信达小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

434 lines
11 KiB

/* eslint-disable eqeqeq */
6 months ago
import dayjs from 'dayjs'
import { parseScene } from '../../../utils/util'
6 months ago
const app = getApp<IAppOption>()
let live_time: null | number = null
Page({
data: {
id: '',
shareShow: false,
dateValue: 0,
6 months ago
detail: {} as any,
6 months ago
zdUserInfo: {} as any,
6 months ago
posterUrl: '',
params: {},
play: false,
currentVideoSrc: '',
lightList: [],
timeData: {},
optionsScene: {} as any,
popupShow: false,
popupType: 'popup6', // 登录失败弹窗
popupParams: {
close: true,
} as any,
6 months ago
},
videoContext: {} as WechatMiniprogram.VideoContext,
onLoad(options) {
this.setData({
id: options.id,
6 months ago
})
if (options.scene) {
const optionsScene: any = parseScene(options.scene)
this.setData({
optionsScene: optionsScene || {},
id: options.id || optionsScene?.id,
})
} else if (options.proMethodId) {
this.setData({
'optionsScene.proMethodId': options.proMethodId,
})
}
6 months ago
if (live_time) {
clearInterval(live_time)
}
this.setData({
dateValue: dayjs().valueOf(),
})
live_time = setInterval(() => {
this.setData({
dateValue: dayjs().valueOf(),
})
}, 1000)
},
onShow() {
6 months ago
app.waitLogin({ type: [0, 1] }).then(() => {
app.mpBehavior({
PageName: 'PG_PatientLiveDetails',
detailId: this.data.id,
promotionMethodId: this.data.optionsScene.proMethodId,
})
6 months ago
this.getDetail()
this.setView()
this.getLightList()
6 months ago
app.getZdUserInfo(this, true, () => {
6 months ago
this.getPosterParams()
})
})
},
onReady() {
this.videoContext = wx.createVideoContext('video')
},
getLightList() {
wx.ajax({
method: 'GET',
url: '?r=zd/activity/get-high-light-list',
data: { activityId: this.data.id },
}).then((res) => {
res.map((item: any) => {
item.duration = dayjs(item.duration * 1000).format('mm:ss')
return item
})
this.setData({
lightList: res,
})
})
},
6 months ago
getPosterParams() {
wx.ajax({
method: 'POST',
url: '?r=poster/prepare',
data: {
posterId: 'activity-invite',
activityId: this.data.id,
6 months ago
userId: this.data.zdUserInfo.UserId,
6 months ago
},
}).then((res) => {
this.setData({
params: res,
})
})
},
setView() {
wx.ajax({
method: 'POST',
6 months ago
url: '?r=zd/activity/view',
6 months ago
data: {
Id: this.data.id,
},
})
},
getDetail() {
wx.ajax({
method: 'GET',
6 months ago
url: '?r=zd/activity/detail',
6 months ago
data: {
Id: this.data.id,
},
}).then((res) => {
if (res.ReplayVideoUrl) {
this.videoContext = wx.createVideoContext('video')
}
if (res.Type == 1) {
wx.setNavigationBarTitle({
title: '会议详情',
})
} else {
wx.setNavigationBarTitle({
title: '活动详情',
})
}
this.setData({
detail: {
...res,
EndTimeValue: dayjs(res.EndTime).valueOf(),
BeginTimeValue: dayjs(res.BeginTime).valueOf(),
SignUpDeadlineValue: dayjs(res.SignUpDeadline).valueOf(),
DetailJson: res.DetailJson ? JSON.parse(res.DetailJson) : [],
SignUpRecord: res.SignUpRecord.map((item) => {
item.date = dayjs().from(item.CreateTime)
item.UserId = '******'.slice(0, 6 - String(item.UserId).length) + item.UserId
return item
}),
BeginTime: dayjs(res.BeginTime).format('YYYY-MM-DD HH:mm'),
},
currentVideoSrc: res.ReplayVideoUrl,
6 months ago
})
})
},
handleLightVideo(e) {
const { url } = e.currentTarget.dataset
this.setData({
currentVideoSrc: url,
})
this.videoContext.requestFullScreen({})
this.videoContext.seek(0)
this.videoContext.play()
},
6 months ago
handleReplay() {
6 months ago
app.mpBehavior({ PageName: 'BTN_PatientLiveReview' })
this.setData({
currentVideoSrc: this.data.detail.ReplayVideoUrl,
})
6 months ago
this.videoContext.requestFullScreen({})
this.videoContext.seek(0)
this.videoContext.play()
},
handleFullscreenExit() {
this.videoContext.pause()
},
handleBanner() {
const { detail, zdUserInfo, dateValue } = this.data
if (detail.IsSignUp && zdUserInfo.AuditStatus) {
if (zdUserInfo.AuditStatus == 1 || zdUserInfo.AuditStatus == 3 || zdUserInfo.AuditStatus == 4) {
if (detail.SignUpStatus == 2) {
if (detail.BeginTimeValue * 1 < dateValue * 1) {
this.handleLive()
}
}
}
}
},
6 months ago
handleLive() {
const { Type } = this.data.detail
6 months ago
app.mpBehavior({ PageName: 'BTN_PatientLiveEnter' })
6 months ago
app
.zdPermissionVerification(
3,
Type == 1 ? 1 : 10,
`/patient/pages/liveDetail/index?id=${this.data.id}`,
this.data.id,
)
6 months ago
.then(() => {
const { TencentMeetingCode } = this.data.detail
wx.navigateToMiniProgram({
appId: 'wx33fd6cdc62520063', // 要跳转的微信小程序appid
// path: `pages/sub-preMeeting/join-meeting/join-meeting?m=${TencentMeetingCode}`, // 要跳转到的页面路径
// path:`pages/index/index?chn=${channel}&code=${TencentMeetingCode}&pwd=${password}&nm={nickname}`
path: `pages/index/index?code=${TencentMeetingCode}`,
})
})
},
// handleLiveTest() {
// wx.navigateToMiniProgram({
// appId: 'wx33fd6cdc62520063', // 要跳转的微信小程序appid
// path: `pages/index/index?code=521826426`,
// })
// },
handleResult() {
wx.navigateTo({
6 months ago
url: `/patient/pages/liveResult/index?id=${this.data.id}`,
6 months ago
})
},
handleSignUp() {
const { SubscribeTemplateList } = this.data.detail
6 months ago
app.mpBehavior({ PageName: 'BTN_PatientLiveSign' })
wx.requestSubscribeMessage({
tmplIds: SubscribeTemplateList,
success: (res) => {
const subscribe = SubscribeTemplateList.map((item) => {
return res[item] === 'accept' ? 1 : 2
6 months ago
})
this.handleSignUpCallback(subscribe)
},
fail: () => {
this.handleSignUpCallback([2, 2])
},
6 months ago
})
},
handleSignUpCallback(res = [2, 2]) {
const { Type } = this.data.detail
const { UserType } = this.data.zdUserInfo
const optionsScene = this.data.optionsScene
wx.ajax({
method: 'POST',
url: '?r=zd/activity/sign-up',
data: {
Id: this.data.id,
PreUserIdentity: UserType,
promotionMethodId: optionsScene.proMethodId,
subscribe: [...res],
},
}).then((res) => {
app
.zdPermissionVerification(
3,
Type == 1 ? 1 : 10,
`/patient/pages/liveResult/index?id=${this.data.id}&rewardScore=${res.rewardScore}`,
this.data.id,
)
.then(() => {
wx.navigateTo({
url: `/patient/pages/liveResult/index?id=${this.data.id}&rewardScore=${res.rewardScore}`,
})
})
})
},
6 months ago
handleShare() {
this.setData({
shareShow: true,
})
this.saveShare()
},
saveShare() {
6 months ago
const { UserType } = this.data.zdUserInfo
6 months ago
wx.ajax({
method: 'POST',
6 months ago
url: '?r=zd/activity/share',
6 months ago
data: { Id: this.data.id, PreUserIdentity: UserType },
}).then(() => {
6 months ago
this.getDetail()
})
},
handleMap() {
const { LocationLAT, LocationLNG, Location } = this.data.detail
wx.openLocation({
latitude: LocationLAT * 1,
longitude: LocationLNG * 1,
name: Location,
})
},
handleShareClose() {
this.setData({
shareShow: false,
})
},
handlePosterFinish(e) {
this.setData({
posterUrl: e.detail,
})
},
handleDownload() {
const that = this
wx.getSetting({
success(res) {
if (
res.authSetting['scope.writePhotosAlbum'] != undefined &&
res.authSetting['scope.writePhotosAlbum'] == true
) {
that.saveImage()
} else if (res.authSetting['scope.writePhotosAlbum'] == undefined) {
//获取当前位置
that.saveImage()
} else {
wx.showModal({
title: '请求授权相册权限',
content: '需要保存海报到相册,请确认授权',
confirmColor: '#8c75d0',
6 months ago
success(res) {
if (res.cancel) {
//取消授权
wx.showToast({
title: '拒绝授权',
icon: 'none',
duration: 1000,
})
} else if (res.confirm) {
//确定授权,通过wx.openSetting发起授权请求
wx.openSetting({
success(res) {
if (res.authSetting['scope.writePhotosAlbum'] == true) {
that.saveImage()
} else {
wx.showToast({
title: '授权失败',
icon: 'none',
duration: 1000,
})
}
},
})
}
},
})
}
},
})
},
saveImage() {
wx.showLoading({
title: '加载中',
})
wx.saveImageToPhotosAlbum({
filePath: this.data.posterUrl,
success: () => {
wx.hideLoading()
wx.showToast({
title: '保存成功,请到相册中查看',
})
},
fail: () => {
wx.hideLoading()
wx.showToast({
icon: 'none',
title: '保存失败,请稍后重试',
})
},
})
},
handleVideoPlay() {
this.setData({
play: true,
})
},
handleVideoPause() {
this.setData({
play: false,
})
},
handlePlayVideo() {
this.videoContext.play()
},
handleBack() {
wx.navigateBack({
fail() {
wx.reLaunch({
url: '/patient/pages/index/index',
})
},
})
},
handleOffice() {
this.setData({
popupShow: true,
popupType: 'popup6',
popupParams: {
close: true,
},
})
},
handlePopupCancel() {
this.setData({
popupShow: false,
})
},
handleAnswer() {
const link = this.data.detail.QuestionnaireUrl
wx.navigateTo({
url: `/pages/webview/index?url=${encodeURIComponent(link)}`,
})
},
handleTimeChange(e) {
this.setData({
timeData: e.detail,
})
},
handleTimeFinish() {
this.setData({
dateValue: dayjs().valueOf(),
'detail.LeftTime': 0,
})
},
handleLightDetail() {
wx.navigateTo({
url: `/patient/pages/liveDetailVideo/index?id=${this.data.id}`,
})
},
6 months ago
onShareAppMessage() {
this.saveShare()
return {
title: `【会议报名】${this.data.detail.Name}`,
6 months ago
path: `/patient/pages/liveDetail/index?id=${this.data.id}`,
6 months ago
// imageUrl: this.data.detail.IntroductionUrl,
}
},
})