|
@@ -2,72 +2,33 @@ const app = getApp()
|
|
|
const httpUtils = require('../../utils/http.js')
|
|
|
const ui = require('../../utils/ui.js')
|
|
|
Page({
|
|
|
- data: {},
|
|
|
- onLoad() {},
|
|
|
- getPhoneNumber(e) {
|
|
|
- let that = this
|
|
|
- console.log("11111111111111111")
|
|
|
- console.log(e)
|
|
|
- let iv = e.detail.iv
|
|
|
- let encryptedData = e.detail.encryptedData
|
|
|
- if(e.detail.errMsg == 'getPhoneNumber:fail user deny'){
|
|
|
- wx.showToast({
|
|
|
- title: '请您授权手机号,以便提供更好服务',
|
|
|
- icon:'none',
|
|
|
- duration:5000
|
|
|
+ data: {
|
|
|
+ tab: 1
|
|
|
+ },
|
|
|
+ onShow(){
|
|
|
+ if(wx.getStorageSync('token')){
|
|
|
+ this.setData({
|
|
|
+ tab: 2
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ this.setData({
|
|
|
+ tab: 1
|
|
|
})
|
|
|
- }else {
|
|
|
- // wx.login({
|
|
|
- // success (res) {
|
|
|
- // if (res.code) {
|
|
|
- // console.log("2222222222222222")
|
|
|
- // console.log(res)
|
|
|
- // let code = res.code
|
|
|
- // // 调userinfo接口
|
|
|
- // let obj = {
|
|
|
- // url: '/api/erp/we/userInfo',
|
|
|
- // data: {
|
|
|
- // code: code
|
|
|
- // }
|
|
|
- // }
|
|
|
- // httpUtils.request(obj).then(res1=>{
|
|
|
- // console.log("33333333333333")
|
|
|
- // console.log(res1)
|
|
|
- //phoneinfo接口请求
|
|
|
- let obj2 = {
|
|
|
- url: '/api/erp/we/phoneInfo',
|
|
|
- data: {
|
|
|
- encryptedData: encryptedData,
|
|
|
- iv: iv,
|
|
|
- code: wx.getStorageSync('code')
|
|
|
- }
|
|
|
- }
|
|
|
- httpUtils.request(obj2).then(res2=>{
|
|
|
- console.log("444444444444444444")
|
|
|
- console.log(res2)
|
|
|
- wx.setStorageSync('token', res2.data.data.token)
|
|
|
- wx.setStorageSync('phone', res2.data.data.phone)
|
|
|
- // 弹框提示
|
|
|
- ui.showToast("登陆成功!")
|
|
|
- wx.switchTab({
|
|
|
- url: '/pages/list/index',
|
|
|
- })
|
|
|
- }).catch(err=>{
|
|
|
- console.log('ERROR')
|
|
|
- });
|
|
|
- // }).catch(err=>{
|
|
|
- // console.log('ERROR')
|
|
|
- // });
|
|
|
- // }
|
|
|
- // }
|
|
|
- // })
|
|
|
}
|
|
|
},
|
|
|
+ toOut(){
|
|
|
+ wx.removeStorageSync('token')
|
|
|
+ wx.removeStorageSync('phone')
|
|
|
+ wx.removeStorageSync('openId')
|
|
|
+ wx.removeStorageSync('code')
|
|
|
+ this.setData({
|
|
|
+ tab: 1
|
|
|
+ })
|
|
|
+ },
|
|
|
toLogin(){
|
|
|
wx.login({
|
|
|
success (res) {
|
|
|
if (res.code) {
|
|
|
- console.log("code",res)
|
|
|
let code = res.code
|
|
|
wx.setStorageSync('code', res.code)
|
|
|
// 调userinfo接口
|
|
@@ -83,27 +44,6 @@ Page({
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/submitPhone/index',
|
|
|
})
|
|
|
- // wx.setStorageSync('token', res2.data.data.token)
|
|
|
- // phoneinfo接口请求
|
|
|
- // let obj = {
|
|
|
- // url: '/api/erp/we/phoneInfo',
|
|
|
- // data: {
|
|
|
- // encryptedData: 'B',
|
|
|
- // iv: '1',
|
|
|
- // code: code
|
|
|
- // }
|
|
|
- // }
|
|
|
- // httpUtils.request(obj).then(res2=>{
|
|
|
- // wx.setStorageSync('token', res2.data.data.token)
|
|
|
- // // wx.setStorageSync('phone', res2.data.data.phone)
|
|
|
- // // 弹框提示
|
|
|
- // ui.showToast("登陆成功!")
|
|
|
- // wx.navigateTo({
|
|
|
- // url: '/pages/submitPhone/index',
|
|
|
- // })
|
|
|
- // }).catch(err=>{
|
|
|
- // console.log('ERROR')
|
|
|
- // });
|
|
|
}).catch(err=>{
|
|
|
console.log('ERROR')
|
|
|
});
|