main.js 2.8 KB

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