Info.vue 3.9 KB

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