main.js 3.2 KB

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