main.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import App from './App'
  2. import messages from './locale/index'
  3. import GoEasy from 'goeasy'
  4. // // 引入全局方法
  5. import baseUrl from '@/config/urlConfig.js';
  6. // // 挂载全局自定义方法
  7. Vue.prototype.$baseUrl = baseUrl;
  8. Vue.prototype.$formPr = function(price){
  9. var number = '0';
  10. var type = typeof(price);
  11. if(type=='string'){
  12. number = price
  13. }
  14. if(type=='number'){
  15. number = price.toString(); // 确保输入是字符串
  16. }
  17. const pattern = /(-?\d+)(\d{3})/;
  18. while (pattern.test(number)) {
  19. number = number.replace(pattern, "$1,$2");
  20. }
  21. return number;
  22. if(price%1000==0){
  23. return price;//price/1000+'k'
  24. }
  25. else{
  26. return price;
  27. }
  28. };
  29. const goEasy = GoEasy.getInstance({
  30. host:"singapore.goeasy.io", //若是新加坡区域:singapore.goeasy.io
  31. appkey:"BC-118535b236de4c83a1ad0341830d1c04",
  32. modules:['im','pubsub'],//根据需要,传入'im’或'pubusub',或数组方式同时传入
  33. allowNotification: true, // true表示支持通知栏提醒,false则表示不需要通知栏提醒
  34. });
  35. goEasy.onClickNotification((message) => {
  36. let currentUrl;
  37. return;
  38. /*
  39. const routes = getCurrentPages();
  40. if (routes && routes.length) {
  41. const curRoute = routes[routes.length - 1].route;
  42. const curParam = routes[routes.length - 1].options;
  43. currentUrl = '/' + curRoute + `?to=${curParam.to}`;
  44. }
  45. let newUrl;
  46. switch (message.toType) {
  47. case GoEasy.IM_SCENE.PRIVATE:
  48. //newUrl = '/pages/privateChat?to=' + message.senderId;
  49. break;
  50. case GoEasy.IM_SCENE.GROUP:
  51. newUrl = '/pages/groupChat?to=' + message.groupId;
  52. break;
  53. }
  54. if (currentUrl !== newUrl) {
  55. uni.navigateTo({
  56. url: newUrl,
  57. });
  58. }
  59. */
  60. });
  61. Vue.prototype.GoEasy = GoEasy;
  62. Vue.prototype.goEasy = goEasy;
  63. let i18nConfig = {
  64. locale: uni.getLocale(),
  65. messages
  66. }
  67. // #ifndef VUE3
  68. import Vue from 'vue'
  69. import VueI18n from 'vue-i18n'
  70. // import uView from "uview-ui";
  71. // Vue.use(uView);
  72. Vue.use(VueI18n)
  73. const i18n = new VueI18n(i18nConfig)
  74. Vue.config.productionTip = false
  75. App.mpType = 'app'
  76. const app = new Vue({
  77. i18n,
  78. ...App
  79. })
  80. app.$mount()
  81. // #endif
  82. // #ifdef VUE3
  83. import { createSSRApp } from 'vue'
  84. import { createI18n } from 'vue-i18n'
  85. const i18n = createI18n(i18nConfig)
  86. export function createApp() {
  87. const app = createSSRApp(App)
  88. app.use(i18n)
  89. return {
  90. app
  91. }
  92. }
  93. // #endif