forked from lsl/xzjl-ui
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
175 lines
4.5 KiB
175 lines
4.5 KiB
// pages/home/me/grzl/grzl.js
|
|
const app = getApp();//新建页面时 默认引入
|
|
const req = app.xzjlReq();//初始化一个的request() 实例
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
avatars:[
|
|
'https://oss.wish.ydxxkj.top/xy/tx1.png',
|
|
'https://oss.wish.ydxxkj.top/xy/tx2.png',
|
|
'https://oss.wish.ydxxkj.top/xy/tx3.png',
|
|
'https://oss.wish.ydxxkj.top/xy/tx4.png',
|
|
'https://oss.wish.ydxxkj.top/xy/tx5.png',
|
|
'https://oss.wish.ydxxkj.top/xy/tx6.png',
|
|
'https://oss.wish.ydxxkj.top/xy/tx1.png',
|
|
'https://oss.wish.ydxxkj.top/xy/tx2.png',
|
|
'https://oss.wish.ydxxkj.top/xy/tx3.png',
|
|
],
|
|
sexs:[{label:'男生',value:'male'},{label:'女生',value:'female'}],
|
|
sexVisible:false,
|
|
note:'',
|
|
cVisible:false,
|
|
userInfo:{},
|
|
endDate:new Date().getTime()
|
|
},
|
|
changeAvatar(e){
|
|
req.patchRequest('/api/user/curt',{avatar:e.target.dataset.img}).then((res)=>{
|
|
if(res.data.code==200){
|
|
this.setData({userInfo:res.data.data})
|
|
wx.showToast({
|
|
title:'修改成功',
|
|
icon: 'none',
|
|
duration: 1000
|
|
})
|
|
}
|
|
}).catch((err)=>{
|
|
console.log(err);
|
|
})
|
|
},
|
|
onColumnChange(e) {/**修改性别 */
|
|
req.patchRequest('/api/user/curt',{spriteType:e.detail.value[0]}).then((res)=>{
|
|
if(res.data.code==200){
|
|
this.setData({userInfo:res.data.data})
|
|
wx.showToast({
|
|
title:'修改成功',
|
|
icon: 'none',
|
|
duration: 1000
|
|
})
|
|
}
|
|
}).catch((err)=>{
|
|
console.log(err);
|
|
})
|
|
},
|
|
handleCalendar(){
|
|
this.setData({cVisible:true})
|
|
console.log('11111')
|
|
},
|
|
changeDate(e) {/**修改日期 */
|
|
console.log(e);
|
|
const { value } = e.detail;
|
|
console.log(value);
|
|
const format = (val) => {
|
|
const date = new Date(val);
|
|
return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
|
|
};
|
|
|
|
this.setData({
|
|
note: format(value),
|
|
});
|
|
req.patchRequest('/api/user/curt',{birthday:format(value)}).then((res)=>{
|
|
console.log(res);
|
|
if(res.data.code==200){
|
|
this.setData({userInfo:res.data.data})
|
|
wx.showToast({
|
|
title:'修改成功',
|
|
icon: 'none',
|
|
duration: 1000
|
|
})
|
|
this.getUserInfo()
|
|
}
|
|
}).catch((err)=>{
|
|
console.log(err);
|
|
})
|
|
},
|
|
changeSex(){
|
|
this.setData({sexVisible:true})
|
|
console.log('修改性别')
|
|
},
|
|
doChangeName1(e){
|
|
if (e.detail.value !== this.data.userInfo.nick) {
|
|
req.patchRequest('/api/user/curt',{nick:e.detail.value}).then((res)=>{
|
|
if(res.data.code==200){
|
|
this.setData({userInfo:res.data.data})
|
|
wx.showToast({
|
|
title:'修改成功',
|
|
icon: 'none',
|
|
duration: 1000
|
|
})
|
|
}
|
|
}).catch((err)=>{
|
|
console.log(err);
|
|
})
|
|
}
|
|
},
|
|
getUserInfo(){
|
|
req.getRequest('/api/user/curt',{}).then((res)=>{
|
|
if(res.data.code==200){
|
|
this.setData({userInfo:res.data.data})
|
|
}
|
|
console.log(this.userInfo);
|
|
}).catch((err)=>{
|
|
console.log(err);
|
|
})
|
|
},
|
|
go2Reback(){
|
|
wx.navigateBack({ changed: true });
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
this.getUserInfo()
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
}) |