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 validate from '@/common/utils/ys-validate.js'
  7. import Json from './json' //本地数据
  8. const userOrganizeID = 2 //组织ID
  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,showCancel=false,callBack) =>{
  23. uni.showModal({
  24. title,
  25. content,
  26. showCancel,
  27. success: function (res) {
  28. if (res.confirm) {
  29. callBack()
  30. }
  31. }
  32. });
  33. }
  34. const json = type=>{
  35. //模拟异步请求数据
  36. return new Promise(resolve=>{
  37. setTimeout(()=>{
  38. // console.log(resolve+'======='+type);
  39. resolve(Json[type]);
  40. }, 500)
  41. })
  42. }
  43. const prePage = ()=>{
  44. let pages = getCurrentPages();
  45. let prePage = pages[pages.length - 2];
  46. // #ifdef H5
  47. return prePage;
  48. // #endif
  49. return prePage.$vm;
  50. }
  51. Vue.config.productionTip = false
  52. Vue.prototype.$fire = new Vue();
  53. Vue.prototype.$store = store;
  54. Vue.prototype.$util = {msg, json, prePage,modal};
  55. Vue.prototype.userOrganizeID = userOrganizeID;
  56. Vue.prototype.$api = Api;
  57. Vue.prototype.$reg = Regs;
  58. Vue.prototype.$validate = validate;
  59. App.mpType = 'app'
  60. const app = new Vue({
  61. ...App
  62. })
  63. app.$mount()