index.js 795 字节
Newer Older
M
mehaotian 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
import Stat from './stat.js';
const stat = Stat.getInstance();
let isHide = false
const lifecycle = {
  onLaunch(options) {
    stat.report(options, this);
  },
  onReady() {
    stat.ready(this);
  },
  onLoad(options) {
    stat.load(options, this);
  },
  onShow() {
    isHide = false
    stat.show(this);
  },
  onHide() {
    isHide = true
    stat.hide(this);
  },
  onUnload() {
    if (isHide) {
      isHide = false
      return
    }
    stat.hide(this);
  },
  onError(e) {
    stat.error(e)
  },
  onShareAppMessage() {
    stat.interceptShare(false)
  }
}

function main() {
  const Vue = require('vue');
  (Vue.default || Vue).mixin(lifecycle);
  uni.report = function(type, options) {
    stat.sendEvent(type, options);
  };
}

main();