Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89cd9d0404 |
@@ -2,6 +2,7 @@
|
|||||||
"pages": [
|
"pages": [
|
||||||
"pages/tab-bar/medicine-box/index",
|
"pages/tab-bar/medicine-box/index",
|
||||||
"pages/tab-bar/medicine-box/add/index",
|
"pages/tab-bar/medicine-box/add/index",
|
||||||
|
"pages/tab-bar/drug-wiki/index",
|
||||||
"pages/tab-bar/education/index",
|
"pages/tab-bar/education/index",
|
||||||
"pages/tab-bar/profile/index",
|
"pages/tab-bar/profile/index",
|
||||||
"pages/tab-bar/profile/edit/index",
|
"pages/tab-bar/profile/edit/index",
|
||||||
@@ -13,12 +14,6 @@
|
|||||||
"pages/live/report/report",
|
"pages/live/report/report",
|
||||||
"pages/common/red/red"
|
"pages/common/red/red"
|
||||||
],
|
],
|
||||||
"plugins": {
|
|
||||||
"myPlugin": {
|
|
||||||
"version": "0.1.5",
|
|
||||||
"provider": "wx116d0dd5e6a39ac7"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tabBar": {
|
"tabBar": {
|
||||||
"custom": true,
|
"custom": true,
|
||||||
"list": [
|
"list": [
|
||||||
@@ -26,6 +21,10 @@
|
|||||||
"pagePath": "pages/tab-bar/medicine-box/index",
|
"pagePath": "pages/tab-bar/medicine-box/index",
|
||||||
"text": "电子药箱"
|
"text": "电子药箱"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"pagePath": "pages/tab-bar/drug-wiki/index",
|
||||||
|
"text": "药品百科"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"pagePath": "pages/tab-bar/education/index",
|
"pagePath": "pages/tab-bar/education/index",
|
||||||
"text": "惠教中心"
|
"text": "惠教中心"
|
||||||
@@ -50,6 +49,7 @@
|
|||||||
"sdkVersionEnd": "15.255.255"
|
"sdkVersionEnd": "15.255.255"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"componentFramework": "glass-easel",
|
||||||
"sitemapLocation": "sitemap.json",
|
"sitemapLocation": "sitemap.json",
|
||||||
"lazyCodeLoading": "requiredComponents",
|
"lazyCodeLoading": "requiredComponents",
|
||||||
"requiredPrivateInfos": [
|
"requiredPrivateInfos": [
|
||||||
|
|||||||
+1
-6
@@ -76,21 +76,16 @@ App<IAppOption>({
|
|||||||
},
|
},
|
||||||
checkLoginState() {
|
checkLoginState() {
|
||||||
const openId = wx.getStorageSync('openId');
|
const openId = wx.getStorageSync('openId');
|
||||||
const unionId = wx.getStorageSync('unionId');
|
|
||||||
const userId = wx.getStorageSync('userId');
|
const userId = wx.getStorageSync('userId');
|
||||||
|
const isLoggedIn = !!(openId && userId);
|
||||||
const isLoggedIn = !!(openId && unionId && userId);
|
|
||||||
|
|
||||||
if (!isLoggedIn) {
|
if (!isLoggedIn) {
|
||||||
// 清理登录相关缓存
|
// 清理登录相关缓存
|
||||||
LOGIN_STORAGE_KEYS.forEach(key => wx.removeStorageSync(key));
|
LOGIN_STORAGE_KEYS.forEach(key => wx.removeStorageSync(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 记录上一次登录状态,用于判断是否从已登录变为未登录
|
// 记录上一次登录状态,用于判断是否从已登录变为未登录
|
||||||
const prev = this.globalData.isLogin;
|
const prev = this.globalData.isLogin;
|
||||||
this.globalData.isLogin = isLoggedIn;
|
this.globalData.isLogin = isLoggedIn;
|
||||||
this.globalData.wasLogin = prev;
|
this.globalData.wasLogin = prev;
|
||||||
|
|
||||||
return isLoggedIn;
|
return isLoggedIn;
|
||||||
},
|
},
|
||||||
login(value: string) {
|
login(value: string) {
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ Component({
|
|||||||
text: '电子药箱',
|
text: '电子药箱',
|
||||||
icon: '💊',
|
icon: '💊',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
pagePath: 'pages/tab-bar/drug-wiki/index',
|
||||||
|
text: '药品百科',
|
||||||
|
icon: '📖',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
pagePath: 'pages/tab-bar/education/index',
|
pagePath: 'pages/tab-bar/education/index',
|
||||||
text: '惠教中心',
|
text: '惠教中心',
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"disableScroll": true,
|
||||||
|
"navigationBarBackgroundColor": "#FFFFFF",
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
@@ -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() {},
|
||||||
|
});
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<!--pages/live/h5Room/index.wxml-->
|
||||||
|
<text>pages/live/h5Room/index.wxml</text>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import UrlParamsHandler from "../../../utils/store";
|
import UrlParamsHandler from "../../../utils/store";
|
||||||
import { version } from "../../../env";
|
import { appversion, 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`,
|
url: `/app/video-watch/details?version=${version.details}&appVer=${appversion}`,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
data: params,
|
data: params,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"backgroundTextStyle": "light",
|
||||||
|
"backgroundColor": "#ffffff",
|
||||||
|
"navigationBarShareAppMessage": false,
|
||||||
|
"navigationBarShareTimeline": false,
|
||||||
|
"usingComponents": {
|
||||||
|
"liveroom": "/components/liveroom/liveroom"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
/* pages/live/room/room.wxss */
|
||||||
|
@import "../../../variables";
|
||||||
|
page {
|
||||||
|
background: #f9f9f9;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
@@ -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",
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<!--pages/live/room/room.wxml-->
|
||||||
|
<view style="width: {{windowWidth}}; height: {{windowHeight}};">
|
||||||
|
<liveroom joined-group-id="{{joinedGroupId}}" />
|
||||||
|
</view>
|
||||||
@@ -9,7 +9,6 @@
|
|||||||
"my-video":"/components/my-video/my-video",
|
"my-video":"/components/my-video/my-video",
|
||||||
"van-tab": "@vant/weapp/tab/index",
|
"van-tab": "@vant/weapp/tab/index",
|
||||||
"van-tabs": "@vant/weapp/tabs/index",
|
"van-tabs": "@vant/weapp/tabs/index",
|
||||||
"my-quiz":"/components/my-quiz/my-quiz",
|
"my-quiz":"/components/my-quiz/my-quiz"
|
||||||
"my-player": "plugin://myPlugin/player"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,12 +142,3 @@ rich-content img {
|
|||||||
height: 80rpx;
|
height: 80rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.cover {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 0;
|
|
||||||
z-index: 998;
|
|
||||||
height: 20%;
|
|
||||||
width: 70%;
|
|
||||||
left: 10%;
|
|
||||||
background-color: rgba(255, 255, 255, 0.007);
|
|
||||||
}
|
|
||||||
@@ -3,9 +3,8 @@
|
|||||||
import UrlParamsHandler from "../../../utils/store";
|
import UrlParamsHandler from "../../../utils/store";
|
||||||
import { htmlToWxNodes } from "../../../utils/html-to-wx-nodes";
|
import { htmlToWxNodes } from "../../../utils/html-to-wx-nodes";
|
||||||
import { request } from "../../../utils/request";
|
import { request } from "../../../utils/request";
|
||||||
import { AES_IV, AES_KEY, appId } from "../../../env";
|
import { appId } from "../../../env";
|
||||||
import { receiveRedPacket } from "../../../utils/util";
|
import { receiveRedPacket } from "../../../utils/util";
|
||||||
import { aesEncrypt } from "../../../utils/crypto";
|
|
||||||
|
|
||||||
const isMobileEnvironment = (): boolean => {
|
const isMobileEnvironment = (): boolean => {
|
||||||
const platform = wx.getSystemInfoSync().platform?.toLowerCase() || '';
|
const platform = wx.getSystemInfoSync().platform?.toLowerCase() || '';
|
||||||
@@ -13,311 +12,260 @@ const isMobileEnvironment = (): boolean => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
// 页面私有变量,避免触发无效渲染
|
/**
|
||||||
_wasPlayingBeforeInterrupt: false,
|
* 页面的初始数据
|
||||||
_pauseVideoHandler: null as any,
|
*/
|
||||||
_resumeVideoHandler: null as any,
|
|
||||||
_appHideHandler: null as any,
|
|
||||||
_appShowHandler: null as any,
|
|
||||||
_networkStatusChangeHandler: null as any,
|
|
||||||
_videoContext: null as any,
|
|
||||||
|
|
||||||
data: {
|
data: {
|
||||||
dataList: {} as any,
|
dataList: {},
|
||||||
nodes: [] as any[],
|
nodes: [] as any[],
|
||||||
eveId: null,
|
eveId: null,
|
||||||
store: {},
|
store: {},
|
||||||
fileid: "",
|
|
||||||
active: 0,
|
active: 0,
|
||||||
canSubmit: false,
|
canSubmit: false,
|
||||||
safeBottom: 24,
|
safeBottom: 0,
|
||||||
resumeTime: 0,
|
|
||||||
playing: false,
|
|
||||||
currentTime: 0,
|
|
||||||
sendDurationTimer: 0,
|
|
||||||
isAppHidden: false,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面加载
|
||||||
|
*/
|
||||||
async onLoad(options: any) {
|
async onLoad(options: any) {
|
||||||
const app = getApp<IAppOption>();
|
const app = getApp<IAppOption>();
|
||||||
wx.hideShareMenu({ menus: ["shareAppMessage"] });
|
wx.hideShareMenu({
|
||||||
|
menus: ["shareAppMessage"], // 单独禁用好友分享
|
||||||
|
});
|
||||||
new UrlParamsHandler(options);
|
new UrlParamsHandler(options);
|
||||||
app.globalData.store = options;
|
app.globalData.store = options;
|
||||||
|
let safeBottom = 0;
|
||||||
// 适配底部安全区
|
|
||||||
let safeBottom = 24;
|
|
||||||
try {
|
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
const { windowHeight, safeArea } = wx.getWindowInfo ? wx.getWindowInfo() : wx.getSystemInfoSync();
|
if (wx.getWindowInfo) {
|
||||||
safeBottom = safeArea ? Math.abs(windowHeight - safeArea.bottom) + 10 : 24;
|
//@ts-ignore
|
||||||
} catch (e) { }
|
const systemInfo = wx.getWindowInfo();
|
||||||
|
safeBottom =
|
||||||
this.setData({ safeBottom, store: options });
|
Math.abs(systemInfo.windowHeight - systemInfo.safeArea.bottom) + 10;
|
||||||
this.initSystemListeners();
|
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()) {
|
if (!isMobileEnvironment()) {
|
||||||
return this.handleEnterError("当前环境不支持观看,请使用手机观看。", "环境不支持");
|
this.handleEnterError(
|
||||||
|
"当前环境不支持观看,请使用手机观看。",
|
||||||
|
"环境不支持",
|
||||||
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
const bool = await app.login("video");
|
||||||
if (!(await app.login("video"))) return;
|
if (!bool) return;
|
||||||
|
// 开启防截屏(仅限当前页面生命周期内)
|
||||||
//@ts-ignore 开启防截屏
|
//@ts-ignore
|
||||||
if (wx.setVisualEffectOnCapture) wx.setVisualEffectOnCapture({ visualEffect: 'hidden' });
|
wx.setVisualEffectOnCapture({
|
||||||
|
visualEffect: 'hidden',
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面初次渲染完成
|
||||||
|
*/
|
||||||
|
onReady() { },
|
||||||
|
handleEnterError(message: string, title = "无法进入") {
|
||||||
|
wx.showModal({
|
||||||
|
title: title,
|
||||||
|
content: message,
|
||||||
|
showCancel: false,
|
||||||
|
confirmText: "确定",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
handleBack() {
|
||||||
|
wx.switchTab({
|
||||||
|
url: "/pages/tab-bar/education/index",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面显示
|
||||||
|
*/
|
||||||
onShow() {
|
onShow() {
|
||||||
this.search();
|
this.search();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面隐藏
|
||||||
|
*/
|
||||||
onHide() {
|
onHide() {
|
||||||
|
// 离开视频页时恢复截屏能力,避免影响其他页面
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
if (wx.setVisualEffectOnCapture) wx.setVisualEffectOnCapture({ visualEffect: 'none' });
|
wx.setVisualEffectOnCapture({
|
||||||
this.flushProgress();
|
visualEffect: 'none',
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面卸载
|
||||||
|
*/
|
||||||
onUnload() {
|
onUnload() {
|
||||||
|
// 卸载时恢复截屏能力
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
if (wx.setVisualEffectOnCapture) wx.setVisualEffectOnCapture({ visualEffect: 'none' });
|
wx.setVisualEffectOnCapture({
|
||||||
this.flushProgress();
|
visualEffect: 'none',
|
||||||
|
});
|
||||||
try { this.pauseVideoBeforeNavigate(); } catch (err) { }
|
|
||||||
|
|
||||||
// 卸载事件与定时器
|
|
||||||
if (this._pauseVideoHandler) wx.offAudioInterruptionBegin(this._pauseVideoHandler);
|
|
||||||
if (this._resumeVideoHandler) wx.offAudioInterruptionEnd(this._resumeVideoHandler);
|
|
||||||
if (this._appHideHandler) wx.offAppHide(this._appHideHandler);
|
|
||||||
if (this._appShowHandler) wx.offAppShow(this._appShowHandler);
|
|
||||||
if (this._networkStatusChangeHandler) wx.offNetworkStatusChange(this._networkStatusChangeHandler);
|
|
||||||
|
|
||||||
this.clearSendProgressTimer();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面相关事件处理函数--监听用户下拉动作
|
||||||
|
*/
|
||||||
|
onPullDownRefresh() { },
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面上拉触底事件的处理函数
|
||||||
|
*/
|
||||||
|
onReachBottom() { },
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户点击右上角分享
|
||||||
|
*/
|
||||||
|
onShareAppMessage() { },
|
||||||
|
|
||||||
onChange(event: any) {
|
onChange(event: any) {
|
||||||
this.setData({ active: event.detail.index });
|
this.setData({
|
||||||
},
|
active: event.detail.index,
|
||||||
|
|
||||||
initSystemListeners() {
|
|
||||||
this._networkStatusChangeHandler = (res: any) => {
|
|
||||||
if (!res.isConnected) {
|
|
||||||
wx.showToast({ title: '网络连接断开', icon: 'none' });
|
|
||||||
this.pauseVideoBeforeNavigate();
|
|
||||||
} else if (res.networkType !== 'wifi') {
|
|
||||||
wx.showToast({ title: '当前为非Wi-Fi环境,请注意流量消耗', icon: 'none' });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
wx.onNetworkStatusChange(this._networkStatusChangeHandler);
|
|
||||||
|
|
||||||
this._pauseVideoHandler = () => {
|
|
||||||
this.flushProgress();
|
|
||||||
this._wasPlayingBeforeInterrupt = this.data.playing;
|
|
||||||
this.pauseVideoBeforeNavigate();
|
|
||||||
};
|
|
||||||
|
|
||||||
this._resumeVideoHandler = () => {
|
|
||||||
if (this._wasPlayingBeforeInterrupt && !this.data.isAppHidden) {
|
|
||||||
this.resumeVideoAfterInterrupt();
|
|
||||||
}
|
|
||||||
this._wasPlayingBeforeInterrupt = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
this._appHideHandler = () => {
|
|
||||||
this.flushProgress();
|
|
||||||
this.setData({ isAppHidden: true });
|
|
||||||
this.pauseVideoBeforeNavigate();
|
|
||||||
};
|
|
||||||
|
|
||||||
this._appShowHandler = () => {
|
|
||||||
this.setData({ isAppHidden: false });
|
|
||||||
};
|
|
||||||
|
|
||||||
wx.onAudioInterruptionBegin(this._pauseVideoHandler);
|
|
||||||
wx.onAudioInterruptionEnd(this._resumeVideoHandler);
|
|
||||||
wx.onAppHide(this._appHideHandler);
|
|
||||||
wx.onAppShow(this._appShowHandler);
|
|
||||||
},
|
|
||||||
|
|
||||||
getVideoContext() {
|
|
||||||
if (!this._videoContext) {
|
|
||||||
this._videoContext = wx.createVideoContext("myPlayerId", this);
|
|
||||||
}
|
|
||||||
return this._videoContext;
|
|
||||||
},
|
|
||||||
|
|
||||||
pauseVideoBeforeNavigate() {
|
|
||||||
this.getVideoContext().pause();
|
|
||||||
},
|
|
||||||
|
|
||||||
resumeVideoAfterInterrupt() {
|
|
||||||
this.getVideoContext().play();
|
|
||||||
},
|
|
||||||
|
|
||||||
// 统一进度落盘(极简版,直接信任内存里的 currentTime)
|
|
||||||
flushProgress() {
|
|
||||||
const t = this.data.currentTime;
|
|
||||||
if (t > 0) {
|
|
||||||
wx.setStorageSync("interruptedTime", t);
|
|
||||||
wx.setStorageSync("currentTime", t);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
getResumeTime(): number {
|
|
||||||
if (wx.getStorageSync("ended")) return 0;
|
|
||||||
const interrupted = Number(wx.getStorageSync("interruptedTime") || 0);
|
|
||||||
const current = Number(wx.getStorageSync("currentTime") || 0);
|
|
||||||
return Math.max(interrupted, current);
|
|
||||||
},
|
|
||||||
|
|
||||||
onPlayerPlay() {
|
|
||||||
this.setData({ playing: true });
|
|
||||||
// 异步拉取到 fileid 后,初次播放如果存在历史记录,则跳转
|
|
||||||
if (this.data.resumeTime > 0) {
|
|
||||||
this.getVideoContext().seek(this.data.resumeTime);
|
|
||||||
this.setData({ resumeTime: 0 }); // 跳转完立即清空,防止二次跳转
|
|
||||||
}
|
|
||||||
this.startSendProgress();
|
|
||||||
},
|
|
||||||
|
|
||||||
onPlayerPause() {
|
|
||||||
this.setData({ playing: false });
|
|
||||||
this.clearSendProgressTimer();
|
|
||||||
this.flushProgress();
|
|
||||||
},
|
|
||||||
|
|
||||||
onPlayerEnded() {
|
|
||||||
this.setData({ playing: false, resumeTime: 0, currentTime: 0 });
|
|
||||||
wx.setStorageSync("ended", true);
|
|
||||||
this.clearSendProgressTimer();
|
|
||||||
wx.removeStorageSync("interruptedTime");
|
|
||||||
wx.removeStorageSync("currentTime");
|
|
||||||
},
|
|
||||||
|
|
||||||
onPlayerError(e: any) {
|
|
||||||
const detail = e?.detail || e || {};
|
|
||||||
wx.showModal({
|
|
||||||
title: "播放出错",
|
|
||||||
content: String(detail.errMsg || detail.message || JSON.stringify(detail) + ',请联系客服'),
|
|
||||||
showCancel: false,
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onPlayerTimeUpdate(e: any) {
|
// 监听答题变化
|
||||||
let time = e.detail?.currentTime ?? e.detail?.detail?.currentTime;
|
onAnswerChange() {
|
||||||
if (typeof time === 'number' && time > 0) {
|
this.updateProgress();
|
||||||
const currentTime = Math.floor(time);
|
|
||||||
if (currentTime === this.data.currentTime) return; // 避免重复操作
|
|
||||||
this.data.currentTime = currentTime;
|
|
||||||
// 逢 5 秒落盘一次
|
|
||||||
if (currentTime % 5 === 0) this.flushProgress();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
startSendProgress() {
|
|
||||||
this.clearSendProgressTimer();
|
|
||||||
this.sendProgress(); // 启动时先发一次
|
|
||||||
const timer = setInterval(() => this.sendProgress(), 15000) as unknown as number;
|
|
||||||
this.setData({ sendDurationTimer: timer });
|
|
||||||
},
|
|
||||||
|
|
||||||
clearSendProgressTimer() {
|
|
||||||
if (this.data.sendDurationTimer) {
|
|
||||||
clearInterval(this.data.sendDurationTimer);
|
|
||||||
this.setData({ sendDurationTimer: 0 });
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async sendProgress() {
|
|
||||||
if (!this.data.playing) return;
|
|
||||||
try {
|
|
||||||
const code = wx.getStorageSync("code");
|
|
||||||
const openId = wx.getStorageSync("openId");
|
|
||||||
const duration = this.data.currentTime + 1; // 时长兜底补偿
|
|
||||||
|
|
||||||
const params = code
|
|
||||||
? { openId, code, duration }
|
|
||||||
: { openId, state: wx.getStorageSync("state"), seeId: wx.getStorageSync("seeId"), duration };
|
|
||||||
|
|
||||||
await request({
|
|
||||||
options: {
|
|
||||||
url: code ? `/app/video-watch/inspect` : `/app/watch/inspect`,
|
|
||||||
data: aesEncrypt(JSON.stringify(params), AES_KEY, AES_IV),
|
|
||||||
},
|
|
||||||
isLoading: false,
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error("上报观看进度失败:", err);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async search() {
|
async search() {
|
||||||
const app = getApp<IAppOption>();
|
const app = getApp<IAppOption>();
|
||||||
if (!(await app.checkLoginState())) return;
|
|
||||||
|
|
||||||
const code = wx.getStorageSync("code");
|
const code = wx.getStorageSync("code");
|
||||||
const params = { openId: wx.getStorageSync("openId"), ...app.globalData.store };
|
const params = {
|
||||||
|
openId: wx.getStorageSync("openId"),
|
||||||
|
...app.globalData.store,
|
||||||
|
};
|
||||||
|
if (code) {
|
||||||
const data = await request({
|
const data = await request({
|
||||||
options: {
|
options: {
|
||||||
url: code ? `/app/video-watch/details` : `/app/watch/details`,
|
url: `/app/video-watch/simple-details`,
|
||||||
method: code ? "GET" : "POST",
|
method: "GET",
|
||||||
data: params
|
data: params,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const targetData = code ? data.watch : data.data;
|
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/simple-details`,
|
||||||
|
data: params,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
if (!targetData?.extend?.fileid) {
|
if (!data.data.url) {
|
||||||
const stateParam = code ? -1 : 5;
|
wx.reLaunch({
|
||||||
return wx.reLaunch({
|
url: `/pages/live/registration/registration?content=${data.data.content
|
||||||
url: `/pages/live/registration/registration?content=${targetData?.content || ''}&state=${stateParam}`,
|
}&state=${5}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const nodes = htmlToWxNodes(data.data.content);
|
||||||
|
this.setData({
|
||||||
|
dataList: data.data,
|
||||||
|
eveId: data.data.eveId,
|
||||||
|
nodes,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setData({
|
this.selectComponent("#tabs").resize();
|
||||||
dataList: targetData,
|
|
||||||
eveId: targetData.eveId,
|
|
||||||
nodes: htmlToWxNodes(targetData.content),
|
|
||||||
fileid: targetData.extend.fileid,
|
|
||||||
resumeTime: this.getResumeTime(), // 获取到真实视频时,一次性读取恢复点
|
|
||||||
});
|
|
||||||
|
|
||||||
this.selectComponent("#tabs")?.resize();
|
|
||||||
},
|
},
|
||||||
|
// 更新答题进度
|
||||||
onAnswerChange() {
|
updateProgress() {
|
||||||
const quizComponent = this.selectComponent("#quizComponent");
|
const quizComponent = this.selectComponent("#quizComponent");
|
||||||
if (quizComponent) {
|
if (quizComponent) {
|
||||||
this.setData({ canSubmit: quizComponent.isAllAnswered() });
|
const canSubmit = quizComponent.isAllAnswered();
|
||||||
|
this.setData({
|
||||||
|
canSubmit: canSubmit,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSubmit() {
|
handleSubmit(this) {
|
||||||
if (!wx.getStorageSync("ended")) {
|
const ended = wx.getStorageSync("ended") || false;
|
||||||
return wx.showModal({ title: "提示", content: "请先观看完整视频,再参与答题", showCancel: false, confirmColor: "#FF0000" });
|
if (!ended) {
|
||||||
}
|
wx.showModal({
|
||||||
|
title: "请先观看视频,再答题",
|
||||||
if (this.data.dataList?.userAnsNum >= this.data.dataList?.answerMax) {
|
|
||||||
return wx.showToast({ title: "答题次数已用完", icon: "none", duration: 3000 });
|
|
||||||
}
|
|
||||||
|
|
||||||
const quizComponent = this.selectComponent("#quizComponent");
|
|
||||||
if (!quizComponent) return wx.showToast({ title: "组件加载失败", icon: "none" });
|
|
||||||
|
|
||||||
if (!quizComponent.isAllAnswered()) {
|
|
||||||
const { answered, total } = quizComponent.getProgress();
|
|
||||||
return wx.showModal({
|
|
||||||
title: "答题未完成",
|
|
||||||
content: `您已完成 ${answered}/${total} 题,请完成所有题目后再提交。`,
|
|
||||||
showCancel: false,
|
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();
|
const answers = quizComponent.getAllAnswers();
|
||||||
if (!answers?.length) return wx.showToast({ title: "请先完成答题", icon: "none" });
|
if (!answers || answers.length === 0) {
|
||||||
|
wx.showToast({
|
||||||
|
title: "请先完成答题",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wx.showModal({
|
wx.showModal({
|
||||||
title: "确认提交",
|
title: "确认提交",
|
||||||
content: `您已完成 ${answers.length} 道题目,确定要提交答案吗?`,
|
content: `您已完成 ${answers.length} 道题目,确定要提交答案吗?`,
|
||||||
success: (res) => { if (res.confirm) this.submitAnswers(answers); },
|
success: (res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
this.submitAnswers(answers);
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -329,92 +277,138 @@ Page({
|
|||||||
eveId: this.data.eveId,
|
eveId: this.data.eveId,
|
||||||
...this.data.store,
|
...this.data.store,
|
||||||
};
|
};
|
||||||
|
wx.showLoading({
|
||||||
|
title: "提交中...",
|
||||||
|
});
|
||||||
|
let res = null;
|
||||||
|
|
||||||
wx.showLoading({ title: "提交中..." });
|
if (code) {
|
||||||
const url = code ? "/app/video-watch/interactive" : "/app/watch/interactive";
|
res = await request({
|
||||||
const res = await request({ options: { url, data: params } });
|
options: {
|
||||||
wx.hideLoading();
|
url: "/app/video-watch/interactive",
|
||||||
|
data: params,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res = await request({
|
||||||
|
options: {
|
||||||
|
url: "/app/watch/interactive",
|
||||||
|
data: params,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (res.code !== 200) {
|
if (res.code !== 200) {
|
||||||
return wx.showToast({ title: res.msg || "提交失败", icon: "none", duration: 2000 });
|
wx.showToast({
|
||||||
|
title: res.msg || "提交失败",
|
||||||
|
icon: "none",
|
||||||
|
duration: 2000,
|
||||||
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { pass, redPackage } = res.data || {};
|
const { pass, redPackage } = res.data || {};
|
||||||
if (pass) {
|
if (pass) {
|
||||||
wx.showModal({
|
wx.showModal({
|
||||||
content: "🎉 回答正确,领取红包!",
|
content: "🎉 领取红包!",
|
||||||
showCancel: false,
|
showCancel: false,
|
||||||
confirmText: "立即领取",
|
confirmText: "立即领取",
|
||||||
confirmColor: "#FF0000",
|
confirmColor: "#FF0000",
|
||||||
success: async (res) => {
|
success: async (res) => {
|
||||||
if (!res.confirm) return;
|
if (res.confirm) {
|
||||||
if (redPackage?.packageInfo) {
|
if (redPackage?.packageInfo) {
|
||||||
this.transferRedPacket(redPackage);
|
|
||||||
} else if (redPackage?.redId) {
|
|
||||||
await this.handleReceive(redPackage.redId);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
wx.showToast({ title: "回答错误,与红包擦肩而过", icon: "none", duration: 3000 });
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async transferRedPacket(redPackage: any) {
|
|
||||||
wx.showLoading({ title: "领取中", mask: true });
|
|
||||||
if (!wx.canIUse?.("requestMerchantTransfer")) {
|
|
||||||
wx.hideLoading();
|
|
||||||
return wx.showModal({ content: "你的微信版本过低,请更新至最新版本。", showCancel: false });
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
wx.showLoading({ title: "领取中", mask: true });
|
||||||
|
if (wx.canIUse?.("requestMerchantTransfer")) {
|
||||||
await new Promise<void>((resolve, reject) => {
|
await new Promise<void>((resolve, reject) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
wx.requestMerchantTransfer({
|
wx.requestMerchantTransfer({
|
||||||
mchId: redPackage.mchId,
|
mchId: redPackage.mchId,
|
||||||
appId,
|
appId,
|
||||||
package: redPackage.packageInfo,
|
package: redPackage.packageInfo,
|
||||||
success: () => resolve(),
|
success: () => {
|
||||||
fail: (err: any) => reject(new Error(err?.errMsg || "领取失败")),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
wx.hideLoading();
|
|
||||||
wx.showToast({ title: "领取成功", icon: "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) {
|
} catch (err: any) {
|
||||||
wx.hideLoading();
|
wx.hideLoading();
|
||||||
wx.showToast({ title: err?.message || "领取失败", icon: "none" });
|
const msg = err?.data?.msg || err?.errMsg || err?.message || "领取失败";
|
||||||
|
wx.showToast({ title: msg, icon: "none" });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await this.handleReceive(redPackage.redId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
wx.showToast({
|
||||||
|
title: "回答错误,您与红包擦肩而过",
|
||||||
|
icon: "none",
|
||||||
|
duration: 6000,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async handleReceive(id: any) {
|
async handleReceive(id: any) {
|
||||||
|
const { code } = this.data.store as Record<string, any>;
|
||||||
|
const params = {
|
||||||
|
appId,
|
||||||
|
code,
|
||||||
|
openId: wx.getStorageSync("openId"),
|
||||||
|
redId: id,
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
wx.showLoading({ title: "领取中" });
|
|
||||||
await receiveRedPacket(
|
await receiveRedPacket(
|
||||||
{ appId, code: wx.getStorageSync("code"), openId: wx.getStorageSync("openId"), redId: id },
|
params,
|
||||||
'/app/general/receive-red',
|
'/app/general/receive-red',
|
||||||
appId
|
appId
|
||||||
);
|
);
|
||||||
wx.hideLoading();
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
wx.hideLoading();
|
console.error('领取红包失败:', err);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 跳转前暂停视频播放
|
||||||
handleEnterError(message: string, title = "无法进入") {
|
pauseVideoBeforeNavigate() {
|
||||||
wx.showModal({ title, content: message, showCancel: false });
|
const video = this.selectComponent("#myVideo") as any;
|
||||||
},
|
if (video && video.pauseVideo) {
|
||||||
|
video.pauseVideo();
|
||||||
handleBack() {
|
}
|
||||||
wx.switchTab({ url: "/pages/tab-bar/course/course" });
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleCustomReport() {
|
handleCustomReport() {
|
||||||
this.pauseVideoBeforeNavigate();
|
this.pauseVideoBeforeNavigate();
|
||||||
wx.navigateTo({ url: `/pages/live/report/report` });
|
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;
|
||||||
|
wx.navigateTo({
|
||||||
|
url: `/pages/live/report/report`,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
handleViewHitory() {
|
handleViewHitory() {
|
||||||
this.pauseVideoBeforeNavigate();
|
this.pauseVideoBeforeNavigate();
|
||||||
wx.navigateTo({ url: `/pages/live/red-history/red-history` });
|
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;
|
||||||
|
wx.navigateTo({
|
||||||
|
url: `/pages/live/red-history/red-history`,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -9,25 +9,8 @@
|
|||||||
<view style="display: flex; align-items: center; padding: 0 20rpx; height: 70rpx; background: #FFF7E6;">
|
<view style="display: flex; align-items: center; padding: 0 20rpx; height: 70rpx; background: #FFF7E6;">
|
||||||
<view style="font-size: 22rpx; color: #999;">本视频仅用于科普,无任何恶意引导行为</view>
|
<view style="font-size: 22rpx; color: #999;">本视频仅用于科普,无任何恶意引导行为</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- VOD 云点播短视频插件方案:续播 seek / 进度缓存上报 / 电话中断恢复 / 全屏状态同步 -->
|
<my-video id="myVideo" src="{{dataList.url}}" backgroundUrl="{{dataList.background}}"></my-video>
|
||||||
<my-player
|
|
||||||
width="100%"
|
|
||||||
height="210px"
|
|
||||||
appid="1304584727"
|
|
||||||
fileid="{{fileid}}"
|
|
||||||
initial-time="{{resumeTime}}"
|
|
||||||
enable-progress-gesture="{{false}}"
|
|
||||||
playerid="myPlayerId"
|
|
||||||
bindplay="onPlayerPlay"
|
|
||||||
bindpause="onPlayerPause"
|
|
||||||
bindended="onPlayerEnded"
|
|
||||||
binderror="onPlayerError"
|
|
||||||
bindtimeupdate="onPlayerTimeUpdate"
|
|
||||||
bindloadedmetadata="onPlayerLoadedMetadata"
|
|
||||||
show-fullscreen-btn
|
|
||||||
>
|
|
||||||
<cover-view class="cover"></cover-view>
|
|
||||||
</my-player>
|
|
||||||
<block wx:if="{{dataList.tipUrl}}">
|
<block wx:if="{{dataList.tipUrl}}">
|
||||||
<image alt="提示" mode="widthFix" src="{{dataList.tipUrl}}" style="width: 100%" />
|
<image alt="提示" mode="widthFix" src="{{dataList.tipUrl}}" style="width: 100%" />
|
||||||
</block>
|
</block>
|
||||||
@@ -49,8 +32,8 @@
|
|||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</van-tab>
|
</van-tab>
|
||||||
<view class="history" bind:tap="handleViewHitory">
|
<!-- <view class="history" bind:tap="handleViewHitory">
|
||||||
<image class="icon" src="./assets/1.png" />
|
<image class="icon" src="./assets/1.png" />
|
||||||
</view>
|
</view> -->
|
||||||
</van-tabs>
|
</van-tabs>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"backgroundColor": "#081120",
|
||||||
|
"disableScroll": true,
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<view class="wxroom-redirect">
|
||||||
|
<view class="wxroom-redirect__spinner"></view>
|
||||||
|
<text class="wxroom-redirect__text">正在进入直播间...</text>
|
||||||
|
</view>
|
||||||
@@ -132,3 +132,109 @@
|
|||||||
line-height: 34rpx;
|
line-height: 34rpx;
|
||||||
margin-left: 4rpx;
|
margin-left: 4rpx;
|
||||||
}
|
}
|
||||||
|
/* ============================================
|
||||||
|
弹窗 — 设置头像和昵称
|
||||||
|
============================================ */
|
||||||
|
|
||||||
|
.popup-title {
|
||||||
|
display: block;
|
||||||
|
font-size: 35rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #000;
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 10rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 40rpx;
|
||||||
|
|
||||||
|
// 左右布局:左头像 + 右按钮组
|
||||||
|
.form-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 36rpx;
|
||||||
|
margin-bottom: 50rpx;
|
||||||
|
|
||||||
|
// 左侧:头像选择器
|
||||||
|
.avatar-picker {
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: 140rpx;
|
||||||
|
height: 140rpx;
|
||||||
|
padding: 0;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
&::after {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-avatar {
|
||||||
|
width: 140rpx;
|
||||||
|
height: 140rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: 3rpx solid $primary-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 右侧:按钮组(上下排列)
|
||||||
|
.btn-group {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 20rpx;
|
||||||
|
|
||||||
|
.form-btn {
|
||||||
|
width: 100%;
|
||||||
|
height: 72rpx;
|
||||||
|
line-height: 72rpx;
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: #fff;
|
||||||
|
background: linear-gradient(90deg, #005bea 0%, #00c6fb 99%);
|
||||||
|
border-radius: 36rpx;
|
||||||
|
border: none;
|
||||||
|
&::after {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 昵称输入:外观伪装成按钮,click 唤起微信昵称弹层
|
||||||
|
.form-input--nickname {
|
||||||
|
width: 100%;
|
||||||
|
height: 72rpx;
|
||||||
|
line-height: 72rpx;
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: $primary-color;
|
||||||
|
background: transparent;
|
||||||
|
border: 2rpx solid $primary-color;
|
||||||
|
border-radius: 36rpx;
|
||||||
|
text-align: center;
|
||||||
|
padding: 0 20rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提交按钮
|
||||||
|
.form-submit {
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.submit-btn {
|
||||||
|
width: 100%;
|
||||||
|
height: 96rpx;
|
||||||
|
line-height: 96rpx;
|
||||||
|
background: linear-gradient(90deg, #005bea 0%, #00c6fb 99%);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 34rpx;
|
||||||
|
border-radius: 48rpx;
|
||||||
|
border: none;
|
||||||
|
&::after {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -213,12 +213,10 @@ Page({
|
|||||||
agree: false,
|
agree: false,
|
||||||
nickFocus: true,
|
nickFocus: true,
|
||||||
showPopup: false,
|
showPopup: false,
|
||||||
|
avatarUrl: defaultAvatarUrl,
|
||||||
|
nickname: '',
|
||||||
safeBottom: app.globalData.safeBottom,
|
safeBottom: app.globalData.safeBottom,
|
||||||
showLoginImage: false,
|
showLoginImage: false,
|
||||||
userInfo: {
|
|
||||||
avatarUrl: defaultAvatarUrl,
|
|
||||||
nickName: "微信用户",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
applyLoginDisplayConfig(options: Record<string, any> = {}) {
|
applyLoginDisplayConfig(options: Record<string, any> = {}) {
|
||||||
@@ -245,10 +243,7 @@ Page({
|
|||||||
success: (res: any) => {
|
success: (res: any) => {
|
||||||
const { data } = JSON.parse(res.data);
|
const { data } = JSON.parse(res.data);
|
||||||
this.setData({
|
this.setData({
|
||||||
userInfo: {
|
|
||||||
...this.data.userInfo,
|
|
||||||
avatarUrl: data,
|
avatarUrl: data,
|
||||||
},
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
fail: () => {
|
fail: () => {
|
||||||
@@ -275,7 +270,6 @@ Page({
|
|||||||
const tabPages = [
|
const tabPages = [
|
||||||
"/pages/tab-bar/medicine-box/index",
|
"/pages/tab-bar/medicine-box/index",
|
||||||
"/pages/tab-bar/shopping-cart/shopping-cart",
|
"/pages/tab-bar/shopping-cart/shopping-cart",
|
||||||
"/pages/tab-bar/course/course",
|
|
||||||
"/pages/tab-bar/user/user",
|
"/pages/tab-bar/user/user",
|
||||||
"/pages/tab-bar/points-mall/points-mall",
|
"/pages/tab-bar/points-mall/points-mall",
|
||||||
"/pages/tab-bar/category/category",
|
"/pages/tab-bar/category/category",
|
||||||
@@ -289,23 +283,7 @@ Page({
|
|||||||
wx.removeStorageSync(WXROOM_REDIRECT_PATH_KEY);
|
wx.removeStorageSync(WXROOM_REDIRECT_PATH_KEY);
|
||||||
} else {
|
} else {
|
||||||
const store = app.globalData.store;
|
const store = app.globalData.store;
|
||||||
const state = wx.getStorageSync("state") ?? undefined;
|
|
||||||
const code = wx.getStorageSync("code") ?? undefined;
|
const code = wx.getStorageSync("code") ?? undefined;
|
||||||
const groupId = wx.getStorageSync("groupId") ?? undefined;
|
|
||||||
|
|
||||||
if (state && !code) {
|
|
||||||
if (self.data.back === "video") {
|
|
||||||
const storeParams =
|
|
||||||
typeof store === "string" ? store : this.buildQueryString(store);
|
|
||||||
fullPath = `/pages/live/video/video?${storeParams}`;
|
|
||||||
} else if (self.data.back === "red") {
|
|
||||||
fullPath = `/pages/common/red/red`;
|
|
||||||
} else if (self.data.back === "user") {
|
|
||||||
fullPath = `/pages/tab-bar/user/user`;
|
|
||||||
} else {
|
|
||||||
fullPath = `/pages/live/registration/registration?state=${state}`;
|
|
||||||
}
|
|
||||||
} else if (!state && code) {
|
|
||||||
if (self.data.back === "video") {
|
if (self.data.back === "video") {
|
||||||
const storeParams =
|
const storeParams =
|
||||||
typeof store === "string" ? store : this.buildQueryString(store);
|
typeof store === "string" ? store : this.buildQueryString(store);
|
||||||
@@ -317,15 +295,7 @@ Page({
|
|||||||
} else {
|
} else {
|
||||||
fullPath = `/pages/live/registration/registration?code=${code}`;
|
fullPath = `/pages/live/registration/registration?code=${code}`;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (self.data.back === "room") {
|
|
||||||
fullPath = `/pages/live/room/room?groupId=${groupId}`;
|
|
||||||
} else if (self.data.back === "red") {
|
|
||||||
fullPath = `/pages/common/red/red`;
|
|
||||||
} else if (self.data.back === "user") {
|
|
||||||
fullPath = `/pages/tab-bar/user/user`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const pages = getCurrentPages();
|
const pages = getCurrentPages();
|
||||||
@@ -376,65 +346,70 @@ Page({
|
|||||||
});
|
});
|
||||||
if (!this.data.agree) return;
|
if (!this.data.agree) return;
|
||||||
}
|
}
|
||||||
|
this.setData({
|
||||||
|
showPopup: true
|
||||||
|
})
|
||||||
|
|
||||||
|
},
|
||||||
|
closePopup() {
|
||||||
|
this.setData({
|
||||||
|
showPopup: false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
// 获取昵称(微信系统填入后失焦触发 bindblur)
|
||||||
|
onNicknameInput(e: any) {
|
||||||
|
const { value } = e.detail;
|
||||||
|
this.setData({
|
||||||
|
nickname: value
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 提交登录
|
||||||
|
async submitLogin() {
|
||||||
|
const { avatarUrl, nickname } = this.data;
|
||||||
|
if (!avatarUrl) {
|
||||||
|
wx.showToast({
|
||||||
|
title: '请选择头像',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!nickname) {
|
||||||
|
wx.showToast({
|
||||||
|
title: '请选择昵称',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
wx.showLoading({ title: "登录中" });
|
wx.showLoading({ title: "登录中" });
|
||||||
const loginRes = await wxLogin();
|
const loginRes = await wxLogin();
|
||||||
if (!loginRes.code) throw new Error(loginRes.errMsg);
|
if (!loginRes.code) throw new Error(loginRes.errMsg);
|
||||||
|
|
||||||
const { avatarUrl, nickName } = this.data.userInfo;
|
|
||||||
const state = wx.getStorageSync("state");
|
|
||||||
let loginResult: LoginRes;
|
let loginResult: LoginRes;
|
||||||
|
|
||||||
if (state) {
|
|
||||||
const reqData: Record<string, any> = {
|
const reqData: Record<string, any> = {
|
||||||
state: wx.getStorageSync("state") ?? undefined,
|
state: loginRes.code,
|
||||||
...(nickName && nickName !== "微信用户" ? { nickName } : {}),
|
avatarUrl,
|
||||||
...(avatarUrl && avatarUrl !== defaultAvatarUrl ? { avatarUrl } : {}),
|
nickName: nickname
|
||||||
};
|
};
|
||||||
|
|
||||||
loginResult = await wxRequest<LoginRes>({
|
loginResult = await wxRequest<LoginRes>({
|
||||||
url: `${BASE_URL}/api/auth/app-login?appId=${appId}&code=${loginRes.code}`,
|
url: `${BASE_URL}/api/auth/app-auth-new?appId=${appId}&code=${loginRes.code}`,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
data: reqData,
|
data: reqData,
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
const reqData: Record<string, any> = {
|
|
||||||
state: wx.getStorageSync("code") ?? undefined,
|
|
||||||
...(nickName && nickName !== "微信用户" ? { nickName } : {}),
|
|
||||||
...(avatarUrl && avatarUrl !== defaultAvatarUrl ? { avatarUrl } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
loginResult = await wxRequest<LoginRes>({
|
if (loginResult?.statusCode !== 200) {
|
||||||
url: `${BASE_URL}/api/auth/app-auth?appId=${appId}&code=${loginRes.code}`,
|
|
||||||
method: "POST",
|
|
||||||
data: reqData,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
loginResult?.statusCode !== 200 ||
|
|
||||||
(loginResult.data.code && loginResult.data.code !== 200)
|
|
||||||
) {
|
|
||||||
throw new Error(loginResult?.data?.msg || "登录失败");
|
throw new Error(loginResult?.data?.msg || "登录失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
|
||||||
mpUserId,
|
|
||||||
id,
|
|
||||||
openId,
|
|
||||||
unionId,
|
|
||||||
nickName: resNickName,
|
|
||||||
avatarUrl: resAvatarUrl,
|
|
||||||
} = loginResult.data;
|
|
||||||
|
|
||||||
const storageData = {
|
const storageData = {
|
||||||
openId,
|
openId: loginResult.data.openId,
|
||||||
userId: mpUserId,
|
userId: loginResult.data.mpUserId,
|
||||||
mbuId: id,
|
userName: loginResult.data.nickName,
|
||||||
unionId,
|
avatarUrl: loginResult.data.avatarUrl,
|
||||||
userName: resNickName,
|
|
||||||
avatarUrl: resAvatarUrl,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.entries(storageData).forEach(([key, value]) => {
|
Object.entries(storageData).forEach(([key, value]) => {
|
||||||
@@ -442,18 +417,15 @@ Page({
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.globalData.isLogin = true;
|
app.globalData.isLogin = true;
|
||||||
this.triggerEvent("loginSuccess", {
|
|
||||||
userName: resNickName,
|
|
||||||
avatarUrl: resAvatarUrl,
|
|
||||||
});
|
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
title: "登录成功",
|
title: "登录成功",
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
});
|
});
|
||||||
|
// 跳转到看课页面
|
||||||
this.redirectUrl();
|
this.redirectUrl();
|
||||||
|
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
console.log("登录失败:", err);
|
|
||||||
app.globalData.isLogin = false;
|
app.globalData.isLogin = false;
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
title: `登录失败:${err.message || err.errMsg}`,
|
title: `登录失败:${err.message || err.errMsg}`,
|
||||||
@@ -462,8 +434,10 @@ Page({
|
|||||||
} finally {
|
} finally {
|
||||||
setTimeout(() => wx.hideToast(), 3000);
|
setTimeout(() => wx.hideToast(), 3000);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
|
// 关闭弹窗
|
||||||
|
this.closePopup();
|
||||||
|
},
|
||||||
handleToggleAgree() {
|
handleToggleAgree() {
|
||||||
this.setData({ agree: !this.data.agree });
|
this.setData({ agree: !this.data.agree });
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -24,3 +24,32 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 弹窗:设置头像和昵称 -->
|
||||||
|
<popup visible="{{showPopup}}" bind:close="closePopup">
|
||||||
|
<text class="popup-title">手动设置头像和昵称</text>
|
||||||
|
<view class="popup-content">
|
||||||
|
<!-- 左右布局:左侧头像 | 右侧按钮组 -->
|
||||||
|
<view class="form-row">
|
||||||
|
<!-- 左侧:头像 -->
|
||||||
|
<button class="avatar-picker" open-type="chooseAvatar" bindchooseavatar="onChooseAvatar">
|
||||||
|
<image src="{{avatarUrl}}" class="popup-avatar"></image>
|
||||||
|
</button>
|
||||||
|
<!-- 右侧:两个按钮 -->
|
||||||
|
<view class="btn-group">
|
||||||
|
<button class="form-btn" open-type="chooseAvatar" bindchooseavatar="onChooseAvatar">点击获取头像</button>
|
||||||
|
<input
|
||||||
|
type="nickname"
|
||||||
|
class="form-input--nickname"
|
||||||
|
placeholder="点击获取昵称"
|
||||||
|
bindblur="onNicknameInput"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 提交 -->
|
||||||
|
<view class="form-submit">
|
||||||
|
<button class="submit-btn" bind:tap="submitLogin">确定授权</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</popup>
|
||||||
|
|||||||
@@ -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=2KnFxIm5GPLK7SLDhvoxdHTAZFrRAM34bi",
|
"query": "code=oyydS188FNmOVk89F_bm56bUwVK8",
|
||||||
"scene": null,
|
"scene": null,
|
||||||
"launchMode": "default"
|
"launchMode": "default"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user