修正微信注册绑定凭证时效

This commit is contained in:
2026-09-11 15:35:41 +08:00
parent e9a2e74b91
commit 2ebaaeec77
+7 -1
View File
@@ -71,13 +71,19 @@ Page({
goBackStep() { this.setData({ step: Math.max(1, this.data.step - 1) }) },
async getCurrentWxCode() {
const result = await new Promise((resolve, reject) => wx.login({ success: resolve, fail: reject }))
return result.code
},
async submit() {
const form = this.data.form
if (this.data.role === 'manager' && !String(form.shopName || '').trim()) { wx.showToast({ title: '请输入店铺名称', icon: 'none' }); return }
if (this.data.role === 'staff' && !form.shopId) { wx.showToast({ title: '请选择要加入的店铺', icon: 'none' }); return }
this.setData({ loading: true })
try {
await authApi.register({ phone: form.phone, verificationCode: this.data.registrationTicket ? undefined : form.code, registrationTicket: this.data.registrationTicket || undefined, applicationId: this.data.applicationId || undefined, password: form.password, confirmPassword: form.confirmPassword, shopName: form.shopName, shopAddress: form.shopAddress, shopId: form.shopId, roleType: this.data.role === 'manager' ? 'MANAGER' : 'STAFF', agreementAccepted: true, wxCode: this.data.wxCode })
const wxCode = this.data.registrationTicket ? await this.getCurrentWxCode() : this.data.wxCode
await authApi.register({ phone: form.phone, verificationCode: this.data.registrationTicket ? undefined : form.code, registrationTicket: this.data.registrationTicket || undefined, applicationId: this.data.applicationId || undefined, password: form.password, confirmPassword: form.confirmPassword, shopName: form.shopName, shopAddress: form.shopAddress, shopId: form.shopId, roleType: this.data.role === 'manager' ? 'MANAGER' : 'STAFF', agreementAccepted: true, wxCode })
this.setData({ step: 4 })
} catch (error) { wx.showToast({ title: error.message || '提交失败', icon: 'none' }) } finally { this.setData({ loading: false }) }
},