main.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import Vue from 'vue'
  2. import App from './App'
  3. import * as Api from './config/api.js'
  4. import * as Common from './config/common.js'
  5. import * as Db from './config/db.js'
  6. import * as Config from './config/config.js'
  7. import share from "@/common/share.js"
  8. import store from './store';
  9. import util from "@/common/util.js"
  10. const logic = {
  11. systemInfo: null,
  12. /**
  13. * 显示消息提示
  14. *
  15. * @param {Object} text
  16. * @param {Object} icon
  17. */
  18. showToast(text, icon) {
  19. return uni.showToast({
  20. title: text || '加载中',
  21. icon: icon || 'none',
  22. mask: true,
  23. duration: 2000
  24. });
  25. },
  26. /**
  27. * 全局方法 - px2rpx
  28. *
  29. * @param {Object} px
  30. */
  31. px2rpx(px) {
  32. if (this.systemInfo === null) {
  33. this.systemInfo = uni.getSystemInfoSync()
  34. }
  35. // 官方规定屏幕宽为750rpx
  36. return px / this.systemInfo.windowWidth * 750;
  37. },
  38. /**
  39. * 全局方法 - rpx2px
  40. *
  41. * @param {Object} rpx
  42. */
  43. rpx2px(rpx) {
  44. if (this.systemInfo === null) {
  45. this.systemInfo = uni.getSystemInfoSync()
  46. }
  47. // 官方规定屏幕宽为750rpx
  48. return rpx / 750 * this.systemInfo.windowWidth;
  49. },
  50. }
  51. // import {
  52. // createSSRApp
  53. // } from 'vue'
  54. // export function createApp() {
  55. // const app = createSSRApp(App)
  56. // app.use(store)
  57. // app.config.globalProperties.$logic = logic
  58. // return {
  59. // app
  60. // }
  61. // }
  62. function isPromise(obj) {
  63. return (!!obj &&
  64. (typeof obj === "object" || typeof obj === "function") &&
  65. typeof obj.then === "function"
  66. );
  67. }
  68. // uni方法转then数组
  69. uni.addInterceptor({
  70. returnValue(res) {
  71. if (!isPromise(res)) {
  72. return res;
  73. }
  74. const returnValue = [undefined, undefined];
  75. return res
  76. .then((res) => {
  77. returnValue[1] = res;
  78. })
  79. .catch((err) => {
  80. returnValue[0] = err;
  81. })
  82. .then(() => returnValue);
  83. },
  84. });
  85. import {tools} from '@/common/fa.mixin.js'
  86. Vue.mixin(tools)
  87. //皮肤色处理
  88. let styleMixin = require('@/common/fa.style.mixin.js')
  89. Vue.mixin(styleMixin)
  90. /*
  91. 有报错我先注释掉了
  92. 105行 还有config.js 5-7行
  93. Vue.component('cu-custom',cuCustom) */
  94. import uView from '@/uni_modules/uview-ui'
  95. Vue.use(uView)
  96. Vue.prototype.$api = Api;
  97. Vue.prototype.$common = Common;
  98. Vue.prototype.$db = Db;
  99. Vue.prototype.$config = Config;
  100. Vue.prototype.$logic=logic;
  101. Vue.prototype.$util=util;
  102. Vue.prototype.vuex_theme={value: {color: "#fff", bgColor: "#c7a772"}}
  103. Vue.prototype.vuex_parse_style={
  104. h1: 'padding:20rpx 0;',
  105. h2: 'padding:10rpx 0;',
  106. h3: 'padding:10rpx 0;',
  107. h4: 'padding:10rpx 0;',
  108. h5: 'padding:5rpx 0;',
  109. h6: 'padding:5rpx 0;',
  110. ul: 'margin-bottom:20rpx;padding-left:30rpx;',
  111. ol: 'margin-bottom:20rpx;padding-left:30rpx;',
  112. code: 'background-color: #f6f6f6;margin: 0 5rpx;padding: 6rpx 8rpx;border-radius: 6rpx;text-align:center;',
  113. pre: 'white-space: pre;overflow: auto;background: #f6f6f6;border-radius: 8rpx;border: none;color: #1a1a1a;margin-bottom: 20rpx;padding:20rpx;',
  114. 'pre code': 'margin:0;padding:0;',
  115. blockquote: 'padding: 15rpx;margin:0 0 20rpx 0;border-radius: 6rpx;',
  116. p: 'margin-bottom:20rpx',
  117. table: 'width:100%;margin-bottom:20rpx;border-collapse: collapse;',
  118. th: 'background-color: whitesmoke;border: 1px solid #e6e6e6;padding:10rpx;',
  119. td: 'border: 1px solid #e6e6e6;padding:10rpx;'
  120. }
  121. Vue.prototype.vuex_config={}
  122. Vue.config.productionTip = false
  123. Vue.mixin(share)
  124. App.mpType = 'app'
  125. const app = new Vue({
  126. ...App,store
  127. })
  128. app.$mount()