旅游教育出版社-数字教材移动端
litian
2025-06-27 f13b301e61d022787da1ef3e3adcd508b9422096
src/assets/js/weChat/weChat.js
@@ -1,18 +1,17 @@
import {
  appRefCode
} from "@/assets/js/config";
import { appRefCode } from "@/assets/js/config";
import service from "@/plugin/axios";
let wxAppId = "wxd2941f9abd7ba978"; // 微信AppId
let WeChat = {
  getCode: (state) => {
  getCode: state => {
    // 调起授权,获取code。注意:每次调用时先清除已储存的token,避免后续跳转监听到旧的token,一直401
    const url = window.location.href;
    console.log(window.location.href, 1);
    const routeCode = url.split("#")[1];
    if (routeCode == 'weChatLogin' || routeCode == '/selectLoginMethod') {
    if (routeCode == "/weChatLogin" || routeCode == "/selectLoginMethod") {
      window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${wxAppId}&redirect_uri=${encodeURIComponent(
        'https://www.tepcb.com/mobile/textbooks/#/personalCenter'
        "https://www.tepcb.com/mobile/textbooks/#/personalCenter"
      )}&response_type=code&scope=snsapi_userinfo&state=${state}`;
    } else {
      window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${wxAppId}&redirect_uri=${encodeURIComponent(
@@ -92,7 +91,8 @@
    const resData = JSON.parse(data);
    // eslint-disable-next-line
    WeixinJSBridge.invoke(
      "getBrandWCPayRequest", {
      "getBrandWCPayRequest",
      {
        appId: resData.appId, // 公众号名称,由商户传入
        timeStamp: resData.timeStamp, // 时间戳
        nonceStr: resData.nonceStr, // 随机串