|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- const Http = require("./utils/HttpBasics.js")
- const config = require("./config/config.js");
- App({
- data:{
-
- },
- globalData:{
- token: null,
- imgHttps: 'https://zhibotang.oss-cn-beijing.aliyuncs.com/douyin/drawable-xhdpi/',
- platform:null,//手机型号
- },
- onLaunch: function () {
- let that = this
- this.logn();
- try {
- var res = tt.getSystemInfoSync();
- that.statusBarHeight = res.statusBarHeight
- console.log(`手机型号为 ${res.platform}`);
- this.globalData.platform = res.platform
- } catch (error) {
- console.log(`获取系统信息失败`);
- }
- },
- statusBarHeight: 0,
- logn(){
- let that = 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);
- that.globalData.token = res.data.token
- if (that.tokenCallback) {
- that.tokenCallback(res.data.token);
- }
- }).catch(err=>{
- console.log(err);
- tt.showModal({
- title: '提示',
- showCancel: false,
- content: '登录失败,请重新尝试',
- success: (res) => {
- if (res.cancel) {
- //点击取消,默认隐藏弹框
- } else {
- //点击确定
- wx.reLaunch({
- url: '/pages/index/index',
- })
- }
- }
- });
- })
-
- }),
-
- });
- }
- })
|