mali-applet-ui 1.1.70 → 1.1.72
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.
- package/index.js +3 -0
- package/lib/components/ml-countdown/ml-countdown.vue +130 -0
- package/lib/components/ml-list-item/ml-list-item.vue +1 -1
- package/lib/components/ml-list-item-describe/ml-list-item-describe.vue +1 -1
- package/lib/components/ml-tag/ml-tag.vue +1 -1
- package/package.json +2 -1
- package/types/index.d.ts +15 -1
- package/types/webview/index.d.ts +7 -0
- package/webview/index.js +35 -0
package/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import MaliToast from './modal/toast'
|
|
|
3
3
|
import MaliModal from './modal/modal'
|
|
4
4
|
import MaliLoading from './modal/loading'
|
|
5
5
|
import MaliStorage from './storage'
|
|
6
|
+
import MaliWebview from './webview'
|
|
6
7
|
import MaliI18n from './i18n/i18n'
|
|
7
8
|
import MaliUtils from './utils'
|
|
8
9
|
|
|
@@ -18,6 +19,7 @@ const MaliUI = {
|
|
|
18
19
|
MaliModal,
|
|
19
20
|
MaliLoading,
|
|
20
21
|
MaliStorage,
|
|
22
|
+
MaliWebview,
|
|
21
23
|
MaliI18n
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -27,6 +29,7 @@ export {
|
|
|
27
29
|
MaliModal,
|
|
28
30
|
MaliLoading,
|
|
29
31
|
MaliStorage,
|
|
32
|
+
MaliWebview,
|
|
30
33
|
MaliI18n
|
|
31
34
|
}
|
|
32
35
|
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="ml-countdown">
|
|
3
|
+
<slot name="prefix">
|
|
4
|
+
<view v-if="prefixText" class="ml-countdown-prefix">{{ prefixText || '' }}</view>
|
|
5
|
+
</slot>
|
|
6
|
+
<slot :secondVals="secondVals" :currVals="currVals" :timeDiffObj="timeDiffObj" :timeFormats="timeFormats" :timeLabels="timeLabels">
|
|
7
|
+
<view class="ml-countdown-item" :class="[`time-${type}`]" v-for="(type) in timeFormats" :key="type">
|
|
8
|
+
<text class="ml-countdown-time-num">{{ timeDiffObj[type] || 0 }}</text>
|
|
9
|
+
<text class="ml-countdown-time-label">{{ timeLabels[type] || '' }}</text>
|
|
10
|
+
</view>
|
|
11
|
+
</slot>
|
|
12
|
+
<slot name="suffix">
|
|
13
|
+
<view v-if="suffixText" class="ml-countdown-suffix">{{ suffixText || '' }}</view>
|
|
14
|
+
</slot>
|
|
15
|
+
</view>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script>
|
|
19
|
+
import XEUtils from 'xe-utils'
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
name: 'MlCountdown',
|
|
23
|
+
props: {
|
|
24
|
+
value: [Number, String],
|
|
25
|
+
formats: Array,
|
|
26
|
+
prefixText: String,
|
|
27
|
+
suffixText: String
|
|
28
|
+
},
|
|
29
|
+
data () {
|
|
30
|
+
return {
|
|
31
|
+
secondVals: 0,
|
|
32
|
+
currVals: 0,
|
|
33
|
+
timeLabels: {
|
|
34
|
+
yyyy: '年',
|
|
35
|
+
MM: '月',
|
|
36
|
+
dd: '天',
|
|
37
|
+
HH: '时',
|
|
38
|
+
mm: '分',
|
|
39
|
+
ss: '秒'
|
|
40
|
+
},
|
|
41
|
+
htime: null
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
computed: {
|
|
45
|
+
timeDiffObj () {
|
|
46
|
+
return XEUtils.getDateDiff(Date.now(), Date.now() + this.currVals)
|
|
47
|
+
},
|
|
48
|
+
timeFormats () {
|
|
49
|
+
if (this.formats && this.formats.length) {
|
|
50
|
+
return this.formats
|
|
51
|
+
}
|
|
52
|
+
if (this.secondVals >= 31622400000) {
|
|
53
|
+
return ['yyyy', 'MM', 'dd', 'HH', 'mm', 'ss']
|
|
54
|
+
}
|
|
55
|
+
if (this.secondVals >= 2678400000) {
|
|
56
|
+
return ['MM', 'dd', 'HH', 'mm', 'ss']
|
|
57
|
+
}
|
|
58
|
+
if (this.secondVals >= 86400000) {
|
|
59
|
+
return ['dd', 'HH', 'mm', 'ss']
|
|
60
|
+
}
|
|
61
|
+
return ['HH', 'mm', 'ss']
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
watch: {
|
|
65
|
+
value () {
|
|
66
|
+
this.updateVal()
|
|
67
|
+
this.stop()
|
|
68
|
+
this.start()
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
created () {
|
|
72
|
+
this.updateVal()
|
|
73
|
+
this.start()
|
|
74
|
+
},
|
|
75
|
+
beforeDestroy () {
|
|
76
|
+
this.stop()
|
|
77
|
+
},
|
|
78
|
+
methods: {
|
|
79
|
+
updateVal () {
|
|
80
|
+
this.secondVals = XEUtils.toNumber(this.value || 0)
|
|
81
|
+
this.currVals = this.secondVals
|
|
82
|
+
},
|
|
83
|
+
handleTime () {
|
|
84
|
+
if (this.currVals > 1000) {
|
|
85
|
+
this.currVals -= 1000
|
|
86
|
+
this.htime = setTimeout(this.handleTime, 1000)
|
|
87
|
+
} else {
|
|
88
|
+
this.currVals = 0
|
|
89
|
+
this.stop()
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
start () {
|
|
93
|
+
this.$emit('start', {})
|
|
94
|
+
this.handleTime()
|
|
95
|
+
},
|
|
96
|
+
stop () {
|
|
97
|
+
if (this.htime != null) {
|
|
98
|
+
this.$emit('stop', {})
|
|
99
|
+
clearTimeout(this.htime)
|
|
100
|
+
this.htime = null
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
</script>
|
|
106
|
+
|
|
107
|
+
<style lang="scss">
|
|
108
|
+
.ml-countdown {
|
|
109
|
+
padding: 0 16rpx;
|
|
110
|
+
.ml-countdown-prefix {
|
|
111
|
+
display: inline-block;
|
|
112
|
+
padding-right: 16rpx;
|
|
113
|
+
}
|
|
114
|
+
.ml-countdown-item {
|
|
115
|
+
display: inline-block;
|
|
116
|
+
}
|
|
117
|
+
.ml-countdown-suffix {
|
|
118
|
+
display: inline-block;
|
|
119
|
+
padding-left: 16rpx;
|
|
120
|
+
}
|
|
121
|
+
.ml-countdown-time-num {
|
|
122
|
+
color: $ml-theme-primary-color;
|
|
123
|
+
padding: 0 8rpx;
|
|
124
|
+
font-size: 1.6em;
|
|
125
|
+
}
|
|
126
|
+
.ml-countdown-time-label {
|
|
127
|
+
padding: 0 8rpx;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
</style>
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -5,9 +5,21 @@ import { MaliStorage, MlStorageCore } from './storage'
|
|
|
5
5
|
import { MaliModal } from './modal'
|
|
6
6
|
import { MaliToast } from './toast'
|
|
7
7
|
import { MaliLoading } from './loading'
|
|
8
|
+
import { MaliWebview, MlWebviewCore } from './webview'
|
|
8
9
|
import { MaliI18n, MlI18nCore } from './i18n'
|
|
9
10
|
|
|
10
11
|
export interface ConfigOptions {
|
|
12
|
+
webview?: {
|
|
13
|
+
setStorage(params: {
|
|
14
|
+
data: any
|
|
15
|
+
}): void
|
|
16
|
+
}
|
|
17
|
+
loading?: any
|
|
18
|
+
upload?: any
|
|
19
|
+
loadMore?: any
|
|
20
|
+
pager?: any
|
|
21
|
+
notData?: any
|
|
22
|
+
listSelectUserPage?: any
|
|
11
23
|
[key: string]: any
|
|
12
24
|
}
|
|
13
25
|
|
|
@@ -19,8 +31,9 @@ export const MaliUI: {
|
|
|
19
31
|
MaliToast: typeof MaliToast
|
|
20
32
|
MaliModal: typeof MaliModal
|
|
21
33
|
MaliLoading: typeof MaliLoading
|
|
22
|
-
MaliI18n: MlI18nCore
|
|
23
34
|
MaliStorage: MlStorageCore
|
|
35
|
+
MaliI18n: MlI18nCore
|
|
36
|
+
MaliWebview: MlWebviewCore
|
|
24
37
|
}
|
|
25
38
|
|
|
26
39
|
export {
|
|
@@ -30,6 +43,7 @@ export {
|
|
|
30
43
|
MaliLoading,
|
|
31
44
|
MaliI18n,
|
|
32
45
|
MaliStorage,
|
|
46
|
+
MaliWebview
|
|
33
47
|
}
|
|
34
48
|
|
|
35
49
|
export default MaliUI
|
package/webview/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import XEUtils from 'xe-utils'
|
|
2
|
+
import globalStore from '../config/store'
|
|
3
|
+
|
|
4
|
+
export function defineH5Transfer (vueOpts = {}) {
|
|
5
|
+
return {
|
|
6
|
+
...vueOpts,
|
|
7
|
+
onLoad (options) {
|
|
8
|
+
if (options) {
|
|
9
|
+
const { _url, _method, _syncStorage } = options
|
|
10
|
+
let data = {}
|
|
11
|
+
if (options && _syncStorage) {
|
|
12
|
+
data = XEUtils.toStringJSON(decodeURIComponent(_syncStorage))
|
|
13
|
+
}
|
|
14
|
+
if (globalStore.webview && globalStore.webview.setStorage) {
|
|
15
|
+
globalStore.webview.setStorage({ data })
|
|
16
|
+
}
|
|
17
|
+
if (vueOpts.onStorage) {
|
|
18
|
+
vueOpts.onStorage.call(this, { data })
|
|
19
|
+
}
|
|
20
|
+
if (vueOpts.onLoad) {
|
|
21
|
+
vueOpts.onLoad.call(this, data)
|
|
22
|
+
}
|
|
23
|
+
if (_url && _method && uni[_method]) {
|
|
24
|
+
uni[_method]({ url: decodeURIComponent(_url) })
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const MaliWebview = {
|
|
32
|
+
defineH5Transfer
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default MaliWebview
|