直播更新

This commit is contained in:
陈誉午
2026-08-03 11:05:19 +08:00
parent 994b267f5c
commit d0776f9676
12 changed files with 288 additions and 177 deletions
+25 -3
View File
@@ -76,6 +76,26 @@ rich-content img {
display: block;
}
.report-nav-btn{
white-space: nowrap;
background: #FF4D4F;
color: #fff;
font-size: 22rpx;
padding: 6rpx 24rpx;
border-radius: 20rpx;
margin-bottom: 20rpx;
line-height: 1.5;
display: flex;
align-items: center;
justify-content: center;
border: none;
outline: none;
&:active {
opacity: 0.8;
transform: scale(0.95);
}
}
.error{
white-space: nowrap;
background: #FF4D4F;
@@ -107,14 +127,16 @@ rich-content img {
}
.history{
position: absolute;
right: 10rpx;
top: 110rpx;
position: fixed;
right: 0;
bottom: 40%;
display: flex;
justify-content: center;
align-items: center;
padding-left: 12rpx;
border-radius: 48rpx 0rpx 0rpx 48rpx;
box-sizing: border-box;
z-index: 999;
.icon{
width: 100rpx;
height: 80rpx;
+72 -36
View File
@@ -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`,
});
}
});
+9 -10
View File
@@ -1,16 +1,15 @@
<!--pages/video/video.wxml-->
<navigation-bar title="" back="{{true}}" bind:handleBack="handleBack" color="black" background="#FFF" />
<navigation-bar title="" back="{{false}}" bind:handleBack="handleBack" color="black" background="#FFF">
<view slot="left" class="report-nav-btn" bind:tap="handleCustomReport">举报</view>
</navigation-bar>
<view style="display: flex; align-items: center; justify-content: space-between; padding: 0 20rpx; height: 80rpx; background: #FFF7E6;">
<view style="font-size: 22rpx; color: #999;">本视频仅用于科普,无任何恶意引导行为</view>
<view style="display: flex; align-items: center; gap: 16rpx;">
<!-- <button open-type="feedback" class="error">微信举报</button> -->
<view class="error" bind:tap="handleCustomReport">举报</view>
</view>
</view>
<scroll-view class="scrollarea" scroll-y type="list">
<my-video src="{{dataList.url}}" backgroundUrl="{{dataList.background}}"></my-video>
<view style="display: flex; align-items: center; padding: 0 20rpx; height: 70rpx; background: #FFF7E6;">
<view style="font-size: 22rpx; color: #999;">本视频仅用于科普,无任何恶意引导行为</view>
</view>
<my-video id="myVideo" src="{{dataList.url}}" backgroundUrl="{{dataList.background}}"></my-video>
<block wx:if="{{dataList.tipUrl}}">
<image alt="提示" mode="widthFix" src="{{dataList.tipUrl}}" style="width: 100%" />
@@ -22,7 +21,7 @@
<form bindsubmit="handleSubmit" form-id="quizForm">
<my-quiz id="quizComponent" questions="{{dataList.questions}}" answerList="{{dataList.answerList}}" bind:change="onAnswerChange" />
<button wx:if="{{active === 0}}" class="btn" form-type="submit" style="bottom:{{safeBottom===0?24:safeBottom}}rpx">
{{canSubmit ? '提交答案领取红包' : '请观看完视频再前往答题'}}
{{canSubmit ? '提交答案领取红包' : '请观看完视频再前往互动'}}
</button>
</form>
</van-tab>