user-info.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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.uploadingFile(e.detail.avatarUrl)
  85. // this.userUpdate()
  86. console.log(e);
  87. },
  88. commonApplet() {
  89. commonApplet().then((res) => {
  90. if (res.code == 1) {
  91. this.setType = res.data
  92. console.log(this.setType, '______________');
  93. this.$forceUpdate()
  94. }
  95. })
  96. },
  97. goToUrl(type) {
  98. if (type === 0) {
  99. if (this.userInfoData.trace_status != 0) {
  100. uni.chooseImage({
  101. count: 1,
  102. sizeType: ["compressed", "camera"],
  103. sourceType: ["album", "camera"],
  104. success: (res) => {
  105. res.tempFiles.forEach((file) => {
  106. this.uploadingFile(file);
  107. })
  108. }
  109. })
  110. }
  111. } else if (type === 1) {
  112. // 昵称
  113. uni.navigateTo({
  114. url: '/pages-my/set-user-name'
  115. })
  116. } else if (type === 2) {
  117. // 性别
  118. uni.navigateTo({
  119. url: '/pages-my/set-user-sex'
  120. })
  121. } else {
  122. // 更换手机号
  123. uni.navigateTo({
  124. url: '/pages-my/set-user-phone'
  125. })
  126. }
  127. },
  128. uploadingFile(file) {
  129. console.log(file,'------------------');
  130. upLoadingFileOss(file).then((res) => {
  131. if (res) {
  132. this.userUpdate(res)
  133. } else {
  134. tools.error('图片上传失败')
  135. }
  136. })
  137. },
  138. userUpdate(img) {
  139. userUpdate({
  140. head_img: img
  141. }).then((res) => {
  142. if (res.code == 1) {
  143. tools.success(res.msg)
  144. this.getUserInfo()
  145. } else {
  146. tools.error(res.msg)
  147. }
  148. })
  149. },
  150. getUserInfo() {
  151. userInfo().then((res) => {
  152. if (res.code === 1) {
  153. this.userInfoData = res.data;
  154. }
  155. })
  156. }
  157. },
  158. }
  159. </script>
  160. <style lang="scss" scoped>
  161. .user-img-box {
  162. width: 144rpx;
  163. height: 144rpx;
  164. position: relative;
  165. margin: 98rpx auto 0;
  166. }
  167. .but-box {
  168. width: 144rpx;
  169. height: 144rpx;
  170. position: absolute;
  171. left: 0;
  172. top: 0;
  173. background: transparent;
  174. border: none;
  175. border-radius: 50%;
  176. }
  177. .user-img {
  178. width: 100%;
  179. height: 100%;
  180. }
  181. .set-iimg {
  182. position: absolute;
  183. right: 10rpx;
  184. bottom: 2rpx;
  185. width: 33rpx;
  186. height: 33rpx;
  187. }
  188. .item-info-box {
  189. padding: 80rpx 0 0 32rpx;
  190. .item-box {
  191. padding: 0 32rpx 32rpx 0;
  192. border-bottom: 1rpx solid #EEEEEE;
  193. }
  194. }
  195. </style>