Info.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <div class="mobile-fix-content">
  3. <div class="info">
  4. <div class="line">
  5. <input type="file"
  6. class="file-input"
  7. name="name"
  8. accept="image/jpeg,image/jpg,image/gif,image/bmp,image/png"
  9. @change="uploadImg"/>
  10. <span><i class="iconfont icon-tuxiang-" style="font-size: .29rem;"></i>头像:</span>
  11. <span class="describe"><img :src="imageUploadUrl ? imageUploadUrl : info.imageUrl ? info.imageUrl : '/images/component/default.png'" alt="">
  12. <i class="iconfont icon-xiangyou"></i></span>
  13. </div>
  14. <div class="line">
  15. <span><i class="iconfont icon-yonghuming"></i>用户名:</span>
  16. <span class="describe">{{info.userName}}</span>
  17. </div>
  18. <div class="line" @click="jumpSet('email')">
  19. <span><i class="iconfont icon-youxiang"></i>邮箱:</span>
  20. <span class="describe">{{info.userEmail}}
  21. <i class="iconfont icon-xiangyou"></i>
  22. </span>
  23. </div>
  24. <div class="line" @click="jumpSet('mobile')">
  25. <span><i class="iconfont icon-shouji"></i>手机:</span>
  26. <span class="describe">{{info.userTel}}
  27. <i class="iconfont icon-xiangyou"></i>
  28. </span>
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. export default {
  35. props: {
  36. info: {
  37. default: {},
  38. type: Object
  39. }
  40. },
  41. data () {
  42. return {
  43. imageUploadUrl: ''
  44. }
  45. },
  46. mounted: function () {
  47. this.$nextTick(() => {
  48. if (!this.$store.state.option.user.logged) {
  49. this.$router.push('/auth/login?returnUrl=' + window.location.href)
  50. }
  51. })
  52. },
  53. computed: {
  54. getEmail () {
  55. return this.$store.state.user.updateUser.email.data.content
  56. },
  57. getMobile () {
  58. return this.$store.state.user.updateUser.mobile.data.content
  59. }
  60. },
  61. methods: {
  62. uploadImg (e) {
  63. let file = e.target.files[0]
  64. if (file) {
  65. let param = new FormData()
  66. param.append('image', file, file.name)
  67. let config = {
  68. headers: {'Content-Type': 'multipart/form-data'}
  69. }
  70. this.$http.post('/api/images', param, config)
  71. .then(response => {
  72. if (response.data) {
  73. let imageUrl = response.data[0].path
  74. this.$http.post('/basic/user/setImageUrl', {imageUrl: imageUrl})
  75. .then(response => {
  76. if (response.data) {
  77. this.imageUploadUrl = response.data.imageUrl
  78. this.$store.dispatch('loadUserInfo')
  79. }
  80. })
  81. }
  82. })
  83. }
  84. },
  85. jumpSet (info) {
  86. if (info === 'email') {
  87. window.location.href = decodeURIComponent(this.getEmail)
  88. } else if (info === 'mobile') {
  89. window.location.href = decodeURIComponent(this.getMobile)
  90. }
  91. }
  92. }
  93. }
  94. </script>
  95. <style lang="scss">
  96. .mobile-fix-content {
  97. background: #f1f3f6;
  98. }
  99. .info {
  100. width: 7.1rem;
  101. background: #fff;
  102. margin: 0 auto;
  103. height: 4.66rem;
  104. padding: 0 .24rem;
  105. font-size: .28rem;
  106. color: #999;
  107. border-radius: .05rem;
  108. margin-top: .3rem;
  109. .line {
  110. position: relative;
  111. overflow: hidden;
  112. text-overflow: ellipsis;
  113. white-space: nowrap;
  114. height: 1.16rem;
  115. line-height: 1.16rem;
  116. border-bottom: .01rem solid #d9d9d9;
  117. &:last-child {
  118. border-bottom: none;
  119. }
  120. input{
  121. position: absolute;
  122. top: 0;
  123. left: 0;
  124. height: 1.16rem;
  125. width: 100%;
  126. opacity: 0;
  127. }
  128. span{
  129. display: inline-block;
  130. font-size: 0.28rem;
  131. color: #226ce7;
  132. text-align: left;
  133. i{
  134. margin-right: .15rem;
  135. font-size: .3rem;
  136. color: #f8953c;
  137. }
  138. }
  139. span.describe {
  140. float: right;
  141. color: #333;
  142. i{
  143. margin: 0 0 0 .1rem;
  144. font-size: .24rem;
  145. color: #bebebe;
  146. }
  147. img{
  148. width: .58rem;
  149. height: .58rem;
  150. /*border: 1px solid #bebebe;*/
  151. }
  152. }
  153. }
  154. }
  155. </style>