user-info.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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 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. export default {
  57. data() {
  58. return {
  59. userInfoData: {
  60. nickname: '',
  61. head_img: '',
  62. phone: '',
  63. sex: '',
  64. msg_count: '',
  65. },
  66. };
  67. },
  68. onShow() {
  69. this.getUserInfo();
  70. },
  71. methods: {
  72. goToUrl(type) {
  73. if (type === 0) {
  74. uni.chooseImage({
  75. count: 1,
  76. sizeType: ["compressed", "camera"],
  77. sourceType: ["album", "camera"],
  78. success: (res) => {
  79. res.tempFiles.forEach((file) => {
  80. this.uploadingFile(file);
  81. })
  82. }
  83. })
  84. } else if (type === 1) {
  85. // 昵称
  86. uni.navigateTo({
  87. url: '/pages-my/set-user-name'
  88. })
  89. } else if (type === 2) {
  90. // 性别
  91. uni.navigateTo({
  92. url: '/pages-my/set-user-sex'
  93. })
  94. } else {
  95. // 更换手机号
  96. uni.navigateTo({
  97. url: '/pages-my/set-user-phone'
  98. })
  99. }
  100. },
  101. uploadingFile(file) {
  102. upLoadingFileOss(file.path).then((res) => {
  103. if (res) {
  104. this.userUpdate(res)
  105. } else {
  106. tools.error('图片上传失败')
  107. }
  108. })
  109. },
  110. userUpdate(img) {
  111. userUpdate({
  112. head_img: img
  113. }).then((res) => {
  114. if (res.code == 1) {
  115. tools.success(res.msg)
  116. this.getUserInfo()
  117. } else {
  118. tools.error(res.msg)
  119. }
  120. })
  121. },
  122. getUserInfo() {
  123. userInfo().then((res) => {
  124. if (res.code === 1) {
  125. this.userInfoData = res.data;
  126. }
  127. })
  128. }
  129. },
  130. }
  131. </script>
  132. <style lang="scss" scoped>
  133. .user-img-box {
  134. width: 144rpx;
  135. height: 144rpx;
  136. position: relative;
  137. margin: 98rpx auto 80rpx;
  138. }
  139. .user-img {
  140. width: 100%;
  141. height: 100%;
  142. }
  143. .set-iimg {
  144. position: absolute;
  145. right: 10rpx;
  146. bottom: 2rpx;
  147. width: 33rpx;
  148. height: 33rpx;
  149. }
  150. .item-info-box {
  151. padding: 0 0 0 32rpx;
  152. .item-box {
  153. padding: 0 32rpx 32rpx 0;
  154. border-bottom: 1rpx solid #EEEEEE;
  155. }
  156. }
  157. </style>