main.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import Vue from 'vue'
  2. import App from './App'
  3. Vue.config.productionTip = false
  4. App.mpType = 'app'
  5. const app = new Vue({
  6. ...App
  7. })
  8. // 引入文件
  9. import Dever from './lib/dever'
  10. // 绑定全局的组件
  11. import ourLoading from '@/lib/our-loading/our-loading.vue'
  12. Vue.component('ourLoading', ourLoading)
  13. Vue.prototype.pageLoading = true;
  14. Vue.prototype.pageLoadingText = '加载中...';
  15. // 绑定到 Vue 的实例上
  16. Vue.prototype.Dever = Dever;
  17. // 载入全局配置 默认配置,防止第一次载入报错的,系统会自动从后台更新最新的配置
  18. var defaultConfig = {
  19. 'system_name' : '云境',
  20. 'system_info' : '云境',
  21. 'system_logo' : '../../static/logo.png',
  22. //自动更新时间间隔
  23. 'set_update' : 86400,
  24. //本次更新时间
  25. 'update_time' : false,
  26. };
  27. Vue.prototype.Dever.init('main/?l=api.config', Vue, defaultConfig);
  28. //自定义get的loading效果,设置全屏loading
  29. Vue.prototype.Dever.setGetLoading(function(self) {
  30. self.vue.prototype.pageLoading = true;
  31. }, function(self) {
  32. self.vue.prototype.pageLoading = false;
  33. self.btnFinish();
  34. });
  35. //自定义post的loading
  36. Vue.prototype.Dever.setPostLoading(function(self) {
  37. self.btnLoad();
  38. uni.showLoading({title: '加载中', mask: true});
  39. }, function(self) {
  40. self.btnFinish();
  41. uni.hideLoading();
  42. });
  43. //设置switchTab
  44. Vue.prototype.Dever.switchTab = ['index/index'];
  45. //自定义switchTab页面回调,因为switchTab执行后不会自动刷新页面,这里需要做个回调
  46. Vue.prototype.Dever.switchTabCall = {
  47. 'index/index' : function(self, e) {
  48. var page = self.getPage();
  49. if (!page) return;
  50. if ('getInfo' in page) {
  51. page.getInfo();
  52. }
  53. }
  54. };
  55. //载入一些通用的方法
  56. Vue.prototype.Dever.common({
  57. // 载入人工客服
  58. 'callPhone' : function() {
  59. uni.makePhoneCall({
  60. phoneNumber: Vue.prototype.$config.system_phone
  61. });
  62. },
  63. // 跳转到页面
  64. 'location' : function(e) {
  65. Vue.prototype.Dever.viewLocation(e);
  66. },
  67. // 提示
  68. 'alert' : function(e) {
  69. Vue.prototype.Dever.viewAlert(e);
  70. },
  71. })
  72. app.$mount()