@dcloudio/uni-h5 2.0.0 → 2.0.1-32920211122002
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/dist/automator.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.umd.min.js +1 -1
- package/lib/apis.js +14 -4
- package/lib/h5/uni.automator.js +1 -1
- package/lib/modules.json +4 -1
- package/manifest.json +49 -0
- package/package.json +2 -3
- package/src/core/helpers/api.js +1 -1
- package/src/core/helpers/constants.js +1 -0
- package/src/core/helpers/i18n/en.json +4 -2
- package/src/core/helpers/i18n/es.json +4 -1
- package/src/core/helpers/i18n/fr.json +4 -1
- package/src/core/helpers/i18n/index.js +155 -4
- package/src/core/helpers/i18n/zh-Hans.json +4 -1
- package/src/core/helpers/i18n/zh-Hant.json +4 -1
- package/src/core/helpers/index.js +1 -1
- package/src/core/helpers/interceptor.js +19 -15
- package/src/core/helpers/promise.js +1 -1
- package/src/core/helpers/protocol/device/set-clipboard-data.js +11 -2
- package/src/core/helpers/protocol/network/request.js +14 -1
- package/src/core/helpers/protocol/network/upload-file.js +1 -1
- package/src/core/helpers/protocol/ui/popup.js +2 -2
- package/src/core/runtime/base.js +2 -0
- package/src/core/runtime/locale.js +37 -0
- package/src/core/runtime/web-view/index.js +4 -0
- package/src/core/runtime/wrapper/create-subpackage-app.js +7 -6
- package/src/core/runtime/wrapper/util.js +6 -1
- package/src/core/service/api/base/interceptor.js +1 -1
- package/src/core/service/api/context/canvas.js +3 -2
- package/src/core/service/api/context/create-map-context.js +8 -1
- package/src/core/service/api/ui/locale.js +50 -0
- package/src/core/service/plugins/app/create-app.js +8 -3
- package/src/core/service/plugins/app/index.js +2 -2
- package/src/core/service/plugins/index.js +8 -2
- package/src/core/view/bridge/subscribe/api/request-component-observer.js +16 -1
- package/src/core/view/components/canvas/index.vue +3 -1
- package/src/core/view/components/editor/formats/image.js +3 -1
- package/src/core/view/components/editor/formats/index.js +3 -1
- package/src/core/view/components/editor/formats/link.js +9 -0
- package/src/core/view/components/editor/index.vue +33 -3
- package/src/core/view/components/image/index.vue +4 -5
- package/src/core/view/components/input/index.vue +53 -25
- package/src/core/view/components/picker-view-column/index.vue +1 -0
- package/src/core/view/components/progress/index.vue +20 -13
- package/src/core/view/components/rich-text/index.vue +13 -1
- package/src/core/view/components/rich-text/nodes-parser.js +23 -4
- package/src/core/view/components/scroll-view/index.vue +253 -122
- package/src/core/view/components/slider/index.vue +1 -1
- package/src/core/view/components/swiper/index.vue +3 -0
- package/src/core/view/components/textarea/index.vue +7 -3
- package/src/core/view/index.css +4 -0
- package/src/core/view/mixins/field.js +27 -9
- package/src/core/view/mixins/interact.js +13 -11
- package/src/core/view/mixins/keyboard.js +42 -26
- package/src/core/view/mixins/touchtrack.js +2 -2
- package/src/core/view/plugins/index.js +1 -1
- package/src/platforms/app-plus/constants.js +1 -0
- package/src/platforms/app-plus/helpers/get-real-path.js +7 -4
- package/src/platforms/app-plus/helpers/uuid.js +1 -1
- package/src/platforms/app-plus/service/api/ad/ad-base.js +159 -0
- package/src/platforms/app-plus/service/api/ad/ad.js +4 -8
- package/src/platforms/app-plus/service/api/ad/full-screen-video-ad.js +5 -98
- package/src/platforms/app-plus/service/api/ad/interactive-ad.js +257 -0
- package/src/platforms/app-plus/service/api/ad/interstitial-ad.js +15 -0
- package/src/platforms/app-plus/service/api/ad/rewarded-video-ad.js +15 -2
- package/src/platforms/app-plus/service/api/device/system.js +3 -2
- package/src/platforms/app-plus/service/api/file/open-document.js +7 -15
- package/src/platforms/app-plus/service/api/index.js +2 -0
- package/src/platforms/app-plus/service/api/location/get-location.js +8 -7
- package/src/platforms/app-plus/service/api/media/choose-image.js +22 -51
- package/src/platforms/app-plus/service/api/media/choose-video.js +19 -36
- package/src/platforms/app-plus/service/api/media/compress-video.js +2 -2
- package/src/platforms/app-plus/service/api/media/get-video-info.js +5 -2
- package/src/platforms/app-plus/service/api/network/request.js +27 -1
- package/src/platforms/app-plus/service/api/network/upload-file.js +1 -1
- package/src/platforms/app-plus/service/api/plugin/oauth.js +140 -8
- package/src/platforms/app-plus/service/api/storage/storage.js +1 -1
- package/src/platforms/app-plus/service/api/ui/popup.js +21 -11
- package/src/platforms/app-plus/service/api/ui/tab-bar.js +3 -2
- package/src/platforms/app-plus/service/api/util.js +5 -1
- package/src/platforms/app-plus/service/framework/app.js +21 -5
- package/src/platforms/app-plus/service/framework/config.js +1 -0
- package/src/platforms/app-plus/service/framework/plugins/index.js +8 -2
- package/src/platforms/app-plus/service/framework/plugins/lifecycle.js +2 -2
- package/src/platforms/app-plus/service/framework/subscribe-handlers/index.js +1 -1
- package/src/platforms/app-plus/service/framework/tab-bar.js +12 -2
- package/src/platforms/app-plus/service/framework/webview/index.js +2 -2
- package/src/platforms/app-plus/service/framework/webview/parser/title-nview-parser.js +73 -30
- package/src/platforms/app-plus/service/framework/webview/parser/webview-style-parser.js +16 -16
- package/src/platforms/app-plus/service/index.js +10 -3
- package/src/platforms/app-plus/service/publish-handler.js +3 -0
- package/src/platforms/app-plus/view/bridge/subscribe/index.js +5 -3
- package/src/platforms/app-plus/view/components/ad/index.vue +53 -44
- package/src/platforms/app-plus/view/components/cover-view/index.vue +13 -7
- package/src/platforms/app-plus/view/components/map/index.vue +29 -27
- package/src/platforms/app-plus/view/components/video/index.vue +40 -24
- package/src/platforms/app-plus/view/framework/plugins/gesture.js +17 -0
- package/src/platforms/app-plus/view/framework/plugins/index.js +3 -1
- package/src/platforms/app-plus/view/index.css +4 -0
- package/src/platforms/app-plus/view/mixins/cover.js +10 -15
- package/src/platforms/app-plus/view/mixins/native.js +45 -3
- package/src/platforms/app-plus-nvue/service/api/context/operate-map-player.js +3 -0
- package/src/platforms/h5/components/app/observable.js +3 -2
- package/src/platforms/h5/components/app/popup/mixins/modal.js +3 -3
- package/src/platforms/h5/components/app/popup/modal.vue +38 -2
- package/src/platforms/h5/components/app/popup/toast.vue +9 -1
- package/src/platforms/h5/components/app/tabBar.vue +39 -17
- package/src/platforms/h5/components/page/index.vue +5 -3
- package/src/platforms/h5/components/page/pageHead.vue +94 -75
- package/src/platforms/h5/components/system-routes/choose-location/index.vue +127 -66
- package/src/platforms/h5/components/system-routes/open-location/index.vue +193 -38
- package/src/platforms/h5/helpers/location.js +26 -0
- package/src/platforms/h5/helpers/todo-api.js +2 -2
- package/src/platforms/h5/service/api/device/clipboard.js +41 -0
- package/src/platforms/h5/service/api/device/get-system-info.js +75 -0
- package/src/platforms/h5/service/api/location/get-location.js +47 -18
- package/src/platforms/h5/service/api/media/MIMEType.js +53 -0
- package/src/platforms/h5/service/api/media/choose-file.js +9 -1
- package/src/platforms/h5/service/api/media/choose-image.js +9 -2
- package/src/platforms/h5/service/api/media/choose-video.js +9 -1
- package/src/platforms/h5/service/api/media/create_input.js +12 -3
- package/src/platforms/h5/service/api/ui/popup.js +3 -5
- package/src/platforms/h5/service/api/ui/tab-bar.js +1 -1
- package/src/platforms/h5/service/index.js +5 -0
- package/src/platforms/h5/view/bridge/subscribe/index.js +3 -2
- package/src/platforms/h5/view/components/ad/index.vue +112 -69
- package/src/platforms/h5/view/components/map/index.vue +96 -349
- package/src/platforms/h5/view/components/map/map-marker.js +287 -0
- package/src/platforms/h5/view/components/map/maps/callout.js +117 -0
- package/src/platforms/h5/view/components/map/maps/index.js +55 -0
- package/src/platforms/h5/view/components/video/index.vue +1 -1
- package/src/platforms/h5/view/index.css +4 -0
- package/src/platforms/mp-alipay/runtime/api/protocols.js +30 -3
- package/src/platforms/mp-baidu/runtime/api/protocols.js +5 -0
- package/src/platforms/mp-baidu/runtime/wrapper/component-parser.js +20 -18
- package/src/platforms/mp-baidu/runtime/wrapper/util.js +2 -1
- package/src/platforms/mp-kuaishou/runtime/api/protocols.js +3 -1
- package/src/platforms/mp-kuaishou/runtime/wrapper/component-parser.js +21 -1
- package/src/platforms/mp-lark/runtime/api/index.js +0 -0
- package/src/platforms/mp-lark/runtime/api/protocols.js +68 -0
- package/src/platforms/mp-lark/runtime/api/providers.js +6 -0
- package/src/platforms/mp-lark/runtime/index.js +1 -0
- package/src/platforms/mp-lark/runtime/web-view.js +11 -0
- package/src/platforms/mp-lark/runtime/wrapper/app-parser.js +33 -0
- package/src/platforms/mp-lark/runtime/wrapper/component-parser.js +50 -0
- package/src/platforms/mp-lark/runtime/wrapper/page-parser.js +39 -0
- package/src/platforms/mp-lark/runtime/wrapper/util.js +64 -0
- package/src/platforms/mp-qq/runtime/api/protocols.js +3 -1
- package/src/platforms/mp-toutiao/runtime/api/protocols.js +2 -0
- package/src/platforms/mp-toutiao/runtime/wrapper/component-parser.js +35 -19
- package/src/platforms/mp-weixin/helpers/get-user-profile.js +6 -0
- package/src/platforms/mp-weixin/runtime/index.js +6 -7
- package/src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js +197 -126
- package/src/platforms/mp-weixin/runtime/wrapper/fix-set-data.js +37 -0
- package/src/shared/uni-id-mixin.js +77 -0
- package/src/shared/util.js +2 -0
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<uni-textarea v-on="$listeners">
|
|
3
|
-
<div
|
|
3
|
+
<div
|
|
4
|
+
ref="wrapper"
|
|
5
|
+
class="uni-textarea-wrapper"
|
|
6
|
+
>
|
|
4
7
|
<div
|
|
5
8
|
v-show="!(composing || valueSync.length)"
|
|
6
9
|
ref="placeholder"
|
|
@@ -144,7 +147,8 @@ export default {
|
|
|
144
147
|
lineCount
|
|
145
148
|
})
|
|
146
149
|
if (this.autoHeight) {
|
|
147
|
-
this.$el.style.height =
|
|
150
|
+
this.$el.style.height = 'auto'
|
|
151
|
+
this.$refs.wrapper.style.height = this.height + 'px'
|
|
148
152
|
}
|
|
149
153
|
}
|
|
150
154
|
},
|
|
@@ -246,7 +250,6 @@ uni-textarea {
|
|
|
246
250
|
line-height: normal;
|
|
247
251
|
white-space: pre-wrap;
|
|
248
252
|
word-break: break-all;
|
|
249
|
-
box-sizing: content-box !important;
|
|
250
253
|
}
|
|
251
254
|
uni-textarea[hidden] {
|
|
252
255
|
display: none;
|
|
@@ -267,6 +270,7 @@ uni-textarea[hidden] {
|
|
|
267
270
|
position: relative;
|
|
268
271
|
width: 100%;
|
|
269
272
|
height: 100%;
|
|
273
|
+
min-height: inherit;
|
|
270
274
|
}
|
|
271
275
|
.uni-textarea-placeholder,
|
|
272
276
|
.uni-textarea-line,
|
package/src/core/view/index.css
CHANGED
|
@@ -64,6 +64,10 @@ body {
|
|
|
64
64
|
content: "\EA08";
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
.uni-icon-error:before {
|
|
68
|
+
content: "\EA0B";
|
|
69
|
+
}
|
|
70
|
+
|
|
67
71
|
.uni-loading,
|
|
68
72
|
uni-button[loading]:before {
|
|
69
73
|
background: transparent url("data:image/svg+xml;base64, PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgxMDB2MTAwSDB6Ii8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTlFOUU5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTMwKSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iIzk4OTY5NyIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgzMCAxMDUuOTggNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjOUI5OTlBIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDYwIDc1Ljk4IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0EzQTFBMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSg5MCA2NSA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNBQkE5QUEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoMTIwIDU4LjY2IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0IyQjJCMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgxNTAgNTQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjQkFCOEI5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDE4MCA1MCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDMkMwQzEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=") no-repeat;
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
} from 'uni-shared'
|
|
5
5
|
import emitter from './emitter'
|
|
6
6
|
import keyboard from './keyboard'
|
|
7
|
+
import interact from './interact'
|
|
7
8
|
|
|
8
9
|
UniViewJSBridge.subscribe('getSelectedTextRange', function ({ pageId, callbackId }) {
|
|
9
10
|
const activeElement = document.activeElement
|
|
@@ -29,7 +30,7 @@ let startTime
|
|
|
29
30
|
|
|
30
31
|
export default {
|
|
31
32
|
name: 'Field',
|
|
32
|
-
mixins: [emitter, keyboard],
|
|
33
|
+
mixins: [emitter, keyboard, interact],
|
|
33
34
|
model: {
|
|
34
35
|
prop: 'value',
|
|
35
36
|
event: 'update:value'
|
|
@@ -116,6 +117,7 @@ export default {
|
|
|
116
117
|
}, 100)
|
|
117
118
|
this.$watch('value', valueChange)
|
|
118
119
|
this.__triggerInput = throttle(($event, detail) => {
|
|
120
|
+
this.__valueChange.cancel()
|
|
119
121
|
this.$emit('update:value', detail.value)
|
|
120
122
|
this.$trigger('input', $event, detail)
|
|
121
123
|
}, 100)
|
|
@@ -146,7 +148,9 @@ export default {
|
|
|
146
148
|
this._field = el
|
|
147
149
|
startTime = startTime || Date.now()
|
|
148
150
|
if (this.needFocus) {
|
|
149
|
-
|
|
151
|
+
setTimeout(() => {
|
|
152
|
+
this._focus()
|
|
153
|
+
})
|
|
150
154
|
}
|
|
151
155
|
},
|
|
152
156
|
_focus () {
|
|
@@ -167,7 +171,10 @@ export default {
|
|
|
167
171
|
return
|
|
168
172
|
}
|
|
169
173
|
field.focus()
|
|
170
|
-
|
|
174
|
+
// 无用户交互的 webview 需主动显示键盘(安卓)
|
|
175
|
+
if (!this.userInteract) {
|
|
176
|
+
plus.key.showSoftKeybord()
|
|
177
|
+
}
|
|
171
178
|
}
|
|
172
179
|
},
|
|
173
180
|
_blur () {
|
|
@@ -190,20 +197,31 @@ export default {
|
|
|
190
197
|
this._onInput($event, true)
|
|
191
198
|
}
|
|
192
199
|
this.focusSync = false
|
|
200
|
+
const field = $event.target
|
|
201
|
+
let cursor
|
|
202
|
+
if (field.type === 'number') {
|
|
203
|
+
field.type = 'text'
|
|
204
|
+
cursor = field.selectionEnd
|
|
205
|
+
field.type = 'number'
|
|
206
|
+
} else {
|
|
207
|
+
cursor = field.selectionEnd
|
|
208
|
+
}
|
|
193
209
|
this.$trigger('blur', $event, {
|
|
194
210
|
value: this.valueSync,
|
|
195
|
-
cursor
|
|
211
|
+
cursor
|
|
196
212
|
})
|
|
197
213
|
},
|
|
198
214
|
_checkSelection () {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
215
|
+
const field = this._field
|
|
216
|
+
if (this.focusSync && this.selectionStartNumber > -1 && this.selectionEndNumber > -1 && field.type !== 'number') {
|
|
217
|
+
field.selectionStart = this.selectionStartNumber
|
|
218
|
+
field.selectionEnd = this.selectionEndNumber
|
|
202
219
|
}
|
|
203
220
|
},
|
|
204
221
|
_checkCursor () {
|
|
205
|
-
|
|
206
|
-
|
|
222
|
+
const field = this._field
|
|
223
|
+
if (this.focusSync && this.selectionStartNumber < 0 && this.selectionEndNumber < 0 && this.cursorNumber > -1 && field.type !== 'number') {
|
|
224
|
+
field.selectionEnd = field.selectionStart = this.cursorNumber
|
|
207
225
|
}
|
|
208
226
|
}
|
|
209
227
|
}
|
|
@@ -9,21 +9,18 @@ const passiveOptions = supportsPassive ? {
|
|
|
9
9
|
const vms = []
|
|
10
10
|
let userInteract = 0
|
|
11
11
|
let inited
|
|
12
|
-
function
|
|
12
|
+
function setInteract (interact) { vms.forEach(vm => (vm.userInteract = interact)) }
|
|
13
|
+
function addInteractListener (vm = {}) {
|
|
13
14
|
if (!inited) {
|
|
14
15
|
const eventNames = ['touchstart', 'touchmove', 'touchend', 'mousedown', 'mouseup']
|
|
15
16
|
eventNames.forEach(eventName => {
|
|
16
17
|
document.addEventListener(eventName, function () {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
vm.userInteract = false
|
|
24
|
-
}
|
|
25
|
-
}, 0)
|
|
26
|
-
})
|
|
18
|
+
!userInteract && setInteract(true)
|
|
19
|
+
userInteract++
|
|
20
|
+
|
|
21
|
+
setTimeout(() => {
|
|
22
|
+
!--userInteract && setInteract(false)
|
|
23
|
+
}, 0)
|
|
27
24
|
}, passiveOptions)
|
|
28
25
|
})
|
|
29
26
|
inited = true
|
|
@@ -51,5 +48,10 @@ export default {
|
|
|
51
48
|
},
|
|
52
49
|
beforeDestroy () {
|
|
53
50
|
removeInteractListener(this)
|
|
51
|
+
},
|
|
52
|
+
addInteractListener,
|
|
53
|
+
// true -> interact
|
|
54
|
+
getStatus () {
|
|
55
|
+
return !!userInteract
|
|
54
56
|
}
|
|
55
57
|
}
|
|
@@ -3,6 +3,23 @@ import {
|
|
|
3
3
|
} from 'uni-shared'
|
|
4
4
|
import emitter from './emitter'
|
|
5
5
|
|
|
6
|
+
let resetTimer
|
|
7
|
+
let isAndroid
|
|
8
|
+
let osVersion
|
|
9
|
+
let keyboardHeight
|
|
10
|
+
let keyboardChangeCallback
|
|
11
|
+
let webviewStyle
|
|
12
|
+
if (__PLATFORM__ === 'app-plus') {
|
|
13
|
+
plusReady(() => {
|
|
14
|
+
isAndroid = plus.os.name.toLowerCase() === 'android'
|
|
15
|
+
osVersion = plus.os.version
|
|
16
|
+
})
|
|
17
|
+
document.addEventListener('keyboardchange', function (event) {
|
|
18
|
+
keyboardHeight = event.height
|
|
19
|
+
keyboardChangeCallback && keyboardChangeCallback()
|
|
20
|
+
}, false)
|
|
21
|
+
}
|
|
22
|
+
|
|
6
23
|
/**
|
|
7
24
|
* 保证iOS点击输入框外隐藏键盘
|
|
8
25
|
*/
|
|
@@ -14,7 +31,8 @@ function setSoftinputTemporary (vm, reset) {
|
|
|
14
31
|
const MODE_ADJUSTPAN = 'adjustPan'
|
|
15
32
|
const MODE_NOTHING = 'nothing'
|
|
16
33
|
const currentWebview = plus.webview.currentWebview()
|
|
17
|
-
|
|
34
|
+
// iOS 14.6 调用同步方法导致键盘弹卡顿
|
|
35
|
+
const style = webviewStyle || currentWebview.getStyle() || {}
|
|
18
36
|
const options = {
|
|
19
37
|
mode: (reset || style.softinputMode === MODE_ADJUSTRESIZE) ? MODE_ADJUSTRESIZE : (vm.adjustPosition ? MODE_ADJUSTPAN : MODE_NOTHING),
|
|
20
38
|
position: {
|
|
@@ -63,22 +81,6 @@ function resetSoftinputNavBar (vm) {
|
|
|
63
81
|
}
|
|
64
82
|
}
|
|
65
83
|
|
|
66
|
-
let resetTimer
|
|
67
|
-
let isAndroid
|
|
68
|
-
let osVersion
|
|
69
|
-
let keyboardHeight
|
|
70
|
-
let keyboardChangeCallback
|
|
71
|
-
if (__PLATFORM__ === 'app-plus') {
|
|
72
|
-
plusReady(() => {
|
|
73
|
-
isAndroid = plus.os.name.toLowerCase() === 'android'
|
|
74
|
-
osVersion = plus.os.version
|
|
75
|
-
})
|
|
76
|
-
document.addEventListener('keyboardchange', function (event) {
|
|
77
|
-
keyboardHeight = event.height
|
|
78
|
-
keyboardChangeCallback && keyboardChangeCallback()
|
|
79
|
-
}, false)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
84
|
export default {
|
|
83
85
|
name: 'Keyboard',
|
|
84
86
|
mixins: [emitter],
|
|
@@ -146,19 +148,30 @@ export default {
|
|
|
146
148
|
|
|
147
149
|
if (__PLATFORM__ === 'app-plus') {
|
|
148
150
|
// 安卓单独隐藏键盘后点击输入框不会触发 focus 事件
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
})
|
|
154
|
-
if (!isAndroid && parseInt(osVersion) < 12) {
|
|
155
|
-
// iOS12 以下系统 focus 事件设置较迟,改在 touchstart 设置
|
|
156
|
-
el.addEventListener('touchstart', () => {
|
|
157
|
-
if (!this.disabled && !focus) {
|
|
151
|
+
if (isAndroid) {
|
|
152
|
+
el.addEventListener('click', () => {
|
|
153
|
+
if (!this.disabled && focus && keyboardHeight === 0) {
|
|
158
154
|
setSoftinputTemporary(this)
|
|
159
155
|
}
|
|
160
156
|
})
|
|
161
157
|
}
|
|
158
|
+
if (!isAndroid) {
|
|
159
|
+
// iOS12 以下系统 focus 事件设置较迟,改在 touchstart 设置
|
|
160
|
+
if (parseInt(osVersion) < 12) {
|
|
161
|
+
el.addEventListener('touchstart', () => {
|
|
162
|
+
if (!this.disabled && !focus) {
|
|
163
|
+
setSoftinputTemporary(this)
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
// iOS 14.6 调用同步方法导致键盘弹卡顿
|
|
168
|
+
if (parseFloat(osVersion) >= 14.6 && !webviewStyle) {
|
|
169
|
+
plusReady(() => {
|
|
170
|
+
const currentWebview = plus.webview.currentWebview()
|
|
171
|
+
webviewStyle = currentWebview.getStyle() || {}
|
|
172
|
+
})
|
|
173
|
+
}
|
|
174
|
+
}
|
|
162
175
|
}
|
|
163
176
|
|
|
164
177
|
const onKeyboardHide = () => {
|
|
@@ -188,6 +201,9 @@ export default {
|
|
|
188
201
|
}
|
|
189
202
|
|
|
190
203
|
el.addEventListener('blur', () => {
|
|
204
|
+
// 在iOS设备上,手动调用uni.hideKeyboard(),键盘收起并且触发blur,但实际并没有blur。
|
|
205
|
+
// 此时如果再点击页面其他地方会重新聚焦,此处做处理
|
|
206
|
+
el.blur()
|
|
191
207
|
focus = false
|
|
192
208
|
onKeyboardHide()
|
|
193
209
|
})
|
|
@@ -22,10 +22,13 @@ function addBase (filePath) {
|
|
|
22
22
|
export default function getRealPath (filePath) {
|
|
23
23
|
if (filePath.indexOf('/') === 0) {
|
|
24
24
|
if (filePath.indexOf('//') === 0) {
|
|
25
|
-
|
|
26
|
-
} else {
|
|
27
|
-
return addBase(filePath.substr(1))
|
|
25
|
+
return 'https:' + filePath
|
|
28
26
|
}
|
|
27
|
+
// 平台绝对路径 安卓、iOS
|
|
28
|
+
if (filePath.startsWith('/storage/') || filePath.startsWith('/sdcard/') || filePath.includes('/Containers/Data/Application/')) {
|
|
29
|
+
return 'file://' + filePath
|
|
30
|
+
}
|
|
31
|
+
return addBase(filePath.substr(1))
|
|
29
32
|
}
|
|
30
33
|
// 网络资源或base64
|
|
31
34
|
if (SCHEME_RE.test(filePath) || DATA_RE.test(filePath) || filePath.indexOf('blob:') === 0) {
|
|
@@ -43,4 +46,4 @@ export default function getRealPath (filePath) {
|
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
return filePath
|
|
46
|
-
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
const eventTypes = {
|
|
2
|
+
load: 'load',
|
|
3
|
+
close: 'close',
|
|
4
|
+
error: 'error',
|
|
5
|
+
adClicked: 'adClicked'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const eventNames = [
|
|
9
|
+
eventTypes.load,
|
|
10
|
+
eventTypes.close,
|
|
11
|
+
eventTypes.error,
|
|
12
|
+
eventTypes.adClicked
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
class AdBase {
|
|
16
|
+
constructor (adInstance, options) {
|
|
17
|
+
const _callbacks = this._callbacks = {}
|
|
18
|
+
eventNames.forEach(item => {
|
|
19
|
+
_callbacks[item] = []
|
|
20
|
+
const name = item[0].toUpperCase() + item.substr(1)
|
|
21
|
+
this[`on${name}`] = function (callback) {
|
|
22
|
+
_callbacks[item].push(callback)
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
this._preload = options.preload !== undefined ? options.preload : false
|
|
27
|
+
|
|
28
|
+
this._isLoaded = false
|
|
29
|
+
this._isLoading = false
|
|
30
|
+
this._adError = ''
|
|
31
|
+
this._loadPromiseResolve = null
|
|
32
|
+
this._loadPromiseReject = null
|
|
33
|
+
this._showPromiseResolve = null
|
|
34
|
+
this._showPromiseReject = null
|
|
35
|
+
|
|
36
|
+
const ad = this._ad = adInstance
|
|
37
|
+
ad.onLoad((e) => {
|
|
38
|
+
this._isLoaded = true
|
|
39
|
+
this._isLoading = false
|
|
40
|
+
|
|
41
|
+
if (this._loadPromiseResolve != null) {
|
|
42
|
+
this._loadPromiseResolve()
|
|
43
|
+
this._loadPromiseResolve = null
|
|
44
|
+
}
|
|
45
|
+
if (this._showPromiseResolve != null) {
|
|
46
|
+
this._showPromiseResolve()
|
|
47
|
+
this._showPromiseResolve = null
|
|
48
|
+
this._showAd()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
this._dispatchEvent(eventTypes.load, {})
|
|
52
|
+
})
|
|
53
|
+
ad.onClose((e) => {
|
|
54
|
+
this._isLoaded = false
|
|
55
|
+
this._isLoading = false
|
|
56
|
+
this._dispatchEvent(eventTypes.close, { isEnded: e.isEnded })
|
|
57
|
+
|
|
58
|
+
if (this._preload === true) {
|
|
59
|
+
this._loadAd()
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
ad.onError((e) => {
|
|
63
|
+
this._isLoading = false
|
|
64
|
+
|
|
65
|
+
const data = {
|
|
66
|
+
code: e.code,
|
|
67
|
+
errMsg: e.message
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
this._adError = data
|
|
71
|
+
|
|
72
|
+
this._dispatchEvent(eventTypes.error, data)
|
|
73
|
+
|
|
74
|
+
const error = new Error(JSON.stringify(this._adError))
|
|
75
|
+
error.code = e.code
|
|
76
|
+
error.errMsg = e.message
|
|
77
|
+
|
|
78
|
+
if (this._loadPromiseReject != null) {
|
|
79
|
+
this._loadPromiseReject(error)
|
|
80
|
+
this._loadPromiseReject = null
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (this._showPromiseReject != null) {
|
|
84
|
+
this._showPromiseReject(error)
|
|
85
|
+
this._showPromiseReject = null
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
ad.onAdClicked && ad.onAdClicked((e) => {
|
|
89
|
+
this._dispatchEvent(eventTypes.adClicked, {})
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
load () {
|
|
94
|
+
return new Promise((resolve, reject) => {
|
|
95
|
+
this._loadPromiseResolve = resolve
|
|
96
|
+
this._loadPromiseReject = reject
|
|
97
|
+
if (this._isLoading) {
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (this._isLoaded) {
|
|
102
|
+
resolve()
|
|
103
|
+
} else {
|
|
104
|
+
this._loadAd()
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
show () {
|
|
110
|
+
return new Promise((resolve, reject) => {
|
|
111
|
+
this._showPromiseResolve = resolve
|
|
112
|
+
this._showPromiseReject = reject
|
|
113
|
+
|
|
114
|
+
if (this._isLoading) {
|
|
115
|
+
return
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (this._isLoaded) {
|
|
119
|
+
this._showAd()
|
|
120
|
+
resolve()
|
|
121
|
+
} else {
|
|
122
|
+
this._loadAd()
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
destroy () {
|
|
128
|
+
this._ad.destroy()
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
getProvider () {
|
|
132
|
+
return this._ad.getProvider()
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
_loadAd () {
|
|
136
|
+
this._adError = ''
|
|
137
|
+
this._isLoaded = false
|
|
138
|
+
this._isLoading = true
|
|
139
|
+
this._ad.load()
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
_showAd () {
|
|
143
|
+
this._ad.show()
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
_dispatchEvent (name, data) {
|
|
147
|
+
this._callbacks[name].forEach(callback => {
|
|
148
|
+
if (typeof callback === 'function') {
|
|
149
|
+
callback(data || {})
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export {
|
|
156
|
+
eventTypes,
|
|
157
|
+
eventNames,
|
|
158
|
+
AdBase
|
|
159
|
+
}
|
|
@@ -10,8 +10,7 @@ UniServiceJSBridge.subscribe('onAdMethodCallback', ({
|
|
|
10
10
|
callbackId,
|
|
11
11
|
data
|
|
12
12
|
}, pageId) => {
|
|
13
|
-
|
|
14
|
-
getAdData(adpid, width, count, (res) => {
|
|
13
|
+
getAdData(data, (res) => {
|
|
15
14
|
operateAdView(pageId, callbackId, 'success', res)
|
|
16
15
|
}, (err) => {
|
|
17
16
|
operateAdView(pageId, callbackId, 'fail', err)
|
|
@@ -20,7 +19,8 @@ UniServiceJSBridge.subscribe('onAdMethodCallback', ({
|
|
|
20
19
|
|
|
21
20
|
const _adDataCache = {}
|
|
22
21
|
|
|
23
|
-
function getAdData (
|
|
22
|
+
function getAdData (data, onsuccess, onerror) {
|
|
23
|
+
const { adpid, width } = data
|
|
24
24
|
const key = adpid + '-' + width
|
|
25
25
|
const adDataList = _adDataCache[key]
|
|
26
26
|
if (adDataList && adDataList.length > 0) {
|
|
@@ -29,11 +29,7 @@ function getAdData (adpid, width, count, onsuccess, onerror) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
plus.ad.getAds(
|
|
32
|
-
|
|
33
|
-
adpid,
|
|
34
|
-
count,
|
|
35
|
-
width
|
|
36
|
-
},
|
|
32
|
+
data,
|
|
37
33
|
(res) => {
|
|
38
34
|
const list = res.ads
|
|
39
35
|
onsuccess(list.splice(0, 1)[0])
|
|
@@ -1,103 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
'error',
|
|
5
|
-
'adClicked'
|
|
6
|
-
]
|
|
1
|
+
import {
|
|
2
|
+
AdBase
|
|
3
|
+
} from './ad-base.js'
|
|
7
4
|
|
|
8
|
-
class FullScreenVideoAd {
|
|
5
|
+
class FullScreenVideoAd extends AdBase {
|
|
9
6
|
constructor (options = {}) {
|
|
10
|
-
|
|
11
|
-
eventNames.forEach(item => {
|
|
12
|
-
_callbacks[item] = []
|
|
13
|
-
const name = item[0].toUpperCase() + item.substr(1)
|
|
14
|
-
this[`on${name}`] = function (callback) {
|
|
15
|
-
_callbacks[item].push(callback)
|
|
16
|
-
}
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
this._isLoad = false
|
|
20
|
-
this._adError = ''
|
|
21
|
-
this._loadPromiseResolve = null
|
|
22
|
-
this._loadPromiseReject = null
|
|
23
|
-
this._lastLoadTime = 0
|
|
24
|
-
|
|
25
|
-
const ad = this._ad = plus.ad.createFullScreenVideoAd(options)
|
|
26
|
-
ad.onLoad((e) => {
|
|
27
|
-
this._isLoad = true
|
|
28
|
-
this._lastLoadTime = Date.now()
|
|
29
|
-
this._dispatchEvent('load', {})
|
|
30
|
-
|
|
31
|
-
if (this._loadPromiseResolve != null) {
|
|
32
|
-
this._loadPromiseResolve()
|
|
33
|
-
this._loadPromiseResolve = null
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
ad.onClose((e) => {
|
|
37
|
-
this._isLoad = false
|
|
38
|
-
this._dispatchEvent('close', { isEnded: e.isEnded })
|
|
39
|
-
})
|
|
40
|
-
ad.onError((e) => {
|
|
41
|
-
const { code, message } = e
|
|
42
|
-
const data = { code: code, errMsg: message }
|
|
43
|
-
this._adError = message
|
|
44
|
-
if (code === -5008) {
|
|
45
|
-
this._isLoad = false
|
|
46
|
-
}
|
|
47
|
-
this._dispatchEvent('error', data)
|
|
48
|
-
|
|
49
|
-
if (this._loadPromiseReject != null) {
|
|
50
|
-
this._loadPromiseReject(data)
|
|
51
|
-
this._loadPromiseReject = null
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
ad.onAdClicked((e) => {
|
|
55
|
-
this._dispatchEvent('adClicked', {})
|
|
56
|
-
})
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
load () {
|
|
60
|
-
return new Promise((resolve, reject) => {
|
|
61
|
-
if (this._isLoad) {
|
|
62
|
-
resolve()
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
this._loadPromiseResolve = resolve
|
|
66
|
-
this._loadPromiseReject = reject
|
|
67
|
-
this._loadAd()
|
|
68
|
-
})
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
show () {
|
|
72
|
-
return new Promise((resolve, reject) => {
|
|
73
|
-
if (this._isLoad) {
|
|
74
|
-
this._ad.show()
|
|
75
|
-
resolve()
|
|
76
|
-
} else {
|
|
77
|
-
reject(new Error(this._adError))
|
|
78
|
-
}
|
|
79
|
-
})
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
getProvider () {
|
|
83
|
-
return this._ad.getProvider()
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
destroy () {
|
|
87
|
-
this._ad.destroy()
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
_loadAd () {
|
|
91
|
-
this._isLoad = false
|
|
92
|
-
this._ad.load()
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
_dispatchEvent (name, data) {
|
|
96
|
-
this._callbacks[name].forEach(callback => {
|
|
97
|
-
if (typeof callback === 'function') {
|
|
98
|
-
callback(data || {})
|
|
99
|
-
}
|
|
100
|
-
})
|
|
7
|
+
super(plus.ad.createFullScreenVideoAd(options), options)
|
|
101
8
|
}
|
|
102
9
|
}
|
|
103
10
|
|