123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- import {
- ApiModel
- } from "../../utils/api"
- const _Http = new ApiModel;
- var utilMd5 = require('../../utils/md5');
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- pageType: 0, //页面类型,0登录,1新账号注册,2多账号
- userTelephone: 13732579910, //电话号
- securityCode: 123456, //验证码
- userList: [], //多账户用户列表
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- },
- /* 赋值号码 */
- inputTelephone(e) {
- /* 验证号码 */
- this.setData({
- userTelephone: e.detail.value
- })
- },
- /* 验证手机号 */
- verifyTelephone(value) {
- const regMobile = /^(0|86\17951)?(13[0-9]|15[0123456789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
- if (!regMobile.test(value)) {
- wx.showToast({
- title: '请输入正确手机号码',
- icon: 'none',
- duration: 2000 //持续的时间
- })
- }
- return regMobile.test(value);
- },
- /* 获取验证码 */
- getSecurityCode(e) {
- /* 验证号码 */
- if (!this.verifyTelephone(this.data.userTelephone)) return;
- /* 发送请求 */
- _Http.getPassword({
- "phonenumber": this.data.userTelephone
- }).then(s => {
- console.log(s)
- })
- },
- /* 验证码赋值 */
- inputVerify(e) {
- if (e.detail.value == "") return console.log("验证码错误")
- this.data.securityCode = e.detail.value
- },
- /* 登录 */
- login() {
- /* 验证号码 */
- if (!this.verifyTelephone(this.data.userTelephone)) return;
- _Http.login({
- "phonenumber": this.data.userTelephone,
- "password": utilMd5.hexMD5(this.data.securityCode)
- }).then(s => {
- console.log(s)
- if (s.msg != "成功") return wx.showToast({
- title: s.msg,
- icon: 'none',
- duration: 2000 //持续的时间
- })
- getApp().globalData.accountList = s.account_list;
- if (s.account_list.length >= 2) {
- console.log("多账号")
- this.setData({
- pageType: 2,
- userList: s.account_list
- })
- } else if (s.account_list[0].isnewregister == 1) {
- console.log("新账号")
- wx.setStorageSync('token', s.account_list[0].token);
- this.setData({
- pageType: 1
- })
- } else {
- console.log("单账号")
- wx.setStorageSync('token', s.account_list[0].token);
- wx.reLaunch({
- url: "/pages/tabbarPage/Home/index"
- })
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|