Files
danyang-match/miniapp/pages/local-eligibility/local-eligibility.ts
T

85 lines
2.3 KiB
TypeScript
Raw Normal View History

import api from '../../utils/api'
type EligibilityStatus =
| 'not_declared'
| 'declared'
| 'needs_evidence'
| 'pending_review'
| 'verified'
| 'rejected'
interface EligibilityStatusResponse {
verificationStatus?: EligibilityStatus
eligibilityType?: string
}
2026-09-09 22:05:00 +08:00
Page({
data: {
loading: true,
loadError: false,
submitting: false,
status: 'not_declared' as EligibilityStatus,
eligibilityType: '',
2026-09-09 22:05:00 +08:00
eligibilityTypes: [
{ value: 'household_registration', label: '丹阳户籍', icon: '户' },
{ value: 'employment', label: '在丹阳工作', icon: '工' },
{ value: 'residence', label: '在丹阳长期居住', icon: '居' },
{ value: 'other', label: '其他符合服务条件', icon: '其' },
],
statusText: {
not_declared: '尚未声明',
declared: '声明已保存',
needs_evidence: '需要补充佐证',
pending_review: '审核中',
verified: '已核验',
rejected: '未通过',
} as Record<EligibilityStatus, string>,
2026-09-09 22:05:00 +08:00
},
onLoad() {
this.checkStatus()
},
onShow() {
if (!this.data.loading) this.checkStatus()
2026-09-09 22:05:00 +08:00
},
onPullDownRefresh() {
this.checkStatus().finally(() => wx.stopPullDownRefresh())
2026-09-09 22:05:00 +08:00
},
async checkStatus() {
this.setData({ loading: true, loadError: false })
try {
const result = await api.get<EligibilityStatusResponse>('/local-eligibility')
this.setData({
loading: false,
status: result.verificationStatus || 'not_declared',
eligibilityType: result.eligibilityType || '',
})
return result
} catch {
this.setData({ loading: false, loadError: true })
return null
}
},
onTypeSelect(event: WechatMiniprogram.TouchEvent) {
const type = event.currentTarget.dataset.type as string
2026-09-09 22:05:00 +08:00
wx.navigateTo({
url: `/pages/local-eligibility-supplement/local-eligibility-supplement?type=${type}`,
2026-09-09 22:05:00 +08:00
})
},
goToMyEligibility() {
const { status, eligibilityType, statusText } = this.data
if (status === 'needs_evidence' || status === 'rejected' || status === 'declared') {
wx.navigateTo({
url: `/pages/local-eligibility-supplement/local-eligibility-supplement?type=${eligibilityType || ''}`,
})
return
}
wx.showToast({ title: statusText[status] || '状态已更新', icon: 'none' })
},
2026-09-09 22:05:00 +08:00
})