chore: establish V1.1 recovery baseline
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* 签到码页 U31
|
||||
*/
|
||||
const api = require('../../utils/api');
|
||||
|
||||
Page({
|
||||
data: {
|
||||
activityId: '',
|
||||
activityTitle: '',
|
||||
locationName: '',
|
||||
token: '',
|
||||
expiresAt: '',
|
||||
loading: true,
|
||||
error: ''
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
if (options.id) {
|
||||
this.setData({ activityId: options.id });
|
||||
this.loadCheckinToken();
|
||||
}
|
||||
},
|
||||
|
||||
onShow() {
|
||||
// 每次显示时刷新Token
|
||||
if (this.data.activityId) {
|
||||
this.loadCheckinToken();
|
||||
}
|
||||
},
|
||||
|
||||
async loadCheckinToken() {
|
||||
this.setData({ loading: true, error: '' });
|
||||
try {
|
||||
const token = wx.getStorageSync('accessToken');
|
||||
const res = await api.post(`/activities/${this.data.activityId}/checkin-token`, {}, {
|
||||
Authorization: `Bearer ${token}`
|
||||
});
|
||||
this.setData({
|
||||
token: res.token,
|
||||
activityTitle: res.activityTitle,
|
||||
locationName: res.locationName,
|
||||
expiresAt: res.expiresAt,
|
||||
loading: false
|
||||
});
|
||||
} catch (err) {
|
||||
this.setData({ loading: false, error: err.message || '加载失败' });
|
||||
}
|
||||
},
|
||||
|
||||
onRefresh() {
|
||||
this.loadCheckinToken();
|
||||
},
|
||||
|
||||
copyToken() {
|
||||
wx.setClipboardData({
|
||||
data: this.data.token,
|
||||
success: () => wx.showToast({ title: '签到码已复制', icon: 'success' })
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user