@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,603 @@
1
+ <template>
2
+ <wxs module="handler" src="./handler.wxs" />
3
+ <view :id="attrs.id" :class="'_block _'+name+' '+attrs.class" :style="attrs.style">
4
+ <block v-for="(n, i) in childs" v-bind:key="i">
5
+ <!-- 图片 -->
6
+ <!-- 占位图 -->
7
+ <image v-if="n.name==='img'&&!n.t&&((opts[1]&&!ctrl[i])||ctrl[i]<0)" class="_img" :style="n.attrs.style" :src="ctrl[i]<0?opts[2]:opts[1]" mode="widthFix" />
8
+ <!-- 显示图片 -->
9
+ <!-- #ifdef H5 || (APP-PLUS && VUE2) -->
10
+ <img v-if="n.name==='img'" :id="n.attrs.id" :class="'_img '+n.attrs.class" :style="(ctrl[i]===-1?'display:none;':'')+n.attrs.style" :src="n.attrs.src||(ctrl.load?n.attrs['data-src']:'')" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap" @longpress="imgLongTap" />
11
+ <!-- #endif -->
12
+ <!-- #ifndef H5 || (APP-PLUS && VUE2) -->
13
+ <!-- 表格中的图片,使用 rich-text 防止大小不正确 -->
14
+ <rich-text v-if="n.name==='img'&&n.t" :style="'display:'+n.t" :nodes="[{attrs:{style:n.attrs.style||'',src:n.attrs.src},name:'img'}]" :data-i="i" @tap.stop="imgTap" />
15
+ <!-- #endif -->
16
+ <!-- #ifdef APP-HARMONY -->
17
+ <image v-else-if="n.name==='img'" :id="n.attrs.id" :class="'_img '+n.attrs.class" :style="(ctrl[i]===-1?'display:none;':'')+'width:'+ctrl[i]+'px;'+n.attrs.style" :src="n.attrs.src||(ctrl.load?n.attrs['data-src']:'')" :mode="!n.h?'widthFix':(!n.w?'heightFix':(n.m||'scaleToFill'))" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap" @longpress="imgLongTap" />
18
+ <!-- #endif -->
19
+ <!-- #ifndef H5 || APP-PLUS || MP-KUAISHOU -->
20
+ <image v-else-if="n.name==='img'" :id="n.attrs.id" :class="'_img '+n.attrs.class" :style="(ctrl[i]===-1?'display:none;':'')+'width:'+(ctrl[i]||1)+'px;height:1px;'+n.attrs.style" :src="n.attrs.src" :mode="!n.h?'widthFix':(!n.w?'heightFix':(n.m||'scaleToFill'))" :lazy-load="opts[0]" :webp="n.webp" :show-menu-by-longpress="opts[3]&&!n.attrs.ignore" :image-menu-prevent="!opts[3]||n.attrs.ignore" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap" @longpress="imgLongTap" />
21
+ <!-- #endif -->
22
+ <!-- #ifdef MP-KUAISHOU -->
23
+ <image v-else-if="n.name==='img'" :id="n.attrs.id" :class="'_img '+n.attrs.class" :style="(ctrl[i]===-1?'display:none;':'')+n.attrs.style" :src="n.attrs.src" :lazy-load="opts[0]" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap"></image>
24
+ <!-- #endif -->
25
+ <!-- #ifdef APP-PLUS && VUE3 -->
26
+ <image v-else-if="n.name==='img'" :id="n.attrs.id" :class="'_img '+n.attrs.class" :style="(ctrl[i]===-1?'display:none;':'')+'width:'+(ctrl[i]||1)+'px;'+n.attrs.style" :src="n.attrs.src||(ctrl.load?n.attrs['data-src']:'')" :mode="!n.h?'widthFix':(!n.w?'heightFix':(n.m||''))" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap" @longpress="imgLongTap" />
27
+ <!-- #endif -->
28
+ <!-- 文本 -->
29
+ <!-- #ifdef MP-WEIXIN -->
30
+ <text v-else-if="n.text" :user-select="opts[4]=='force'&&isiOS" decode>{{n.text}}</text>
31
+ <!-- #endif -->
32
+ <!-- #ifndef MP-WEIXIN || MP-BAIDU || MP-ALIPAY || MP-TOUTIAO -->
33
+ <text v-else-if="n.text" decode>{{n.text}}</text>
34
+ <!-- #endif -->
35
+ <text v-else-if="n.name==='br'">{{'\n'}}</text>
36
+ <!-- 链接 -->
37
+ <view v-else-if="n.name==='a'" :id="n.attrs.id" :class="(n.attrs.href?'_a ':'')+n.attrs.class" hover-class="_hover" :style="'display:inline;'+n.attrs.style" :data-i="i" @tap.stop="linkTap">
38
+ <node name="span" :childs="n.children" :opts="opts" style="display:inherit" />
39
+ </view>
40
+ <!-- 视频 -->
41
+ <!-- #ifdef APP-PLUS -->
42
+ <view v-else-if="n.html" :id="n.attrs.id" :class="'_video '+n.attrs.class" :style="n.attrs.style" v-html="n.html" :data-i="i" @vplay.stop="play" />
43
+ <!-- #endif -->
44
+ <!-- #ifndef APP-PLUS -->
45
+ <video v-else-if="n.name==='video'" :id="n.attrs.id" :class="n.attrs.class" :style="n.attrs.style" :autoplay="n.attrs.autoplay" :controls="n.attrs.controls" :loop="n.attrs.loop" :muted="n.attrs.muted" :object-fit="n.attrs['object-fit']" :poster="n.attrs.poster" :src="n.src[ctrl[i]||0]" :data-i="i" @play="play" @error="mediaError" />
46
+ <!-- #endif -->
47
+ <!-- #ifdef H5 || APP-PLUS -->
48
+ <iframe v-else-if="n.name==='iframe'" :style="n.attrs.style" :allowfullscreen="n.attrs.allowfullscreen" :frameborder="n.attrs.frameborder" :src="n.attrs.src" />
49
+ <embed v-else-if="n.name==='embed'" :style="n.attrs.style" :src="n.attrs.src" />
50
+ <!-- #endif -->
51
+ <!-- #ifndef MP-TOUTIAO || ((H5 || APP-PLUS) && VUE3) -->
52
+ <!-- 音频 -->
53
+ <audio v-else-if="n.name==='audio'" :id="n.attrs.id" :class="n.attrs.class" :style="n.attrs.style" :author="n.attrs.author" :controls="n.attrs.controls" :loop="n.attrs.loop" :name="n.attrs.name" :poster="n.attrs.poster" :src="n.src[ctrl[i]||0]" :data-i="i" @play="play" @error="mediaError" />
54
+ <!-- #endif -->
55
+ <view v-else-if="(n.name==='table'&&n.c)||n.name==='li'" :id="n.attrs.id" :class="'_'+n.name+' '+n.attrs.class" :style="n.attrs.style">
56
+ <node v-if="n.name==='li'" :childs="n.children" :opts="opts" />
57
+ <view v-else v-for="(tbody, x) in n.children" v-bind:key="x" :class="'_'+tbody.name+' '+tbody.attrs.class" :style="tbody.attrs.style">
58
+ <node v-if="tbody.name==='td'||tbody.name==='th'" :childs="tbody.children" :opts="opts" />
59
+ <block v-else v-for="(tr, y) in tbody.children" v-bind:key="y">
60
+ <view v-if="tr.name==='td'||tr.name==='th'" :class="'_'+tr.name+' '+tr.attrs.class" :style="tr.attrs.style">
61
+ <node :childs="tr.children" :opts="opts" />
62
+ </view>
63
+ <view v-else :class="'_'+tr.name+' '+tr.attrs.class" :style="tr.attrs.style">
64
+ <view v-for="(td, z) in tr.children" v-bind:key="z" :class="'_'+td.name+' '+td.attrs.class" :style="td.attrs.style">
65
+ <node :childs="td.children" :opts="opts" />
66
+ </view>
67
+ </view>
68
+ </block>
69
+ </view>
70
+ </view>
71
+ <!-- insert -->
72
+ <!-- 富文本 -->
73
+ <!-- #ifdef H5 || ((MP-WEIXIN || MP-QQ || APP-PLUS || MP-360) && VUE2) -->
74
+ <rich-text v-else-if="!n.c&&!handler.isInline(n.name, n.attrs.style)" :id="n.attrs.id" :style="n.f" :user-select="opts[4]" :nodes="[n]" />
75
+ <!-- #endif -->
76
+ <!-- #ifndef H5 || ((MP-WEIXIN || MP-QQ || APP-PLUS || MP-360) && VUE2) -->
77
+ <rich-text v-else-if="!n.c" :id="n.attrs.id" :style="'display:inline;'+n.f" :preview="false" :selectable="opts[4]" :user-select="opts[4]" :nodes="[n]" />
78
+ <!-- #endif -->
79
+ <!-- 继续递归 -->
80
+ <view v-else-if="n.c===2" :id="n.attrs.id" :class="'_block _'+n.name+' '+n.attrs.class" :style="n.f+';'+n.attrs.style">
81
+ <node v-for="(n2, j) in n.children" v-bind:key="j" :style="n2.f" :name="n2.name" :attrs="n2.attrs" :childs="n2.children" :opts="opts" />
82
+ </view>
83
+ <node v-else :style="n.f" :name="n.name" :attrs="n.attrs" :childs="n.children" :opts="opts" />
84
+ </block>
85
+ </view>
86
+ </template>
87
+ <script>
88
+ import node from './node'
89
+ export default {
90
+ name: 'node',
91
+ options: {
92
+ // #ifdef MP-WEIXIN
93
+ virtualHost: true,
94
+ // #endif
95
+ // #ifdef MP-TOUTIAO
96
+ addGlobalClass: false
97
+ // #endif
98
+ },
99
+ data () {
100
+ return {
101
+ ctrl: {},
102
+ // #ifdef MP-WEIXIN
103
+ isiOS: uni.getSystemInfoSync().system.includes('iOS')
104
+ // #endif
105
+ }
106
+ },
107
+ props: {
108
+ name: String,
109
+ attrs: {
110
+ type: Object,
111
+ default () {
112
+ return {}
113
+ }
114
+ },
115
+ childs: Array,
116
+ opts: Array
117
+ },
118
+ components: {
119
+ // #ifndef ((H5 || APP-PLUS) && VUE3) || APP-HARMONY
120
+ node
121
+ // #endif
122
+ },
123
+ mounted () {
124
+ this.$nextTick(() => {
125
+ // 修复可能导致死循环的问题
126
+ for (this.root = this?.$parent; this.root && this.root?.$options.name !== 'dd-parse'; this.root = this.root?.$parent);
127
+ })
128
+ // #ifdef H5 || APP-PLUS
129
+ if (this.opts[0]) {
130
+ let i
131
+ for (i = this.childs.length; i--;) {
132
+ if (this.childs[i].name === 'img') break
133
+ }
134
+ if (i !== -1) {
135
+ this.observer = uni.createIntersectionObserver(this).relativeToViewport({
136
+ top: 500,
137
+ bottom: 500
138
+ })
139
+ this.observer.observe('._img', res => {
140
+ if (res.intersectionRatio) {
141
+ this.ctrl.load = 1
142
+ this.observer.disconnect()
143
+ }
144
+ })
145
+ }
146
+ }
147
+ // #endif
148
+ },
149
+ beforeUnmount () {
150
+ // #ifdef H5 || APP-PLUS
151
+ if (this.observer) {
152
+ this.observer.disconnect()
153
+ }
154
+ // #endif
155
+ },
156
+ emits: ['linktap', 'imgtap', 'play', 'ready', 'error'],
157
+ methods: {
158
+ // #ifdef MP-WEIXIN
159
+ toJSON () { return this },
160
+ // #endif
161
+ /**
162
+ * @description 规范化链接地址
163
+ * @param {any} href
164
+ * @return {String}
165
+ */
166
+ normalizeHref (href) {
167
+ return typeof href === 'string' ? href.trim() : ''
168
+ },
169
+
170
+ /**
171
+ * @description 判断是否为外部链接
172
+ * @param {String} href
173
+ * @return {Boolean}
174
+ */
175
+ isExternalLink (href) {
176
+ return href.split('?')[0].includes('://')
177
+ },
178
+
179
+ /**
180
+ * @description 打开外部链接
181
+ * @param {String} href
182
+ */
183
+ openExternalLink (href) {
184
+ // #ifdef H5
185
+ window.open(href)
186
+ // #endif
187
+ // #ifdef MP
188
+ uni.setClipboardData({
189
+ data: href,
190
+ success: () =>
191
+ uni.showToast({
192
+ title: '链接已复制'
193
+ })
194
+ })
195
+ // #endif
196
+ // #ifdef APP-PLUS
197
+ try {
198
+ plus.runtime.openWeb(href)
199
+ } catch (e) { }
200
+ // #endif
201
+ // #ifdef APP-HARMONY
202
+ try {
203
+ plus.runtime.openURL(href)
204
+ } catch (e) { }
205
+ // #endif
206
+ },
207
+
208
+ /**
209
+ * @description 播放视频事件
210
+ * @param {Event} e
211
+ */
212
+ play (e) {
213
+ const i = e.currentTarget.dataset.i
214
+ const node = this.childs[i]
215
+ this.root.$emit('play', {
216
+ source: node.name,
217
+ attrs: {
218
+ ...node.attrs,
219
+ src: node.src[this.ctrl[i] || 0]
220
+ }
221
+ })
222
+ // #ifndef APP-PLUS
223
+ if (this.root.pauseVideo) {
224
+ let flag = false
225
+ const id = e.target.id
226
+ for (let i = this.root._videos.length; i--;) {
227
+ if (this.root._videos[i].id === id) {
228
+ flag = true
229
+ } else {
230
+ this.root._videos[i].pause() // 自动暂停其他视频
231
+ }
232
+ }
233
+ // 将自己加入列表
234
+ if (!flag) {
235
+ const ctx = uni.createVideoContext(id
236
+ // #ifndef MP-BAIDU
237
+ , this
238
+ // #endif
239
+ )
240
+ ctx.id = id
241
+ if (this.root.playbackRate) {
242
+ ctx.playbackRate(this.root.playbackRate)
243
+ }
244
+ this.root._videos.push(ctx)
245
+ }
246
+ }
247
+ // #endif
248
+ },
249
+
250
+ /**
251
+ * @description 图片点击事件
252
+ * @param {Event} e
253
+ */
254
+ imgTap (e) {
255
+ const node = this.childs[e.currentTarget.dataset.i]
256
+ if (node.a) {
257
+ this.linkTap(node.a)
258
+ return
259
+ }
260
+ if (node.attrs.ignore) return
261
+ // #ifdef H5 || APP-PLUS
262
+ node.attrs.src = node.attrs.src || node.attrs['data-src']
263
+ // #endif
264
+ // #ifndef APP-HARMONY
265
+ this.root.$emit('imgtap', node.attrs)
266
+ // #endif
267
+ // #ifdef APP-HARMONY
268
+ this.root.$emit('imgtap', {
269
+ ...node.attrs
270
+ })
271
+ // #endif
272
+ // 自动预览图片
273
+ if (this.root.previewImg) {
274
+ uni.previewImage({
275
+ // #ifdef MP-WEIXIN
276
+ showmenu: this.root.showImgMenu,
277
+ // #endif
278
+ // #ifdef MP-ALIPAY
279
+ enablesavephoto: this.root.showImgMenu,
280
+ enableShowPhotoDownload: this.root.showImgMenu,
281
+ // #endif
282
+ current: parseInt(node.attrs.i),
283
+ urls: this.root.imgList
284
+ })
285
+ }
286
+ },
287
+
288
+ /**
289
+ * @description 图片长按
290
+ */
291
+ imgLongTap (e) {
292
+ // #ifdef APP-PLUS
293
+ const attrs = this.childs[e.currentTarget.dataset.i].attrs
294
+ if (this.opts[3] && !attrs.ignore) {
295
+ uni.showActionSheet({
296
+ itemList: ['保存图片'],
297
+ success: () => {
298
+ const save = path => {
299
+ uni.saveImageToPhotosAlbum({
300
+ filePath: path,
301
+ success () {
302
+ uni.showToast({
303
+ title: '保存成功'
304
+ })
305
+ }
306
+ })
307
+ }
308
+ if (this.root.imgList[attrs.i].startsWith('http')) {
309
+ uni.downloadFile({
310
+ url: this.root.imgList[attrs.i],
311
+ success: res => save(res.tempFilePath)
312
+ })
313
+ } else {
314
+ save(this.root.imgList[attrs.i])
315
+ }
316
+ }
317
+ })
318
+ }
319
+ // #endif
320
+ },
321
+
322
+ /**
323
+ * @description 图片加载完成事件
324
+ * @param {Event} e
325
+ */
326
+ imgLoad (e) {
327
+ const i = e.currentTarget.dataset.i
328
+ /* #ifndef H5 || (APP-PLUS && VUE2) */
329
+ if (!this.childs[i].w) {
330
+ // 设置原宽度
331
+ this.ctrl[i] = e.detail.width
332
+ } else /* #endif */ if ((this.opts[1] && !this.ctrl[i]) || this.ctrl[i] === -1) {
333
+ // 加载完毕,取消加载中占位图
334
+ this.ctrl[i] = 1
335
+ }
336
+ this.checkReady()
337
+ },
338
+
339
+ /**
340
+ * @description 检查是否所有图片加载完毕
341
+ */
342
+ checkReady () {
343
+ if (this.root && !this.root.lazyLoad) {
344
+ this.root._unloadimgs -= 1
345
+ if (!this.root._unloadimgs) {
346
+ setTimeout(() => {
347
+ this.root.getRect().then(rect => {
348
+ this.root.$emit('ready', rect)
349
+ }).catch(() => {
350
+ this.root.$emit('ready', {})
351
+ })
352
+ }, 350)
353
+ }
354
+ }
355
+ },
356
+
357
+ /**
358
+ * @description 链接点击事件
359
+ * @param {Event} e
360
+ */
361
+ linkTap (e) {
362
+ const node = e.currentTarget ? this.childs[e.currentTarget.dataset.i] : {}
363
+ const attrs = node.attrs || e
364
+ const href = this.normalizeHref(attrs.href)
365
+ this.root.$emit('linktap', Object.assign({
366
+ innerText: this.root.getText(node.children || []) // 链接内的文本内容
367
+ }, attrs))
368
+ if (href) {
369
+ if (href[0] === '#') {
370
+ // 跳转锚点
371
+ this.root.navigateTo(href.substring(1)).catch(() => { })
372
+ } else if (this.isExternalLink(href)) {
373
+ // 复制外部链接
374
+ if (this.root.copyLink) {
375
+ this.openExternalLink(href)
376
+ }
377
+ } else {
378
+ // 跳转页面
379
+ uni.navigateTo({
380
+ url: href,
381
+ fail () {
382
+ uni.switchTab({
383
+ url: href,
384
+ fail () { }
385
+ })
386
+ }
387
+ })
388
+ }
389
+ }
390
+ },
391
+
392
+ /**
393
+ * @description 错误事件
394
+ * @param {Event} e
395
+ */
396
+ mediaError (e) {
397
+ const i = e.currentTarget.dataset.i
398
+ const node = this.childs[i]
399
+ // 加载其他源
400
+ if (node.name === 'video' || node.name === 'audio') {
401
+ let index = (this.ctrl[i] || 0) + 1
402
+ if (index > node.src.length) {
403
+ index = 0
404
+ }
405
+ if (index < node.src.length) {
406
+ this.ctrl[i] = index
407
+ return
408
+ }
409
+ } else if (node.name === 'img') {
410
+ // #ifdef H5 && VUE3
411
+ if (this.opts[0] && !this.ctrl.load) return
412
+ // #endif
413
+ // 显示错误占位图
414
+ if (this.opts[2]) {
415
+ this.ctrl[i] = -1
416
+ }
417
+ this.checkReady()
418
+ }
419
+ if (this.root) {
420
+ this.root.$emit('error', {
421
+ source: node.name,
422
+ attrs: node.attrs,
423
+ // #ifndef H5 && VUE3
424
+ errMsg: e.detail.errMsg
425
+ // #endif
426
+ })
427
+ }
428
+ }
429
+ }
430
+ }
431
+ </script>
432
+ <style>
433
+ /* a 标签默认效果 */
434
+ ._a {
435
+ padding: 1.5px 0 1.5px 0;
436
+ color: #366092;
437
+ word-break: break-all;
438
+ }
439
+
440
+ /* a 标签点击态效果 */
441
+ ._hover {
442
+ text-decoration: underline;
443
+ opacity: 0.7;
444
+ }
445
+
446
+ /* 图片默认效果 */
447
+ ._img {
448
+ max-width: 100%;
449
+ -webkit-touch-callout: none;
450
+ }
451
+
452
+ /* 内部样式 */
453
+
454
+ ._block {
455
+ display: block;
456
+ }
457
+
458
+ ._b,
459
+ ._strong {
460
+ font-weight: bold;
461
+ }
462
+
463
+ ._code {
464
+ font-family: monospace;
465
+ }
466
+
467
+ ._del {
468
+ text-decoration: line-through;
469
+ }
470
+
471
+ ._em,
472
+ ._i {
473
+ font-style: italic;
474
+ }
475
+
476
+ ._h1 {
477
+ font-size: 2em;
478
+ }
479
+
480
+ ._h2 {
481
+ font-size: 1.5em;
482
+ }
483
+
484
+ ._h3 {
485
+ font-size: 1.17em;
486
+ }
487
+
488
+ ._h5 {
489
+ font-size: 0.83em;
490
+ }
491
+
492
+ ._h6 {
493
+ font-size: 0.67em;
494
+ }
495
+
496
+ ._h1,
497
+ ._h2,
498
+ ._h3,
499
+ ._h4,
500
+ ._h5,
501
+ ._h6 {
502
+ display: block;
503
+ font-weight: bold;
504
+ }
505
+
506
+ ._image {
507
+ height: 1px;
508
+ }
509
+
510
+ ._ins {
511
+ text-decoration: underline;
512
+ }
513
+
514
+ ._li {
515
+ display: list-item;
516
+ }
517
+
518
+ ._ol {
519
+ list-style-type: decimal;
520
+ }
521
+
522
+ ._ol,
523
+ ._ul {
524
+ display: block;
525
+ padding-left: 40px;
526
+ margin: 1em 0;
527
+ }
528
+
529
+ ._q::before {
530
+ content: '"';
531
+ }
532
+
533
+ ._q::after {
534
+ content: '"';
535
+ }
536
+
537
+ ._sub {
538
+ font-size: smaller;
539
+ vertical-align: sub;
540
+ }
541
+
542
+ ._sup {
543
+ font-size: smaller;
544
+ vertical-align: super;
545
+ }
546
+
547
+ ._thead,
548
+ ._tbody,
549
+ ._tfoot {
550
+ display: table-row-group;
551
+ }
552
+
553
+ ._tr {
554
+ display: table-row;
555
+ }
556
+
557
+ ._td,
558
+ ._th {
559
+ display: table-cell;
560
+ vertical-align: middle;
561
+ }
562
+
563
+ ._th {
564
+ font-weight: bold;
565
+ text-align: center;
566
+ }
567
+
568
+ ._ul {
569
+ list-style-type: disc;
570
+ }
571
+
572
+ ._ul ._ul {
573
+ margin: 0;
574
+ list-style-type: circle;
575
+ }
576
+
577
+ ._ul ._ul ._ul {
578
+ list-style-type: square;
579
+ }
580
+
581
+ ._abbr,
582
+ ._b,
583
+ ._code,
584
+ ._del,
585
+ ._em,
586
+ ._i,
587
+ ._ins,
588
+ ._label,
589
+ ._q,
590
+ ._span,
591
+ ._strong,
592
+ ._sub,
593
+ ._sup {
594
+ display: inline;
595
+ }
596
+
597
+ /* #ifdef APP-PLUS */
598
+ ._video {
599
+ width: 300px;
600
+ height: 225px;
601
+ }
602
+ /* #endif */
603
+ </style>
@@ -0,0 +1,13 @@
1
+ export default {
2
+ // parse
3
+ parse: {
4
+ copyLink: true,
5
+ errorImg: '',
6
+ lazyLoad: false,
7
+ loadingImg: '',
8
+ pauseVideo: true,
9
+ previewImg: true,
10
+ setTitle: true,
11
+ showImgMenu: true
12
+ }
13
+ }