fix
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import UrlParamsHandler from "../../../utils/store";
|
||||
import { appversion, version } from "../../../env";
|
||||
import { version } from "../../../env";
|
||||
import { request } from "../../../utils/request";
|
||||
const defaultAvatarUrl =
|
||||
"https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0";
|
||||
@@ -45,7 +45,7 @@ Page({
|
||||
};
|
||||
const data = await request({
|
||||
options: {
|
||||
url: `/app/video-watch/details?version=${version.details}&appVer=${appversion}`,
|
||||
url: `/app/video-watch/details`,
|
||||
method: "GET",
|
||||
data: params,
|
||||
},
|
||||
|
||||
@@ -30,7 +30,7 @@ Page({
|
||||
nodes: [] as any[],
|
||||
eveId: null,
|
||||
store: {},
|
||||
fileid: "5001834818839455549",
|
||||
fileid: "",
|
||||
active: 0,
|
||||
canSubmit: false,
|
||||
safeBottom: 24,
|
||||
@@ -205,7 +205,7 @@ Page({
|
||||
const detail = (e && e.detail) || e || {};
|
||||
wx.showModal({
|
||||
title: "播放出错",
|
||||
content: String(detail.errMsg || detail.message || JSON.stringify(detail)),
|
||||
content: String(detail.errMsg || detail.message || JSON.stringify(detail) + '请联系坐席'),
|
||||
showCancel: false,
|
||||
});
|
||||
},
|
||||
@@ -292,7 +292,7 @@ Page({
|
||||
|
||||
const targetData = code ? data.watch : data.data;
|
||||
|
||||
if (!targetData?.url) {
|
||||
if (!targetData.extend?.fileid) {
|
||||
const stateParam = code ? -1 : 5;
|
||||
wx.reLaunch({
|
||||
url: `/pages/live/registration/registration?content=${targetData?.content || ''}&state=${stateParam}`,
|
||||
@@ -304,6 +304,7 @@ Page({
|
||||
dataList: targetData,
|
||||
eveId: targetData.eveId,
|
||||
nodes: htmlToWxNodes(targetData.content),
|
||||
fileid: targetData.extend.fileid,
|
||||
});
|
||||
|
||||
this.syncResumeTime();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { BASE_URL } from "../env";
|
||||
import { BASE_URL, appId } from "../env";
|
||||
import { base64Encode } from "./crypto";
|
||||
type RequestProps = {
|
||||
options: WechatMiniprogram.RequestOption;
|
||||
loadingTitle?: string;
|
||||
@@ -6,27 +7,23 @@ type RequestProps = {
|
||||
needLogin?: boolean;
|
||||
};
|
||||
|
||||
// 生成设备指纹字符串
|
||||
const generateFingerprint = (): string => {
|
||||
const info = wx.getSystemInfoSync();
|
||||
return [
|
||||
String(info.system),
|
||||
String(info.platform),
|
||||
String(info.SDKVersion),
|
||||
String(info.screenWidth),
|
||||
String(info.screenHeight),
|
||||
].join("&");
|
||||
};
|
||||
|
||||
// 每次请求动态生成 header,确保使用最新的 openId
|
||||
const fingerprint = wx.getSystemInfoSync();
|
||||
|
||||
export const request = <T = any>(
|
||||
{ options, loadingTitle = "加载中", isLoading = true }: RequestProps
|
||||
{ options, loadingTitle = "加载中", isLoading = true, needLogin = true }: RequestProps
|
||||
): Promise<T> => {
|
||||
|
||||
const app = getApp<IAppOption>();
|
||||
const header: any = {
|
||||
"X-Fingerprint": generateFingerprint(),
|
||||
"X-Fingerprint": fingerprint,
|
||||
};
|
||||
|
||||
if (needLogin) {
|
||||
if (!app.checkLoginState()) {
|
||||
return Promise.reject(new Error('请先登录'));
|
||||
}
|
||||
const openId = wx.getStorageSync("openId") || "";
|
||||
header.Authorization = `Basic ${base64Encode(`${openId}:${appId}`)}`
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let showToast = false;
|
||||
@@ -47,13 +44,27 @@ export const request = <T = any>(
|
||||
if (!res.data.code || res.data.code === 200) {
|
||||
resolve(res.data as T);
|
||||
} else if (res.data.code === 401) {
|
||||
// 保存当前页面路径,登录后跳转回来
|
||||
const pages = getCurrentPages();
|
||||
const currentPage = pages[pages.length - 1];
|
||||
if (currentPage) {
|
||||
const route = `/${currentPage.route}`;
|
||||
const options = currentPage.options || {};
|
||||
const query = Object.entries(options)
|
||||
.filter(([, value]) => value !== undefined && value !== null)
|
||||
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value as string)}`)
|
||||
.join("&");
|
||||
const fullPath = query ? `${route}?${query}` : route;
|
||||
wx.setStorageSync("redirectPath", fullPath);
|
||||
}
|
||||
wx.showModal({
|
||||
title: "登录提示",
|
||||
content: "请先登录",
|
||||
confirmText: "去登录",
|
||||
success: (options) => {
|
||||
if (options.confirm) {
|
||||
wx.navigateTo({ url: "/pages/login/login" });
|
||||
// 使用 redirectTo 替换当前页,登录页无返回按钮
|
||||
wx.redirectTo({ url: "/pages/login/login" });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
{
|
||||
"name": "pages/live/video/video",
|
||||
"pathName": "pages/live/video/video",
|
||||
"query": "code=oyydS188FNmOVk89F_bm56bUwVK8",
|
||||
"query": "code=2KnFxIm5GPLK7SLDhvoxdHTAZFrRAM34bi",
|
||||
"scene": null,
|
||||
"launchMode": "default"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user