app.js 1.23 KB
//app.js
let fetchApi = require('./http/fetch-api.js');
let api = require('./http/api');
let config = require('./config');
let router = require('./router/index');
let store = require('./utils/stroage');

require('./http/mock-data');

App({
  get: fetchApi.fetch,
  post: (params) => {
    params.method = 'post';
    return fetchApi.fetch(params);
  },
  api: api,
  config: config,
  router: router,
  store: store,
  onLaunch: function () {},
  globalData: {
    indexInfo: null,
    userInfo: null,
    wxcode: store.getItem("wxcode"),
    tlMemberCode: "",
    curCoupon: null,
    questionResult:null,//答题的结果 弹力值 elasticValue
  },
  // 获取用户基本信息
  queryIndex() {
    return new Promise((resolve, reject) => {
      this.post({
        url: this.api.index,
        data: {},
        loading: true,
      }).then((result) => {
        this.globalData.indexInfo = result;
        this.globalData.userInfo = result.userInfo;
        if (result.isNeedAuth == 1) {
          //需要授权
          this.router.push({
            path: "authorize"
          })
          reject();
          // resolve();
        } else {
          resolve(result)
        }
      }).catch((err) => {
        reject();
      });
    });
  }
})