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.
- package/.prettierrc.js +32 -6
- package/miniprogram_dist/GoodsItem/index.json +6 -6
- package/miniprogram_dist/GoodsItem/index.wxs +18 -18
- package/miniprogram_dist/LiveGoodsList/Header/index.js +54 -54
- package/miniprogram_dist/LiveGoodsList/Header/index.json +6 -6
- package/miniprogram_dist/LiveGoodsList/Header/index.less +45 -45
- package/miniprogram_dist/LiveGoodsList/Header/index.scss +105 -105
- package/miniprogram_dist/LiveGoodsList/Header/index.wxml +32 -32
- package/miniprogram_dist/LiveGoodsList/README.md +9 -9
- package/miniprogram_dist/LiveGoodsList/index.json +8 -8
- package/miniprogram_dist/LiveGoodsList/index.less +53 -53
- package/miniprogram_dist/LiveGoodsList/index.scss +92 -92
- package/miniprogram_dist/Task/TaskBubble/index.js +2 -1
- package/miniprogram_dist/Task/TaskPopup/component/RewardList/index.js +23 -21
- package/miniprogram_dist/Task/TaskPopup/component/RewardList/index.wxml +1 -0
- package/miniprogram_dist/Task/TaskPopup/component/TaskItem/index.js +264 -169
- package/miniprogram_dist/Task/TaskPopup/component/TaskItem/index.scss +26 -0
- package/miniprogram_dist/Task/TaskPopup/component/TaskItem/index.wxml +32 -13
- package/miniprogram_dist/Task/TaskPopup/component/TaskItem/index.wxss +96 -0
- package/miniprogram_dist/Task/TaskPopup/component/TaskList/index.js +8 -0
- package/miniprogram_dist/Task/TaskPopup/component/TaskList/index.wxml +1 -0
- package/miniprogram_dist/Task/TaskPopup/component/TaskType/index.js +4 -0
- package/miniprogram_dist/Task/TaskPopup/component/TaskType/index.wxml +1 -0
- package/miniprogram_dist/Task/TaskPopup/index.js +76 -70
- package/miniprogram_dist/Task/TaskPopup/index.json +2 -2
- package/miniprogram_dist/Task/TaskPopup/index.wxml +2 -0
- package/miniprogram_dist/Task/TaskQuizPopup/components/quizContent/index.js +132 -0
- package/miniprogram_dist/Task/TaskQuizPopup/components/quizContent/index.json +6 -0
- package/miniprogram_dist/Task/TaskQuizPopup/components/quizContent/index.scss +192 -0
- package/miniprogram_dist/Task/TaskQuizPopup/components/quizContent/index.wxml +65 -0
- package/miniprogram_dist/Task/TaskQuizPopup/components/quizContent/index.wxs +79 -0
- package/miniprogram_dist/Task/TaskQuizPopup/components/quizContent/index.wxss +521 -0
- package/miniprogram_dist/Task/TaskQuizPopup/components/quizRichText/index.js +40 -0
- package/miniprogram_dist/Task/TaskQuizPopup/components/quizRichText/index.json +6 -0
- package/miniprogram_dist/Task/TaskQuizPopup/components/quizRichText/index.scss +7 -0
- package/miniprogram_dist/Task/TaskQuizPopup/components/quizRichText/index.wxml +2 -0
- package/miniprogram_dist/Task/TaskQuizPopup/components/quizRichText/index.wxss +298 -0
- package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/base.wxml +50 -0
- package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/html2json.js +623 -0
- package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/htmlparser.js +183 -0
- package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/iframeParse.js +216 -0
- package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/loop.wxml +3563 -0
- package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/showdown.js +2364 -0
- package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/wxDiscode.js +209 -0
- package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/wxParse.js +269 -0
- package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/wxParse.wxml +1276 -0
- package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/wxParse.wxss +316 -0
- package/miniprogram_dist/Task/TaskQuizPopup/index.js +225 -0
- package/miniprogram_dist/Task/TaskQuizPopup/index.json +8 -0
- package/miniprogram_dist/Task/TaskQuizPopup/index.scss +159 -0
- package/miniprogram_dist/Task/TaskQuizPopup/index.wxml +97 -0
- package/miniprogram_dist/Task/TaskQuizPopup/index.wxss +478 -0
- package/miniprogram_dist/Task/taskQuizRemindPopup/index.js +74 -0
- package/miniprogram_dist/Task/taskQuizRemindPopup/index.json +6 -0
- package/miniprogram_dist/Task/taskQuizRemindPopup/index.scss +108 -0
- package/miniprogram_dist/Task/taskQuizRemindPopup/index.wxml +27 -0
- package/miniprogram_dist/Task/taskQuizRemindPopup/index.wxss +286 -0
- package/miniprogram_dist/common/utils/tool.js +54 -48
- package/package.json +1 -1
- package/src/AliveInvite/LiveRoomVertical/index.wxss +252 -252
- package/src/CollectionAddress/index.wxss +5 -5
- package/src/ConfirmOrder/components/AddressEdit/index.wxss +120 -120
- package/src/ConfirmOrder/components/AddressManage/index.wxss +98 -98
- package/src/ConfirmOrder/components/AddressSelect/index.wxss +67 -67
- package/src/ConfirmOrder/components/ChoosePicker/index.wxss +18 -18
- package/src/ConfirmOrder/components/GoodsInfo/components/GoodsCommerce/components/entityGiftList/index.wxss +45 -45
- package/src/ConfirmOrder/components/GoodsInfo/components/GoodsCommerce/components/entityItem/index.wxss +100 -100
- package/src/ConfirmOrder/components/GoodsInfo/components/GoodsCommerce/index.wxss +55 -55
- package/src/ConfirmOrder/components/GoodsInfo/components/ImageData/index.wxss +13 -13
- package/src/ConfirmOrder/components/Header/index.wxss +26 -26
- package/src/ConfirmOrder/components/IntegralSelect/componenets/integralTips/index.wxss +85 -85
- package/src/ConfirmOrder/components/Invoice/components/InvoiceSelect/index.wxss +155 -155
- package/src/ConfirmOrder/components/Invoice/components/InvoiceTip/index.wxss +51 -51
- package/src/ConfirmOrder/components/ModeSelect/index.wxss +44 -44
- package/src/ConfirmOrder/components/PickupSelect/index.wxss +22 -22
- package/src/ConfirmOrder/components/SelectSite/index.wxss +82 -82
- package/src/ConfirmOrder/components/Shipper/index.wxss +76 -76
- package/src/ConfirmOrder/components/ShipperEdit/index.wxss +78 -78
- package/src/ConfirmOrder/components/WechatAddress/index.wxss +22 -22
- package/src/ConfirmOrder/index.wxss +5 -5
- package/src/CouponList/couponMsg/index.wxss +3 -3
- package/src/CustomPopup/index.wxss +22 -22
- package/src/GoodsItem/index.json +6 -6
- package/src/GoodsItem/index.wxs +18 -18
- package/src/LiveGoodsList/Header/index.js +54 -54
- package/src/LiveGoodsList/Header/index.json +6 -6
- package/src/LiveGoodsList/Header/index.less +45 -45
- package/src/LiveGoodsList/Header/index.scss +105 -105
- package/src/LiveGoodsList/Header/index.wxml +32 -32
- package/src/LiveGoodsList/README.md +9 -9
- package/src/LiveGoodsList/index.json +8 -8
- package/src/LiveGoodsList/index.less +53 -53
- package/src/LiveGoodsList/index.scss +92 -92
- package/src/LiveGoodsList/index.wxss +218 -218
- package/src/PayComplete/Components/CouponItem/index.wxss +122 -122
- package/src/PayComplete/Components/Header/index.wxss +27 -27
- package/src/PayComplete/Components/LeadGroup/index.wxss +33 -33
- package/src/PayComplete/Components/PayGifts/index.wxss +157 -157
- package/src/PayComplete/Components/PayState/earnIntegral/index.wxss +23 -23
- package/src/PayComplete/Components/PayState/index.wxss +20 -20
- package/src/PayComplete/index.wxss +27 -27
- package/src/PayModule/wechatLoading/index.wxss +57 -57
- package/src/Recommend/index.wxss +110 -110
- package/src/Sku/Header/index.wxss +27 -27
- package/src/Sku/goods-info/index.wxss +52 -52
- package/src/Sku/index/index.wxss +52 -52
- package/src/Sku/row-item/index.wxss +50 -50
- package/src/Sku/step/index.wxss +11 -11
- package/src/Task/TaskBubble/index.js +2 -1
- package/src/Task/TaskBubble/index.wxss +289 -289
- package/src/Task/TaskIcon/index.wxss +130 -130
- package/src/Task/TaskPopup/component/RewardList/index.js +23 -21
- package/src/Task/TaskPopup/component/RewardList/index.wxml +1 -0
- package/src/Task/TaskPopup/component/RewardList/index.wxss +18 -18
- package/src/Task/TaskPopup/component/TaskItem/index.js +264 -169
- package/src/Task/TaskPopup/component/TaskItem/index.scss +26 -0
- package/src/Task/TaskPopup/component/TaskItem/index.wxml +32 -13
- package/src/Task/TaskPopup/component/TaskItem/index.wxss +1 -394
- package/src/Task/TaskPopup/component/TaskList/index.js +8 -0
- package/src/Task/TaskPopup/component/TaskList/index.wxml +1 -0
- package/src/Task/TaskPopup/component/TaskList/index.wxss +118 -118
- package/src/Task/TaskPopup/component/TaskType/index.js +4 -0
- package/src/Task/TaskPopup/component/TaskType/index.wxml +1 -0
- package/src/Task/TaskPopup/component/TaskType/index.wxss +110 -110
- package/src/Task/TaskPopup/index.js +76 -70
- package/src/Task/TaskPopup/index.json +2 -2
- package/src/Task/TaskPopup/index.wxml +2 -0
- package/src/Task/TaskPopup/index.wxss +406 -406
- package/src/Task/TaskQuizPopup/components/quizContent/index.js +132 -0
- package/src/Task/TaskQuizPopup/components/quizContent/index.json +6 -0
- package/src/Task/TaskQuizPopup/components/quizContent/index.scss +192 -0
- package/src/Task/TaskQuizPopup/components/quizContent/index.wxml +65 -0
- package/src/Task/TaskQuizPopup/components/quizContent/index.wxs +79 -0
- package/src/Task/TaskQuizPopup/components/quizContent/index.wxss +1 -0
- package/src/Task/TaskQuizPopup/components/quizRichText/index.js +40 -0
- package/src/Task/TaskQuizPopup/components/quizRichText/index.json +6 -0
- package/src/Task/TaskQuizPopup/components/quizRichText/index.scss +7 -0
- package/src/Task/TaskQuizPopup/components/quizRichText/index.wxml +2 -0
- package/src/Task/TaskQuizPopup/components/quizRichText/index.wxss +1 -0
- package/src/Task/TaskQuizPopup/components/wxParse/base.wxml +50 -0
- package/src/Task/TaskQuizPopup/components/wxParse/html2json.js +623 -0
- package/src/Task/TaskQuizPopup/components/wxParse/htmlparser.js +183 -0
- package/src/Task/TaskQuizPopup/components/wxParse/iframeParse.js +216 -0
- package/src/Task/TaskQuizPopup/components/wxParse/loop.wxml +3563 -0
- package/src/Task/TaskQuizPopup/components/wxParse/showdown.js +2364 -0
- package/src/Task/TaskQuizPopup/components/wxParse/wxDiscode.js +209 -0
- package/src/Task/TaskQuizPopup/components/wxParse/wxParse.js +269 -0
- package/src/Task/TaskQuizPopup/components/wxParse/wxParse.wxml +1276 -0
- package/src/Task/TaskQuizPopup/components/wxParse/wxParse.wxss +283 -0
- package/src/Task/TaskQuizPopup/index.js +225 -0
- package/src/Task/TaskQuizPopup/index.json +8 -0
- package/src/Task/TaskQuizPopup/index.scss +159 -0
- package/src/Task/TaskQuizPopup/index.wxml +97 -0
- package/src/Task/TaskQuizPopup/index.wxss +1 -0
- package/src/Task/taskQuizRemindPopup/index.js +74 -0
- package/src/Task/taskQuizRemindPopup/index.json +6 -0
- package/src/Task/taskQuizRemindPopup/index.scss +108 -0
- package/src/Task/taskQuizRemindPopup/index.wxml +27 -0
- package/src/Task/taskQuizRemindPopup/index.wxss +1 -0
- package/src/Task/taskReceivePopup/customPrizes/index.wxss +220 -220
- package/src/Task/taskReceivePopup/index.wxss +1 -1
- package/src/Task/taskReceivePopup/integral/index.wxss +94 -94
- package/src/common/css/theme.wxss +16 -16
- package/src/common/utils/tool.js +54 -48
- package/src/miniprogram_npm/miniprogram-computed/index.js +1 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
// HTML 支持的数学符号
|
|
2
|
+
function strNumDiscode(str) {
|
|
3
|
+
str = str.replace(/∀/g, '∀')
|
|
4
|
+
str = str.replace(/∂/g, '∂')
|
|
5
|
+
str = str.replace(/&exists;/g, '∃')
|
|
6
|
+
str = str.replace(/∅/g, '∅')
|
|
7
|
+
str = str.replace(/∇/g, '∇')
|
|
8
|
+
str = str.replace(/∈/g, '∈')
|
|
9
|
+
str = str.replace(/∉/g, '∉')
|
|
10
|
+
str = str.replace(/∋/g, '∋')
|
|
11
|
+
str = str.replace(/∏/g, '∏')
|
|
12
|
+
str = str.replace(/∑/g, '∑')
|
|
13
|
+
str = str.replace(/−/g, '−')
|
|
14
|
+
str = str.replace(/∗/g, '∗')
|
|
15
|
+
str = str.replace(/√/g, '√')
|
|
16
|
+
str = str.replace(/∝/g, '∝')
|
|
17
|
+
str = str.replace(/∞/g, '∞')
|
|
18
|
+
str = str.replace(/∠/g, '∠')
|
|
19
|
+
str = str.replace(/∧/g, '∧')
|
|
20
|
+
str = str.replace(/∨/g, '∨')
|
|
21
|
+
str = str.replace(/∩/g, '∩')
|
|
22
|
+
str = str.replace(/∩/g, '∪')
|
|
23
|
+
str = str.replace(/∫/g, '∫')
|
|
24
|
+
str = str.replace(/∴/g, '∴')
|
|
25
|
+
str = str.replace(/∼/g, '∼')
|
|
26
|
+
str = str.replace(/≅/g, '≅')
|
|
27
|
+
str = str.replace(/≈/g, '≈')
|
|
28
|
+
str = str.replace(/≠/g, '≠')
|
|
29
|
+
str = str.replace(/≤/g, '≤')
|
|
30
|
+
str = str.replace(/≥/g, '≥')
|
|
31
|
+
str = str.replace(/⊂/g, '⊂')
|
|
32
|
+
str = str.replace(/⊃/g, '⊃')
|
|
33
|
+
str = str.replace(/⊄/g, '⊄')
|
|
34
|
+
str = str.replace(/⊆/g, '⊆')
|
|
35
|
+
str = str.replace(/⊇/g, '⊇')
|
|
36
|
+
str = str.replace(/⊕/g, '⊕')
|
|
37
|
+
str = str.replace(/⊗/g, '⊗')
|
|
38
|
+
str = str.replace(/⊥/g, '⊥')
|
|
39
|
+
str = str.replace(/⋅/g, '⋅')
|
|
40
|
+
return str
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//HTML 支持的希腊字母
|
|
44
|
+
function strGreeceDiscode(str) {
|
|
45
|
+
str = str.replace(/Α/g, 'Α')
|
|
46
|
+
str = str.replace(/Β/g, 'Β')
|
|
47
|
+
str = str.replace(/Γ/g, 'Γ')
|
|
48
|
+
str = str.replace(/Δ/g, 'Δ')
|
|
49
|
+
str = str.replace(/Ε/g, 'Ε')
|
|
50
|
+
str = str.replace(/Ζ/g, 'Ζ')
|
|
51
|
+
str = str.replace(/Η/g, 'Η')
|
|
52
|
+
str = str.replace(/Θ/g, 'Θ')
|
|
53
|
+
str = str.replace(/Ι/g, 'Ι')
|
|
54
|
+
str = str.replace(/Κ/g, 'Κ')
|
|
55
|
+
str = str.replace(/Λ/g, 'Λ')
|
|
56
|
+
str = str.replace(/Μ/g, 'Μ')
|
|
57
|
+
str = str.replace(/Ν/g, 'Ν')
|
|
58
|
+
str = str.replace(/Ξ/g, 'Ν')
|
|
59
|
+
str = str.replace(/Ο/g, 'Ο')
|
|
60
|
+
str = str.replace(/Π/g, 'Π')
|
|
61
|
+
str = str.replace(/Ρ/g, 'Ρ')
|
|
62
|
+
str = str.replace(/Σ/g, 'Σ')
|
|
63
|
+
str = str.replace(/Τ/g, 'Τ')
|
|
64
|
+
str = str.replace(/Υ/g, 'Υ')
|
|
65
|
+
str = str.replace(/Φ/g, 'Φ')
|
|
66
|
+
str = str.replace(/Χ/g, 'Χ')
|
|
67
|
+
str = str.replace(/Ψ/g, 'Ψ')
|
|
68
|
+
str = str.replace(/Ω/g, 'Ω')
|
|
69
|
+
|
|
70
|
+
str = str.replace(/α/g, 'α')
|
|
71
|
+
str = str.replace(/β/g, 'β')
|
|
72
|
+
str = str.replace(/γ/g, 'γ')
|
|
73
|
+
str = str.replace(/δ/g, 'δ')
|
|
74
|
+
str = str.replace(/ε/g, 'ε')
|
|
75
|
+
str = str.replace(/ζ/g, 'ζ')
|
|
76
|
+
str = str.replace(/η/g, 'η')
|
|
77
|
+
str = str.replace(/θ/g, 'θ')
|
|
78
|
+
str = str.replace(/ι/g, 'ι')
|
|
79
|
+
str = str.replace(/κ/g, 'κ')
|
|
80
|
+
str = str.replace(/λ/g, 'λ')
|
|
81
|
+
str = str.replace(/μ/g, 'μ')
|
|
82
|
+
str = str.replace(/ν/g, 'ν')
|
|
83
|
+
str = str.replace(/ξ/g, 'ξ')
|
|
84
|
+
str = str.replace(/ο/g, 'ο')
|
|
85
|
+
str = str.replace(/π/g, 'π')
|
|
86
|
+
str = str.replace(/ρ/g, 'ρ')
|
|
87
|
+
str = str.replace(/ς/g, 'ς')
|
|
88
|
+
str = str.replace(/σ/g, 'σ')
|
|
89
|
+
str = str.replace(/τ/g, 'τ')
|
|
90
|
+
str = str.replace(/υ/g, 'υ')
|
|
91
|
+
str = str.replace(/φ/g, 'φ')
|
|
92
|
+
str = str.replace(/χ/g, 'χ')
|
|
93
|
+
str = str.replace(/ψ/g, 'ψ')
|
|
94
|
+
str = str.replace(/ω/g, 'ω')
|
|
95
|
+
str = str.replace(/ϑ/g, 'ϑ')
|
|
96
|
+
str = str.replace(/ϒ/g, 'ϒ')
|
|
97
|
+
str = str.replace(/ϖ/g, 'ϖ')
|
|
98
|
+
str = str.replace(/·/g, '·')
|
|
99
|
+
return str
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
//
|
|
103
|
+
|
|
104
|
+
function strcharacterDiscode(str) {
|
|
105
|
+
// 加入常用解析
|
|
106
|
+
str = str.replace(/ /g, ' ')
|
|
107
|
+
str = str.replace(/"/g, '"')
|
|
108
|
+
str = str.replace(/&/g, '&')
|
|
109
|
+
|
|
110
|
+
str = str.replace(/</g, '‹')
|
|
111
|
+
str = str.replace(/>/g, '›')
|
|
112
|
+
|
|
113
|
+
str = str.replace(/'/g, "'")
|
|
114
|
+
|
|
115
|
+
// str = str.replace(/</g, '<');
|
|
116
|
+
// str = str.replace(/>/g, '>');
|
|
117
|
+
|
|
118
|
+
return str
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// HTML 支持的其他实体
|
|
122
|
+
function strOtherDiscode(str) {
|
|
123
|
+
str = str.replace(/Œ/g, 'Œ')
|
|
124
|
+
str = str.replace(/œ/g, 'œ')
|
|
125
|
+
str = str.replace(/Š/g, 'Š')
|
|
126
|
+
str = str.replace(/š/g, 'š')
|
|
127
|
+
str = str.replace(/Ÿ/g, 'Ÿ')
|
|
128
|
+
str = str.replace(/ƒ/g, 'ƒ')
|
|
129
|
+
str = str.replace(/ˆ/g, 'ˆ')
|
|
130
|
+
str = str.replace(/˜/g, '˜')
|
|
131
|
+
str = str.replace(/ /g, '')
|
|
132
|
+
str = str.replace(/ /g, '')
|
|
133
|
+
str = str.replace(/ /g, '')
|
|
134
|
+
str = str.replace(/‌/g, '')
|
|
135
|
+
str = str.replace(/‍/g, '')
|
|
136
|
+
str = str.replace(/‎/g, '')
|
|
137
|
+
str = str.replace(/‏/g, '')
|
|
138
|
+
str = str.replace(/–/g, '–')
|
|
139
|
+
str = str.replace(/—/g, '—')
|
|
140
|
+
str = str.replace(/‘/g, '‘')
|
|
141
|
+
str = str.replace(/’/g, '’')
|
|
142
|
+
str = str.replace(/‚/g, '‚')
|
|
143
|
+
str = str.replace(/“/g, '“')
|
|
144
|
+
str = str.replace(/”/g, '”')
|
|
145
|
+
str = str.replace(/„/g, '„')
|
|
146
|
+
str = str.replace(/†/g, '†')
|
|
147
|
+
str = str.replace(/‡/g, '‡')
|
|
148
|
+
str = str.replace(/•/g, '•')
|
|
149
|
+
str = str.replace(/…/g, '…')
|
|
150
|
+
str = str.replace(/‰/g, '‰')
|
|
151
|
+
str = str.replace(/′/g, '′')
|
|
152
|
+
str = str.replace(/″/g, '″')
|
|
153
|
+
str = str.replace(/‹/g, '‹')
|
|
154
|
+
str = str.replace(/›/g, '›')
|
|
155
|
+
str = str.replace(/‾/g, '‾')
|
|
156
|
+
str = str.replace(/€/g, '€')
|
|
157
|
+
str = str.replace(/™/g, '™')
|
|
158
|
+
|
|
159
|
+
str = str.replace(/←/g, '←')
|
|
160
|
+
str = str.replace(/↑/g, '↑')
|
|
161
|
+
str = str.replace(/→/g, '→')
|
|
162
|
+
str = str.replace(/↓/g, '↓')
|
|
163
|
+
str = str.replace(/↔/g, '↔')
|
|
164
|
+
str = str.replace(/↵/g, '↵')
|
|
165
|
+
str = str.replace(/⌈/g, '⌈')
|
|
166
|
+
str = str.replace(/⌉/g, '⌉')
|
|
167
|
+
|
|
168
|
+
str = str.replace(/⌊/g, '⌊')
|
|
169
|
+
str = str.replace(/⌋/g, '⌋')
|
|
170
|
+
str = str.replace(/◊/g, '◊')
|
|
171
|
+
str = str.replace(/♠/g, '♠')
|
|
172
|
+
str = str.replace(/♣/g, '♣')
|
|
173
|
+
str = str.replace(/♥/g, '♥')
|
|
174
|
+
|
|
175
|
+
str = str.replace(/♦/g, '♦')
|
|
176
|
+
|
|
177
|
+
return str
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function strMoreDiscode(str) {
|
|
181
|
+
str = str.replace(/\r\n/g, '')
|
|
182
|
+
// str = str.replace(/\n/g, "");
|
|
183
|
+
|
|
184
|
+
str = str.replace(/code/g, 'wxxxcode-style')
|
|
185
|
+
return str
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function strDiscode(str) {
|
|
189
|
+
// 屏蔽鸡肋字符串替换 否则会导致图文渲染过慢
|
|
190
|
+
// str = strNumDiscode(str);
|
|
191
|
+
// str = strGreeceDiscode(str);
|
|
192
|
+
str = strcharacterDiscode(str)
|
|
193
|
+
// str = strOtherDiscode(str);
|
|
194
|
+
str = strMoreDiscode(str)
|
|
195
|
+
return str
|
|
196
|
+
}
|
|
197
|
+
function urlToHttpUrl(url, rep) {
|
|
198
|
+
var patt1 = new RegExp('^//')
|
|
199
|
+
var result = patt1.test(url)
|
|
200
|
+
if (result) {
|
|
201
|
+
url = rep + ':' + url
|
|
202
|
+
}
|
|
203
|
+
return url
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
module.exports = {
|
|
207
|
+
strDiscode: strDiscode,
|
|
208
|
+
urlToHttpUrl: urlToHttpUrl,
|
|
209
|
+
}
|
|
@@ -0,0 +1,269 @@
|
|
|
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
|
+
/**
|
|
13
|
+
* utils函数引入
|
|
14
|
+
**/
|
|
15
|
+
import showdown from 'showdown.js'
|
|
16
|
+
import HtmlToJson from 'html2json.js'
|
|
17
|
+
/**
|
|
18
|
+
* 解析 iframe
|
|
19
|
+
**/
|
|
20
|
+
import iframeParse from './iframeParse.js'
|
|
21
|
+
/**
|
|
22
|
+
* 配置及公有属性
|
|
23
|
+
**/
|
|
24
|
+
/**
|
|
25
|
+
* 主函数入口区
|
|
26
|
+
**/
|
|
27
|
+
|
|
28
|
+
// can_select: 是否可选中文本 这里只根据该值进行是否可预览图文的判断(can_select为1-可选中,则可预览图文)
|
|
29
|
+
function wxParse(
|
|
30
|
+
bindName = 'wxParseData',
|
|
31
|
+
type = 'html',
|
|
32
|
+
data = '<div class="color:red;">数据不能为空</div>',
|
|
33
|
+
target,
|
|
34
|
+
can_select = 1,
|
|
35
|
+
) {
|
|
36
|
+
var that = target
|
|
37
|
+
that.setData({
|
|
38
|
+
imageComplete: false,
|
|
39
|
+
})
|
|
40
|
+
//缓存imageUrls和images
|
|
41
|
+
var articleBack = that.data.article ? true : false
|
|
42
|
+
var imageUrlsBack = []
|
|
43
|
+
var imagesBack = []
|
|
44
|
+
if (articleBack) {
|
|
45
|
+
imageUrlsBack = that.data.article.imageUrls
|
|
46
|
+
imagesBack = that.data.article.images
|
|
47
|
+
}
|
|
48
|
+
var transData = {} //存放转化后的数据
|
|
49
|
+
if (type == 'html') {
|
|
50
|
+
data = data.replace(/"/g, "'") // style样式
|
|
51
|
+
transData = HtmlToJson.html2json(data, bindName)
|
|
52
|
+
// console.log(JSON.stringify(transData, ' ', ' '));
|
|
53
|
+
} else if (type == 'md' || type == 'markdown') {
|
|
54
|
+
var converter = new showdown.Converter()
|
|
55
|
+
var html = converter.makeHtml(data)
|
|
56
|
+
transData = HtmlToJson.html2json(html, bindName)
|
|
57
|
+
// console.log(JSON.stringify(transData, ' ', ' '));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
console.log('iframeParse', transData)
|
|
61
|
+
|
|
62
|
+
// 处理 iframe ,转成 video 和 audio, 仅限于自用组件
|
|
63
|
+
return new Promise((resolve) => {
|
|
64
|
+
iframeParse(transData, function (res) {
|
|
65
|
+
transData = res
|
|
66
|
+
transData.view = {}
|
|
67
|
+
transData.can_select = can_select
|
|
68
|
+
// 图片预览数组处理
|
|
69
|
+
if (transData['imageUrls']) {
|
|
70
|
+
setTimeout(() => {
|
|
71
|
+
transData['imageUrls'] = imgListFormat(transData['imageUrls'])
|
|
72
|
+
}, 0)
|
|
73
|
+
}
|
|
74
|
+
var bindData = {}
|
|
75
|
+
bindData[bindName] = transData
|
|
76
|
+
|
|
77
|
+
//当为第二次进入详情时,对比缓存图片对图片进行宽度附值
|
|
78
|
+
if (articleBack) {
|
|
79
|
+
//最小循环
|
|
80
|
+
if (transData.imageUrls.length > imageUrlsBack.length) {
|
|
81
|
+
for (var i = 0; i <= imageUrlsBack.length - 1; i++) {
|
|
82
|
+
for (var j = 0; j <= transData.imageUrls.length - 1; j++) {
|
|
83
|
+
if (imageUrlsBack[i] == transData.imageUrls[j]) {
|
|
84
|
+
transData.images[j].width = imagesBack[i].width
|
|
85
|
+
break
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
for (var i = 0; i <= transData.imageUrls.length - 1; i++) {
|
|
91
|
+
for (var j = 0; j <= imageUrlsBack.length - 1; j++) {
|
|
92
|
+
if (transData.imageUrls[i] == imageUrlsBack[j]) {
|
|
93
|
+
transData.images[i].width = imagesBack[j].width
|
|
94
|
+
break
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
that.setData(
|
|
101
|
+
{
|
|
102
|
+
bindName: bindName,
|
|
103
|
+
[bindName]: transData,
|
|
104
|
+
},
|
|
105
|
+
() => {},
|
|
106
|
+
)
|
|
107
|
+
resolve()
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function wxParseTemArray(temArrayName, bindNameReg, total, that) {
|
|
113
|
+
var array = []
|
|
114
|
+
var temData = that.data
|
|
115
|
+
var obj = null
|
|
116
|
+
for (var i = 0; i < total; i++) {
|
|
117
|
+
var simArr = temData[bindNameReg + i].nodes
|
|
118
|
+
array.push(simArr)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
temArrayName = temArrayName || 'wxParseTemArray'
|
|
122
|
+
obj = JSON.parse('{"' + temArrayName + '":""}')
|
|
123
|
+
obj[temArrayName] = array
|
|
124
|
+
that.setData(obj)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 配置emojis
|
|
129
|
+
*
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
function emojisInit(reg = '', baseSrc = '/wxParse/emojis/', emojis) {
|
|
133
|
+
HtmlToJson.emojisInit(reg, baseSrc, emojis)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// 初始化图片bindload事件
|
|
137
|
+
function imageInit(instance) {
|
|
138
|
+
instance.imageLoad = imageLoad.bind(instance)
|
|
139
|
+
instance.showNoSupportUrl = showNoSupportUrl.bind(instance)
|
|
140
|
+
// 图片预览
|
|
141
|
+
instance.wxParsePreview = wxParsePreview.bind(instance)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
let timeId = null
|
|
145
|
+
|
|
146
|
+
// 图片bindload事件(设置图片真实宽度)
|
|
147
|
+
function imageLoad(e, that) {
|
|
148
|
+
return new Promise((resolve) => {
|
|
149
|
+
let instance = that
|
|
150
|
+
let width = e.detail.width //获取图片真实宽度
|
|
151
|
+
let height = e.detail.height //获取图片真实宽度
|
|
152
|
+
let index = e.target.dataset.idx
|
|
153
|
+
let bindName = instance.data.bindName
|
|
154
|
+
let import_width = false // 是否使用强制宽度覆盖auto属性
|
|
155
|
+
let item = instance.data[bindName]['images'][index]
|
|
156
|
+
item.show = false
|
|
157
|
+
// 该图片有样式
|
|
158
|
+
if (item.attr && item.attr.style) {
|
|
159
|
+
let style = item.attr.style
|
|
160
|
+
for (let i = 0; i < style.length; i++) {
|
|
161
|
+
if (style[i] == 'width:') {
|
|
162
|
+
if (style[i + 1].indexOf('auto') >= 0) {
|
|
163
|
+
import_width = true // 使用强制宽度覆盖auto
|
|
164
|
+
} else {
|
|
165
|
+
import_width = false // 不使用强制宽度
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
item.attr.style = style
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (import_width) {
|
|
173
|
+
item.width = width + 'px!important'
|
|
174
|
+
item.importWidth = 'width:' + width + 'px!important' // 使用强制宽度覆盖auto
|
|
175
|
+
} else {
|
|
176
|
+
item.width = width + 'px'
|
|
177
|
+
item.importWidth = ''
|
|
178
|
+
}
|
|
179
|
+
wx.getSystemInfo({
|
|
180
|
+
success: (result) => {
|
|
181
|
+
// let width = item.width
|
|
182
|
+
if (Number(item.width.split('px')[0]) > result.windowWidth / 2 - 34) {
|
|
183
|
+
item.center = true
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
fail: () => {},
|
|
187
|
+
complete: () => {},
|
|
188
|
+
})
|
|
189
|
+
instance.data[bindName]['images'][index] = item
|
|
190
|
+
let bindData = {}
|
|
191
|
+
bindData[bindName] = instance.data[bindName]
|
|
192
|
+
// 防止多次setData,0.25s内最多执行一次
|
|
193
|
+
if (timeId == null) {
|
|
194
|
+
timeId = setTimeout(() => {
|
|
195
|
+
instance.setData(bindData)
|
|
196
|
+
clearTimeout(timeId)
|
|
197
|
+
timeId = null
|
|
198
|
+
}, 250)
|
|
199
|
+
}
|
|
200
|
+
// instance.setData({
|
|
201
|
+
// imageComplete:true
|
|
202
|
+
// })
|
|
203
|
+
item.show = true
|
|
204
|
+
resolve()
|
|
205
|
+
})
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function showNoSupportUrl(e) {
|
|
209
|
+
let copy_text = e.currentTarget.dataset.url
|
|
210
|
+
wx.showModal({
|
|
211
|
+
title: '提示',
|
|
212
|
+
confirmText: '复制链接',
|
|
213
|
+
content: '小程序暂不支持跳转外部链接',
|
|
214
|
+
success: function (res) {
|
|
215
|
+
if (res.confirm) {
|
|
216
|
+
if (wx.setClipboardData) {
|
|
217
|
+
wx.setClipboardData({
|
|
218
|
+
data: copy_text,
|
|
219
|
+
})
|
|
220
|
+
} else {
|
|
221
|
+
wx.showModal({
|
|
222
|
+
content: '复制失败,请更新微信版本后重试',
|
|
223
|
+
showCancel: false,
|
|
224
|
+
})
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
})
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// 图片预览事件
|
|
232
|
+
function wxParsePreview(e) {
|
|
233
|
+
let instance = this
|
|
234
|
+
let bindName = instance.data.bindName
|
|
235
|
+
let articleData = instance.data[bindName],
|
|
236
|
+
can_select = articleData.can_select,
|
|
237
|
+
imageUrls = articleData.imageUrls
|
|
238
|
+
let index = e.target.dataset.idx
|
|
239
|
+
let no_img_preview = e.target.dataset.no_img_preview
|
|
240
|
+
// can_select-1 关闭图文防复制开关(可预览图文) 0-打开图文防复制开关(不可预览图文)
|
|
241
|
+
// no_img_preview: true-不可预览(a标签下的图片都不能预览,防止事件重叠)
|
|
242
|
+
if (can_select && !no_img_preview) {
|
|
243
|
+
wx.previewImage({
|
|
244
|
+
current: imageUrls[index],
|
|
245
|
+
urls: imageUrls,
|
|
246
|
+
})
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// 预览图片数组处理(一个图片标签包含多个src 取第一个)
|
|
251
|
+
function imgListFormat(data) {
|
|
252
|
+
if (Array.isArray(data)) {
|
|
253
|
+
for (let i = data.length; 0 <= i; i--) {
|
|
254
|
+
// 若包含多个src,取第一个
|
|
255
|
+
if (Array.isArray(data[i])) {
|
|
256
|
+
data[i] = data[i][0]
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return data
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
module.exports = {
|
|
264
|
+
wxParse: wxParse,
|
|
265
|
+
wxParseTemArray: wxParseTemArray,
|
|
266
|
+
emojisInit: emojisInit,
|
|
267
|
+
imageInit: imageInit,
|
|
268
|
+
imageLoad: imageLoad,
|
|
269
|
+
}
|