main.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import Vue from 'vue'
  2. import store from './store'
  3. import App from './App'
  4. import * as Api from '@/common/config/caimeiApi.js'
  5. import * as Regs from '@/common/config/common.js'
  6. import validate from '@/common/utils/ys-validate.js'
  7. import Json from './json' //本地数据
  8. /**
  9. * 示例使用了uni.scss下的变量, 除变量外已尽量移除特有语法,可直接替换为其他预处理器使用
  10. */
  11. const msg = (title, duration=1500, mask=true, icon='none')=>{
  12. //统一提示方便全局修改
  13. if(Boolean(title) === false){return;}
  14. uni.showToast({
  15. title,
  16. duration,
  17. mask,
  18. icon
  19. });
  20. }
  21. const modal = (title,content,confirmText,cancelText,showCancel=false,callBack) =>{
  22. uni.showModal({
  23. title,
  24. content,
  25. confirmText,
  26. cancelText,
  27. confirmColor:'#E15616',
  28. showCancel,
  29. success: function (res) {
  30. if (res.confirm) {
  31. callBack()
  32. }
  33. }
  34. });
  35. }
  36. const json = type=>{
  37. //模拟异步请求数据
  38. return new Promise(resolve=>{
  39. setTimeout(()=>{
  40. // console.log(resolve+'======='+type);
  41. resolve(Json[type]);
  42. }, 500)
  43. })
  44. }
  45. const prePage = ()=>{
  46. let pages = getCurrentPages();
  47. let prePage = pages[pages.length - 2];
  48. // #ifdef H5
  49. return prePage;
  50. // #endif
  51. return prePage.$vm;
  52. }
  53. Vue.config.productionTip = false
  54. Vue.prototype.$fire = new Vue();
  55. Vue.prototype.$store = store;
  56. Vue.prototype.$util = {msg, json, prePage,modal};
  57. Vue.prototype.$api = Api;
  58. Vue.prototype.$reg = Regs;
  59. Vue.prototype.$validate = validate;
  60. App.mpType = 'app'
  61. const app = new Vue({
  62. ...App
  63. })
  64. app.$mount()