xiaoe_mp_npm 1.0.21 → 1.0.22-store2

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 (165) hide show
  1. package/.prettierrc.js +32 -6
  2. package/miniprogram_dist/GoodsItem/index.json +6 -6
  3. package/miniprogram_dist/GoodsItem/index.wxs +18 -18
  4. package/miniprogram_dist/LiveGoodsList/Header/index.js +54 -54
  5. package/miniprogram_dist/LiveGoodsList/Header/index.json +6 -6
  6. package/miniprogram_dist/LiveGoodsList/Header/index.less +45 -45
  7. package/miniprogram_dist/LiveGoodsList/Header/index.scss +105 -105
  8. package/miniprogram_dist/LiveGoodsList/Header/index.wxml +32 -32
  9. package/miniprogram_dist/LiveGoodsList/README.md +9 -9
  10. package/miniprogram_dist/LiveGoodsList/index.json +8 -8
  11. package/miniprogram_dist/LiveGoodsList/index.less +53 -53
  12. package/miniprogram_dist/LiveGoodsList/index.scss +92 -92
  13. package/miniprogram_dist/Task/TaskBubble/index.js +2 -1
  14. package/miniprogram_dist/Task/TaskPopup/component/RewardList/index.js +23 -21
  15. package/miniprogram_dist/Task/TaskPopup/component/RewardList/index.wxml +1 -0
  16. package/miniprogram_dist/Task/TaskPopup/component/TaskItem/index.js +264 -169
  17. package/miniprogram_dist/Task/TaskPopup/component/TaskItem/index.scss +26 -0
  18. package/miniprogram_dist/Task/TaskPopup/component/TaskItem/index.wxml +32 -13
  19. package/miniprogram_dist/Task/TaskPopup/component/TaskItem/index.wxss +96 -0
  20. package/miniprogram_dist/Task/TaskPopup/component/TaskList/index.js +8 -0
  21. package/miniprogram_dist/Task/TaskPopup/component/TaskList/index.wxml +1 -0
  22. package/miniprogram_dist/Task/TaskPopup/component/TaskType/index.js +4 -0
  23. package/miniprogram_dist/Task/TaskPopup/component/TaskType/index.wxml +1 -0
  24. package/miniprogram_dist/Task/TaskPopup/index.js +76 -70
  25. package/miniprogram_dist/Task/TaskPopup/index.json +2 -2
  26. package/miniprogram_dist/Task/TaskPopup/index.wxml +2 -0
  27. package/miniprogram_dist/Task/TaskQuizPopup/components/quizContent/index.js +132 -0
  28. package/miniprogram_dist/Task/TaskQuizPopup/components/quizContent/index.json +6 -0
  29. package/miniprogram_dist/Task/TaskQuizPopup/components/quizContent/index.scss +192 -0
  30. package/miniprogram_dist/Task/TaskQuizPopup/components/quizContent/index.wxml +65 -0
  31. package/miniprogram_dist/Task/TaskQuizPopup/components/quizContent/index.wxs +79 -0
  32. package/miniprogram_dist/Task/TaskQuizPopup/components/quizContent/index.wxss +521 -0
  33. package/miniprogram_dist/Task/TaskQuizPopup/components/quizRichText/index.js +40 -0
  34. package/miniprogram_dist/Task/TaskQuizPopup/components/quizRichText/index.json +6 -0
  35. package/miniprogram_dist/Task/TaskQuizPopup/components/quizRichText/index.scss +7 -0
  36. package/miniprogram_dist/Task/TaskQuizPopup/components/quizRichText/index.wxml +2 -0
  37. package/miniprogram_dist/Task/TaskQuizPopup/components/quizRichText/index.wxss +298 -0
  38. package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/base.wxml +50 -0
  39. package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/html2json.js +623 -0
  40. package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/htmlparser.js +183 -0
  41. package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/iframeParse.js +216 -0
  42. package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/loop.wxml +3563 -0
  43. package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/showdown.js +2364 -0
  44. package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/wxDiscode.js +209 -0
  45. package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/wxParse.js +269 -0
  46. package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/wxParse.wxml +1276 -0
  47. package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/wxParse.wxss +316 -0
  48. package/miniprogram_dist/Task/TaskQuizPopup/index.js +225 -0
  49. package/miniprogram_dist/Task/TaskQuizPopup/index.json +8 -0
  50. package/miniprogram_dist/Task/TaskQuizPopup/index.scss +159 -0
  51. package/miniprogram_dist/Task/TaskQuizPopup/index.wxml +97 -0
  52. package/miniprogram_dist/Task/TaskQuizPopup/index.wxss +478 -0
  53. package/miniprogram_dist/Task/taskQuizRemindPopup/index.js +74 -0
  54. package/miniprogram_dist/Task/taskQuizRemindPopup/index.json +6 -0
  55. package/miniprogram_dist/Task/taskQuizRemindPopup/index.scss +108 -0
  56. package/miniprogram_dist/Task/taskQuizRemindPopup/index.wxml +27 -0
  57. package/miniprogram_dist/Task/taskQuizRemindPopup/index.wxss +286 -0
  58. package/miniprogram_dist/common/utils/tool.js +54 -48
  59. package/package.json +1 -1
  60. package/src/AliveInvite/LiveRoomVertical/index.wxss +252 -252
  61. package/src/CollectionAddress/index.wxss +5 -5
  62. package/src/ConfirmOrder/components/AddressEdit/index.wxss +120 -120
  63. package/src/ConfirmOrder/components/AddressManage/index.wxss +98 -98
  64. package/src/ConfirmOrder/components/AddressSelect/index.wxss +67 -67
  65. package/src/ConfirmOrder/components/ChoosePicker/index.wxss +18 -18
  66. package/src/ConfirmOrder/components/GoodsInfo/components/GoodsCommerce/components/entityGiftList/index.wxss +45 -45
  67. package/src/ConfirmOrder/components/GoodsInfo/components/GoodsCommerce/components/entityItem/index.wxss +100 -100
  68. package/src/ConfirmOrder/components/GoodsInfo/components/GoodsCommerce/index.wxss +55 -55
  69. package/src/ConfirmOrder/components/GoodsInfo/components/ImageData/index.wxss +13 -13
  70. package/src/ConfirmOrder/components/Header/index.wxss +26 -26
  71. package/src/ConfirmOrder/components/IntegralSelect/componenets/integralTips/index.wxss +85 -85
  72. package/src/ConfirmOrder/components/Invoice/components/InvoiceSelect/index.wxss +155 -155
  73. package/src/ConfirmOrder/components/Invoice/components/InvoiceTip/index.wxss +51 -51
  74. package/src/ConfirmOrder/components/ModeSelect/index.wxss +44 -44
  75. package/src/ConfirmOrder/components/PickupSelect/index.wxss +22 -22
  76. package/src/ConfirmOrder/components/SelectSite/index.wxss +82 -82
  77. package/src/ConfirmOrder/components/Shipper/index.wxss +76 -76
  78. package/src/ConfirmOrder/components/ShipperEdit/index.wxss +78 -78
  79. package/src/ConfirmOrder/components/WechatAddress/index.wxss +22 -22
  80. package/src/ConfirmOrder/index.wxss +5 -5
  81. package/src/CouponList/couponMsg/index.wxss +3 -3
  82. package/src/CustomPopup/index.wxss +22 -22
  83. package/src/GoodsItem/index.json +6 -6
  84. package/src/GoodsItem/index.wxs +18 -18
  85. package/src/LiveGoodsList/Header/index.js +54 -54
  86. package/src/LiveGoodsList/Header/index.json +6 -6
  87. package/src/LiveGoodsList/Header/index.less +45 -45
  88. package/src/LiveGoodsList/Header/index.scss +105 -105
  89. package/src/LiveGoodsList/Header/index.wxml +32 -32
  90. package/src/LiveGoodsList/README.md +9 -9
  91. package/src/LiveGoodsList/index.json +8 -8
  92. package/src/LiveGoodsList/index.less +53 -53
  93. package/src/LiveGoodsList/index.scss +92 -92
  94. package/src/LiveGoodsList/index.wxss +218 -218
  95. package/src/PayComplete/Components/CouponItem/index.wxss +122 -122
  96. package/src/PayComplete/Components/Header/index.wxss +27 -27
  97. package/src/PayComplete/Components/LeadGroup/index.wxss +33 -33
  98. package/src/PayComplete/Components/PayGifts/index.wxss +157 -157
  99. package/src/PayComplete/Components/PayState/earnIntegral/index.wxss +23 -23
  100. package/src/PayComplete/Components/PayState/index.wxss +20 -20
  101. package/src/PayComplete/index.wxss +27 -27
  102. package/src/PayModule/wechatLoading/index.wxss +57 -57
  103. package/src/Recommend/index.wxss +110 -110
  104. package/src/Sku/Header/index.wxss +27 -27
  105. package/src/Sku/goods-info/index.wxss +52 -52
  106. package/src/Sku/index/index.wxss +52 -52
  107. package/src/Sku/row-item/index.wxss +50 -50
  108. package/src/Sku/step/index.wxss +11 -11
  109. package/src/Task/TaskBubble/index.js +2 -1
  110. package/src/Task/TaskBubble/index.wxss +289 -289
  111. package/src/Task/TaskIcon/index.wxss +130 -130
  112. package/src/Task/TaskPopup/component/RewardList/index.js +23 -21
  113. package/src/Task/TaskPopup/component/RewardList/index.wxml +1 -0
  114. package/src/Task/TaskPopup/component/RewardList/index.wxss +18 -18
  115. package/src/Task/TaskPopup/component/TaskItem/index.js +264 -169
  116. package/src/Task/TaskPopup/component/TaskItem/index.scss +26 -0
  117. package/src/Task/TaskPopup/component/TaskItem/index.wxml +32 -13
  118. package/src/Task/TaskPopup/component/TaskItem/index.wxss +1 -394
  119. package/src/Task/TaskPopup/component/TaskList/index.js +8 -0
  120. package/src/Task/TaskPopup/component/TaskList/index.wxml +1 -0
  121. package/src/Task/TaskPopup/component/TaskList/index.wxss +118 -118
  122. package/src/Task/TaskPopup/component/TaskType/index.js +4 -0
  123. package/src/Task/TaskPopup/component/TaskType/index.wxml +1 -0
  124. package/src/Task/TaskPopup/component/TaskType/index.wxss +110 -110
  125. package/src/Task/TaskPopup/index.js +76 -70
  126. package/src/Task/TaskPopup/index.json +2 -2
  127. package/src/Task/TaskPopup/index.wxml +2 -0
  128. package/src/Task/TaskPopup/index.wxss +406 -406
  129. package/src/Task/TaskQuizPopup/components/quizContent/index.js +132 -0
  130. package/src/Task/TaskQuizPopup/components/quizContent/index.json +6 -0
  131. package/src/Task/TaskQuizPopup/components/quizContent/index.scss +192 -0
  132. package/src/Task/TaskQuizPopup/components/quizContent/index.wxml +65 -0
  133. package/src/Task/TaskQuizPopup/components/quizContent/index.wxs +79 -0
  134. package/src/Task/TaskQuizPopup/components/quizContent/index.wxss +1 -0
  135. package/src/Task/TaskQuizPopup/components/quizRichText/index.js +40 -0
  136. package/src/Task/TaskQuizPopup/components/quizRichText/index.json +6 -0
  137. package/src/Task/TaskQuizPopup/components/quizRichText/index.scss +7 -0
  138. package/src/Task/TaskQuizPopup/components/quizRichText/index.wxml +2 -0
  139. package/src/Task/TaskQuizPopup/components/quizRichText/index.wxss +1 -0
  140. package/src/Task/TaskQuizPopup/components/wxParse/base.wxml +50 -0
  141. package/src/Task/TaskQuizPopup/components/wxParse/html2json.js +623 -0
  142. package/src/Task/TaskQuizPopup/components/wxParse/htmlparser.js +183 -0
  143. package/src/Task/TaskQuizPopup/components/wxParse/iframeParse.js +216 -0
  144. package/src/Task/TaskQuizPopup/components/wxParse/loop.wxml +3563 -0
  145. package/src/Task/TaskQuizPopup/components/wxParse/showdown.js +2364 -0
  146. package/src/Task/TaskQuizPopup/components/wxParse/wxDiscode.js +209 -0
  147. package/src/Task/TaskQuizPopup/components/wxParse/wxParse.js +269 -0
  148. package/src/Task/TaskQuizPopup/components/wxParse/wxParse.wxml +1276 -0
  149. package/src/Task/TaskQuizPopup/components/wxParse/wxParse.wxss +283 -0
  150. package/src/Task/TaskQuizPopup/index.js +225 -0
  151. package/src/Task/TaskQuizPopup/index.json +8 -0
  152. package/src/Task/TaskQuizPopup/index.scss +159 -0
  153. package/src/Task/TaskQuizPopup/index.wxml +97 -0
  154. package/src/Task/TaskQuizPopup/index.wxss +1 -0
  155. package/src/Task/taskQuizRemindPopup/index.js +74 -0
  156. package/src/Task/taskQuizRemindPopup/index.json +6 -0
  157. package/src/Task/taskQuizRemindPopup/index.scss +108 -0
  158. package/src/Task/taskQuizRemindPopup/index.wxml +27 -0
  159. package/src/Task/taskQuizRemindPopup/index.wxss +1 -0
  160. package/src/Task/taskReceivePopup/customPrizes/index.wxss +220 -220
  161. package/src/Task/taskReceivePopup/index.wxss +1 -1
  162. package/src/Task/taskReceivePopup/integral/index.wxss +94 -94
  163. package/src/common/css/theme.wxss +16 -16
  164. package/src/common/utils/tool.js +54 -48
  165. package/src/miniprogram_npm/miniprogram-computed/index.js +1 -0
@@ -0,0 +1,623 @@
1
+ /**
2
+ * author: Di (微信小程序开发工程师)
3
+ * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
4
+ * 垂直微信小程序开发交流社区
5
+ *
6
+ * github地址: https://github.com/icindy/wxParse
7
+ *
8
+ * for: 微信小程序富文本解析
9
+ * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
10
+ */
11
+
12
+ var __placeImgeUrlHttps = 'https'
13
+ var __emojisReg = ''
14
+ var __emojisBaseSrc = ''
15
+ var __emojis = {}
16
+ var wxDiscode = require('wxDiscode.js')
17
+ var HTMLParser = require('htmlparser.js')
18
+ // Empty Elements - HTML 5
19
+ var empty = makeMap(
20
+ 'area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr',
21
+ )
22
+ // Block Elements - HTML 5
23
+ var block = makeMap(
24
+ 'br,a,code,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video',
25
+ )
26
+
27
+ // Inline Elements - HTML 5
28
+ var inline = makeMap(
29
+ 'abbr,acronym,applet,b,basefont,bdo,big,button,cite,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var',
30
+ )
31
+
32
+ // Elements that you can, intentionally, leave open
33
+ // (and which close themselves)
34
+ var closeSelf = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr')
35
+
36
+ // Attributes that have their values filled in disabled="disabled"
37
+ var fillAttrs = makeMap(
38
+ 'checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected',
39
+ )
40
+
41
+ // Special Elements (can contain anything)
42
+ var special = makeMap('wxxxcode-style,script,style,view,scroll-view,block')
43
+
44
+ // 定义列表类型
45
+ var listTypeObj = {
46
+ 'lower-alpha': [
47
+ 'a',
48
+ 'b',
49
+ 'c',
50
+ 'd',
51
+ 'e',
52
+ 'f',
53
+ 'g',
54
+ 'h',
55
+ 'i',
56
+ 'j',
57
+ 'k',
58
+ 'l',
59
+ 'm',
60
+ 'n',
61
+ 'o',
62
+ 'p',
63
+ 'q',
64
+ 'r',
65
+ 's',
66
+ 't',
67
+ 'u',
68
+ 'v',
69
+ 'w',
70
+ 'x',
71
+ 'y',
72
+ 'z',
73
+ ],
74
+ 'lower-roman': ['i', 'ii', 'iii', 'iv', 'v', 'vi', 'vii', 'viii', 'ix', 'x'],
75
+ 'upper-alpha': [
76
+ 'A',
77
+ 'B',
78
+ 'C',
79
+ 'D',
80
+ 'E',
81
+ 'F',
82
+ 'G',
83
+ 'H',
84
+ 'I',
85
+ 'J',
86
+ 'K',
87
+ 'L',
88
+ 'M',
89
+ 'N',
90
+ 'O',
91
+ 'P',
92
+ 'Q',
93
+ 'R',
94
+ 'S',
95
+ 'T',
96
+ 'U',
97
+ 'V',
98
+ 'W',
99
+ 'X',
100
+ 'Y',
101
+ 'Z',
102
+ ],
103
+ 'upper-roman': ['I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X'],
104
+ 'cjk-ideographic': ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十'],
105
+ 'lower-greek': [
106
+ 'α',
107
+ 'β',
108
+ 'γ',
109
+ 'δ',
110
+ 'ε',
111
+ 'ζ',
112
+ 'η',
113
+ 'θ',
114
+ 'ι',
115
+ 'κ',
116
+ 'λ',
117
+ 'μ',
118
+ 'ν',
119
+ 'ξ',
120
+ 'ο',
121
+ 'π',
122
+ 'ρ',
123
+ 'σ',
124
+ 'τ',
125
+ 'υ',
126
+ 'φ',
127
+ 'χ',
128
+ 'ψ',
129
+ 'ω',
130
+ ],
131
+ }
132
+
133
+ //字母转化为数字
134
+ function toNum(listTextLen) {
135
+ //至多36位
136
+ switch (listTextLen) {
137
+ case 0:
138
+ listTextLen = 0
139
+ break
140
+ case 1:
141
+ listTextLen = 1
142
+ break
143
+ case 2:
144
+ listTextLen = 2
145
+ break
146
+ case 3:
147
+ listTextLen = 3
148
+ break
149
+ case 4:
150
+ listTextLen = 4
151
+ break
152
+ case 5:
153
+ listTextLen = 5
154
+ break
155
+ case 6:
156
+ listTextLen = 6
157
+ break
158
+ case 7:
159
+ listTextLen = 7
160
+ break
161
+ case 8:
162
+ listTextLen = 8
163
+ break
164
+ case 9:
165
+ listTextLen = 9
166
+ break
167
+ case 'a':
168
+ listTextLen = 10
169
+ break
170
+ case 'b':
171
+ listTextLen = 11
172
+ break
173
+ case 'c':
174
+ listTextLen = 12
175
+ break
176
+ case 'd':
177
+ listTextLen = 13
178
+ break
179
+ case 'e':
180
+ listTextLen = 14
181
+ break
182
+ case 'f':
183
+ listTextLen = 16
184
+ break
185
+ case 'g':
186
+ listTextLen = 17
187
+ break
188
+ case 'h':
189
+ listTextLen = 18
190
+ break
191
+ case 'i':
192
+ listTextLen = 19
193
+ break
194
+ case 'j':
195
+ listTextLen = 20
196
+ break
197
+ case 'k':
198
+ listTextLen = 21
199
+ break
200
+ case 'l':
201
+ listTextLen = 22
202
+ break
203
+ case 'm':
204
+ listTextLen = 23
205
+ break
206
+ case 'n':
207
+ listTextLen = 24
208
+ break
209
+ case 'o':
210
+ listTextLen = 25
211
+ break
212
+ case 'p':
213
+ listTextLen = 26
214
+ break
215
+ case 'q':
216
+ listTextLen = 27
217
+ break
218
+ case 'r':
219
+ listTextLen = 28
220
+ break
221
+ case 's':
222
+ listTextLen = 29
223
+ break
224
+ case 't':
225
+ listTextLen = 30
226
+ break
227
+ case 'u':
228
+ listTextLen = 31
229
+ break
230
+ case 'v':
231
+ listTextLen = 32
232
+ break
233
+ case 'w':
234
+ listTextLen = 33
235
+ break
236
+ case 'x':
237
+ listTextLen = 34
238
+ break
239
+ case 'y':
240
+ listTextLen = 35
241
+ break
242
+ case 'z':
243
+ listTextLen = 36
244
+ break
245
+ }
246
+
247
+ return listTextLen
248
+ }
249
+
250
+ function getListText(listType, listIdx) {
251
+ var listTypeArr = listTypeObj[listType]
252
+ var listTypeLen = listTypeArr.length
253
+ var listText = ''
254
+ var listTextLen = listIdx.toString(listTypeLen)
255
+
256
+ var listTextArr = listTextLen.split('').reverse()
257
+ if (listType == 'cjk-ideographic') {
258
+ if (listIdx <= listTypeLen) {
259
+ var j = listIdx - 1
260
+ listText += listTypeArr[j]
261
+ } else {
262
+ for (var z = listTextArr.length - 1; z >= 0; z--) {
263
+ if (z == 0) {
264
+ j = toNum(listTextArr[z])
265
+ if (j == 0) {
266
+ break
267
+ } else {
268
+ listText += listTypeArr[j - 1]
269
+ break
270
+ }
271
+ }
272
+ if (z == 1 && listTextArr[z] == 1) {
273
+ listText += listTypeArr[listTypeLen - 1]
274
+ } else {
275
+ j = toNum(listTextArr[z]) - 1
276
+ listText = listTypeArr[j] + listTypeArr[listTypeLen - 1]
277
+ }
278
+ }
279
+ }
280
+ } else if (listType == 'upper-roman' || listType == 'lower-roman') {
281
+ if (listIdx <= listTypeLen) {
282
+ let j = listIdx - 1
283
+ listText += listTypeArr[j]
284
+ } else {
285
+ for (let z = listTextArr.length - 1; z >= 0; z--) {
286
+ if (z == 0) {
287
+ j = toNum(listTextArr[z])
288
+ if (j == 0) {
289
+ break
290
+ } else {
291
+ listText += listTypeArr[j - 1]
292
+ break
293
+ }
294
+ }
295
+ if (z == 1 && listTextArr[z] == 1) {
296
+ listText += listTypeArr[listTypeLen - 1]
297
+ } else {
298
+ j = toNum(listTextArr[z])
299
+ for (var k = 0; k <= j - 1; j--) {
300
+ listText += listTypeArr[listTypeLen - 1]
301
+ }
302
+ }
303
+ }
304
+ }
305
+ } else {
306
+ if (listIdx <= listTypeLen) {
307
+ let j = listIdx - 1
308
+ listText += listTypeArr[j]
309
+ } else {
310
+ for (let z = listTextArr.length - 1; z >= 0; z--) {
311
+ if (z == 0) {
312
+ j = toNum(listTextArr[z])
313
+ if (j == 0) {
314
+ break
315
+ } else {
316
+ listText += listTypeArr[j - 1]
317
+ break
318
+ }
319
+ } else {
320
+ j = toNum(listTextArr[z])
321
+ listText += listTypeArr[j - 1]
322
+ }
323
+ }
324
+ }
325
+ }
326
+
327
+ return listText
328
+ }
329
+
330
+ function makeMap(str) {
331
+ var obj = {},
332
+ items = str.split(',')
333
+ for (var i = 0; i < items.length; i++) obj[items[i]] = true
334
+ return obj
335
+ }
336
+
337
+ function q(v) {
338
+ return '"' + v + '"'
339
+ }
340
+
341
+ function removeDOCTYPE(html) {
342
+ return html
343
+ .replace(/<\?xml.*\?>\n/, '')
344
+ .replace(/<!doctype.*\>\n/, '')
345
+ .replace(/<!DOCTYPE.*\>\n/, '')
346
+ }
347
+
348
+ function html2json(html, bindName) {
349
+ //处理字符串
350
+ html = removeDOCTYPE(html)
351
+ html = wxDiscode.strDiscode(html)
352
+ //生成node节点
353
+ var bufArray = []
354
+ var results = {
355
+ node: bindName,
356
+ nodes: [],
357
+ images: [],
358
+ imageUrls: [],
359
+ }
360
+ HTMLParser(html, {
361
+ start: function (tag, attrs, unary) {
362
+ //debug(tag, attrs, unary);
363
+ // node for this element
364
+ var node = {
365
+ node: 'element',
366
+ tag: tag,
367
+ }
368
+
369
+ if (block[tag]) {
370
+ node.tagType = 'block'
371
+ } else if (inline[tag]) {
372
+ node.tagType = 'inline'
373
+ } else if (closeSelf[tag]) {
374
+ node.tagType = 'closeSelf'
375
+ }
376
+
377
+ if (attrs.length !== 0) {
378
+ node.attr = attrs.reduce(function (pre, attr) {
379
+ var name = attr.name
380
+ var value = attr.value
381
+ if (name == 'class') {
382
+ // console.dir(value);
383
+ // value = value.join("")
384
+ node.classStr = value
385
+ }
386
+ // has multi attibutes
387
+ // make it array of attribute
388
+ if (name == 'style') {
389
+ // console.dir(value);
390
+ // value = value.join("")
391
+ node.styleStr = value
392
+ }
393
+ if (value.match(/ /)) {
394
+ value = value.split(' ')
395
+ }
396
+
397
+ // if attr already exists
398
+ // merge it
399
+ if (pre[name]) {
400
+ if (Array.isArray(pre[name])) {
401
+ // already array, push to last
402
+ pre[name].push(value)
403
+ } else {
404
+ // single value, make it array
405
+ pre[name] = [pre[name], value]
406
+ }
407
+ } else {
408
+ // not exist, put it
409
+ pre[name] = value
410
+ }
411
+
412
+ return pre
413
+ }, {})
414
+ }
415
+
416
+ if (node.tag === 'a') {
417
+ // a的图文子节点预览事件屏蔽
418
+ node.no_img_preview = true
419
+ }
420
+ //对img添加额外数据
421
+ if (node.tag === 'img') {
422
+ node.imgIndex = results.images.length
423
+ var imgUrl = node.attr.src
424
+ imgUrl = wxDiscode.urlToHttpUrl(imgUrl, __placeImgeUrlHttps)
425
+ node.attr.src = imgUrl
426
+ node.from = bindName
427
+ results.images.push(node)
428
+ results.imageUrls.push(imgUrl)
429
+ }
430
+
431
+ if (unary) {
432
+ // if this tag dosen't have end tag
433
+ // like <img src="hoge.png"/>
434
+ // add to parents
435
+ var parent = bufArray[0] || results
436
+ if (parent.nodes === undefined) {
437
+ parent.nodes = []
438
+ }
439
+ // 传递父节点的no_img_preview
440
+ if (parent['no_img_preview']) {
441
+ node.no_img_preview = true
442
+ }
443
+ parent.nodes.push(node)
444
+ } else {
445
+ // 传递父节点的no_img_preview
446
+ if (bufArray[0] && bufArray[0]['no_img_preview']) {
447
+ node.no_img_preview = true
448
+ }
449
+ bufArray.unshift(node)
450
+ }
451
+ },
452
+ end: function (tag) {
453
+ //debug(tag);
454
+ // merge into parent tag
455
+ var node = bufArray.shift()
456
+ if (node.tag !== tag) console.error('invalid state: mismatch end tag')
457
+
458
+ if (bufArray.length === 0) {
459
+ results.nodes.push(node)
460
+ } else {
461
+ var parent = bufArray[0]
462
+ if (parent.nodes === undefined) {
463
+ parent.nodes = []
464
+ }
465
+ parent.nodes.push(node)
466
+ }
467
+ //富文本list加序列号
468
+ if (node.tag === 'ul' || node.tag === 'ol') {
469
+ //去除自身富文本携带过来的padding-left
470
+ if (node.styleStr && node.styleStr.indexOf('padding-left:30px;') > -1) {
471
+ node.styleStr = node.styleStr.replace('padding-left:30px;', '')
472
+ }
473
+ if (!node?.nodes?.length) return
474
+ //递归给列表添加索引标准
475
+ if (node.styleStr && node.styleStr.indexOf('list-style-type') > -1) {
476
+ var listType = node.styleStr.split('list-style-type:')[1].split(';')[0].replace(' ', '')
477
+ //普通阿拉伯数字
478
+ switch (listType) {
479
+ case 'decimal':
480
+ for (let i = 0; i <= node.nodes.length - 1; i++) {
481
+ node.nodes[i].listText = i + 1 + '.'
482
+ node.nodes[i].listType = listType
483
+ }
484
+ break
485
+ case 'disc':
486
+ for (let i = 0; i <= node.nodes.length - 1; i++) {
487
+ node.nodes[i].listType = listType
488
+ }
489
+ break
490
+ case 'square':
491
+ for (let i = 0; i <= node.nodes.length - 1; i++) {
492
+ node.nodes[i].listType = listType
493
+ }
494
+ break
495
+ case 'circle':
496
+ for (let i = 0; i <= node.nodes.length - 1; i++) {
497
+ node.nodes[i].listType = listType
498
+ }
499
+ break
500
+ case 'lower-alpha':
501
+ for (let i = 0; i <= node.nodes.length - 1; i++) {
502
+ node.nodes[i].listText = getListText(listType, i + 1) + '.'
503
+ node.nodes[i].listType = listType
504
+ }
505
+ break
506
+ case 'lower-roman':
507
+ for (let i = 0; i <= node.nodes.length - 1; i++) {
508
+ node.nodes[i].listText = getListText(listType, i + 1) + '.'
509
+ node.nodes[i].listType = listType
510
+ }
511
+ break
512
+ case 'upper-alpha':
513
+ for (let i = 0; i <= node.nodes.length - 1; i++) {
514
+ node.nodes[i].listText = getListText(listType, i + 1) + '.'
515
+ node.nodes[i].listType = listType
516
+ }
517
+ break
518
+ case 'upper-roman':
519
+ for (let i = 0; i <= node.nodes.length - 1; i++) {
520
+ node.nodes[i].listText = getListText(listType, i + 1) + '.'
521
+ node.nodes[i].listType = listType
522
+ }
523
+ break
524
+ case 'cjk-ideographic':
525
+ for (let i = 0; i <= node.nodes.length - 1; i++) {
526
+ node.nodes[i].listText = getListText(listType, i + 1) + '.'
527
+ node.nodes[i].listType = listType
528
+ }
529
+ break
530
+ case 'lower-greek':
531
+ for (let i = 0; i <= node.nodes.length - 1; i++) {
532
+ node.nodes[i].listText = getListText(listType, i + 1) + '.'
533
+ node.nodes[i].listType = listType
534
+ }
535
+ break
536
+ default:
537
+ for (let i = 0; i <= node.nodes.length - 1; i++) {
538
+ node.nodes[i].listText = ''
539
+ node.nodes[i].listType = listType
540
+ }
541
+ }
542
+ }
543
+ }
544
+ },
545
+ chars: function (text) {
546
+ //debug(text);
547
+ var node = {
548
+ node: 'text',
549
+ text: text,
550
+ textArray: transEmojiStr(text),
551
+ }
552
+
553
+ if (bufArray.length === 0) {
554
+ results.nodes.push(node)
555
+ } else {
556
+ var parent = bufArray[0]
557
+ if (parent.nodes === undefined) {
558
+ parent.nodes = []
559
+ }
560
+ parent.nodes.push(node)
561
+ }
562
+ },
563
+ comment: function (text) {
564
+ //debug(text);
565
+ var node = {
566
+ node: 'comment',
567
+ text: text,
568
+ }
569
+ var parent = bufArray[0]
570
+ if (parent.nodes === undefined) {
571
+ parent.nodes = []
572
+ }
573
+ parent.nodes.push(node)
574
+ },
575
+ })
576
+ return results
577
+ }
578
+
579
+ function transEmojiStr(str) {
580
+ // var eReg = new RegExp("["+__reg+' '+"]");
581
+ // str = str.replace(/\[([^\[\]]+)\]/g,':$1:')
582
+
583
+ var emojiObjs = []
584
+ //如果正则表达式为空
585
+ if (__emojisReg.length == 0 || !__emojis) {
586
+ var emojiObj = {}
587
+ emojiObj.node = 'text'
588
+ emojiObj.text = str
589
+ array = [emojiObj]
590
+ return array
591
+ }
592
+ //这个地方需要调整
593
+ str = str.replace(/\[([^\[\]]+)\]/g, ':$1:')
594
+ var eReg = new RegExp('[:]')
595
+ var array = str.split(eReg)
596
+ for (var i = 0; i < array.length; i++) {
597
+ var ele = array[i]
598
+ const emojiObj = {}
599
+ if (__emojis[ele]) {
600
+ emojiObj.node = 'element'
601
+ emojiObj.tag = 'emoji'
602
+ emojiObj.text = __emojis[ele]
603
+ emojiObj.baseSrc = __emojisBaseSrc
604
+ } else {
605
+ emojiObj.node = 'text'
606
+ emojiObj.text = ele
607
+ }
608
+ emojiObjs.push(emojiObj)
609
+ }
610
+
611
+ return emojiObjs
612
+ }
613
+
614
+ function emojisInit(reg = '', baseSrc = '/wxParse/emojis/', emojis) {
615
+ __emojisReg = reg
616
+ __emojisBaseSrc = baseSrc
617
+ __emojis = emojis
618
+ }
619
+
620
+ module.exports = {
621
+ html2json: html2json,
622
+ emojisInit: emojisInit,
623
+ }