86 lines
1.7 KiB
JavaScript
86 lines
1.7 KiB
JavaScript
import _ from '../../commons/js/commons'
|
|
const app = getApp()
|
|
Component({
|
|
properties: {
|
|
isShow: {
|
|
type:Boolean,
|
|
value:false
|
|
},
|
|
},
|
|
data: {
|
|
mobileNumber: '',
|
|
},
|
|
|
|
lifetimes: {
|
|
attached: function () {
|
|
let userInfo = app.getStorageByKey("userInfo");
|
|
if (!!userInfo) {
|
|
this.setData({
|
|
userInfo: userInfo,
|
|
mobileNumber: !!userInfo.tel ? userInfo.tel : userInfo.mobile,
|
|
})
|
|
} else {
|
|
this.getUserInfo()
|
|
}
|
|
},
|
|
detached: function () {
|
|
// 在组件实例被从页面节点树移除时执行
|
|
},
|
|
},
|
|
ready: function () {},
|
|
methods: {
|
|
onClose() {
|
|
this.setData({
|
|
isShow: false
|
|
})
|
|
},
|
|
|
|
// 输入
|
|
inputTx(e) {
|
|
this.setData({
|
|
[e.currentTarget.dataset.key]: e.detail.value
|
|
})
|
|
},
|
|
|
|
//用户信息
|
|
getUserInfo() {
|
|
let params = {};
|
|
params['biz_id'] = 0;
|
|
_.apiQuery.getUserInfo(params, false).then(res => {
|
|
this.setData({
|
|
userInfo: res,
|
|
mobileNumber: !!res.tel ? res.tel : res.mobile,
|
|
})
|
|
});
|
|
},
|
|
|
|
//保存手机号
|
|
putAppUserTel() {
|
|
if (!/^1[3456789]\d{9}$/.test(this.data.mobileNumber)) {
|
|
wx.showToast({
|
|
title: '请输入正确手机号',
|
|
icon: 'none'
|
|
})
|
|
} else {
|
|
let params = {};
|
|
params['tel'] = this.data.mobileNumber;
|
|
_.apiQuery.putAppUserTel(params).then(res => {
|
|
console.log(res)
|
|
wx.showToast({
|
|
title: '修改成功',
|
|
icon: 'success',
|
|
duration: 2000
|
|
})
|
|
|
|
this.getUserInfo()
|
|
|
|
this.setData({
|
|
isShow: false
|
|
})
|
|
|
|
});
|
|
}
|
|
},
|
|
|
|
}
|
|
}) |