宜轩到家/服务到家第三版,换个颜色
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

207 lines
5.0 KiB

7 months ago
  1. <template>
  2. <view class="setting">
  3. <mNavbar title="设置" :leftClick="leftClick"></mNavbar>
  4. <van-cell-group>
  5. <van-cell @click="fileUploads" title="头像" style="display: flex;align-items: center;" is-link>
  6. <template #value>
  7. <image style="width: 118rpx;height: 118rpx;border-radius: 50%;" mode="aspectFill" :src="userInfo.image"></image>
  8. </template>
  9. </van-cell>
  10. <van-cell title="昵称" :value="userInfo.title" @click="showBottom = true" is-link></van-cell>
  11. <van-cell title="性别" :value="userInfo.sex || '暂无'" @click="changeGenderShow = true" is-link></van-cell>
  12. </van-cell-group>
  13. <van-cell-group style="margin-top: 10rpx;">
  14. <!-- <van-cell title="手机号" :value="userInfo.phone || '未绑定'" @click="toPhoneDetail" is-link></van-cell> -->
  15. <van-cell title="用户协议" @click="keyValue = 'protocol';configPopupShow = true" is-link></van-cell>
  16. <van-cell title="隐私政策" @click="keyValue = 'policy';configPopupShow = true" is-link></van-cell>
  17. <van-cell title="关于我们" @click="keyValue = 'we';configPopupShow = true" is-link></van-cell>
  18. </van-cell-group>
  19. <configPopup :keyValue="keyValue" :show="configPopupShow" :list="config" @close="configPopupShow = false" />
  20. <van-popup v-model:show="showBottom" round position="bottom" @close="showBottom = false">
  21. <view style="padding: 20rpx;">
  22. <view style="text-align: center;font-size: 35rpx;">修改昵称</view>
  23. <view class="item-line flex">
  24. <view class="before"></view>
  25. <view class="label">用户昵称</view>
  26. <input v-model="userInfo.title" placeholder="请输入昵称" />
  27. </view>
  28. <view @click="editNickName" class="button-submit">立即修改</view>
  29. </view>
  30. </van-popup>
  31. <van-action-sheet v-model:show="changeGenderShow" :actions="actions" @select="selectGender" />
  32. </view>
  33. </template>
  34. <script>
  35. import mNavbar from '@/components/base/m-navbar.vue'
  36. import configPopup from '@/components/configPopup'
  37. import OSS from "ali-oss"
  38. import { v4 as uuidv4 } from 'uuid';
  39. export default {
  40. components: { mNavbar, configPopup },
  41. data() {
  42. return {
  43. userInfo: {},
  44. configPopupShow: false,
  45. keyValue: '',
  46. config: [],
  47. showBottom: false,
  48. changeGenderShow: false,
  49. actions: [
  50. { name: '男' },
  51. {name: '女'},
  52. {name: '未知'}
  53. ]
  54. }
  55. },
  56. onShow() {
  57. this.getUserInfo()
  58. this.getConfig()
  59. },
  60. methods: {
  61. //返回个人中心
  62. leftClick() {
  63. uni.switchTab({
  64. url: '/pages/index/center'
  65. })
  66. },
  67. //获取用户信息
  68. getUserInfo() {
  69. this.$api('giveTenInfo', {}, res => {
  70. if (res.code == 200) {
  71. this.userInfo = res.result.msgTen;
  72. }
  73. })
  74. },
  75. //获取配置
  76. getConfig() {
  77. this.$api('getConfig', {}, res => {
  78. if (res.code == 200) {
  79. this.config = res.result
  80. }
  81. })
  82. },
  83. //选择性别
  84. selectGender(val) {
  85. this.userInfo.sex = val.name;
  86. this.editNickName();
  87. this.changeGenderShow = false;
  88. },
  89. //修改用户信息
  90. editNickName() {
  91. let data = {
  92. nickName: this.userInfo.title,
  93. sex : this.userInfo.sex,
  94. avatarUrl : this.userInfo.image,
  95. }
  96. this.$api('editUserInfo', data , res => {
  97. if (res.code == 200) {
  98. this.showBottom = false;
  99. uni.showToast({
  100. title : '修改成功',
  101. icon : 'none'
  102. })
  103. this.getUserInfo();
  104. }
  105. })
  106. },
  107. //上传文件
  108. fileUploads() {
  109. uni.chooseImage({
  110. count: 1, // 默认9,设置为1表示单选
  111. sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
  112. sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
  113. success: (res) => {
  114. let resultPromise = [];
  115. this.uploadFileToOSS(res.tempFiles[0]).then(imgPath => {
  116. this.userInfo.image = imgPath;
  117. this.editNickName();
  118. })
  119. }
  120. });
  121. }
  122. }
  123. }
  124. </script>
  125. <style scoped lang="scss">
  126. .setting {
  127. background-color: #f3f3f3;
  128. min-height: calc(100vh);
  129. .item-line {
  130. height: 60rpx;
  131. line-height: 60rpx;
  132. font-size: 28rpx;
  133. font-family: PingFang SC, PingFang SC-Bold;
  134. font-weight: 700;
  135. text-align: left;
  136. color: #333333;
  137. margin-top: 40rpx;
  138. }
  139. .item-line .before {
  140. width: 8rpx;
  141. height: 30rpx;
  142. background: $uni-color;
  143. border-radius: 4rpx;
  144. margin: 15rpx 12rpx 15rpx 0;
  145. }
  146. .item-line .label {
  147. width: 152rpx;
  148. height: 60rpx;
  149. }
  150. .item-line input {
  151. width: 456rpx;
  152. height: 60rpx;
  153. line-height: 60rpx;
  154. background: #f5f5f5;
  155. border-radius: 12rpx;
  156. font-size: 24rpx;
  157. font-family: PingFang SC, PingFang SC-Medium;
  158. font-weight: 500;
  159. text-align: left;
  160. color: #939393;
  161. padding: 0 20rpx;
  162. }
  163. .button-submit {
  164. width: 596rpx;
  165. height: 90rpx;
  166. line-height: 90rpx;
  167. border-radius: 46rpx;
  168. margin: 40rpx auto;
  169. font-size: 28rpx;
  170. font-family: PingFang SC, PingFang SC-Regular;
  171. font-weight: 400;
  172. text-align: center;
  173. color: $uni-color;
  174. background: $uni-bg-color;
  175. }
  176. }
  177. </style>