167 lines
3.6 KiB
JavaScript
167 lines
3.6 KiB
JavaScript
import _ from '../../commons/js/commons'
|
|
const app = getApp()
|
|
|
|
Page({
|
|
|
|
data: {
|
|
mobile: '',
|
|
sms_code: '',
|
|
interval: 0,
|
|
downCount: 119,
|
|
text: '验证码',
|
|
pageshow: false,
|
|
imgUrl: _.config.imgUrl,
|
|
brand_page_show: false
|
|
},
|
|
|
|
onLoad: function (options) {
|
|
|
|
},
|
|
|
|
onShow: function () {
|
|
let ukey = app.getStorageByKey("ukey");
|
|
if (!!ukey&&!!app.getStorageByKey("userInfo")){
|
|
if(app.getStorageByKey("userInfo").biz_type==4){
|
|
wx.reLaunch({
|
|
url: '/pages/allot/index',
|
|
})
|
|
}else if(app.getStorageByKey("userInfo").group_id==4){
|
|
wx.reLaunch({
|
|
url: '/pages/channel/index',
|
|
})
|
|
}else{
|
|
wx.reLaunch({
|
|
url: '/pages/index/index',
|
|
})
|
|
}
|
|
}else{
|
|
this.setData({
|
|
pageshow: true,
|
|
})
|
|
}
|
|
},
|
|
|
|
// 输入
|
|
inputTx(e) {
|
|
this.setData({
|
|
submitFlag: false,
|
|
[e.currentTarget.dataset.key]: e.detail.value
|
|
})
|
|
},
|
|
|
|
//获取验证码
|
|
getAppSms() {
|
|
|
|
if (this.data.downCount == 119){
|
|
if (!/^1[3456789]\d{9}$/.test(this.data.mobile)) {
|
|
wx.showToast({
|
|
title: '请输入正确的手机号',
|
|
icon: 'none'
|
|
})
|
|
} else {
|
|
let params = {};
|
|
params['mobile'] = this.data.mobile;
|
|
_.apiQuery.getAppSms(params).then(res => {
|
|
this.setData({
|
|
text: 120 + 's'
|
|
})
|
|
let interval = setInterval(res => {
|
|
if (this.data.downCount > 0) {
|
|
this.setData({
|
|
downCount: this.data.downCount - 1,
|
|
text: this.data.downCount + 's'
|
|
})
|
|
} else {
|
|
clearInterval(interval)
|
|
this.setData({
|
|
downCount: 119,
|
|
text: '验证码'
|
|
})
|
|
}
|
|
}, 1000)
|
|
});
|
|
}
|
|
}
|
|
},
|
|
|
|
//登录
|
|
getUserUkey() {
|
|
if (!/^1[3456789]\d{9}$/.test(this.data.mobile)) {
|
|
wx.showToast({
|
|
title: '请输入正确的手机号',
|
|
icon: 'none'
|
|
})
|
|
} else if (this.data.sms_code == '' ){
|
|
wx.showToast({
|
|
title: '请输入验证码',
|
|
icon: 'none'
|
|
})
|
|
} else{
|
|
|
|
wx.login({
|
|
success:resc => {
|
|
wx.showToast({
|
|
title: '登录中...',
|
|
icon: 'loading'
|
|
})
|
|
let params = {};
|
|
params['mobile'] = this.data.mobile;
|
|
params['code'] =resc.code;
|
|
params['sms_code'] = this.data.sms_code;
|
|
_.apiQuery.getUserUkey(params).then(res => {
|
|
wx.setStorage({
|
|
key: "ukey",
|
|
data: res.data.ukey
|
|
})
|
|
setTimeout(function () {
|
|
_.apiQuery.getUserInfo().then(res => {
|
|
if(res.biz_type==4){
|
|
wx.reLaunch({
|
|
url: '/pages/allot/index',
|
|
})
|
|
}else if(res.group_id==4){
|
|
wx.reLaunch({
|
|
url: '/pages/channel/index',
|
|
})
|
|
}else{
|
|
wx.reLaunch({
|
|
url: '/pages/index/index',
|
|
})
|
|
}
|
|
});
|
|
}, 500);
|
|
});
|
|
|
|
}
|
|
})
|
|
}
|
|
},
|
|
|
|
//点企业微信客服
|
|
completemessage(e){
|
|
if(e.detail.name){
|
|
this.setData({
|
|
iskefuSuccess:true,
|
|
})
|
|
}else{
|
|
wx.showToast({
|
|
title:'目前客服忙',
|
|
icon: "none"
|
|
});
|
|
}
|
|
},
|
|
|
|
//推送链接
|
|
pushLink(e){
|
|
if(e.currentTarget.dataset.url){
|
|
_.$router.openUrlScheme(e.currentTarget.dataset.url)
|
|
}
|
|
},
|
|
|
|
bindShowBrand(){
|
|
this.setData({
|
|
brand_page_show: true
|
|
})
|
|
}
|
|
|
|
}) |