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.
169 lines
3.1 KiB
169 lines
3.1 KiB
4 years ago
|
// pages/topics/activity/activitySign/index.js
|
||
|
import {
|
||
|
store
|
||
|
} from '../../../../utils/store.js'
|
||
|
import {
|
||
|
TopicModel
|
||
|
} from '../../../../models/topic.js'
|
||
|
let topicModel = new TopicModel()
|
||
|
const app = getApp()
|
||
|
Page({
|
||
|
|
||
|
/**
|
||
|
* 页面的初始数据
|
||
|
*/
|
||
|
data: {
|
||
|
aId: '',
|
||
|
username: '',
|
||
|
company: '',
|
||
|
phone: ''
|
||
|
},
|
||
|
/**
|
||
|
* 生命周期函数--监听页面加载
|
||
|
*/
|
||
|
onLoad: function (options) {
|
||
|
console.log(options)
|
||
|
this.setData({
|
||
|
aId: options.activityId
|
||
|
})
|
||
|
this.initFormData()
|
||
|
// console.log(this.data.aId)
|
||
|
},
|
||
|
initFormData() {
|
||
|
let {
|
||
|
nickName,
|
||
|
phone
|
||
|
} = store.readUserInfo()
|
||
|
this.setData({
|
||
|
username: nickName,
|
||
|
phone: phone
|
||
|
})
|
||
|
},
|
||
|
changeCompany: function (e) {
|
||
|
var company = e.detail.value;
|
||
|
this.setData({
|
||
|
company: company
|
||
|
})
|
||
|
},
|
||
|
changeUsername: function (e) {
|
||
|
var username = e.detail.value;
|
||
|
this.setData({
|
||
|
username: username
|
||
|
})
|
||
|
},
|
||
|
changePhone: function (e) {
|
||
|
let isPhoneFlag = this.isPhone(e.detail.value)
|
||
|
if (!isPhoneFlag) {
|
||
|
wx.showToast({
|
||
|
title: '请输入正确格式的手机号',
|
||
|
icon: 'none',
|
||
|
duration: 2000,
|
||
|
})
|
||
|
return;
|
||
|
}
|
||
|
this.setData({
|
||
|
phone: e.detail.value
|
||
|
})
|
||
|
},
|
||
|
isPhone(value) {
|
||
|
if (!/^1(3|4|5|7|8)\d{9}$/.test(value)) {
|
||
|
return false
|
||
|
} else {
|
||
|
return true
|
||
|
}
|
||
|
},
|
||
|
submit() {
|
||
|
var th = this;
|
||
|
if (this.data.username === '') {
|
||
|
wx.showModal({
|
||
|
title: '提示',
|
||
|
content: '请输入姓名',
|
||
|
showCancel: false
|
||
|
})
|
||
|
return
|
||
|
}
|
||
|
if (this.data.phone === '') {
|
||
|
wx.showModal({
|
||
|
title: '提示',
|
||
|
content: '请输入联系电话',
|
||
|
showCancel: false
|
||
|
})
|
||
|
return
|
||
|
}
|
||
|
this.onlineSignApi()
|
||
|
},
|
||
|
//在线报名
|
||
|
onlineSignApi() {
|
||
|
topicModel.onlineSign(this.data.aId, res => {
|
||
|
if (res.code == 200) {
|
||
|
console.log(res.code);
|
||
|
wx.showModal({
|
||
|
title: res.message,
|
||
|
showCancel: false, //是否显示取消按钮
|
||
|
confirmText: "确定", //默认是“确定”
|
||
|
success: function (res) {
|
||
|
app.globalData.currentTab = "5"
|
||
|
wx.switchTab({
|
||
|
url: '../../../topics/index'
|
||
|
})
|
||
|
},
|
||
|
})
|
||
|
}
|
||
|
if (res.code != 200) {
|
||
|
wx.showToast({
|
||
|
title: res.message,
|
||
|
icon: 'none'
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面初次渲染完成
|
||
|
*/
|
||
|
onReady: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面显示
|
||
|
*/
|
||
|
onShow: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面隐藏
|
||
|
*/
|
||
|
onHide: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面卸载
|
||
|
*/
|
||
|
onUnload: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 页面相关事件处理函数--监听用户下拉动作
|
||
|
*/
|
||
|
onPullDownRefresh: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 页面上拉触底事件的处理函数
|
||
|
*/
|
||
|
onReachBottom: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 用户点击右上角分享
|
||
|
*/
|
||
|
onShareAppMessage: function () {
|
||
|
|
||
|
}
|
||
|
})
|