|
@@ -11,12 +11,20 @@ Page({
|
|
|
sexList: [{label:'男',value:1},{label:'女',value:2}],
|
|
|
form: {},
|
|
|
areaList: [],
|
|
|
- school: []
|
|
|
+ sortList: [
|
|
|
+ {name:'actualName',title:'姓名'},
|
|
|
+ {name:'sex',title:'性别'},
|
|
|
+ {name:'age',title:'年龄'},
|
|
|
+ {name:'area',title:'区域'},
|
|
|
+ {name:'school',title:'学校'},
|
|
|
+ {name:'grade',title:'年级'}
|
|
|
+ ],
|
|
|
+ jgList: [true,true,true,true,true,true]
|
|
|
},
|
|
|
|
|
|
changeInput (e) {
|
|
|
const id = e.currentTarget.id;
|
|
|
- const value = e.detail.value;
|
|
|
+ let value = (id === 'age' ? e.detail.value.replace(/\D/g, '')-0 : e.detail.value)
|
|
|
this.setData({
|
|
|
['form.'+id]: value
|
|
|
})
|
|
@@ -58,19 +66,29 @@ Page({
|
|
|
id: this.data.form[id]
|
|
|
}},r => {
|
|
|
this.setData({
|
|
|
- schoolList: r.list
|
|
|
+ schoolList: r.list,
|
|
|
+ ['form.school']: null
|
|
|
})
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
|
|
|
submit (e) {
|
|
|
- let {actualName,age,area,grade,other,school} = this.data.form
|
|
|
- let id = wx.getStorageSync('id')
|
|
|
- imine.updateUser({reqdata:{actualName,age,area,grade,other,school,id}},r => {
|
|
|
- this.loadMyinformation()
|
|
|
- wx.navigateTo({
|
|
|
- url: '/pages/contest/answer/answer'
|
|
|
+ let {actualName,sex,age,area,grade,other,school} = this.data.form
|
|
|
+ let {sortList} = this.data
|
|
|
+ this.setData({
|
|
|
+ jgList: sortList.map(item => !!this.data.form[item.name])
|
|
|
+ }, () => {
|
|
|
+ if (!sortList.every(item => this.data.form[item.name])) {
|
|
|
+ console.log(this.data.jgList);
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let id = wx.getStorageSync('id')
|
|
|
+ imine.updateUser({reqdata:{actualName,sex,age,area,grade,other,school,id}},r => {
|
|
|
+ this.loadMyinformation()
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pages/contest/answer/answer'
|
|
|
+ })
|
|
|
})
|
|
|
})
|
|
|
},
|
|
@@ -86,10 +104,7 @@ Page({
|
|
|
loadMyinformation() {
|
|
|
let id = wx.getStorageSync('id')
|
|
|
imine.loadMyinformation({reqdata: {id}},r => {
|
|
|
- wx.setStorage({
|
|
|
- key: 'user',
|
|
|
- data: r.object
|
|
|
- })
|
|
|
+ wx.setStorageSync('user', r.object)
|
|
|
})
|
|
|
},
|
|
|
|