feat: 电子药箱小程序 - 4Tab药品管理

- 电子药箱: 药品库存管理 + 手动录入 + 今日用药打卡
- 药品百科: 搜索 + 分类筛选 + 20种药品静态数据
- 惠教中心: 4条药品使用指南课程
- 我的: 家庭成员信息管理
- 自定义TabBar + navigation-bar组件
- SVG药品分类插图
This commit is contained in:
陈誉午
2026-07-29 11:20:52 +08:00
commit 994b267f5c
683 changed files with 43849 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
{
"disableScroll": true,
"navigationBarBackgroundColor": "#FFFFFF",
"usingComponents": {}
}
+112
View File
@@ -0,0 +1,112 @@
/* pages/live/h5Room/index.wxss */
page {
height: 100%;
background: #eaf6ff;
overflow: hidden;
}
.h5-room {
width: 100%;
min-height: 100vh;
background: #fff;
padding: 0;
box-sizing: border-box;
}
.h5-room__nav {
position: relative;
width: 100%;
background: linear-gradient(135deg, #edf8ff 0%, #dbeeff 48%, #cae5ff 100%);
box-sizing: border-box;
overflow: hidden;
box-shadow: inset 0 -1px 0 rgba(120, 180, 255, 0.14);
}
.h5-room__nav-status {
position: relative;
z-index: 2;
width: 100%;
background: transparent;
}
.h5-room__nav-bg,
.h5-room__nav-grid,
.h5-room__nav-glow,
.h5-room__nav-bubble {
position: absolute;
}
.h5-room__nav-bg {
top: 0;
right: 0;
bottom: 0;
left: 0;
background:
radial-gradient(circle at 14% 82%, rgba(74, 183, 255, 0.26) 0%, rgba(74, 183, 255, 0) 28%),
radial-gradient(circle at 88% 22%, rgba(93, 255, 240, 0.22) 0%, rgba(93, 255, 240, 0) 20%),
radial-gradient(circle at 76% 84%, rgba(123, 152, 255, 0.18) 0%, rgba(123, 152, 255, 0) 24%),
linear-gradient(135deg, #edf8ff 0%, #dbeeff 48%, #cae5ff 100%);
}
.h5-room__nav-grid {
top: 0;
right: 0;
bottom: 0;
left: 0;
opacity: 0.42;
background-image:
linear-gradient(rgba(255, 255, 255, 0.32) 1px, transparent 1px),
linear-gradient(90deg, rgba(255, 255, 255, 0.28) 1px, transparent 1px);
background-size: 18px 18px;
background-position: center center;
}
.h5-room__nav-glow {
border-radius: 999rpx;
background: rgba(255, 255, 255, 0.28);
}
.h5-room__nav-glow--left {
top: 20rpx;
left: -36rpx;
width: 220rpx;
height: 220rpx;
}
.h5-room__nav-glow--right {
right: -30rpx;
bottom: -72rpx;
width: 260rpx;
height: 260rpx;
background: rgba(147, 177, 255, 0.2);
}
.h5-room__nav-bubble {
border-radius: 50%;
background: rgba(71, 170, 255, 0.5);
box-shadow: 0 0 0 10rpx rgba(255, 255, 255, 0.12);
}
.h5-room__nav-bubble--sm {
top: 22rpx;
right: 184rpx;
width: 12rpx;
height: 12rpx;
background: rgba(89, 187, 255, 0.8);
}
.h5-room__nav-bubble--md {
top: 66rpx;
left: 112rpx;
width: 18rpx;
height: 18rpx;
background: rgba(79, 165, 255, 0.58);
}
.h5-room__nav-bubble--lg {
right: 64rpx;
bottom: 18rpx;
width: 28rpx;
height: 28rpx;
background: rgba(120, 157, 255, 0.38);
}
+108
View File
@@ -0,0 +1,108 @@
// pages/live/h5Room/index.ts
import { appId } from "../../../env";
Page({
/**
* 页面的初始数据
*/
data: {
webViewUrl: "",
webViewHeight: 0,
statusBarHeight: 0,
navBarHeight: 0,
},
async onLoad(options: any) {
const windowInfo = (wx as any).getWindowInfo
? (wx as any).getWindowInfo()
: wx.getSystemInfoSync();
const menuButtonRect = wx.getMenuButtonBoundingClientRect();
const statusBarHeight =
windowInfo.safeArea?.top || windowInfo.statusBarHeight || 0;
const navBarHeight = menuButtonRect?.top
? menuButtonRect.bottom + menuButtonRect.top - statusBarHeight
: statusBarHeight + 44;
const webViewHeight = Math.max(
(windowInfo.windowHeight || 0) - navBarHeight,
0,
);
this.setData({
statusBarHeight,
navBarHeight,
webViewHeight,
});
const app = getApp<IAppOption>();
const bool = await app.login("room");
if (!bool) return;
try {
// const baseUrl = "http://localhost:5173/pages/room";
const baseUrl = "https://live.byteoc.com/1859506470730939/1425285?platform=mobile";
const openId = wx.getStorageSync("openId");
const roomId = options?.roomId;
const params: Record<string, string> = {};
if (openId) params.openId = openId;
if (appId) params.appId = appId;
if (roomId) params.roomId = roomId;
if (options?.extraParams) {
try {
const extraParams = JSON.parse(
decodeURIComponent(options.extraParams),
);
Object.entries(extraParams).forEach(([key, value]) => {
params[key] = String(value);
});
} catch (e) {
console.warn("Failed to parse extra parameters");
}
}
const queryString = Object.entries(params)
.map(
([key, value]) =>
`${encodeURIComponent(key)}=${encodeURIComponent(value)}`,
)
.join("&");
const finalUrl = `${baseUrl}?${queryString}`;
this.setData({
webViewUrl: finalUrl,
});
} catch (error) {
console.error("Error generating URL:", error);
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {},
});
+2
View File
@@ -0,0 +1,2 @@
<!--pages/live/h5Room/index.wxml-->
<text>pages/live/h5Room/index.wxml</text>
@@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1744786271399" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M832 192H192c-35.2 0-64 28.8-64 64v512c0 35.2 28.8 64 64 64h640c35.2 0 64-28.8 64-64V256c0-35.2-28.8-64-64-64z" fill="#F56C6C"/><path d="M192 192h640L512 448 192 192z" fill="#F78989"/><path d="M512 512m-48 0a48 48 0 1 0 96 0 48 48 0 1 0-96 0Z" fill="#FFD700"/></svg>

After

Width:  |  Height:  |  Size: 545 B

@@ -0,0 +1,7 @@
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar",
"van-tabs": "@vant/weapp/tabs/index",
"van-tab": "@vant/weapp/tab/index"
}
}
@@ -0,0 +1,184 @@
.page-wrap {
box-sizing: border-box;
background: #f5f5f5;
height: calc(100vh - 162rpx);
display: flex;
flex-direction: column;
}
/* ===== 汇总卡片 ===== */
.summary-section {
padding: 24rpx 24rpx 0;
}
.summary-card {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 20rpx;
border-radius: 16rpx;
}
.total-card {
background: linear-gradient(135deg, #ff4d4f 0%, #ff7875 100%);
margin-bottom: 16rpx;
padding: 28rpx 20rpx;
}
.total-card .card-label {
color: rgba(255, 255, 255, 0.85);
font-size: 26rpx;
}
.total-amount {
color: #fff !important;
font-size: 48rpx !important;
}
.summary-row {
display: flex;
gap: 16rpx;
}
.sub-card {
flex: 1;
background: #fff;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06);
padding: 24rpx 10rpx;
}
.card-label {
font-size: 22rpx;
color: #999;
margin-bottom: 10rpx;
}
.card-amount {
font-size: 30rpx;
font-weight: 700;
}
.card-amount.received {
color: #52c41a;
}
.card-amount.pending {
color: #fa8c16;
}
.card-amount.expired {
color: #999;
}
.tabs-wrap {
margin: 16rpx;
}
/* ===== 红包列表 ===== */
.red-history {
flex: 1;
background: #f5f5f5;
margin-top: 16rpx;
overflow: hidden;
}
.list-scroll {
height: 100%;
overflow: auto;
}
.record {
display: flex;
align-items: center;
padding: 24rpx 30rpx;
background: #fff;
border-bottom: 1px solid #eee;
margin: 0 24rpx;
border-radius: 12rpx;
margin-bottom: 12rpx;
}
.record:first-child {
margin-top: 12rpx;
}
.red-icon {
width: 70rpx;
height: 140rpx;
flex-shrink: 0;
}
.content {
flex: 1;
margin-left: 20rpx;
min-width: 0;
}
.name {
font-size: 28rpx;
color: #333;
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.time {
font-size: 24rpx;
color: #999;
display: block;
margin-top: 8rpx;
}
.right {
display: flex;
flex-direction: column;
align-items: flex-end;
flex-shrink: 0;
}
.amount {
font-size: 32rpx;
color: #ff4d4f;
font-weight: 600;
}
.state-text {
font-size: 24rpx;
color: #999;
margin-top: 8rpx;
}
.receive-btn {
margin-top: 12rpx;
padding: 8rpx 28rpx;
font-size: 24rpx;
color: #fff;
background: #ff4d4f;
border-radius: 24rpx;
line-height: 1.4;
}
.no-more {
text-align: center;
padding: 30rpx 0;
font-size: 24rpx;
color: #999;
}
.loading-tip {
text-align: center;
padding: 20rpx 0;
font-size: 24rpx;
color: #999;
}
.no-data {
display: flex;
justify-content: center;
align-items: center;
flex: 0.9;
font-size: 32rpx;
color: #999;
}
@@ -0,0 +1,196 @@
import { appId } from "../../../env";
import { request } from "../../../utils/request";
import { receiveRedPacket } from "../../../utils/util";
const app = getApp<IAppOption>();
const formatDate = (isoString: string): string => {
const date = new Date(isoString);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
return `${year}-${month}-${day} ${hours}:${minutes}`;
};
const RED_STATE_MAP: Record<number, string> = {
10: "未发送",
11: "等待领取",
20: "正在发送",
21: "等待确认",
30: "发送失败",
31: "个数不够",
32: "账户余额不足",
33: "客户未实名",
34: "其它原因",
40: "已领取",
50: "已过期",
};
const getStateText = (state: number) => {
return RED_STATE_MAP[state] || "发放中";
};
const FAILED_STATES = [30, 31, 32, 33, 34];
const canReceive = (state: number) => {
return state === 11 || state === 21 || FAILED_STATES.includes(state);
};
const isRetry = (state: number) => {
return FAILED_STATES.includes(state);
};
Page({
data: {
list: [] as any[],
loading: false,
hasMore: true,
current: 1,
pageSize: 15,
activeTab: 0,
tabs: [
{ label: '待领取', value: 0, type: 1 },
{ label: '已领取', value: 1, type: 2 },
{ label: '已过期', value: 2, type: 3 },
],
summary: {
totalAmount: '0.00',
receivedAmount: '0.00',
pendingAmount: '0.00',
expiredAmount: '0.00',
},
store: {},
safeBottom: app.globalData.safeBottom,
safeTop: app.globalData.safeTop,
},
async onLoad() {
await this.fetchRecords(1, false, this.data.tabs[0].type);
},
onReachBottom() {
if (this.data.loading || !this.data.hasMore) return;
const nextPage = this.data.current + 1;
this.fetchRecords(nextPage, true, this.data.tabs[this.data.activeTab].type);
},
onTabChange(e: any) {
const index = e.detail.index;
const tab = this.data.tabs[index];
this.setData({ activeTab: index });
this.fetchRecords(1, false, tab.type);
},
async handleReceive(e: any) {
const { id } = e.currentTarget.dataset;
const { code } = this.data.store as Record<string, any>;
const params = {
appId,
code,
openId: wx.getStorageSync("openId"),
redId: id,
}
try {
await receiveRedPacket(
params,
'/app/general/receive-red',
appId
);
// 领取成功,刷新当前列表
this.fetchRecords(1, false, this.data.tabs[this.data.activeTab].type);
} catch (err) {
console.error('领取红包失败:', err);
}
},
async fetchRecords(page: number, append = false, type: number) {
const app = getApp<IAppOption>();
const openId = wx.getStorageSync("openId");
this.setData({
store: app.globalData.store,
});
if (!openId) {
wx.showToast({ title: "请先登录", icon: "none" });
return;
}
if (append) {
this.setData({ loading: true });
} else {
wx.showLoading({ title: "加载中" });
}
try {
let res: any;
const { state, seeId, code } = this.data.store as Record<string, any>;
const params: Record<string, any> = {};
params.openId = openId;
params.current = page;
params.pageSize = 15;
params.type = type;
if (code) params.code = code;
if (state) params.state = state;
if (seeId) params.seeId = seeId;
// if (code) {
res = await request({
options: {
url: "/app/video-watch/record",
data: params,
},
isLoading: !append,
// needLogin: false,
});
// } else {
// res = await request({
// options: {
// url: "/live/watch/record",
// data: params,
// },
// isLoading: !append,
// needLogin: false,
// });
// }
const records = res.data?.records || res.records || [];
const items = records.map((item: any) => ({
...item,
date: formatDate(item.createdTime),
stateText: getStateText(item.state),
amountText: `${(item.amount / 100).toFixed(2)}`,
canReceive: canReceive(item.state),
isRetry: isRetry(item.state),
}));
this.setData({
list: append ? [...this.data.list, ...items] : items,
current: page,
hasMore: records.length >= this.data.pageSize,
});
// 汇总数据在 res.data 根层级,单位是分,转为元
const d = res.data;
if (d && d.totalAmount !== undefined) {
this.setData({
summary: {
totalAmount: (d.totalAmount / 100).toFixed(2),
receivedAmount: (d.receivedAmount / 100).toFixed(2),
pendingAmount: (d.pendingAmount / 100).toFixed(2),
expiredAmount: (d.expiredAmount / 100).toFixed(2),
},
});
}
} catch (err) {
console.error("加载红包记录失败:", err);
} finally {
if (append) {
this.setData({ loading: false });
} else {
wx.hideLoading();
}
}
},
});
@@ -0,0 +1,57 @@
<navigation-bar title="红包记录" back="{{true}}" color="black" background="#FFF" />
<view class="page-wrap">
<view class="summary-section">
<view class="summary-card total-card">
<text class="card-label">总领取金额</text>
<text class="card-amount total-amount">¥{{summary.totalAmount}}</text>
</view>
<view class="summary-row">
<view class="summary-card sub-card">
<text class="card-label">待领取金额</text>
<text class="card-amount pending">¥{{summary.pendingAmount}}</text>
</view>
<view class="summary-card sub-card">
<text class="card-label">已领取金额</text>
<text class="card-amount received">¥{{summary.receivedAmount}}</text>
</view>
<view class="summary-card sub-card">
<text class="card-label">已过期金额</text>
<text class="card-amount expired">¥{{summary.expiredAmount}}</text>
</view>
</view>
</view>
<view class="tabs-wrap">
<van-tabs active="{{activeTab}}" bind:change="onTabChange" animated>
<van-tab wx:for="{{tabs}}" wx:key="value" title="{{item.label}}" />
</van-tabs>
</view>
<view wx:if="{{list.length}}" class="red-history">
<scroll-view
class="list-scroll"
scroll-y
bindscrolltolower="onReachBottom"
lower-threshold="200"
>
<view class="record" wx:for="{{list}}" wx:key="id">
<image class="red-icon" src="./assets/red.svg" mode="aspectFill"/>
<view class="content">
<text class="name">{{item.description}}</text>
<text class="time">{{item.date}}</text>
</view>
<view class="right">
<text class="amount">¥{{item.amountText}}</text>
<view wx:if="{{item.canReceive}}" class="receive-btn" data-id="{{item.id}}" bind:tap="handleReceive">{{item.isRetry ? '重试' : '领取'}}</view>
<text wx:else class="state-text">{{item.stateText}}</text>
</view>
</view>
<view wx:if="{{!hasMore}}" class="no-more">没有更多数据了</view>
<view wx:if="{{loading}}" class="loading-tip">加载中...</view>
</scroll-view>
</view>
<view wx:else class="no-data">暂无记录</view>
</view>
@@ -0,0 +1,9 @@
{
"backgroundTextStyle": "light",
"backgroundColor": "#ffffff",
"navigationBarShareAppMessage": false,
"navigationBarShareTimeline": false,
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}
@@ -0,0 +1,102 @@
@import "../../../variables";
/* pages/live/registration.wxss */
.page-result {
box-sizing: border-box;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
padding-top: 180rpx;
.clock-icon,
.success-container,
.forbid-container {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 40rpx;
image {
width: 200rpx;
height: 200rpx;
margin-bottom: 30rpx;
}
.success-icon {
width: 240rpx;
height: 240rpx;
/* 使用滤镜改变颜色为 #0dc70d 绿色 */
filter: brightness(0) saturate(100%) invert(48%) sepia(99%) saturate(748%) hue-rotate(90deg) brightness(90%) contrast(85%);
}
}
.text-group {
display: flex;
flex-direction: column;
align-items: center;
text {
margin-bottom: 20rpx;
font-size: 32rpx;
}
}
.info {
margin-top: 80rpx;
width: 90%;
text-align: center;
z-index: 9999;
font-size: 20px;
color: #c6c6c6;
}
.color-green {
color: #0dc70d;
}
.userinfo {
display: flex;
align-items: center;
margin-bottom: 15vh;
border: 1px solid #ccc;
padding: 30rpx ;
border-radius: 25rpx;
.choose-avatar {
padding: 0;
margin: 0;
border: none;
background: none;
width: 120rpx;
height: 120rpx;
border-radius: 50%;
overflow: hidden;
display: inline-block;
}
button::after {
border: none;
}
.avatar {
width: 113rpx;
height: 113rpx;
border-radius: 50%;
border: 2px solid $primary-color;
display: block;
}
.nickname {
width: 300rpx;
margin-left: $primary-gap;
font-size: $large-font-size;
font-weight: 800;
}
.refresh {
width: 150rpx;
height: 50rpx;
line-height: 50rpx;
text-align: center;
border-radius: 25rpx;
border: 1px solid $primary-color;
color: $primary-color;
font-size: $large-font-size;
}
}
}
@@ -0,0 +1,144 @@
import UrlParamsHandler from "../../../utils/store";
import { appversion, version } from "../../../env";
import { request } from "../../../utils/request";
const defaultAvatarUrl =
"https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0";
// pages/live/registration/registration.ts
Page({
/**
* 页面的初始数据
*/
data: {
userInfo: {
avatarUrl: wx.getStorageSync("avatarUrl") || defaultAvatarUrl,
nickName: wx.getStorageSync("userName") || "未登录用户",
},
state: -1,
info: "",
content: "",
},
async register(state: string) {
const app = getApp<IAppOption>();
const bool = await app.login("register");
if (!bool) return;
const params = {
openId: wx.getStorageSync("openId"),
state,
};
return await request({
options: {
url: "/app/watch/register?version=" + version.register,
data: params,
},
});
},
async registers(code: string) {
const app = getApp<IAppOption>();
const bool = await app.login("register");
if (!bool) return;
const params = {
openId: wx.getStorageSync("openId"),
code,
};
const data = await request({
options: {
url: `/app/video-watch/details?version=${version.details}&appVer=${appversion}`,
method: "GET",
data: params,
},
});
if (!data.watch.url) {
this.setData({
content: data.watch.content,
state: -1,
});
} else {
wx.redirectTo({
url: `/pages/live/video/video?openId=${params.openId}&code=${params.code}&seeId=${data.watch.id}`,
});
}
},
async refresh() {
const params = {
openId: wx.getStorageSync("openId"),
code: wx.getStorageSync("code"),
};
const res = await request({
options: {
url: "/app/video-watch/refresh",
method: "GET",
data: params,
},
});
if (res.pass)
wx.redirectTo({
url: `/pages/live/video/video?openId=${params.openId}&code=${params.code}`,
});
},
/**
* 生命周期函数--监听页面加载
*/
async onLoad(options: any) {
new UrlParamsHandler(options);
wx.hideShareMenu({
menus: ["shareAppMessage"], // 单独禁用好友分享
});
if (options.code && !options.content) {
this.registers(options.code);
}
if (options.state && typeof options.state != "number" && !options.content) {
const res = await this.register(options.state);
if (res.code == 200) {
this.setData({
state: res.data.state,
info: res.data.info,
});
}
}
if (options.content) {
this.setData({
content: options.content,
state: options.state,
});
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {},
});
@@ -0,0 +1,54 @@
<!--pages/live/registration/registration.wxml-->
<navigation-bar title="会员认证" back="{{false}}" color="black" background="#FFF" />
<view class="page-result">
<block wx:if="{{!content && state === -1}}"></block>
<block wx:elif="{{state === 1}}">
<view class="clock-icon">
<image src="/assets/img/clock.svg" mode="aspectFit" />
</view>
<view class="text-group">
<text class="color-gray">审核中...</text>
<text class="color-gray">恭喜您成功参与福利!</text>
<text class="color-gray">请联系群主审核即可!</text>
</view>
</block>
<block wx:elif="{{state === 2}}">
<view class="success-container">
<image class="success-icon" src="/assets/img/success.svg" mode="aspectFit" />
<text class="color-green">认证已通过</text>
</view>
</block>
<block wx:elif="{{state === 4}}">
<image src="/assets/img/600.jpg" mode="widthFix" />
</block>
<block wx:elif="{{content}}">
<view class="forbid-container" wx:if="{{state > 0}}">
<image src="/assets/img/forbid.svg" mode="aspectFit" />
<view style="white-space:pre-wrap">{{content}}</view>
</view>
<block wx:if="{{state < 0}}">
<view class="userinfo" >
<button class="choose-avatar">
<image class="avatar" src="{{userInfo.avatarUrl}}" />
</button>
<view class="nickname">{{userInfo.nickName}}</view>
<view class="refresh" bind:tap="refresh">刷新</view>
</view>
<view style="white-space:pre-wrap">{{content}}</view>
</block>
</block>
<block wx:else>
<view class="forbid-container">
<image src="/assets/img/forbid.svg" mode="aspectFit" />
<text>暂无法访问该功能,如有疑问请联系客服</text>
</view>
</block>
<view class="info" wx:if="{{info}}">{{info}}</view>
</view>
@@ -0,0 +1,6 @@
{
"disableScroll": true,
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}
+384
View File
@@ -0,0 +1,384 @@
@import "../../../variables";
/* pages/live/report/report.scss */
page {
background: #f5f5f5;
}
.report-page {
display: flex;
flex-direction: column;
padding-bottom: 120rpx;
padding-top: 30rpx;
background: #f5f5f5;
box-sizing: border-box;
}
/* ===== Section Card ===== */
.section-card {
background: #fff;
margin: 0 24rpx 16rpx;
border-radius: $primary-border-radius;
padding: 0 32rpx;
overflow: hidden;
}
.section-title {
font-size: 28rpx;
color: #333;
font-weight: 500;
padding: 28rpx 0;
line-height: 1;
}
.section-header {
font-size: 32rpx;
color: #333;
font-weight: 600;
padding: 32rpx 32rpx 24rpx;
line-height: 1;
text-align: center;
}
/* ===== Step 1: Reason List ===== */
.reason-list-scroll {
height: 100vh;
overflow-y: scroll;
}
.reason-list {
padding: 0;
}
.reason-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 28rpx 0;
border-bottom: 1rpx solid #f5f5f5;
box-sizing: border-box;
}
.reason-item:last-child {
border-bottom: none;
}
.reason-item:active {
background: #fafafa;
margin: 0 -32rpx;
padding-left: 32rpx;
padding-right: 32rpx;
}
.reason-label {
font-size: 28rpx;
color: #333;
line-height: 1.4;
}
.reason-arrow {
width: 12rpx;
height: 12rpx;
border-top: 3rpx solid #b0b0b0;
border-right: 3rpx solid #b0b0b0;
transform: rotate(45deg);
flex-shrink: 0;
margin-left: 12rpx;
}
/* ===== Target Info ===== */
.target-row {
display: flex;
align-items: center;
padding: 24rpx 0;
}
.target-avatar {
width: 88rpx;
height: 88rpx;
border-radius: 50%;
margin-right: 24rpx;
flex-shrink: 0;
background: #f0f0f0;
border: 2rpx solid #f0f0f0;
}
.target-info {
display: flex;
flex-direction: column;
flex: 1;
min-width: 0;
}
.target-name {
font-size: 32rpx;
color: #333;
font-weight: 600;
line-height: 1.4;
}
.target-context {
font-size: 24rpx;
color: #999;
margin-top: 6rpx;
line-height: 1.4;
}
/* ===== Selected Reason Row ===== */
.selected-reason-row {
padding: 28rpx 0;
}
.selected-reason-text {
font-size: 28rpx;
line-height: 1.4;
font-weight: 500;
}
/* ===== Description ===== */
.desc-wrap {
padding-bottom: 16rpx;
}
.desc-textarea {
width: 100%;
min-height: 180rpx;
font-size: 28rpx;
color: #333;
line-height: 1.6;
border: none;
outline: none;
box-sizing: border-box;
padding: 16rpx 0 12rpx;
}
.desc-textarea::placeholder {
color: #c8c8c8;
}
.char-count {
font-size: 24rpx;
color: $gray-color;
text-align: right;
padding-bottom: 16rpx;
}
/* ===== Image Upload ===== */
.evidence-tip {
font-size: 24rpx;
color: $gray-color;
font-weight: normal;
}
.upload-grid {
display: flex;
flex-wrap: wrap;
padding-bottom: 28rpx;
}
.upload-cell {
width: 200rpx;
height: 200rpx;
margin-right: 12rpx;
margin-bottom: 12rpx;
position: relative;
overflow: hidden;
border-radius: 12rpx;
}
.upload-cell:nth-child(3n) {
margin-right: 0;
}
.upload-img {
width: 100%;
height: 100%;
display: block;
object-fit: cover;
}
.upload-close {
position: absolute;
top: 0;
right: 0;
width: 44rpx;
height: 44rpx;
display: flex;
align-items: center;
justify-content: center;
background: rgba(0, 0, 0, 0.45);
color: #fff;
font-size: 26rpx;
line-height: 1;
}
.upload-add {
border: 2rpx dashed #d0d0d0;
display: flex;
align-items: center;
justify-content: center;
font-size: 72rpx;
color: #d0d0d0;
line-height: 1;
background: #fafafa;
box-sizing: border-box;
}
.upload-add:active {
background: #f0f0f0;
}
/* ===== Unified Card (投诉原因+补充描述+图片证据) ===== */
.unified-card {
padding-bottom: 0;
}
.unified-divider {
height: 1rpx;
background: #f0f0f0;
margin: 0;
}
/* ===== Agreement ===== */
.agreement-section {
padding: 28rpx 32rpx;
background: transparent;
}
.agreement-row {
display: flex;
align-items: center;
}
.agreement-check-circle {
width: 36rpx;
height: 36rpx;
border-radius: 50%;
border: 2rpx solid #d0d0d0;
display: flex;
align-items: center;
justify-content: center;
margin-right: 14rpx;
flex-shrink: 0;
box-sizing: border-box;
}
.agreement-check-circle.checked {
background: #07c160;
border-color: #07c160;
}
.agreement-check-icon {
color: #fff;
font-size: 22rpx;
line-height: 1;
font-weight: bold;
}
.agreement-text {
font-size: 24rpx;
color: #999;
}
.agreement-link {
font-size: 24rpx;
color: $primary-color-blue;
}
/* ===== Bottom Submit Bar ===== */
.bottom-bar {
position: fixed;
left: 0;
right: 0;
bottom: 0;
padding: 20rpx 32rpx;
padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
background: #fff;
box-sizing: border-box;
box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.04);
}
.submit-btn {
width: 100%;
height: 88rpx;
line-height: 88rpx;
background: #07c160;
color: #fff;
font-size: 32rpx;
font-weight: 500;
border-radius: 8rpx;
border: none;
text-align: center;
padding: 0;
}
.submit-btn[disabled] {
background: #e0e0e0;
color: #999;
}
.submit-btn:not([disabled]):active {
opacity: 0.85;
}
/* ===== Step 3: Success ===== */
.success-content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 200rpx 60rpx 60rpx;
box-sizing: border-box;
}
.success-icon-wrap {
width: 120rpx;
height: 120rpx;
border-radius: 50%;
background: #07c160;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 40rpx;
}
.success-check {
color: #fff;
font-size: 60rpx;
line-height: 1;
font-weight: bold;
}
.success-title {
font-size: 36rpx;
font-weight: 600;
color: #333;
margin-bottom: 20rpx;
}
.success-desc {
font-size: 26rpx;
color: #999;
line-height: 1.6;
text-align: center;
margin-bottom: 72rpx;
}
.success-btn {
width: 400rpx;
height: 88rpx;
line-height: 88rpx;
background: #07c160;
color: #fff;
font-size: 30rpx;
border-radius: 8rpx;
border: none;
text-align: center;
padding: 0;
}
.success-btn:active {
opacity: 0.85;
}
+139
View File
@@ -0,0 +1,139 @@
import { appId } from "../../../env";
import { request } from "../../../utils/request";
Page({
data: {
pageStep: 1 as number,
targetAvatar: '',
targetName: '',
targetContext: '',
reasons: [
{ id: 1, label: '欺诈' },
{ id: 2, label: '色情低俗' },
{ id: 3, label: '诱导' },
{ id: 4, label: '传播不实信息' },
{ id: 5, label: '违法犯罪' },
{ id: 6, label: '骚扰' },
{ id: 7, label: '侵权(诽谤、抄袭)' },
{ id: 8, label: '混淆他人投诉' },
{ id: 9, label: '恶意营销' },
{ id: 10, label: '与服务类目不符' },
{ id: 11, label: '隐私信息收集' },
{ id: 12, label: '广告体验' },
{ id: 13, label: '其他' },
],
selectedReason: '',
description: '',
descriptionLen: 0 as number,
imageList: [] as string[],
isAgreed: true as boolean,
canSubmit: false as boolean,
},
onLoad(options: any) {
if (options?.targetName) {
this.setData({
targetName: decodeURIComponent(options.targetName),
targetContext: options.targetContext || '',
targetAvatar: options.targetAvatar || '',
});
}
},
onReasonTap(e: any) {
const { id } = e.currentTarget.dataset;
const reason = this.data.reasons.find((r: any) => r.id === Number(id));
if (reason) {
this.setData({
selectedReason: reason.label,
pageStep: 2,
isAgreed: true,
});
this.updateCanSubmit();
}
},
updateCanSubmit() {
const d = this.data;
this.setData({ canSubmit: !!d.selectedReason && !!d.description && d.isAgreed && d.imageList.length > 0 });
},
onDescriptionInput(e: any) {
this.setData({
description: e.detail.value,
descriptionLen: e.detail.value.length,
});
this.updateCanSubmit();
},
onChooseImage() {
wx.chooseMedia({
count: 9 - this.data.imageList.length,
mediaType: ['image'],
sourceType: ['album', 'camera'],
success: (res: any) => {
const tempFiles = res.tempFiles || [];
const newImages = tempFiles.map((f: any) => f.tempFilePath || f.path);
this.setData({
imageList: [...this.data.imageList, ...newImages],
}, () => {
this.updateCanSubmit();
});
},
});
},
onRemoveImage(e: any) {
const { index } = e.currentTarget.dataset;
const list = [...this.data.imageList];
list.splice(index, 1);
this.setData({ imageList: list }, () => {
this.updateCanSubmit();
});
},
toggleAgree() {
this.setData({ isAgreed: !this.data.isAgreed });
this.updateCanSubmit();
},
async handleSubmit() {
if (!this.data.canSubmit) {
return;
}
if (!this.data.selectedReason) {
wx.showToast({ title: '请选择投诉原因', icon: 'none' });
return;
}
wx.showLoading({ title: '提交中...' });
try {
await request({
options: {
url: '/app/video-watch/feedback',
method: 'POST',
data: {
seeId: wx.getStorageSync("seeId") || '',
code: wx.getStorageSync("code") || '',
openId: wx.getStorageSync("openId") || '',
appId,
type: this.data.selectedReason,
description: this.data.description,
},
},
});
wx.hideLoading();
this.setData({ pageStep: 3 });
} catch (err) {
wx.hideLoading();
wx.showToast({ title: '提交失败,请重试', icon: 'none' });
}
},
handleClose() {
wx.navigateBack();
},
});
+113
View File
@@ -0,0 +1,113 @@
<!-- pages/live/report/report.wxml -->
<navigation-bar title="反馈与投诉" back="{{true}}" bind:handleBack="handleBack" color="black" background="#ffffff" />
<block wx:if="{{pageStep === 1}}">
<scroll-view class="reason-list-scroll" scroll-y>
<view class="report-page">
<!-- 举报原因列表 -->
<view class="section-header">请选择投诉原因</view>
<view class="section-card">
<view class="reason-list">
<view
wx:for="{{reasons}}"
wx:key="id"
class="reason-item"
data-id="{{item.id}}"
bind:tap="onReasonTap"
>
<text class="reason-label">{{item.label}}</text>
<view class="reason-arrow"></view>
</view>
</view>
</view>
</view>
</scroll-view>
</block>
<block wx:elif="{{pageStep === 2}}">
<view class="report-page">
<!-- 举报对象 - 小程序头像和名称 -->
<view class="section-card">
<view class="target-row">
<image class="target-avatar" src="{{'/assets/img/wchat.svg'}}" mode="aspectFill" />
<view class="target-info">
<text class="target-name">小程序</text>
<text class="target-context" wx:if="{{targetContext}}">{{targetContext}}</text>
</view>
</view>
</view>
<!-- 投诉内容卡片(合并:投诉原因、补充描述、图片证据) -->
<view class="section-card unified-card">
<!-- 已选原因 - 直接展示,不可修改 -->
<view class="selected-reason-row">
<text class="selected-reason-text">{{selectedReason}}</text>
</view>
<!-- 分隔线 -->
<view class="unified-divider"></view>
<!-- 补充描述 -->
<view class="desc-wrap">
<textarea
class="desc-textarea"
placeholder="请详细描述投诉内容,包括时间、地点、涉及人员等信息..."
maxlength="500"
value="{{description}}"
bindinput="onDescriptionInput"
auto-height
/>
<view class="char-count">{{descriptionLen}}/500</view>
</view>
<!-- 分隔线 -->
<view class="unified-divider"></view>
<!-- 图片证据 -->
<view class="section-title">
<text>图片证据</text>
<text class="evidence-tip">(最多9张,选填)</text>
</view>
<view class="upload-grid">
<view
wx:for="{{imageList}}"
wx:key="index"
class="upload-cell"
>
<image class="upload-img" src="{{item}}" mode="aspectFill" />
<view class="upload-close" data-index="{{index}}" bind:tap="onRemoveImage">✕</view>
</view>
<view class="upload-cell upload-add" wx:if="{{imageList.length < 9}}" bind:tap="onChooseImage">+</view>
</view>
</view>
<!-- 投诉须知 - 无背景,圆形选中,默认选中 -->
<view class="agreement-section">
<view class="agreement-row" bind:tap="toggleAgree">
<view class="agreement-check-circle {{isAgreed ? 'checked' : ''}}">
<text wx:if="{{isAgreed}}" class="agreement-check-icon">✓</text>
</view>
<text class="agreement-text">我已阅读并同意</text>
<text class="agreement-link">《投诉须知》</text>
</view>
</view>
</view>
<!-- 底部提交按钮 -->
<view class="bottom-bar">
<button class="submit-btn" bind:tap="handleSubmit" disabled="{{!canSubmit}}">提交</button>
</view>
</block>
<block wx:else>
<view class="report-page">
<view class="success-content">
<view class="success-icon-wrap">
<text class="success-check">✓</text>
</view>
<text class="success-title">提交成功</text>
<text class="success-desc">我们将在24小时内处理您的投诉,请耐心等待</text>
<button class="success-btn" bind:tap="handleClose">我知道了</button>
</view>
</view>
</block>
+9
View File
@@ -0,0 +1,9 @@
{
"backgroundTextStyle": "light",
"backgroundColor": "#ffffff",
"navigationBarShareAppMessage": false,
"navigationBarShareTimeline": false,
"usingComponents": {
"liveroom": "/components/liveroom/liveroom"
}
}
+6
View File
@@ -0,0 +1,6 @@
/* pages/live/room/room.wxss */
@import "../../../variables";
page {
background: #f9f9f9;
height: 100%;
}
+75
View File
@@ -0,0 +1,75 @@
// pages/live/room/room.ts
Page({
/**
* 页面的初始数据
*/
data: {
joinedGroupId: "", // 已加入的消息组id
windowHeight: "100%",
windowWidth: "100%",
},
/**
* 生命周期函数--监听页面加载
*/
async onLoad(options) {
const app = getApp<IAppOption>();
wx.setStorageSync("joinedGroupId", options.groupId);
const bool = await app.login("room");
if (!bool) return;
this.setData({
joinedGroupId: options.groupId,
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
const groupId = this.data.joinedGroupId || wx.getStorageSync("joinedGroupId");
const path = groupId
? `/pages/live/room/room?groupId=${groupId}`
: "/pages/live/room/room";
return {
/*
title: "邀请你进入直播间",
*/
title: "邀请你进入直播间",
path,
imageUrl: "/assets/img/600.jpg",
};
},
});
+4
View File
@@ -0,0 +1,4 @@
<!--pages/live/room/room.wxml-->
<view style="width: {{windowWidth}}; height: {{windowHeight}};">
<liveroom joined-group-id="{{joinedGroupId}}" />
</view>
Binary file not shown.

After

Width:  |  Height:  |  Size: 288 KiB

@@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1744786271399" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4083" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M816.49 909H211.21c-1.1 0-2-0.9-2-2v-68.18c0-1.1 0.9-2 2-2h605.28c1.1 0 2 0.9 2 2V907c0 1.1-0.9 2-2 2z" fill="#FFF" p-id="4084"></path><path d="M910.24 316.23c-27.11 0-49.1 22.52-49.1 50.31 0 7.28 1.58 14.16 4.3 20.4l-176.13 80.21-147.2-258.57c14.56-8.73 24.46-24.74 24.46-43.28 0-27.79-21.98-50.31-49.1-50.31s-49.1 22.52-49.1 50.31c0 17.99 9.29 33.66 23.15 42.55l-158.16 259.3-176.13-80.21c2.71-6.25 4.3-13.12 4.3-20.4 0-27.78-21.98-50.31-49.1-50.31s-49.1 22.52-49.1 50.31c0 27.78 21.98 50.31 49.1 50.31 3.99 0 7.82-0.62 11.53-1.54l86.65 366.28h601.43l86.65-366.28c3.71 0.92 7.54 1.54 11.53 1.54 27.12 0 49.1-22.52 49.1-50.31 0.01-27.78-21.97-50.31-49.08-50.31z" fill="#FFF" p-id="4085"></path></svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

+14
View File
@@ -0,0 +1,14 @@
{
"backgroundTextStyle": "light",
"backgroundColor": "#ffffff",
"navigationBarShareAppMessage": false,
"navigationBarShareTimeline": false,
"disableScroll": true,
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar",
"my-video":"/components/my-video/my-video",
"van-tab": "@vant/weapp/tab/index",
"van-tabs": "@vant/weapp/tabs/index",
"my-quiz":"/components/my-quiz/my-quiz"
}
}
+122
View File
@@ -0,0 +1,122 @@
/* pages/video/video.wxss */
@import "../../../variables";
page {
background: #f9f9f9;
height: 100%;
}
.scrollarea {
height: 90vh;
display: flex;
flex-direction: column;
.tabs {
flex:1
}
}
.scrollarea-inner {
height: 50vh;
width: 100%;
box-sizing: border-box;
rich-text {
width: 100%;
height: 100%;
box-sizing: border-box;
}
}
.submit-container {
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding: 20rpx;
box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1);
z-index: 100;
}
/* 提交按钮样式 */
.btn {
width: 80%;
height: 88rpx;
line-height: 88rpx;
background: #ff4d4f;
color: white;
border-radius: 44rpx;
font-size: 32rpx;
border: none;
margin: 0 auto;
position: fixed;
left: 50%;
transform: translate(-50%);
z-index: 1000;
transition: all 0.3s ease;
}
.btn:active {
background: #ff7875;
}
.scrollarea-inner-text{
padding: 40rpx;
box-sizing: border-box;
overflow: auto;
}
rich-content image {
width: 100% !important;
height: auto !important;
display: block;
}
rich-content img {
width: 100% !important;
height: auto !important;
display: block;
}
.error{
white-space: nowrap;
background: #FF4D4F;
color: #fff;
font-size: 22rpx;
padding: 6rpx 24rpx;
border-radius: 20rpx;
line-height: 1.5;
box-shadow: 0 2rpx 8rpx rgba(255, 77, 79, 0.4);
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
border: none;
outline: none;
margin: 0;
&::before {
content: '';
margin-right: 4rpx;
font-size: 20rpx;
}
&::after {
border: none;
}
&:active {
opacity: 0.8;
transform: scale(0.95);
}
}
.history{
position: absolute;
right: 10rpx;
top: 110rpx;
display: flex;
justify-content: center;
padding-left: 12rpx;
border-radius: 48rpx 0rpx 0rpx 48rpx;
box-sizing: border-box;
.icon{
width: 100rpx;
height: 80rpx;
}
}
+381
View File
@@ -0,0 +1,381 @@
// pages/video/video.ts
import UrlParamsHandler from "../../../utils/store";
import { htmlToWxNodes } from "../../../utils/html-to-wx-nodes";
import { request } from "../../../utils/request";
import { version, appversion, appId } from "../../../env";
import { receiveRedPacket } from "../../../utils/util";
const isMobileEnvironment = (): boolean => {
const platform = wx.getSystemInfoSync().platform?.toLowerCase() || '';
return platform !== 'windows' && platform !== 'mac';
};
Page({
/**
* 页面的初始数据
*/
data: {
dataList: {},
nodes: [] as any[],
eveId: null,
store: {},
active: 0,
canSubmit: false,
safeBottom: 0,
},
/**
* 生命周期函数--监听页面加载
*/
async onLoad(options: any) {
const app = getApp<IAppOption>();
wx.hideShareMenu({
menus: ["shareAppMessage"], // 单独禁用好友分享
});
new UrlParamsHandler(options);
app.globalData.store = options;
let safeBottom = 0;
//@ts-ignore
if (wx.getWindowInfo) {
//@ts-ignore
const systemInfo = wx.getWindowInfo();
safeBottom =
Math.abs(systemInfo.windowHeight - systemInfo.safeArea.bottom) + 10;
if (safeBottom === 0) safeBottom = 24;
} else {
const systemInfo = wx.getSystemInfoSync();
safeBottom = systemInfo.safeArea
? Math.abs(systemInfo.windowHeight - systemInfo.safeArea.bottom) + 10
: 24;
}
this.setData({
safeBottom: safeBottom,
store: options,
});
if (!isMobileEnvironment()) {
this.handleEnterError(
"当前环境不支持观看,请使用手机观看。",
"环境不支持",
);
return;
}
const bool = await app.login("video");
if (!bool) return;
// 在需要保护的页面调用
//@ts-ignore
wx.setVisualEffectOnCapture({
visualEffect: 'hidden', // 录屏或截图时隐藏内容
success: function () {
console.log('防截屏录屏保护已开启');
}
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() { },
handleEnterError(message: string, title = "无法进入") {
wx.showModal({
title: title,
content: message,
showCancel: false,
confirmText: "确定",
});
},
handleBack() {
wx.switchTab({
url: "/pages/tab-bar/course/course",
});
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.search();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() { },
/**
* 生命周期函数--监听页面卸载
*/
onUnload() { },
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() { },
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() { },
/**
* 用户点击右上角分享
*/
onShareAppMessage() { },
onChange(e: any) {
this.setData({
active: event.detail.index,
});
},
// 监听答题变化
onAnswerChange() {
this.updateProgress();
},
async search() {
const app = getApp<IAppOption>();
const bool = await app.checkLoginState();
if (!bool) return;
const code = wx.getStorageSync("code");
const params = {
openId: wx.getStorageSync("openId"),
...app.globalData.store,
};
if (code) {
const data = await request({
options: {
url: `/app/video-watch/details?version=${version.details}&appVer=${appversion}`,
method: "GET",
data: params,
},
});
if (!data.watch.url) {
wx.reLaunch({
url: `/pages/live/registration/registration?content=${data.watch.content}&state=${-1}`,
});
}
const nodes = htmlToWxNodes(data.watch.content);
this.setData({
dataList: data.watch,
eveId: data.watch.eveId,
nodes,
});
} else {
const data = await request({
options: {
url: `/app/watch/details?version=${version.details}&appVer=${appversion}`,
data: params,
},
});
if (!data.data.url) {
wx.reLaunch({
url: `/pages/live/registration/registration?content=${data.data.content
}&state=${5}`,
});
}
const nodes = htmlToWxNodes(data.data.content);
this.setData({
dataList: data.data,
eveId: data.data.eveId,
nodes,
});
}
this.selectComponent("#tabs").resize();
},
// 更新答题进度
updateProgress() {
const quizComponent = this.selectComponent("#quizComponent");
if (quizComponent) {
const canSubmit = quizComponent.isAllAnswered();
this.setData({
canSubmit: canSubmit,
});
}
},
handleSubmit(this) {
const ended = wx.getStorageSync("ended") || false;
if (!ended) {
wx.showModal({
title: "请先观看视频,再答题",
showCancel: false,
confirmText: "确定",
confirmColor: "#FF0000",
});
return;
}
//@ts-ignore
if (this.data.dataList?.userAnsNum >= this.data.dataList?.answerMax) {
wx.showToast({
title: "答题次数已用完",
icon: "none",
duration: 6000,
});
return;
}
const quizComponent = this.selectComponent("#quizComponent");
if (!quizComponent) {
wx.showToast({
title: "组件加载失败",
icon: "none",
});
return;
}
const isAllAnswered = quizComponent.isAllAnswered();
if (!isAllAnswered) {
const progress = quizComponent.getProgress();
wx.showModal({
title: "答题未完成",
content: `您已完成 ${progress.answered}/${progress.total} 题,请完成所有题目后再提交。`,
showCancel: false,
confirmText: "继续答题",
});
return;
}
const answers = quizComponent.getAllAnswers();
if (!answers || answers.length === 0) {
wx.showToast({
title: "请先完成答题",
icon: "none",
});
return;
}
wx.showModal({
title: "确认提交",
content: `您已完成 ${answers.length} 道题目,确定要提交答案吗?`,
success: (res) => {
if (res.confirm) {
this.submitAnswers(answers);
}
},
});
},
async submitAnswers(answers: any[]) {
const code = wx.getStorageSync("code");
const params = {
answers,
openId: wx.getStorageSync("openId"),
eveId: this.data.eveId,
...this.data.store,
};
wx.showLoading({
title: "提交中...",
});
let res = null;
if (code) {
res = await request({
options: {
url: "/app/video-watch/interactive?version=" + version.interactive,
data: params,
},
});
} else {
res = await request({
options: {
url: "/app/watch/interactive?version=" + version.interactive,
data: params,
},
});
}
if (res.code !== 200) {
wx.showToast({
title: res.msg || "提交失败",
icon: "none",
duration: 2000,
});
return;
}
const { pass, redId } = res.data;
if (redId) {
wx.showModal({
content: "🎉 领取红包!",
showCancel: false,
confirmText: "立即领取",
confirmColor: "#FF0000",
success: (res) => {
if (res.confirm) {
this.handleReceive(redId);
}
},
});
return;
}
if (pass) {
wx.showModal({
content: "🎉 恭喜您获得红包!",
showCancel: false,
confirmText: "确定",
confirmColor: "#FF0000",
});
} else {
wx.showToast({
title: "回答错误,您与红包擦肩而过",
icon: "none",
duration: 6000,
});
}
},
async handleReceive(e: any) {
const { id } = e.currentTarget.dataset;
const { code } = this.data.store as Record<string, any>;
const params = {
appId,
code,
openId: wx.getStorageSync("openId"),
redId: id,
}
try {
await receiveRedPacket(
params,
'/app/general/receive-red',
appId
);
} catch (err) {
console.error('领取红包失败:', err);
}
},
handleCustomReport() {
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}` : ""}`,
});
},
handleViewHitory() {
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}` : ""}`,
});
}
});
+40
View File
@@ -0,0 +1,40 @@
<!--pages/video/video.wxml-->
<navigation-bar title="" back="{{true}}" bind:handleBack="handleBack" color="black" background="#FFF" />
<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>
<block wx:if="{{dataList.tipUrl}}">
<image alt="提示" mode="widthFix" src="{{dataList.tipUrl}}" style="width: 100%" />
</block>
<van-tabs active="{{ active }}" bind:change="onChange" animated class="tabs" id="tabs">
<van-tab wx:if="{{dataList.questions.length != 0}}" title="答题">
<!-- 答题有多选单选 -->
<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 ? '提交答案领取红包' : '请观看完视频再前往答题'}}
</button>
</form>
</van-tab>
<van-tab title="介绍{{dataList.cusId ? '(' + dataList.cusId + ')' : ''}}">
<scroll-view class="scrollarea-inner" scroll-y type="list">
<view class="scrollarea-inner-text">
<rich-text nodes="{{nodes}}"></rich-text>
</view>
</scroll-view>
</van-tab>
<view class="history" bind:tap="handleViewHitory">
<image class="icon" src="./assets/1.png" />
</view>
</van-tabs>
</scroll-view>
+5
View File
@@ -0,0 +1,5 @@
{
"backgroundColor": "#081120",
"disableScroll": true,
"usingComponents": {}
}
+42
View File
@@ -0,0 +1,42 @@
page {
height: 100%;
background: #081120;
}
.wxroom-redirect {
width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 28rpx;
color: #f4f8ff;
background:
radial-gradient(circle at 18% 12%, rgba(83, 214, 255, 0.14), transparent 28%),
linear-gradient(180deg, #0d1b31 0%, #09121f 52%, #050b15 100%);
}
.wxroom-redirect__spinner {
width: 72rpx;
height: 72rpx;
border-radius: 50%;
border: 6rpx solid rgba(255, 255, 255, 0.1);
border-top-color: #71c1ff;
animation: wxroom-redirect-spin 0.9s linear infinite;
}
.wxroom-redirect__text {
font-size: 30rpx;
line-height: 1.4;
}
@keyframes wxroom-redirect-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
+26
View File
@@ -0,0 +1,26 @@
// pages/live/wxroom/index.ts
Page({
onLoad(options: Record<string, string | undefined>) {
const query = Object.entries(options || {})
.filter(([, value]) => value !== undefined && value !== "")
.map(
([key, value]) =>
`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`,
)
.join("&");
const target = query
? `/package-live/wxroom/index?${query}`
: "/package-live/wxroom/index";
wx.redirectTo({
url: target,
fail: () => {
wx.showToast({
title: "进入直播间失败",
icon: "none",
});
},
});
},
});
+4
View File
@@ -0,0 +1,4 @@
<view class="wxroom-redirect">
<view class="wxroom-redirect__spinner"></view>
<text class="wxroom-redirect__text">正在进入直播间...</text>
</view>