|
-
- const app = getApp()
- const config = require("../../config/config")
- const Http = require("../../utils/HttpBasics.js")
- const navigationBarHeight = (getApp().statusBarHeight + 44) + "px"
- Page({
- data: {
- navigationBarHeight,
- imgHttps: app.globalData.imgHttps,
- userData: "",
- },
-
- onLoad: function () {
- console.log(123);
- let _this = this
- tt.login({
- success(_res) {
- let {code} = _res
- Http.post({
- url:config.api.login,
- data:{
- code:code,
- appId:'tt8183f73e1ebb053701'
- }
- }).then(res=>{
- Http.setToken(res.data.token);
- app.globalData.token = res.data.token
- tt.getUserInfo({// 获取用户信息
- withCredentials: true,
- // withRealNameAuthenticationInfo: true,
- success(res) {
- console.log(res);
- _this.setData({
- userData: res.userInfo
- })
-
- Http.get({
- url: config.api.checkUserInfo
- }).then(res => {
- }).catch(err=>{
- console.log("我没提交授权",err.code);
- if(err.code == 11004){
- Http.post({
- url:config.api.userInfo,
- data:{
- iv:res.iv,
- encryptedData:res.encryptedData
- }
- }).then(res=>{
- console.log(res);
- })
- }
- })
-
- },
- fail(res) {
- tt.navigateTo({
- url: 'pages/index/index' // 指定页面的url
- });
- },
- });
-
- }).catch(err=>{
- console.log(err);
- tt.showModal({
- title: '提示',
- showCancel: false,
- content: '登录失败,请重新尝试',
- success: (res) => {
- if (res.cancel) {
- //点击取消,默认隐藏弹框
- } else {
- //点击确定
- wx.reLaunch({
- url: '/pages/index/index',
- })
- }
- }
- });
- })
-
-
-
- },
- });
- }
- })
|