Info.vue 4.6 KB

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