直播更新
This commit is contained in:
@@ -66,13 +66,10 @@ Page({
|
||||
const bool = await app.login("video");
|
||||
if (!bool) return;
|
||||
|
||||
// 在需要保护的页面调用
|
||||
// 开启防截屏(仅限当前页面生命周期内)
|
||||
//@ts-ignore
|
||||
wx.setVisualEffectOnCapture({
|
||||
visualEffect: 'hidden', // 录屏或截图时隐藏内容
|
||||
success: function () {
|
||||
console.log('防截屏录屏保护已开启');
|
||||
}
|
||||
visualEffect: 'hidden',
|
||||
});
|
||||
},
|
||||
|
||||
@@ -91,7 +88,7 @@ Page({
|
||||
|
||||
handleBack() {
|
||||
wx.switchTab({
|
||||
url: "/pages/tab-bar/course/course",
|
||||
url: "/pages/tab-bar/education/index",
|
||||
});
|
||||
},
|
||||
/**
|
||||
@@ -104,12 +101,24 @@ Page({
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() { },
|
||||
onHide() {
|
||||
// 离开视频页时恢复截屏能力,避免影响其他页面
|
||||
//@ts-ignore
|
||||
wx.setVisualEffectOnCapture({
|
||||
visualEffect: 'none',
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() { },
|
||||
onUnload() {
|
||||
// 卸载时恢复截屏能力
|
||||
//@ts-ignore
|
||||
wx.setVisualEffectOnCapture({
|
||||
visualEffect: 'none',
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
@@ -126,7 +135,7 @@ Page({
|
||||
*/
|
||||
onShareAppMessage() { },
|
||||
|
||||
onChange(e: any) {
|
||||
onChange(event: any) {
|
||||
this.setData({
|
||||
active: event.detail.index,
|
||||
});
|
||||
@@ -279,14 +288,14 @@ Page({
|
||||
if (code) {
|
||||
res = await request({
|
||||
options: {
|
||||
url: "/app/video-watch/interactive?version=" + version.interactive,
|
||||
url: "/app/video-watch/interactive",
|
||||
data: params,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
res = await request({
|
||||
options: {
|
||||
url: "/app/watch/interactive?version=" + version.interactive,
|
||||
url: "/app/watch/interactive",
|
||||
data: params,
|
||||
},
|
||||
});
|
||||
@@ -301,30 +310,54 @@ Page({
|
||||
return;
|
||||
}
|
||||
|
||||
const { pass, redId } = res.data;
|
||||
if (redId) {
|
||||
const { pass, redPackage } = res.data || {};
|
||||
if (pass) {
|
||||
wx.showModal({
|
||||
content: "🎉 领取红包!",
|
||||
showCancel: false,
|
||||
confirmText: "立即领取",
|
||||
confirmColor: "#FF0000",
|
||||
success: (res) => {
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
this.handleReceive(redId);
|
||||
if (redPackage?.packageInfo) {
|
||||
try {
|
||||
wx.showLoading({ title: "领取中", mask: true });
|
||||
if (wx.canIUse?.("requestMerchantTransfer")) {
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
// @ts-ignore
|
||||
wx.requestMerchantTransfer({
|
||||
mchId: redPackage.mchId,
|
||||
appId,
|
||||
package: redPackage.packageInfo,
|
||||
success: () => {
|
||||
wx.showToast({ title: "领取成功", icon: "success" });
|
||||
resolve();
|
||||
},
|
||||
fail: (err: any) => {
|
||||
console.error("拉起转账失败:", err);
|
||||
wx.showToast({ title: "领取失败", icon: "none" });
|
||||
reject(new Error(err?.errMsg || "领取失败"));
|
||||
},
|
||||
});
|
||||
});
|
||||
} else {
|
||||
wx.showModal({
|
||||
content: "你的微信版本过低,请更新至最新版本。",
|
||||
showCancel: false,
|
||||
});
|
||||
throw new Error("微信版本过低");
|
||||
}
|
||||
} catch (err: any) {
|
||||
wx.hideLoading();
|
||||
const msg = err?.data?.msg || err?.errMsg || err?.message || "领取失败";
|
||||
wx.showToast({ title: msg, icon: "none" });
|
||||
}
|
||||
} else {
|
||||
await this.handleReceive(redPackage.redId);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (pass) {
|
||||
|
||||
wx.showModal({
|
||||
content: "🎉 恭喜您获得红包!",
|
||||
showCancel: false,
|
||||
confirmText: "确定",
|
||||
confirmColor: "#FF0000",
|
||||
|
||||
});
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: "回答错误,您与红包擦肩而过",
|
||||
@@ -333,8 +366,7 @@ Page({
|
||||
});
|
||||
}
|
||||
},
|
||||
async handleReceive(e: any) {
|
||||
const { id } = e.currentTarget.dataset;
|
||||
async handleReceive(id: any) {
|
||||
const { code } = this.data.store as Record<string, any>;
|
||||
const params = {
|
||||
appId,
|
||||
@@ -352,30 +384,34 @@ Page({
|
||||
console.error('领取红包失败:', err);
|
||||
}
|
||||
},
|
||||
// 跳转前暂停视频播放
|
||||
pauseVideoBeforeNavigate() {
|
||||
const video = this.selectComponent("#myVideo") as any;
|
||||
if (video && video.pauseVideo) {
|
||||
video.pauseVideo();
|
||||
}
|
||||
},
|
||||
|
||||
handleCustomReport() {
|
||||
this.pauseVideoBeforeNavigate();
|
||||
const { code, state, seeId } = this.data.store as Record<string, any>;
|
||||
const params: Record<string, string> = {};
|
||||
if (code) params.code = code;
|
||||
if (state) params.state = state;
|
||||
if (seeId) params.seeId = seeId;
|
||||
const query = Object.entries(params)
|
||||
.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
|
||||
.join("&");
|
||||
wx.navigateTo({
|
||||
url: `/pages/live/report/report${query ? `?${query}` : ""}`,
|
||||
url: `/pages/live/report/report`,
|
||||
});
|
||||
},
|
||||
handleViewHitory() {
|
||||
this.pauseVideoBeforeNavigate();
|
||||
const { code, state, seeId } = this.data.store as Record<string, any>;
|
||||
const params: Record<string, string> = {};
|
||||
if (code) params.code = code;
|
||||
if (state) params.state = state;
|
||||
if (seeId) params.seeId = seeId;
|
||||
const query = Object.entries(params)
|
||||
.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
|
||||
.join("&");
|
||||
wx.navigateTo({
|
||||
url: `/pages/live/red-history/red-history${query ? `?${query}` : ""}`,
|
||||
url: `/pages/live/red-history/red-history`,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user