@didaoktv/didaoui-uniapp 1.0.0 → 1.2.0

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.
Files changed (114) hide show
  1. package/README.md +16 -7
  2. package/components/dd-action-sheet/dd-action-sheet.vue +3 -3
  3. package/components/dd-album/album.js +19 -0
  4. package/components/dd-album/dd-album.vue +345 -0
  5. package/components/dd-album/props.js +89 -0
  6. package/components/dd-avatar/avatar.js +19 -0
  7. package/components/dd-avatar/dd-avatar.vue +172 -160
  8. package/components/dd-avatar/props.js +84 -0
  9. package/components/dd-avatar-group/avatarGroup.js +14 -0
  10. package/components/dd-avatar-group/dd-avatar-group.vue +110 -0
  11. package/components/dd-avatar-group/props.js +57 -0
  12. package/components/dd-badge/dd-badge.vue +2 -2
  13. package/components/dd-barcode/dd-barcode.vue +1030 -0
  14. package/components/dd-bill-detail/dd-bill-detail.vue +265 -0
  15. package/components/dd-button/dd-button.vue +17 -17
  16. package/components/dd-calendar/dd-calendar.vue +357 -0
  17. package/components/dd-canvas/dd-canvas.vue +1088 -0
  18. package/components/dd-capsule-button/dd-capsule-button.vue +6 -6
  19. package/components/dd-car-keyboard/carKeyboard.js +6 -0
  20. package/components/dd-car-keyboard/dd-car-keyboard.vue +315 -0
  21. package/components/dd-car-keyboard/props.js +19 -0
  22. package/components/dd-cascader/dd-cascader.vue +405 -0
  23. package/components/dd-cell/dd-cell.vue +50 -23
  24. package/components/dd-cell-group/dd-cell-group.vue +32 -25
  25. package/components/dd-champion-card/dd-champion-card.vue +4 -4
  26. package/components/dd-checkbox/dd-checkbox.vue +30 -39
  27. package/components/dd-checkbox-group/dd-checkbox-group.vue +67 -0
  28. package/components/dd-copy/dd-copy.vue +74 -0
  29. package/components/dd-coupon/dd-coupon.vue +368 -0
  30. package/components/dd-cropper/dd-cropper.vue +1297 -0
  31. package/components/dd-dialog/dd-dialog.vue +1 -1
  32. package/components/dd-divider/dd-divider.vue +3 -3
  33. package/components/dd-dropdown-item/dd-dropdown-item.vue +5 -5
  34. package/components/dd-empty-state/dd-empty-state.vue +1 -1
  35. package/components/dd-field/dd-field.vue +531 -106
  36. package/components/dd-form/dd-form.vue +116 -0
  37. package/components/dd-form/rules.ts +84 -0
  38. package/components/dd-goods-sku/dd-goods-sku.vue +434 -0
  39. package/components/dd-icon/dd-icon.vue +2 -2
  40. package/components/dd-image/dd-image.vue +4 -4
  41. package/components/dd-input/dd-input.vue +5 -5
  42. package/components/dd-keyboard/dd-keyboard.vue +178 -0
  43. package/components/dd-keyboard/keyboard.js +22 -0
  44. package/components/dd-keyboard/props.js +89 -0
  45. package/components/dd-link/dd-link.vue +87 -0
  46. package/components/dd-link/link.js +18 -0
  47. package/components/dd-link/props.js +44 -0
  48. package/components/dd-list-cell/dd-list-cell.vue +4 -4
  49. package/components/dd-loading/dd-loading.vue +1 -1
  50. package/components/dd-loadmore/dd-loadmore.vue +2 -2
  51. package/components/dd-markdown/dd-markdown.vue +344 -0
  52. package/components/dd-markdown/marked.esm.mjs +7 -0
  53. package/components/dd-mini-program-navbar/dd-mini-program-navbar.vue +9 -9
  54. package/components/dd-navigation/dd-navigation.vue +5 -5
  55. package/components/dd-number-keyboard/dd-number-keyboard.vue +200 -0
  56. package/components/dd-number-keyboard/numberKeyboard.js +8 -0
  57. package/components/dd-number-keyboard/props.js +24 -0
  58. package/components/dd-parse/dd-parse.vue +534 -0
  59. package/components/dd-parse/node/handler.wxs +26 -0
  60. package/components/dd-parse/node/node.vue +603 -0
  61. package/components/dd-parse/parse.js +13 -0
  62. package/components/dd-parse/parser.js +1400 -0
  63. package/components/dd-parse/props.js +57 -0
  64. package/components/dd-popover/dd-popover.vue +10 -10
  65. package/components/dd-popover-item/dd-popover-item.vue +3 -3
  66. package/components/dd-popup/dd-popup.vue +5 -5
  67. package/components/dd-poster/dd-poster.vue +695 -0
  68. package/components/dd-progress/dd-progress.vue +3 -3
  69. package/components/dd-pull-refresh/dd-pull-refresh.vue +3 -3
  70. package/components/dd-qrcode/dd-qrcode.vue +509 -0
  71. package/components/dd-qrcode/qrcode.js +1283 -0
  72. package/components/dd-radio/dd-radio.vue +19 -20
  73. package/components/dd-radio-group/dd-radio-group.vue +53 -0
  74. package/components/dd-rate/dd-rate.vue +1 -1
  75. package/components/dd-room-card/dd-room-card.vue +3 -3
  76. package/components/dd-search-bar/dd-search-bar.vue +8 -8
  77. package/components/dd-segmented-tab/dd-segmented-tab.vue +6 -6
  78. package/components/dd-signature/dd-signature.vue +513 -0
  79. package/components/dd-skeleton/dd-skeleton.vue +1 -1
  80. package/components/dd-slider/dd-slider.vue +4 -4
  81. package/components/dd-stat-card/dd-stat-card.vue +5 -5
  82. package/components/dd-step/dd-step.vue +11 -11
  83. package/components/dd-stepper/dd-stepper.vue +6 -6
  84. package/components/dd-swipe-action/dd-swipe-action.vue +1 -1
  85. package/components/dd-swipeable-tab/dd-swipeable-tab.vue +1 -1
  86. package/components/dd-tabbar-item/dd-tabbar-item.vue +8 -8
  87. package/components/dd-tag/dd-tag.vue +17 -1
  88. package/components/dd-text/dd-text.vue +250 -0
  89. package/components/dd-text/props.js +120 -0
  90. package/components/dd-text/text.js +30 -0
  91. package/components/dd-text/value.js +87 -0
  92. package/components/dd-toast/dd-toast.vue +2 -2
  93. package/components/dd-upload/dd-upload.vue +4 -4
  94. package/components/dd-workorder-card/dd-workorder-card.vue +237 -0
  95. package/index.ts +50 -9
  96. package/libs/config/color.js +16 -0
  97. package/libs/config/config.js +25 -0
  98. package/libs/config/props.js +185 -0
  99. package/libs/config/zIndex.js +20 -0
  100. package/libs/function/digit.js +167 -0
  101. package/libs/function/index.js +932 -0
  102. package/libs/function/test.js +327 -0
  103. package/libs/i18n/index.d.ts +2 -0
  104. package/libs/i18n/index.js +89 -0
  105. package/libs/i18n/locales/zh-Hans.js +86 -0
  106. package/libs/mixin/button.js +18 -0
  107. package/libs/mixin/mixin.js +44 -0
  108. package/libs/mixin/mpMixin.js +13 -0
  109. package/libs/mixin/openType.js +27 -0
  110. package/libs/utils.ts +462 -0
  111. package/libs/vue.js +3 -0
  112. package/package.json +1 -1
  113. package/scss/_dd-shared.scss +40 -0
  114. package/scss/_variables.scss +4 -1
@@ -0,0 +1,534 @@
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.5.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: 'dd-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 规范化链接地址
135
+ * @param {any} href
136
+ * @return {String}
137
+ */
138
+ normalizeHref(href) {
139
+ return typeof href === 'string' ? href.trim() : ''
140
+ },
141
+
142
+ /**
143
+ * @description 判断是否为外部链接
144
+ * @param {String} href
145
+ * @return {Boolean}
146
+ */
147
+ isExternalLink(href) {
148
+ return href.split('?')[0].includes('://')
149
+ },
150
+
151
+ /**
152
+ * @description 打开外部链接
153
+ * @param {String} href
154
+ */
155
+ openExternalLink(href) {
156
+ // #ifdef APP-PLUS
157
+ try {
158
+ plus.runtime.openWeb(href)
159
+ } catch (e) { }
160
+ // #endif
161
+ // #ifdef APP-HARMONY
162
+ try {
163
+ plus.runtime.openURL(href)
164
+ } catch (e) { }
165
+ // #endif
166
+ },
167
+
168
+ /**
169
+ * @description 将锚点跳转的范围限定在一个 scroll-view 内
170
+ * @param {Object} page scroll-view 所在页面的示例
171
+ * @param {String} selector scroll-view 的选择器
172
+ * @param {String} scrollTop scroll-view scroll-top 属性绑定的变量名
173
+ */
174
+ in(page, selector, scrollTop) {
175
+ // #ifndef APP-PLUS-NVUE
176
+ if (page && selector && scrollTop) {
177
+ this._in = {
178
+ page,
179
+ selector,
180
+ scrollTop
181
+ }
182
+ }
183
+ // #endif
184
+ },
185
+
186
+ /**
187
+ * @description 锚点跳转
188
+ * @param {String} id 要跳转的锚点 id
189
+ * @param {Number} offset 跳转位置的偏移量
190
+ * @returns {Promise}
191
+ */
192
+ navigateTo(id, offset) {
193
+ return new Promise((resolve, reject) => {
194
+ if (!this.useAnchor) {
195
+ reject(Error('Anchor is disabled'))
196
+ return
197
+ }
198
+ offset = offset || parseInt(this.useAnchor) || 0
199
+ // #ifdef APP-PLUS-NVUE
200
+ if (!id) {
201
+ dom.scrollToElement(this.$refs.web, {
202
+ offset
203
+ })
204
+ resolve()
205
+ } else {
206
+ this._navigateTo = {
207
+ resolve,
208
+ reject,
209
+ offset
210
+ }
211
+ this.$refs.web.evalJs('uni.postMessage({data:{action:"getOffset",offset:(document.getElementById(' + id + ')||{}).offsetTop}})')
212
+ }
213
+ // #endif
214
+ // #ifndef APP-PLUS-NVUE
215
+ let deep = ' '
216
+ // #ifdef MP-WEIXIN || MP-QQ || MP-TOUTIAO
217
+ deep = '>>>'
218
+ // #endif
219
+ const selector = uni.createSelectorQuery()
220
+ // #ifndef MP-ALIPAY
221
+ .in(this._in ? this._in.page : this)
222
+ // #endif
223
+ .select((this._in ? this._in.selector : '._root') + (id ? `${deep}#${id}` : '')).boundingClientRect()
224
+ if (this._in) {
225
+ selector.select(this._in.selector).scrollOffset()
226
+ .select(this._in.selector).boundingClientRect()
227
+ } else {
228
+ // 获取 scroll-view 的位置和滚动距离
229
+ selector.selectViewport().scrollOffset() // 获取窗口的滚动距离
230
+ }
231
+ selector.exec(res => {
232
+ if (!res[0]) {
233
+ reject(Error('Label not found'))
234
+ return
235
+ }
236
+ const scrollTop = res[1].scrollTop + res[0].top - (res[2] ? res[2].top : 0) + offset
237
+ if (this._in) {
238
+ // scroll-view 跳转
239
+ this._in.page[this._in.scrollTop] = scrollTop
240
+ } else {
241
+ // 页面跳转
242
+ uni.pageScrollTo({
243
+ scrollTop,
244
+ duration: 300
245
+ })
246
+ }
247
+ resolve()
248
+ })
249
+ // #endif
250
+ })
251
+ },
252
+
253
+ /**
254
+ * @description 获取文本内容
255
+ * @return {String}
256
+ */
257
+ getText(nodes) {
258
+ let text = '';
259
+ (function traversal(nodes) {
260
+ for (let i = 0; i < nodes.length; i++) {
261
+ const node = nodes[i]
262
+ if (node.type === 'text') {
263
+ text += node.text.replace(/&amp;/g, '&')
264
+ } else if (node.name === 'br') {
265
+ text += '\n'
266
+ } else {
267
+ // 块级标签前后加换行
268
+ 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')
269
+ if (isBlock && text && text[text.length - 1] !== '\n') {
270
+ text += '\n'
271
+ }
272
+ // 递归获取子节点的文本
273
+ if (node.children) {
274
+ traversal(node.children)
275
+ }
276
+ if (isBlock && text[text.length - 1] !== '\n') {
277
+ text += '\n'
278
+ } else if (node.name === 'td' || node.name === 'th') {
279
+ text += '\t'
280
+ }
281
+ }
282
+ }
283
+ })(nodes || this.nodes)
284
+ return text
285
+ },
286
+
287
+ /**
288
+ * @description 获取内容大小和位置
289
+ * @return {Promise}
290
+ */
291
+ getRect() {
292
+ return new Promise((resolve, reject) => {
293
+ uni.createSelectorQuery()
294
+ // #ifndef MP-ALIPAY
295
+ .in(this)
296
+ // #endif
297
+ .select('#_root').boundingClientRect().exec(res => res[0] ? resolve(res[0]) : reject(Error('Root label not found')))
298
+ })
299
+ },
300
+
301
+ /**
302
+ * @description 暂停播放媒体
303
+ */
304
+ pauseMedia() {
305
+ for (let i = (this._videos || []).length; i--;) {
306
+ this._videos[i].pause()
307
+ }
308
+ // #ifdef APP-PLUS
309
+ const command = 'for(var e=document.getElementsByTagName("video"),i=e.length;i--;)e[i].pause()'
310
+ // #ifndef APP-PLUS-NVUE
311
+ let page = this.$parent
312
+ while (!page.$scope) page = page.$parent
313
+ page.$scope.$getAppWebview().evalJS(command)
314
+ // #endif
315
+ // #ifdef APP-PLUS-NVUE
316
+ this.$refs.web.evalJs(command)
317
+ // #endif
318
+ // #endif
319
+ },
320
+
321
+ /**
322
+ * @description 设置媒体播放速率
323
+ * @param {Number} rate 播放速率
324
+ */
325
+ setPlaybackRate(rate) {
326
+ this.playbackRate = rate
327
+ for (let i = (this._videos || []).length; i--;) {
328
+ this._videos[i].playbackRate(rate)
329
+ }
330
+ // #ifdef APP-PLUS
331
+ const command = 'for(var e=document.getElementsByTagName("video"),i=e.length;i--;)e[i].playbackRate=' + rate
332
+ // #ifndef APP-PLUS-NVUE
333
+ let page = this.$parent
334
+ while (!page.$scope) page = page.$parent
335
+ page.$scope.$getAppWebview().evalJS(command)
336
+ // #endif
337
+ // #ifdef APP-PLUS-NVUE
338
+ this.$refs.web.evalJs(command)
339
+ // #endif
340
+ // #endif
341
+ },
342
+
343
+ /**
344
+ * @description 设置内容
345
+ * @param {String} content html 内容
346
+ * @param {Boolean} append 是否在尾部追加
347
+ */
348
+ setContent(content, append) {
349
+ if (!append || !this.imgList) {
350
+ this.imgList = []
351
+ }
352
+ const nodes = new Parser(this).parse(content)
353
+ // #ifdef APP-PLUS-NVUE
354
+ if (this._ready) {
355
+ this._set(nodes, append)
356
+ }
357
+ // #endif
358
+ this.$set(this, 'nodes', append ? (this.nodes || []).concat(nodes) : nodes)
359
+
360
+ // #ifndef APP-PLUS-NVUE
361
+ this._videos = []
362
+ this.$nextTick(() => {
363
+ this._hook('onLoad')
364
+ this.$emit('load')
365
+ })
366
+
367
+ if (this.lazyLoad || this.imgList._unloadimgs < this.imgList.length / 2) {
368
+ // 设置懒加载,每 350ms 获取高度,不变则认为加载完毕
369
+ let height = 0
370
+ const callback = rect => {
371
+ if (!rect || !rect.height) rect = {}
372
+ // 350ms 总高度无变化就触发 ready 事件
373
+ if (rect.height === height) {
374
+ this.$emit('ready', rect)
375
+ } else {
376
+ height = rect.height
377
+ setTimeout(() => {
378
+ this.getRect().then(callback).catch(callback)
379
+ }, 350)
380
+ }
381
+ }
382
+ this.getRect().then(callback).catch(callback)
383
+ } else {
384
+ // 未设置懒加载,等待所有图片加载完毕
385
+ if (!this.imgList._unloadimgs) {
386
+ this.getRect().then(rect => {
387
+ this.$emit('ready', rect)
388
+ }).catch(() => {
389
+ this.$emit('ready', {})
390
+ })
391
+ }
392
+ }
393
+ // #endif
394
+ },
395
+
396
+ /**
397
+ * @description 调用插件钩子函数
398
+ */
399
+ _hook(name) {
400
+ for (let i = plugins.length; i--;) {
401
+ if (this.plugins[i][name]) {
402
+ this.plugins[i][name]()
403
+ }
404
+ }
405
+ },
406
+
407
+ // #ifdef APP-PLUS-NVUE
408
+ /**
409
+ * @description 设置内容
410
+ */
411
+ _set(nodes, append) {
412
+ 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 + ')')
413
+ },
414
+
415
+ /**
416
+ * @description 接收到 web-view 消息
417
+ */
418
+ _onMessage(e) {
419
+ const message = e.detail.data[0]
420
+ switch (message.action) {
421
+ // web-view 初始化完毕
422
+ case 'onJSBridgeReady':
423
+ this._ready = true
424
+ if (this.nodes) {
425
+ this._set(this.nodes)
426
+ }
427
+ break
428
+ // 内容 dom 加载完毕
429
+ case 'onLoad':
430
+ this.height = message.height
431
+ this._hook('onLoad')
432
+ this.$emit('load')
433
+ break
434
+ // 所有图片加载完毕
435
+ case 'onReady':
436
+ this.getRect().then(res => {
437
+ this.$emit('ready', res)
438
+ }).catch(() => {
439
+ this.$emit('ready', {})
440
+ })
441
+ break
442
+ // 总高度发生变化
443
+ case 'onHeightChange':
444
+ this.height = message.height
445
+ break
446
+ // 图片点击
447
+ case 'onImgTap':
448
+ this.$emit('imgtap', message.attrs)
449
+ if (this.previewImg) {
450
+ uni.previewImage({
451
+ current: parseInt(message.attrs.i),
452
+ urls: this.imgList
453
+ })
454
+ }
455
+ break
456
+ // 链接点击
457
+ case 'onLinkTap': {
458
+ const href = this.normalizeHref(message.attrs.href)
459
+ this.$emit('linktap', message.attrs)
460
+ if (href) {
461
+ // 锚点跳转
462
+ if (href[0] === '#') {
463
+ if (this.useAnchor) {
464
+ dom.scrollToElement(this.$refs.web, {
465
+ offset: message.offset
466
+ })
467
+ }
468
+ } else if (this.isExternalLink(href)) {
469
+ // 打开外链
470
+ if (this.copyLink) {
471
+ this.openExternalLink(href)
472
+ }
473
+ } else {
474
+ uni.navigateTo({
475
+ url: href,
476
+ fail() {
477
+ uni.switchTab({
478
+ url: href
479
+ })
480
+ }
481
+ })
482
+ }
483
+ }
484
+ break
485
+ }
486
+ case 'onPlay':
487
+ this.$emit('play')
488
+ break
489
+ // 获取到锚点的偏移量
490
+ case 'getOffset':
491
+ if (typeof message.offset === 'number') {
492
+ dom.scrollToElement(this.$refs.web, {
493
+ offset: message.offset + this._navigateTo.offset
494
+ })
495
+ this._navigateTo.resolve()
496
+ } else {
497
+ this._navigateTo.reject(Error('Label not found'))
498
+ }
499
+ break
500
+ // 点击
501
+ case 'onClick':
502
+ this.$emit('tap')
503
+ this.$emit('click')
504
+ break
505
+ // 出错
506
+ case 'onError':
507
+ this.$emit('error', {
508
+ source: message.source,
509
+ attrs: message.attrs
510
+ })
511
+ }
512
+ }
513
+ // #endif
514
+ }
515
+ }
516
+ </script>
517
+
518
+ <style>
519
+ /* #ifndef APP-PLUS-NVUE */
520
+ /* 根节点样式 */
521
+ ._root {
522
+ padding: 1px 0;
523
+ overflow-x: auto;
524
+ overflow-y: hidden;
525
+ -webkit-overflow-scrolling: touch;
526
+ }
527
+
528
+ /* 长按复制 */
529
+ ._select {
530
+ user-select: text;
531
+ }
532
+
533
+ /* #endif */
534
+ </style>
@@ -0,0 +1,26 @@
1
+ // 行内标签列表(wxs 运行于视图层,无法用 ES Module)
2
+ var inlineTags = {
3
+ abbr: true,
4
+ b: true,
5
+ big: true,
6
+ code: true,
7
+ del: true,
8
+ em: true,
9
+ i: true,
10
+ ins: true,
11
+ label: true,
12
+ q: true,
13
+ small: true,
14
+ span: true,
15
+ strong: true,
16
+ sub: true,
17
+ sup: true
18
+ }
19
+ /**
20
+ * @description 判断是否为行内标签
21
+ */
22
+ module.exports = {
23
+ isInline: function (tagName, style) {
24
+ return inlineTags[tagName] || (style || '').indexOf('display:inline') !== -1
25
+ }
26
+ }