|
@@ -0,0 +1,114 @@
|
|
|
+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
|
|
|
+ })
|
|
|
+ }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')
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ toLogin(){
|
|
|
+ wx.login({
|
|
|
+ success (res) {
|
|
|
+ if (res.code) {
|
|
|
+ console.log("code",res)
|
|
|
+ let code = res.code
|
|
|
+ wx.setStorageSync('code', res.code)
|
|
|
+ // 调userinfo接口
|
|
|
+ let obj = {
|
|
|
+ url: '/api/erp/we/userInfo',
|
|
|
+ data: {
|
|
|
+ code: code
|
|
|
+ }
|
|
|
+ }
|
|
|
+ httpUtils.request(obj).then(res1=>{
|
|
|
+ console.log("userInfo",res1)
|
|
|
+ wx.setStorageSync('openId', res1.data.data)
|
|
|
+ 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')
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+})
|