user-info.vue 4.7 KB

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