@cloudbase/weda-ui 0.2.15 → 1.0.21

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 (250) hide show
  1. package/README.md +41 -169
  2. package/package.json +28 -15
  3. package/src/configs/components/calendar.json +78 -0
  4. package/src/configs/components/carousel.json +273 -0
  5. package/src/configs/components/chart/bar.json +724 -0
  6. package/src/configs/components/chart/line.json +679 -0
  7. package/src/configs/components/chart/pie.json +497 -0
  8. package/src/configs/components/chart/statisticsCard.json +379 -0
  9. package/src/configs/components/container.json +7 -2
  10. package/src/configs/components/dataView.json +154 -0
  11. package/src/configs/components/form/checkbox.json +97 -5
  12. package/src/configs/components/form/location.json +152 -0
  13. package/src/configs/components/form/radio.json +96 -4
  14. package/src/configs/components/form/select.json +245 -11
  15. package/src/configs/components/form/uploaderFile.json +2 -1
  16. package/src/configs/components/graphicCard.json +410 -0
  17. package/src/configs/components/image.json +7 -2
  18. package/src/configs/components/link.json +20 -4
  19. package/src/configs/components/listView.json +277 -0
  20. package/src/configs/components/modal.json +37 -5
  21. package/src/configs/components/navLayout.json +362 -0
  22. package/src/configs/components/navigationBar.json +59 -0
  23. package/src/configs/components/richtextview.json +4 -1
  24. package/src/configs/components/scrollVeiw.json +74 -22
  25. package/src/configs/components/swiper.json +6 -3
  26. package/src/configs/components/tabs.json +51 -8
  27. package/src/configs/components/text.json +33 -25
  28. package/src/configs/components/wxOpenApi/phone.json +141 -0
  29. package/src/configs/components/wxOpenApi/phoneCode.json +121 -0
  30. package/src/configs/components/wxOpenApi/share.json +167 -0
  31. package/src/configs/components/wxOpenApi/userInfo.json +174 -0
  32. package/src/configs/index.js +34 -0
  33. package/src/mp/components/button/index.js +12 -13
  34. package/src/mp/components/button/index.wxml +1 -1
  35. package/src/mp/components/calendar/arrowright--line.svg +11 -0
  36. package/src/mp/components/calendar/index.js +238 -0
  37. package/src/mp/components/calendar/index.json +4 -0
  38. package/src/mp/components/calendar/index.wxml +37 -0
  39. package/src/mp/components/calendar/index.wxss +178 -0
  40. package/src/mp/components/carousel/index.js +88 -0
  41. package/src/mp/components/carousel/index.json +7 -0
  42. package/src/mp/components/carousel/index.wxml +6 -0
  43. package/src/mp/components/chart/bar/index.js +258 -0
  44. package/src/mp/components/chart/bar/index.json +6 -0
  45. package/src/mp/components/chart/bar/index.wxml +3 -0
  46. package/src/mp/components/chart/bar/index.wxss +9 -0
  47. package/src/mp/components/chart/common/config/bar.js +50 -0
  48. package/src/mp/components/chart/common/config/global.js +16 -0
  49. package/src/mp/components/chart/common/config/line.js +48 -0
  50. package/src/mp/components/chart/common/config/pie.js +36 -0
  51. package/src/mp/components/chart/common/core/eChartBar.js +263 -0
  52. package/src/mp/components/chart/common/core/eChartBase.js +375 -0
  53. package/src/mp/components/chart/common/core/eChartLine.js +229 -0
  54. package/src/mp/components/chart/common/core/eChartPie.js +166 -0
  55. package/src/mp/components/chart/common/lib/echarts.min.js +18 -0
  56. package/src/mp/components/chart/ec-canvas/ec-canvas.js +277 -0
  57. package/src/mp/components/chart/ec-canvas/ec-canvas.json +4 -0
  58. package/src/mp/components/chart/ec-canvas/ec-canvas.wxml +4 -0
  59. package/src/mp/components/chart/ec-canvas/ec-canvas.wxss +4 -0
  60. package/src/mp/components/chart/ec-canvas/wx-canvas.js +107 -0
  61. package/src/mp/components/chart/line/index.js +247 -0
  62. package/src/mp/components/chart/line/index.json +6 -0
  63. package/src/mp/components/chart/line/index.wxml +3 -0
  64. package/src/mp/components/chart/line/index.wxss +9 -0
  65. package/src/mp/components/chart/pie/index.js +182 -0
  66. package/src/mp/components/chart/pie/index.json +6 -0
  67. package/src/mp/components/chart/pie/index.wxml +4 -0
  68. package/src/mp/components/chart/pie/index.wxss +9 -0
  69. package/src/mp/components/chart/statisticsCard/index.js +253 -0
  70. package/src/mp/components/chart/statisticsCard/index.json +4 -0
  71. package/src/mp/components/chart/statisticsCard/index.wxml +9 -0
  72. package/src/mp/components/chart/statisticsCard/index.wxss +45 -0
  73. package/src/mp/components/dataView/index.js +34 -0
  74. package/src/mp/components/dataView/index.json +7 -0
  75. package/src/mp/components/dataView/index.wxml +15 -0
  76. package/src/mp/components/dataView/index.wxss +0 -0
  77. package/src/mp/components/form/checkbox/index.js +41 -2
  78. package/src/mp/components/form/checkbox/index.wxml +1 -1
  79. package/src/mp/components/form/input/index.js +1 -1
  80. package/src/mp/components/form/location/components/mapChoose/index.js +201 -0
  81. package/src/mp/components/form/location/components/mapChoose/index.json +4 -0
  82. package/src/mp/components/form/location/components/mapChoose/index.wxml +42 -0
  83. package/src/mp/components/form/location/components/mapChoose/index.wxss +188 -0
  84. package/src/mp/components/form/location/index.js +382 -0
  85. package/src/mp/components/form/location/index.json +6 -0
  86. package/src/mp/components/form/location/index.wxml +25 -0
  87. package/src/mp/components/form/location/index.wxss +91 -0
  88. package/src/mp/components/form/radio/index.js +38 -0
  89. package/src/mp/components/form/select/index.js +360 -40
  90. package/src/mp/components/form/select/index.wxml +21 -6
  91. package/src/mp/components/form/select/region/index.js +98 -0
  92. package/src/mp/components/form/textarea/index.wxml +6 -5
  93. package/src/mp/components/form/uploader/index.js +84 -48
  94. package/src/mp/components/form/uploader/index.wxml +15 -3
  95. package/src/mp/components/form/uploaderFile/index.js +106 -27
  96. package/src/mp/components/graphicCard/chevron-right.svg +3 -0
  97. package/src/mp/components/graphicCard/index.js +203 -0
  98. package/src/mp/components/graphicCard/index.json +4 -0
  99. package/src/mp/components/graphicCard/index.wxml +29 -0
  100. package/src/mp/components/graphicCard/index.wxss +157 -0
  101. package/src/mp/components/image/index.js +0 -1
  102. package/src/mp/components/listView/arrow-right-line.svg +3 -0
  103. package/src/mp/components/listView/index.js +285 -0
  104. package/src/mp/components/listView/index.json +4 -0
  105. package/src/mp/components/listView/index.wxml +40 -0
  106. package/src/mp/components/listView/index.wxss +155 -0
  107. package/src/mp/components/listView/more-line.svg +3 -0
  108. package/src/mp/components/navLayout/index.js +123 -0
  109. package/src/mp/components/navLayout/index.json +7 -0
  110. package/src/mp/components/navLayout/index.wxml +25 -0
  111. package/src/mp/components/navLayout/index.wxss +1193 -0
  112. package/src/mp/components/navigationBar/index.js +193 -0
  113. package/src/mp/components/navigationBar/index.json +6 -0
  114. package/src/mp/components/navigationBar/index.wxml +88 -0
  115. package/src/mp/components/navigationBar/index.wxss +1257 -0
  116. package/src/mp/components/swiper/index.wxml +2 -0
  117. package/src/mp/components/tabs/index.js +7 -2
  118. package/src/mp/components/tabs/index.wxml +2 -1
  119. package/src/mp/components/text/index.js +0 -25
  120. package/src/mp/components/text/index.wxml +3 -3
  121. package/src/mp/components/wxOpenApi/phone/index.js +117 -0
  122. package/src/mp/components/wxOpenApi/phone/index.json +4 -0
  123. package/src/mp/components/wxOpenApi/phone/index.wxml +15 -0
  124. package/src/mp/components/wxOpenApi/phone/index.wxss +22 -0
  125. package/src/mp/components/wxOpenApi/phoneCode/index.js +89 -0
  126. package/src/mp/components/wxOpenApi/phoneCode/index.json +4 -0
  127. package/src/mp/components/wxOpenApi/phoneCode/index.wxml +15 -0
  128. package/src/mp/components/wxOpenApi/phoneCode/index.wxss +22 -0
  129. package/src/mp/components/wxOpenApi/share/index.js +117 -0
  130. package/src/mp/components/wxOpenApi/share/index.json +4 -0
  131. package/src/mp/components/wxOpenApi/share/index.wxml +15 -0
  132. package/src/mp/components/wxOpenApi/share/index.wxss +22 -0
  133. package/src/mp/components/wxOpenApi/userInfo/index.js +88 -0
  134. package/src/mp/components/wxOpenApi/userInfo/index.json +4 -0
  135. package/src/mp/components/wxOpenApi/userInfo/index.wxml +14 -0
  136. package/src/mp/components/wxOpenApi/userInfo/index.wxss +22 -0
  137. package/src/mp/index.json +18 -2
  138. package/src/mp/style/weda-ui.wxss +2 -0
  139. package/src/mp/utils/debounce.js +133 -0
  140. package/src/mp/utils/destr.js +48 -0
  141. package/src/mp/utils/dr_square_point.js +25 -0
  142. package/src/mp/utils/platform.js +25 -0
  143. package/src/mp/utils/qqmap-wx-jssdk1.2/qqmap-wx-jssdk.js +1336 -0
  144. package/src/mp/utils/spark-md5.js +776 -0
  145. package/src/mp/utils/tcb.js +62 -0
  146. package/src/setupTests.js +2 -1
  147. package/src/web/components/button/index.css +8 -1
  148. package/src/web/components/button/index.tsx +3 -2
  149. package/src/web/components/calendar/index.css +382 -0
  150. package/src/web/components/calendar/index.jsx +312 -0
  151. package/src/web/components/calendar/util.js +90 -0
  152. package/src/web/components/carousel/index.css +119 -0
  153. package/src/web/components/carousel/index.tsx +417 -0
  154. package/src/web/components/chart/bar/index.tsx +140 -0
  155. package/src/web/components/chart/common/config/bar.js +49 -0
  156. package/src/web/components/chart/common/config/global.js +16 -0
  157. package/src/web/components/chart/common/config/line.js +50 -0
  158. package/src/web/components/chart/common/config/pie.js +37 -0
  159. package/src/web/components/chart/common/core/eChartBar.js +265 -0
  160. package/src/web/components/chart/common/core/eChartBase.ts +383 -0
  161. package/src/web/components/chart/common/core/eChartLine.js +231 -0
  162. package/src/web/components/chart/common/core/eChartPie.js +170 -0
  163. package/src/web/components/chart/common/core/type.ts +34 -0
  164. package/src/web/components/chart/common/echart.css +106 -0
  165. package/src/web/components/chart/common/echarts.ts +33 -0
  166. package/src/web/components/chart/common/useChart.tsx +69 -0
  167. package/src/web/components/chart/line/index.tsx +136 -0
  168. package/src/web/components/chart/pie/index.tsx +99 -0
  169. package/src/web/components/chart/statisticsCard/index.css +62 -0
  170. package/src/web/components/chart/statisticsCard/index.tsx +307 -0
  171. package/src/web/components/chart/statisticsCard/interface.ts +14 -0
  172. package/src/web/components/dataView/index.tsx +20 -0
  173. package/src/web/components/dataView/interface.ts +6 -0
  174. package/src/web/components/form/checkbox/index.tsx +55 -23
  175. package/src/web/components/form/location/common/mapChoose.css +178 -0
  176. package/src/web/components/form/location/common/mapChoose.jsx +343 -0
  177. package/src/web/components/form/location/common/mapView.jsx +190 -0
  178. package/src/web/components/form/location/common/propsConfig.js +54 -0
  179. package/src/web/components/form/location/common/selectModal.css +44 -0
  180. package/src/web/components/form/location/common/selectModal.jsx +82 -0
  181. package/src/web/components/form/location/common/useLocationInfo.js +100 -0
  182. package/src/web/components/form/location/components/LocationH5/index.css +243 -0
  183. package/src/web/components/form/location/components/LocationH5/location.h5.jsx +403 -0
  184. package/src/web/components/form/location/components/LocationPC/Header.jsx +109 -0
  185. package/src/web/components/form/location/components/LocationPC/index.css +44 -0
  186. package/src/web/components/form/location/components/LocationPC/location.PC.jsx +323 -0
  187. package/src/web/components/form/location/constants.js +4 -0
  188. package/src/web/components/form/location/index.css +0 -0
  189. package/src/web/components/form/location/index.jsx +25 -0
  190. package/src/web/components/form/radio/index.tsx +84 -53
  191. package/src/web/components/form/select/h5.tsx +389 -71
  192. package/src/web/components/form/select/index.css +10 -0
  193. package/src/web/components/form/select/index.tsx +404 -144
  194. package/src/web/components/form/select/region/index.ts +122 -31
  195. package/src/web/components/form/select/time.jsx +90 -0
  196. package/src/web/components/form/select/year.tsx +170 -0
  197. package/src/web/components/form/uploader/uploader.h5.tsx +19 -4
  198. package/src/web/components/form/uploader/uploader.pc.tsx +8 -7
  199. package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +132 -113
  200. package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +16 -11
  201. package/src/web/components/graphicCard/index.css +159 -0
  202. package/src/web/components/graphicCard/index.tsx +310 -0
  203. package/src/web/components/image/image.tsx +1 -2
  204. package/src/web/components/image/index.tsx +1 -1
  205. package/src/web/components/index.js +24 -2
  206. package/src/web/components/link/index.tsx +6 -3
  207. package/src/web/components/listView/arrow-right-line.svg +3 -0
  208. package/src/web/components/listView/index.css +143 -0
  209. package/src/web/components/listView/index.tsx +359 -0
  210. package/src/web/components/listView/interface.ts +98 -0
  211. package/src/web/components/modal/index.tsx +3 -1
  212. package/src/web/components/navLayout/index.css +332 -0
  213. package/src/web/components/navLayout/index.tsx +247 -0
  214. package/src/web/components/navigationBar/chevron-right--double.svg +3 -0
  215. package/src/web/components/navigationBar/common.tsx +198 -0
  216. package/src/web/components/navigationBar/h5Menu.tsx +179 -0
  217. package/src/web/components/navigationBar/horizontalMenu.tsx +200 -0
  218. package/src/web/components/navigationBar/index.css +762 -0
  219. package/src/web/components/navigationBar/index.tsx +231 -0
  220. package/src/web/components/navigationBar/type.d.ts +111 -0
  221. package/src/web/components/navigationBar/verticalMenu.tsx +81 -0
  222. package/src/web/components/phone/index.css +0 -0
  223. package/src/web/components/phone/index.tsx +22 -0
  224. package/src/web/components/phoneCode/index.css +0 -0
  225. package/src/web/components/phoneCode/index.tsx +22 -0
  226. package/src/web/components/richTextView/index.tsx +3 -5
  227. package/src/web/components/share/index.css +0 -0
  228. package/src/web/components/share/index.tsx +38 -0
  229. package/src/web/components/tabs/index.tsx +4 -2
  230. package/src/web/components/tabs/tabs.h5.tsx +50 -37
  231. package/src/web/components/tabs/tabs.pc.tsx +23 -10
  232. package/src/web/components/text/index.tsx +6 -14
  233. package/src/web/components/uploaderFileView/index.css +9 -9
  234. package/src/web/components/uploaderFileView/index.jsx +32 -23
  235. package/src/web/components/userInfo/index.css +0 -0
  236. package/src/web/components/userInfo/index.tsx +30 -0
  237. package/src/web/types.d.ts +15 -14
  238. package/src/web/utils/debounce.js +98 -0
  239. package/src/web/utils/platform.js +40 -0
  240. package/src/web/utils/tcb.js +49 -0
  241. package/src/web/utils/tmap.js +4 -0
  242. package/src/web/weda-ui.css +2 -0
  243. package/CHANGELOG.md +0 -240
  244. package/src/.DS_Store +0 -0
  245. package/src/configs/.DS_Store +0 -0
  246. package/src/mp/.gitignore +0 -10
  247. package/src/web/.DS_Store +0 -0
  248. package/src/web/components/form/select/region/cities.ts +0 -2410
  249. package/src/web/components/form/select/region/provinces.ts +0 -240
  250. package/src/web/components/form/select/region/regions.ts +0 -20645
@@ -0,0 +1,157 @@
1
+ .weda-graphic-card {
2
+ width: 100%;
3
+ }
4
+
5
+ .weda-graphic-card .weda-graphic-card__wrapper {
6
+ width: 100%;
7
+ padding: 0 32rpx;
8
+ box-sizing: border-box;
9
+ }
10
+
11
+ .weda-graphic-card .weda-grid {
12
+ display: flex;
13
+ flex-wrap: wrap;
14
+ }
15
+
16
+ .weda-graphic-card .weda-graphic-card__row {
17
+ padding: 36rpx 0;
18
+ box-sizing: border-box;
19
+ margin: 0 -11.5rpx;
20
+ }
21
+
22
+ .weda-graphic-card .weda-grid__item {
23
+ flex-grow: 1;
24
+ }
25
+
26
+ .weda-graphic-card .weda-graphic-card__col {
27
+ padding: 0 11.5rpx;
28
+ box-sizing: border-box;
29
+ }
30
+
31
+ .weda-graphic-card .weda-graphic-card__col .weda-graphic-card__col-body {
32
+ width: 100%;
33
+ display: flex;
34
+ flex-direction: column;
35
+ justify-content: space-between;
36
+ align-items: center;
37
+ }
38
+
39
+ .weda-graphic-card .weda-graphic-card__col .weda-grid__box {
40
+ width: 100%;
41
+ height: 100%;
42
+ display: flex;
43
+ flex-direction: column;
44
+ justify-content: space-between;
45
+ align-items: center;
46
+ }
47
+
48
+ .weda-graphic-card
49
+ .weda-graphic-card__col.weda-graphic-card__col--left
50
+ .weda-grid__box,
51
+ .weda-graphic-card
52
+ .weda-graphic-card__col.weda-graphic-card__col--left
53
+ .weda-graphic-card__col-body {
54
+ align-items: flex-start;
55
+ }
56
+
57
+ .weda-graphic-card
58
+ .weda-graphic-card__col.weda-graphic-card__col--right
59
+ .weda-grid__box,
60
+ .weda-graphic-card
61
+ .weda-graphic-card__col.weda-graphic-card__col--right
62
+ .weda-graphic-card__col-body {
63
+ align-items: flex-end;
64
+ }
65
+
66
+ .weda-graphic-card .weda-graphic-card__col .weda-graphic-card__icon {
67
+ width: 100%;
68
+ height: 400rpx;
69
+ }
70
+
71
+ .weda-graphic-card .weda-graphic-card__icon .weda-graphic-card__img {
72
+ width: 100%;
73
+ height: 100%;
74
+ }
75
+
76
+ .weda-graphic-card .weda-graphic-card__col .weda-graphic-card__title {
77
+ font-size: 32rpx;
78
+ line-height: 48rpx;
79
+ text-align: center;
80
+ color: rgba(0, 0, 0, 0.9);
81
+ display: -webkit-box;
82
+ overflow: hidden;
83
+ text-overflow: ellipsis;
84
+ -webkit-box-orient: vertical;
85
+ -webkit-line-clamp: 2;
86
+ }
87
+
88
+ .weda-graphic-card .weda-graphic-card__col .weda-graphic-card__desc {
89
+ font-size: 28rpx;
90
+ line-height: 44rpx;
91
+ color: rgba(0, 0, 0, 0.4);
92
+ text-align: center;
93
+ display: -webkit-box;
94
+ overflow: hidden;
95
+ text-overflow: ellipsis;
96
+ -webkit-box-orient: vertical;
97
+ -webkit-line-clamp: 2;
98
+ }
99
+
100
+ .weda-graphic-card .weda-graphic-card__col .weda-graphic-card__title {
101
+ margin-top: 32rpx;
102
+ }
103
+
104
+ .weda-graphic-card .weda-graphic-card__col .weda-graphic-card__desc {
105
+ margin-top: 12rpx;
106
+ }
107
+
108
+ button:not([size='mini']) {
109
+ margin-left: 0;
110
+ margin-right: 0;
111
+ width: auto;
112
+ }
113
+
114
+ .weda-graphic-card .wedatea2td-btn {
115
+ outline: 0 none;
116
+ box-sizing: border-box;
117
+ font-size: 28rpx;
118
+ white-space: nowrap;
119
+ user-select: none;
120
+ display: inline-block;
121
+ text-align: center;
122
+ height: auto;
123
+ vertical-align: middle;
124
+ text-decoration: none;
125
+ background-color: transparent;
126
+ border: none;
127
+ color: #0052d9;
128
+ padding: 0;
129
+ line-height: 1.5;
130
+ font-weight: normal;
131
+ margin: 0;
132
+ }
133
+
134
+ .weda-graphic-card .weda-graphic-card__col .weda-graphic-card__btn--text {
135
+ font-size: 28rpx;
136
+ line-height: 44rpx;
137
+ color: #0052d9;
138
+ margin-right: 16rpx;
139
+ }
140
+
141
+ .weda-graphic-card
142
+ .weda-graphic-card__col
143
+ .weda-graphic-card__btn
144
+ .weda-graphic-card__btn--icon {
145
+ width: 32rpx;
146
+ height: 32rpx;
147
+ display: inline-block;
148
+ vertical-align: middle;
149
+ background-repeat: no-repeat;
150
+ background-position: inherit;
151
+ font-size: 0;
152
+ margin-bottom: 3px;
153
+ }
154
+
155
+ .weda-graphic-card .weda-graphic-card__col .weda-graphic-card__btn {
156
+ margin-top: 32rpx;
157
+ }
@@ -76,7 +76,6 @@ Component({
76
76
  offsetHeight,
77
77
  });
78
78
  }
79
- this.triggerEvent('tap', e.detail);
80
79
  },
81
80
  onPinch: function (ev) {
82
81
  let zoom = ev.detail.zoom;
@@ -0,0 +1,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M13.1719 12.0002L8.22192 7.05023L9.63592 5.63623L15.9999 12.0002L9.63592 18.3642L8.22192 16.9502L13.1719 12.0002Z" fill="#09121F"/>
3
+ </svg>
@@ -0,0 +1,285 @@
1
+ const isNull = (val) => [undefined, null].includes(val);
2
+ const REL_DICT = {
3
+ equal: 'eq', // 等于
4
+ unequal: 'neq', // 不等于
5
+ include: 'search', // 包含
6
+ exclude: '_exclude', // 不包含
7
+ begin_with: '_begin_with', // 开头是
8
+ greater: 'gt', // 大于
9
+ greater_or_equal: 'gte', // 大于等于
10
+ less: 'lt', // 小于
11
+ less_or_equal: 'lte', // 小于等于
12
+ in: 'in', // 多选值
13
+ not_in: 'nin', // 不在多选值
14
+ };
15
+ const ORDERTYPE = ['asc', 'desc'];
16
+ const getWhereList = (where) => {
17
+ let result = [];
18
+ Array.isArray(where) &&
19
+ where.forEach((item1) => {
20
+ if (item1?.groupLogic !== 'or' && Array.isArray(item1?.logicData)) {
21
+ item1?.logicData.forEach((item2) => {
22
+ let [rel, val] = [REL_DICT[item2?.rel], item2?.value];
23
+ if ('_begin_with' === rel) {
24
+ rel = 'regex';
25
+ val = `^${val}`;
26
+ }
27
+ if ('_exclude' === rel) {
28
+ rel = 'regex';
29
+ val = `^((?!${val}).)*$`;
30
+ }
31
+ if (item2?.logic !== 'or' && item2?.key && rel && !isNull(val)) {
32
+ result.push({ key: item2.key, rel, val });
33
+ }
34
+ });
35
+ }
36
+ });
37
+ return result;
38
+ };
39
+ const DEFAULT_DATA = {
40
+ pageNo: 1,
41
+ total: 0,
42
+ records: [],
43
+ pageStr: '0/0',
44
+ isVisiableSign: false,
45
+ isFirstScreen: true,
46
+ };
47
+
48
+ Component({
49
+ options: {
50
+ virtualHost: true,
51
+ },
52
+ properties: {
53
+ className: {
54
+ type: String,
55
+ value: '',
56
+ },
57
+ style: {
58
+ type: String,
59
+ value: '',
60
+ },
61
+ datasource: {
62
+ type: Object,
63
+ value: {},
64
+ },
65
+ orderBy: {
66
+ type: String,
67
+ },
68
+ orderType: {
69
+ type: String,
70
+ },
71
+ where: {
72
+ type: Array,
73
+ value: [],
74
+ },
75
+ pageSize: {
76
+ type: Number,
77
+ value: 5,
78
+ },
79
+ template: {
80
+ type: String,
81
+ value: 'simpleList',
82
+ },
83
+ pagination: {
84
+ type: String,
85
+ value: 'loadMoreButton',
86
+ },
87
+ beforeDataChange: {
88
+ type: Function,
89
+ value: (v) => v,
90
+ },
91
+ },
92
+ data: { ...DEFAULT_DATA, isReLoad: false, loading: false },
93
+ methods: {
94
+ /**
95
+ * 列表容器拉取数据,放在 setData 的回调函数中执行
96
+ */
97
+ _fetchData: async function () {
98
+ const { app } = getApp();
99
+ const callDataSource = app?.cloud?.callDataSource;
100
+ const { pageNo, loading, isReLoad } = this.data;
101
+ const { datasource, orderBy, orderType, where, pageSize } =
102
+ this.properties;
103
+ if (loading && !isReLoad) return;
104
+ if (!callDataSource) {
105
+ console.warn(`当前环境缺少方法 app.cloud.callDataSource`);
106
+ return;
107
+ }
108
+ this.setData({ loading: true });
109
+ const { name: dataSourceName, extra } = datasource || {};
110
+ const methodName =
111
+ typeof extra?.methodName === 'string'
112
+ ? extra?.methodName
113
+ : 'wedaGetRecords';
114
+ const tcbParams = {};
115
+
116
+ // tcb分页参数
117
+ if (!isNull(pageNo) && !isNull(pageSize)) {
118
+ tcbParams['pageNo'] = pageNo;
119
+ tcbParams['pageSize'] = pageSize;
120
+ }
121
+ // tcb排序参数
122
+ if (orderBy && ORDERTYPE.includes(orderType)) {
123
+ tcbParams['orderBy'] = orderBy;
124
+ tcbParams['orderType'] = orderType;
125
+ }
126
+ // tcb过滤参数
127
+ const whereEffected = [].concat(getWhereList(where));
128
+ whereEffected.length > 0 && (tcbParams['where'] = whereEffected);
129
+ // tcb结果和事件
130
+ try {
131
+ const data = await callDataSource({
132
+ dataSourceName,
133
+ methodName,
134
+ params: tcbParams,
135
+ });
136
+ let records = data?.records || [];
137
+ let total = data?.total || 0;
138
+ if (
139
+ ['loadMoreButton', 'bottomLoad'].includes(
140
+ this.properties.pagination
141
+ ) &&
142
+ !isReLoad
143
+ ) {
144
+ records = [...this.data.records, ...records]; // TODO 可能存在单次 setData 数据量过大引起小程序性能问题
145
+ }
146
+ this.setData(
147
+ {
148
+ total,
149
+ records,
150
+ loading: false,
151
+ isReLoad: false,
152
+ pageStr: `${total > 0 ? pageNo : 0}/${
153
+ Math.ceil(total / pageSize) || 0
154
+ }`,
155
+ },
156
+ () => {
157
+ this._handleEvents(data);
158
+ setTimeout(() => this._firstScreenLoadMore(), 150);
159
+ }
160
+ );
161
+ } catch (e) {
162
+ this.setData({ loading: false });
163
+ }
164
+ },
165
+ /**
166
+ * 下一页
167
+ */
168
+ handleNext: function () {
169
+ if (
170
+ this.data.loading ||
171
+ !(this.properties.pageSize * this.data.pageNo < this.data.total)
172
+ ) {
173
+ return;
174
+ }
175
+ this.setData({ pageNo: this.data.pageNo + 1 }, () => this._fetchData());
176
+ },
177
+ /**
178
+ * 上一页
179
+ */
180
+ handlePre: function () {
181
+ if (this.data.loading || !(this.properties.pageNo > 1)) {
182
+ return;
183
+ }
184
+ this.setData({ pageNo: this.data.pageNo - 1 }, () => this._fetchData());
185
+ },
186
+ /**
187
+ * 向外部传递事件
188
+ */
189
+ _handleEvents: function (data) {
190
+ const records = this.data.records || [];
191
+ const total = this.data.total || records?.length || 0;
192
+ const beforeDataChange = this.properties.beforeDataChange || ((v) => v);
193
+ this.triggerEvent('onDataChange', {
194
+ data: beforeDataChange(records),
195
+ });
196
+ if (JSON.stringify(data) === '{}') {
197
+ this.triggerEvent('queryFail', {
198
+ datasource: this.properties.datasource,
199
+ data: null,
200
+ });
201
+ } else {
202
+ if (total === 0) {
203
+ this.triggerEvent('queryEmpty', {
204
+ datasource: this.properties.datasource,
205
+ data: beforeDataChange([]),
206
+ });
207
+ }
208
+ this.triggerEvent('querySuccess', {
209
+ datasource: this.properties.datasource,
210
+ data: beforeDataChange(records),
211
+ });
212
+ }
213
+ },
214
+ /**
215
+ * 首屏持续触底加载特殊处理
216
+ */
217
+ _firstScreenLoadMore: function () {
218
+ if (this.properties.pagination === 'bottomLoad') {
219
+ if (this.data.isFirstScreen) {
220
+ this.setData({ isFirstScreen: false });
221
+ this.contentObserver?.disconnect();
222
+ this._observerContent();
223
+ }
224
+ }
225
+ },
226
+ /**
227
+ * 开始监听slot
228
+ */
229
+ _observerContent: function () {
230
+ this.contentObserver = this.createIntersectionObserver();
231
+ this.contentObserver
232
+ .relativeToViewport()
233
+ .observe('#weda-list-view_content', (res) => {
234
+ this.setData({
235
+ isFirstScreen:
236
+ res?.boundingClientRect?.bottom <= res?.relativeRect?.bottom,
237
+ });
238
+ });
239
+ },
240
+ /**
241
+ * 开始监听sign
242
+ */
243
+ _observerSign: function () {
244
+ this.signObserver = this.createIntersectionObserver();
245
+ this.signObserver
246
+ .relativeToViewport()
247
+ .observe('#weda-list-view_sign', (res) => {
248
+ this.setData({ isVisiableSign: res?.intersectionRatio > 0 });
249
+ });
250
+ },
251
+ },
252
+ observers: {
253
+ 'datasource,orderBy,orderType,where,pageSize,pagination': function () {
254
+ clearTimeout(this._timer);
255
+ this._timer = setTimeout(
256
+ () =>
257
+ this.setData({ ...DEFAULT_DATA, isReLoad: true }, () =>
258
+ this._fetchData()
259
+ ),
260
+ 200
261
+ );
262
+ },
263
+ isVisiableSign: function (dIsVisiableSign) {
264
+ if (dIsVisiableSign && this.properties.pagination === 'bottomLoad') {
265
+ this.handleNext();
266
+ }
267
+ },
268
+ isFirstScreen: function (dIsFirstScreen) {
269
+ if (dIsFirstScreen && this.properties.pagination === 'bottomLoad') {
270
+ this.handleNext();
271
+ }
272
+ },
273
+ },
274
+ lifetimes: {
275
+ attached: function () {
276
+ clearTimeout(this._timer);
277
+ this._fetchData();
278
+ this._observerSign();
279
+ },
280
+ detached: function () {
281
+ this.contentObserver?.disconnect();
282
+ this.signObserver?.disconnect();
283
+ },
284
+ },
285
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "styleIsolation": "shared"
4
+ }
@@ -0,0 +1,40 @@
1
+ <scroll-view scroll-y scroll-with-animation lower-threshold="5" style="{{style}}"
2
+ class="weda-list-view__containor weda-ui {{className}}">
3
+ <!-- 列表插槽 -->
4
+ <view class="{{template === 'cardList' ? 'weda-list-view-card' : ''}}" id="weda-list-view_content">
5
+ <slot></slot>
6
+ </view>
7
+
8
+ <view class="weda-list-view__more {{'weda-list-view__more-' + pagination}}">
9
+ <!-- 加载更多 -->
10
+ <block wx:if="{{pagination==='loadMoreButton' && pageSize * pageNo < total}}">
11
+ <view class="weda-list-view__more-text" bindtap="handleNext">加载更多</view>
12
+ </block>
13
+ <!-- 触底刷新 -->
14
+ <block wx:elif="{{pagination==='bottomLoad'}}">
15
+ <view class="weda-list-view__bottom-load" id="weda-list-view_sign">
16
+ <view class="weda-list-view__more-symbol" wx:if="{{loading}}">
17
+ <view class="weda-list-view__symbol-item"></view>
18
+ <view class="weda-list-view__symbol-item"></view>
19
+ <view class="weda-list-view__symbol-item"></view>
20
+ </view>
21
+ </view>
22
+ </block>
23
+ <!-- 分页器 -->
24
+ <block wx:elif="{{pagination==='pagination'}}">
25
+ <view class="weda-list-view__more-pagination">
26
+ <view class="weda-list-view__pagination-pre {{pageNo > 1 ? 'active': ''}}" bindtap="handlePre">
27
+ <image class="weda-list-view__pagination-icon" src='arrow-right-line.svg' />
28
+ 上一页
29
+ </view>
30
+ <view class="weda-list-view__pagination-text">{{pageStr}}</view>
31
+ <view class="weda-list-view__pagination-next {{pageSize * pageNo < total ? 'active' : ''}}"
32
+ bindtap="handleNext">
33
+ <image class="weda-list-view__pagination-icon" src='arrow-right-line.svg' />
34
+ 下一页
35
+ </view>
36
+ </view>
37
+ </block>
38
+ <block wx:else></block>
39
+ </view>
40
+ </scroll-view>
@@ -0,0 +1,155 @@
1
+ /* weda_list_view */
2
+
3
+ .weda-list-view__containor {
4
+ background: #fff;
5
+ width: 100%;
6
+ height: 100%;
7
+ overflow-x: hidden;
8
+ }
9
+
10
+ /* 卡片列表 */
11
+ .weda-list-view-card {
12
+ display: flex;
13
+ flex-wrap: wrap;
14
+ margin-right: 6rpx;
15
+ }
16
+
17
+ /* 加载更多 */
18
+ .weda-list-view__containor .weda-list-view__more {
19
+ width: 100%;
20
+ }
21
+
22
+ .weda-list-view__containor .weda-list-view__more .weda-list-view__more-text {
23
+ padding-top: 20rpx;
24
+ padding-bottom: 28rpx;
25
+ font-size: 24rpx;
26
+ line-height: 44rpx;
27
+ color: rgba(0, 0, 0, 0.4);
28
+ text-align: center;
29
+ box-sizing: border-box;
30
+ }
31
+
32
+ /* 加载更多 ... */
33
+ .weda-list-view__containor .weda-list-view__more {
34
+ background: #fff;
35
+ }
36
+
37
+ .weda-list-view__containor
38
+ .weda-list-view__more.weda-list-view__more-bottomLoad {
39
+ background: transparent;
40
+ }
41
+
42
+ .weda-list-view__bottom-load {
43
+ padding-top: 1px;
44
+ }
45
+
46
+ .weda-list-view__containor .weda-list-view__more .weda-list-view__more-symbol {
47
+ display: flex;
48
+ align-items: center;
49
+ justify-content: center;
50
+ padding-top: 40rpx;
51
+ padding-bottom: 36rpx;
52
+ box-sizing: border-box;
53
+ }
54
+
55
+ .weda-list-view__containor .weda-list-view__more .weda-list-view__symbol-item {
56
+ width: 16rpx;
57
+ height: 16rpx;
58
+ background: #c4c4c4;
59
+ margin-left: 12rpx;
60
+ border-radius: 50%;
61
+ }
62
+
63
+ .weda-list-view__containor
64
+ .weda-list-view__more
65
+ .weda-list-view__symbol-item:first-child {
66
+ width: 12rpx;
67
+ height: 12rpx;
68
+ margin-left: 0;
69
+ }
70
+
71
+ /* 加载更多 分页 */
72
+ .weda-list-view__containor
73
+ .weda-list-view__more
74
+ .weda-list-view__more-pagination {
75
+ display: flex;
76
+ align-items: center;
77
+ justify-content: space-between;
78
+ position: relative;
79
+ padding: 20rpx 36rpx 24rpx 32rpx;
80
+ box-sizing: border-box;
81
+ }
82
+
83
+ .weda-list-view__containor
84
+ .weda-list-view__more
85
+ .weda-list-view__pagination-pre,
86
+ .weda-list-view__containor
87
+ .weda-list-view__more
88
+ .weda-list-view__pagination-next {
89
+ font-size: 24rpx;
90
+ line-height: 48rpx;
91
+ color: rgba(0, 0, 0, 0.4);
92
+ padding: 0 48rpx;
93
+ }
94
+
95
+ .weda-list-view__containor
96
+ .weda-list-view__more
97
+ .weda-list-view__pagination-pre.active,
98
+ .weda-list-view__containor
99
+ .weda-list-view__more
100
+ .weda-list-view__pagination-next.active {
101
+ color: rgba(0, 0, 0, 0.9);
102
+ }
103
+
104
+ .weda-list-view__containor
105
+ .weda-list-view__more
106
+ .weda-list-view__pagination-pre
107
+ .weda-list-view__pagination-icon,
108
+ .weda-list-view__containor
109
+ .weda-list-view__more
110
+ .weda-list-view__pagination-next
111
+ .weda-list-view__pagination-icon {
112
+ position: absolute;
113
+ width: 48rpx;
114
+ height: 48rpx;
115
+ top: 20rpx;
116
+ opacity: 0.2;
117
+ }
118
+
119
+ .weda-list-view__containor
120
+ .weda-list-view__more
121
+ .active.weda-list-view__pagination-pre
122
+ .weda-list-view__pagination-icon,
123
+ .weda-list-view__containor
124
+ .weda-list-view__more
125
+ .active.weda-list-view__pagination-next
126
+ .weda-list-view__pagination-icon {
127
+ opacity: 1;
128
+ }
129
+
130
+ .weda-list-view__containor
131
+ .weda-list-view__more
132
+ .weda-list-view__pagination-pre
133
+ .weda-list-view__pagination-icon {
134
+ left: 32rpx;
135
+ transform: rotate(180deg);
136
+ }
137
+
138
+ .weda-list-view__containor
139
+ .weda-list-view__more
140
+ .weda-list-view__pagination-next
141
+ .weda-list-view__pagination-icon {
142
+ right: 36rpx;
143
+ }
144
+
145
+ .weda-list-view__containor
146
+ .weda-list-view__more
147
+ .weda-list-view__pagination-text {
148
+ font-size: 24rpx;
149
+ line-height: 44rpx;
150
+ color: rgba(0, 0, 0, 0.4);
151
+ }
152
+
153
+ .split {
154
+ height: 40rpx;
155
+ }
@@ -0,0 +1,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M4.5 10.5C3.675 10.5 3 11.175 3 12C3 12.825 3.675 13.5 4.5 13.5C5.325 13.5 6 12.825 6 12C6 11.175 5.325 10.5 4.5 10.5ZM19.5 10.5C18.675 10.5 18 11.175 18 12C18 12.825 18.675 13.5 19.5 13.5C20.325 13.5 21 12.825 21 12C21 11.175 20.325 10.5 19.5 10.5ZM12 10.5C11.175 10.5 10.5 11.175 10.5 12C10.5 12.825 11.175 13.5 12 13.5C12.825 13.5 13.5 12.825 13.5 12C13.5 11.175 12.825 10.5 12 10.5Z" fill="#09121F"/>
3
+ </svg>