main.js 1.4 KB

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