import Vue from 'vue';
import md5 from 'js-md5';
import {
  md,
  geTel,
  formatRichText,
  saveSceneQrcodeDetail,
  noMultipleClicks,
  savePullVipcode,
  is_weixin,
  delStorageSync,
  copyH5,
  getLocationValue,
} from '@/utils/common';
// #ifdef H5
import wx from '../utils/js_sdk/weixin';
import { authorizeH5, getCode, postCode } from '@/utils/authorizeH5';
// #endif
import { location } from '@/utils/location';

import CacheTool from '@/utils/cache-tool.js';
CacheTool.init();
import {
  KIP_APP_PATH,
  ETCP_APP_PATH,
  ETCP_APP_INVOICE_PATH,
} from '@/constants.js';
import cacheTool from '@/utils/cache-tool';

Vue.prototype.$md5 = md5;
Vue.prototype.$md = md;
Vue.prototype.$location = location;
Vue.prototype.$geTel = geTel;
Vue.prototype.$formatRichText = formatRichText;
Vue.prototype.$saveSceneQrcodeDetail = saveSceneQrcodeDetail;
Vue.prototype.$noMultipleClicks = noMultipleClicks;
Vue.prototype.$savePullVipcode = savePullVipcode;
// 页面的 onLoad 在 onLaunch 之后执行
Vue.prototype.$onLaunched = new Promise((resolve) => {
  Vue.prototype.$isResolve = resolve;
});
// #ifdef MP-WEIXIN
Vue.prototype.$userName = 'sys_miniprogram';
// #endif

// #ifdef H5
Vue.prototype.$wx = wx;
Vue.prototype.$authorizeH5 = authorizeH5;
Vue.prototype.$getCode = getCode;
Vue.prototype.$postCode = postCode;
Vue.prototype.$delStorageSync = delStorageSync;
Vue.prototype.$copyH5 = copyH5;
Vue.prototype.$userName = 'sys_gzh';
Vue.prototype.$getLocationValue = getLocationValue;
// #endif
// Local环境
// Vue.prototype.$baseURL = 'https://192.168.2.5:8081/xcrm-api/'
// Vue.prototype.$baseURLH5 = 'https://192.168.2.5:8081/aifengleh5/'
// Vue.prototype.$wsBaseURL = 'wss://192.168.2.5:8081/xcrm-api'
// Vue.prototype.$picUrl = 'https://dev-crm-kpl.kerryonvip.com/upload/'

// DEV环境 DEV_28ae
// Vue.prototype.$baseURL = 'https://dev-crm-kpl.kerryonvip.com/xcrm-api/'
// Vue.prototype.$baseURLH5 = 'https://dev-crm-kpl.kerryonvip.com/aifengleh5/'
// Vue.prototype.$wsBaseURL = 'wss://dev-crm-kpl.kerryonvip.com/xcrm-api'
// Vue.prototype.$picUrl = 'https://dev-crm-kpl.kerryonvip.com/upload/'
// Vue.prototype.$kipPaymentUrl = 'https://dev-payment.kerryonvip.com/'
// Vue.prototype.$kipAppId = 'wx92c3e55fbef6b2af'
// Vue.prototype.$kipAppPath = '/pages/tabbar/home/home'

// QA环境 QA_a4d6
// Vue.prototype.$baseURL = 'https://qa-crm-kpl.kerryprops.com.cn/xcrm-api/'
// Vue.prototype.$baseURLH5 = 'https://qa-crm-kpl.kerryprops.com.cn/aifengleh5/'
// Vue.prototype.$wsBaseURL = 'wss://qa-crm-kpl.kerryprops.com.cn/xcrm-api'
// Vue.prototype.$picUrl = 'https://cnsh-kerry-crm-le.oss-cn-shanghai.aliyuncs.com'
// Vue.prototype.$kipPaymentUrl = 'https://qa-payment.kerryplus.com'
// Vue.prototype.$kipAppId = 'wx92c3e55fbef6b2af'
// Vue.prototype.$kipAppPath = '/pages/tabbar/home/home'

// PROD环境
// Vue.prototype.$baseURL = 'https://crm.kerryplus.com/xcrm-api/'
// Vue.prototype.$baseURLH5 = 'https://crm.kerryplus.com/aifengleh5/'
// Vue.prototype.$wsBaseURL = 'wss://crm.kerryplus.com/xcrm-api'
// Vue.prototype.$picUrl = 'https://cnsh-kerry-crm-prod.oss-cn-shanghai.aliyuncs.com'
// Vue.prototype.$kipPaymentUrl = 'https://apim.kerryplus.com/c/api/payment/v1/'
// Vue.prototype.$kipAppId = 'wx92c3e55fbef6b2af'
// Vue.prototype.$kipAppPath = '/pages/tabbar/home/home'

const curEnvConst = CacheTool.getCurEnvConst();
// console.log(8989, curEnvConst.KIP_PAYMENT_URL)
Vue.prototype.$baseURL = curEnvConst.BASE_URL;
Vue.prototype.$baseURLH5 = curEnvConst.BASE_URL_H5;
Vue.prototype.$wsBaseURL = curEnvConst.WS_BASE_URL;
Vue.prototype.$picUrl = curEnvConst.PIC_URL;
Vue.prototype.$kipPaymentUrl = curEnvConst.KIP_PAYMENT_URL;
Vue.prototype.$kipAppId = curEnvConst.KIP_APPID;
Vue.prototype.$kipAppPath = KIP_APP_PATH;
Vue.prototype.$etcpAppId = curEnvConst.ETCP_APPID;
Vue.prototype.$etcpAppPath = ETCP_APP_PATH;
Vue.prototype.$etcpAppInvoicePath = ETCP_APP_INVOICE_PATH;

// 静态图片前缀(不用改)
Vue.prototype.$staticPicUrl =
  'https://hafeng-admin.oss-cn-beijing.aliyuncs.com';
