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>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
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 }))
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user