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

import QQMapWX from 'static/qqmap-wx-jssdk.min.js'

import cuCustom from './colorui/components/cu-custom.vue'
import myIcon from '@/components/my-icon/my-icon.vue'
import encode from '@/utils/encode'
import global from '@/api/global.js'

// import home from '@/pages/components/home/home.vue'
// import user from '@/pages/components/user/user.vue'
// import stationList from '@/pages/components/station/stationList.vue'
// import orderList from '@/pages/components/order/orderList/orderList.vue'

import Empty from '@/components/Empty.vue'
import {share} from './mixins/index.js'
import oilSiteApi from '@/api/oil-site.js'
Vue.mixin(share)
// Vue.component('home', home)
// Vue.component('user', user)
Vue.component('my-icon', myIcon)
// Vue.component('station-list', stationList)
// Vue.component('order-list', orderList)
Vue.component('cu-custom',cuCustom)
Vue.component('my-empty',Empty)


Vue.prototype.moneyIntercept = function(value){
		if (value != 'xxx.x') {
			return String(value).split('.')[1]&&String(value).split('.')[1].length>2? Number(`${String(value).split('.')[0]}.${String(value).split('.')[1].substring(0,1)}${ Number(String(value).split('.')[1].substring(1,2)) + 1}`)  :Number(value).toFixed(2);
		} else {
			return Number(value).toFixed(2)
		}
}
Vue.prototype.SetFilterData =  function(value){
	 return new Promise((re,rj)=>{
		 let menuList = [{
		 					title: '渠道',
		 					isMutiple: false,
		 					key: 'channelCode',
		 					detailList: [{
		 						title: "全部",
		 						value: ""
		 					}]
		 				},
		 				{
		 					title: '0#轻柴油',
		 					key: 'oilProductCode',
		 					isMutiple: false,
		 					detailList: [{
		 						title: "全部",
		 						value: ""
		 					}]
		 				},
		 				{
		 					title: '品牌',
		 					key: 'siteBrand',
		 					isSort: true,
		 					isMutiple: false,
		 					detailList: [{
		 						title: "全部",
		 						value: ""
		 					}]
		 				}
		 			]
					if(uni.getStorageSync('filterData')){
						re('ok')
					}else{
						oilSiteApi.getCheckInfo().then(res => {
							if (res.code == 20000) {
								let channelCodes = []
								res.data.channelCodes.map(item => {
									channelCodes.push({
										title: item.name,
										value: item.id
									})
								})
								let productCodes = []
								res.data.productCodes.map(item => {
									productCodes.push({
										title: item.name,
										value: item.id
									})
								})
								let siteBrands = []
								res.data.siteBrands.map(item => {
									siteBrands.push({
										title: item.name,
										value: item.id
									})
								})
								console.log(channelCodes, productCodes, siteBrands)
								menuList[0].detailList = menuList[0].detailList.concat(channelCodes)
								menuList[1].detailList = menuList[1].detailList.concat(productCodes)
								menuList[2].detailList = menuList[2].detailList.concat(siteBrands)
								uni.setStorageSync('filterData', this.menuList);
								re('ok')
							}else{
								rj('no')
							}
						})
					}
					
	 })
}
let qqmapsdk = new QQMapWX({
	// key: 'IUKBZ-5MKL3-HXB3P-3OS7U-6MHX3-MYBI3'
	key:'NYEBZ-YURY3-XTU3N-YBR54-PKW6E-ROB2F'
})
Vue.prototype.$qqmapsdk = qqmapsdk


Vue.config.productionTip = false

App.mpType = 'app'
Vue.prototype.utils = encode
Vue.prototype.global = global

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