import App from './App' import messages from './locale/index' import GoEasy from 'goeasy' // 引入全局方法 import {http} from '@/utils/request'; import mytool from '@/utils/tool'; // 挂载全局自定义方法 Vue.prototype.$http = http; Vue.prototype.$mytool = mytool; Vue.prototype.$baseurl = 'https://api.awayqtw.com';//生产环境 const goEasy = GoEasy.getInstance({ host:"singapore.goeasy.io", //若是新加坡区域:singapore.goeasy.io appkey:"BC-118535b236de4c83a1ad0341830d1c04", modules:['im','pubsub'],//根据需要,传入'im’或'pubusub',或数组方式同时传入 allowNotification: false, // true表示支持通知栏提醒,false则表示不需要通知栏提醒 }); // goEasy.im.on(GoEasy.IM_EVENT.CONVERSATIONS_UPDATED, setUnreadNumber); // function setUnreadNumber (content) { // let unreadTotal = content.unreadTotal; // if(unreadTotal > 0) { // uni.setTabBarBadge({ // index: 0, // text: unreadTotal.toString() // }); // }else{ // uni.removeTabBarBadge({index: 0}); // } // // #ifdef APP-PLUS // goEasy.setBadge({ // badge: unreadTotal, // onSuccess: function () { // console.log("setBadge successfully.") // }, // onFailed: function (error) { // console.log("Failed to setBadge,error:" + error); // } // }); // // #endif // } goEasy.onClickNotification((message) => { // let currentUrl; // const routes = getCurrentPages(); // if (routes && routes.length) { // const curRoute = routes[routes.length - 1].route; // const curParam = routes[routes.length - 1].options; // currentUrl = '/' + curRoute + `?to=${curParam.to}`; // } // let newUrl; // switch (message.toType) { // case GoEasy.IM_SCENE.PRIVATE: // newUrl = '/pages/privateChat?to=' + message.senderId; // break; // case GoEasy.IM_SCENE.GROUP: // newUrl = '/pages/groupChat?to=' + message.groupId; // break; // } // if (currentUrl !== newUrl) { // uni.navigateTo({ // url: newUrl, // }); // } }); Vue.prototype.GoEasy = GoEasy; Vue.prototype.goEasy = goEasy; Vue.prototype.$formPr = function(price){ var number = '0'; var type = typeof(price); if(type=='string'){ number = price } if(type=='number'){ number = price.toString(); // 确保输入是字符串 } const pattern = /(-?\d+)(\d{3})/; while (pattern.test(number)) { number = number.replace(pattern, "$1,$2"); } return number; if(price%1000==0){ return price;//price/1000+'k' } else{ return price; } }; let i18nConfig = { locale: uni.getLocale(), messages } // #ifndef VUE3 import Vue from 'vue' import VueI18n from 'vue-i18n' Vue.use(VueI18n) const i18n = new VueI18n(i18nConfig) Vue.config.productionTip = false App.mpType = 'app' const app = new Vue({ i18n, ...App }) app.$mount() // #endif // #ifdef VUE3 import { createSSRApp } from 'vue' import { createI18n } from 'vue-i18n' const i18n = createI18n(i18nConfig) export function createApp() { const app = createSSRApp(App) app.use(i18n) return { app } } // #endif