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,165 @@
1
+ <template>
2
+ <view
3
+ class="xd-loading"
4
+ @touchmove.stop.prevent
5
+ :style="{zIndex:loading.zIndex <= 4000? 4000 :loading.zIndex }"
6
+ v-if="show"
7
+ >
8
+ <view class="xd-loading__mask" v-if="loading.isMask" :style="{ backgroundColor:loading.bgColor}"></view>
9
+ <view class="xd-loading__body" :style="{borderRadius: loading.radius}">
10
+ <view class="xd-loading__body-content"></view>
11
+ <view class="xd-loading__body-title" v-if="loading.title">{{loading.title}}</view>
12
+ </view>
13
+ </view>
14
+ </template>
15
+
16
+ <script>
17
+ import XdFontIcon from "@/components/XdFontIcon/XdFontIcon";
18
+ import {mapState, mapMutations} from 'vuex';
19
+
20
+ export default {
21
+ name: "XdLoading",
22
+ components: {
23
+ XdFontIcon
24
+ },
25
+ computed: {
26
+ ...mapState([
27
+ 'xdLoading'
28
+ ])
29
+ },
30
+ data(){
31
+ return {
32
+ show: false,
33
+
34
+ /**
35
+ * @description 确认框
36
+ * @property loading {Object}
37
+ * @property loading.zIndex {Number} 样式层级关系 默认:1700
38
+ * @property loading.radius {String} 边框圆角 默认:确认30rpx
39
+ * @property loading.title {String} 文字显示 默认:''
40
+ * @property loading.bgColor {String} 文字显示 默认:rgba(0,0,0,0)
41
+ * @property loading.isMask {Boolean} 是否显示遮罩层 默认:true
42
+ */
43
+ loading: {},
44
+
45
+ defaultLoading: {
46
+ zIndex: 4000,
47
+ title: '',
48
+ radius: '30rpx',
49
+ bgColor: 'rgba(0,0,0,.3)',
50
+ isMask: true
51
+ }
52
+ }
53
+ },
54
+ watch:{
55
+ xdLoading(value){
56
+ this.init(value);
57
+ }
58
+ },
59
+ created(){
60
+ this.init(this.xdLoading);
61
+ },
62
+ methods: {
63
+ ...mapMutations(['setXdLoading']),
64
+
65
+ init(value) {
66
+ //只有当前访问页面触发逻辑
67
+ if (this.$root.$isShow === false) {
68
+ return;
69
+ }
70
+ if (value === null) {
71
+ this.show = false;
72
+ this.loading = {}
73
+ } else {
74
+ this.loading = Object.assign({},
75
+ this.$xdUniHelper.cloneDeep(this.defaultLoading),
76
+ value,
77
+ );
78
+ console.log('xdLoading', this.confirm);
79
+ this.show = true;
80
+ }
81
+ },
82
+
83
+ handleConfirm(status){
84
+ if(typeof this.confirm.success === 'function') {
85
+ let params = {};
86
+ params[status] = true;
87
+ this.confirm.success(params);
88
+ this.close();
89
+ }else {
90
+ this.close();
91
+ }
92
+ },
93
+
94
+ close(){
95
+ this.setXdLoading(null);
96
+ },
97
+ }
98
+ }
99
+ </script>
100
+
101
+ <style scoped lang="less">
102
+ @-webkit-keyframes spin {
103
+ 0% {
104
+ -webkit-transform: rotate(0deg);
105
+ }
106
+ 100% {
107
+ -webkit-transform: rotate(360deg);
108
+ }
109
+ }
110
+
111
+ @keyframes spin {
112
+ 0% {
113
+ transform: rotate(0deg);
114
+ }
115
+ 100% {
116
+ transform: rotate(360deg);
117
+ }
118
+ }
119
+
120
+ .xd-loading {
121
+ position: fixed;
122
+ top: 0;
123
+ bottom: 0;
124
+ left: 0;
125
+ right: 0;
126
+
127
+ &__mask {
128
+ position: absolute;
129
+ top: 0;
130
+ bottom: 0;
131
+ left: 0;
132
+ right: 0;
133
+ }
134
+
135
+ &__body {
136
+ position: absolute;
137
+ top: 50%;
138
+ left: 50%;
139
+ transform: translate(-50%, -50%);
140
+ width: unit(300, rpx);
141
+ background: rgba(0,0,0,.8);
142
+ padding: unit(60,rpx) unit(30, rpx);
143
+ display: flex;
144
+ justify-content: center;
145
+ align-items: center;
146
+ flex-direction: column;
147
+ box-sizing: border-box;
148
+
149
+ &-content {
150
+ height: unit(90, rpx);
151
+ width: unit(90, rpx);
152
+ background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgxMDB2MTAwSDB6Ii8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTlFOUU5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTMwKSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iIzk4OTY5NyIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgzMCAxMDUuOTggNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjOUI5OTlBIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDYwIDc1Ljk4IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0EzQTFBMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSg5MCA2NSA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNBQkE5QUEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoMTIwIDU4LjY2IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0IyQjJCMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgxNTAgNTQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjQkFCOEI5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDE4MCA1MCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDMkMwQzEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=') no-repeat;
153
+ background-size: 100%;
154
+ animation: spin 2s linear infinite;
155
+ -webkit-animation: spin 2s linear infinite;
156
+ }
157
+
158
+ &-title {
159
+ color: #eee;
160
+ margin-top: unit(22,rpx)
161
+ }
162
+
163
+ }
164
+ }
165
+ </style>
@@ -0,0 +1,66 @@
1
+ <template>
2
+ <view class="app-no-more">
3
+ <view
4
+ class="app-no-more__text"
5
+ :style="{
6
+ background:background,
7
+ color:color
8
+ }"
9
+ >
10
+ <slot>没有更多了</slot>
11
+ </view>
12
+ </view>
13
+ </template>
14
+
15
+ <script>
16
+ /**
17
+ * XdMore 全局Ui
18
+ * @description 显示没有更多样式,支持插槽
19
+ * @property {String} background 背景颜色值
20
+ */
21
+ export default {
22
+ name: "XdMore",
23
+ props: {
24
+ background: {
25
+ type: String,
26
+ default: '#f8f8f8'
27
+ },
28
+ color: {
29
+ type: String,
30
+ default: '#999'
31
+ }
32
+ }
33
+ }
34
+ </script>
35
+
36
+ <style scoped lang="less">
37
+ .app-no-more {
38
+ padding: unit(20,rpx) 0 unit(20, rpx);
39
+ text-align: center;
40
+ color: @custom-btn-info;
41
+ font-size: @xd-font-size-sm;
42
+ position: relative;
43
+ display: flex;
44
+ justify-content: center;
45
+ align-items: center;
46
+
47
+ &:before {
48
+ content: ' ';
49
+ position: absolute;
50
+ left: 30%;
51
+ right: 30%;
52
+ top: 50%;
53
+ margin: -1px;
54
+ height: 1px;
55
+ background: #ccc;
56
+ z-index: 1;
57
+ }
58
+
59
+ &__text {
60
+ position: relative;
61
+ z-index: 2;
62
+ padding: 0 unit(20, rpx);
63
+ }
64
+ }
65
+
66
+ </style>
@@ -0,0 +1,458 @@
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]" name="span" />
6
+ <!-- #endif -->
7
+ <!-- #ifdef APP-PLUS-NVUE -->
8
+ <web-view ref="web" src="./static/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.2.2
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} error 媒体加载出错时触发
38
+ */
39
+ // #ifndef APP-PLUS-NVUE
40
+ import node from './node/node'
41
+ // #endif
42
+ import Parser from './parser';
43
+ const plugins=[]
44
+ // #ifdef APP-PLUS-NVUE
45
+ const dom = weex.requireModule('dom')
46
+ // #endif
47
+ export default {
48
+ name: 'XdMpHtml',
49
+ data () {
50
+ return {
51
+ nodes: [],
52
+ // #ifdef APP-PLUS-NVUE
53
+ height: 3
54
+ // #endif
55
+ }
56
+ },
57
+ props: {
58
+ containerStyle: {
59
+ type: String,
60
+ default: ''
61
+ },
62
+ content: {
63
+ type: String,
64
+ default: ''
65
+ },
66
+ copyLink: {
67
+ type: [Boolean, String],
68
+ default: true
69
+ },
70
+ domain: String,
71
+ errorImg: {
72
+ type: String,
73
+ default: ''
74
+ },
75
+ lazyLoad: {
76
+ type: [Boolean, String],
77
+ default: false
78
+ },
79
+ loadingImg: {
80
+ type: String,
81
+ default: ''
82
+ },
83
+ pauseVideo: {
84
+ type: [Boolean, String],
85
+ default: true
86
+ },
87
+ previewImg: {
88
+ type: [Boolean, String],
89
+ default: true
90
+ },
91
+ scrollTable: [Boolean, String],
92
+ selectable: [Boolean, String],
93
+ setTitle: {
94
+ type: [Boolean, String],
95
+ default: true
96
+ },
97
+ showImgMenu: {
98
+ type: [Boolean, String],
99
+ default: true
100
+ },
101
+ tagStyle: Object,
102
+ useAnchor: [Boolean, Number]
103
+ },
104
+ // #ifdef VUE3
105
+ emits: ['load', 'ready', 'imgtap', 'linktap', 'error'],
106
+ // #endif
107
+ // #ifndef APP-PLUS-NVUE
108
+ components: {
109
+ node
110
+ },
111
+ // #endif
112
+ watch: {
113
+ content (content) {
114
+ this.setContent(content)
115
+ }
116
+ },
117
+ created () {
118
+ this.plugins = []
119
+ for (let i = plugins.length; i--;) {
120
+ this.plugins.push(new plugins[i](this))
121
+ }
122
+ },
123
+ mounted () {
124
+ if (this.content && !this.nodes.length) {
125
+ this.setContent(this.content)
126
+ }
127
+ },
128
+ beforeDestroy () {
129
+ this._hook('onDetached')
130
+ clearInterval(this._timer)
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(/&amp;/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 {String} content html 内容
289
+ * @param {Boolean} append 是否在尾部追加
290
+ */
291
+ setContent (content, append) {
292
+ if (!append || !this.imgList) {
293
+ this.imgList = []
294
+ }
295
+ const nodes = new Parser(this).parse(content)
296
+ // #ifdef APP-PLUS-NVUE
297
+ if (this._ready) {
298
+ this._set(nodes, append)
299
+ }
300
+ // #endif
301
+ this.$set(this, 'nodes', append ? (this.nodes || []).concat(nodes) : nodes)
302
+
303
+ // #ifndef APP-PLUS-NVUE
304
+ this._videos = []
305
+ this.$nextTick(() => {
306
+ this._hook('onLoad')
307
+ this.$emit('load')
308
+ })
309
+
310
+ // 等待图片加载完毕
311
+ let height
312
+ clearInterval(this._timer)
313
+ this._timer = setInterval(() => {
314
+ this.getRect().then(rect => {
315
+ // 350ms 总高度无变化就触发 ready 事件
316
+ if (rect.height === height) {
317
+ this.$emit('ready', rect)
318
+ clearInterval(this._timer)
319
+ }
320
+ height = rect.height
321
+ }).catch(() => { })
322
+ }, 350)
323
+ // #endif
324
+ },
325
+
326
+ /**
327
+ * @description 调用插件钩子函数
328
+ */
329
+ _hook (name) {
330
+ for (let i = plugins.length; i--;) {
331
+ if (this.plugins[i][name]) {
332
+ this.plugins[i][name]()
333
+ }
334
+ }
335
+ },
336
+
337
+ // #ifdef APP-PLUS-NVUE
338
+ /**
339
+ * @description 设置内容
340
+ */
341
+ _set (nodes, append) {
342
+ this.$refs.web.evalJs('setContent(' + JSON.stringify(nodes) + ',' + JSON.stringify([this.containerStyle.replace(/(?:margin|padding)[^;]+/g, ''), this.errorImg, this.loadingImg, this.pauseVideo, this.scrollTable, this.selectable]) + ',' + append + ')')
343
+ },
344
+
345
+ /**
346
+ * @description 接收到 web-view 消息
347
+ */
348
+ _onMessage (e) {
349
+ const message = e.detail.data[0]
350
+ switch (message.action) {
351
+ // web-view 初始化完毕
352
+ case 'onJSBridgeReady':
353
+ this._ready = true
354
+ if (this.nodes) {
355
+ this._set(this.nodes)
356
+ }
357
+ break
358
+ // 内容 dom 加载完毕
359
+ case 'onLoad':
360
+ this.height = message.height
361
+ this._hook('onLoad')
362
+ this.$emit('load')
363
+ break
364
+ // 所有图片加载完毕
365
+ case 'onReady':
366
+ this.getRect().then(res => {
367
+ this.$emit('ready', res)
368
+ }).catch(() => { })
369
+ break
370
+ // 总高度发生变化
371
+ case 'onHeightChange':
372
+ this.height = message.height
373
+ break
374
+ // 图片点击
375
+ case 'onImgTap':
376
+ this.$emit('imgtap', message.attrs)
377
+ if (this.previewImg) {
378
+ uni.previewImage({
379
+ current: parseInt(message.attrs.i),
380
+ urls: this.imgList
381
+ })
382
+ }
383
+ break
384
+ // 链接点击
385
+ case 'onLinkTap': {
386
+ const href = message.attrs.href
387
+ this.$emit('linktap', message.attrs)
388
+ if (href) {
389
+ // 锚点跳转
390
+ if (href[0] === '#') {
391
+ if (this.useAnchor) {
392
+ dom.scrollToElement(this.$refs.web, {
393
+ offset: message.offset
394
+ })
395
+ }
396
+ } else if (href.includes('://')) {
397
+ // 打开外链
398
+ if (this.copyLink) {
399
+ plus.runtime.openWeb(href)
400
+ }
401
+ } else {
402
+ uni.navigateTo({
403
+ url: href,
404
+ fail () {
405
+ uni.switchTab({
406
+ url: href
407
+ })
408
+ }
409
+ })
410
+ }
411
+ }
412
+ break
413
+ }
414
+ // 获取到锚点的偏移量
415
+ case 'getOffset':
416
+ if (typeof message.offset === 'number') {
417
+ dom.scrollToElement(this.$refs.web, {
418
+ offset: message.offset + this._navigateTo.offset
419
+ })
420
+ this._navigateTo.resolve()
421
+ } else {
422
+ this._navigateTo.reject(Error('Label not found'))
423
+ }
424
+ break
425
+ // 点击
426
+ case 'onClick':
427
+ this.$emit('tap')
428
+ this.$emit('click')
429
+ break
430
+ // 出错
431
+ case 'onError':
432
+ this.$emit('error', {
433
+ source: message.source,
434
+ attrs: message.attrs
435
+ })
436
+ }
437
+ }
438
+ // #endif
439
+ }
440
+ }
441
+ </script>
442
+
443
+ <style>
444
+ /* #ifndef APP-PLUS-NVUE */
445
+ /* 根节点样式 */
446
+ ._root {
447
+ padding: 1px 0;
448
+ overflow-x: auto;
449
+ overflow-y: hidden;
450
+ -webkit-overflow-scrolling: touch;
451
+ }
452
+
453
+ /* 长按复制 */
454
+ ._select {
455
+ user-select: text;
456
+ }
457
+ /* #endif */
458
+ </style>