123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <template>
- <view class="user-info">
- <view class="avatar">
- <view class="avatar-text">头像</view>
- <view @click="chooseAvatar">
- <image :src="avatarUrl" class="avatar-img"></image>
- </view>
- </view>
- <view class="nickname">
- <view class="nickname-text">昵称</view>
- <input class="nickname-input" type="text" v-model="nickname" placeholder="请输入新昵称" />
- </view>
- <view class="intro">
- <view class="intro-text">简介</view>
- <view class="intro-value" @click="editIntro">一句话介绍自己</view>
- </view>
- <view class="birthday">
- <view class="birthday-text">生日</view>
- <view class="birthday-value" @click="editBirthday">填写生日有福利</view>
- </view>
- <view class="address">
- <view class="address-text">收货地址</view>
- <view class="address-value" @click="editAddress">修改/添加</view>
- </view>
- <view class="confirm-btn" @click="saveAndBack">确定修改</view>
- </view>
- </template>
- <script>
- import {mapState,mapMutations,mapGetters} from 'vuex'
- export default {
- data() {
- return {
- avatarUrl: '../../static/avator/1.jpg',
- nickname: 'ST [渔夺]'
- };
- },
- methods: {
- ...mapMutations('m_user', ['updateUserName','updateAvatarUrl']),
- chooseAvatar() {
- uni.chooseImage({
- count: 1,
- sizeType: ['original', 'compressed'],
- sourceType: ['album'],
- success: (res) => {
- this.avatarUrl = res.tempFilePaths[0];
- }
- });
- },
- editIntro() {
- // 处理编辑简介的逻辑
- },
- editBirthday() {
- // 处理编辑生日的逻辑
- },
- editAddress() {
- // 处理编辑收货地址的逻辑
- },
- saveAndBack() {
- // 保存数据的逻辑
- // ...
- this.updateUserName(this.nickname)
- this.updateAvatarUrl(this.avatarUrl)
- // 返回上一层页面
- uni.navigateBack();
- }
- },
- }
- </script>
- <style lang="scss">
- .user-info {
- padding: 40rpx;
- background-color: #fff;
- .avatar,
- .nickname,
- .intro,
- .birthday,
- .address {
- display: flex;
- align-items: center;
- margin-bottom: 40rpx;
- &-text {
- font-weight: bold;
- margin-right: 20rpx;
- color: #333;
- }
- &-value {
- flex: 1;
- text-align: right;
- color: #666;
- }
- }
- .avatar {
- .avatar-img {
- width: 120rpx;
- height: 120rpx;
- border-radius: 50%;
- }
- }
- .nickname {
- .nickname-input {
- flex: 1;
- text-align: right;
- font-size: 36rpx;
- color: #333;
- }
- }
- .confirm-btn {
- margin-top: 40rpx;
- background-color: #07c160;
- color: #fff;
- font-size: 32rpx;
- text-align: center;
- padding: 20rpx;
- border-radius: 10rpx;
- }
- }
- </style>
|