main.js 3.2 KB

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