main.js 1.8 KB

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