//app.js
let wechat = require('./utils/wechat.js');
let log = require('./utils/log.js');
App({
  globalData: {

    // 测试
    postHeadAgreement: 'https://jqcs.pjnes.com/cloud/chargapi',

    // 正式
    // postHeadAgreement: 'https://cdglyy.pjnes.com/cloud/chargapi',
    helpPhoneNum: '4009608068',
    version:'2.0'
  },
  onLaunch() {
    log.info('[全局]', '[小程序加载完成]');
    // log.error({ str: 'hello world22' }, 'warn log', 100, [1, 2, 3]); 
    // log.warn({ str: 'hello world33' }, 'warn log', 100, [1, 2, 3]);
    // log.setFilterMsg('filterkeyword');
    // log.setFilterMsg('addfilterkeyword');
    // wx.showModal({
    //   title: '温馨提示',
    //   content: '为方便您更好的使用派捷充电小程序,平台将定期(暂定每周一次)对未支付订单进行自动支付。望周知',
    //   showCancel:false
    // }); 
    // wx.showToast({
    //   title: '当前网络环境较差,无法连接服务器,请稍后重试。有问题请联系客服电话4009608068,接听时段08:30-17:00。',
    //   icon: 'none',
    //   duration:2000
    // });
    //this.showNetworkError();
     
  },
  showNetworkError(){
    wx.showModal({
      title: '温馨提示',
      content: '当前网络环境较差,无法连接服务器,请稍后重试。有问题请联系客服电话4009608068,接听时段08:30-17:00。',
      showCancel: false
    });
  },
  onShow() {
    let userInfo = wx.getStorageSync('userInfo');
    let isLogin = wx.getStorageSync('isLogin');
    // 页面显示
    if (userInfo && isLogin) {
      if ((!userInfo.userId && userInfo.userId != 0)) {
        log.info('[全局]', '[已登陆未有用户ID跳转登录界面]');
        let url = `/pages/login/login`;
        wx.navigateTo({
          url
        });
        return;
      }
    }
  }
  // "tabBar": {
  //       "color": "#a9b7b7",
  //       "selectedColor": "#11cd6e",
  //       "borderStyle": "black",
  //       "list": [
  //     {
  //             "selectedIconPath": "images/index.png",
  //           "iconPath": "images/index.png",
  //             "pagePath": "pages/index/index",
  //           "text": "首页"  

  //     },

  //     {
  //            "selectedIconPath": "images/ucenter.png",
  //            "iconPath": "images/ucenter.png",
  //            "pagePath": "pages/ucenter/index/index",
  //            "text": "我的"  

  //     }

  //   ]  
  // },
})