123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- // pages/entry/index.ts
- const app = getApp<IAppOption>();
- 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 { }
|