信达小程序
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.

304 lines
7.9 KiB

3 months ago
import dayjs from 'dayjs'
const app = getApp<IAppOption>()
let live_time: null | number = null
Page({
data: {
id: '',
shareShow: false,
detail: {} as any,
3 months ago
zdUserInfo: {} as any,
3 months ago
posterUrl: '',
params: {},
play: false,
},
videoContext: {} as WechatMiniprogram.VideoContext,
onLoad(options) {
const scene = app.globalData.scene
this.setData({
id: options.id || scene.id,
})
if (live_time) {
clearInterval(live_time)
}
this.setData({
dateValue: dayjs().valueOf(),
})
live_time = setInterval(() => {
this.setData({
dateValue: dayjs().valueOf(),
})
}, 1000)
},
onShow() {
3 months ago
app.zdWaitLogin({ isReg: false }).then(() => {
3 months ago
this.getDetail()
this.setView()
3 months ago
app.getZdUserInfo(this, true, () => {
3 months ago
this.getPosterParams()
})
})
},
onReady() {
this.videoContext = wx.createVideoContext('video')
},
getPosterParams() {
wx.ajax({
method: 'POST',
url: '?r=poster/prepare',
data: {
posterId: 'activity-invite',
activityId: this.data.id,
3 months ago
userId: this.data.zdUserInfo.UserId,
3 months ago
},
}).then((res) => {
this.setData({
params: res,
})
})
},
setView() {
wx.ajax({
method: 'POST',
url: '?r=xd/activity/view',
data: {
Id: this.data.id,
},
}).then((res) => {
console.log('res: ', res)
})
},
getDetail() {
wx.ajax({
method: 'GET',
url: '?r=xd/activity/detail',
data: {
Id: this.data.id,
},
}).then((res) => {
if (res.ReplayVideoUrl) {
this.videoContext = wx.createVideoContext('video')
}
if (res.Type == 1) {
app.zdMpBehavior({ PageName: 'PG_PATIENTLECTUREDETAILS' })
wx.setNavigationBarTitle({
title: '会议详情',
})
} else {
app.zdMpBehavior({ PageName: 'PG_PATIENTACTIVITYDETAILS' })
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'),
},
})
})
},
handleReplay() {
app.zdMpBehavior({ PageName: 'BTN_PATIENTMEETINGDETAILREPLAY' })
this.videoContext.requestFullScreen({})
this.videoContext.seek(0)
this.videoContext.play()
},
handleFullscreenExit() {
this.videoContext.pause()
},
handleLive() {
const { Type } = this.data.detail
app
3 months ago
.zdPermissionVerification(3, Type == 1 ? 1 : 10, `/patient/pages/liveDetail/index?id=${this.data.id}`, this.data.id)
3 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({
3 months ago
url: `/patient/pages/liveResult/index?id=${this.data.id}`,
3 months ago
})
},
handleSignUp() {
const { Type } = this.data.detail
3 months ago
const { UserType } = this.data.zdUserInfo
3 months ago
if (Type == 1) {
app.zdMpBehavior({ PageName: 'BTN_PATIENTMEETINGDETAILSIGNUP' })
} else if (Type == 2) {
app.zdMpBehavior({ PageName: 'BTN_PATIENTACTIVITYDETAILSIGNUP' })
}
wx.ajax({
method: 'POST',
url: '?r=xd/activity/sign-up',
data: {
Id: this.data.id,
PreUserIdentity: UserType,
},
}).then((res) => {
app
3 months ago
.zdPermissionVerification(
3 months ago
3,
Type == 1 ? 1 : 10,
3 months ago
`/patient/pages/liveResult/index?id=${this.data.id}&rewardScore=${res.rewardScore}`,
3 months ago
this.data.id,
)
.then(() => {
wx.navigateTo({
3 months ago
url: `/patient/pages/liveResult/index?id=${this.data.id}&rewardScore=${res.rewardScore}`,
3 months ago
})
})
})
},
handleShare() {
this.setData({
shareShow: true,
})
this.saveShare()
},
saveShare() {
3 months ago
const { UserType } = this.data.zdUserInfo
3 months ago
wx.ajax({
method: 'POST',
url: '?r=xd/activity/share',
data: { Id: this.data.id, PreUserIdentity: UserType },
}).then((res) => {
this.getDetail()
})
},
handleMap() {
const { LocationLAT, LocationLNG, Location } = this.data.detail
wx.openLocation({
latitude: LocationLAT * 1,
longitude: LocationLNG * 1,
name: Location,
fail(err) {
console.log(err)
},
})
},
handleShareClose() {
this.setData({
shareShow: false,
})
},
handlePosterFinish(e) {
this.setData({
posterUrl: e.detail,
})
},
handleDownload() {
const that = this
wx.getSetting({
success(res) {
console.log(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: '#cf5375',
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()
},
onShareAppMessage() {
this.saveShare()
return {
title: `【会议报名】${this.data.detail.Name}`,
3 months ago
path: `/patient/pages/liveDetail/index?id=${this.data.id}`,
3 months ago
// imageUrl: this.data.detail.IntroductionUrl,
}
},
})