main.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import Vue from 'vue'
  2. import store from './store'
  3. import App from './App'
  4. import uView from 'uview-ui'
  5. // #ifdef H5
  6. import dsbridge from '@/static/js/dsbridge.js'
  7. import alipay from '@/static/js/alipay.js'
  8. // #endif
  9. Vue.use(uView)
  10. /**
  11. * 所有测试用数据均存放于根目录json.js
  12. *
  13. * css部分使用了App.vue下的全局样式和iconfont图标,有需要图标库的可以留言。
  14. * 示例使用了uni.scss下的变量, 除变量外已尽量移除特有语法,可直接替换为其他预处理器使用
  15. */
  16. const msg = (title, duration=1500, mask=false, icon='none')=>{
  17. //统一提示方便全局修改
  18. if(Boolean(title) === false){
  19. return;
  20. }
  21. uni.showToast({
  22. title,
  23. duration,
  24. mask,
  25. icon
  26. });
  27. }
  28. const prePage = ()=>{
  29. // 获取当前页面
  30. let pages = getCurrentPages();
  31. let prePage = pages[pages.length - 2];
  32. // #ifdef H5
  33. return prePage;
  34. // #endif
  35. return prePage.$vm;
  36. }
  37. Vue.config.productionTip = false
  38. Vue.prototype.$fire = new Vue();
  39. Vue.prototype.$store = store;
  40. Vue.prototype.$api = {msg, prePage};
  41. // #ifdef H5
  42. Vue.prototype.$dsbridge = dsbridge
  43. Vue.prototype.$alipay = alipay
  44. // #endif
  45. App.mpType = 'app'
  46. const app = new Vue({
  47. ...App
  48. })
  49. app.$mount()