Info.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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/*"
  9. @change="uploadImg"
  10. multiple
  11. />
  12. <span><i class="iconfont icon-tuxiang-" style="font-size: .29rem;"></i>头像:</span>
  13. <span class="describe"><img :src="imageUploadUrl ? imageUploadUrl : info.imageUrl ? info.imageUrl : '/images/component/default.png'" alt="">
  14. <i class="iconfont icon-xiangyou"></i></span>
  15. </div>
  16. <div class="line">
  17. <span><i class="iconfont icon-yonghuming"></i>用户名:</span>
  18. <span class="describe">{{info.userName}}</span>
  19. </div>
  20. <div class="line" @click="jumpSet('email')">
  21. <span><i class="iconfont icon-youxiang"></i>邮箱:</span>
  22. <span class="describe">{{info.userEmail}}
  23. <i class="iconfont icon-xiangyou"></i>
  24. </span>
  25. </div>
  26. <div class="line" @click="jumpSet('mobile')">
  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. mounted: function () {
  49. this.$nextTick(() => {
  50. if (!this.$store.state.option.user.logged) {
  51. this.$router.push('/auth/login?returnUrl=' + window.location.href)
  52. }
  53. })
  54. },
  55. computed: {
  56. getEmail () {
  57. return this.$store.state.user.updateUser.email.data.content
  58. },
  59. getMobile () {
  60. return this.$store.state.user.updateUser.mobile.data.content
  61. }
  62. },
  63. methods: {
  64. uploadImg (e) {
  65. let file = e.target.files[0]
  66. if (file) {
  67. let param = new FormData()
  68. param.append('image', file, file.name)
  69. let config = {
  70. headers: {'Content-Type': 'multipart/form-data'}
  71. }
  72. this.$http.post('/api/images', param, config)
  73. .then(response => {
  74. if (response.data) {
  75. let imageUrl = response.data[0].path
  76. this.$http.post('/basic/user/setImageUrl', {imageUrl: imageUrl})
  77. .then(response => {
  78. if (response.data) {
  79. this.imageUploadUrl = response.data.imageUrl
  80. this.$store.dispatch('loadUserInfo')
  81. }
  82. })
  83. }
  84. })
  85. }
  86. },
  87. jumpSet (info) {
  88. if (info === 'email') {
  89. window.location.href = decodeURIComponent(this.getEmail)
  90. } else if (info === 'mobile') {
  91. window.location.href = decodeURIComponent(this.getMobile)
  92. }
  93. }
  94. }
  95. }
  96. </script>
  97. <style lang="scss">
  98. .mobile-fix-content {
  99. background: #f1f3f6;
  100. }
  101. .user-info {
  102. .info {
  103. width: 7.1rem;
  104. background: #fff;
  105. margin: 0 auto;
  106. height: 4.66rem;
  107. padding: 0 .24rem;
  108. font-size: .28rem;
  109. color: #999;
  110. border-radius: .05rem;
  111. margin-top: .3rem;
  112. .line {
  113. position: relative;
  114. overflow: hidden;
  115. text-overflow: ellipsis;
  116. white-space: nowrap;
  117. height: 1.16rem;
  118. line-height: 1.16rem;
  119. border-bottom: .01rem solid #d9d9d9;
  120. &:last-child {
  121. border-bottom: none;
  122. }
  123. input{
  124. position: absolute;
  125. top: 0;
  126. left: 0;
  127. height: 1.16rem;
  128. width: 100%;
  129. opacity: 0;
  130. }
  131. span{
  132. display: inline-block;
  133. font-size: 0.28rem;
  134. color: #226ce7;
  135. text-align: left;
  136. i{
  137. margin-right: .15rem;
  138. font-size: .3rem;
  139. color: #f8953c;
  140. }
  141. }
  142. span.describe {
  143. float: right;
  144. color: #333;
  145. i{
  146. margin: 0 0 0 .1rem;
  147. font-size: .24rem;
  148. color: #bebebe;
  149. }
  150. img{
  151. width: .58rem;
  152. height: .58rem;
  153. /*border: 1px solid #bebebe;*/
  154. }
  155. }
  156. }
  157. }
  158. }
  159. </style>