import App from './App'
import Vue from 'vue'
import getOpenId from './apis/utils/init.js'
import getALIOpenId from './apis/utils/initALI.js'
//import './assets/font/font/font.css'
var IS_WEIXIN = /MicroMessenger/.test(window.navigator.userAgent)
var IS_ALI = /AlipayClient/.test(window.navigator.userAgent)

if (IS_ALI) {

	getALIOpenId.init()
} else {
	getOpenId.init()
}

import mixin from './apis/utils/mixin.js'
 
Vue.prototype.carhelp = mixin
 window.wx = {}
 import Vconsole from 'vconsole'
//import uView from "uview-ui";
import uView from '@/uni_modules/uview-ui'
import router from '@/components/bobo-router'

Vue.use(uView);


Vue.mixin({
	
	updated: function() {
		
	},
	onReady() {


	},
	onLoad(option) {
		if (option.test == 'test') {
			let vConsole = new Vconsole()
		}
		
		var ProjectName=process.car.ProjectName;
		if(process.car.NODE_ENV=='dev'||process.car.NODE_ENV=='test'){
			  ProjectName+='('+process.car.NODE_ENV+')';				 
		}
		uni.setNavigationBarTitle({
		   		title:ProjectName
		}) 
		
		this.personInfo=this.carhelp.getPersonInfo();
		

	},
	methods: {
		replaceLastTwoWords(str) {
		
		  
		
		
		    return str;  
		
		},
		 replaceLastTwoWords2(str) {  
		
		  
		
		    if (str.length >= 2 && str.indexOf('总表') !=-1) {  
		
		
		        return str.replace('总表', '总电源');  
		
		    }  
			if (str.length >= 2 && str.indexOf('电表') !=-1) {  
					
					
			  return str.replace('电表', '电源');  
					
			}  
		
		
		    return str;  
		
		},
		jpAmount(amount){
			if(amount){
				return amount.toFixed(2)
			}else{
				return "0.00"
			}
		},
		substrDate(date){
			if(date){
				return date.substr(0,11)
			}
			return ''
		},
		
		gotoUrl(url) {
			
			var mod =  {}
			mod.clickUrl = url
			
			 if (mod.clickUrl == null) {
			
			} else if (mod.clickUrl.indexOf('http') == 0) {
			
				window.location = mod.clickUrl  ;
			}  else if (mod.clickUrl.indexOf('#/') == 0) {
				if (mod.clickUrl.indexOf("?") == -1) {
					mod.clickUrl += '?';
				}
				var url = mod.clickUrl.split("#")[1]
				//window.location = mod.clickUrl;
				uni.navigateTo({
					url: url 
				})
			} else if (mod.clickUrl == '#' || mod.clickUrl == '') {
			
			} else {
				uni.navigateTo({
					url: mod.clickUrl 
				})
			}
		}
	}
})


Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
	...App
})
app.$mount()
