Info.vue 4.0 KB

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