import { autoSetUid, checkAppVersion } from './jsapi';
import { executeHooks } from './registerHooks';
import { imgSrcPrefix } from './constants';

export function onDefaultAppLaunch(options) {
  const appIdRes = my.getAppIdSync();
  this.globalData.appId = appIdRes.appId;
  this.globalData.launchOptions = options;
  autoSetUid();
  checkAppVersion();
  executeHooks('onAppLaunch', {
    context: this,
    args: [options],
  });
}


export const defaultGlobalData = {
  ticketData: { // 票据信息
    ticket: '',
    expiresTime: 0,
  },
  settingData: {
    loginType: null,
    scopes: [],
    showRegion: null,
  },
  regionData: {
    regionCode: null,
    accuracy: null,
    longitude: null,
    latitude: null,
    cityAdcode: null,
    mktCode: null,
    regionList: [],
  },
  imgSrcPrefix,
  isUserLogin: false,
  userInfo: null,
  appId: '',
  templateUUID: '',
  isInitialized: false,
  pagesQuery: {}, // 全局可传参的数据
  getTicketing: false,
};
