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.
135 lines
3.5 KiB
135 lines
3.5 KiB
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, |
|
zdUserInfo: {}, |
|
}, |
|
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(() => { |
|
this.getConfig() |
|
app.getZdUserInfo(this, true) |
|
}) |
|
}, |
|
getConfig() { |
|
wx.ajax({ |
|
method: 'GET', |
|
url: '?r=zd/common/get-config', |
|
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', |
|
url: '?r=zd/activity/sign-up-list', |
|
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 |
|
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({ |
|
url: `/patient/pages/liveDetail/index?id=${id}`, |
|
}) |
|
}, |
|
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', |
|
}) |
|
}, |
|
}) |
|
}, |
|
})
|
|
|