Info.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. <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. .info {
  95. width: 7.1rem;
  96. background: #fff;
  97. margin: 0 auto;
  98. height: 4.66rem;
  99. padding: 0 .24rem;
  100. font-size: .28rem;
  101. color: #999;
  102. border-radius: .05rem;
  103. margin-top: .3rem;
  104. .line {
  105. position: relative;
  106. overflow: hidden;
  107. text-overflow: ellipsis;
  108. white-space: nowrap;
  109. height: 1.16rem;
  110. line-height: 1.16rem;
  111. border-bottom: .01rem solid #d9d9d9;
  112. &:last-child {
  113. border-bottom: none;
  114. }
  115. input{
  116. position: absolute;
  117. top: 0;
  118. left: 0;
  119. height: 1.16rem;
  120. width: 100%;
  121. opacity: 0;
  122. }
  123. span{
  124. display: inline-block;
  125. font-size: 0.28rem;
  126. color: #999;
  127. text-align: left;
  128. i{
  129. margin-right: .15rem;
  130. font-size: .3rem;
  131. color: #f8953c;
  132. }
  133. }
  134. span.describe {
  135. float: right;
  136. color: #333;
  137. i{
  138. margin: 0 0 0 .1rem;
  139. font-size: .24rem;
  140. color: #bebebe;
  141. }
  142. img{
  143. width: .58rem;
  144. height: .58rem;
  145. /*border: 1px solid #bebebe;*/
  146. }
  147. }
  148. }
  149. }
  150. </style>