Commit 798cee58 authored by ziyu's avatar ziyu

improvement: 修改bug,优化

parent 8fc54288
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -37,15 +37,16 @@ const request = async (url, options) => {
method: options.method,
header: options.header
}).then(res => {
let msg = res.data.msg || '服务器异常';
if (res.statusCode === 200) {
if (res.data.code === 2000) {
return res.data.data;
}
Notify({ message: '服务器异常,请稍后重试', safeAreaInsetTop });
throw new Error(res.data.msg || '服务器异常,请求url:' + url);
throw new Error(msg + ',请求url:' + url + '请求返回:' + res.data);
}
Notify({ message: '服务器异常,请稍后重试', safeAreaInsetTop });
throw new Error(res.data.msg || '服务器异常,请求url:' + url);
throw new Error(msg + ',请求url:' + url + '请求返回:' + res.data);
});
};
......
......@@ -582,10 +582,10 @@
this.mainInfo = await getUserInfo(wx.getStorageSync('openId'));
this.sign = this.mainInfo && this.mainInfo.signin;
wx.setStorageSync('hasPhone', this.mainInfo.phone);
if(this.mainInfo&&this.mainInfo.innerActivity) {
if (this.mainInfo && this.mainInfo.innerActivity) {
wx.setStorageSync('innerActivity', this.mainInfo.innerActivity);
} else {
wx.setStorageSync('innerActivity','')
wx.setStorageSync('innerActivity', '');
}
if (this.mainInfo.inviteRecord && this.mainInfo.inviteRecord.length) {
this.showShareModal = true;
......
......@@ -140,6 +140,10 @@
Notify({message: '请填写身份证号'});
return;
}
if (!/^[0-9]+[Xx]?$/.test(this.idNumber)) {
Notify({message: '请填写正确的身份证号'});
return;
}
if (!this.city) {
Notify({message: '请选择所在地区'});
return;
......
......@@ -266,16 +266,17 @@
photoUrl: '',
btnfont: '立即参与',
hasPhone: false,
isInnerDone:'hide',
innerActivity:'',
isError:false,
code:'',
isInnerDone: 'hide',
innerActivity: '',
isError: false,
code: ''
},
methods: {
check() {
this.isCheck = !this.isCheck;
},
async getPhoneNumber(e) {
// 用户获取手机号之前一定要登录
if (this.btnfont !== '立即参与') { return; }
let that = this;
let detail = e.$wx.detail || {};
......@@ -290,9 +291,14 @@
}
if (detail.encryptedData) {
this.btnfont = '参与中...';
const { code } = await wepy.wx.login();
await login(code);
goprize();
wx.checkSession({
async fail () {
// session_key 已经失效,需要重新执行登录流程
const { code } = await wepy.wx.login();
await login(code);
goprize();
}
});
} else {
Notify({message: '参与失败,请重新授权!'});
}
......@@ -301,6 +307,7 @@
let title = ['参与成功!', '参与失败!', '参与失败!'];
let message = ['参与成功,坐等开奖。', '当前抽奖已结束。', '当前奖品已经没有库存了。'];
// 如果用户还未注册
// 用户抽奖之前一定要注册
let isRegister = wx.getStorageSync('isRegister');
if (isRegister === false) {
await register(store.state.userInfo);
......@@ -327,10 +334,10 @@
return;
}
if (this.hasPhone) {
//当有innerActivity并且没有邀请码(没有验证过)并且不是VIP的时候才显示modal
if(this.innerActivity && !this.innerActivity.haveCode && !this.innerActivity.vip) {
// 当有innerActivity并且没有邀请码(没有验证过)并且不是VIP的时候才显示modal
if (this.innerActivity && !this.innerActivity.haveCode && !this.innerActivity.vip) {
this.showModal();
}else {
} else {
this.confirmRaff();
}
}
......@@ -356,14 +363,14 @@
this.code = '';
},
checkCode () {
checkInnerCode({code:this.code}).then(data=>{
if(+data.checkCode === 0) {
checkInnerCode({code: this.code}).then(data => {
if (+data.checkCode === 0) {
this.closeModal();
this.confirmRaff();
}else{
} else {
this.isError = true;
}
})
});
}
},
computed: {
......@@ -377,7 +384,7 @@
},
watch: {
code(val) {
if(!val.length&&this.isError) {
if (!val.length && this.isError) {
this.isError = false;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment