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.
116 lines
2.5 KiB
116 lines
2.5 KiB
import dayjs from 'dayjs' |
|
|
|
const app = getApp<IAppOption>() |
|
let live_time: null | number = null |
|
|
|
Page({ |
|
data: { |
|
id: '', |
|
detail: {} as any, |
|
liveDetail: {} as any, |
|
zdUserInfo: {}, |
|
codeUrl: '', |
|
dateValue: '' as string | number, |
|
rewardScore: 0 as number | undefined, |
|
qrCode: '', |
|
|
|
entry: '0', |
|
}, |
|
onLoad(options) { |
|
this.setData({ |
|
id: options.id, |
|
rewardScore: options.rewardScore, |
|
entry: options.entry, |
|
}) |
|
if (live_time) { |
|
clearInterval(live_time) |
|
} |
|
this.setData({ |
|
dateValue: dayjs().valueOf(), |
|
}) |
|
live_time = setInterval(() => { |
|
this.setData({ |
|
dateValue: dayjs().valueOf(), |
|
}) |
|
}, 1000) |
|
app.waitLogin({ type: [1] }).then((_res) => { |
|
this.getLiveDetail() |
|
this.getDetail() |
|
app.getZdUserInfo(this, true) |
|
}) |
|
}, |
|
getDetail() { |
|
wx.ajax({ |
|
method: 'GET', |
|
url: '?r=zd/activity/sign-up-detail', |
|
data: { |
|
Id: this.data.id, |
|
}, |
|
}).then((res) => { |
|
res.BeginTime = dayjs(res.BeginTime).format('YYYY-MM-DD HH:mm') |
|
res.BeginTimeValue = dayjs(res.BeginTime).valueOf() |
|
this.setData({ |
|
detail: res, |
|
}) |
|
if (this.data.entry == '1' && res.BeginTimeValue < this.data.dateValue && res.Type == 1) { |
|
this.handleLive() |
|
} |
|
this.getQrCode() |
|
}) |
|
}, |
|
getQrCode() { |
|
wx.ajax({ |
|
method: 'GET', |
|
url: '?r=zd/common/get-channel-wx-code', |
|
data: { |
|
ChannelType: this.data.detail.Type == 1 ? '1' : '11', |
|
Id: this.data.id, |
|
}, |
|
}).then((res) => { |
|
this.setData({ |
|
qrCode: res, |
|
}) |
|
}) |
|
}, |
|
getLiveDetail() { |
|
wx.ajax({ |
|
method: 'GET', |
|
url: '?r=zd/activity/detail', |
|
data: { |
|
Id: this.data.id, |
|
}, |
|
}).then((res) => { |
|
this.setData({ |
|
liveDetail: res, |
|
}) |
|
}) |
|
}, |
|
handleLive() { |
|
const { TencentMeetingCode } = this.data.detail |
|
wx.navigateToMiniProgram({ |
|
appId: 'wx33fd6cdc62520063', // 要跳转的微信小程序appid |
|
path: `pages/index/index?code=${TencentMeetingCode}`, |
|
}) |
|
}, |
|
handleHome() { |
|
wx.reLaunch({ |
|
url: '/patient/pages/index/index', |
|
}) |
|
}, |
|
handleBack() { |
|
wx.navigateBack({ |
|
fail: () => { |
|
wx.reLaunch({ |
|
url: '/pages/start/index', |
|
}) |
|
}, |
|
}) |
|
}, |
|
onShareAppMessage() { |
|
return { |
|
title: this.data.detail.ActivityName, |
|
path: `/patient/pages/liveDetail/index?id=${this.data.detail.ActivityId}`, |
|
imageUrl: `${this.data.liveDetail.IntroductionUrl}`, |
|
} |
|
}, |
|
})
|
|
|