feat: implement mobile number binding via WeChat and enforce phone verification for venue entry, booking, and card purchases

This commit is contained in:
2026-04-18 18:32:30 +08:00
parent 7552f9946b
commit 5236fabc83
11 changed files with 139 additions and 19 deletions

View File

@@ -113,8 +113,8 @@ Page({
// 手机号一键登录/注册
onGetPhoneNumber(e) {
// 微信一键登录
onWechatLogin() {
if (!this.data.isAgree) {
wx.showToast({
title: '请阅读并同意服务条款及隐私政策',
@@ -124,22 +124,14 @@ Page({
return;
}
if (e.detail.errMsg === 'getPhoneNumber:fail user deny') {
return;
}
this.setData({ showUnclickMask: true });
let that = this;
// 前端获取到手机号授权 code 后,再去获取 wx.login 的 code
// 前端获取 code 后去换取 token
wx.login({
success: function (r) {
// 调用后端接口。
// 注意:这里复用了 memberLoginWXPhone。请让后端把接收参数改为 phoneCode 和 loginCode
// 或者您自己在 api.js 里新建一个专属的一键登录接口。后端收到 phoneCode 后去微信服换取真实手机号并完成注册登录。
app.$api.memberLoginWXPhone({
loginCode: r.code,
phoneCode: e.detail.code
app.$api.memberLoginWX({
code: r.code
}).then(res => {
if (!res.authorization) {
that.setData({ showUnclickMask: false });
@@ -149,8 +141,8 @@ Page({
wx.setStorageSync('information', res.information);
wx.setStorageSync('accessToken', res.authorization.accessToken);
that.setData({ showUnclickMask: false });
that.changeLoginStatus();
let route = wx.getStorageSync('history');
wx.removeStorageSync('history');
if (!route || route == '/pages/login/index') {
@@ -165,5 +157,17 @@ Page({
that.setData({ showUnclickMask: false });
}
})
},
// 暂不登录,退回上一页
skipLogin() {
let pages = getCurrentPages();
if (pages.length <= 1) {
wx.redirectTo({
url: '/pages/home/index',
});
} else {
wx.navigateBack();
}
}
})