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

82 lines
1.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) {
let that = this;
// uni.reLaunch({
// url: '../tabBar/home/home'
// })
// #ifdef H5
let arr1 = window.location.href;
let arr2 = arr1.split('=');
if (arr2[2]) {
var arr3 = arr2[2].split('&');
if (arr3[0] != undefined && arr3[0]) {
app.globalData.h5code = arr3[0];
uni.setStorage({
key: "h5code",
data: arr3[0]
})
}
} else {
// 获取openid
that.jumpcdx();
}
if (app.globalData.h5code) {
that.getAccessToken();
}
// #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.setStorage({
key: "openId",
data: res.return_data.openid
})
if (this.userInfo) {
uni.reLaunch({
url: '../tabBar/home/home'
})
} else {
uni.reLaunch({
url: '/pages/login/login'
})
}
} else {
this.jumpcdx();
}
});
},
jumpcdx() {
location.href =
'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa075e8509802f826&redirect_uri=https://hsg.dctpay.com/wechat_authorize/?redirect_uri=https://gratia-pay.dctpay.com/cweb&response_type=code&scope=snsapi_base#wechat_redirect';
},
}
}
</script>
<style>
2 years ago
</style>