import GoEasy from './lib/goeasy-2.6.1.esm.min.js';
import App from './App'
import fui from './common/fui-app'
import http from './components/firstui/fui-request'
import store from './store'
import Config from './static/js/config.js'
import Common from './static/js/common.js'
// import {request} from 'utils/request.js'
import uView from 'uview-ui'
Vue.use(uView)
import vueSignature from "vue-signature"
Vue.use(vueSignature)
// 全局前置守卫
// 如此配置即可
uni.$u.config.unit = 'rpx'
// Vue.prototype.request = request;
Vue.prototype.$Common = Common
Vue.prototype.$Config = Config
const goEasy = GoEasy.getInstance({
host:"hangzhou.goeasy.io",//应用所在的区域地址: 【hangzhou.goeasy.io |singapore.goeasy.io】
appkey:"BC-08a8e79aad95409a83b281f6bae92ae6",// common key
// true表示支持通知栏提醒,false则表示不需要通知栏提醒
allowNotification:true, //仅有效于app,小程序和H5将会被自动忽略
modules: ['pubsub'],
});
//初始化请求配置项
http.create({
host: 'http://124.223.159.211:4113/app/v1',
header: {
// 'content-type': 'application/x-www-form-urlencoded'
}
})
//请求拦截
http.interceptors.request.use(config => {
//请求之前可在请求头中加入token等信息
let token = uni.getStorageSync('token');
if (config.header) {
config.header['Authorization'] = token
} else {
config.header = {
'Authorization': token
}
}
return config
})
// 响应拦截
http.interceptors.response.use(response => {
//TODO
return response
})
Vue.prototype.goEasy = goEasy;
// 新的工单
Vue.prototype.ScanAudio = function() {
var music = null;
music = uni.createInnerAudioContext(); //创建播放器对象
music.src = "https://cdn.fsbhgg.com/video/newproduct.mp3";
music.play(); //执行播放
music.onEnded(() => {
//播放结束
music = null;
});
}
// 新的通知
Vue.prototype.ScanAudioMessage = function() {
var music = null;
music = uni.createInnerAudioContext(); //创建播放器对象
music.src = "https://cdn.fsbhgg.com/static/shuidi.wav";
music.play(); //执行播放
music.onEnded(() => {
//播放结束
music = null;
});
}
// 新的通知
Vue.prototype.ScanAudioWX = function() {
var music = null;
music = uni.createInnerAudioContext(); //创建播放器对象
music.src = "https://cdn.fsbhgg.com/static/wx.mp3";
music.play(); //执行播放
music.onEnded(() => {
//播放结束
music = null;
});
}
// 新的通知
Vue.prototype.ScanAudioQQ = function() {
var music = null;
music = uni.createInnerAudioContext(); //创建播放器对象
music.src = "https://cdn.fsbhgg.com/static/qq.wav";
music.play(); //执行播放
music.onEnded(() => {
//播放结束
music = null;
});
}
//格式化时间
Date.prototype.formatDate = function (fmt) {
var o = {
"M+": this.getMonth() + 1,
"d+": this.getDate(),
"h+": this.getHours(),
"m+": this.getMinutes(),
"s+": this.getSeconds(),
"q+": Math.floor((this.getMonth() + 3) / 3),
"S": this.getMilliseconds()
};
if (/(y+)/.test(fmt))
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if(o.hasOwnProperty(k)){
if (new RegExp("(" + k + ")").test(fmt))
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
}
return fmt;
};
/格式化颜色/
Vue.filter('formatColor', (time, data, type) => {
if (type == "时间进度" || type == "系数进度") {
return Config.COLOR[3];
} else {
if (Number(data) >= 100) {
return Config.COLOR[2];
} else if (Number(data) <= Number(time)) {
return Config.COLOR[0];
} else {
return Config.COLOR[1];
}
}
})
// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
Vue.prototype.$store = store
Vue.prototype.fui = fui
Vue.prototype.http = http
App.mpType = 'app'
const app = new Vue({
store,
...App
})
app.$mount()
// #endif
// #ifdef VUE3
import {
createSSRApp
} from 'vue';
/
在 Vue3 中,如果 nvue 使用了 Vuex 的相关 API,
需要在 main.js 的 createApp 的返回值中 return 一下 Vuex
/
import Vuex from "vuex";
export function createApp() {
const app = createSSRApp(App)
app.use(store)
app.config.globalProperties.fui = fui;
app.config.globalProperties.http = http;
return {
Vuex,
app
}
这是main.js代码
0 个回复