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