main.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import App from './App'
  2. import messages from './locale/index'
  3. // 引入全局方法
  4. import {http} from '@/utils/request';
  5. import mytool from '@/utils/tool';
  6. // 挂载全局自定义方法
  7. Vue.prototype.$http = http;
  8. Vue.prototype.$mytool = mytool;
  9. Vue.prototype.$baseImagurl = 'https://backend.awayqtw.com/prod-api';//生产环境
  10. Vue.prototype.$upImagurl = 'http://108.61.127.24:8080';//生产环境
  11. //Vue.prototype.$baseImagurl = ' http://192.168.1.242:8080';//调试环境
  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. }
  29. else{
  30. return price;
  31. }
  32. };
  33. let i18nConfig = {
  34. locale: uni.getLocale(),
  35. messages
  36. }
  37. // #ifndef VUE3
  38. import Vue from 'vue'
  39. import VueI18n from 'vue-i18n'
  40. Vue.use(VueI18n)
  41. const i18n = new VueI18n(i18nConfig)
  42. Vue.config.productionTip = false
  43. App.mpType = 'app'
  44. const app = new Vue({
  45. i18n,
  46. ...App
  47. })
  48. app.$mount()
  49. // #endif
  50. // #ifdef VUE3
  51. import { createSSRApp } from 'vue'
  52. import { createI18n } from 'vue-i18n'
  53. const i18n = createI18n(i18nConfig)
  54. export function createApp() {
  55. const app = createSSRApp(App)
  56. app.use(i18n)
  57. return {
  58. app
  59. }
  60. }
  61. // #endif