<!--
 * @Author: ZhengXiaowei
 * @Date: 2019-10-15 12:02:18
 * @LastEditors: ZhengXiaowei
 * @LastEditTime: 2019-10-15 14:02:07
 * @Description: 主入口
 -->
<script>
/**
 * 应用级别的配置，供所有页面公用
 */
import "./helper/regenerator.js";
import it from "./helper/interface.js";
import storage from "@system.storage";
import router from '@system.router';


export default {
  async onCreate() {
    this.dataCache = {
    }

    // 一进入程序就判断是否添加过主屏幕
    it.shortcut.systemPromptEnabled = false;
    await it.shortcut.hasInstalled({
      success: (ret) => {
        console.log("is installed:", ret);
        if (!ret) this.$def.data.backClickCount = 0;
        else this.$def.data.backClickCount = 1;
      }
    })

     it.getPushRedId(regId=>{
       storage.set({ key: "regId", value: regId });
    })
    
     /* router.push({
      uri: "/views/Ad",
     })  */ 

  }, 
  getAppData(key) {
    return this.dataCache[key]
  },
  setAppData(key, val) {
    this.dataCache[key] = val
  },
  showMenu: it.showMenu,
  getDeviceInfo: it.getDeviceInfo,
  createShortcut: it.hasCreateShortCut,
  data: {
    backClickCount: 0,
    cutomerQrcode: "",
    weChat: "wxlxf1099",
    appVersion: '',
    dataCache: {
      backfrom: '',
      options:null
    }
  }
};
</script>
