Info.vue 3.8 KB

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