85 lines
2.3 KiB
TypeScript
85 lines
2.3 KiB
TypeScript
import api from '../../utils/api'
|
|
|
|
type EligibilityStatus =
|
|
| 'not_declared'
|
|
| 'declared'
|
|
| 'needs_evidence'
|
|
| 'pending_review'
|
|
| 'verified'
|
|
| 'rejected'
|
|
|
|
interface EligibilityStatusResponse {
|
|
verificationStatus?: EligibilityStatus
|
|
eligibilityType?: string
|
|
}
|
|
|
|
Page({
|
|
data: {
|
|
loading: true,
|
|
loadError: false,
|
|
submitting: false,
|
|
status: 'not_declared' as EligibilityStatus,
|
|
eligibilityType: '',
|
|
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>,
|
|
},
|
|
|
|
onLoad() {
|
|
this.checkStatus()
|
|
},
|
|
|
|
onShow() {
|
|
if (!this.data.loading) this.checkStatus()
|
|
},
|
|
|
|
onPullDownRefresh() {
|
|
this.checkStatus().finally(() => wx.stopPullDownRefresh())
|
|
},
|
|
|
|
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
|
|
wx.navigateTo({
|
|
url: `/pages/local-eligibility-supplement/local-eligibility-supplement?type=${type}`,
|
|
})
|
|
},
|
|
|
|
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' })
|
|
},
|
|
})
|