feat(M03-D): 完成场景码NFC与受控WiFi

This commit is contained in:
Codex
2026-06-18 15:56:36 +08:00
parent 88fa22ee92
commit d563078a9f
28 changed files with 859 additions and 14 deletions
+24
View File
@@ -9,6 +9,12 @@ Page({
stores: [],
},
onLoad(options) {
if (options.scene) {
this.resolveScene(decodeURIComponent(options.scene), options.source === 'nfc' ? 'NFC' : 'QRCODE')
}
},
onCityInput(event) {
this.setData({ city: event.detail.value })
},
@@ -52,4 +58,22 @@ Page({
this.setData({ loading: false })
}
},
async resolveScene(code, sourceType) {
this.setData({ loading: true, errorMessage: '' })
try {
const response = await request('/scenes/resolve', {
method: 'POST',
data: { code, sourceType },
})
const target = response.data
const query = [`storeId=${encodeURIComponent(target.storeId)}`]
if (target.roomId) query.push(`roomId=${encodeURIComponent(target.roomId)}`)
wx.navigateTo({ url: `${target.page}?${query.join('&')}` })
} catch (error) {
this.setData({ errorMessage: error.message || '场景码已失效' })
} finally {
this.setData({ loading: false })
}
},
})