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