gxd-uni-library-editx 1.0.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 (215) hide show
  1. package/.editorconfig +14 -0
  2. package/README.md +447 -0
  3. package/index.js +3 -0
  4. package/package.json +104 -0
  5. package/postcss.config.js +22 -0
  6. package/settings.js.tpl +68 -0
  7. package/src/XdAppClass.1.0.js +257 -0
  8. package/src/XdAppClass.js +150 -0
  9. package/src/components/XdAddress/XdAddress.vue +579 -0
  10. package/src/components/XdAddressSelect/XdAddressSelect.vue +243 -0
  11. package/src/components/XdBaiduMap/XdBaiduMap.vue +204 -0
  12. package/src/components/XdBaiduOverlay/XdBaiduOverlay.vue +345 -0
  13. package/src/components/XdBaiduSearch/XdBaiduSearch.vue +354 -0
  14. package/src/components/XdBar/XdBar.vue +339 -0
  15. package/src/components/XdButton/XdButton.vue +288 -0
  16. package/src/components/XdCartList/XdCartList.vue +791 -0
  17. package/src/components/XdCartNoStoreList/XdCartNoStoreList.vue +747 -0
  18. package/src/components/XdCity/XdCity.vue +620 -0
  19. package/src/components/XdCity/city.js +93 -0
  20. package/src/components/XdCity/testData.js +124 -0
  21. package/src/components/XdCityLocation/XdCityLocation.vue +314 -0
  22. package/src/components/XdCityLocation/jweixin.js +72 -0
  23. package/src/components/XdCityShow/XdCityShow.vue +354 -0
  24. package/src/components/XdClipImage/XdClipImage.vue +879 -0
  25. package/src/components/XdCoins/XdCoins.vue +66 -0
  26. package/src/components/XdConfirm/XdConfirm.vue +240 -0
  27. package/src/components/XdContentXss/XdContentXss.vue +71 -0
  28. package/src/components/XdDailog/XdDailog.vue +258 -0
  29. package/src/components/XdDate/XdDataItemOne.vue +236 -0
  30. package/src/components/XdDate/XdDate.vue +1081 -0
  31. package/src/components/XdDate/XdDateItem.vue +316 -0
  32. package/src/components/XdDate/XdDateTime.vue +929 -0
  33. package/src/components/XdDate/i18n/en.json +19 -0
  34. package/src/components/XdDate/i18n/index.js +8 -0
  35. package/src/components/XdDate/i18n/zh-Hans.json +19 -0
  36. package/src/components/XdDate/i18n/zh-Hant.json +19 -0
  37. package/src/components/XdDate/keypress.js +45 -0
  38. package/src/components/XdDate/util.js +418 -0
  39. package/src/components/XdDownDrawer/XdDownDrawer.vue +176 -0
  40. package/src/components/XdEditPwd/XdEditPwd.vue +305 -0
  41. package/src/components/XdEnterOrderList/XdEnterOrderList.vue +413 -0
  42. package/src/components/XdExpressTimeLine/XdExpressTimeLine.vue +280 -0
  43. package/src/components/XdFilter/XdFilter.vue +541 -0
  44. package/src/components/XdFontIcon/XdFontIcon.vue +165 -0
  45. package/src/components/XdFontIcon/css/icon.less +498 -0
  46. package/src/components/XdFooterBar/XdFooterBar.vue +291 -0
  47. package/src/components/XdFooterTabbar/XdFooterTabbar.vue +284 -0
  48. package/src/components/XdForm/XdForm.vue +481 -0
  49. package/src/components/XdForm/validate.js +486 -0
  50. package/src/components/XdFormCheckbox/XdFormCheckbox.vue +858 -0
  51. package/src/components/XdFormDate.vue +187 -0
  52. package/src/components/XdFormInput/XdFormInput.vue +535 -0
  53. package/src/components/XdFormInput/common.js +56 -0
  54. package/src/components/XdFormItem/XdFormItem.vue +583 -0
  55. package/src/components/XdFormSelect/XdFormSelect.vue +119 -0
  56. package/src/components/XdImage/XdImage.vue +113 -0
  57. package/src/components/XdItemCardUser/XdItemCardUser.vue +232 -0
  58. package/src/components/XdItemFilmImage/XdItemFilmImage.vue +146 -0
  59. package/src/components/XdItemFilmText/XdItemFilmText.vue +83 -0
  60. package/src/components/XdItemPhysical/XdItemPhysical.vue +410 -0
  61. package/src/components/XdItemPhysicalPack/XdItemPhysicalPack.vue +240 -0
  62. package/src/components/XdItemStore/XdItemStore.vue +236 -0
  63. package/src/components/XdItemUserInfo/XdItemUserInfo.vue +175 -0
  64. package/src/components/XdJson/XdJson.vue +398 -0
  65. package/src/components/XdKeyValue/XdKeyValue.vue +150 -0
  66. package/src/components/XdLabelNew/XdLabelNew.vue +193 -0
  67. package/src/components/XdLayout/XdLayout.vue +634 -0
  68. package/src/components/XdLoading/XdLoading.vue +165 -0
  69. package/src/components/XdMore/XdMore.vue +66 -0
  70. package/src/components/XdMpHtml/XdMpHtml.vue +458 -0
  71. package/src/components/XdMpHtml/node/node.vue +536 -0
  72. package/src/components/XdMpHtml/parser.js +1260 -0
  73. package/src/components/XdMpHtml/static/js/handler.js +1 -0
  74. package/src/components/XdMpHtml/static/js/uni.webview.min.js +1 -0
  75. package/src/components/XdMpHtml/static/local.html +1 -0
  76. package/src/components/XdMy/XdMy.vue +294 -0
  77. package/src/components/XdMySuccess/XdMySuccess.vue +603 -0
  78. package/src/components/XdNavTab/XdNavTab.vue +147 -0
  79. package/src/components/XdNoData/XdNoData.vue +87 -0
  80. package/src/components/XdNoticeBar/XdNoticeBar.vue +501 -0
  81. package/src/components/XdNumber/XdNumber.vue +210 -0
  82. package/src/components/XdNumberUni/XdNumberUni.vue +270 -0
  83. package/src/components/XdNumberUni/readme.md +42 -0
  84. package/src/components/XdOnlineConfirm/XdOnlineConfirm.vue +385 -0
  85. package/src/components/XdOnlineDetail/XdOnlineDetail.vue +332 -0
  86. package/src/components/XdOnlinePay/XdOnlinePay.vue +349 -0
  87. package/src/components/XdOnlineSchedule/XdOnlineSchedule.vue +453 -0
  88. package/src/components/XdOnlineSeat/XdOnlineSeat.vue +796 -0
  89. package/src/components/XdOnlineSeatMove/XdOnlineSeatMove.vue +1012 -0
  90. package/src/components/XdPayCombo/XdPayCombo.vue +118 -0
  91. package/src/components/XdPreviewImage/XdPreviewImage.vue +372 -0
  92. package/src/components/XdPwPay/XdPwPay.vue +214 -0
  93. package/src/components/XdRadio/XdRadio.vue +151 -0
  94. package/src/components/XdRangeSlider/XdRangeSlider.vue +355 -0
  95. package/src/components/XdRedName/XdRedName.vue +35 -0
  96. package/src/components/XdSearchBar/XdSearchBar.vue +286 -0
  97. package/src/components/XdSelect/XdSelect.vue +382 -0
  98. package/src/components/XdSelectCity/XdSelectCity.vue +270 -0
  99. package/src/components/XdSelectTime/XdSelectTime.vue +342 -0
  100. package/src/components/XdStar/XdStar.vue +261 -0
  101. package/src/components/XdStoreCashier/XdStoreCashier.vue +526 -0
  102. package/src/components/XdStoreItem/XdStoreItem.vue +400 -0
  103. package/src/components/XdStoreOrderDetail/XdStoreOrderDetail.vue +1571 -0
  104. package/src/components/XdStoreOrderList/XdStoreOrderList.vue +450 -0
  105. package/src/components/XdStoreProductInfo/XdStoreProductInfo.vue +940 -0
  106. package/src/components/XdStoreProductType/XdStoreProductType.vue +307 -0
  107. package/src/components/XdSuccess/XdSuccess.vue +527 -0
  108. package/src/components/XdSwipeSelect/XdSwipeSelect.vue +99 -0
  109. package/src/components/XdSwiper/XdSwiper.vue +124 -0
  110. package/src/components/XdSwitch/XdSwitch.vue +204 -0
  111. package/src/components/XdTab/XdTab.vue +220 -0
  112. package/src/components/XdTabScroll/XdTabScroll.vue +212 -0
  113. package/src/components/XdTag/XdTag.vue +423 -0
  114. package/src/components/XdTimeLine/XdTimeLine.vue +121 -0
  115. package/src/components/XdTips/XdTips.vue +212 -0
  116. package/src/components/XdTipsBlock/XdTipsBlock.vue +141 -0
  117. package/src/components/XdTitleSection/XdTitleSection.vue +152 -0
  118. package/src/components/XdTitleTab/XdTitleTab.vue +227 -0
  119. package/src/components/XdUnit/XdUnit.vue +206 -0
  120. package/src/components/XdUpload/XdUpload.vue +197 -0
  121. package/src/components/XdUploadImage/XdUploadImage.vue +145 -0
  122. package/src/components/Xdlogs/XdLogs.vue +144 -0
  123. package/src/components/autoload.js +211 -0
  124. package/src/components/swipeAction/UniSwipeAction.vue +43 -0
  125. package/src/components/swipeActionItem/UniSwipeActionItem.vue +386 -0
  126. package/src/components/swipeActionItem/bindingx.js +298 -0
  127. package/src/components/swipeActionItem/index.wxs +321 -0
  128. package/src/components/swipeActionItem/isPC.js +18 -0
  129. package/src/components/swipeActionItem/mpalipay.js +210 -0
  130. package/src/components/swipeActionItem/mpother.js +252 -0
  131. package/src/components/swipeActionItem/mpwxs.js +140 -0
  132. package/src/dome/dome/address.vue +415 -0
  133. package/src/dome/dome/auth/login.vue +166 -0
  134. package/src/dome/dome/baidu_show.vue +20 -0
  135. package/src/dome/dome/cake.vue +186 -0
  136. package/src/dome/dome/cart.vue +205 -0
  137. package/src/dome/dome/cart_store.vue +149 -0
  138. package/src/dome/dome/cashier/cashier.vue +73 -0
  139. package/src/dome/dome/cashier/check_cashier.vue +469 -0
  140. package/src/dome/dome/cashier/success.vue +127 -0
  141. package/src/dome/dome/city.vue +148 -0
  142. package/src/dome/dome/cityData.js +9 -0
  143. package/src/dome/dome/clip.vue +82 -0
  144. package/src/dome/dome/date/date.vue +273 -0
  145. package/src/dome/dome/date/selected.js +315 -0
  146. package/src/dome/dome/dcom/app1.vue +13 -0
  147. package/src/dome/dome/dcom/app2.vue +13 -0
  148. package/src/dome/dome/dcom/app3.vue +13 -0
  149. package/src/dome/dome/dcom/app4.vue +13 -0
  150. package/src/dome/dome/dcom/app5.vue +13 -0
  151. package/src/dome/dome/dcom/index.vue +1 -0
  152. package/src/dome/dome/debug/debug.vue +95 -0
  153. package/src/dome/dome/docache/docache.vue +88 -0
  154. package/src/dome/dome/express.vue +269 -0
  155. package/src/dome/dome/form.vue +312 -0
  156. package/src/dome/dome/icon.js +125 -0
  157. package/src/dome/dome/icon.vue +93 -0
  158. package/src/dome/dome/index.vue +725 -0
  159. package/src/dome/dome/item.vue +236 -0
  160. package/src/dome/dome/json/json.vue +88 -0
  161. package/src/dome/dome/layout.vue +105 -0
  162. package/src/dome/dome/line.vue +113 -0
  163. package/src/dome/dome/map/search.vue +70 -0
  164. package/src/dome/dome/my.vue +171 -0
  165. package/src/dome/dome/notice.vue +93 -0
  166. package/src/dome/dome/online/confirm.vue +92 -0
  167. package/src/dome/dome/online/detail.vue +80 -0
  168. package/src/dome/dome/online/pay.vue +78 -0
  169. package/src/dome/dome/online/schedule.vue +73 -0
  170. package/src/dome/dome/online/seat.vue +98 -0
  171. package/src/dome/dome/order/detail.vue +166 -0
  172. package/src/dome/dome/order/enter_order.vue +294 -0
  173. package/src/dome/dome/order/list.vue +219 -0
  174. package/src/dome/dome/order/order.js +18 -0
  175. package/src/dome/dome/order/success.vue +68 -0
  176. package/src/dome/dome/product.vue +179 -0
  177. package/src/dome/dome/store_cashier.vue +67 -0
  178. package/src/dome/dome/swiper.vue +32 -0
  179. package/src/dome/dome/webview.vue +61 -0
  180. package/src/install.js +183 -0
  181. package/src/main/address/address.vue +251 -0
  182. package/src/main/cart/cart.vue +149 -0
  183. package/src/main/cashier/cashier.vue +72 -0
  184. package/src/main/cashier/check_cashier.vue +483 -0
  185. package/src/main/city/city.vue +149 -0
  186. package/src/main/date/date.vue +260 -0
  187. package/src/main/order/order.js +19 -0
  188. package/src/main/order/order.vue +222 -0
  189. package/src/main/product/detail.vue +121 -0
  190. package/src/main/product/type.vue +108 -0
  191. package/src/main/search/search.vue +501 -0
  192. package/src/pages.json +337 -0
  193. package/src/plugins/CreatedComponentsPlugin.js +19 -0
  194. package/src/plugins/JsonRename.js +72 -0
  195. package/src/plugins/SetAppParams.js +171 -0
  196. package/src/project.js +18 -0
  197. package/src/utils/Cookie.js +68 -0
  198. package/src/utils/Runtime.js +105 -0
  199. package/src/utils/Storage.js +104 -0
  200. package/src/utils/XdNetwork.js +133 -0
  201. package/src/utils/helper.js +1321 -0
  202. package/src/utils/nourl.js +95 -0
  203. package/src/utils/project.js +17 -0
  204. package/src/utils/xd.auth.js +61 -0
  205. package/src/utils/xd.base.js +474 -0
  206. package/src/utils/xd.common.js +240 -0
  207. package/src/utils/xd.event.js +99 -0
  208. package/src/utils/xd.frame.js +96 -0
  209. package/src/utils/xd.path.js +96 -0
  210. package/src/utils/xdAppLog.js +170 -0
  211. package/src/utils/xdWxLog.js +302 -0
  212. package/src/utils/xdh5log.js +307 -0
  213. package/src/websetting.js +64 -0
  214. package/tsconfig.json +9 -0
  215. package/xd.less +180 -0
@@ -0,0 +1,536 @@
1
+ <template>
2
+ <view :id="attrs.id" :class="'_block _'+name+' '+attrs.class" :style="attrs.style">
3
+ <block v-for="(n, i) in childs" v-bind:key="i">
4
+ <!-- 图片 -->
5
+ <!-- 占位图 -->
6
+ <image v-if="n.name==='img'&&((opts[1]&&!ctrl[i])||ctrl[i]<0)" class="_img" :style="n.attrs.style" :src="ctrl[i]<0?opts[2]:opts[1]" mode="widthFix" />
7
+ <!-- 显示图片 -->
8
+ <!-- #ifdef H5 || (APP-PLUS && VUE2) -->
9
+ <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" />
10
+ <!-- #endif -->
11
+ <!-- #ifdef APP-PLUS && VUE3 -->
12
+ <image v-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'" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap" @longpress="imgLongTap" />
13
+ <!-- #endif -->
14
+ <!-- #ifndef H5 || APP-PLUS -->
15
+ <image v-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'" :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" />
16
+ <!-- #endif -->
17
+ <!-- 文本 -->
18
+ <!-- #ifndef MP-BAIDU || MP-ALIPAY || MP-TOUTIAO -->
19
+ <text v-else-if="n.text" :user-select="n.us" decode>{{n.text}}</text>
20
+ <!-- #endif -->
21
+ <text v-else-if="n.name==='br'">\n</text>
22
+ <!-- 链接 -->
23
+ <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">
24
+ <node name="span" :childs="n.children" :opts="opts" style="display:inherit" />
25
+ </view>
26
+ <!-- 视频 -->
27
+ <!-- #ifdef APP-PLUS -->
28
+ <view v-else-if="n.html" :id="n.attrs.id" :class="'_video '+n.attrs.class" :style="n.attrs.style" v-html="n.html" />
29
+ <!-- #endif -->
30
+ <!-- #ifndef APP-PLUS -->
31
+ <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" :poster="n.attrs.poster" :src="n.src[ctrl[i]||0]" :data-i="i" @play="play" @error="mediaError" />
32
+ <!-- #endif -->
33
+ <!-- #ifdef H5 || APP-PLUS -->
34
+ <iframe v-else-if="n.name==='iframe'" :style="n.attrs.style" :allowfullscreen="n.attrs.allowfullscreen" :frameborder="n.attrs.frameborder" :src="n.attrs.src" />
35
+ <embed v-else-if="n.name==='embed'" :style="n.attrs.style" :src="n.attrs.src" />
36
+ <!-- #endif -->
37
+ <!-- #ifndef MP-TOUTIAO || ((H5 || APP-PLUS) && VUE3) -->
38
+ <!-- 音频 -->
39
+ <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" />
40
+ <!-- #endif -->
41
+ <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">
42
+ <node v-if="n.name==='li'" :childs="n.children" :opts="opts" />
43
+ <view v-else v-for="(tbody, x) in n.children" v-bind:key="x" :class="'_'+tbody.name+' '+tbody.attrs.class" :style="tbody.attrs.style">
44
+ <node v-if="tbody.name==='td'||tbody.name==='th'" :childs="tbody.children" :opts="opts" />
45
+ <block v-else v-for="(tr, y) in tbody.children" v-bind:key="y">
46
+ <view v-if="tr.name==='td'||tr.name==='th'" :class="'_'+tr.name+' '+tr.attrs.class" :style="tr.attrs.style">
47
+ <node :childs="tr.children" :opts="opts" />
48
+ </view>
49
+ <view v-else :class="'_'+tr.name+' '+tr.attrs.class" :style="tr.attrs.style">
50
+ <view v-for="(td, z) in tr.children" v-bind:key="z" :class="'_'+td.name+' '+td.attrs.class" :style="td.attrs.style">
51
+ <node :childs="td.children" :opts="opts" />
52
+ </view>
53
+ </view>
54
+ </block>
55
+ </view>
56
+ </view>
57
+
58
+ <!-- 富文本 -->
59
+ <!-- #ifdef H5 || ((MP-WEIXIN || MP-QQ || APP-PLUS || MP-360) && VUE2) -->
60
+ <rich-text v-else-if="handler.use(n)" :id="n.attrs.id" :style="n.f" :nodes="[n]" />
61
+ <!-- #endif -->
62
+ <!-- #ifndef H5 || ((MP-WEIXIN || MP-QQ || APP-PLUS || MP-360) && VUE2) -->
63
+ <rich-text v-else-if="!n.c" :id="n.attrs.id" :style="n.f+';display:inline'" :preview="false" :nodes="[n]" />
64
+ <!-- #endif -->
65
+ <!-- 继续递归 -->
66
+ <view v-else-if="n.c===2" :id="n.attrs.id" :class="'_block _'+n.name+' '+n.attrs.class" :style="n.f+';'+n.attrs.style">
67
+ <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" />
68
+ </view>
69
+ <node v-else :style="n.f" :name="n.name" :attrs="n.attrs" :childs="n.children" :opts="opts" />
70
+ </block>
71
+ </view>
72
+ </template>
73
+ <script module="handler" lang="wxs">
74
+ // 行内标签列表
75
+ var inlineTags = {
76
+ abbr: true,
77
+ b: true,
78
+ big: true,
79
+ code: true,
80
+ del: true,
81
+ em: true,
82
+ i: true,
83
+ ins: true,
84
+ label: true,
85
+ q: true,
86
+ small: true,
87
+ span: true,
88
+ strong: true,
89
+ sub: true,
90
+ sup: true
91
+ }
92
+ /**
93
+ * @description 是否使用 rich-text 显示剩余内容
94
+ */
95
+ module.exports = {
96
+ use: function (item) {
97
+ if (item.c) return false
98
+ // 微信和 QQ 的 rich-text inline 布局无效
99
+ return !inlineTags[item.name] && (item.attrs.style || '').indexOf('display:inline') == -1
100
+ }
101
+ }
102
+ </script>
103
+ <script>
104
+
105
+ import node from './node'
106
+ export default {
107
+ name: 'node',
108
+ options: {
109
+ // #ifdef MP-WEIXIN
110
+ virtualHost: true,
111
+ // #endif
112
+ // #ifdef MP-TOUTIAO
113
+ addGlobalClass: false
114
+ // #endif
115
+ },
116
+ data () {
117
+ return {
118
+ ctrl: {}
119
+ }
120
+ },
121
+ props: {
122
+ name: String,
123
+ attrs: {
124
+ type: Object,
125
+ default () {
126
+ return {}
127
+ }
128
+ },
129
+ childs: Array,
130
+ opts: Array
131
+ },
132
+ // #ifndef H5 && VUE3
133
+ components: {
134
+
135
+ node
136
+ },
137
+ // #endif
138
+ mounted () {
139
+ this.$nextTick(() => {
140
+ for (this.root = this.$parent; this.root.$options.name !== 'XdMpHtml'; this.root = this.root.$parent);
141
+ })
142
+ // #ifdef H5 || APP-PLUS
143
+ if (this.opts[0]) {
144
+ let i
145
+ for (i = this.childs.length; i--;) {
146
+ if (this.childs[i].name === 'img') break
147
+ }
148
+ if (i !== -1) {
149
+ this.observer = uni.createIntersectionObserver(this).relativeToViewport({
150
+ top: 500,
151
+ bottom: 500
152
+ })
153
+ this.observer.observe('._img', res => {
154
+ if (res.intersectionRatio) {
155
+ this.$set(this.ctrl, 'load', 1)
156
+ this.observer.disconnect()
157
+ }
158
+ })
159
+ }
160
+ }
161
+ // #endif
162
+ },
163
+ beforeDestroy () {
164
+ // #ifdef H5 || APP-PLUS
165
+ if (this.observer) {
166
+ this.observer.disconnect()
167
+ }
168
+ // #endif
169
+ },
170
+ methods:{
171
+ // #ifdef MP-WEIXIN
172
+ toJSON () { },
173
+ // #endif
174
+ /**
175
+ * @description 播放视频事件
176
+ * @param {Event} e
177
+ */
178
+ play (e) {
179
+ // #ifndef APP-PLUS
180
+ if (this.root.pauseVideo) {
181
+ let flag = false; const id = e.target.id
182
+ for (let i = this.root._videos.length; i--;) {
183
+ if (this.root._videos[i].id === id) {
184
+ flag = true
185
+ } else {
186
+ this.root._videos[i].pause() // 自动暂停其他视频
187
+ }
188
+ }
189
+ // 将自己加入列表
190
+ if (!flag) {
191
+ const ctx = uni.createVideoContext(id
192
+ // #ifndef MP-BAIDU
193
+ , this
194
+ // #endif
195
+ )
196
+ ctx.id = id
197
+ this.root._videos.push(ctx)
198
+ }
199
+ }
200
+ // #endif
201
+ },
202
+
203
+ /**
204
+ * @description 图片点击事件
205
+ * @param {Event} e
206
+ */
207
+ imgTap (e) {
208
+ const node = this.childs[e.currentTarget.dataset.i]
209
+ if (node.a) {
210
+ this.linkTap(node.a)
211
+ return
212
+ }
213
+ if (node.attrs.ignore) return
214
+ // #ifdef H5 || APP-PLUS
215
+ node.attrs.src = node.attrs.src || node.attrs['data-src']
216
+ // #endif
217
+ this.root.$emit('imgtap', node.attrs)
218
+ // 自动预览图片
219
+ if (this.root.previewImg) {
220
+ uni.previewImage({
221
+ current: parseInt(node.attrs.i),
222
+ urls: this.root.imgList
223
+ })
224
+ }
225
+ },
226
+
227
+ /**
228
+ * @description 图片长按
229
+ */
230
+ imgLongTap (e) {
231
+ // #ifdef APP-PLUS
232
+ const attrs = this.childs[e.currentTarget.dataset.i].attrs
233
+ if (this.opts[3] && !attrs.ignore) {
234
+ uni.showActionSheet({
235
+ itemList: ['保存图片'],
236
+ success: () => {
237
+ const save = path => {
238
+ uni.saveImageToPhotosAlbum({
239
+ filePath: path,
240
+ success () {
241
+ uni.showToast({
242
+ title: '保存成功'
243
+ })
244
+ }
245
+ })
246
+ }
247
+ if (this.root.imgList[attrs.i].startsWith('http')) {
248
+ uni.downloadFile({
249
+ url: this.root.imgList[attrs.i],
250
+ success: res => save(res.tempFilePath)
251
+ })
252
+ } else {
253
+ save(this.root.imgList[attrs.i])
254
+ }
255
+ }
256
+ })
257
+ }
258
+ // #endif
259
+ },
260
+
261
+ /**
262
+ * @description 图片加载完成事件
263
+ * @param {Event} e
264
+ */
265
+ imgLoad (e) {
266
+ const i = e.currentTarget.dataset.i
267
+ /* #ifndef H5 || (APP-PLUS && VUE2) */
268
+ if (!this.childs[i].w) {
269
+ // 设置原宽度
270
+ this.$set(this.ctrl, i, e.detail.width)
271
+ } else /* #endif */ if ((this.opts[1] && !this.ctrl[i]) || this.ctrl[i] === -1) {
272
+ // 加载完毕,取消加载中占位图
273
+ this.$set(this.ctrl, i, 1)
274
+ }
275
+ },
276
+
277
+ /**
278
+ * @description 链接点击事件
279
+ * @param {Event} e
280
+ */
281
+ linkTap (e) {
282
+ const node = e.currentTarget ? this.childs[e.currentTarget.dataset.i] : {}
283
+ const attrs = node.attrs || e
284
+ const href = attrs.href
285
+ this.root.$emit('linktap', Object.assign({
286
+ innerText: this.root.getText(node.children || []) // 链接内的文本内容
287
+ }, attrs))
288
+ if (href) {
289
+ if (href[0] === '#') {
290
+ // 跳转锚点
291
+ this.root.navigateTo(href.substring(1)).catch(() => { })
292
+ } else if (href.split('?')[0].includes('://')) {
293
+ // 复制外部链接
294
+ if (this.root.copyLink) {
295
+ // #ifdef H5
296
+ window.open(href)
297
+ // #endif
298
+ // #ifdef MP
299
+ uni.setClipboardData({
300
+ data: href,
301
+ success: () =>
302
+ uni.showToast({
303
+ title: '链接已复制'
304
+ })
305
+ })
306
+ // #endif
307
+ // #ifdef APP-PLUS
308
+ plus.runtime.openWeb(href)
309
+ // #endif
310
+ }
311
+ } else {
312
+ // 跳转页面
313
+ uni.navigateTo({
314
+ url: href,
315
+ fail () {
316
+ uni.switchTab({
317
+ url: href,
318
+ fail () { }
319
+ })
320
+ }
321
+ })
322
+ }
323
+ }
324
+ },
325
+
326
+ /**
327
+ * @description 错误事件
328
+ * @param {Event} e
329
+ */
330
+ mediaError (e) {
331
+ const i = e.currentTarget.dataset.i
332
+ const node = this.childs[i]
333
+ // 加载其他源
334
+ if (node.name === 'video' || node.name === 'audio') {
335
+ let index = (this.ctrl[i] || 0) + 1
336
+ if (index > node.src.length) {
337
+ index = 0
338
+ }
339
+ if (index < node.src.length) {
340
+ this.$set(this.ctrl, i, index)
341
+ return
342
+ }
343
+ } else if (node.name === 'img') {
344
+ // #ifdef H5 && VUE3
345
+ if (this.opts[0] && !this.ctrl.load) return
346
+ // #endif
347
+ // 显示错误占位图
348
+ if (this.opts[2]) {
349
+ this.$set(this.ctrl, i, -1)
350
+ }
351
+ }
352
+ if (this.root) {
353
+ this.root.$emit('error', {
354
+ source: node.name,
355
+ attrs: node.attrs,
356
+ // #ifndef H5 && VUE3
357
+ errMsg: e.detail.errMsg
358
+ // #endif
359
+ })
360
+ }
361
+ }
362
+ }
363
+ }
364
+ </script>
365
+ <style>
366
+ /* a 标签默认效果 */
367
+ ._a {
368
+ padding: 1.5px 0 1.5px 0;
369
+ color: #366092;
370
+ word-break: break-all;
371
+ }
372
+
373
+ /* a 标签点击态效果 */
374
+ ._hover {
375
+ text-decoration: underline;
376
+ opacity: 0.7;
377
+ }
378
+
379
+ /* 图片默认效果 */
380
+ ._img {
381
+ max-width: 100%;
382
+ -webkit-touch-callout: none;
383
+ }
384
+
385
+ /* 内部样式 */
386
+
387
+ ._block {
388
+ display: block;
389
+ }
390
+
391
+ ._b,
392
+ ._strong {
393
+ font-weight: bold;
394
+ }
395
+
396
+ ._code {
397
+ font-family: monospace;
398
+ }
399
+
400
+ ._del {
401
+ text-decoration: line-through;
402
+ }
403
+
404
+ ._em,
405
+ ._i {
406
+ font-style: italic;
407
+ }
408
+
409
+ ._h1 {
410
+ font-size: 2em;
411
+ }
412
+
413
+ ._h2 {
414
+ font-size: 1.5em;
415
+ }
416
+
417
+ ._h3 {
418
+ font-size: 1.17em;
419
+ }
420
+
421
+ ._h5 {
422
+ font-size: 0.83em;
423
+ }
424
+
425
+ ._h6 {
426
+ font-size: 0.67em;
427
+ }
428
+
429
+ ._h1,
430
+ ._h2,
431
+ ._h3,
432
+ ._h4,
433
+ ._h5,
434
+ ._h6 {
435
+ display: block;
436
+ font-weight: bold;
437
+ }
438
+
439
+ ._image {
440
+ height: 1px;
441
+ }
442
+
443
+ ._ins {
444
+ text-decoration: underline;
445
+ }
446
+
447
+ ._li {
448
+ display: list-item;
449
+ }
450
+
451
+ ._ol {
452
+ list-style-type: decimal;
453
+ }
454
+
455
+ ._ol,
456
+ ._ul {
457
+ display: block;
458
+ padding-left: 40px;
459
+ margin: 1em 0;
460
+ }
461
+
462
+ ._q::before {
463
+ content: '"';
464
+ }
465
+
466
+ ._q::after {
467
+ content: '"';
468
+ }
469
+
470
+ ._sub {
471
+ font-size: smaller;
472
+ vertical-align: sub;
473
+ }
474
+
475
+ ._sup {
476
+ font-size: smaller;
477
+ vertical-align: super;
478
+ }
479
+
480
+ ._thead,
481
+ ._tbody,
482
+ ._tfoot {
483
+ display: table-row-group;
484
+ }
485
+
486
+ ._tr {
487
+ display: table-row;
488
+ }
489
+
490
+ ._td,
491
+ ._th {
492
+ display: table-cell;
493
+ vertical-align: middle;
494
+ }
495
+
496
+ ._th {
497
+ font-weight: bold;
498
+ text-align: center;
499
+ }
500
+
501
+ ._ul {
502
+ list-style-type: disc;
503
+ }
504
+
505
+ ._ul ._ul {
506
+ margin: 0;
507
+ list-style-type: circle;
508
+ }
509
+
510
+ ._ul ._ul ._ul {
511
+ list-style-type: square;
512
+ }
513
+
514
+ ._abbr,
515
+ ._b,
516
+ ._code,
517
+ ._del,
518
+ ._em,
519
+ ._i,
520
+ ._ins,
521
+ ._label,
522
+ ._q,
523
+ ._span,
524
+ ._strong,
525
+ ._sub,
526
+ ._sup {
527
+ display: inline;
528
+ }
529
+
530
+ /* #ifdef APP-PLUS */
531
+ ._video {
532
+ width: 300px;
533
+ height: 225px;
534
+ }
535
+ /* #endif */
536
+ </style>