| | |
| | | |
| | | <view class="content"> |
| | | <view class="avatar"> |
| | | <image :src="userInfo.avatar" class="avatar-image" mode=""></image> |
| | | <image :src="detail.avatar" class="avatar-image" mode=""></image> |
| | | <view class="a" @click="handleChooseImg">更换头像</view> |
| | | </view> |
| | | <view class="form"> |
| | | <view class="cell"> |
| | | <view class="name">昵称</view> |
| | | <input type="text" placeholder="请输入昵称" v-model="userInfo.nick_name" class="ipt" |
| | | <view class="name">姓名</view> |
| | | <input type="text" placeholder="请输入姓名" v-model="detail.nick_name" class="ipt" |
| | | placeholder-class="hold" /> |
| | | </view> |
| | | <view class="cell"> |
| | | <view class="name">生日</view> |
| | | <picker mode="date" class="ipt" :class="{ hold: !detail.birthday }" |
| | | @change="changeDefaultPicker('birthday', $event)"> |
| | | <view>{{ detail.birthday || '请选择生日' }}</view> |
| | | </picker> |
| | | </view> |
| | | <view class="cell"> |
| | | <view class="name">性别</view> |
| | | <picker mode="selector" :range="sexPicker" range-key="name" class="ipt" |
| | | :class="{ hold: !detail.sex }" @change="changePicker('sex', $event)"> |
| | | <view>{{ detail.sex === 1?'男':'女' || '请选择性别' }}</view> |
| | | </picker> |
| | | </view> |
| | | <view class="cell"> |
| | | <view class="name">手机号</view> |
| | | <input type="number" placeholder="请填写手机号" v-model="detail.phone" class="ipt" |
| | | placeholder-class="hold" /> |
| | | </view> |
| | | <view class="cell"> |
| | | <view class="name">邮箱</view> |
| | | <input v-model="detail.email" class="ipt" placeholder-class="hold" /> |
| | | </view> |
| | | <!--<view class="cell"> |
| | | <view class="name">国家/地区</view> |
| | | <pickRegions :defaultRegion="detail.region" v-model="detail.region" |
| | | :class="{ hold: !detail.region, ipt: true }"> |
| | | <view>{{ detail.region || '请选择国家/地区' }}</view> |
| | | </pickRegions> |
| | | </view>--> |
| | | </view> |
| | | </view> |
| | | <!-- --> |
| | | <view class="back" @click="logout">退出登录</view> |
| | | <view> |
| | | <u-toast ref="uToast" /> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | |
| | | }; |
| | | }, |
| | | onLoad() { |
| | | this.$u.api.userInfo().then(data => { |
| | | console.log(data); |
| | | if (data.success) { |
| | | this.detail = data.data; |
| | | } |
| | | }).catch(err => { |
| | | console.log(err) |
| | | this.$u.func.showToast({ |
| | | title: err, |
| | | }) |
| | | }) |
| | | |
| | | if (this.$store.state |
| | | .UserData) { |
| | | this.detail = this.$store.state |
| | | .UserData |
| | | } |
| | | |
| | | }, |
| | | methods: { |
| | | logout() { |
| | | this.$u.func.logout(); |
| | | }, |
| | | submit() { |
| | | let detail = this.detail |
| | | if (!detail.phone && !/^1\d{10}$/.test(detail.phone)) { |
| | | return uni.showToast({ |
| | | title: '请输入正确的手机号', |
| | | duration: 2000, |
| | | icon: 'none' |
| | | }); |
| | | } |
| | | console.log(JSON.stringify(detail)); |
| | | // let detail = this.detail |
| | | // if (!detail.phone && !/^1\d{10}$/.test(detail.phone)) { |
| | | // return uni.showToast({ |
| | | // title: '请输入正确的手机号', |
| | | // duration: 2000, |
| | | // icon: 'none' |
| | | // }); |
| | | // } |
| | | var that = this; |
| | | uni.request({ |
| | | url: this.$store.state.piAPI + "/blade-user/update-info", |
| | | method: "post", |
| | | data: { |
| | | realName: this.detail.nick_name, |
| | | avatar: this.detail.avatar, |
| | | id: this.detail.user_id |
| | | }, |
| | | success: (res) => { |
| | | console.log(res, 885858884488) |
| | | if (res.data.msg == "操作成功") { |
| | | that.$refs.uToast.show({ |
| | | title: '修改成功', |
| | | type: 'success', |
| | | callback: () => { |
| | | uni.navigateBack(); |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | }); |
| | | |
| | | }, |
| | | changeDefaultPicker(name, e) { |
| | | this.detail[name] = e.detail.value; |