main.js 1.3 KB

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