martial-arts/pagesA/my-data/my-data.vue

112 lines
3.4 KiB
Vue

<template>
<view>
<status-container titlet="基本资料" returnc="#FFFFFF">
<view slot="content" style="margin-top: -20rpx;">
<view class="bacf pad-x50 pad-zy20">
<view class="pad-sx30 pad-zy10 disjbac bbot">
<view class="fon24 col26">头像</view>
<view class="disac">
<image class="radius_100" :src="userInfo.headimgurl" mode="aspectFill" style="width: 92rpx;height: 92rpx;"></image>
<!-- <view class="icon icon-next fon24 mar-z10" style="color: #7f7f7f;"></view> -->
</view>
</view>
<view class="pad-sx30 fon24 pad-zy10 disjbac bbot">
<view class="col26">昵称</view>
<view class="disac">
<view class="">{{userInfo.nickname}}</view>
<view class="icon icon-next fon24 mar-z10" style="color: #FFFFFF;"></view>
</view>
</view>
<view class="pad-sx30 fon24 pad-zy10 disjbac bbot" @tap="chooseEv(5)">
<view class="col26">真实姓名</view>
<view class="disac">
<view class="">{{realName || '未填写'}}</view>
<view class="icon icon-next fon24 mar-z10" style="color: #7f7f7f;"></view>
</view>
</view>
<view class="pad-sx30 fon24 pad-zy10 disjbac bbot mar-x30" @tap="chooseEv(6)">
<!-- <view class="pad-sx30 fon24 pad-zy10 disjbac bbot mar-x30"> -->
<view class="col26">联系电话</view>
<view class="disac">
<view class="">{{phone || '未填写'}}</view>
<view class="icon icon-next fon24 mar-z10" style="color: #7f7f7f;"></view>
</view>
</view>
</view>
</view>
</status-container>
<dynamic-frame ref="refFrame" :showType="showType" :tipsTitle="tipsTitle" @returnEv="returnEv"></dynamic-frame>
</view>
</template>
<script>
import dynamicFrame from '@/components/dynamic-frame.vue';
export default {
components:{
dynamicFrame
},
data() {
return {
showType:5,
tipsTitle:'真实姓名',
realName:'',//真实姓名字段
phone:'',//联系电话
userInfo:''
}
},
onLoad() {
this.userInfo = uni.getStorageSync('userInfo');
this.realName = this.userInfo.real_name;
this.phone = this.userInfo.mobile;
},
methods: {
// 发起修改
chooseEv(index){
this.showType = index;
this.tipsTitle = index==5?'真实姓名':'电话号码';
this.$refs.refFrame.ifLogistics = true;
this.$refs.refFrame.ifAnimated = true;
if(this.showType==5){
this.$refs.refFrame.dynamicObj.content = this.realName || '';
this.$refs.refFrame.tempText = JSON.parse(JSON.stringify(this.realName || ''));
}
if(this.showType==6){
this.$refs.refFrame.dynamicObj.content = this.phone || '';
this.$refs.refFrame.tempText = JSON.parse(JSON.stringify(this.phone || ''));
}
},
//确认修改
returnEv(obj){
if(this.showType==5){
if(this.realName!=obj.content){
// 如果修改后的跟修改前的不一样
this.setData('real_name',obj.content);
}
this.realName = obj.content;
}
if(this.showType==6){
if(this.phone!=obj.content){
// 如果修改后的跟修改前的不一样
this.setData('mobile',obj.content);
}
this.phone = obj.content;
}
},
// 执行修改事件
setData(field,value){
let params = {
field,
value
}
this.$requst.post('/api/user/update-info',params).then(res=>{
if(res.code==0){
this.$toolAll.tools.showToast('修改成功');
}
})
}
}
}
</script>
<style></style>