|
@@ -2,8 +2,7 @@ import store from "@/store/index.js";
|
|
|
import api from "@/common/api.js";
|
|
|
import { isWeixin, modalComfirm } from "./shared";
|
|
|
import { getQueryString } from "../common/navTo";
|
|
|
-import goods from "../common/httpList/goods";
|
|
|
-export function getCode() {
|
|
|
+export function getCode(url = window.location.href) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
// #ifdef H5
|
|
|
if (location.search.includes("code")) {
|
|
@@ -14,7 +13,7 @@ export function getCode() {
|
|
|
// 没有code,就重定向到地址https://www.xyyxt.net?ask_type=https://api.xyyxt.net/pages2/order/confirm_pay 去获取code,授权后就会把code带上然后访问域名
|
|
|
// ?fromCart=&code=061F5a1w3aolh03SLe1w3sMsCF4F5a16&state=STATE
|
|
|
if (process.env.NODE_ENV !== "development") {
|
|
|
- const url = window.location.host + "/pages2/order/confirm_pay";
|
|
|
+ url = url.split("//")[1];
|
|
|
// 跳自己授权
|
|
|
if (store.getters.config.gzhSelfLicense) {
|
|
|
api.getWxConfig().then((res) => {
|
|
@@ -44,7 +43,7 @@ export function getCode() {
|
|
|
}
|
|
|
|
|
|
// 获得openid
|
|
|
-export async function getOpenid(isNeedUid = false) {
|
|
|
+export async function getOpenid() {
|
|
|
let openid = uni.getStorageSync("openid");
|
|
|
if (!openid) {
|
|
|
let code = await getCode();
|
|
@@ -105,16 +104,12 @@ export async function isCanDoExam(examLimitClient) {
|
|
|
if (!examLimitClient || !examClientCanLearn(examLimitClient)) {
|
|
|
return false;
|
|
|
}
|
|
|
- let isFlag = false;
|
|
|
- let data = await checkOpenidIsUser();
|
|
|
- if (data.code === 200) {
|
|
|
- isFlag = data.data;
|
|
|
- }
|
|
|
- if (!isFlag) {
|
|
|
+ let { data } = await checkOpenidIsUser();
|
|
|
+ if (!data) {
|
|
|
modalComfirm("该题库只允许同一用户学习");
|
|
|
- throw new Error("isFlag:" + isFlag);
|
|
|
+ throw new Error("data:" + data);
|
|
|
}
|
|
|
- return isFlag;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
export async function goodsExamIsCanLearn(goodsId) {
|