main.js 2.2 KB

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