const navigationBarHeight = (getApp().statusBarHeight + 60) + 'px' const util = require("../../utils/util.js"); const Http = require("../../utils/HttpBasics"); const config = require("../../config/config"); const imgurl = require("../../utils/imgurl"); Page({ /** * 页面的初始数据 */ data: { navigationBarHeight, tabIndex: 0, pdwSwitch: 0, isShowPwd: false, isChangePhone: false, code: "", name: "叶文沁", phone: "1379****591", tempPhone: '', password: '' }, // 兑换 exchange(e) { console.log(e, 'e'); let that = this; let code = e.detail.value.code; console.log(code); }, // 更改手机号 changePhone() { this.setData({ isChangePhone: true, tempPhone: this.data.phone }) }, // 输入手机号 phoneInput(e) { this.setData({ phone: e.detail.value }) }, // 输入密码 pwdInput(e) { this.setData({ password: e.detail.value, }) }, // 确认手机号更改 confirmPhone() { const phoneReg = /^(?:(?:\+|00)86)?1[3-9]\d{9}$/ const phoneValid = phoneReg.test(this.data.phone) if (!phoneValid) { wx.showToast({ title: '请输入正确的手机号!', icon: 'none' }) return } this.setData({ isChangePhone: false, }) }, // 取消更改 cancelChangePhone() { this.setData({ isChangePhone: false, phone: this.data.tempPhone }) }, // 更改tab栏 changeTabs(e) { console.log(e, 'changeTabs'); this.setData({ tabIndex: e.target.id, code: '', password: '' }) }, // 支付安全设置 securityChange(e) { this.setData({ pdwSwitch: e.detail.value * 1 }) }, // 扫描二维码 goScanCode() { console.log('scan!!!'); const that = this wx.scanCode({ success: (res) => { console.log(res, 'res'); const num = res.result that.setData({ code: num }) that.exchange({ detail: { value: num } }) }, fail: (res) => { console.log(res, 'fail'); } }) }, setPwdShow() { const isShowPwd = this.data.isShowPwd this.setData({ isShowPwd: !isShowPwd }) }, submit() { const thisData = this.data const data = { name: thisData.name, phone: thisData.phone, pdwSwitch: thisData.pdwSwitch, password: thisData.password, } console.log(data, 'submitData'); }, goGive() { }, // 检查用户登录状态 checkPhoneStatus() { let that = this; Http.get({ url: config.api.checkPhoneStatus, }) .then(res => { }) .catch(err => { if (err.code == 11005) { // 手机号没有授权,将值传到用户手机号授权的页面 wx.redirectTo({ url: "/pages/getphoneInfo/index", }) } else { wx.showToast({ title: err.message, icon: 'none', duration: 2500 }) } }) }, onLoad() { setTimeout(() => { this.checkPhoneStatus() }, 2000); } })