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.
xuan-pay-cweb/pages/welcome/welcome.vue

132 lines
3.7 KiB

<template>
<view>
</view>
</template>
<script>
import {
getAccessToken
} from '../../Utils/Api.js';
let app = getApp();
export default {
data() {
return {
userInfo: app.globalData.userInfo, //登录信息
}
},
onLoad(options) {
1 year ago
// uni.reLaunch({
1 year ago
// url: '/pages/login/login',
// // url: '/subpackages/groupBuyingConfiguration/groupVerify/groupVerify?orderKey='+'4576027622249814',
1 year ago
// })
// return
1 year ago
let that = this;
/*
重定向前:https://gratia-pay.dctpay.com/cweb?accountId=0001&key=123#/
https://gratia-pay.dctpay.com/cweb?accountId=0001&key=123&code=456#/
重定向后 -微信
https://gratia-pay.dctpay.com/cweb/?redirect_uri=https://gratia-pay.dctpay.com/cweb&code=0111BKGa1EvjoG0sm9Ha1u8wG111BKGR&state=1#/
["https://gratia-pay.dctpay.com/cweb/?redirect_uri", "https://gratia-pay.dctpay.com/cweb&code", "0111BKGa1EvjoG0sm9Ha1u8wG111BKGR&state", "1#/"]
*/
// #ifdef H5
1 year ago
let locationPathStr = window.location.href;
let locationPathArr = locationPathStr.split('=');
let codeArr = locationPathArr[2] ? locationPathArr[2].split('&') : [];
if (locationPathArr[locationPathArr.length-1]=='1#/'&&codeArr[0]) {
app.globalData.h5code = codeArr[0];
uni.setStorageSync("h5code",codeArr[0])
this.getAccessToken();//获取openID
} else {
uni.setStorageSync("accountId","");
uni.setStorageSync("urlKey","");
uni.setStorageSync("urlCode","");
1 year ago
if(locationPathArr[1]){
let accountId = locationPathArr[1].split("&")[0];
app.globalData.accountId=accountId;
uni.setStorageSync("accountId",accountId);
}
if(locationPathArr[2]){
let key;
if(!locationPathArr[3]){
key = locationPathArr[2].split("#")[0];
}else{
key = locationPathArr[2].split("&")[0];
}
app.globalData.urlKey = key;
uni.setStorageSync("urlKey",key);
}
if(locationPathArr[3]&&!locationPathArr[4]){
let code = locationPathArr[3].split("#")[0];
app.globalData.code = code;
uni.setStorageSync("urlCode",code);
}
this.jumpcdx();//网页授权
}
// #endif
},
methods: {
//H5 获取openId
getAccessToken() {
let params = {
code: app.globalData.h5code
}
getAccessToken(params).then(res => {
if (res.return_code == '000000' && res.return_data.openid) {
app.globalData.openId = res.return_data.openid;
uni.setStorageSync("openId",res.return_data.openid);
if (this.userInfo) {
1 year ago
if(!this.isGoHomeUrl()) return;
uni.reLaunch({
url: '../tabBar/home/home'
})
} else {
uni.reLaunch({
url: '/pages/login/login'
})
}
} else {
this.jumpcdx();
}
});
},
1 year ago
isGoHomeUrl(){
// 0001扫码核销https://gratia-pay.dctpay.com/cweb?accountId=0001&key=123
if (app.globalData.accountId == '0001' && app.globalData.h5code){
let orderKey = uni.getStorageSync("urlKey");
1 year ago
if(orderKey&&this.userInfo.store.id){
1 year ago
uni.redirectTo({
url: '/subpackages/groupBuyingConfiguration/groupVerify/groupVerify?orderKey='+orderKey,
})
return false;
1 year ago
}else{
uni.redirectTo({
url: '/pages/login/login'
})
return false;
1 year ago
}
}
return true;
},
jumpcdx() {
let redirectUrl = app.globalData.redirectUrl;
location.href =
1 year ago
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa075e8509802f826&redirect_uri=https://hsg.dctpay.com/wechat_authorize/?redirect_uri=${redirectUrl}&response_type=code&scope=snsapi_base&state=1#wechat_redirect`;
},
}
}
</script>
<style>
2 years ago
</style>