fix
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import UrlParamsHandler from "../../../utils/store";
|
import UrlParamsHandler from "../../../utils/store";
|
||||||
import { appversion, version } from "../../../env";
|
import { version } from "../../../env";
|
||||||
import { request } from "../../../utils/request";
|
import { request } from "../../../utils/request";
|
||||||
const defaultAvatarUrl =
|
const defaultAvatarUrl =
|
||||||
"https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0";
|
"https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0";
|
||||||
@@ -45,7 +45,7 @@ Page({
|
|||||||
};
|
};
|
||||||
const data = await request({
|
const data = await request({
|
||||||
options: {
|
options: {
|
||||||
url: `/app/video-watch/details?version=${version.details}&appVer=${appversion}`,
|
url: `/app/video-watch/details`,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
data: params,
|
data: params,
|
||||||
},
|
},
|
||||||
@@ -110,35 +110,35 @@ Page({
|
|||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面初次渲染完成
|
* 生命周期函数--监听页面初次渲染完成
|
||||||
*/
|
*/
|
||||||
onReady() {},
|
onReady() { },
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面显示
|
* 生命周期函数--监听页面显示
|
||||||
*/
|
*/
|
||||||
onShow() {},
|
onShow() { },
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面隐藏
|
* 生命周期函数--监听页面隐藏
|
||||||
*/
|
*/
|
||||||
onHide() {},
|
onHide() { },
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面卸载
|
* 生命周期函数--监听页面卸载
|
||||||
*/
|
*/
|
||||||
onUnload() {},
|
onUnload() { },
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页面相关事件处理函数--监听用户下拉动作
|
* 页面相关事件处理函数--监听用户下拉动作
|
||||||
*/
|
*/
|
||||||
onPullDownRefresh() {},
|
onPullDownRefresh() { },
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页面上拉触底事件的处理函数
|
* 页面上拉触底事件的处理函数
|
||||||
*/
|
*/
|
||||||
onReachBottom() {},
|
onReachBottom() { },
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户点击右上角分享
|
* 用户点击右上角分享
|
||||||
*/
|
*/
|
||||||
onShareAppMessage() {},
|
onShareAppMessage() { },
|
||||||
});
|
});
|
||||||
@@ -30,7 +30,7 @@ Page({
|
|||||||
nodes: [] as any[],
|
nodes: [] as any[],
|
||||||
eveId: null,
|
eveId: null,
|
||||||
store: {},
|
store: {},
|
||||||
fileid: "5001834818839455549",
|
fileid: "",
|
||||||
active: 0,
|
active: 0,
|
||||||
canSubmit: false,
|
canSubmit: false,
|
||||||
safeBottom: 24,
|
safeBottom: 24,
|
||||||
@@ -205,7 +205,7 @@ Page({
|
|||||||
const detail = (e && e.detail) || e || {};
|
const detail = (e && e.detail) || e || {};
|
||||||
wx.showModal({
|
wx.showModal({
|
||||||
title: "播放出错",
|
title: "播放出错",
|
||||||
content: String(detail.errMsg || detail.message || JSON.stringify(detail)),
|
content: String(detail.errMsg || detail.message || JSON.stringify(detail) + '请联系坐席'),
|
||||||
showCancel: false,
|
showCancel: false,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -292,7 +292,7 @@ Page({
|
|||||||
|
|
||||||
const targetData = code ? data.watch : data.data;
|
const targetData = code ? data.watch : data.data;
|
||||||
|
|
||||||
if (!targetData?.url) {
|
if (!targetData.extend?.fileid) {
|
||||||
const stateParam = code ? -1 : 5;
|
const stateParam = code ? -1 : 5;
|
||||||
wx.reLaunch({
|
wx.reLaunch({
|
||||||
url: `/pages/live/registration/registration?content=${targetData?.content || ''}&state=${stateParam}`,
|
url: `/pages/live/registration/registration?content=${targetData?.content || ''}&state=${stateParam}`,
|
||||||
@@ -304,6 +304,7 @@ Page({
|
|||||||
dataList: targetData,
|
dataList: targetData,
|
||||||
eveId: targetData.eveId,
|
eveId: targetData.eveId,
|
||||||
nodes: htmlToWxNodes(targetData.content),
|
nodes: htmlToWxNodes(targetData.content),
|
||||||
|
fileid: targetData.extend.fileid,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.syncResumeTime();
|
this.syncResumeTime();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { BASE_URL } from "../env";
|
import { BASE_URL, appId } from "../env";
|
||||||
|
import { base64Encode } from "./crypto";
|
||||||
type RequestProps = {
|
type RequestProps = {
|
||||||
options: WechatMiniprogram.RequestOption;
|
options: WechatMiniprogram.RequestOption;
|
||||||
loadingTitle?: string;
|
loadingTitle?: string;
|
||||||
@@ -6,27 +7,23 @@ type RequestProps = {
|
|||||||
needLogin?: boolean;
|
needLogin?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 生成设备指纹字符串
|
// 每次请求动态生成 header,确保使用最新的 openId
|
||||||
const generateFingerprint = (): string => {
|
const fingerprint = wx.getSystemInfoSync();
|
||||||
const info = wx.getSystemInfoSync();
|
|
||||||
return [
|
|
||||||
String(info.system),
|
|
||||||
String(info.platform),
|
|
||||||
String(info.SDKVersion),
|
|
||||||
String(info.screenWidth),
|
|
||||||
String(info.screenHeight),
|
|
||||||
].join("&");
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
export const request = <T = any>(
|
export const request = <T = any>(
|
||||||
{ options, loadingTitle = "加载中", isLoading = true }: RequestProps
|
{ options, loadingTitle = "加载中", isLoading = true, needLogin = true }: RequestProps
|
||||||
): Promise<T> => {
|
): Promise<T> => {
|
||||||
|
const app = getApp<IAppOption>();
|
||||||
const header: any = {
|
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) => {
|
return new Promise((resolve, reject) => {
|
||||||
let showToast = false;
|
let showToast = false;
|
||||||
@@ -47,13 +44,27 @@ export const request = <T = any>(
|
|||||||
if (!res.data.code || res.data.code === 200) {
|
if (!res.data.code || res.data.code === 200) {
|
||||||
resolve(res.data as T);
|
resolve(res.data as T);
|
||||||
} else if (res.data.code === 401) {
|
} 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({
|
wx.showModal({
|
||||||
title: "登录提示",
|
title: "登录提示",
|
||||||
content: "请先登录",
|
content: "请先登录",
|
||||||
confirmText: "去登录",
|
confirmText: "去登录",
|
||||||
success: (options) => {
|
success: (options) => {
|
||||||
if (options.confirm) {
|
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",
|
"name": "pages/live/video/video",
|
||||||
"pathName": "pages/live/video/video",
|
"pathName": "pages/live/video/video",
|
||||||
"query": "code=oyydS188FNmOVk89F_bm56bUwVK8",
|
"query": "code=2KnFxIm5GPLK7SLDhvoxdHTAZFrRAM34bi",
|
||||||
"scene": null,
|
"scene": null,
|
||||||
"launchMode": "default"
|
"launchMode": "default"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user