setting.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <view class="user-info">
  3. <view class="avatar">
  4. <view class="avatar-text">头像</view>
  5. <view @click="chooseAvatar">
  6. <image :src="avatarUrl" class="avatar-img"></image>
  7. </view>
  8. </view>
  9. <view class="nickname">
  10. <view class="nickname-text">昵称</view>
  11. <input class="nickname-input" type="text" v-model="nickname" placeholder="请输入新昵称" />
  12. </view>
  13. <view class="intro">
  14. <view class="intro-text">简介</view>
  15. <view class="intro-value" @click="editIntro">一句话介绍自己</view>
  16. </view>
  17. <view class="birthday">
  18. <view class="birthday-text">生日</view>
  19. <view class="birthday-value" @click="editBirthday">填写生日有福利</view>
  20. </view>
  21. <view class="address">
  22. <view class="address-text">收货地址</view>
  23. <view class="address-value" @click="editAddress">修改/添加</view>
  24. </view>
  25. <view class="confirm-btn" @click="saveAndBack">确定修改</view>
  26. </view>
  27. </template>
  28. <script>
  29. import {mapState,mapMutations,mapGetters} from 'vuex'
  30. export default {
  31. data() {
  32. return {
  33. avatarUrl: '../../static/avator/1.jpg',
  34. nickname: 'ST [渔夺]'
  35. };
  36. },
  37. methods: {
  38. ...mapMutations('m_user', ['updateUserName','updateAvatarUrl']),
  39. chooseAvatar() {
  40. uni.chooseImage({
  41. count: 1,
  42. sizeType: ['original', 'compressed'],
  43. sourceType: ['album'],
  44. success: (res) => {
  45. this.avatarUrl = res.tempFilePaths[0];
  46. }
  47. });
  48. },
  49. editIntro() {
  50. // 处理编辑简介的逻辑
  51. },
  52. editBirthday() {
  53. // 处理编辑生日的逻辑
  54. },
  55. editAddress() {
  56. // 处理编辑收货地址的逻辑
  57. },
  58. saveAndBack() {
  59. // 保存数据的逻辑
  60. // ...
  61. this.updateUserName(this.nickname)
  62. this.updateAvatarUrl(this.avatarUrl)
  63. // 返回上一层页面
  64. uni.navigateBack();
  65. }
  66. },
  67. }
  68. </script>
  69. <style lang="scss">
  70. .user-info {
  71. padding: 40rpx;
  72. background-color: #fff;
  73. .avatar,
  74. .nickname,
  75. .intro,
  76. .birthday,
  77. .address {
  78. display: flex;
  79. align-items: center;
  80. margin-bottom: 40rpx;
  81. &-text {
  82. font-weight: bold;
  83. margin-right: 20rpx;
  84. color: #333;
  85. }
  86. &-value {
  87. flex: 1;
  88. text-align: right;
  89. color: #666;
  90. }
  91. }
  92. .avatar {
  93. .avatar-img {
  94. width: 120rpx;
  95. height: 120rpx;
  96. border-radius: 50%;
  97. }
  98. }
  99. .nickname {
  100. .nickname-input {
  101. flex: 1;
  102. text-align: right;
  103. font-size: 36rpx;
  104. color: #333;
  105. }
  106. }
  107. .confirm-btn {
  108. margin-top: 40rpx;
  109. background-color: #07c160;
  110. color: #fff;
  111. font-size: 32rpx;
  112. text-align: center;
  113. padding: 20rpx;
  114. border-radius: 10rpx;
  115. }
  116. }
  117. </style>