Files
Wechat/pages/phone-auth/phone-auth.js
XingQue c03d22776f backup: 紫色UI换肤前完整备份(当前橙色逍遥梦主题)
保留改造前全部页面样式与功能代码,便于回滚。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 01:59:42 +08:00

40 lines
942 B
JavaScript

import { submit, getPhoneAuthReturnPage } from '../../utils/phone-auth';
Page({
data: {
show: false,
avatar: '',
avatarFile: null,
phoneCode: '',
phoneGot: false
},
onLoad() {
setTimeout(() => this.setData({ show: true }), 100);
},
onAvatar(e) {
const p = e.detail.avatarUrl;
this.setData({ avatar: p, avatarFile: p });
},
onPhone(e) {
if (e.detail.code) {
this.setData({ phoneCode: e.detail.code, phoneGot: true });
}
},
async submit() {
const { phoneCode, avatarFile } = this.data;
if (!avatarFile || !phoneCode) return;
try {
wx.showLoading({ title: '认证中...', mask: true });
await submit(phoneCode, avatarFile);
wx.hideLoading();
wx.reLaunch({ url: getPhoneAuthReturnPage() });
} catch (e) {
wx.hideLoading();
wx.showToast({ title: e.message, icon: 'none' });
}
},
exit() {
wx.exitMiniProgram();
}
});