Files
cardtest/pages/makeForm/makeForm.js
2021-06-24 14:15:58 +08:00

122 lines
2.9 KiB
JavaScript

/*
* 本时生活
*/
Page({
/**
* 页面的初始数据
*/
data: {
businessId: '', // 业务收集携带参数-接收id
checkedId : '', // 选择生效时间样式
makeTime : [], // 业务收集-生效时间数据
makeData : '', // 业务收集数据,
disabled : false, //预约按钮状态
makeItems : [], //业务手机套餐列表
itemsId : '' //业务手机套餐列表id
},
/**
* 生命周期函数--监听页面加载
*/
onLoad (options) {
console.log(options)
this.setData({
businessId: options.business_id
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow () {
// 获取业务收集数据
this.makeInfo();
},
/**
* 业务收集数据
*/
makeInfo() {
wx.$api.index.busineSee(this.data.businessId).then(res=>{
this.setData({
businessId: res.data.business_id,
makeData : res.data,
makeTime : res.data.type,
makeItems : res.data.items
})
}).catch(err=>{
if(!err.login){
wx.showModal({
title : '用户登录已过期',
content : '请重新登录',
showCancel : false,
success : res => {
if (res.confirm) {
wx.redirectTo({
url: '/pages/login/login'
})
}
}
})
}
})
},
/**
* 生效时间选择
*/
radioChange(e) {
this.setData({
checkedId: e.detail.value
})
},
/**
* 套餐列表选择
*/
makeTap(e) {
this.setData({
itemsId: e.currentTarget.dataset.id
})
},
/**
* 预约表单
*/
formSubmit(e) {
let newMobile = e.detail.value.mobile,
newUsername = e.detail.value.username,
business_id = this.data.businessId,
checked_id = this.data.checkedId,
items_id = this.data.itemsId
wx.$api.index.busineForm(business_id, items_id, checked_id, newMobile, newUsername).then(res=>{
this.setData({
disabled: true
})
wx.showToast({
title: '预约成功',
icon: 'success'
})
setTimeout(function () {
wx.navigateBack({
delta: 1
})
}, 2000)
}).catch(err=>{
if(!err.login){
}
})
},
/**
* 拨打客服电话
*/
makeOneTel() {
wx.makePhoneCall({
phoneNumber: this.data.makeData.mobile
})
}
})