调整首页样式,增加联通专项业务
This commit is contained in:
174
pages/unicom_form/unicom_form.js
Normal file
174
pages/unicom_form/unicom_form.js
Normal file
@@ -0,0 +1,174 @@
|
||||
|
||||
const api = require("../../api/api"),
|
||||
app = getApp()
|
||||
|
||||
var outTime
|
||||
|
||||
Page({
|
||||
data: {
|
||||
perferentialConfig : {},
|
||||
perferentialType : {},
|
||||
comboType : [],
|
||||
comboTypeValue : "",
|
||||
comboTypeText : "",
|
||||
comboNmae : [],
|
||||
comboNmaeValue : 0,
|
||||
tle : "",
|
||||
codeBtnText : "获取验证码",
|
||||
codeBtnStat : false
|
||||
},
|
||||
// 生命周期函数 -- 页面加载
|
||||
onLoad() {
|
||||
|
||||
},
|
||||
// 生命周期函数 -- 页面显示
|
||||
onShow(){
|
||||
this.preferential()
|
||||
},
|
||||
// 获取优惠配置信息
|
||||
preferential(){
|
||||
api.request({
|
||||
url : "unicom/user",
|
||||
header: {
|
||||
"Authorization": app.globalData.token
|
||||
},
|
||||
method: "POST"
|
||||
}).then(res=>{
|
||||
console.log(res)
|
||||
let combo_type = []
|
||||
for(let i in res.data.perferential_type){
|
||||
combo_type.push(i)
|
||||
}
|
||||
|
||||
this.setData({
|
||||
perferentialConfig: res.data.perferential_config,
|
||||
perferentialType : res.data.perferential_type,
|
||||
comboType : combo_type,
|
||||
user : res.data.user
|
||||
})
|
||||
console.log(res.data.user);
|
||||
})
|
||||
},
|
||||
// 选择套餐类型
|
||||
comboTypeChange(e){
|
||||
let comboType = this.data.comboType,
|
||||
value = e.detail.value,
|
||||
perferentialType = this.data.perferentialType,
|
||||
comboTypeName = comboType[value]
|
||||
|
||||
this.setData({
|
||||
comboTypeValue : value,
|
||||
comboTypeText : comboTypeName,
|
||||
comboNmae : perferentialType[comboTypeName],
|
||||
comboNmaeValue : 0
|
||||
})
|
||||
},
|
||||
// 选择套餐名称
|
||||
comboNmaeChange(e){
|
||||
this.setData({
|
||||
comboNmaeValue: e.detail.value
|
||||
})
|
||||
},
|
||||
// 存储手机号码
|
||||
telInput(e){
|
||||
this.setData({
|
||||
tle: e.detail.value
|
||||
})
|
||||
},
|
||||
// 获取短信验证码
|
||||
getCode(){
|
||||
setTimeout(() => {
|
||||
if(this.data.tle != ''){
|
||||
my.showLoading();
|
||||
api.request({
|
||||
url : "sms",
|
||||
method: "POST",
|
||||
data : {
|
||||
mobile : this.data.tle,
|
||||
channel : "DEFAULT"
|
||||
}
|
||||
}).then(res=>{
|
||||
// 获取倒计时
|
||||
this.setData({
|
||||
codeBtnStat: true,
|
||||
codeBtnText: "重新获取60s"
|
||||
})
|
||||
|
||||
let outTimeNumber = 60
|
||||
outTime = setInterval(()=>{
|
||||
if(outTimeNumber >= 1){
|
||||
outTimeNumber--
|
||||
this.setData({
|
||||
codeBtnText: "重新获取" + outTimeNumber + 's'
|
||||
})
|
||||
}else{
|
||||
this.setData({
|
||||
codeBtnStat: false,
|
||||
codeBtnText: "获取验证码"
|
||||
})
|
||||
clearInterval(outTime)
|
||||
}
|
||||
},1000)
|
||||
// 提示信息
|
||||
my.showToast({
|
||||
content: res.data
|
||||
})
|
||||
my.hideLoading();
|
||||
}).catch(err=>{
|
||||
my.showToast({
|
||||
content: err.data.message
|
||||
})
|
||||
my.hideLoading();
|
||||
})
|
||||
}else{
|
||||
my.showToast({
|
||||
content: "手机号码不能为空"
|
||||
});
|
||||
}
|
||||
}, 100)
|
||||
},
|
||||
// 提交表单
|
||||
welfareForm(e){
|
||||
if(this.data.comboTypeText != ''){
|
||||
my.showLoading()
|
||||
// api
|
||||
api.request({
|
||||
url : "unicom/audit",
|
||||
method : "POST",
|
||||
header: {
|
||||
"Authorization": app.globalData.token
|
||||
},
|
||||
data : {
|
||||
perferential_id : this.data.comboNmae[this.data.comboNmaeValue].id,
|
||||
mobile : e.detail.value.tel,
|
||||
code : e.detail.value.code,
|
||||
phone : e.detail.value.phone,
|
||||
description : e.detail.value.description,
|
||||
channel : "DEFAULT"
|
||||
}
|
||||
}).then(res=>{
|
||||
my.showToast({
|
||||
content: '办理成功'
|
||||
});
|
||||
my.navigateTo({
|
||||
url: '../unicom/unicom'
|
||||
});
|
||||
my.hideLoading()
|
||||
}).catch(err=>{
|
||||
my.showToast({
|
||||
content: err
|
||||
})
|
||||
my.hideLoading()
|
||||
})
|
||||
}else{
|
||||
my.showToast({
|
||||
content: "请选择套餐类型"
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 退出页面
|
||||
onUnload(){
|
||||
clearInterval(outTime)
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user