user-info.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <view class="flex-common-css bgc-f">
  3. <Nav title="个人资料" titleColor="#333" bgckgroundBox='#fff'></Nav>
  4. <scroll-view :scroll-y="true" class="scroll-view-css">
  5. <view class="user-img-box b-rad-50" @click="goToUrl(0)">
  6. <image class="user-img b-rad-50" :src="userInfoData.head_img" mode="aspectFill"></image>
  7. <image class="set-iimg" src="@/static/img/my/pen.png" mode=""></image>
  8. </view>
  9. <view class="text-align-center" v-if="userInfoData.trace_status == 0 || userInfoData.trace_status == 2">
  10. {{userInfoData.trace_status == 0?'头像审核中,请耐心等待':userInfoData.trace_status == 2?'上传头像违规,请重新上传':''}}
  11. </view>
  12. <view class="item-info-box box-border-box">
  13. <view class="item-box mb-32 flex-justify-space box-border-box">
  14. <view class="item-left fs-32 fc-3">
  15. 昵称
  16. </view>
  17. <view class="item-right align-items-center" @click="goToUrl(1)">
  18. <view class="fc-9198A2 fs-28 mr-6">
  19. {{userInfoData.nickname||''}}
  20. </view>
  21. <uni-icons color="#9198A2" type="right" size="20"></uni-icons>
  22. </view>
  23. </view>
  24. <view class="item-box mb-32 flex-justify-space box-border-box">
  25. <view class="item-left fs-32 fc-3">
  26. 性别
  27. </view>
  28. <view class="item-right align-items-center" @click="goToUrl(2)">
  29. <view v-if="userInfoData.sex == 0" class="fc-9198A2 fs-28 mr-6">保密</view>
  30. <view v-else-if="userInfoData.sex == 1" class="fc-9198A2 fs-28 mr-6">男</view>
  31. <view v-else class="fc-9198A2 fs-28 mr-6">女</view>
  32. <uni-icons color="#9198A2" type="right" size="20"></uni-icons>
  33. </view>
  34. </view>
  35. <view class="item-box mb-32 flex-justify-space box-border-box">
  36. <view class="item-left fs-32 fc-3">
  37. 更换手机号
  38. </view>
  39. <view class="item-right align-items-center" @click="goToUrl(3)">
  40. <view class="fc-9198A2 fs-28 mr-6">
  41. {{userInfoData.phone?userInfoData.phone:'去绑定'}}
  42. </view>
  43. <uni-icons color="#9198A2" type="right" size="20"></uni-icons>
  44. </view>
  45. </view>
  46. </view>
  47. </scroll-view>
  48. </view>
  49. </template>
  50. <script>
  51. import {
  52. userInfo,
  53. userUpdate
  54. } from '@/api/member.js'
  55. import tools from '@/service/tools';
  56. import {
  57. upLoadingFileOss
  58. } from "@/service/upLoadingFile.js";
  59. import {
  60. commonApplet
  61. } from "@/api/common.js"
  62. export default {
  63. data() {
  64. return {
  65. userInfoData: {
  66. nickname: '',
  67. head_img: '',
  68. phone: '',
  69. sex: '',
  70. msg_count: '',
  71. },
  72. setType: 0
  73. };
  74. },
  75. onShow() {
  76. this.getUserInfo();
  77. },
  78. mounted() {
  79. this.commonApplet()
  80. },
  81. methods: {
  82. commonApplet() {
  83. commonApplet().then((res) => {
  84. if (res.code == 1) {
  85. this.setType = res.data
  86. console.log(this.setType, '______________');
  87. this.$forceUpdate()
  88. }
  89. })
  90. },
  91. goToUrl(type) {
  92. if (type === 0) {
  93. if (this.userInfoData.trace_status != 0) {
  94. uni.chooseImage({
  95. count: 1,
  96. sizeType: ["compressed", "camera"],
  97. sourceType: ["album", "camera"],
  98. success: (res) => {
  99. res.tempFiles.forEach((file) => {
  100. this.uploadingFile(file);
  101. })
  102. }
  103. })
  104. }
  105. } else if (type === 1) {
  106. // 昵称
  107. uni.navigateTo({
  108. url: '/pages-my/set-user-name'
  109. })
  110. } else if (type === 2) {
  111. // 性别
  112. uni.navigateTo({
  113. url: '/pages-my/set-user-sex'
  114. })
  115. } else {
  116. // 更换手机号
  117. uni.navigateTo({
  118. url: '/pages-my/set-user-phone'
  119. })
  120. }
  121. },
  122. uploadingFile(file) {
  123. upLoadingFileOss(file.path).then((res) => {
  124. if (res) {
  125. this.userUpdate(res)
  126. } else {
  127. tools.error('图片上传失败')
  128. }
  129. })
  130. },
  131. userUpdate(img) {
  132. userUpdate({
  133. head_img: img
  134. }).then((res) => {
  135. if (res.code == 1) {
  136. tools.success(res.msg)
  137. this.getUserInfo()
  138. } else {
  139. tools.error(res.msg)
  140. }
  141. })
  142. },
  143. getUserInfo() {
  144. userInfo().then((res) => {
  145. if (res.code === 1) {
  146. this.userInfoData = res.data;
  147. }
  148. })
  149. }
  150. },
  151. }
  152. </script>
  153. <style lang="scss" scoped>
  154. .user-img-box {
  155. width: 144rpx;
  156. height: 144rpx;
  157. position: relative;
  158. margin: 98rpx auto 0;
  159. }
  160. .user-img {
  161. width: 100%;
  162. height: 100%;
  163. }
  164. .set-iimg {
  165. position: absolute;
  166. right: 10rpx;
  167. bottom: 2rpx;
  168. width: 33rpx;
  169. height: 33rpx;
  170. }
  171. .item-info-box {
  172. padding: 80rpx 0 0 32rpx;
  173. .item-box {
  174. padding: 0 32rpx 32rpx 0;
  175. border-bottom: 1rpx solid #EEEEEE;
  176. }
  177. }
  178. </style>