Info.vue 4.6 KB

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