95 lines
2.1 KiB
JavaScript
Raw Normal View History

2024-02-21 17:43:11 +08:00
let app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
form: {
userName: '',
phone: '',
sex: 0
},
sex: ['男', '女'],
sexindex: 0
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (e) {
let that = this
app.AjaxRequest('get', {
'content-type': 'application/json',
'Authorization': 'Bearer ' + app.Getopenid()
}, '/user/profile', {}, function (res) {
that.setData({
'form.userId': res.data.userId,
'form.userName': res.data.nickname,
'form.actId': e.actId,
'form.sex': res.data.sex,
sexindex: res.data.sex
})
})
},
// 性别选择
sexChange: function (e) {
this.setData({
sexindex: e.detail.value,
'form.sex': parseInt(e.detail.value)
})
},
formSubmit(e) {
let that = this
let form = that.data.form
if (form.userName == '') {
wx.showToast({
title: '请先填写姓名',
duration: 3000,
icon: 'none'
})
return false
}
wx.showModal({
title: '提示',
content: '是否确认报名',
success(res) {
if (res.confirm) {
app.AjaxRequest('POST', {
'content-type': 'application/json',
'Authorization': 'Bearer ' + app.Getopenid()
}, '/activity/addSign?parkId=' + wx.getStorageSync('parkId'), {
userName: form.userName,
sex: form.sex,
mobile: form.phone,
userId: form.userId,
actId: form.actId
},
function (res) {
if (res.code == 0) {
wx.navigateBack()
}
})
}
}
})
},
bindPickerChange: function (e) {
this.setData({
'form.index': e.detail.value
})
},
bindCompanyChange(e) {
this.setData({
'form.companyindex': e.detail.value
})
},
valueChange(e) {
let a = "form." + e.currentTarget.dataset.type
console.log(a)
this.setData({
[a]: e.detail.value
})
}
})