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

Merge branch 'fix/goods' into 'master'

fix: 分享测试

See merge request !182
parents 2a8cd11f aebb3153
import getWxShareInfo from "@/service/wxJsSdk";
import { setShare } from "@/service/wxJsSdk";
const currentOrigin = window.location.origin + "/share.html?path=";
const logo = currentOrigin + "/shareImg/index.png";
const shareList = {
......@@ -102,6 +102,6 @@ export const getShare = to => {
}
const _name = shareName.toLowerCase();
if (shareList[_name]) {
getWxShareInfo(shareList[_name]);
setShare(shareList[_name]);
}
};
......@@ -57,6 +57,9 @@ axios.interceptors.request.use(
pending[config.url]("取消重复请求");
}
config.cancelToken = new CancelToken(c => (pending[config.url] = c));
// ! 上线需要删掉
// eslint-disable-next-line
config.baseURL = baseUrl || config.baseURL;
// 添加token
const token = localStorage.get("mongoToken");
if (token) {
......
......@@ -2,13 +2,22 @@
* @Description: weixin-js-sdk
* @LastEditors: gzw
* @Date: 20120-08-30 18:40:11
* @LastEditTime: 2020-09-01 15:31:27
* @LastEditTime: 2020-09-01 17:23:22
*/
import cfg from "@/config/index";
import { getwxAuth } from "@/api/user";
import wx from "weixin-js-sdk";
export default async function({ title = "", desc = "", link = window.location.href, imgUrl = "" }) {
import { isWeixinBrower } from "@/service/validation";
import localStorage from "@/service/localStorage";
/**
* @description: 微信分享
*/
export async function setShare({
title = "",
desc = "",
link = window.location.href,
imgUrl = ""
}) {
// console.log(title, desc, link, imgUrl);
const res = await getwxAuth({
appId: cfg.wxAppId,
......@@ -53,3 +62,22 @@ export default async function({ title = "", desc = "", link = window.location.hr
});
});
}
/**
* @description: 检查微信环境,分享进入,是否存在openid,否则重定向加载
*/
export function checkOpenId() {
const openId = localStorage.get("openId");
const local = window.location.href;
if (!openId && isWeixinBrower) {
window.location.href =
"https://open.weixin.qq.com/connect/oauth2/authorize?appid=" +
cfg.wxAppId +
"&redirect_uri=" +
encodeURIComponent(local) +
"&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect";
return false;
} else {
return true;
}
}
......@@ -89,6 +89,7 @@ import Card from "@/components/Card";
import Collapse from "@/components/Collapse";
import PayWaitLayer from "@/components/PayWaitLayer";
import CpsQa from "../../Goods/Detail/modules/CpsQA";
import { checkOpenId } from "@/service/wxJsSdk";
const SUM = 300;
export default {
name: "ConsultantBuy",
......@@ -227,6 +228,9 @@ export default {
methods: {
...mapActions(["setIsShowLogin"]),
checkLogin() {
if (!checkOpenId()) {
return;
}
if (!this.isLogin) {
this.setIsShowLogin(true);
return;
......
......@@ -103,6 +103,7 @@ import Detail from "@/api/detail.huatai.zhongjixian";
import { trail, list } from "@/api/product";
import { isIdNo } from "@/service/validation";
import { getRealAge, getBirthDate } from "@/service/utils";
import { checkOpenId } from "@/service/wxJsSdk";
export default {
name: "GoodsDetail-CII",
......@@ -251,6 +252,9 @@ export default {
this.$notify({ type: "warn", message: "被保人年龄不在可投保范围,请仔细核对" });
return;
}
if (!checkOpenId()) {
return;
}
if (localStorage.get("mongoToken")) {
this.$refs.insureForm.getFamilyList(true).then(() => {
setTimeout(() => {
......
......@@ -128,6 +128,7 @@ import detailLoginMixin from "./modules/detailLogin.mixin";
import Detail from "@/api/detail.huagui.shouxian";
import { trail, list } from "@/api/product";
import { checkOpenId } from "@/service/wxJsSdk";
export default {
name: "GoodsDetail-LI",
......@@ -236,6 +237,9 @@ export default {
// this.currentPupopIndex = 6;
// return;
// }
if (!checkOpenId()) {
return;
}
this.showLoginPopup();
this.popupShow = false;
},
......
......@@ -102,6 +102,7 @@ import localStorage from "@/service/localStorage";
import { getRealAge, getBirthDate } from "@/service/utils";
import Detail from "@/api/detail.taikang.yiliaobaozhang";
import { isIdNo } from "@/service/validation";
import { checkOpenId } from "@/service/wxJsSdk";
let socialSecurityCache = "";
export default {
......@@ -234,6 +235,9 @@ export default {
this.$notify({ type: "warning", message: "被保人年龄不在可投保范围,请仔细核对" });
return;
}
if (!checkOpenId()) {
return;
}
if (localStorage.get("mongoToken")) {
socialSecurityCache = this.formData.socialSecurity;
this.$refs.insureForm.getFamilyList(true).then(() => {
......
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