hy-app 0.1.3 → 0.1.4
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/components/hy-button/hy-button.vue +7 -6
- package/components/hy-button/typing.d.ts +1 -1
- package/components/hy-divider/index.scss +1 -0
- package/components/hy-float-button/hy-float-button.vue +19 -3
- package/components/hy-float-button/index.scss +0 -2
- package/components/hy-form/typing.d.ts +1 -1
- package/components/hy-image/hy-image.vue +5 -1
- package/components/hy-loading/typing.d.ts +2 -1
- package/components/hy-login/TheUserLogin.vue +5 -73
- package/components/hy-notice-bar/hy-row-notice.vue +12 -3
- package/components/hy-parse/hy-parse.vue +499 -0
- package/components/hy-parse/index.scss +9 -0
- package/components/hy-parse/node/node.vue +584 -0
- package/components/hy-parse/parser.js +1337 -0
- package/components/hy-parse/props.ts +19 -0
- package/components/hy-parse/typing.d.ts +68 -0
- package/components/hy-price/hy-price.vue +6 -8
- package/components/hy-price/index.scss +6 -6
- package/components/hy-price/props.ts +4 -3
- package/components/hy-price/typing.d.ts +8 -4
- package/components/hy-slider/hy-slider.vue +4 -3
- package/components/hy-submitBar/Index.vue +17 -0
- package/components/hy-submitBar/hy-submitBar.vue +216 -0
- package/components/hy-submitBar/index.scss +9 -0
- package/components/hy-submitBar/props.ts +22 -0
- package/components/hy-submitBar/typing.d.ts +88 -0
- package/components/hy-tag/hy-tag.vue +24 -6
- package/components/hy-tag/index.scss +3 -2
- package/components/hy-text/typing.d.ts +1 -1
- package/components/hy-toast/hy-toast.vue +175 -0
- package/components/hy-toast/index.scss +77 -0
- package/components/hy-toast/props.ts +3 -0
- package/components/hy-toast/typing.d.ts +38 -0
- package/components/hy-warn/hy-warn.vue +2 -21
- package/components/hy-waterfall/hy-waterfall.vue +168 -38
- package/components/hy-waterfall/index.scss +9 -75
- package/components/hy-waterfall/props.ts +4 -5
- package/components/hy-waterfall/typing.d.ts +5 -9
- package/composables/index.ts +1 -0
- package/composables/useShare.ts +27 -0
- package/config/color.ts +1 -1
- package/config/icon.ts +21 -1
- package/index.ts +9 -8
- package/package.json +3 -2
- package/typing/index.ts +1 -1
- package/typing/modules/common.d.ts +21 -1
- package/utils/inspect.ts +50 -1
- package/utils/utils.ts +9 -7
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view id="_root" :class="(selectable ? '_select ' : '') + '_root'" :style="containerStyle">
|
|
3
|
+
<slot v-if="!nodes[0]" />
|
|
4
|
+
<!-- #ifndef APP-PLUS-NVUE -->
|
|
5
|
+
<node v-else :childs="nodes" :opts="[lazyLoad, loadingImg, errorImg, showImgMenu, selectable]" name="span" />
|
|
6
|
+
<!-- #endif -->
|
|
7
|
+
<!-- #ifdef APP-PLUS-NVUE -->
|
|
8
|
+
<web-view ref="web" src="/static/app-plus/mp-html/local.html" :style="'margin-top:-2px;height:' + height + 'px'" @onPostMessage="_onMessage" />
|
|
9
|
+
<!-- #endif -->
|
|
10
|
+
</view>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script>
|
|
14
|
+
/**
|
|
15
|
+
* mp-html v2.4.1
|
|
16
|
+
* @description 富文本组件
|
|
17
|
+
* @tutorial https://github.com/jin-yufeng/mp-html
|
|
18
|
+
* @property {String} container-style 容器的样式
|
|
19
|
+
* @property {String} content 用于渲染的 html 字符串
|
|
20
|
+
* @property {Boolean} copy-link 是否允许外部链接被点击时自动复制
|
|
21
|
+
* @property {String} domain 主域名,用于拼接链接
|
|
22
|
+
* @property {String} error-img 图片出错时的占位图链接
|
|
23
|
+
* @property {Boolean} lazy-load 是否开启图片懒加载
|
|
24
|
+
* @property {string} loading-img 图片加载过程中的占位图链接
|
|
25
|
+
* @property {Boolean} pause-video 是否在播放一个视频时自动暂停其他视频
|
|
26
|
+
* @property {Boolean} preview-img 是否允许图片被点击时自动预览
|
|
27
|
+
* @property {Boolean} scroll-table 是否给每个表格添加一个滚动层使其能单独横向滚动
|
|
28
|
+
* @property {Boolean | String} selectable 是否开启长按复制
|
|
29
|
+
* @property {Boolean} set-title 是否将 title 标签的内容设置到页面标题
|
|
30
|
+
* @property {Boolean} show-img-menu 是否允许图片被长按时显示菜单
|
|
31
|
+
* @property {Object} tag-style 标签的默认样式
|
|
32
|
+
* @property {Boolean | Number} use-anchor 是否使用锚点链接
|
|
33
|
+
* @event {Function} load dom 结构加载完毕时触发
|
|
34
|
+
* @event {Function} ready 所有图片加载完毕时触发
|
|
35
|
+
* @event {Function} imgTap 图片被点击时触发
|
|
36
|
+
* @event {Function} linkTap 链接被点击时触发
|
|
37
|
+
* @event {Function} play 音视频播放时触发
|
|
38
|
+
* @event {Function} error 媒体加载出错时触发
|
|
39
|
+
*/
|
|
40
|
+
// #ifndef APP-PLUS-NVUE
|
|
41
|
+
import node from './node/node'
|
|
42
|
+
// #endif
|
|
43
|
+
import Parser from './parser'
|
|
44
|
+
const plugins = []
|
|
45
|
+
// #ifdef APP-PLUS-NVUE
|
|
46
|
+
const dom = weex.requireModule('dom')
|
|
47
|
+
// #endif
|
|
48
|
+
export default {
|
|
49
|
+
name: 'hy-parse',
|
|
50
|
+
data() {
|
|
51
|
+
return {
|
|
52
|
+
nodes: [],
|
|
53
|
+
// #ifdef APP-PLUS-NVUE
|
|
54
|
+
height: 3
|
|
55
|
+
// #endif
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
props: {
|
|
59
|
+
containerStyle: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: ''
|
|
62
|
+
},
|
|
63
|
+
content: {
|
|
64
|
+
type: String,
|
|
65
|
+
default: ''
|
|
66
|
+
},
|
|
67
|
+
copyLink: {
|
|
68
|
+
type: [Boolean, String],
|
|
69
|
+
default: true
|
|
70
|
+
},
|
|
71
|
+
domain: String,
|
|
72
|
+
errorImg: {
|
|
73
|
+
type: String,
|
|
74
|
+
default: ''
|
|
75
|
+
},
|
|
76
|
+
lazyLoad: {
|
|
77
|
+
type: [Boolean, String],
|
|
78
|
+
default: false
|
|
79
|
+
},
|
|
80
|
+
loadingImg: {
|
|
81
|
+
type: String,
|
|
82
|
+
default: ''
|
|
83
|
+
},
|
|
84
|
+
pauseVideo: {
|
|
85
|
+
type: [Boolean, String],
|
|
86
|
+
default: true
|
|
87
|
+
},
|
|
88
|
+
previewImg: {
|
|
89
|
+
type: [Boolean, String],
|
|
90
|
+
default: true
|
|
91
|
+
},
|
|
92
|
+
scrollTable: [Boolean, String],
|
|
93
|
+
selectable: [Boolean, String],
|
|
94
|
+
setTitle: {
|
|
95
|
+
type: [Boolean, String],
|
|
96
|
+
default: true
|
|
97
|
+
},
|
|
98
|
+
showImgMenu: {
|
|
99
|
+
type: [Boolean, String],
|
|
100
|
+
default: true
|
|
101
|
+
},
|
|
102
|
+
tagStyle: Object,
|
|
103
|
+
useAnchor: [Boolean, Number]
|
|
104
|
+
},
|
|
105
|
+
// #ifdef VUE3
|
|
106
|
+
emits: ['load', 'ready', 'imgTap', 'linkTap', 'play', 'error'],
|
|
107
|
+
// #endif
|
|
108
|
+
// #ifndef APP-PLUS-NVUE
|
|
109
|
+
components: {
|
|
110
|
+
node
|
|
111
|
+
},
|
|
112
|
+
// #endif
|
|
113
|
+
watch: {
|
|
114
|
+
content(content) {
|
|
115
|
+
this.setContent(content)
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
created() {
|
|
119
|
+
this.plugins = []
|
|
120
|
+
for (let i = plugins.length; i--;) {
|
|
121
|
+
this.plugins.push(new plugins[i](this))
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
mounted() {
|
|
125
|
+
if (this.content && !this.nodes.length) {
|
|
126
|
+
this.setContent(this.content)
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
beforeUnmount() {
|
|
130
|
+
this._hook('onDetached')
|
|
131
|
+
},
|
|
132
|
+
methods: {
|
|
133
|
+
/**
|
|
134
|
+
* @description 将锚点跳转的范围限定在一个 scroll-view 内
|
|
135
|
+
* @param {Object} page scroll-view 所在页面的示例
|
|
136
|
+
* @param {String} selector scroll-view 的选择器
|
|
137
|
+
* @param {String} scrollTop scroll-view scroll-top 属性绑定的变量名
|
|
138
|
+
*/
|
|
139
|
+
in(page, selector, scrollTop) {
|
|
140
|
+
// #ifndef APP-PLUS-NVUE
|
|
141
|
+
if (page && selector && scrollTop) {
|
|
142
|
+
this._in = {
|
|
143
|
+
page,
|
|
144
|
+
selector,
|
|
145
|
+
scrollTop
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// #endif
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @description 锚点跳转
|
|
153
|
+
* @param {String} id 要跳转的锚点 id
|
|
154
|
+
* @param {Number} offset 跳转位置的偏移量
|
|
155
|
+
* @returns {Promise}
|
|
156
|
+
*/
|
|
157
|
+
navigateTo(id, offset) {
|
|
158
|
+
return new Promise((resolve, reject) => {
|
|
159
|
+
if (!this.useAnchor) {
|
|
160
|
+
reject(Error('Anchor is disabled'))
|
|
161
|
+
return
|
|
162
|
+
}
|
|
163
|
+
offset = offset || parseInt(this.useAnchor) || 0
|
|
164
|
+
// #ifdef APP-PLUS-NVUE
|
|
165
|
+
if (!id) {
|
|
166
|
+
dom.scrollToElement(this.$refs.web, {
|
|
167
|
+
offset
|
|
168
|
+
})
|
|
169
|
+
resolve()
|
|
170
|
+
} else {
|
|
171
|
+
this._navigateTo = {
|
|
172
|
+
resolve,
|
|
173
|
+
reject,
|
|
174
|
+
offset
|
|
175
|
+
}
|
|
176
|
+
this.$refs.web.evalJs('uni.postMessage({data:{action:"getOffset",offset:(document.getElementById(' + id + ')||{}).offsetTop}})')
|
|
177
|
+
}
|
|
178
|
+
// #endif
|
|
179
|
+
// #ifndef APP-PLUS-NVUE
|
|
180
|
+
let deep = ' '
|
|
181
|
+
// #ifdef MP-WEIXIN || MP-QQ || MP-TOUTIAO
|
|
182
|
+
deep = '>>>'
|
|
183
|
+
// #endif
|
|
184
|
+
const selector = uni.createSelectorQuery()
|
|
185
|
+
// #ifndef MP-ALIPAY
|
|
186
|
+
.in(this._in ? this._in.page : this)
|
|
187
|
+
// #endif
|
|
188
|
+
.select((this._in ? this._in.selector : '._root') + (id ? `${deep}#${id}` : '')).boundingClientRect()
|
|
189
|
+
if (this._in) {
|
|
190
|
+
selector.select(this._in.selector).scrollOffset()
|
|
191
|
+
.select(this._in.selector).boundingClientRect()
|
|
192
|
+
} else {
|
|
193
|
+
// 获取 scroll-view 的位置和滚动距离
|
|
194
|
+
selector.selectViewport().scrollOffset() // 获取窗口的滚动距离
|
|
195
|
+
}
|
|
196
|
+
selector.exec(res => {
|
|
197
|
+
if (!res[0]) {
|
|
198
|
+
reject(Error('Label not found'))
|
|
199
|
+
return
|
|
200
|
+
}
|
|
201
|
+
const scrollTop = res[1].scrollTop + res[0].top - (res[2] ? res[2].top : 0) + offset
|
|
202
|
+
if (this._in) {
|
|
203
|
+
// scroll-view 跳转
|
|
204
|
+
this._in.page[this._in.scrollTop] = scrollTop
|
|
205
|
+
} else {
|
|
206
|
+
// 页面跳转
|
|
207
|
+
uni.pageScrollTo({
|
|
208
|
+
scrollTop,
|
|
209
|
+
duration: 300
|
|
210
|
+
})
|
|
211
|
+
}
|
|
212
|
+
resolve()
|
|
213
|
+
})
|
|
214
|
+
// #endif
|
|
215
|
+
})
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* @description 获取文本内容
|
|
220
|
+
* @return {String}
|
|
221
|
+
*/
|
|
222
|
+
getText(nodes) {
|
|
223
|
+
let text = '';
|
|
224
|
+
(function traversal(nodes) {
|
|
225
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
226
|
+
const node = nodes[i]
|
|
227
|
+
if (node.type === 'text') {
|
|
228
|
+
text += node.text.replace(/&/g, '&')
|
|
229
|
+
} else if (node.name === 'br') {
|
|
230
|
+
text += '\n'
|
|
231
|
+
} else {
|
|
232
|
+
// 块级标签前后加换行
|
|
233
|
+
const isBlock = node.name === 'p' || node.name === 'div' || node.name === 'tr' || node.name === 'li' || (node.name[0] === 'h' && node.name[1] > '0' && node.name[1] < '7')
|
|
234
|
+
if (isBlock && text && text[text.length - 1] !== '\n') {
|
|
235
|
+
text += '\n'
|
|
236
|
+
}
|
|
237
|
+
// 递归获取子节点的文本
|
|
238
|
+
if (node.children) {
|
|
239
|
+
traversal(node.children)
|
|
240
|
+
}
|
|
241
|
+
if (isBlock && text[text.length - 1] !== '\n') {
|
|
242
|
+
text += '\n'
|
|
243
|
+
} else if (node.name === 'td' || node.name === 'th') {
|
|
244
|
+
text += '\t'
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
})(nodes || this.nodes)
|
|
249
|
+
return text
|
|
250
|
+
},
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* @description 获取内容大小和位置
|
|
254
|
+
* @return {Promise}
|
|
255
|
+
*/
|
|
256
|
+
getRect() {
|
|
257
|
+
return new Promise((resolve, reject) => {
|
|
258
|
+
uni.createSelectorQuery()
|
|
259
|
+
// #ifndef MP-ALIPAY
|
|
260
|
+
.in(this)
|
|
261
|
+
// #endif
|
|
262
|
+
.select('#_root').boundingClientRect().exec(res => res[0] ? resolve(res[0]) : reject(Error('Root label not found')))
|
|
263
|
+
})
|
|
264
|
+
},
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* @description 暂停播放媒体
|
|
268
|
+
*/
|
|
269
|
+
pauseMedia() {
|
|
270
|
+
for (let i = (this._videos || []).length; i--;) {
|
|
271
|
+
this._videos[i].pause()
|
|
272
|
+
}
|
|
273
|
+
// #ifdef APP-PLUS
|
|
274
|
+
const command = 'for(var e=document.getElementsByTagName("video"),i=e.length;i--;)e[i].pause()'
|
|
275
|
+
// #ifndef APP-PLUS-NVUE
|
|
276
|
+
let page = this.$parent
|
|
277
|
+
while (!page.$scope) page = page.$parent
|
|
278
|
+
page.$scope.$getAppWebview().evalJS(command)
|
|
279
|
+
// #endif
|
|
280
|
+
// #ifdef APP-PLUS-NVUE
|
|
281
|
+
this.$refs.web.evalJs(command)
|
|
282
|
+
// #endif
|
|
283
|
+
// #endif
|
|
284
|
+
},
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* @description 设置媒体播放速率
|
|
288
|
+
* @param {Number} rate 播放速率
|
|
289
|
+
*/
|
|
290
|
+
setPlaybackRate(rate) {
|
|
291
|
+
this.playbackRate = rate
|
|
292
|
+
for (let i = (this._videos || []).length; i--;) {
|
|
293
|
+
this._videos[i].playbackRate(rate)
|
|
294
|
+
}
|
|
295
|
+
// #ifdef APP-PLUS
|
|
296
|
+
const command = 'for(var e=document.getElementsByTagName("video"),i=e.length;i--;)e[i].playbackRate=' + rate
|
|
297
|
+
// #ifndef APP-PLUS-NVUE
|
|
298
|
+
let page = this.$parent
|
|
299
|
+
while (!page.$scope) page = page.$parent
|
|
300
|
+
page.$scope.$getAppWebview().evalJS(command)
|
|
301
|
+
// #endif
|
|
302
|
+
// #ifdef APP-PLUS-NVUE
|
|
303
|
+
this.$refs.web.evalJs(command)
|
|
304
|
+
// #endif
|
|
305
|
+
// #endif
|
|
306
|
+
},
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* @description 设置内容
|
|
310
|
+
* @param {String} content html 内容
|
|
311
|
+
* @param {Boolean} append 是否在尾部追加
|
|
312
|
+
*/
|
|
313
|
+
setContent(content, append) {
|
|
314
|
+
if (!append || !this.imgList) {
|
|
315
|
+
this.imgList = []
|
|
316
|
+
}
|
|
317
|
+
const nodes = new Parser(this).parse(content)
|
|
318
|
+
// #ifdef APP-PLUS-NVUE
|
|
319
|
+
if (this._ready) {
|
|
320
|
+
this._set(nodes, append)
|
|
321
|
+
}
|
|
322
|
+
// #endif
|
|
323
|
+
this.$set(this, 'nodes', append ? (this.nodes || []).concat(nodes) : nodes)
|
|
324
|
+
|
|
325
|
+
// #ifndef APP-PLUS-NVUE
|
|
326
|
+
this._videos = []
|
|
327
|
+
this.$nextTick(() => {
|
|
328
|
+
this._hook('onLoad')
|
|
329
|
+
this.$emit('load')
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
if (this.lazyLoad || this.imgList._unloadimgs < this.imgList.length / 2) {
|
|
333
|
+
// 设置懒加载,每 350ms 获取高度,不变则认为加载完毕
|
|
334
|
+
let height = 0
|
|
335
|
+
const callback = rect => {
|
|
336
|
+
if (!rect || !rect.height) rect = {}
|
|
337
|
+
// 350ms 总高度无变化就触发 ready 事件
|
|
338
|
+
if (rect.height === height) {
|
|
339
|
+
this.$emit('ready', rect)
|
|
340
|
+
} else {
|
|
341
|
+
height = rect.height
|
|
342
|
+
setTimeout(() => {
|
|
343
|
+
this.getRect().then(callback).catch(callback)
|
|
344
|
+
}, 350)
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
this.getRect().then(callback).catch(callback)
|
|
348
|
+
} else {
|
|
349
|
+
// 未设置懒加载,等待所有图片加载完毕
|
|
350
|
+
if (!this.imgList._unloadimgs) {
|
|
351
|
+
this.getRect().then(rect => {
|
|
352
|
+
this.$emit('ready', rect)
|
|
353
|
+
}).catch(() => {
|
|
354
|
+
this.$emit('ready', {})
|
|
355
|
+
})
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
// #endif
|
|
359
|
+
},
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* @description 调用插件钩子函数
|
|
363
|
+
*/
|
|
364
|
+
_hook(name) {
|
|
365
|
+
for (let i = plugins.length; i--;) {
|
|
366
|
+
if (this.plugins[i][name]) {
|
|
367
|
+
this.plugins[i][name]()
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
|
|
372
|
+
// #ifdef APP-PLUS-NVUE
|
|
373
|
+
/**
|
|
374
|
+
* @description 设置内容
|
|
375
|
+
*/
|
|
376
|
+
_set(nodes, append) {
|
|
377
|
+
this.$refs.web.evalJs('setContent(' + JSON.stringify(nodes).replace(/%22/g, '') + ',' + JSON.stringify([this.containerStyle.replace(/(?:margin|padding)[^;]+/g, ''), this.errorImg, this.loadingImg, this.pauseVideo, this.scrollTable, this.selectable]) + ',' + append + ')')
|
|
378
|
+
},
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* @description 接收到 web-view 消息
|
|
382
|
+
*/
|
|
383
|
+
_onMessage(e) {
|
|
384
|
+
const message = e.detail.data[0]
|
|
385
|
+
switch (message.action) {
|
|
386
|
+
// web-view 初始化完毕
|
|
387
|
+
case 'onJSBridgeReady':
|
|
388
|
+
this._ready = true
|
|
389
|
+
if (this.nodes) {
|
|
390
|
+
this._set(this.nodes)
|
|
391
|
+
}
|
|
392
|
+
break
|
|
393
|
+
// 内容 dom 加载完毕
|
|
394
|
+
case 'onLoad':
|
|
395
|
+
this.height = message.height
|
|
396
|
+
this._hook('onLoad')
|
|
397
|
+
this.$emit('load')
|
|
398
|
+
break
|
|
399
|
+
// 所有图片加载完毕
|
|
400
|
+
case 'onReady':
|
|
401
|
+
this.getRect().then(res => {
|
|
402
|
+
this.$emit('ready', res)
|
|
403
|
+
}).catch(() => {
|
|
404
|
+
this.$emit('ready', {})
|
|
405
|
+
})
|
|
406
|
+
break
|
|
407
|
+
// 总高度发生变化
|
|
408
|
+
case 'onHeightChange':
|
|
409
|
+
this.height = message.height
|
|
410
|
+
break
|
|
411
|
+
// 图片点击
|
|
412
|
+
case 'onImgTap':
|
|
413
|
+
this.$emit('imgTap', message.attrs)
|
|
414
|
+
if (this.previewImg) {
|
|
415
|
+
uni.previewImage({
|
|
416
|
+
current: parseInt(message.attrs.i),
|
|
417
|
+
urls: this.imgList
|
|
418
|
+
})
|
|
419
|
+
}
|
|
420
|
+
break
|
|
421
|
+
// 链接点击
|
|
422
|
+
case 'onLinkTap': {
|
|
423
|
+
const href = message.attrs.href
|
|
424
|
+
this.$emit('linkTap', message.attrs)
|
|
425
|
+
if (href) {
|
|
426
|
+
// 锚点跳转
|
|
427
|
+
if (href[0] === '#') {
|
|
428
|
+
if (this.useAnchor) {
|
|
429
|
+
dom.scrollToElement(this.$refs.web, {
|
|
430
|
+
offset: message.offset
|
|
431
|
+
})
|
|
432
|
+
}
|
|
433
|
+
} else if (href.includes('://')) {
|
|
434
|
+
// 打开外链
|
|
435
|
+
if (this.copyLink) {
|
|
436
|
+
plus.runtime.openWeb(href)
|
|
437
|
+
}
|
|
438
|
+
} else {
|
|
439
|
+
uni.navigateTo({
|
|
440
|
+
url: href,
|
|
441
|
+
fail() {
|
|
442
|
+
uni.switchTab({
|
|
443
|
+
url: href
|
|
444
|
+
})
|
|
445
|
+
}
|
|
446
|
+
})
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
break
|
|
450
|
+
}
|
|
451
|
+
case 'onPlay':
|
|
452
|
+
this.$emit('play')
|
|
453
|
+
break
|
|
454
|
+
// 获取到锚点的偏移量
|
|
455
|
+
case 'getOffset':
|
|
456
|
+
if (typeof message.offset === 'number') {
|
|
457
|
+
dom.scrollToElement(this.$refs.web, {
|
|
458
|
+
offset: message.offset + this._navigateTo.offset
|
|
459
|
+
})
|
|
460
|
+
this._navigateTo.resolve()
|
|
461
|
+
} else {
|
|
462
|
+
this._navigateTo.reject(Error('Label not found'))
|
|
463
|
+
}
|
|
464
|
+
break
|
|
465
|
+
// 点击
|
|
466
|
+
case 'onClick':
|
|
467
|
+
this.$emit('tap')
|
|
468
|
+
this.$emit('click')
|
|
469
|
+
break
|
|
470
|
+
// 出错
|
|
471
|
+
case 'onError':
|
|
472
|
+
this.$emit('error', {
|
|
473
|
+
source: message.source,
|
|
474
|
+
attrs: message.attrs
|
|
475
|
+
})
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
// #endif
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
</script>
|
|
482
|
+
|
|
483
|
+
<style>
|
|
484
|
+
/* #ifndef APP-PLUS-NVUE */
|
|
485
|
+
/* 根节点样式 */
|
|
486
|
+
._root {
|
|
487
|
+
padding: 1px 0;
|
|
488
|
+
overflow-x: auto;
|
|
489
|
+
overflow-y: hidden;
|
|
490
|
+
-webkit-overflow-scrolling: touch;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/* 长按复制 */
|
|
494
|
+
._select {
|
|
495
|
+
user-select: text;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/* #endif */
|
|
499
|
+
</style>
|