This commit is contained in:
tcubic 2022-08-08 17:49:07 +08:00
parent 1f3d09053e
commit 8e07827b3e

View File

@ -161,12 +161,14 @@ const apiAll = () => {
//
onBeforeMount(() => {
if (!h5plugin.isWX()) {
apiAll();
// apiAll();
}
console.log("link", window.location.href);
console.log("用户活动信息:", store.state.userAccount);
console.log("code:", h5plugin.getQueryString("code"));
//
if (h5plugin.isWX()) {
// console.log("code:", h5plugin.getQueryString("code"));
@ -179,7 +181,12 @@ onBeforeMount(() => {
// getCode();
// }
apiAll();
if (h5plugin.getQueryString("code")) {
getOpenId(h5plugin.getQueryString("code"));
} else {
wxAuthGetCode();
}
//
// if(h5plugin.getQueryString("openid")){
@ -189,9 +196,6 @@ onBeforeMount(() => {
// console.log("openid");
// getCode2();
// }
}
});
@ -211,14 +215,15 @@ const getCode2 = () => {
let redirect_uri = window.location.href;
// service.post(process.env.VUE_APP_API + '/cms-activity/cms88/zsApi/xfhdAuthorize?redirect_uri='+redirect_uri,
service
.get("https://test.szxgl.cn/zszq-celebration/zsApi/xfhdAuthorize1"
// {
// params:{
// // redirect_uri: redirect_uri,
// redirect_uri: 'https://test.szxgl.cn/zszq-celebration/activity/index.html',
.get(
"https://test.szxgl.cn/zszq-celebration/zsApi/xfhdAuthorize1"
// {
// params:{
// // redirect_uri: redirect_uri,
// redirect_uri: 'https://test.szxgl.cn/zszq-celebration/activity/index.html',
// }
// }
// }
// }
)
.then((res) => {
let code = res.data.data;
@ -230,6 +235,25 @@ const getCode2 = () => {
});
};
const wxAuthGetCode = () => {
var appId = "wx35766a64d73d08a9";
var REDIRECT_URI = window.location.href;
window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect
`;
// service
// .post(process.env.VUE_APP_API + "/cms-activity/cms88/zsApi/xfhdAuthorize", {
// redirect_uri: redirect_uri,
// })
// .then((res) => {
// let code = res.data.data;
// console.log("get code3", res);
// authCode.value = res.data.data;
// window.location.href = res.data.data;
// // location.href = res.data.data;
// // window.open(res.data.data)
// });
};
const getCode = () => {
let redirect_uri = window.location.href;
@ -323,7 +347,7 @@ const stopBack = () => {
window.addEventListener("popstate", function () {
// history.pushState(null, null, document.URL);
history.back(-1)
history.back(-1);
});
};