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

136 lines
3.5 KiB

3 months ago
import dayjs from 'dayjs'
const app = getApp<IAppOption>()
let live_time: null | number = null
Page({
data: {
active: 0,
list: [],
pagination: {
page: 1,
pages: 1,
count: 1,
},
online_open_status: 1, // 线上
offline_open_status: 1, // 线下
liveStatus: app.globalData.liveStatus,
activityStatus: app.globalData.activityStatus,
3 months ago
zdUserInfo: {},
3 months ago
},
onLoad() {
this.setData({
dateValue: dayjs().valueOf(),
})
if (live_time) {
clearInterval(live_time)
}
live_time = setInterval(() => {
this.setData({
dateValue: dayjs().valueOf(),
})
}, 1000)
app.waitLogin({ type: [1] }).then(() => {
3 months ago
this.getConfig()
3 months ago
app.getZdUserInfo(this, true)
3 months ago
})
},
getConfig() {
wx.ajax({
method: 'GET',
3 months ago
url: '?r=zd/common/get-config',
3 months ago
data: {},
}).then((res) => {
let active = 0
if (res.online_open_status == 0) {
active = 1
}
this.setData({
online_open_status: res.online_open_status,
offline_open_status: res.offline_open_status,
active,
})
this.getList()
})
},
getList(newPage = 1) {
const { active } = this.data
if (newPage == 1 && active == 0) {
app.zdMpBehavior({ PageName: 'PG_PATIENTMYEVENTS_ALL' })
}
if (newPage == 1 && active == 1) {
app.zdMpBehavior({ PageName: 'PG_PATIENTMYEVENTS_ONLINE' })
}
if (newPage == 1 && active == 2) {
app.zdMpBehavior({ PageName: 'PG_PATIENTMYEVENTS_OFFLINE' })
}
wx.ajax({
method: 'GET',
3 months ago
url: '?r=zd/activity/sign-up-list',
3 months ago
data: {
Type: Number(active) == 0 ? '' : Number(active),
page: newPage,
},
}).then((res) => {
res.list = res.list.map((item) => {
item.EndTimeValue = dayjs(item.EndTime).valueOf()
item.BeginTimeValue = dayjs(item.BeginTime).valueOf()
item.SignUpDeadlineValue = dayjs(item.SignUpDeadline).valueOf()
item.BeginDate = dayjs(item.BeginTime).format('YYYY-MM-DD')
item.EndDate = dayjs(item.EndTime).format('YYYY-MM-DD')
item.isDay = item.BeginDate == item.EndDate
item.BeginHm = dayjs(item.BeginTime).format('HH:mm')
item.EndHm = dayjs(item.EndTime).format('HH:mm')
item.BeginTime = dayjs(item.BeginTime).format('YYYY-MM-DD HH:mm')
item.EndTime = dayjs(item.EndTime).format('YYYY-MM-DD HH:mm')
return item
})
const list = res.page == 1 ? res.list : [...this.data.list, ...res.list]
this.setData({
list,
pagination: {
page: res.page,
pages: res.pages,
count: res.count,
},
})
})
},
tabChange(e) {
this.setData({
active: e.detail.index,
})
this.getList()
},
handleDetail(e) {
const { id } = e.currentTarget.dataset
const { active } = this.data
3 months ago
if (active == 0) {
app.zdMpBehavior({ PageName: 'BTN_PATIENTSIGNEDUPACTIVITIESALLLIST' })
}
if (active == 1) {
app.zdMpBehavior({ PageName: 'BTN_PATIENTSIGNEDUPACTIVITIESONLINELIST' })
}
if (active == 2) {
app.zdMpBehavior({ PageName: 'BTN_PATIENTSIGNEDUPACTIVITIESOFFLINELIST' })
}
wx.navigateTo({
3 months ago
url: `/patient/pages/liveDetail/index?id=${id}`,
3 months ago
})
},
onReachBottom() {
const { page, pages } = this.data.pagination
if (pages > page) {
this.getList(page + 1)
}
},
handleBack() {
wx.navigateBack({
fail() {
wx.reLaunch({
url: '/patient/pages/index/index',
})
},
})
},
3 months ago
})