// index.js
var myRequest = require("../../utils/api.js");
const app = getApp()
Page({
  data: { 
    imageSrc:app.globalData.imgUrl+'head.png',
    tel:'',
    passworld:''
  },
  onchange(e){
    console.log(e)
    this.setData({
      tel:e.detail.value,
 
    })
  },
  onchangeps(e){
    console.log(e)
    this.setData({
      passworld:e.detail.value,
 
    })
  },

  register(){
    wx.navigateTo({
      url: '../register/index',
    })
  },
  login(){
    if(this.data.tel.length!=11){
      wx.showToast({
      title: '请输入手机号',
      icon:'none'
    })
    return 
    }
  
    myRequest.myRequest('phonenmberLogin',{
      phonenumber:this.data.tel,
      passworld:this.data.passworld
     },'get').then(res=>{
      
       wx.setStorageSync("token",res.data.token);
       wx.redirectTo({
         url: '../index/index',
       })
     })

  },
  weChatLogin(e) {
     console.log(e)
     myRequest.myRequest('login',{
      code:e.detail.code
     },'get').then(res=>{
      
       wx.setStorageSync("token",res.data.token);
       wx.redirectTo({
         url: '../index/index',
       })
     })

  },
})
