user-info.vue 4.1 KB

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