Blame view

lvdao-miniapp/uni_modules/wu-ui-tools/index.js 1.83 KB
0fd8b750   杨鑫   '最新落地1'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
  // 全局挂载引入http相关请求拦截插件
  import Request from './libs/luch-request'
  
  // 引入全局mixin
  import mixin from './libs/mixin/mixin.js'
  // 小程序特有的mixin
  import mpMixin from './libs/mixin/mpMixin.js'
  // #ifdef MP
  import mpShare from './libs/mixin/mpShare.js'
  // #endif
  
  // 路由封装
  import route from './libs/util/route.js'
  // 公共工具函数
  import * as index from './libs/function/index.js'
  // 防抖方法
  import debounce from './libs/function/debounce.js'
  // 节流方法
  import throttle from './libs/function/throttle.js'
  // 规则检验
  import * as test from './libs/function/test.js'
  
  // 配置信息
  import config from './libs/config/config.js'
  // 平台
  import platform from './libs/function/platform'
  
  import Color from './libs/function/color/index.js'
  
  const $w = {
  	...index,
  	route,
  	config,
  	test,
  	throttle,
  	date: index.timeFormat, // 另名date
  	Color,
  	http: new Request(),
  	debounce,
  	throttle,
  	platform,
  	mixin,
  	mpMixin
  }
  uni.$w = $w;
  const install = (Vue,options={}) => {
  		// #ifndef APP-NVUE
  		Vue.mixin(mixin);
  		// #ifdef MP
  		if(options.mpShare){
  			Vue.mixin(mpShare);
  		}
  		// #endif
  		// #endif
  		// #ifdef VUE2
  		// 时间格式化,同时两个名称,date和timeFormat
  		Vue.filter('timeFormat', (timestamp, format) => uni.$w.timeFormat(timestamp, format));
  		Vue.filter('date', (timestamp, format) => uni.$w.timeFormat(timestamp, format));
  		// 将多久以前的方法,注入到全局过滤器
  		Vue.filter('timeFrom', (timestamp, format) => uni.$w.timeFrom(timestamp, format));
  		// 同时挂载到uni和Vue.prototype中
  		// #ifndef APP-NVUE
  		// 只有vue,挂载到Vue.prototype才有意义,因为nvue中全局Vue.prototype和Vue.mixin是无效的
  		Vue.prototype.$w = $w;
  		// #endif
  		// #endif
  		// #ifdef VUE3
  		Vue.config.globalProperties.$w = $w;
  		// #endif
  }
  export default {
  	install
  }