FenXiNspUniapp/main.js

118 lines
2.8 KiB
JavaScript

import Vue from 'vue'
import App from './App'
import store from './store'
import MinCache from'./common/util/MinCache.js'
import tip from'./common/util/tip.js'
import configService from'./common/service/config.service.js'
import router from './common/router'
import {RouterMount} from './plugin/uni-simple-router/index.js'
//引入mescroll插件
// import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue"
// import MescrollUni from "@/components/mescroll-uni/mescroll-uni.vue"
// Vue.component('mescroll-body', MescrollBody);
// Vue.component('mescroll-uni', MescrollUni);
// 注册缓存器
Vue.use(MinCache,{timeout: 6})
// store
Vue.prototype.$store=store;
// tip
Vue.prototype.$tip=tip;
// config
Vue.prototype.$config=configService;
// request请求
import { http } from '@/common/service/service.js'
Vue.prototype.$http = http
Vue.prototype.cutMoneyFiter = (amount) => {
if(!amount) {
return "0"
}
//强制保留两位小数
let f = parseFloat(amount);
if (isNaN(f)) return false;
f = Math.round(amount * 100) / 100;
let s = f.toString();
// let rs = s.indexOf('.');
// if (rs < 0) {
// rs = s.length;
// s += '.';
// }
// while (s.length < (rs + 1) + 2) {
// s += '0';
// }
//每三位用一个逗号隔开
let leftNum=s.split(".")[0];
let rightNum="."+s.split(".")[1];
let result;
//定义数组记录截取后的价格
let resultArray=new Array();
if(leftNum.length>3){
let i=true;
while (i){
resultArray.push(leftNum.slice(-3));
leftNum=leftNum.slice(0,leftNum.length-3);
if(leftNum.length<4){
i=false;
}
}
//由于从后向前截取,所以从最后一个开始遍历并存到一个新的数组,顺序调换
let sortArray=new Array();
for(let i=resultArray.length-1;i>=0;i--){
sortArray.push(resultArray[i]);
}
// result=leftNum+","+sortArray.join(",")+rightNum;
result=leftNum+","+sortArray.join(",");
}else {
result=s;
}
return result;
}
// 自定义组件
// import mySelect from './components/my-componets/my-select.vue'
// Vue.component('mySelect',mySelect)
// import myImageUpload from './components/my-componets/my-image-upload.vue'
// Vue.component('myImageUpload',myImageUpload)
// import myPage from './components/my-componets/my-page.vue'
// Vue.component('myPage',myPage)
// import cuCustom from './plugin/colorui/components/cu-custom.vue'
// Vue.component('cu-custom',cuCustom)
// import VConsole from './js_sdk/vconsole.min'
// var vConsole = new VConsole();
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
store,
MinCache,
...App
})
//v1.3.5起 H5端 你应该去除原有的app.$mount();使用路由自带的渲染方式
// #ifdef H5
RouterMount(app,'#app');
// #endif
// #ifndef H5
app.$mount(); //为了兼容小程序及app端必须这样写才有效果
// #endif