app.js 1.5 KB
const fetchApi = require('./http/fetch-api.js');
const api = require('./http/api');
const config = require('./config');
const router = require('./router/index');
const storage = require('./utils/stroage');
const util = require('./utils/util');
const func = require('./utils/func');
// console.log('api.login:', api.login)

// console.log('fetchApi:',fetchApi)
// console.log('fetchApi.get:',fetchApi.fetch)

App({
  get: fetchApi.fetchMethod,
  post: (params) => {
    params.method = 'post';
    return fetchApi.fetchMethod(params);
  },
  delete: (params) => {
    params.method = 'DELETE';
    return fetchApi.fetchMethod(params);
  },
  uploadFile: fetchApi.uploadFile, // 单文件上传
  uploadFileMultiple: fetchApi.uploadFileMultiple, // 多文件上传,
  api: api,
  config: config,
  router: router,
  storage: storage,
  util: util,
  func: func,
  tapData: util.getBindtapData,
  globalData: {
    userInfo: null,
    profile: null,
    wxcode: storage.getItem("wxcode"),
    ui: {
      colorUI: "#409EFF",
      colorDanger: "#EE0A24"
    },
    invitationCode: "",
    statusBarHeight: 0,
  },
  onLaunch(options) {
    // 第一次打开
    // options.query == {number:1}
    console.info('App onLaunch');
  },
  onShow(options) {
    // 从后台被 scheme 重新打开
    // options.query == {number:1}
  },

  /**
   * 封装toast
   * @returns 
   */
  toast(title, opt = {
    icon: 'none'
  }) {
    let data = opt;
    data.title = title
    my.showToast({
      content: title
    })
    return;
  },
});