You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.1 KiB

6 months ago
  1. import Vue from 'vue'
  2. import App from './App'
  3. import * as $api from './common/api'
  4. import $util from './common/util'
  5. import hypIcon from './components/hyp-icon/hyp-icon'
  6. import hypImage from './components/hyp-image/hyp-image'
  7. Vue.prototype.$api = $api
  8. Vue.prototype.$util = $util
  9. import Json from './Json' //测试用数据
  10. Vue.component('hyp-icon', hypIcon)
  11. Vue.component('hyp-image', hypImage)
  12. //模拟接口,获取本地数据
  13. const msg = (title, duration=1500, mask=false, icon='none')=>{
  14. //统一提示方便全局修改
  15. if(Boolean(title) === false){
  16. return;
  17. }
  18. uni.showToast({
  19. title,
  20. duration,
  21. mask,
  22. icon
  23. });
  24. }
  25. const json = type=>{
  26. //模拟异步请求数据
  27. return new Promise(resolve=>{
  28. setTimeout(()=>{
  29. resolve(Json[type]);
  30. }, 500)
  31. })
  32. }
  33. const prePage = ()=>{
  34. let pages = getCurrentPages();
  35. let prePage = pages[pages.length - 2];
  36. // #ifdef H5
  37. return prePage;
  38. // #endif
  39. return prePage.$vm;
  40. }
  41. Vue.config.productionTip = false
  42. Vue.prototype.$testapi = {msg, json, prePage};
  43. App.mpType = 'app'
  44. const app = new Vue({
  45. ...App
  46. })
  47. app.$mount()