@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27
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/LICENSE +160 -0
- package/dist/apis/apis.ts +15 -0
- package/dist/apis/base/index.ts +5 -0
- package/dist/apis/base/system.ts +77 -0
- package/dist/apis/device/accelerometer.ts +76 -0
- package/dist/apis/device/battery.ts +24 -0
- package/dist/apis/device/clipboard.ts +70 -0
- package/dist/apis/device/index.ts +9 -0
- package/dist/apis/device/keyboard.ts +62 -0
- package/dist/apis/device/memory.ts +4 -0
- package/dist/apis/device/network.ts +72 -0
- package/dist/apis/device/phone.ts +43 -0
- package/dist/apis/device/screen.ts +79 -0
- package/dist/apis/device/vibrate.ts +24 -0
- package/dist/apis/files/index.ts +135 -0
- package/dist/apis/files/manager.ts +941 -0
- package/dist/apis/framework/index.ts +32 -0
- package/dist/apis/index.ts +124 -0
- package/dist/apis/location/index.ts +133 -0
- package/dist/apis/media/common.ts +74 -0
- package/dist/apis/media/image.ts +122 -0
- package/dist/apis/media/index.ts +3 -0
- package/dist/apis/media/video.ts +86 -0
- package/dist/apis/navigate/index.ts +8 -0
- package/dist/apis/network/downloadFile.ts +113 -0
- package/dist/apis/network/index.ts +4 -0
- package/dist/apis/network/request.ts +113 -0
- package/dist/apis/network/uploadFile.ts +158 -0
- package/dist/apis/network/webSocket.ts +130 -0
- package/dist/apis/open-api/index.ts +7 -0
- package/dist/apis/open-api/user-info/index.ts +85 -0
- package/dist/apis/page/index.ts +92 -0
- package/dist/apis/route/index.ts +138 -0
- package/dist/apis/storage/index.ts +133 -0
- package/dist/apis/tabbar/index.ts +147 -0
- package/dist/apis/ui/animation.ts +222 -0
- package/dist/apis/ui/background.ts +35 -0
- package/dist/apis/ui/index.ts +14 -0
- package/dist/apis/ui/interaction/index.ts +195 -0
- package/dist/apis/ui/navigation-bar/index.ts +33 -0
- package/dist/apis/ui/pull-down-refresh.ts +41 -0
- package/dist/apis/utils/handler.ts +116 -0
- package/dist/apis/utils/index.ts +85 -0
- package/dist/apis/utils/types.ts +12 -0
- package/dist/apis/utils/validate.ts +87 -0
- package/dist/apis/wxml/IntersectionObserver.ts +119 -0
- package/dist/apis/wxml/index.ts +12 -0
- package/dist/apis/wxml/nodesRef.ts +56 -0
- package/dist/apis/wxml/selectorQuery.ts +287 -0
- package/dist/components/components-react.js +51 -0
- package/dist/components/components-react.js.map +1 -0
- package/dist/components-harmony/button/index.css +109 -0
- package/dist/components-harmony/button/index.hml +31 -0
- package/dist/components-harmony/button/index.js +105 -0
- package/dist/components-harmony/camera/index.hml +6 -0
- package/dist/components-harmony/camera/index.js +12 -0
- package/dist/components-harmony/checkbox/index.hml +11 -0
- package/dist/components-harmony/checkbox/index.js +60 -0
- package/dist/components-harmony/checkbox-group/index.hml +3 -0
- package/dist/components-harmony/checkbox-group/index.js +22 -0
- package/dist/components-harmony/cover-image/index.css +4 -0
- package/dist/components-harmony/cover-image/index.hml +9 -0
- package/dist/components-harmony/cover-image/index.js +15 -0
- package/dist/components-harmony/form/index.hml +10 -0
- package/dist/components-harmony/form/index.js +11 -0
- package/dist/components-harmony/icon/index.css +27 -0
- package/dist/components-harmony/icon/index.hml +54 -0
- package/dist/components-harmony/icon/index.js +17 -0
- package/dist/components-harmony/image/index.css +5 -0
- package/dist/components-harmony/image/index.hml +11 -0
- package/dist/components-harmony/image/index.js +28 -0
- package/dist/components-harmony/input/index.hml +21 -0
- package/dist/components-harmony/input/index.js +98 -0
- package/dist/components-harmony/label/index.hml +3 -0
- package/dist/components-harmony/label/index.js +6 -0
- package/dist/components-harmony/navbar/index.css +56 -0
- package/dist/components-harmony/navbar/index.hml +9 -0
- package/dist/components-harmony/navbar/index.js +30 -0
- package/dist/components-harmony/navigator/index.css +8 -0
- package/dist/components-harmony/navigator/index.hml +9 -0
- package/dist/components-harmony/navigator/index.js +104 -0
- package/dist/components-harmony/picker/index.hml +25 -0
- package/dist/components-harmony/picker/index.js +132 -0
- package/dist/components-harmony/picker-view/index.hml +23 -0
- package/dist/components-harmony/picker-view/index.js +161 -0
- package/dist/components-harmony/picker-view-column/index.hml +3 -0
- package/dist/components-harmony/picker-view-column/index.js +3 -0
- package/dist/components-harmony/progress/index.css +4 -0
- package/dist/components-harmony/progress/index.hml +28 -0
- package/dist/components-harmony/progress/index.js +23 -0
- package/dist/components-harmony/radio/index.hml +11 -0
- package/dist/components-harmony/radio/index.js +41 -0
- package/dist/components-harmony/radio-group/index.hml +3 -0
- package/dist/components-harmony/radio-group/index.js +11 -0
- package/dist/components-harmony/rich-text/index.hml +5 -0
- package/dist/components-harmony/rich-text/index.js +16 -0
- package/dist/components-harmony/scroll-view/index.css +5 -0
- package/dist/components-harmony/scroll-view/index.hml +12 -0
- package/dist/components-harmony/scroll-view/index.js +65 -0
- package/dist/components-harmony/slider/index.hml +16 -0
- package/dist/components-harmony/slider/index.js +53 -0
- package/dist/components-harmony/swiper/index.css +3 -0
- package/dist/components-harmony/swiper/index.hml +14 -0
- package/dist/components-harmony/swiper/index.js +19 -0
- package/dist/components-harmony/switch/index.hml +7 -0
- package/dist/components-harmony/switch/index.js +16 -0
- package/dist/components-harmony/tabbar/index.css +7 -0
- package/dist/components-harmony/tabbar/index.hml +26 -0
- package/dist/components-harmony/tabbar/index.js +42 -0
- package/dist/components-harmony/textarea/index.hml +24 -0
- package/dist/components-harmony/textarea/index.js +92 -0
- package/dist/components-harmony/utils/index.js +41 -0
- package/dist/components-harmony/video/index.hml +7 -0
- package/dist/components-harmony/video/index.js +73 -0
- package/dist/components-harmony/web-view/index.hml +8 -0
- package/dist/components-harmony/web-view/index.js +22 -0
- package/dist/components-harmony-ets/base.ets +63 -0
- package/dist/components-harmony-ets/button.ets +119 -0
- package/dist/components-harmony-ets/checkbox.ets +219 -0
- package/dist/components-harmony-ets/element.ets +223 -0
- package/dist/components-harmony-ets/form.ets +149 -0
- package/dist/components-harmony-ets/icon.ets +84 -0
- package/dist/components-harmony-ets/image.ets +85 -0
- package/dist/components-harmony-ets/index.ts +49 -0
- package/dist/components-harmony-ets/innerHtml.ets +79 -0
- package/dist/components-harmony-ets/input.ets +195 -0
- package/dist/components-harmony-ets/label.ets +111 -0
- package/dist/components-harmony-ets/picker.ets +370 -0
- package/dist/components-harmony-ets/radio.ets +225 -0
- package/dist/components-harmony-ets/richText.ets +97 -0
- package/dist/components-harmony-ets/scrollView.ets +199 -0
- package/dist/components-harmony-ets/slider.ets +159 -0
- package/dist/components-harmony-ets/swiper.ets +204 -0
- package/dist/components-harmony-ets/switch.ets +113 -0
- package/dist/components-harmony-ets/text.ets +97 -0
- package/dist/components-harmony-ets/textArea.ets +169 -0
- package/dist/components-harmony-ets/utils/AttributeManager.ets +250 -0
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +48 -0
- package/dist/components-harmony-ets/utils/constant/event.ets +25 -0
- package/dist/components-harmony-ets/utils/constant/icon.ts +19 -0
- package/dist/components-harmony-ets/utils/constant/style.ets +88 -0
- package/dist/components-harmony-ets/utils/events.ts +24 -0
- package/dist/components-harmony-ets/utils/flexManager.ets +107 -0
- package/dist/components-harmony-ets/utils/helper.ets +99 -0
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +103 -0
- package/dist/components-harmony-ets/utils/htmlParser/index.ts +56 -0
- package/dist/components-harmony-ets/utils/index.ts +83 -0
- package/dist/components-harmony-ets/utils/styles.ets +91 -0
- package/dist/components-harmony-ets/video.ets +161 -0
- package/dist/components-harmony-ets/view.ets +79 -0
- package/dist/index.js +1183 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime-ets/bom/document.ts +38 -0
- package/dist/runtime-ets/bom/getComputedStyle.ts +5 -0
- package/dist/runtime-ets/bom/navigator.ts +21 -0
- package/dist/runtime-ets/bom/raf.ts +37 -0
- package/dist/runtime-ets/bom/window.ts +44 -0
- package/dist/runtime-ets/constant.ts +29 -0
- package/dist/runtime-ets/current.ts +16 -0
- package/dist/runtime-ets/dom/class-list.ts +117 -0
- package/dist/runtime-ets/dom/comment.ts +10 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +105 -0
- package/dist/runtime-ets/dom/document.ts +108 -0
- package/dist/runtime-ets/dom/element.ts +457 -0
- package/dist/runtime-ets/dom/event.ts +164 -0
- package/dist/runtime-ets/dom/eventTarget.ts +98 -0
- package/dist/runtime-ets/dom/node.ts +215 -0
- package/dist/runtime-ets/dom/stylesheet/index.ts +687 -0
- package/dist/runtime-ets/dom/stylesheet/type.ts +136 -0
- package/dist/runtime-ets/dom/stylesheet/util.ts +134 -0
- package/dist/runtime-ets/dom/text.ts +19 -0
- package/dist/runtime-ets/index.ts +19 -0
- package/dist/runtime-ets/interface/event.ts +9 -0
- package/dist/runtime-ets/interface/index.ts +1 -0
- package/dist/runtime-ets/utils/bind.ts +35 -0
- package/dist/runtime-ets/utils/index.ts +135 -0
- package/dist/runtime-ets/utils/info.ts +128 -0
- package/dist/runtime-framework/react/app.ts +256 -0
- package/dist/runtime-framework/react/connect.ts +24 -0
- package/dist/runtime-framework/react/constant.ts +5 -0
- package/dist/runtime-framework/react/hooks.ts +101 -0
- package/dist/runtime-framework/react/index.ts +16 -0
- package/dist/runtime-framework/react/page.ts +263 -0
- package/dist/runtime-framework/react/utils/index.ts +25 -0
- package/dist/runtime-framework/react/utils/is.ts +46 -0
- package/dist/runtime-framework/solid/README.md +99 -0
- package/dist/runtime-framework/solid/app.ts +200 -0
- package/dist/runtime-framework/solid/connect.ts +11 -0
- package/dist/runtime-framework/solid/contant.ts +5 -0
- package/dist/runtime-framework/solid/hooks.ts +88 -0
- package/dist/runtime-framework/solid/index.ts +10 -0
- package/dist/runtime-framework/solid/page.ts +202 -0
- package/dist/runtime-framework/solid/reconciler/h.ts +132 -0
- package/dist/runtime-framework/solid/reconciler/index.ts +3 -0
- package/dist/runtime-framework/solid/reconciler/props.ts +151 -0
- package/dist/runtime-framework/solid/reconciler/render.ts +61 -0
- package/dist/runtime-framework/solid/reconciler/use.ts +8 -0
- package/dist/runtime-framework/solid/utils/index.ts +49 -0
- package/dist/runtime-framework/solid/utils/is.ts +46 -0
- package/dist/runtime-utils.js +4149 -0
- package/dist/runtime-utils.js.map +1 -0
- package/dist/runtime.js +4150 -0
- package/dist/runtime.js.map +1 -0
- package/dist/template/container.js +7 -0
- package/index.js +4 -0
- package/package.json +54 -0
- package/types/api.d.ts +4 -0
- package/types/component.d.ts +4 -0
- package/types/harmony.d.ts +11 -0
- package/types/runtime.d.ts +15 -0
- package/types/taro.d.ts +7 -0
- package/types/webpack-sources.d.ts +108 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import window from '@ohos.window'
|
|
2
|
+
|
|
3
|
+
import { createOption } from '../utils'
|
|
4
|
+
|
|
5
|
+
export default createOption({
|
|
6
|
+
data: {
|
|
7
|
+
type: 'keyboardHeightChange',
|
|
8
|
+
windowClass: null,
|
|
9
|
+
height: 0
|
|
10
|
+
},
|
|
11
|
+
props: {
|
|
12
|
+
id: String,
|
|
13
|
+
value: String,
|
|
14
|
+
type: String,
|
|
15
|
+
name: String,
|
|
16
|
+
password: Boolean,
|
|
17
|
+
placeholder: String,
|
|
18
|
+
placeholderColor: '#99000000',
|
|
19
|
+
disabled: Boolean,
|
|
20
|
+
maxlength: {
|
|
21
|
+
default: 140
|
|
22
|
+
},
|
|
23
|
+
focus: Boolean,
|
|
24
|
+
confirmType: {
|
|
25
|
+
default: 'done',
|
|
26
|
+
validator: function (value) {
|
|
27
|
+
const isValidConfirmType = ['default', 'next', 'go', 'done', 'send', 'search'].indexOf(value) !== -1
|
|
28
|
+
if (!isValidConfirmType) {
|
|
29
|
+
console.warn('unsupported props-confirmType:' + value + ', will use default confirmType[done].')
|
|
30
|
+
}
|
|
31
|
+
return isValidConfirmType
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
computed: {
|
|
37
|
+
realType () {
|
|
38
|
+
let temp = this.type
|
|
39
|
+
if (this.password === true) {
|
|
40
|
+
temp = 'password'
|
|
41
|
+
}
|
|
42
|
+
return temp
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
onInit () {
|
|
47
|
+
this.windowClass = window.getTopWindow()
|
|
48
|
+
this.windowClass.then(win => {
|
|
49
|
+
win.on('keyboardHeightChange', (err, data) => {
|
|
50
|
+
if (!err) {
|
|
51
|
+
if (this.height !== data.height) {
|
|
52
|
+
this.onKeyboardHeightChange(data.height)
|
|
53
|
+
}
|
|
54
|
+
this.height = data.height
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
onInput (e) {
|
|
61
|
+
this.value = e.value
|
|
62
|
+
this.$trigger('input', {
|
|
63
|
+
value: e.value, cursor: this.value.length, keyCode: null
|
|
64
|
+
})
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
onFocus () {
|
|
68
|
+
this.$trigger('focus', {
|
|
69
|
+
value: this.value, height: this.height
|
|
70
|
+
})
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
onBlur () {
|
|
74
|
+
this.$trigger('blur', {
|
|
75
|
+
value: this.value
|
|
76
|
+
})
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
onEnterKeyClick () {
|
|
80
|
+
this.$trigger('confirm', {
|
|
81
|
+
value: this.value
|
|
82
|
+
})
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
onKeyboardHeightChange (height) {
|
|
86
|
+
this.$trigger('keyboardheightchange', {
|
|
87
|
+
height: height, duration: 0
|
|
88
|
+
})
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
onDestroy () {
|
|
92
|
+
if (this.windowClass) {
|
|
93
|
+
this.windowClass.then(win => {
|
|
94
|
+
win.off('keyboardheightchange')
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
})
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
.navbar {
|
|
2
|
+
position: fixed;
|
|
3
|
+
top: 0px;
|
|
4
|
+
left: 0;
|
|
5
|
+
right: 0;
|
|
6
|
+
height: 44vp;
|
|
7
|
+
grid-template-columns: 1fr 1fr 1fr;
|
|
8
|
+
grid-template-rows: 44vp;
|
|
9
|
+
align-items: center;
|
|
10
|
+
}
|
|
11
|
+
.navbar__route {
|
|
12
|
+
margin-right: 40vp;
|
|
13
|
+
width: 60vp;
|
|
14
|
+
height: 100%;
|
|
15
|
+
background-size: 44px;
|
|
16
|
+
background-repeat: no-repeat;
|
|
17
|
+
background-position: center;
|
|
18
|
+
}
|
|
19
|
+
.navbar__route--show {
|
|
20
|
+
background-image: url('http://storage.360buyimg.com/cjj-pub-images/icon_left_arrow.png');
|
|
21
|
+
}
|
|
22
|
+
.navbar__title {
|
|
23
|
+
flex: 1;
|
|
24
|
+
text-align: center;
|
|
25
|
+
font-size: 14vp;
|
|
26
|
+
font-weight: bold;
|
|
27
|
+
}
|
|
28
|
+
.navbar__options {
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
margin: 8vp;
|
|
32
|
+
width: 84vp;
|
|
33
|
+
border: 1px solid #e8e8ed;
|
|
34
|
+
border-radius: 17vp;
|
|
35
|
+
}
|
|
36
|
+
.navbar__options--more {
|
|
37
|
+
flex: 1;
|
|
38
|
+
height: 100%;
|
|
39
|
+
background-image: url('http://storage.360buyimg.com/cjj-pub-images/icon-mp-more.png');
|
|
40
|
+
background-size: 36px;
|
|
41
|
+
background-repeat: no-repeat;
|
|
42
|
+
background-position: center;
|
|
43
|
+
}
|
|
44
|
+
.navbar__options--divider {
|
|
45
|
+
width: 1px;
|
|
46
|
+
height: 16vp;
|
|
47
|
+
background-color: #e8e8ed;
|
|
48
|
+
}
|
|
49
|
+
.navbar__options--close {
|
|
50
|
+
flex: 1;
|
|
51
|
+
height: 100%;
|
|
52
|
+
background-image: url('http://storage.360buyimg.com/cjj-pub-images/icon-mp-close.png');
|
|
53
|
+
background-size: 36px;
|
|
54
|
+
background-repeat: no-repeat;
|
|
55
|
+
background-position: center;
|
|
56
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<div class="navbar" style="background-color: {{bg}}">>
|
|
2
|
+
<div class="navbar__route {{isShowReturn ? 'navbar__route--show' : ''}}" onclick="goBack"></div>
|
|
3
|
+
<text class="navbar__title" style="color: {{textStyle}}">{{title}}</text>
|
|
4
|
+
<div class="navbar__options">
|
|
5
|
+
<div class="navbar__options--more"></div>
|
|
6
|
+
<div class="navbar__options--divider"></div>
|
|
7
|
+
<div class="navbar__options--close"></div>
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import router from '@system.router'
|
|
2
|
+
|
|
3
|
+
import { covertHex3ToHex6 } from '../utils'
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
props: {
|
|
7
|
+
title: {
|
|
8
|
+
default: '标题'
|
|
9
|
+
},
|
|
10
|
+
background: String,
|
|
11
|
+
textStyle: String,
|
|
12
|
+
st: String
|
|
13
|
+
},
|
|
14
|
+
data () {
|
|
15
|
+
const pagesLen = Number(router.getLength())
|
|
16
|
+
return {
|
|
17
|
+
isShowReturn: pagesLen > 0
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
computed: {
|
|
21
|
+
bg () {
|
|
22
|
+
return covertHex3ToHex6(this.background)
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
goBack () {
|
|
26
|
+
if (!this._data.isShowReturn) return
|
|
27
|
+
|
|
28
|
+
router.back()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import router from '@system.router'
|
|
2
|
+
|
|
3
|
+
import { createOption, queryToJson } from '../utils'
|
|
4
|
+
|
|
5
|
+
export default createOption({
|
|
6
|
+
props: {
|
|
7
|
+
id: {
|
|
8
|
+
default: ''
|
|
9
|
+
},
|
|
10
|
+
openType: {
|
|
11
|
+
default: 'navigate'
|
|
12
|
+
},
|
|
13
|
+
url: {
|
|
14
|
+
default: ''
|
|
15
|
+
},
|
|
16
|
+
hoverStartTime: {
|
|
17
|
+
default: 50
|
|
18
|
+
},
|
|
19
|
+
hoverStayTime: {
|
|
20
|
+
default: 600
|
|
21
|
+
},
|
|
22
|
+
hoverClass: {
|
|
23
|
+
default: 'navigator-hover'
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
data () {
|
|
28
|
+
return {
|
|
29
|
+
targetObj: {
|
|
30
|
+
navigate: 'push',
|
|
31
|
+
redirect: 'replace',
|
|
32
|
+
switchTab: 'push',
|
|
33
|
+
reLaunch: 'replace',
|
|
34
|
+
navigateBack: 'back'
|
|
35
|
+
},
|
|
36
|
+
hover: false,
|
|
37
|
+
touch: false
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
computed: {
|
|
42
|
+
clsHover () {
|
|
43
|
+
return this.hover ? this.hoverClass : ''
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
onClick () {
|
|
48
|
+
const { openType = 'navigate', url = '' } = this
|
|
49
|
+
this.getRouterFunc(`${openType}`, url)
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
getRouterFunc (method, url) {
|
|
53
|
+
const methodName = this.targetObj[method]
|
|
54
|
+
const [uri, queryString = ''] = url.split('?')
|
|
55
|
+
const params = queryToJson(queryString)
|
|
56
|
+
|
|
57
|
+
const uriObj = url ? { uri: uri.replace(/^\//, '') } : {}
|
|
58
|
+
|
|
59
|
+
const paramsObj = queryString ? { params } : {}
|
|
60
|
+
|
|
61
|
+
if (method === 'reLaunch') {
|
|
62
|
+
return router.clear()
|
|
63
|
+
} else if (method === 'switchTab') {
|
|
64
|
+
const app = getApp()
|
|
65
|
+
const pages = app.pageStack
|
|
66
|
+
|
|
67
|
+
for (let i = 0; i < pages.length; i++) {
|
|
68
|
+
const item = pages[i]
|
|
69
|
+
if (item === uriObj.uri) {
|
|
70
|
+
return router.back({
|
|
71
|
+
uri: item
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
router[methodName]({
|
|
78
|
+
...uriObj,
|
|
79
|
+
...paramsObj
|
|
80
|
+
})
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
onTouchStart () {
|
|
84
|
+
this.touch = true
|
|
85
|
+
if (this.hoverClass) {
|
|
86
|
+
setTimeout(() => {
|
|
87
|
+
if (this.touch) {
|
|
88
|
+
this.hover = true
|
|
89
|
+
}
|
|
90
|
+
}, this.hoverStartTime)
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
onTouchEnd () {
|
|
95
|
+
this.touch = false
|
|
96
|
+
if (this.hoverClass) {
|
|
97
|
+
setTimeout(() => {
|
|
98
|
+
if (!this.touch) {
|
|
99
|
+
this.hover = false
|
|
100
|
+
}
|
|
101
|
+
}, this.hoverStayTime)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<div>
|
|
2
|
+
<picker if="{{type === 'date'}}" id="{{id}}" style="flex: 1" type="date" value="{{localValue}}" start="{{start}}"
|
|
3
|
+
end="{{end}}" selected="{{selected}}" disabled="{{disabled}}" lunar="{{lunar}}" lunarswitch="{{lunarswitch}}"
|
|
4
|
+
vibrate="{{vibrate}}" @change="dateChange" @cancel="cancel">
|
|
5
|
+
</picker>
|
|
6
|
+
|
|
7
|
+
<picker elif="{{type === 'time'}}" id="{{id}}" style="flex: 1" type="time" value="{{localValue}}"
|
|
8
|
+
selected="{{selected}}" hours="{{hours}}" containsecond="{{containsecond}}" disabled="{{disabled}}" vibrate="{{vibrate}}" @change="timeChange"
|
|
9
|
+
@cancel="cancel">
|
|
10
|
+
</picker>
|
|
11
|
+
|
|
12
|
+
<picker elif="{{type === 'datetime'}}" id="{{id}}" style="flex: 1" type="datetime" value="{{localValue}}"
|
|
13
|
+
selected="{{selected}}" hours="{{hours}}" disabled="{{disabled}}" lunar="{{lunar}}" lunarswitch="{{lunarswitch}}"
|
|
14
|
+
vibrate="{{vibrate}}" @change="datetimeChange" @cancel="cancel">
|
|
15
|
+
</picker>
|
|
16
|
+
|
|
17
|
+
<picker elif="{{type === 'multi-text'}}" id="{{id}}" style="flex: 1" type="multi-text" value="{{localValue}}"
|
|
18
|
+
columns="{{columns}}" range="{{localRange}}" selected="{{selected}}" disabled="{{disabled}}" vibrate="{{vibrate}}"
|
|
19
|
+
@change="multiTextChange" @columnchange="multiTextColumnChange" @cancel="cancel">
|
|
20
|
+
</picker>
|
|
21
|
+
|
|
22
|
+
<picker else id="{{id}}" style="flex: 1" type="text" value="{{localValue}}" selected="{{selected}}"
|
|
23
|
+
range="{{localRange}}" disabled="{{disabled}}" vibrate="{{vibrate}}" @change="textChange" @cancel="cancel">
|
|
24
|
+
</picker>
|
|
25
|
+
</div>
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { createOption } from '../utils'
|
|
2
|
+
|
|
3
|
+
const DEFAULT_MODE = 'selector'
|
|
4
|
+
const DEFAULT_TYPE = 'text'
|
|
5
|
+
const MODE_TYPE_MAP = {
|
|
6
|
+
selector: 'text',
|
|
7
|
+
multiSelector: 'multi-text',
|
|
8
|
+
time: 'time',
|
|
9
|
+
date: 'date',
|
|
10
|
+
datetime: 'datetime'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default createOption({
|
|
14
|
+
props: [
|
|
15
|
+
'id',
|
|
16
|
+
'disabled',
|
|
17
|
+
'mode',
|
|
18
|
+
'range',
|
|
19
|
+
'value',
|
|
20
|
+
'rangeKey',
|
|
21
|
+
'start',
|
|
22
|
+
'end',
|
|
23
|
+
'hours',
|
|
24
|
+
'containsecond',
|
|
25
|
+
'vibrate',
|
|
26
|
+
'lunar',
|
|
27
|
+
'lunarswitch'
|
|
28
|
+
],
|
|
29
|
+
|
|
30
|
+
data () {
|
|
31
|
+
const isArray = Array.isArray
|
|
32
|
+
const range = isArray(this.range) ? this.range : []
|
|
33
|
+
const type = MODE_TYPE_MAP[this.mode || DEFAULT_MODE] || DEFAULT_TYPE
|
|
34
|
+
|
|
35
|
+
if (type === 'text') {
|
|
36
|
+
let localRange = range; const selected = this.value || 0
|
|
37
|
+
if (this.rangeKey) {
|
|
38
|
+
localRange = localRange.map(v => v[this.rangeKey])
|
|
39
|
+
}
|
|
40
|
+
// this.value代表的是下标,鸿蒙组件的value代表选择器的值
|
|
41
|
+
const localValue = localRange[selected]
|
|
42
|
+
return {
|
|
43
|
+
type,
|
|
44
|
+
localRange,
|
|
45
|
+
localValue,
|
|
46
|
+
selected
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (type === 'multi-text') {
|
|
51
|
+
const columns = range.length
|
|
52
|
+
let localRange = range
|
|
53
|
+
const selected = isArray(this.value) ? this.value : Array(columns).fill(0)
|
|
54
|
+
if (this.rangeKey) {
|
|
55
|
+
localRange = range.map(column => {
|
|
56
|
+
return (column || []).map(v => v[this.rangeKey])
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
const localValue = localRange.map((column, idx) => {
|
|
60
|
+
return column[selected[idx]]
|
|
61
|
+
})
|
|
62
|
+
return {
|
|
63
|
+
type,
|
|
64
|
+
localRange,
|
|
65
|
+
localValue,
|
|
66
|
+
selected,
|
|
67
|
+
columns
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (type === 'time') {
|
|
72
|
+
return {
|
|
73
|
+
type,
|
|
74
|
+
localValue: this.value,
|
|
75
|
+
selected: this.value || ''
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (type === 'date') {
|
|
80
|
+
return {
|
|
81
|
+
type,
|
|
82
|
+
localValue: this.value,
|
|
83
|
+
selected: this.value || ''
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (type === 'datetime') {
|
|
88
|
+
return {
|
|
89
|
+
type,
|
|
90
|
+
localValue: this.value,
|
|
91
|
+
selected: this.value || ''
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
textChange (e) {
|
|
97
|
+
const { newValue, newSelected } = e
|
|
98
|
+
this.localValue = newValue
|
|
99
|
+
this.$trigger('change', { value: newSelected })
|
|
100
|
+
},
|
|
101
|
+
multiTextChange (e) {
|
|
102
|
+
const { newValue, newSelected } = e
|
|
103
|
+
this.localValue = newValue
|
|
104
|
+
this.$trigger('change', { value: newSelected })
|
|
105
|
+
},
|
|
106
|
+
multiTextColumnChange (e) {
|
|
107
|
+
const { column, newSelected } = e
|
|
108
|
+
this.$trigger('columnchange', { column, value: newSelected })
|
|
109
|
+
},
|
|
110
|
+
timeChange (e) {
|
|
111
|
+
const { hour, minute, second } = e
|
|
112
|
+
this.localValue = padNumZero(hour) + ':' + padNumZero(minute) + (this.containsecond ? ':' + padNumZero(second) : '')
|
|
113
|
+
this.$trigger('change', { value: this.localValue, hour, minute, second })
|
|
114
|
+
},
|
|
115
|
+
dateChange (e) {
|
|
116
|
+
const { year, month, day } = e
|
|
117
|
+
this.localValue = [year, padNumZero(month + 1), padNumZero(day)].join('-')
|
|
118
|
+
this.$trigger('change', { value: this.localValue, year, month, day })
|
|
119
|
+
},
|
|
120
|
+
datetimeChange (e) {
|
|
121
|
+
const { year, month, day, hour, minute } = e
|
|
122
|
+
this.localValue = [year, padNumZero(month + 1), padNumZero(day), padNumZero(hour), padNumZero(minute)].join('-')
|
|
123
|
+
this.$trigger('change', { value: this.localValue, year, month, day, hour, minute })
|
|
124
|
+
},
|
|
125
|
+
cancel () {
|
|
126
|
+
this.$trigger('cancel')
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
function padNumZero (num) {
|
|
131
|
+
return num.toString().padStart(2, '0')
|
|
132
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<div>
|
|
2
|
+
<picker-view if="{{type === 'date'}}" id="{{id}}" type="date" start="{{start}}" end="{{end}}" selected="{{selected}}"
|
|
3
|
+
disabled="{{disabled}}" lunar="{{lunar}}" lunarswitch="{{lunarswitch}}" vibrate="{{vibrate}}" @change="dateChange">
|
|
4
|
+
</picker-view>
|
|
5
|
+
|
|
6
|
+
<picker-view elif="{{type === 'time'}}" id="{{id}}" type="time" selected="{{selected}}" hours="{{hours}}"
|
|
7
|
+
containsecond="{{containsecond}}" disabled="{{disabled}}" vibrate="{{vibrate}}" @change="timeChange">
|
|
8
|
+
</picker-view>
|
|
9
|
+
|
|
10
|
+
<picker-view elif="{{type === 'datetime'}}" id="{{id}}" type="datetime" selected="{{selected}}" hours="{{hours}}"
|
|
11
|
+
disabled="{{disabled}}" lunar="{{lunar}}" lunarswitch="{{lunarswitch}}" vibrate="{{vibrate}}"
|
|
12
|
+
@change="datetimeChange">
|
|
13
|
+
</picker-view>
|
|
14
|
+
|
|
15
|
+
<picker-view elif="{{type === 'multi-text'}}" id="{{id}}" type="multi-text" columns="{{columns}}"
|
|
16
|
+
range="{{localRange}}" selected="{{selected}}" disabled="{{disabled}}" vibrate="{{vibrate}}"
|
|
17
|
+
@columnchange="multiTextColumnChange">
|
|
18
|
+
</picker-view>
|
|
19
|
+
|
|
20
|
+
<picker-view else id="{{id}}" type="text" selected="{{selected}}" range="{{localRange}}" disabled="{{disabled}}"
|
|
21
|
+
indicatorprefix="{{indicatorprefix}}" indicatorsuffix="{{indicatorsuffix}}" vibrate="{{vibrate}}" @change="textChange">
|
|
22
|
+
</picker-view>
|
|
23
|
+
</div>
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { createOption } from '../utils'
|
|
2
|
+
|
|
3
|
+
const MODE_TYPE_MAP = {
|
|
4
|
+
selector: 'text',
|
|
5
|
+
multiSelector: 'multi-text',
|
|
6
|
+
time: 'time',
|
|
7
|
+
date: 'date',
|
|
8
|
+
datetime: 'datetime'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default createOption({
|
|
12
|
+
props: [
|
|
13
|
+
'id',
|
|
14
|
+
'disabled',
|
|
15
|
+
'mode',
|
|
16
|
+
'range',
|
|
17
|
+
'value',
|
|
18
|
+
'start',
|
|
19
|
+
'end',
|
|
20
|
+
'hours',
|
|
21
|
+
'containsecond',
|
|
22
|
+
'indicatorprefix',
|
|
23
|
+
'indicatorsuffix',
|
|
24
|
+
'vibrate',
|
|
25
|
+
'lunar',
|
|
26
|
+
'lunarswitch',
|
|
27
|
+
'cn'
|
|
28
|
+
],
|
|
29
|
+
|
|
30
|
+
data () {
|
|
31
|
+
const isArray = Array.isArray
|
|
32
|
+
const hasRangeProp = Boolean(this.range)
|
|
33
|
+
const hasModeProp = Boolean(this.mode)
|
|
34
|
+
let range = isArray(this.range) ? this.range : []
|
|
35
|
+
let type = hasModeProp ? MODE_TYPE_MAP[this.mode] || 'text' : null
|
|
36
|
+
const children = (this.cn || []).filter(child => child.nn === 'picker-view-column')
|
|
37
|
+
|
|
38
|
+
// 优先读取range属性,若无则解析子节点
|
|
39
|
+
if (!hasRangeProp && ['text', 'multi-text', null].includes(type)) {
|
|
40
|
+
range = recursiveGetCandidates(children)
|
|
41
|
+
}
|
|
42
|
+
// 若未指定type,则根据range类型来确定type
|
|
43
|
+
if (type === null) {
|
|
44
|
+
if (isMultiRange(range)) {
|
|
45
|
+
type = range.length === 1 ? 'text' : 'multi-text'
|
|
46
|
+
range = range.length === 1 ? range[0] : range
|
|
47
|
+
} else {
|
|
48
|
+
type = 'text'
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (type === 'text') {
|
|
53
|
+
const selected = this.value || 0
|
|
54
|
+
return {
|
|
55
|
+
type,
|
|
56
|
+
localRange: range,
|
|
57
|
+
selected
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (type === 'multi-text') {
|
|
62
|
+
const columns = range.length
|
|
63
|
+
const selected = isArray(this.value) ? this.value : Array(columns).fill(0)
|
|
64
|
+
return {
|
|
65
|
+
type,
|
|
66
|
+
localRange: range,
|
|
67
|
+
selected,
|
|
68
|
+
curSelected: selected,
|
|
69
|
+
columns
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (type === 'time') {
|
|
74
|
+
return {
|
|
75
|
+
type,
|
|
76
|
+
selected: this.value || ''
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (type === 'date') {
|
|
81
|
+
return {
|
|
82
|
+
type,
|
|
83
|
+
selected: this.value || ''
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (type === 'datetime') {
|
|
88
|
+
return {
|
|
89
|
+
type,
|
|
90
|
+
selected: this.value || ''
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
textChange (e) {
|
|
96
|
+
const { newSelected } = e
|
|
97
|
+
this.$trigger('change', { value: newSelected })
|
|
98
|
+
},
|
|
99
|
+
multiTextColumnChange (e) {
|
|
100
|
+
const { column, newSelected } = e
|
|
101
|
+
this.curSelected[column] = newSelected
|
|
102
|
+
this.$trigger('columnchange', { column, value: newSelected })
|
|
103
|
+
this.$trigger('change', { value: this.curSelected })
|
|
104
|
+
},
|
|
105
|
+
timeChange (e) {
|
|
106
|
+
const { hour, minute, second } = e
|
|
107
|
+
const value = padNumZero(hour) + ':' + padNumZero(minute) + (this.containsecond ? ':' + padNumZero(second) : '')
|
|
108
|
+
this.$trigger('change', { value, hour, minute, second })
|
|
109
|
+
},
|
|
110
|
+
dateChange (e) {
|
|
111
|
+
const { year, month, day } = e
|
|
112
|
+
const value = [year, padNumZero(month + 1), padNumZero(day)].join('-')
|
|
113
|
+
this.$trigger('change', { value, year, month, day })
|
|
114
|
+
},
|
|
115
|
+
datetimeChange (e) {
|
|
116
|
+
const { year, month, day, hour, minute } = e
|
|
117
|
+
const value = [year, padNumZero(month + 1), padNumZero(day), padNumZero(hour), padNumZero(minute)].join('-')
|
|
118
|
+
this.$trigger('change', { value, year, month, day, hour, minute })
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
function isMultiRange (range = []) {
|
|
123
|
+
return range.length > 0 && range.every(r => Array.isArray(r))
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* 对<PickerViewColumn>组件的子节点递归收集候选词
|
|
128
|
+
*/
|
|
129
|
+
function recursiveGetCandidates (children = []) {
|
|
130
|
+
if (children.length === 0) return []
|
|
131
|
+
return children.map(child => getCandidatesDFS(child.cn || []))
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* 以深度遍历方式收集候选词,最多遍历4层,优先查找左子树,直到读取到“#text”节点为止
|
|
135
|
+
* eg:
|
|
136
|
+
* <View>A</View> => A
|
|
137
|
+
* <View><Text>A</Text><Text>B</Text></View> => A
|
|
138
|
+
*/
|
|
139
|
+
function getCandidatesDFS (children = []) {
|
|
140
|
+
if (children.length === 0) return []
|
|
141
|
+
|
|
142
|
+
const allowDepth = 4 // 最深遍历4层,避免无限制递归
|
|
143
|
+
const trave = function (node, depth) {
|
|
144
|
+
if (node.nn === '#text') {
|
|
145
|
+
return node.v
|
|
146
|
+
}
|
|
147
|
+
if (depth > allowDepth) return ''
|
|
148
|
+
if (node.cn) {
|
|
149
|
+
return trave(node.cn[0], depth + 1) // 优先查找第一个孩子节点,这就要求开发者将候选词始终放在第一个节点中
|
|
150
|
+
}
|
|
151
|
+
return ''
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return children.map(child => {
|
|
155
|
+
return trave(child, 1)
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function padNumZero (num) {
|
|
160
|
+
return num.toString().padStart(2, '0')
|
|
161
|
+
}
|