main.js 2.1 KB

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