import Vue from 'vue'
import App from './App'
import store from './store/store'
import 'lodash'
import lang from '@/api/lang.js'

import mixinCheck from './mixins/mixin-check.js'
import * as types from 'store/mutations-types.js'

import DictTag from './components/Dicttag/DictTag.vue'
import { DICT_TYPE, getDictDatas2, getDictDatas } from "./util/dict";
import dayjs from 'dayjs'
import { getUserProfile } from './api/system'
import util from './util/util'
import i18n from './i18n'

uni._scanlistener_action = 'com.sunmi.scanner.ACTION_DATA_CODE_RECEIVED'
uni._scanlistener_label = 'data'

// 扫码成功提示音和失败提示音播放挂在到uni对象，方便调试
uni.ScanSuccess = function(){
	if(!uni.ScanSuccessAudio){
		uni.ScanSuccessAudio = uni.createInnerAudioContext()
		uni.ScanSuccessAudio.src = "../../static/mp3/success.mp3"
		uni.ScanSuccessAudio.onError((err)=>{
			console.log('ScanSuccessAudio err', err)
		})
	}
	uni.ScanSuccessAudio.play()
}
uni.ScanError = function(){
	if(!uni.ScanErrorAudio){
		uni.ScanErrorAudio = uni.createInnerAudioContext()
		uni.ScanErrorAudio.src = "../../static/mp3/error.mp3"
		uni.ScanErrorAudio.onError((err)=>{
			console.log('ScanErrorAudio err', err)
		})
	}
	uni.ScanErrorAudio.play()
}

Vue.component('DictTag', DictTag)

//所有页面都检查用户登录
Vue.mixin(mixinCheck)

Vue.prototype.dayjs = dayjs
Vue.prototype.DICT_TYPE = DICT_TYPE
Vue.prototype.getDictDatas2 = getDictDatas2
Vue.prototype.getDictDatas = getDictDatas
Vue.prototype.$util = util
Vue.prototype.$lang = lang
Vue.prototype._i18n = i18n
Vue.prototype.ScanSuccess = uni.ScanSuccess
Vue.prototype.ScanError = uni.ScanError
Vue.prototype.$platform =  uni.getSystemInfoSync().platform

//添加全局store类型
Vue.prototype.$TYPE = types

Vue.config.productionTip = false

App.mpType = 'app';

// console.log(process.env.NODE_ENV);
// window.localStorage.setItem('NODE_ENV', process.env.NODE_ENV)
uni.setStorageSync('NODE_ENV', process.env.NODE_ENV);

store.dispatch('dict/loadDictDatas')
getUserProfile()
const app = new Vue({
  store,
  i18n,
  ...App
})
app.$mount()
