// pages/entry/index.ts const app = getApp(); import { compareVersion } from "../../utils/util"; Page({ /** * 页面的初始数据 */ data: { nickName: "", phoneNumber: "", school: "", schoolList: [], inputed: false }, phoneinput(e: WechatMiniprogram.CustomEvent) { this.setData({ phoneNumber: e.detail.value }) }, bindKeyInput(e: WechatMiniprogram.CustomEvent) { this.setData({ nickName: e.detail.value }) }, toFace() { if (!this.data.phoneNumber) { return wx.showToast({ "icon": "none", "title": "未获取手机号", duration: 2000 }) } app.seaveUserData({ data: { name: this.data.nickName, phone: this.data.phoneNumber, organization: this.data.school || undefined }, method: "POST", success: () => { // 进入人脸识别 let url = "/pages/faceRecognition/index"; const version: string = app.globalData.SystemInfo?.SDKVersion || ""; if (compareVersion(version, "2.25.0") !== -1) url = "/pages/faceRecognitionVK/index" wx.navigateTo({ url }) } }) }, getPhoneNumber(e: WechatMiniprogram.CustomEvent) { if (!e.detail.code) { wx.showToast({ title: "请升级最新版微信。" }) return } app.getPhone({ data: { code: e.detail.code }, header: {}, success: (res: any) => { if (!res.purePhoneNumber) { app.globalData.phone = ""; wx.setStorageSync("userphone", ""); wx.showToast({ icon: "none", title: "未获取手机号,请手动输入", duration: 2000 }) return; } app.globalData.phone = res.purePhoneNumber; this.setData({ phoneNumber: res.purePhoneNumber }) wx.setStorageSync("userphone", res.purePhoneNumber); this.setData({ inputed: true }) } }) }, bindchange(e:WechatMiniprogram.CustomEvent){ this.setData({ school: this.data.schoolList[e.detail.value] || "" }) }, /** * 生命周期函数--监听页面加载 */ onLoad() { if (app.globalData.phone) { this.setData({ phoneNumber: app.globalData.phone, inputed: true }) } app.getSchoolList({ data: {}, method: "GET", success: (res: any) => { this.setData({ schoolList: (res || []).map((v:any) => v.organization), school: (res || [])[0]?.organization }) } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } }) export { }