Commit becf339b authored by 郭志伟's avatar 郭志伟

fix: 分享问题

parent 9c46aca9
......@@ -2,12 +2,13 @@
* @Description: weixin-js-sdk
* @LastEditors: gzw
* @Date: 20120-08-30 18:40:11
* @LastEditTime: 2020-09-01 19:06:07
* @LastEditTime: 2020-09-01 19:27:35
*/
import cfg from "@/config/index";
import { getwxAuth } from "@/api/user";
import wx from "weixin-js-sdk";
import { isWeixinBrower } from "@/service/validation";
import { parseSearch } from "@/service/utils";
import localStorage from "@/service/localStorage";
/**
......@@ -22,7 +23,7 @@ export async function setShare({
// console.log(title, desc, link, imgUrl);
const res = await getwxAuth({
appId: cfg.wxAppId,
url: window.location.href
url: link
});
const { appId, timestamp, nonceStr, signature } = res;
wx.config({
......@@ -69,10 +70,10 @@ export async function setShare({
*/
export function checkOpenId() {
const openId = localStorage.get("openId");
const _param = parseSearch(window.location.href);
const local = window.location.href;
console.log(!openId, isWeixinBrower);
if (!openId && isWeixinBrower) {
alert("无openid");
if (!openId && isWeixinBrower && !_param.code) {
var nextPage = document.createElement("a");
nextPage.setAttribute(
"href",
......@@ -83,8 +84,5 @@ export function checkOpenId() {
"&response_type=code&scope=snsapi_base&state=1#wechat_redirect"
);
nextPage.click();
return false;
} else {
return true;
}
}
......@@ -223,7 +223,7 @@ export default {
}
},
created() {
!checkOpenId();
checkOpenId();
},
mounted() {
this.updateRemain();
......
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