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.

162 lines
2.9 KiB

5 years ago
// pages/activity/huawei/form/index.js
import commonApi from "../../../../utils/https/common"
import userApi from "../../../../utils/https/user"
Page({
/**
* 页面的初始数据
*/
data: {
multiArray:[],
multiIndex:[],
areaList:[],
info:{},
brands:[],
brandIndex:-1,
id:null,
info:{}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
commonApi.user_post('actonline/act_online/getActDetail',{
id:options.id
}).then(res=>{
this.setData({
info:res.data
})
})
commonApi.user_post('actonline/act_online/getMobileBrand',{}).then(res=>{
let brands = []
for(let i in res.data){
brands.push({
name:res.data[i],
id:i
})
}
this.setData({
brands:brands,
id:options.id
})
})
},
changeBrand:function(e){
this.setData({
brandIndex:e.detail.value
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
changeName:function(e){
let info = this.data.info
info.name = e.detail.value
this.setData({
info:info
})
},
changeTel:function(e){
let info = this.data.info
info.mobile = e.detail.value
this.setData({
info:info
})
},
changeCard:function(e){
let info = this.data.info
info.card_number = e.detail.value
this.setData({
info:info
})
},
submit:function(e){
let info = this.data.info;
if(!info.name){
wx.showToast({
title: '请输入姓名',
icon:'none'
})
return;
}
if(info.mobile.length!=11){
wx.showToast({
title: '请输入正确的手机号',
icon:'none'
})
return;
}
if(info.card_number.length!=18){
wx.showToast({
title: '请输入正确的身份证号码',
icon:'none'
})
return;
}
if(this.data.brandIndex==-1){
wx.showToast({
title: '请选择手机品牌',
icon:'none'
})
return;
}
info.id = this.data.id
info.mobile_type = Number(this.data.brands[this.data.brandIndex].id)
commonApi.user_post("actonline/act_online/actSign",info).then(res=>{
if(res.code==1){
wx.navigateTo({
url: '../result/index?id='+this.data.id,
})
}
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})