@@ -477,8 +477,14 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
goRegister() {
|
||||
wx.navigateTo({ url: '/pages/register/index' })
|
||||
async getWechatCode() {
|
||||
const result = await new Promise((resolve, reject) => wx.login({ success: resolve, fail: reject }))
|
||||
return result.code
|
||||
},
|
||||
|
||||
goRegister(wxCode) {
|
||||
const query = wxCode ? `?wxCode=${encodeURIComponent(wxCode)}` : ''
|
||||
wx.navigateTo({ url: `/pages/register/index${query}` })
|
||||
},
|
||||
|
||||
async wechatLogin() {
|
||||
@@ -489,7 +495,8 @@ Page({
|
||||
const result = await authApi.wechatAutoLogin(loginResult.code)
|
||||
if (result.status === 'NEED_MANUAL_LOGIN') {
|
||||
wx.showToast({ title: '新账号请先完成手机号注册和身份审核', icon: 'none', duration: 2500 })
|
||||
setTimeout(() => this.goRegister(), 900)
|
||||
const wxCode = await this.getWechatCode()
|
||||
setTimeout(() => this.goRegister(wxCode), 900)
|
||||
return
|
||||
}
|
||||
if (result.status !== 'SUCCESS' || !result.accessToken) {
|
||||
|
||||
@@ -8,6 +8,7 @@ Page({
|
||||
role: 'manager',
|
||||
passwordMode: false,
|
||||
form: { phone: '', code: '', password: '', confirmPassword: '', shopName: '', shopAddress: '', shopId: '' },
|
||||
wxCode: '',
|
||||
shopOptions: [],
|
||||
shopIndex: 0,
|
||||
selectedShopName: '',
|
||||
@@ -17,7 +18,8 @@ Page({
|
||||
countdownTimer: null
|
||||
},
|
||||
|
||||
async onLoad() {
|
||||
async onLoad(options) {
|
||||
this.setData({ wxCode: options && options.wxCode ? options.wxCode : '' })
|
||||
try {
|
||||
const shopOptions = await authApi.getAvailableRegistrationShops()
|
||||
this.setData({ shopOptions: Array.isArray(shopOptions) ? shopOptions : [] })
|
||||
@@ -65,7 +67,7 @@ Page({
|
||||
if (this.data.role === 'staff') { wx.showToast({ title: '店员申请功能即将开放', icon: 'none' }); return }
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
await authApi.register({ phone: form.phone, verificationCode: form.code, password: form.password, confirmPassword: form.confirmPassword, shopName: form.shopName, shopAddress: form.shopAddress, shopId: form.shopId, roleType: this.data.role === 'manager' ? 'MANAGER' : 'STAFF', agreementAccepted: true })
|
||||
await authApi.register({ phone: form.phone, verificationCode: form.code, 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 })
|
||||
this.setData({ step: 4 })
|
||||
} catch (error) { wx.showToast({ title: error.message || '提交失败', icon: 'none' }) } finally { this.setData({ loading: false }) }
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user