111
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.
 
 
 
 

74 lines
1.7 KiB

import oilIdentityApi from '@/api/oil-identity'
export default {
async WXlogin(e) {
return new Promise((re, rj) => {
uni.login({
provider: 'weixin',
success: async (loginRes) => {
const code = loginRes.code
oilIdentityApi.sendCode(loginRes.code).then(res => {
if (res.code === 20000) {
uni.setStorageSync('sessionKey', res.data.sessionKey);
uni.setStorageSync('openid', res.data.openId);
uni.setStorageSync('unionid', res.data.unionId);
const data1 = {
...e.detail,
sessionKey: uni.getStorageSync('sessionKey'),
unionId: uni.getStorageSync('unionid'),
openId: uni.getStorageSync('openid'),
appId: 'wx7a939c19b270cc3d'
}
oilIdentityApi.getPhone(data1).then(resj => {
re(resj.data.phoneNumber)
});
} else if (res.code == 1002) {
uni.showModal({
title: '微信登录失败提醒',
content: `${res.msg}如有疑问,请联系客服处理`
})
}
}).catch(err => {
uni.showToast({
title: '登陆失败',
icon: 'none'
})
})
},
fail: err => {},
})
})
},
overallInterceptor(callBack) {
uni.addInterceptor('redirectTo', {
invoke(e) {
console.log('拦截redirectTo');
setTimeout(() => {
callBack('redirectTo')
}, 0)
return false;
},
success(e) {
taht.$nextTick(function() {
console.log('跳转页面加载成功')
})
}
});
uni.addInterceptor('switchTab', {
invoke(e) {
console.log('拦截switchTab')
setTimeout(() => {
callBack('switchTab')
}, 0)
return false;
},
success(e) {
taht.$nextTick(function() {
console.log('跳转页面加载成功')
})
}
})
},
}