Info.vue 4.2 KB

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