info.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <view style="padding: 20px;">
  3. <uni-forms :modelValue="postForm" ref="form" :label-width="100">
  4. <uni-forms-item label="ID">
  5. <uni-easyinput type="text" v-model="postForm.id" disabled />
  6. </uni-forms-item>
  7. <uni-forms-item label="用户名">
  8. <uni-easyinput type="text" v-model="postForm.userName" disabled />
  9. </uni-forms-item>
  10. <uni-forms-item label="用户头像">
  11. <yf-file-upload v-model="postForm.avatar"></yf-file-upload>
  12. </uni-forms-item>
  13. <uni-forms-item label="人脸照片">
  14. <yf-file-upload v-model="postForm.face"></yf-file-upload>
  15. </uni-forms-item>
  16. <uni-forms-item label="姓名">
  17. <uni-easyinput type="text" v-model="postForm.realName" placeholder="请输入姓名" />
  18. </uni-forms-item>
  19. <uni-forms-item label="身份证号">
  20. <uni-easyinput type="number" v-model="postForm.idCard" placeholder="请输入身份证号" />
  21. </uni-forms-item>
  22. <uni-forms-item label="手机号">
  23. <view v-if="postForm.mobile" class="mv-box">
  24. <view>
  25. {{ postForm.mobile }}
  26. </view>
  27. <view class="btn">
  28. <button type="warn" size="mini" @click="bindMobile">解绑</button>
  29. </view>
  30. </view>
  31. <view v-else>
  32. <button type="primary" size="mini" @click="bindMobile">绑定</button>
  33. </view>
  34. </uni-forms-item>
  35. <uni-forms-item label="邮箱">
  36. <uni-easyinput type="text" v-model="postForm.email" placeholder="请输入邮箱" />
  37. </uni-forms-item>
  38. </uni-forms>
  39. <button type="primary" @click="handleUpdate()">保存资料</button>
  40. </view>
  41. </template>
  42. <script>
  43. import { info, update } from '@/api/user'
  44. export default {
  45. data() {
  46. return {
  47. postForm: {
  48. avatar: '',
  49. face: ''
  50. }
  51. }
  52. },
  53. mounted() {
  54. this.handleInfo()
  55. },
  56. methods: {
  57. handleInfo() {
  58. let token = uni.getStorageSync('token');
  59. info(token).then(res => {
  60. this.postForm = res
  61. })
  62. },
  63. handleUpdate() {
  64. uni.showLoading()
  65. update(this.postForm).then(() => {
  66. uni.showToast({
  67. title: '资料更新成功!'
  68. })
  69. uni.hideLoading()
  70. setTimeout(()=>{
  71. uni.switchTab({
  72. url: '/pages/user/index'
  73. })
  74. }, 2000)
  75. })
  76. },
  77. bindMobile() {
  78. uni.navigateTo({
  79. url: `/pages/user/info/bind-mobile?type=${this.postForm.mobile?0:1}&mobile=${this.postForm.mobile|| ''}`
  80. })
  81. },
  82. }
  83. }
  84. </script>
  85. <style>
  86. .user-banner {
  87. height: 160px;
  88. display: flex;
  89. background: url('https://cdn.yfhl.net/static/user-bg.jpg') no-repeat;
  90. align-items: center;
  91. background-position: center;
  92. background-size: 100%;
  93. justify-content: center;
  94. width: 100%;
  95. flex-direction: column;
  96. }
  97. .user-banner .avatar {
  98. width: 80px;
  99. height: 80px;
  100. border: #3771CF 2px solid;
  101. border-radius: 50%;
  102. }
  103. .user-banner .points {
  104. position: absolute;
  105. top: 15px;
  106. right: 15px;
  107. color: #FDBF40;
  108. font-weight: bold;
  109. font-weight: 700;
  110. font-size: 16px;
  111. }
  112. .user-banner .name {
  113. color: #fff;
  114. font-weight: 700;
  115. font-size: 18px;
  116. }
  117. .user-banner .dept {
  118. color: #eee;
  119. font-weight: 700;
  120. font-size: 14px;
  121. }
  122. .mv-box{
  123. font-size: 16px;
  124. font-weight: 700;
  125. display: flex;
  126. align-items: center;
  127. }
  128. .mv-box .btn{
  129. margin-left: 10px;
  130. display: flex;
  131. align-items: center;
  132. }
  133. </style>