mali-applet-ui 0.0.53 → 0.0.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,31 +8,7 @@
8
8
  import XEUtils from 'xe-utils'
9
9
  import WxCanvas from './wx-canvas';
10
10
  import * as echarts from './echarts';
11
-
12
- function compareVersion(v1, v2) {
13
- v1 = v1.split('.')
14
- v2 = v2.split('.')
15
- const len = Math.max(v1.length, v2.length)
16
-
17
- while (v1.length < len) {
18
- v1.push('0')
19
- }
20
- while (v2.length < len) {
21
- v2.push('0')
22
- }
23
-
24
- for (let i = 0; i < len; i++) {
25
- const num1 = parseInt(v1[i])
26
- const num2 = parseInt(v2[i])
27
-
28
- if (num1 > num2) {
29
- return 1
30
- } else if (num1 < num2) {
31
- return -1
32
- }
33
- }
34
- return 0
35
- }
11
+ import globalStore from '../../config/store'
36
12
 
37
13
  export default {
38
14
  name: 'MlEcharts',
@@ -44,7 +20,6 @@ export default {
44
20
  height:String,
45
21
  width: String,
46
22
  lazyLoad:Boolean,
47
- forceUseOldCanvas: Boolean,
48
23
  className: String
49
24
  },
50
25
  data() {
@@ -87,7 +62,10 @@ export default {
87
62
  opts.legend.formatter = this.customFormat
88
63
  }
89
64
  }
90
- return opts
65
+ return {
66
+ color: globalStore.echarts.color,
67
+ ...opts
68
+ }
91
69
  },
92
70
  customFormat (name) {
93
71
  return this.formatLegend(name, this.options || {})
@@ -111,17 +89,6 @@ export default {
111
89
  this.loadChart()
112
90
  },
113
91
  init: function() {
114
- const version = uni.getSystemInfoSync().SDKVersion
115
- const canUseNewCanvas = compareVersion(version, '2.9.0') >= 0;
116
- const forceUseOldCanvas = this.forceUseOldCanvas;
117
- const isUseNewCanvas = canUseNewCanvas && !forceUseOldCanvas;
118
- this.isUseNewCanvas = isUseNewCanvas
119
-
120
- if (forceUseOldCanvas && canUseNewCanvas) {
121
- console.warn('开发者强制使用旧canvas,建议关闭');
122
- }
123
-
124
- // version >= 2.9.0:使用新的方式初始化
125
92
  const query = uni.createSelectorQuery().in(this)
126
93
  query
127
94
  .in(this)
package/config/store.js CHANGED
@@ -27,6 +27,10 @@ const globalStore = {
27
27
  record: {
28
28
  optionMethod: null
29
29
  }
30
+ },
31
+ // 图表
32
+ echarts: {
33
+ color: ['#582D27', '#391085', '#13c2c2', '#04395E', '#5E503F', '#7C98B3', '#69C6DB', '#A98467', '#b37feb']
30
34
  }
31
35
  }
32
36
 
package/index.js CHANGED
@@ -1,13 +1,19 @@
1
1
  import config from './config'
2
+ import MaliToast from './toast'
3
+ import MaliLoading from './loading'
2
4
  import * as MaliUtils from './utils'
3
5
 
4
6
  const MaliUI = {
5
7
  config,
6
- MaliUtils
8
+ MaliUtils,
9
+ MaliToast,
10
+ MaliLoading
7
11
  }
8
12
 
9
13
  export {
10
- MaliUtils
14
+ MaliUtils,
15
+ MaliToast,
16
+ MaliLoading
11
17
  }
12
18
 
13
19
  export default MaliUI
@@ -0,0 +1,19 @@
1
+ const MaliLoading = {
2
+ show (option = {}) {
3
+ return new Promise(resolve => {
4
+ uni.showLoading({
5
+ title: option.content || '加载中',
6
+ success: resolve
7
+ })
8
+ })
9
+ },
10
+ hide () {
11
+ return new Promise(resolve => {
12
+ uni.hideLoading({
13
+ success: resolve
14
+ })
15
+ })
16
+ }
17
+ }
18
+
19
+ export default MaliLoading
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "0.0.53",
3
+ "version": "0.0.54",
4
4
  "description": "码里云小程序组件库",
5
5
  "files": [
6
6
  "components",
7
7
  "config",
8
8
  "utils",
9
+ "loading",
10
+ "toast",
9
11
  "iconfont.css",
10
12
  "index.js",
11
13
  "index.scss"
package/toast/index.js ADDED
@@ -0,0 +1,29 @@
1
+ const MaliToast = {
2
+ success (option = {}) {
3
+ return new Promise(resolve => {
4
+ uni.showToast({
5
+ title: option.content || '操作成功',
6
+ icon: 'success',
7
+ success: resolve
8
+ })
9
+ })
10
+ },
11
+ error (option = {}) {
12
+ return new Promise(resolve => {
13
+ uni.showToast({
14
+ title: option.content || '操作失败',
15
+ icon: 'error',
16
+ success: resolve
17
+ })
18
+ })
19
+ },
20
+ hide () {
21
+ return new Promise(resolve => {
22
+ uni.hideToast({
23
+ success: resolve
24
+ })
25
+ })
26
+ }
27
+ }
28
+
29
+ export default MaliToast