import Vue from 'vue'
import App from './App'


// OSS静态资源
Vue.prototype.$iImgUrl = 'https://szcf.superbest.wang/xcxImages/'


//http请求
import http from '@/common/js/http.js'
Vue.prototype.$http = http


// 时间处理模块
import dayjs from 'dayjs'
Vue.prototype.$day = dayjs


// OSS静态资源
Vue.prototype.$ImgUrl = 'https://xiaopay2020.oss-cn-shenzhen.aliyuncs.com/static/weapp/';


// #ifdef H5
import Vant from 'vant';
Vue.use(Vant);

let ua = navigator.userAgent.toLocaleString();
if (ua.match("/MicroMessenger/i") == "micromessenger") {
	console.log("微信浏览器环境");
	Vue.prototype.env = "wx"
} else {
	console.log("普通览器环境");
	Vue.prototype.env = "h5"
}

// JSSDK授权
async function JssdkAuth() {
	try {
		let [err, res] = await uni.request({
			url: "https://pay.xiaopay.net/mp_wechat/svmpwechat/GetWechatJSSDKConfig",
			method: "POST",
			data: {
				"mp_session_id": uni.getStorageSync("personalInfo").seesionID,
				"url": encodeURIComponent(window.location.href.split("#")[0]),
			}
		})
		console.log(err, res);
	} catch (e) {
		//TODO handle the exception
		//TODO handle the exception
		console.log(e);
		uni.showToast({
			icon: "none",
			mask: true,
			title: e.message
		})
	}
}
// WeixinJSBridge内置对象在其他浏览器中无效。
setTimeout(function() {
	if (typeof WeixinJSBridge == "undefined") {
		if (document.addEventListener) {
			Vue.prototype.JSBridge = false
		} else if (document.attachEvent) {
			Vue.prototype.JSBridge = false
		}
	} else {
		Vue.prototype.JSBridge = true
	}
}, 1000)



// echarts图标
var echarts = require('echarts')
Vue.prototype.$echarts = echarts
// console.log(echarts);

// 微信JSSDK
// import jweixin from 'jweixin-module'
// Vue.prototype.$jweixin = jweixin
// console.log(jweixin);
import VConsole from 'vconsole';
// const vConsole = new VConsole();

//加载es5>>js
function loadJs(path, callback) {
	let secScript = document.createElement("script");
	secScript.setAttribute("src", path);
	secScript.setAttribute("async", "async");
	document.body.insertBefore(secScript, document.body.lastChild);
	secScript.onload = callback;
	if (secScript.readyState) {
		// IE
		secScript.onreadystatechange = function() {
			if (secScript.readyState === 'loaded' || secScript.readyState === 'complete') {
				secScript.onreadystatechange = null;
				callback();
			}
		};
	} else {
		//其他浏览器
		secScript.onload = callback;
	}
}
// //JQ
// loadJs("//s1.pstatp.com/cdn/expire-1-M/jquery/1.8.0/jquery-1.8.0.min.js")
// // 微信-WEUI框架
// loadJs("//res.wx.qq.com/open/libs/weuijs/1.2.1/weui.min.js")
// // 公众号js-sdk
// loadJs("//res.wx.qq.com/open/js/jweixin-1.6.0.js")
// // 二维码生成
// loadJs("//static.runoob.com/assets/qrcode/qrcode.min.js")

if (navigator.userAgent.indexOf('AliApp') > -1) {
	loadJs("https://appx/web-view.min.js")
}
// #endif

Vue.config.productionTip = false

App.mpType = 'app'

const app = new Vue({
	...App
})
app.$mount()