|
@@ -1,4 +1,6 @@ |
|
|
const app = getApp(); |
|
|
|
|
|
|
|
|
const util = require("../../utils/util.js"); |
|
|
|
|
|
const Http = require("../../utils/HttpBasics"); |
|
|
|
|
|
const config = require("../../config/config"); |
|
|
Page({ |
|
|
Page({ |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@@ -6,10 +8,11 @@ Page({ |
|
|
*/ |
|
|
*/ |
|
|
data: { |
|
|
data: { |
|
|
date: '1988-03-12', |
|
|
date: '1988-03-12', |
|
|
flag:1, |
|
|
|
|
|
|
|
|
flag: 1, |
|
|
|
|
|
flagsex: 0, |
|
|
items: [ |
|
|
items: [ |
|
|
{ name: 'male', value: '男' }, |
|
|
|
|
|
{ name: 'famale', value: '女' }, |
|
|
|
|
|
|
|
|
{ name: 1, value: '男', checked: false }, |
|
|
|
|
|
{ name: 2, value: '女', checked: false }, |
|
|
] |
|
|
] |
|
|
}, |
|
|
}, |
|
|
/** |
|
|
/** |
|
@@ -17,36 +20,142 @@ Page({ |
|
|
*/ |
|
|
*/ |
|
|
bindDateChange: function (e) { |
|
|
bindDateChange: function (e) { |
|
|
console.log('picker发送选择改变,携带值为', e.detail.value); |
|
|
console.log('picker发送选择改变,携带值为', e.detail.value); |
|
|
|
|
|
|
|
|
|
|
|
console.log(typeof (e.detail.value)) |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
date: e.detail.value, |
|
|
date: e.detail.value, |
|
|
flag:2 |
|
|
|
|
|
|
|
|
flag: 2 |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
address: function () { |
|
|
address: function () { |
|
|
let that = this; |
|
|
let that = this; |
|
|
wx.chooseLocation({ |
|
|
wx.chooseLocation({ |
|
|
success:function(res){ |
|
|
|
|
|
|
|
|
success: function (res) { |
|
|
console.log(res); |
|
|
console.log(res); |
|
|
that.setData({ |
|
|
that.setData({ |
|
|
name: res.name |
|
|
|
|
|
|
|
|
name: res.name, |
|
|
|
|
|
address: res, |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
fail:function(error){ |
|
|
|
|
|
|
|
|
fail: function (error) { |
|
|
console.log(error) |
|
|
console.log(error) |
|
|
}, |
|
|
}, |
|
|
complete:function(data){ |
|
|
|
|
|
|
|
|
complete: function (data) { |
|
|
console.log(data); |
|
|
console.log(data); |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
formSubmit: function (e) { |
|
|
|
|
|
console.log(e); |
|
|
|
|
|
let that = this; |
|
|
|
|
|
/** |
|
|
|
|
|
* sex |
|
|
|
|
|
* 0 保密 |
|
|
|
|
|
* 1 男 |
|
|
|
|
|
* 2 女 |
|
|
|
|
|
*/ |
|
|
|
|
|
if (that.data.flagsex == 0) { |
|
|
|
|
|
var sex = 0; |
|
|
|
|
|
} else { |
|
|
|
|
|
var sex = that.data.sex; |
|
|
|
|
|
} |
|
|
|
|
|
if (that.data.address) { |
|
|
|
|
|
var address = JSON.stringify(that.data.address); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
var address = null; |
|
|
|
|
|
} |
|
|
|
|
|
if (e.detail.value.username) { |
|
|
|
|
|
var username = e.detail.value.username; |
|
|
|
|
|
} else if (that.data.username) { |
|
|
|
|
|
var username = that.data.username; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
var username = null; |
|
|
|
|
|
} |
|
|
|
|
|
if (that.data.flag == 2 && that.data.date) { |
|
|
|
|
|
var birthdate = new Date(that.data.date).getTime(); |
|
|
|
|
|
} else { |
|
|
|
|
|
var birthdate = null; |
|
|
|
|
|
} |
|
|
|
|
|
console.log(username); |
|
|
|
|
|
console.log(address); |
|
|
|
|
|
console.log(sex); |
|
|
|
|
|
console.log(birthdate); |
|
|
|
|
|
|
|
|
|
|
|
if (username == null || address == null || sex == 0 || birthdate == null) { |
|
|
|
|
|
wx.showModal({ |
|
|
|
|
|
title: '提示', |
|
|
|
|
|
content: '请输入完整的用户信息', |
|
|
|
|
|
showCancel: false |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
Http.post({ |
|
|
|
|
|
url: config.api.updateInfo, |
|
|
|
|
|
data: { |
|
|
|
|
|
sex: sex, |
|
|
|
|
|
address: address, |
|
|
|
|
|
name: username, |
|
|
|
|
|
birthdate: birthdate, |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
.then(res => { |
|
|
|
|
|
console.log(res); |
|
|
|
|
|
wx.showModal({ |
|
|
|
|
|
title: '提示', |
|
|
|
|
|
content: '修改成功', |
|
|
|
|
|
showCancel: false, |
|
|
|
|
|
success: function (res) { |
|
|
|
|
|
wx.switchTab({ |
|
|
|
|
|
url: '/pages/user/index', |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
radioChange: function (e) { |
|
|
radioChange: function (e) { |
|
|
console.log('radio发生change事件,携带value值为:', e.detail.value) |
|
|
|
|
|
|
|
|
console.log(e.detail.value) |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
sex: e.detail.value, |
|
|
|
|
|
flagsex: 1 |
|
|
|
|
|
}) |
|
|
}, |
|
|
}, |
|
|
/** |
|
|
/** |
|
|
* 生命周期函数--监听页面加载 |
|
|
* 生命周期函数--监听页面加载 |
|
|
*/ |
|
|
*/ |
|
|
onLoad: function (options) { |
|
|
onLoad: function (options) { |
|
|
|
|
|
|
|
|
|
|
|
let that = this; |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
username: options.name, |
|
|
|
|
|
sex: options.sex, |
|
|
|
|
|
date: util.fmtDate(parseInt(options.birthdate)), |
|
|
|
|
|
name: JSON.parse(options.address).name, |
|
|
|
|
|
address: JSON.parse(options.address), |
|
|
|
|
|
flag: 2 |
|
|
|
|
|
}); |
|
|
|
|
|
if (options.sex == "1") { |
|
|
|
|
|
console.log(that.data.items); |
|
|
|
|
|
that.data.items[0].checked = true; |
|
|
|
|
|
var checked = 'items[' + 0 + '].checked' |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
[checked]: true |
|
|
|
|
|
}) |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
flagsex: 1 |
|
|
|
|
|
}) |
|
|
|
|
|
} else if (options.sex == "2") { |
|
|
|
|
|
that.data.items[1].checked = true; |
|
|
|
|
|
var checked = 'items[' + 1 + '].checked' |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
[checked]: true |
|
|
|
|
|
}) |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
flagsex: 1 |
|
|
|
|
|
}) |
|
|
|
|
|
console.log(that.data.items); |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@@ -60,7 +169,7 @@ Page({ |
|
|
* 生命周期函数--监听页面显示 |
|
|
* 生命周期函数--监听页面显示 |
|
|
*/ |
|
|
*/ |
|
|
onShow: function () { |
|
|
onShow: function () { |
|
|
let that = this; |
|
|
|
|
|
|
|
|
console.log("oShow") |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|