Files
Michelle ZanandCursor cd05113755 Add 卓米会 mini program and admin server.
Initial commit of the WeChat mini program, Express backend, and admin console.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-29 19:01:36 +08:00

57 lines
1.3 KiB
JavaScript

const api = require('../../utils/api')
const media = require('../../utils/media')
const activityUtil = require('../../utils/activity')
Page({
data: {
nickName: '',
avatarUrl: '',
letter: '微',
signups: [],
checkins: [],
checking: false
},
onShow() {
this.loadAll()
},
onPullDownRefresh() {
this.loadAll().then(() => wx.stopPullDownRefresh())
},
loadAll() {
return Promise.all([api.profile(), api.mySignups()])
.then((results) => {
const profile = results[0] || {}
const mine = results[1] || {}
const nickName = profile.nickName || ''
this.setData({
nickName: nickName,
avatarUrl: media.absUrl(profile.avatarUrl),
letter: (nickName || '微').slice(0, 1),
signups: mine.signups || [],
checkins: mine.checkins || []
})
})
.catch(() => {})
},
goProfile() {
wx.navigateTo({ url: '/pages/profile/profile' })
},
checkin() {
if (this.data.checking) return
this.setData({ checking: true })
api
.checkin({ simulate: true })
.then(() => {
wx.showToast({ title: '签到成功', icon: 'success' })
return this.loadAll()
})
.catch(activityUtil.toast)
.then(() => this.setData({ checking: false }))
}
})