main.js 1.5 KB

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