xiaoe_mp_npm 1.1.21 → 1.1.22-test02

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 (418) hide show
  1. package/.babelrc +10 -10
  2. package/.eslintrc.js +102 -102
  3. package/.gitlab-ci.yml +44 -44
  4. package/.prettierrc.js +34 -34
  5. package/.vscode/extensions.json +4 -4
  6. package/.vscode/settings.json +9 -9
  7. package/LICENSE +21 -21
  8. package/README.md +134 -134
  9. package/gulpfile.js +26 -26
  10. package/miniprogram_dist/AliveInvite/LiveRoomVertical/components/friends/friends.js +181 -181
  11. package/miniprogram_dist/AliveInvite/LiveRoomVertical/components/friends/friends.wxml +25 -25
  12. package/miniprogram_dist/AliveInvite/LiveRoomVertical/index.js +253 -253
  13. package/miniprogram_dist/AliveInvite/LiveRoomVertical/index.less +255 -255
  14. package/miniprogram_dist/AliveInvite/LiveRoomVertical/index.wxml +122 -122
  15. package/miniprogram_dist/CollectionAddress/index.js +288 -288
  16. package/miniprogram_dist/CollectionAddress/index.json +13 -13
  17. package/miniprogram_dist/CollectionAddress/index.less +4 -4
  18. package/miniprogram_dist/CollectionAddress/index.wxml +93 -93
  19. package/miniprogram_dist/ConfirmOrder/components/AddressEdit/index.json +10 -10
  20. package/miniprogram_dist/ConfirmOrder/components/AddressEdit/index.less +123 -123
  21. package/miniprogram_dist/ConfirmOrder/components/AddressEdit/index.wxml +51 -51
  22. package/miniprogram_dist/ConfirmOrder/components/AddressManage/index.js +168 -168
  23. package/miniprogram_dist/ConfirmOrder/components/AddressManage/index.json +7 -7
  24. package/miniprogram_dist/ConfirmOrder/components/AddressManage/index.less +95 -95
  25. package/miniprogram_dist/ConfirmOrder/components/AddressManage/index.wxml +36 -36
  26. package/miniprogram_dist/ConfirmOrder/components/AddressSelect/index.js +160 -160
  27. package/miniprogram_dist/ConfirmOrder/components/AddressSelect/index.json +4 -4
  28. package/miniprogram_dist/ConfirmOrder/components/AddressSelect/index.less +79 -79
  29. package/miniprogram_dist/ConfirmOrder/components/AddressSelect/index.wxml +33 -33
  30. package/miniprogram_dist/ConfirmOrder/components/ChoosePicker/index.js +115 -115
  31. package/miniprogram_dist/ConfirmOrder/components/ChoosePicker/index.json +5 -5
  32. package/miniprogram_dist/ConfirmOrder/components/ChoosePicker/index.less +20 -20
  33. package/miniprogram_dist/ConfirmOrder/components/ChoosePicker/index.wxml +9 -9
  34. package/miniprogram_dist/ConfirmOrder/components/ConfirmOrderContent/index.js +1819 -1819
  35. package/miniprogram_dist/ConfirmOrder/components/ConfirmOrderContent/index.json +27 -27
  36. package/miniprogram_dist/ConfirmOrder/components/ConfirmOrderContent/index.scss +44 -44
  37. package/miniprogram_dist/ConfirmOrder/components/ConfirmOrderContent/index.wxml +225 -225
  38. package/miniprogram_dist/ConfirmOrder/components/GoodsInfo/components/CopGoodsList/index.js +129 -129
  39. package/miniprogram_dist/ConfirmOrder/components/GoodsInfo/components/CopGoodsList/index.json +8 -8
  40. package/miniprogram_dist/ConfirmOrder/components/GoodsInfo/components/CopGoodsList/index.scss +58 -58
  41. package/miniprogram_dist/ConfirmOrder/components/GoodsInfo/components/CopGoodsList/index.wxml +25 -25
  42. package/miniprogram_dist/GoodsItem/index.js +180 -21
  43. package/miniprogram_dist/GoodsItem/index.scss +822 -627
  44. package/miniprogram_dist/GoodsItem/index.wxml +145 -108
  45. package/miniprogram_dist/GoodsItem/index.wxs +40 -40
  46. package/miniprogram_dist/GoodsItem/index.wxss +1149 -461
  47. package/miniprogram_dist/LiveGoodsList/Header/index.js +65 -65
  48. package/miniprogram_dist/LiveGoodsList/Header/index.json +6 -6
  49. package/miniprogram_dist/LiveGoodsList/Header/index.less +45 -45
  50. package/miniprogram_dist/LiveGoodsList/Header/index.scss +157 -137
  51. package/miniprogram_dist/LiveGoodsList/Header/index.wxml +39 -36
  52. package/miniprogram_dist/LiveGoodsList/Header/index.wxss +88 -12
  53. package/miniprogram_dist/LiveGoodsList/README.md +9 -9
  54. package/miniprogram_dist/LiveGoodsList/index.js +29 -10
  55. package/miniprogram_dist/LiveGoodsList/index.less +53 -53
  56. package/miniprogram_dist/LiveGoodsList/index.scss +173 -173
  57. package/miniprogram_dist/LiveGoodsList/index.wxml +9 -1
  58. package/miniprogram_dist/MatchList/index.js +445 -441
  59. package/miniprogram_dist/MatchList/index.json +5 -5
  60. package/miniprogram_dist/MatchList/index.scss +175 -175
  61. package/miniprogram_dist/MatchList/index.wxml +98 -97
  62. package/miniprogram_dist/MemberIntegralMultiplierBar/index.js +196 -196
  63. package/miniprogram_dist/MemberIntegralMultiplierBar/index.json +7 -7
  64. package/miniprogram_dist/MemberIntegralMultiplierBar/index.scss +67 -67
  65. package/miniprogram_dist/MemberIntegralMultiplierBar/index.wxml +8 -8
  66. package/miniprogram_dist/MemberIntegralMultiplierPopup/index.js +54 -54
  67. package/miniprogram_dist/MemberIntegralMultiplierPopup/index.json +7 -7
  68. package/miniprogram_dist/MemberIntegralMultiplierPopup/index.scss +86 -86
  69. package/miniprogram_dist/MemberIntegralMultiplierPopup/index.wxml +48 -48
  70. package/miniprogram_dist/MemberIntegralMultiplierPopup/popup-service.js +18 -18
  71. package/miniprogram_dist/MsgBubble/index.js +312 -0
  72. package/miniprogram_dist/MsgBubble/index.json +7 -0
  73. package/miniprogram_dist/MsgBubble/index.scss +81 -0
  74. package/miniprogram_dist/MsgBubble/index.wxml +19 -0
  75. package/miniprogram_dist/MsgBubble/index.wxss +202 -0
  76. package/miniprogram_dist/ShoppingCartBubble/index.js +336 -156
  77. package/miniprogram_dist/ShoppingCartBubble/index.scss +94 -55
  78. package/miniprogram_dist/ShoppingCartBubble/index.wxml +14 -11
  79. package/miniprogram_dist/ShoppingCartBubble/index.wxss +196 -40
  80. package/miniprogram_dist/Task/TaskBubble/index.json +3 -3
  81. package/miniprogram_dist/Task/TaskBubble/index.scss +125 -125
  82. package/miniprogram_dist/Task/TaskBubble/index.wxml +22 -22
  83. package/miniprogram_dist/Task/TaskIcon/index.js +29 -29
  84. package/miniprogram_dist/Task/TaskIcon/index.json +4 -4
  85. package/miniprogram_dist/Task/TaskIcon/index.scss +70 -70
  86. package/miniprogram_dist/Task/TaskIcon/index.wxml +5 -5
  87. package/miniprogram_dist/Task/TaskPopup/component/RewardList/index.js +52 -52
  88. package/miniprogram_dist/Task/TaskPopup/component/RewardList/index.json +6 -6
  89. package/miniprogram_dist/Task/TaskPopup/component/RewardList/index.scss +39 -39
  90. package/miniprogram_dist/Task/TaskPopup/component/RewardList/index.wxml +23 -23
  91. package/miniprogram_dist/Task/TaskPopup/component/TaskItem/index.js +578 -578
  92. package/miniprogram_dist/Task/TaskPopup/component/TaskItem/index.json +10 -10
  93. package/miniprogram_dist/Task/TaskPopup/component/TaskItem/index.scss +245 -245
  94. package/miniprogram_dist/Task/TaskPopup/component/TaskItem/index.wxml +145 -145
  95. package/miniprogram_dist/Task/TaskPopup/component/TaskItem/index.wxs +7 -7
  96. package/miniprogram_dist/Task/TaskPopup/component/TaskList/index.js +298 -298
  97. package/miniprogram_dist/Task/TaskPopup/component/TaskList/index.json +7 -7
  98. package/miniprogram_dist/Task/TaskPopup/component/TaskList/index.scss +66 -66
  99. package/miniprogram_dist/Task/TaskPopup/component/TaskList/index.wxml +41 -41
  100. package/miniprogram_dist/Task/TaskPopup/component/TaskType/index.js +129 -129
  101. package/miniprogram_dist/Task/TaskPopup/component/TaskType/index.json +13 -13
  102. package/miniprogram_dist/Task/TaskPopup/component/TaskType/index.scss +90 -90
  103. package/miniprogram_dist/Task/TaskPopup/component/TaskType/index.wxml +69 -69
  104. package/miniprogram_dist/Task/TaskPopup/index.js +174 -174
  105. package/miniprogram_dist/Task/TaskPopup/index.json +7 -7
  106. package/miniprogram_dist/Task/TaskPopup/index.scss +166 -166
  107. package/miniprogram_dist/Task/TaskPopup/index.wxml +87 -87
  108. package/miniprogram_dist/Task/TaskQuizPopup/components/quizContent/index.js +131 -131
  109. package/miniprogram_dist/Task/TaskQuizPopup/components/quizContent/index.json +5 -5
  110. package/miniprogram_dist/Task/TaskQuizPopup/components/quizContent/index.scss +191 -191
  111. package/miniprogram_dist/Task/TaskQuizPopup/components/quizContent/index.wxml +64 -64
  112. package/miniprogram_dist/Task/TaskQuizPopup/components/quizContent/index.wxs +78 -78
  113. package/miniprogram_dist/Task/TaskQuizPopup/components/quizRichText/index.js +40 -40
  114. package/miniprogram_dist/Task/TaskQuizPopup/components/quizRichText/index.json +5 -5
  115. package/miniprogram_dist/Task/TaskQuizPopup/components/quizRichText/index.scss +6 -6
  116. package/miniprogram_dist/Task/TaskQuizPopup/components/quizRichText/index.wxml +1 -1
  117. package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/base.wxml +50 -50
  118. package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/html2json.js +623 -623
  119. package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/htmlparser.js +183 -183
  120. package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/iframeParse.js +216 -216
  121. package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/loop.wxml +3563 -3563
  122. package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/showdown.js +2364 -2364
  123. package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/wxDiscode.js +209 -209
  124. package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/wxParse.js +269 -269
  125. package/miniprogram_dist/Task/TaskQuizPopup/components/wxParse/wxParse.wxml +1276 -1276
  126. package/miniprogram_dist/Task/TaskQuizPopup/index.js +246 -246
  127. package/miniprogram_dist/Task/TaskQuizPopup/index.json +7 -7
  128. package/miniprogram_dist/Task/TaskQuizPopup/index.scss +158 -158
  129. package/miniprogram_dist/Task/TaskQuizPopup/index.wxml +99 -99
  130. package/miniprogram_dist/Task/common/task.js +55 -55
  131. package/miniprogram_dist/Task/taskQuizRemindPopup/index.js +74 -74
  132. package/miniprogram_dist/Task/taskQuizRemindPopup/index.json +5 -5
  133. package/miniprogram_dist/Task/taskQuizRemindPopup/index.scss +107 -107
  134. package/miniprogram_dist/Task/taskQuizRemindPopup/index.wxml +27 -27
  135. package/miniprogram_dist/Task/taskReceivePopup/coupon/index.js +68 -68
  136. package/miniprogram_dist/Task/taskReceivePopup/coupon/index.json +6 -6
  137. package/miniprogram_dist/Task/taskReceivePopup/coupon/index.scss +123 -123
  138. package/miniprogram_dist/Task/taskReceivePopup/coupon/index.wxml +81 -81
  139. package/miniprogram_dist/Task/taskReceivePopup/coupon/index.wxs +48 -48
  140. package/miniprogram_dist/Task/taskReceivePopup/customPrizes/index.js +44 -44
  141. package/miniprogram_dist/Task/taskReceivePopup/customPrizes/index.json +6 -6
  142. package/miniprogram_dist/Task/taskReceivePopup/customPrizes/index.scss +106 -106
  143. package/miniprogram_dist/Task/taskReceivePopup/customPrizes/index.wxml +38 -38
  144. package/miniprogram_dist/Task/taskReceivePopup/customPrizes/index.wxs +48 -48
  145. package/miniprogram_dist/Task/taskReceivePopup/index.js +47 -47
  146. package/miniprogram_dist/Task/taskReceivePopup/index.json +13 -13
  147. package/miniprogram_dist/Task/taskReceivePopup/index.wxml +32 -32
  148. package/miniprogram_dist/Task/taskReceivePopup/integral/index.js +106 -106
  149. package/miniprogram_dist/Task/taskReceivePopup/integral/index.json +7 -7
  150. package/miniprogram_dist/Task/taskReceivePopup/integral/index.scss +60 -60
  151. package/miniprogram_dist/Task/taskReceivePopup/integral/index.wxml +23 -23
  152. package/miniprogram_dist/TeacherGoodsList/index.js +997 -983
  153. package/miniprogram_dist/TeacherGoodsList/index.json +10 -10
  154. package/miniprogram_dist/TeacherGoodsList/index.scss +178 -178
  155. package/miniprogram_dist/TeacherGoodsList/index.wxml +146 -144
  156. package/miniprogram_dist/common/api/liveGoodsList.js +181 -167
  157. package/miniprogram_dist/common/assets/images/coupon/emptypage.svg +49 -49
  158. package/miniprogram_dist/common/assets/images/coupon/failed.svg +5 -5
  159. package/miniprogram_dist/common/assets/images/coupon/up.svg +21 -21
  160. package/miniprogram_dist/common/assets/images/pay/loading.svg +3 -3
  161. package/miniprogram_dist/common/assets/images/recommend.svg +6 -6
  162. package/miniprogram_dist/common/assets/images/refresh.svg +10 -10
  163. package/miniprogram_dist/common/assets/images/refresh_white.svg +3 -3
  164. package/miniprogram_dist/common/assets/images/wechat.svg +4 -4
  165. package/miniprogram_dist/common/css/index.less +2 -2
  166. package/miniprogram_dist/common/css/theme.less +19 -19
  167. package/miniprogram_dist/common/libs/dataUp/sensorUp.js +91 -91
  168. package/miniprogram_dist/common/libs/playerHttp.js +58 -58
  169. package/miniprogram_dist/common/libs/playerRequestUrl.js +39 -39
  170. package/miniprogram_dist/common/transaction/parameter/channel-info.js +36 -36
  171. package/miniprogram_dist/common/transaction/parameter/delivery-info.js +26 -26
  172. package/miniprogram_dist/common/transaction/parameter/misc-parameter.js +21 -21
  173. package/miniprogram_dist/common/utils/currency.js +52 -52
  174. package/miniprogram_dist/common/utils/getInfoCollectionData.js +59 -59
  175. package/miniprogram_dist/common/utils/image-cdn-slim/constant.js +8 -8
  176. package/miniprogram_dist/common/utils/image-cdn-slim/index.js +7 -7
  177. package/miniprogram_dist/common/utils/image-cdn-slim/utils.js +156 -156
  178. package/miniprogram_dist/common/utils/index.js +86 -86
  179. package/miniprogram_dist/common/utils/liveGoods.js +217 -217
  180. package/miniprogram_dist/common/utils/specialList.js +5 -5
  181. package/miniprogram_dist/common/utils/tool.js +72 -72
  182. package/miniprogram_dist/common/wxs/filter.wxs +29 -29
  183. package/miniprogram_dist/index.js +6 -6
  184. package/miniprogram_dist/index.js.map +1 -1
  185. package/miniprogram_dist/lib.js.map +1 -1
  186. package/package.json +78 -78
  187. package/project.config.json +79 -79
  188. package/src/AliveInvite/LiveRoomVertical/components/friends/friends.js +181 -181
  189. package/src/AliveInvite/LiveRoomVertical/components/friends/friends.wxml +25 -25
  190. package/src/AliveInvite/LiveRoomVertical/components/friends/friends.wxss +97 -97
  191. package/src/AliveInvite/LiveRoomVertical/index.js +253 -253
  192. package/src/AliveInvite/LiveRoomVertical/index.less +255 -255
  193. package/src/AliveInvite/LiveRoomVertical/index.wxml +122 -122
  194. package/src/AliveInvite/LiveRoomVertical/index.wxss +252 -252
  195. package/src/CollectionAddress/index.js +288 -288
  196. package/src/CollectionAddress/index.json +13 -13
  197. package/src/CollectionAddress/index.less +4 -4
  198. package/src/CollectionAddress/index.wxml +93 -93
  199. package/src/CollectionAddress/index.wxss +5 -5
  200. package/src/ConfirmOrder/components/AddressEdit/index.json +10 -10
  201. package/src/ConfirmOrder/components/AddressEdit/index.less +123 -123
  202. package/src/ConfirmOrder/components/AddressEdit/index.wxml +51 -51
  203. package/src/ConfirmOrder/components/AddressEdit/index.wxss +120 -120
  204. package/src/ConfirmOrder/components/AddressManage/index.js +168 -168
  205. package/src/ConfirmOrder/components/AddressManage/index.json +7 -7
  206. package/src/ConfirmOrder/components/AddressManage/index.less +95 -95
  207. package/src/ConfirmOrder/components/AddressManage/index.wxml +36 -36
  208. package/src/ConfirmOrder/components/AddressManage/index.wxss +98 -98
  209. package/src/ConfirmOrder/components/AddressSelect/index.js +160 -160
  210. package/src/ConfirmOrder/components/AddressSelect/index.json +4 -4
  211. package/src/ConfirmOrder/components/AddressSelect/index.less +79 -79
  212. package/src/ConfirmOrder/components/AddressSelect/index.wxml +33 -33
  213. package/src/ConfirmOrder/components/AddressSelect/index.wxss +67 -67
  214. package/src/ConfirmOrder/components/ChoosePicker/index.js +115 -115
  215. package/src/ConfirmOrder/components/ChoosePicker/index.json +5 -5
  216. package/src/ConfirmOrder/components/ChoosePicker/index.less +20 -20
  217. package/src/ConfirmOrder/components/ChoosePicker/index.wxml +9 -9
  218. package/src/ConfirmOrder/components/ChoosePicker/index.wxss +18 -18
  219. package/src/ConfirmOrder/components/ConfirmOrderContent/index.js +1819 -1819
  220. package/src/ConfirmOrder/components/ConfirmOrderContent/index.json +27 -27
  221. package/src/ConfirmOrder/components/ConfirmOrderContent/index.scss +44 -44
  222. package/src/ConfirmOrder/components/ConfirmOrderContent/index.wxml +225 -225
  223. package/src/ConfirmOrder/components/ConfirmOrderContent/index.wxss +37 -37
  224. package/src/ConfirmOrder/components/GoodsInfo/components/CopGoodsList/index.js +129 -129
  225. package/src/ConfirmOrder/components/GoodsInfo/components/CopGoodsList/index.json +8 -8
  226. package/src/ConfirmOrder/components/GoodsInfo/components/CopGoodsList/index.scss +58 -58
  227. package/src/ConfirmOrder/components/GoodsInfo/components/CopGoodsList/index.wxml +25 -25
  228. package/src/ConfirmOrder/components/GoodsInfo/components/CopGoodsList/index.wxss +1 -1
  229. package/src/ConfirmOrder/components/GoodsInfo/index.wxss +1 -1
  230. package/src/ConfirmOrder/components/IntegralSelect/index.wxss +218 -218
  231. package/src/ConfirmOrder/components/Invoice/index.wxss +93 -93
  232. package/src/ConfirmOrder/components/LeaveWord/index.wxss +1 -1
  233. package/src/ConfirmOrder/components/OrderBubble/index.wxss +1 -1
  234. package/src/ConfirmOrder/components/PayBar/index.wxss +1 -1
  235. package/src/ConfirmOrder/components/PayDetail/index.wxss +78 -78
  236. package/src/ConfirmOrder/components/SvipSelect/SvipSelect.wxss +266 -266
  237. package/src/CopGoodsCard/index.wxss +1 -1
  238. package/src/CouponList/components/CouponItem/index.wxss +1 -1
  239. package/src/CouponList/components/couponIcon/index.wxss +1 -1
  240. package/src/CouponList/stuCouponPopup/index.wxss +1 -1
  241. package/src/CouponReceivePopup/index.wxss +1 -1
  242. package/src/CustomPopup/index.wxss +37 -37
  243. package/src/GoodsBubble/index.wxss +1 -1
  244. package/src/GoodsItem/index.js +180 -21
  245. package/src/GoodsItem/index.scss +822 -627
  246. package/src/GoodsItem/index.wxml +145 -108
  247. package/src/GoodsItem/index.wxs +40 -40
  248. package/src/GoodsItem/index.wxss +1 -1
  249. package/src/GoodsRecommend/index.wxss +537 -537
  250. package/src/LevelMemberBar/index.wxss +1 -1
  251. package/src/LiveGoodsList/Header/index.js +65 -65
  252. package/src/LiveGoodsList/Header/index.json +6 -6
  253. package/src/LiveGoodsList/Header/index.less +45 -45
  254. package/src/LiveGoodsList/Header/index.scss +157 -137
  255. package/src/LiveGoodsList/Header/index.wxml +39 -36
  256. package/src/LiveGoodsList/Header/index.wxss +1 -1
  257. package/src/LiveGoodsList/README.md +9 -9
  258. package/src/LiveGoodsList/index.js +29 -10
  259. package/src/LiveGoodsList/index.less +53 -53
  260. package/src/LiveGoodsList/index.scss +173 -173
  261. package/src/LiveGoodsList/index.wxml +9 -1
  262. package/src/LiveGoodsList/index.wxss +1 -1
  263. package/src/MatchList/index.js +445 -441
  264. package/src/MatchList/index.json +5 -5
  265. package/src/MatchList/index.scss +175 -175
  266. package/src/MatchList/index.wxml +98 -97
  267. package/src/MatchList/index.wxss +1 -1
  268. package/src/MemberIntegralMultiplierBar/index.js +196 -196
  269. package/src/MemberIntegralMultiplierBar/index.json +7 -7
  270. package/src/MemberIntegralMultiplierBar/index.scss +67 -67
  271. package/src/MemberIntegralMultiplierBar/index.wxml +8 -8
  272. package/src/MemberIntegralMultiplierBar/index.wxss +1 -1
  273. package/src/MemberIntegralMultiplierPopup/index.js +54 -54
  274. package/src/MemberIntegralMultiplierPopup/index.json +7 -7
  275. package/src/MemberIntegralMultiplierPopup/index.scss +86 -86
  276. package/src/MemberIntegralMultiplierPopup/index.wxml +48 -48
  277. package/src/MemberIntegralMultiplierPopup/index.wxss +1 -1
  278. package/src/MemberIntegralMultiplierPopup/popup-service.js +18 -18
  279. package/src/MsgBubble/index.js +312 -0
  280. package/src/MsgBubble/index.json +7 -0
  281. package/src/MsgBubble/index.scss +81 -0
  282. package/src/MsgBubble/index.wxml +19 -0
  283. package/src/MsgBubble/index.wxss +1 -0
  284. package/src/PayModule/button/index.wxss +58 -58
  285. package/src/ShoppingCartBubble/index.js +336 -156
  286. package/src/ShoppingCartBubble/index.scss +94 -55
  287. package/src/ShoppingCartBubble/index.wxml +14 -11
  288. package/src/ShoppingCartBubble/index.wxss +1 -1
  289. package/src/Task/TaskBubble/index.json +3 -3
  290. package/src/Task/TaskBubble/index.scss +125 -125
  291. package/src/Task/TaskBubble/index.wxml +22 -22
  292. package/src/Task/TaskBubble/index.wxss +289 -289
  293. package/src/Task/TaskIcon/index.js +29 -29
  294. package/src/Task/TaskIcon/index.json +4 -4
  295. package/src/Task/TaskIcon/index.scss +70 -70
  296. package/src/Task/TaskIcon/index.wxml +5 -5
  297. package/src/Task/TaskIcon/index.wxss +130 -130
  298. package/src/Task/TaskPopup/component/RewardList/index.js +52 -52
  299. package/src/Task/TaskPopup/component/RewardList/index.json +6 -6
  300. package/src/Task/TaskPopup/component/RewardList/index.scss +39 -39
  301. package/src/Task/TaskPopup/component/RewardList/index.wxml +23 -23
  302. package/src/Task/TaskPopup/component/RewardList/index.wxss +18 -18
  303. package/src/Task/TaskPopup/component/TaskItem/index.js +578 -578
  304. package/src/Task/TaskPopup/component/TaskItem/index.json +10 -10
  305. package/src/Task/TaskPopup/component/TaskItem/index.scss +245 -245
  306. package/src/Task/TaskPopup/component/TaskItem/index.wxml +145 -145
  307. package/src/Task/TaskPopup/component/TaskItem/index.wxs +7 -7
  308. package/src/Task/TaskPopup/component/TaskItem/index.wxss +1 -1
  309. package/src/Task/TaskPopup/component/TaskList/index.js +298 -298
  310. package/src/Task/TaskPopup/component/TaskList/index.json +7 -7
  311. package/src/Task/TaskPopup/component/TaskList/index.scss +66 -66
  312. package/src/Task/TaskPopup/component/TaskList/index.wxml +41 -41
  313. package/src/Task/TaskPopup/component/TaskList/index.wxss +118 -118
  314. package/src/Task/TaskPopup/component/TaskType/index.js +129 -129
  315. package/src/Task/TaskPopup/component/TaskType/index.json +13 -13
  316. package/src/Task/TaskPopup/component/TaskType/index.scss +90 -90
  317. package/src/Task/TaskPopup/component/TaskType/index.wxml +69 -69
  318. package/src/Task/TaskPopup/component/TaskType/index.wxss +1 -1
  319. package/src/Task/TaskPopup/index.js +174 -174
  320. package/src/Task/TaskPopup/index.json +7 -7
  321. package/src/Task/TaskPopup/index.scss +166 -166
  322. package/src/Task/TaskPopup/index.wxml +87 -87
  323. package/src/Task/TaskPopup/index.wxss +490 -490
  324. package/src/Task/TaskQuizPopup/components/quizContent/index.js +131 -131
  325. package/src/Task/TaskQuizPopup/components/quizContent/index.json +5 -5
  326. package/src/Task/TaskQuizPopup/components/quizContent/index.scss +191 -191
  327. package/src/Task/TaskQuizPopup/components/quizContent/index.wxml +64 -64
  328. package/src/Task/TaskQuizPopup/components/quizContent/index.wxs +78 -78
  329. package/src/Task/TaskQuizPopup/components/quizContent/index.wxss +521 -521
  330. package/src/Task/TaskQuizPopup/components/quizRichText/index.js +40 -40
  331. package/src/Task/TaskQuizPopup/components/quizRichText/index.json +5 -5
  332. package/src/Task/TaskQuizPopup/components/quizRichText/index.scss +6 -6
  333. package/src/Task/TaskQuizPopup/components/quizRichText/index.wxml +1 -1
  334. package/src/Task/TaskQuizPopup/components/quizRichText/index.wxss +298 -298
  335. package/src/Task/TaskQuizPopup/components/wxParse/base.wxml +50 -50
  336. package/src/Task/TaskQuizPopup/components/wxParse/html2json.js +623 -623
  337. package/src/Task/TaskQuizPopup/components/wxParse/htmlparser.js +183 -183
  338. package/src/Task/TaskQuizPopup/components/wxParse/iframeParse.js +216 -216
  339. package/src/Task/TaskQuizPopup/components/wxParse/loop.wxml +3563 -3563
  340. package/src/Task/TaskQuizPopup/components/wxParse/showdown.js +2364 -2364
  341. package/src/Task/TaskQuizPopup/components/wxParse/wxDiscode.js +209 -209
  342. package/src/Task/TaskQuizPopup/components/wxParse/wxParse.js +269 -269
  343. package/src/Task/TaskQuizPopup/components/wxParse/wxParse.wxml +1276 -1276
  344. package/src/Task/TaskQuizPopup/components/wxParse/wxParse.wxss +316 -316
  345. package/src/Task/TaskQuizPopup/index.js +246 -246
  346. package/src/Task/TaskQuizPopup/index.json +7 -7
  347. package/src/Task/TaskQuizPopup/index.scss +158 -158
  348. package/src/Task/TaskQuizPopup/index.wxml +99 -99
  349. package/src/Task/TaskQuizPopup/index.wxss +478 -478
  350. package/src/Task/common/task.js +55 -55
  351. package/src/Task/taskQuizRemindPopup/index.js +74 -74
  352. package/src/Task/taskQuizRemindPopup/index.json +5 -5
  353. package/src/Task/taskQuizRemindPopup/index.scss +107 -107
  354. package/src/Task/taskQuizRemindPopup/index.wxml +27 -27
  355. package/src/Task/taskQuizRemindPopup/index.wxss +286 -286
  356. package/src/Task/taskReceivePopup/coupon/index.js +68 -68
  357. package/src/Task/taskReceivePopup/coupon/index.json +6 -6
  358. package/src/Task/taskReceivePopup/coupon/index.scss +123 -123
  359. package/src/Task/taskReceivePopup/coupon/index.wxml +81 -81
  360. package/src/Task/taskReceivePopup/coupon/index.wxs +48 -48
  361. package/src/Task/taskReceivePopup/coupon/index.wxss +274 -274
  362. package/src/Task/taskReceivePopup/customPrizes/index.js +44 -44
  363. package/src/Task/taskReceivePopup/customPrizes/index.json +6 -6
  364. package/src/Task/taskReceivePopup/customPrizes/index.scss +106 -106
  365. package/src/Task/taskReceivePopup/customPrizes/index.wxml +38 -38
  366. package/src/Task/taskReceivePopup/customPrizes/index.wxs +48 -48
  367. package/src/Task/taskReceivePopup/customPrizes/index.wxss +220 -220
  368. package/src/Task/taskReceivePopup/index.js +47 -47
  369. package/src/Task/taskReceivePopup/index.json +13 -13
  370. package/src/Task/taskReceivePopup/index.wxml +32 -32
  371. package/src/Task/taskReceivePopup/index.wxss +1 -1
  372. package/src/Task/taskReceivePopup/integral/index.js +106 -106
  373. package/src/Task/taskReceivePopup/integral/index.json +7 -7
  374. package/src/Task/taskReceivePopup/integral/index.scss +60 -60
  375. package/src/Task/taskReceivePopup/integral/index.wxml +23 -23
  376. package/src/Task/taskReceivePopup/integral/index.wxss +94 -94
  377. package/src/TeacherGoodsList/index.js +997 -983
  378. package/src/TeacherGoodsList/index.json +10 -10
  379. package/src/TeacherGoodsList/index.scss +178 -178
  380. package/src/TeacherGoodsList/index.wxml +146 -144
  381. package/src/TeacherGoodsList/index.wxss +1 -1
  382. package/src/common/api/liveGoodsList.js +181 -167
  383. package/src/common/assets/copy.wxss +3 -3
  384. package/src/common/assets/images/coupon/emptypage.svg +49 -49
  385. package/src/common/assets/images/coupon/failed.svg +5 -5
  386. package/src/common/assets/images/coupon/up.svg +21 -21
  387. package/src/common/assets/images/pay/loading.svg +3 -3
  388. package/src/common/assets/images/recommend.svg +6 -6
  389. package/src/common/assets/images/refresh.svg +10 -10
  390. package/src/common/assets/images/refresh_white.svg +3 -3
  391. package/src/common/assets/images/wechat.svg +4 -4
  392. package/src/common/css/index.less +2 -2
  393. package/src/common/css/theme.less +19 -19
  394. package/src/common/css/theme.wxss +16 -16
  395. package/src/common/libs/dataUp/sensorUp.js +91 -91
  396. package/src/common/libs/playerHttp.js +58 -58
  397. package/src/common/libs/playerRequestUrl.js +39 -39
  398. package/src/common/transaction/parameter/channel-info.js +36 -36
  399. package/src/common/transaction/parameter/delivery-info.js +26 -26
  400. package/src/common/transaction/parameter/misc-parameter.js +21 -21
  401. package/src/common/utils/currency.js +52 -52
  402. package/src/common/utils/getInfoCollectionData.js +59 -59
  403. package/src/common/utils/image-cdn-slim/constant.js +8 -8
  404. package/src/common/utils/image-cdn-slim/index.js +7 -7
  405. package/src/common/utils/image-cdn-slim/utils.js +156 -156
  406. package/src/common/utils/index.js +86 -86
  407. package/src/common/utils/liveGoods.js +217 -217
  408. package/src/common/utils/specialList.js +5 -5
  409. package/src/common/utils/tool.js +72 -72
  410. package/src/common/wxs/filter.wxs +29 -29
  411. package/src/coupon/components/CouponItem/index.wxss +821 -821
  412. package/src/coupon/components/CouponSelect/index.wxss +1132 -1132
  413. package/src/coupon/index.wxss +216 -216
  414. package/src/index.js +23 -23
  415. package/src/lib.ts +5 -5
  416. package/src/project.config.json +68 -68
  417. package/src/utils.js +5 -5
  418. package/tsconfig.json +25 -25
@@ -1,1820 +1,1820 @@
1
- // src/ConfirmOrder/components/ConfirmOrderContent/index.js
2
- import {
3
- fetchCollectInfo,
4
- getBusinessFeature,
5
- getConfirmOrderDetail,
6
- getExpressSwitch,
7
- getGoodsPackage,
8
- getMarketingInfo,
9
- getPickerInfo,
10
- getPrePayInfoV3,
11
- getShopConf,
12
- getSuperVipInfo
13
- } from "../../../common/api/confirmOrder";
14
- import { ActivityInfo, CouponInfo, DeliveryInfo, GoodsList, GoodsOrderList, IdentityInfo, LevelMemberInfo, MiscParameter, Parameter, PointInfo, PromoCodeInfo, resolveChannelInfo } from "../../../common/transaction/parameter/index.js";
15
- import { createOrderInLive, queryOrder, queryOrderInfo, valuate } from "../../../common/transaction/valuate/index.js";
16
- import {
17
- ASSOCIATION,
18
- BIG_SPECIAL_COLUMN,
19
- DELIVERY_METHOD_TEXT,
20
- DELIVERY_MODE,
21
- DISCOUNT_SHOW_TYPE,
22
- DISCOUNT_SHOW_TYPE_MAP,
23
- MARKETING_FISSION_POSTER,
24
- MARKETING_SEC_KILL,
25
- MEMBER,
26
- SHIELD_ACTIVITY,
27
- SPECIAL_COLUMN,
28
- SVIP,
29
- TRAINING_CAMP
30
- } from "../../../common/utils/constants.js";
31
- import eventBus from '../../../common/utils/eventBus.js';
32
- import {
33
- isEmptyObject
34
- } from "../../../common/utils/index";
35
- import {
36
- postCouponList
37
- } from "../../../common/utils/postCouponList";
38
- import { PICKER_WHITE_LIST } from "../../../common/utils/specialList";
39
- import {
40
- debounce
41
- } from "../../../common/utils/tool.js";
42
- const { sensorLog } = require("live-mp-tools");
43
-
44
-
45
- const computedBehavior = require('miniprogram-computed').behavior
46
-
47
- const IdentityType = {
48
- NONUSE: -1,//不参加任何身份特权优惠
49
- ANSWER: 0,//需要后端请求身份信息,选择优惠力度大的那个
50
- USE_SVIP: 1,//使用超级会员
51
- FORBID_SVIP: 2//禁止使用超级会员
52
- }
53
-
54
- const MINMUM_PRICE_TYPE_MAP = {
55
- NORMAL: 1,
56
- SVIP: 2,
57
- MARKETING: 3
58
- }
59
-
60
- // 订单状态 1 未支付 2 支付完成(0元单)
61
- const ORDER_PAY_STATUS = {
62
- UNPAID: 1,
63
- PAID: 2,
64
- };
65
-
66
- Component({
67
- behaviors: [computedBehavior],
68
- /**
69
- * 组件的属性列表
70
- */
71
- properties: {
72
- baseInfoQuery: {
73
- type: Object,
74
- value: () => {},
75
- },
76
- isCart: {
77
- type: Number,
78
- value: 0,
79
- },
80
- isTeam: {
81
- type: Boolean,
82
- default: false,
83
- },
84
- aliveInfo:{
85
- type: Object,
86
- value:{}
87
- },
88
- sensorReportParams:{
89
- type: Object,
90
- value:{}
91
- },
92
- popPosition: {
93
- type: String,
94
- value: 'bottom'
95
- },
96
- round:{
97
- type:Boolean,
98
- value: true
99
- },
100
- showClose:{
101
- type:Boolean,
102
- value: true
103
- },
104
- invoiceSelectZIndex:{
105
- type: Number,
106
- value: 100
107
- },
108
- invoiceTipZIndex:{
109
- type: Number,
110
- value: 100
111
- },
112
- refundTipsZIndex:{
113
- type: Number,
114
- value: 100
115
- },
116
- zIndex:{
117
- type: Number,
118
- value: 100
119
- },
120
- },
121
-
122
- /**
123
- * 组件的初始数据
124
- */
125
- data: {
126
- activeMode: 0, // 0:快递配送,1:自提
127
- express_type: 0, // 接口下发配送信息 1-快递配送 2-商品自提
128
- userCanPick: 1, // 商家是否支持自提 1支持 0不支持
129
- shopConf: {},
130
- confirmOrderInfo: {
131
- // 订单页详细信息(通过查询接口拿到)
132
- app_info: {},
133
- goods_info: {},
134
- },
135
- distributionMode: 0, // 配送方式 -1全部 1快递配送 2商品自提 (目前只支持实物商品,非实物商品返回0)
136
- resource_id: "",
137
- addressInfo: {}, // 地址信息(非自提)
138
- pickerUserInfo: {}, // 自提人信息
139
- picksiteInfo:{}, //自提点信息
140
- hasEntityGoods: false, // 商品套餐是否包含实物商品
141
- superVipInfo: {}, // 超级会员信息
142
- userIsVip: false, // 用户是否是超级会员
143
- businessConf: {},
144
- marketingData: {}, //营销数据
145
- isShowPoint: false, // 是否显示选择提货点组件
146
- isShowSelectShipper: false, // 是否显示选择提货人组件
147
- isShowCreateShipper: false, // 是否显示新增、编辑提货人组件
148
- isShowAddressManage: false, // 是否显示地址管理组件(非自提)
149
- isShowEditAddress: false, // 是否显示新建、编辑组件(非自提)
150
- addressQuery: {}, // 地址相关组件需要的入参
151
- marketingDataLoaded: false, //营销数据加载
152
- cartInfoLoaded: false, //购物车数据加载
153
- addressInfoLoaded: false, //地址信息加载
154
- backType: 0, // 弹框顶部返回按钮操作
155
- backPage: 1, // 1:确认订单页面大组件
156
- shipperType: 1, // 1:新建自提人;2:编辑自提人
157
- checkList: {}, // 支付前校验信息
158
- beforePay: {}, // 支付前校验函数
159
- afterPay: {}, // 支付后的参数
160
- afterPayCallback: {}, // 支付后回调
161
- payParams: {},
162
- prePayParams: {}, //批价信息参数
163
- getPrePayInfoReset: null, // 批价防抖函数回调
164
- //错误信息
165
- errMsg: {
166
- 10309: "该商品已售罄",
167
- 30201: "商家未设置支付方式,请联系商家处理",
168
- 30202: "支付失败,请联系商家处理",
169
- 10029: "已拥有,不可重复购买",
170
- 10067: "该商品已下架,不支持继续购买!",
171
- 10100: "该商品可能已下架或价格变更,请稍后再试。",
172
- 10306: "拼团失败,请刷新重试。",
173
- 10308: "活动即将开始",
174
- 10310: "商家正努力补货中",
175
- 10312: "未预约该活动",
176
- 20012: "购买数量超过活动限制。",
177
- 20020: "该团已满,请重新下单。",
178
- 20021: "该活动已结束。",
179
- 20011: "您已参与本团,不可重复参与。",
180
- 20077: "配送区域已更新,此收货地址超出配送范围,请重新选择",
181
- 20023: "单笔订单最多可购买1000件",
182
- },
183
- goodsPackageInfo: {}, //商品套餐信息
184
- isShowSkeleton: true, //是否显示骨架屏
185
- customDeliveryType: [DELIVERY_METHOD_TEXT.EXPRESSAGE, DELIVERY_METHOD_TEXT.PICK],//自定义配送方式顺序-由b端交易设置修改
186
- showLoadingE: false, // loading,用于控制能否批价等操作
187
- valuateParams: new Parameter(),//批价参数
188
- formData: {
189
- address: null, // 收货地址
190
- pickInfo: {
191
- site: null,
192
- picker: null
193
- }, // 自提信息,包括自提人、自提点
194
- infoCollectionInfo: null,//信息采集参数
195
- eduInfo: {
196
- course_id: ''
197
- }, // 线下课学员信息
198
- goodsInfo: {}, // 商品信息
199
- count: 1, // 商品数量
200
- invoiceInfo: {
201
- invoice_type: 0
202
- }, // 发票信息
203
- userRemark: '', // 留言
204
- isUseIntegral: false, // 是否使用积分
205
- isInitPoint: true, //积分抵扣标识
206
- couponInfo: {
207
- isSelected: false,
208
- selectedCoupons: []
209
- }, // 优惠券信息
210
- promoCodeInfo: '', // 优惠码信息
211
- teamBuy: {}, // 拼团
212
- activityApplyInfo: [], // 活动管理报名信息
213
- beforePay: {}, // 支付前校验函数
214
- checkList: {}, // 支付前校验信息
215
- identityType: IdentityType.ANSWER, // 身份特权类型: -1 不参加任何优惠, 0 都需要查询, 1 超级会员
216
- },//表单数据,如自提信息、优惠券、信息采集 等等
217
- sku_floor_price: null, // 商品低价
218
- valuateData: {},// 批价返回参数
219
- prePayInfo: {}, // 批价信息
220
- payResult: {}, // 支付接口返回信息
221
- assertNeedCollectInfo: {},
222
- infoIsLoadSuc: false,//信息采集加载状态
223
- needCollect: false, //信息采集状态二次确认
224
- successCallbackParams: {}, // 支付成功回调参数
225
- waitInformation: true, // 是否是第一次批价,用来第一次批价等信息采集接口返回
226
- setTime: null, // 计时器
227
- infoCollectionLoaded: [], //信息采集加载完成的时间
228
- showFreightIns: false, // 运费险
229
- is_show_freight_ins: false, // 运费险
230
- isHideSelfPickerInfo: null, // 自提人信息填写状态
231
- },
232
- options: {
233
- addGlobalClass: true
234
- },
235
- lifetimes: {
236
- attached: async function () {
237
- // 在组件实例进入页面节点树时执行
238
- eventBus.on('order_onInfoCollectionLoaded', ({needCollect, isLoad}) => {
239
- console.log(needCollect, isLoad);
240
- this.setData({
241
- infoIsLoadSuc: isLoad,
242
- needCollect,
243
- waitInformation: false, // 信息采集接口返回成功,不需要等
244
- })
245
- if(this.data.setTime){ // 等待中的话
246
- clearTimeout(this.data.setTime); // 不等待了
247
- this.loadingStatus(false);
248
- this.setData({
249
- setTime: null
250
- })
251
- }
252
- const time = `第${this.data.infoCollectionLoaded.length + 1}_${new Date().getTime()}_${needCollect}`
253
- const infoCollectionLoaded = this.data.infoCollectionLoaded;
254
- this.setData({
255
- infoCollectionLoaded: infoCollectionLoaded.push(time)
256
- })
257
- // TODO: 信息采集上报
258
- });
259
- // 优先请求下单页基本数据,然后隐藏骨架屏,展示基本内容
260
- let result = await this.initConfirmOrderInfo();
261
- console.log('result',result)
262
- if (result.data.code === 0 & this.data.baseInfoQuery.spu_type == "ENT" & result.data.data.goods_info.distribution_pattern === -1 && this.data.userCanPick === 1) {
263
- const customDeliveryType = result.data.data.distribution_pattern_config;
264
- this.setData({
265
- customDeliveryType: customDeliveryType,
266
- activeMode: customDeliveryType[0] === DELIVERY_METHOD_TEXT.EXPRESSAGE ? DELIVERY_MODE.EXPRESSAGE : DELIVERY_MODE.PICK
267
- })
268
- }
269
- this.handleOrderInfo(result);
270
- // 隐藏骨架屏
271
- this.setData({
272
- isShowSkeleton: false,
273
- });
274
-
275
- // 请求营销活动、超级会员接口,从而进行批价
276
- await this.initSuperVipInfo();
277
- await this.initMarketingData();
278
- await this.initGoodsPackage();
279
-
280
- this.initData();
281
-
282
- // 批价
283
- await this.doValuate('initialize');
284
- },
285
- },
286
- computed: {
287
- // 是否全屏
288
- isFullScreen(properties) {
289
- return properties.popPosition === 'right'
290
- },
291
- isShowMain(data) {
292
- return (
293
- !data.isShowPoint &&
294
- !data.isShowSelectShipper &&
295
- !data.isShowCreateShipper &&
296
- !data.isShowAddressManage &&
297
- !data.isShowEditAddress
298
- )
299
- },
300
- //判断模式选择tab栏的显示和隐藏
301
- showModeSelect(data) {
302
- return data.distributionMode === -1 && data.userCanPick === 1;
303
- },
304
- // 显示地址栏的情况 商品有两种配送方式,商家关闭自提/购物车
305
- showAddressSelect(data) {
306
- return (
307
- data.activeMode === DELIVERY_MODE.EXPRESSAGE &&
308
- (data.distributionMode === -1 || data.distributionMode === 1)
309
- );
310
- },
311
- // 商品信息
312
- goodsInfo(data) {
313
- if (isEmptyObject(data.confirmOrderInfo.goods_info)) {
314
- return data.baseInfoQuery;
315
- }
316
- return data.confirmOrderInfo.goods_info;
317
- },
318
- //通过商家是否开启自提和自提选择 决定自提组件的显示和隐藏
319
- showPickSelf(data) {
320
- return (data.activeMode === DELIVERY_MODE.PICK || data.distributionMode === 2)
321
- },
322
- // 用户信息填写,0-必填,1-可选,2-不填。不填则隐藏提货人
323
- showPicker(data) {
324
- return data.isHideSelfPickerInfo !== null && data.isHideSelfPickerInfo !== 2
325
- },
326
- // 公共批价请求参数
327
- commonPrePayParams(data) {
328
- let spuType = data.baseInfoQuery.spu_type;
329
- let coursePackage = [
330
- MEMBER,
331
- SPECIAL_COLUMN,
332
- BIG_SPECIAL_COLUMN,
333
- TRAINING_CAMP,
334
- ];
335
- let paymentType15 = [SVIP]
336
- let paymentType = 2;
337
- if (coursePackage.includes(spuType)) {
338
- paymentType = 3;
339
- }
340
- if (paymentType15.includes(spuType)) {
341
- paymentType = 15;
342
- }
343
- return {
344
- pre_pay_type: data.baseInfoQuery.pre_pay_type || 1,
345
- resource_id: data.baseInfoQuery.resource_id,
346
- spu_id: data.baseInfoQuery.id,
347
- count: data.baseInfoQuery.count,
348
- // product_id: data.baseInfoQuery.id,
349
- product_id: '',
350
- resource_type: data.baseInfoQuery.resource_type,
351
- spu_type: spuType,
352
- payment_type: paymentType,
353
- sku_id: data.baseInfoQuery.sku,
354
- };
355
- },
356
- // 通过请求获取的批价参数是否都已加载完毕
357
- prePayParamsInfoLoaded(data) {
358
- return (
359
- ((data.marketingDataLoaded && !data.isCart) ||
360
- (data.isCart && data.cartInfoLoaded)) &&
361
- (data.addressInfoLoaded ||
362
- Object.keys(data.pickerUserInfo).length > 0 ||
363
- data.activeMode === 0)
364
- //加入商品自提后,这里判断是否加载完自提人消息来确定批价参数是否加载完毕
365
- //每次切换提货模式时也要触发商品批价信息
366
- );
367
- },
368
- marketInfo(data) {
369
- return data.marketingData?.marketing_info || {};
370
- },
371
- marketingLowPrice(data) {
372
- const { activity_type, low_price, is_subscribe, user_subscribed, in_activity, event_has_stock } = data.marketInfo;
373
- if ([3, 6].includes(activity_type)) {
374
- return low_price;
375
- }
376
- if ([8].includes(activity_type)) {
377
- if (is_subscribe === 1 && user_subscribed === 0 && in_activity === 1) {
378
- return null;
379
- }
380
- // 如何没库存则按原价来计算券后价
381
- if (event_has_stock === 0) {
382
- return null;
383
- }
384
- return low_price;
385
- }
386
- return null;
387
- },
388
- isSvipUseful(data) {
389
- return (
390
- data.superVipInfo?.svip_purchase_valid === 1 &&
391
- data.superVipInfo?.svip_info?.svip_state === 0 &&
392
- data.superVipInfo?.svip_info?.single_resource_rights?.rights_type === 2 && // 增加超会折扣权益判断
393
- data.userIsVip
394
- )
395
- },
396
- // 超级会员价
397
- svipPrice(data) {
398
- const skuPriceInfo = data.superVipInfo.sku_svip_price_list;
399
- if (skuPriceInfo && Object.keys(skuPriceInfo).length) {
400
- const svipPrices = Object.keys(skuPriceInfo).map((sku) => skuPriceInfo[sku]);
401
- return Math.min.apply(Math, svipPrices);
402
- }
403
- return 0;
404
- },
405
- zeroPay(data) {
406
- return data.valuateData?.price_info?.final_price === 0
407
- },
408
- // 积分组件需要的信息
409
- integral(data) {
410
- return data.valuateData?.points_info || '';
411
- },
412
- priceInfo(data) {
413
- return data.valuateData?.price_info || {};
414
- },
415
- showIntegral(data) {
416
- return data.valuateData?.points_info?.is_show_point;
417
- }
418
- },
419
- observers: {
420
- distributionMode(val) {
421
- if (val === 1) {
422
- this.setData({
423
- express_type: val
424
- })
425
- } else if (val === 2) {
426
- this.setData({
427
- express_type: val
428
- })
429
- }else if (val === 0) {
430
- this.setData({
431
- express_type: val
432
- })
433
- }else if (val === -1) {
434
- this.setData({
435
- express_type: 1
436
- })
437
- }
438
- },
439
- marketingData(marketingData) {
440
- // 这里的逻辑应该是存在拼团的时候那么payment_type就要赋值为13,如果是限时折扣或者是单买的话,payment_type不做赋值默认为2
441
- if (
442
- marketingData &&
443
- marketingData.payment_type &&
444
- this.data.isTeam === "true"
445
- ) {
446
- this.payInfoChange({
447
- name: "marketingData",
448
- prePayParams: {
449
- payment_type: marketingData.payment_type,
450
- },
451
- });
452
- }
453
- this.setData({
454
- marketingDataLoaded: true
455
- })
456
- },
457
- isShowCreateShipper(val) {
458
- if (val) {
459
- if (this.data.shipperType === 1) {
460
- this.triggerEvent("changeSheetInfo", {
461
- title: "新建提货人",
462
- })
463
- } else {
464
- this.triggerEvent("changeSheetInfo", {
465
- title: "编辑提货人",
466
- })
467
- }
468
- this.triggerEvent("changeSheetInfo", {
469
- showClose: false,
470
- showBack: true,
471
- })
472
- this.setData({
473
- backType: 3
474
- })
475
- } else {
476
- this.backClick();
477
- }
478
- },
479
- showPickSelf(val) {
480
- if (!val) {
481
- this.payInfoChange({
482
- name: "pickerUserInfo",
483
- errMsg: "",
484
- });
485
- this.payInfoChange({
486
- name: "address",
487
- errMsg: "",
488
- });
489
- }
490
- },
491
- isShowSelectShipper: function (newData) {
492
- if (newData) {
493
- this.triggerEvent("changeSheetInfo", {
494
- title: "选择提货人",
495
- showClose: false,
496
- showBack: true,
497
- })
498
- this.setData({
499
- backType: 2
500
- })
501
- } else {
502
- this.backClick();
503
- }
504
- },
505
- isShowAddressManage(newData) {
506
- if (newData) {
507
- this.triggerEvent("changeSheetInfo", {
508
- title: "选择地址",
509
- showClose: false,
510
- showBack: true,
511
- })
512
- this.setData({
513
- backType: 4
514
- })
515
- } else {
516
- if (!this.data.isShowEditAddress) {
517
- this.backClick()
518
- }
519
- }
520
- },
521
- isShowEditAddress(newData) {
522
- if (newData) {
523
- this.triggerEvent("changeSheetInfo", {
524
- title: "地址编辑",
525
- showClose: false,
526
- showBack: true,
527
- })
528
- this.setData({
529
- backType: 5
530
- })
531
- } else {
532
- this.backClick()
533
- }
534
- },
535
- isShowPoint: function (newData) {
536
- if (newData) {
537
- this.triggerEvent("changeSheetInfo", {
538
- title: "提货地址",
539
- showClose: false,
540
- showBack: true,
541
- })
542
- this.setData({
543
- backType: 1
544
- })
545
- } else {
546
- this.backClick();
547
- }
548
- },
549
- prePayParamsInfoLoaded(val) {
550
- // if (val) {
551
- // let obj = {
552
- // ...this.data.commonPrePayParams,
553
- // ...this.data.prePayParams,
554
- // }
555
- // this.setData({
556
- // getPrePayInfoReset: this.getPrePayInfo(obj)
557
- // })
558
- // }
559
- },
560
- picksiteInfo(val) {
561
- this.setData({
562
- 'formData.pickInfo.site': val,
563
- })
564
- const { address } = this.data.formData;
565
- if (this.shouldValuateOnDeliveryChange(this.data.activeMode, address)) {
566
- // 触发批价
567
- this.doValuate('listenPickup');
568
- }
569
- },
570
- pickerUserInfo(val) {
571
- this.setData({
572
- 'formData.pickInfo.picker': val,
573
- })
574
- },
575
- addressInfo(newVal) {
576
- const formData = this.data.formData.address
577
- this.setData({
578
- 'formData.address': !newVal?.id ? null : newVal
579
- })
580
- if (newVal?.id && newVal?.id !== formData?.id) {
581
- wx.nextTick(async () => {
582
- let result = await this.initConfirmOrderInfo();
583
- this.handleOrderInfo(result);
584
- this.doValuate('listenAddress')
585
- })
586
- }
587
- },
588
- showAddressSelect(val) {
589
- val && this.initAddressErro();
590
- }
591
- },
592
- /**
593
- * 组件的方法列表
594
- */
595
- methods: {
596
- handleSvipChange(val) {
597
- let data = {};
598
- val.detail ? data = val.detail : data = val
599
- this.setData({
600
- 'formData.identityType': data?.selectSvip,
601
- })
602
- if (data?.trigger) {
603
- this.$nextTick(() => {
604
- this.doValuate('selectSvip');
605
- })
606
- }
607
- },
608
- handleIntegralSelectChange(val) {
609
- let data = {};
610
- val.detail ? data = val.detail : data = val
611
- this.setData({
612
- 'formData.isUseIntegral': data?.isUseIntegral ? true : false,
613
- 'formData.isInitPoint': false,
614
- })
615
- this.doValuate('selectPoint');
616
- },
617
- //判断配送模式/信息变化时是否需要触发批价
618
- shouldValuateOnDeliveryChange(deliveryMode, addressInfo,) {
619
- switch (deliveryMode) {
620
- case DELIVERY_MODE.EXPRESSAGE:
621
- return addressInfo?.id;
622
- case DELIVERY_MODE.PICK:
623
- return true;
624
- default:
625
- return false;
626
- }
627
- },
628
- /**
629
- * 触发批价
630
- * @description 触发批价的场景
631
- * changeCount:改变商品数量
632
- * initialize:初始化
633
- * selectAddress:选择地址信息
634
- * changeAddress: 地址编辑、删除回调
635
- * selectPickup:选择自提人
636
- * selectCoupon: 选择优惠券/优惠码
637
- * selectPoint: 选择积分
638
- * selectSvip: 选择Svip
639
- * createOrder: 下单前校验批价
640
- * changeMode: 切换配送方式
641
- * listenAddress: 地址监听(兜底)
642
- * listenPickup: 自提监听
643
- * getCoupon: 领取优惠卷重新批价
644
- * @param entrance
645
- */
646
- async doValuate(entrance) {
647
- console.log('entrance=>',entrance);
648
- if (this.data.showLoadingE && entrance !== 1) {
649
- return;
650
- }
651
- this.loadingStatus(true);
652
-
653
- // 批价
654
- console.log('this.formData-----------: ', this.data.formData);
655
- const params = this.assembleValuateParams();
656
-
657
- if (isEmptyObject(params)) {
658
- this.loadingStatus(false);
659
- return;
660
- }
661
-
662
- // 商品参数校验
663
- if (params?.goods_list){
664
- let missingParameter = false;
665
- params.goods_list.forEach(val=>{
666
- if (!val.spu_id || !val.sku_id){
667
- missingParameter = true
668
- }
669
- })
670
- if (missingParameter) {
671
- console.log('批价参数校验失败',params)
672
- this.loadingStatus(false);
673
- return;
674
- }
675
- }else{
676
- this.loadingStatus(false);
677
- return;
678
- }
679
-
680
- // 当是初始请求批价时,触发帮领取优惠券
681
- if (entrance === 'initialize') {
682
- try {
683
- await this.autoReceiveCoupon()
684
- }catch (e){
685
- console.log('领取优惠券失败')
686
- }
687
- }
688
-
689
- params.live_commerce = true
690
-
691
- return valuate(params).then(async (val) => {
692
- const { code, data, msg } = val.data;
693
- this.setData({
694
- valuateData: data,
695
- is_show_freight_ins: data.shipment_info?.is_show_freight_ins
696
- })
697
- this.triggerEvent('onTipsInfoUpdate', {
698
- // is_show_freight_ins: data.shipment_info?.is_show_freight_ins && data.price_info?.final_price !== 0,
699
- is_show_freight_ins: false,
700
- price_info: data.price_info
701
- })
702
- if (code !== 0) {
703
- try {
704
- sensorLog.sensors.track('view_page', {
705
- page_id: 'e_alive#mini#order',
706
- page_name: '确认订单页',
707
- l_program: '鹅直播',
708
- page_path: '鹅直播#小程序#直播间#确认订单页',
709
- app_id: this.data.confirmOrderInfo?.goods_info?.app_id,
710
- c_user_id: this.data.aliveInfo?.user_id,
711
- cmm1: '批价接口报错',
712
- cmm2: JSON.stringify(params),
713
- cmm3: msg
714
- })
715
- } catch (error) {
716
- console.log('上报失败', error);
717
- }
718
- }
719
- }).catch((err) => {
720
-
721
- }).finally(() => {
722
- this.loadingStatus(false);
723
- // 初次批价 & 开了信息采集 & 信息采集接口还没返回
724
- if (this.data.waitInformation){
725
- this.loadingStatus(true);
726
- this.setData({
727
- setTime: setTimeout(() => {
728
- this.loadingStatus(false);
729
- this.setData({
730
- waitInformation: false
731
- })
732
- }, 2000)
733
- })
734
- }
735
- })
736
- },
737
- // 自动领取优惠券
738
- async autoReceiveCoupon() {
739
- const { resource_id, resource_type, spu_id } = this.data.baseInfoQuery;
740
- const { in_activity, is_super_vip } = this.data.marketInfo;
741
- const { piece_price } = this.data.goodsInfo;
742
-
743
- // 营销最低价
744
- const marketingLowPrice = in_activity && this.marketingLowPrice;
745
-
746
- // 超会和营销活动是否能叠加
747
- const isSvipSupportMarketing = is_super_vip === 1;
748
-
749
- const svipDiscount = this.data.superVipInfo?.svip_info?.svip_info?.discount / 10;
750
-
751
- let isSvipCanUseCoupon = this.data.superVipInfo.svip_info?.svip_info?.is_coupons === 1;
752
-
753
- // 原价
754
- let minimumPrice = piece_price;
755
- let minimumPriceType = MINMUM_PRICE_TYPE_MAP.NORMAL;
756
-
757
- // 超级会员营销叠加价格
758
- const marketingSvipPrice = this.data.isSvipUseful && isSvipSupportMarketing && marketingLowPrice * svipDiscount;
759
-
760
- // 有超级会员价
761
- const superVipPrice = this.data.svipPrice;
762
- if (superVipPrice) {
763
- if (
764
- // 没有营销价或者营销价低于超级会员价
765
- (!marketingLowPrice || marketingLowPrice && superVipPrice < marketingLowPrice) &&
766
- this.data.userIsVip // 用户是超级会员
767
- ) {
768
- // 以超级会员价计算券后价
769
- minimumPrice = superVipPrice;
770
- minimumPriceType = MINMUM_PRICE_TYPE_MAP.SVIP;
771
- }
772
- }
773
-
774
- // 当前仍是原价的情况下,有营销价,使用营销价计算券后价
775
- if (minimumPriceType === MINMUM_PRICE_TYPE_MAP.NORMAL) {
776
- if (marketingLowPrice) {
777
- minimumPrice = marketingSvipPrice || marketingLowPrice;
778
- minimumPriceType = MINMUM_PRICE_TYPE_MAP.MARKETING;
779
- }
780
- }
781
-
782
- let params = {
783
- resource_type,
784
- resource_id: resource_id || spu_id,
785
- minimum_price: minimumPrice,
786
- minimum_price_type: minimumPriceType,
787
- svip_coupon_over: this.data.isSvipUseful && isSvipCanUseCoupon,
788
- spu_id: spu_id
789
- }
790
- if (this.data.sku_floor_price){
791
- params.floor_price = this.data.sku_floor_price
792
- }
793
-
794
- await postCouponList(params).then((res) => {
795
- wx.showToast({
796
- title: "您已享有最佳优惠,下单更优惠",
797
- icon: 'none',
798
- duration: 2000
799
- })
800
- }).catch((err) => {
801
- console.log("优惠券获取列表报错或者没有可领券", err)
802
- })
803
- },
804
- // 封装批价入参
805
- assembleValuateParams() {
806
- // 每次批价时,都重置批价参数
807
- let newValuateParams = new Parameter()
808
-
809
- const { count, address, identityType } = this.data.formData;
810
- const { spu_id: spuId, sku_id: skuId } = this.data.goodsInfo;
811
- const { isFissionPoster, spu_type: spuType, renew } = this.data.baseInfoQuery;
812
-
813
- const buyNum = count;
814
- let goodsInfo = [];
815
- let teamBuyInfo;
816
- let identityInfo;
817
-
818
- // 地址信息
819
- const addressId = this.data.showAddressSelect ? address?.id : 0;
820
-
821
- // 商品信息
822
- let { activityId, activityType } = this.handleMarketInfo();
823
-
824
- let activityInfo;
825
- if (activityId) {
826
- //非裂变海报进入的下单,不加活动参数
827
- if (activityType === MARKETING_FISSION_POSTER && !isFissionPoster) {
828
- activityInfo = null;
829
- } else {
830
- activityInfo = new ActivityInfo(activityId, activityType, teamBuyInfo);
831
- }
832
- }
833
-
834
- goodsInfo = new GoodsList({ spuId, skuId, buyNum }, activityInfo).transformApiParams();
835
-
836
- // 身份特权信息
837
- const realIdentityType = identityType === IdentityType.FORBID_SVIP ? IdentityType.ANSWER : identityType
838
- identityInfo = new IdentityInfo(realIdentityType).transformApiParams();
839
-
840
- // 优惠券信息
841
- const { isSelected, selectedCoupons } = this.data.formData.couponInfo;
842
- const couponInfoData = new CouponInfo(isSelected, selectedCoupons).transformApiParams();
843
-
844
- // 优惠码信息
845
- const promoCode = this.data.formData.promoCodeInfo;
846
- const promoCodeInfo = new PromoCodeInfo(promoCode).transformApiParams();
847
-
848
- // 积分信息
849
- const pointsExchange = this.data.baseInfoQuery.isIntegral;
850
- const usePoints = this.data.formData.isUseIntegral;
851
- const pointInfo = new PointInfo(pointsExchange, usePoints, 0, this.data.formData?.isInitPoint).transformApiParams();
852
-
853
- // 会员等级
854
- const isUseMemberLevel = this.data.formData?.isUseMemberLevel === undefined ? 1 : this.data.formData?.isUseMemberLevel;
855
- const level_member_info = new LevelMemberInfo(isUseMemberLevel).transformApiParams();
856
-
857
- // 是否为社群续费
858
- const communityRenewal = spuType === ASSOCIATION && renew == '1';
859
-
860
- // 将批价所有参数封装进一个对象中
861
- addressId && newValuateParams.append('address_id', addressId);
862
- newValuateParams
863
- .append('identity_info', identityInfo)
864
- .append('goods_list', goodsInfo)
865
- .append('points_info', pointInfo)
866
- .append('community_renewal', communityRenewal)
867
- .append('coupon_info', couponInfoData)
868
- .append('promo_code_info', promoCodeInfo)
869
- .append('from_shopping_cart', false) // 直播不存在购物车 - 写死false
870
- .append('is_gift', false) // 直播不存在赠送 - 写死false
871
- .append('level_member_info', level_member_info);
872
-
873
- this.setData({
874
- valuateParams: newValuateParams
875
- });
876
-
877
- return this.data.valuateParams;
878
- },
879
- // 处理批价的 activity_type 和 activity_id
880
- handleMarketInfo() {
881
- let { activity_id: activityId, activity_type: activityType, event_has_stock, in_activity } = this.data.marketInfo || {};
882
- let isShield = activityId ? SHIELD_ACTIVITY.some(item => activityId.includes(item)) : false;
883
- if ((activityType === MARKETING_SEC_KILL && (event_has_stock === 0 || in_activity === 0)) || isShield) {
884
- return {};
885
- }
886
- return {
887
- activityId,
888
- activityType
889
- }
890
- },
891
- loadingStatus(val) {
892
- if (val) {
893
- wx.showLoading({
894
- mask: true,
895
- title: '加载中'
896
- });
897
- } else {
898
- wx.hideLoading();
899
- }
900
- this.setData({
901
- showLoadingE: val
902
- });
903
- },
904
- // 初始化店铺设置信息
905
- initShopConf() {
906
- getShopConf().then(res => {
907
- if (res.data.code === 0) {
908
- this.setData({
909
- shopConf: res.data.data
910
- })
911
- }
912
- })
913
- },
914
- // 做防抖处理,避免短时间触发多次批价
915
- getPrePayInfo: debounce(function (payload) {
916
- // console.log("val: ", val);
917
- // let payload = val[0]
918
- if (!payload["resource_id"]) {
919
- payload = {
920
- ...payload,
921
- resource_id: this.data.resource_id,
922
- };
923
- }
924
- this.setData({
925
- prePayParams: payload
926
- })
927
- wx.showLoading({
928
- mask: true,
929
- title: '加载中'
930
- })
931
- return getPrePayInfoV3(payload).then(res => {
932
- wx.hideLoading()
933
- if (res.data.code === 0) {
934
- this.setData({
935
- prePayInfo: res.data.data
936
- })
937
- } else {
938
- this.handlePreErrorCode(res.data);
939
- }
940
- if (wx.getStorageSync('toastWarn')) {
941
- wx.showToast({
942
- title: "单笔订单最多可购买1000件",
943
- icon: 'none',
944
- duration: 2000
945
- })
946
- setTimeout(() => {
947
- wx.removeStorage({
948
- key: "toastWarn"
949
- })
950
- }, 3000)
951
- }
952
- if (res.data.code === 10310 || res.data.code === 10309) {
953
- this.setData({
954
- ["checkList.order"]: "商家努力补货中"
955
- })
956
- } else {
957
- this.setData({
958
- ["checkList.order"]: ""
959
- })
960
- }
961
- }).catch((err) => console.log(err))
962
- }, 1000),
963
- handlePreErrorCode(res) {
964
- if (res.code !== 20077) {
965
- this.handleErrorCode(res);
966
- }
967
- },
968
- handleErrorCode(res) {
969
- // 重复支付错误code特殊逻辑,不做toast处理,弹窗处理
970
- if (res.code === 20022) {
971
- return;
972
- }
973
-
974
- if (res.code === 10061001) {
975
- wx.showToast({
976
- title: "订单信息有变化, 请刷新后重试",
977
- icon: 'none',
978
- duration: 2000
979
- })
980
- setTimeout(() => {
981
- this.onLoad()
982
- }, 1000);
983
- return;
984
- }
985
- wx.showToast({
986
- title: this.data.errMsg[res.code] || res.msg,
987
- icon: 'none',
988
- duration: 2000
989
- })
990
- },
991
- /**
992
- * @description: 支付参数改变事件,用于约束各业务测支付参数传参
993
- * @param {string} data.name 业务侧名称,用于区分各业务侧参数
994
- * @param {string} data.errMsg [同步校验]业务侧参数提示信息,用于支付前判断,目前主要用于判空提示(若为disabled标明只禁止提交,不弹提示。如信息采集,必须等信息采集加载完才能进行提交)
995
- * @param {promise} data.beforePay [异步校验]业务侧用于进行支付前校验的校验方法, 这里为一个function,并返回一个Promise,resolve返回校验成功true或者校验失败false
996
- * @param {object} data.prePayParams 业务侧涉及的批价参数,当有此参数时,会触发重新批价
997
- * @param {object} data.payParams 业务侧涉及的支付参数,用于支付时传参
998
- * @param {object} data.afterPay 业务侧支付后使用的一些参数 callBack: 支付完成后回调,支付完成后就只执行此回调方法,回调可返回支付完成后的跳转页面;
999
- * srcUrl:支付失败跳转页面;backUrl: 支付成功跳转页面
1000
- * @param {Boolean} data.triggerPrePay 本次修改是否触发批价
1001
- */
1002
- payInfoChange(val) {
1003
- // console.log('val: ', val);
1004
- // let data = {};
1005
- // val.detail ? data = val.detail : data = val
1006
- // this.setData({
1007
- // [`checkList.${data.name}`]: data.errMsg || ""
1008
- // })
1009
- // if (data.beforePay) {
1010
- // this.setData({
1011
- // [`beforePay.${data.name}`]: data.beforePay
1012
- // })
1013
- // }
1014
- // if (data.afterPay) {
1015
- // let {
1016
- // callBack,
1017
- // ...others
1018
- // } = data.afterPay;
1019
- // this.setData({
1020
- // afterPay: {
1021
- // ...this.data.afterPay,
1022
- // ...others,
1023
- // }
1024
- // })
1025
- // if (callBack) {
1026
- // this.setData({
1027
- // [`afterPayCallback.${data.name}`]: callBack
1028
- // })
1029
- // }
1030
- // }
1031
- // // 支付参数处理
1032
- // if (data.payParams) {
1033
- // this.setData({
1034
- // payParams: {
1035
- // ...this.data.payParams,
1036
- // ...data.payParams,
1037
- // }
1038
- // })
1039
- // }
1040
- // if (data.prePayParams) {
1041
- // // 更新业务批价参数
1042
- // this.setData({
1043
- // prePayParams: {
1044
- // ...this.data.prePayParams,
1045
- // ...data.prePayParams,
1046
- // }
1047
- // })
1048
- // if (this.data.prePayParamsInfoLoaded && data.triggerPrePay !== false) {
1049
- // let obj = {
1050
- // ...this.data.commonPrePayParams,
1051
- // ...this.data.prePayParams,
1052
- // }
1053
- // this.setData({
1054
- // getPrePayInfoReset: this.getPrePayInfo(obj)
1055
- // })
1056
- // }
1057
- // }
1058
- },
1059
- // 留言变更
1060
- handleLeaveWordChange(val) {
1061
- this.setData({
1062
- 'formData.userRemark': val.detail,
1063
- })
1064
- },
1065
- // 发票变更
1066
- handleInvoiceChange(val) {
1067
- this.setData({
1068
- 'formData.invoiceInfo': {
1069
- ...this.data.formData.invoiceInfo,
1070
- ...val.detail
1071
- },
1072
- })
1073
- },
1074
- // 返回箭头点击事件
1075
- backClick() {
1076
- switch (this.data.backType) {
1077
- case 1:
1078
- this.triggerEvent("changeSheetInfo", {
1079
- title: "确认订单",
1080
- showClose: true,
1081
- showBack: false,
1082
- })
1083
- this.setData({
1084
- isShowPoint: false,
1085
- backType: 0
1086
- })
1087
- break;
1088
- case 2:
1089
- this.triggerEvent("changeSheetInfo", {
1090
- title: "确认订单",
1091
- showClose: true,
1092
- showBack: false,
1093
- })
1094
- this.setData({
1095
- isShowSelectShipper: false,
1096
- backType: 0
1097
- })
1098
- break;
1099
- case 3:
1100
- if (this.data.backPage === 1) {
1101
- this.triggerEvent("changeSheetInfo", {
1102
- title: "确认订单",
1103
- showBack: false,
1104
- });
1105
- } else {
1106
- this.setData({
1107
- isShowSelectShipper: true,
1108
- })
1109
- this.triggerEvent("changeSheetInfo", {
1110
- title: "选择提货人",
1111
- showBack: true,
1112
- });
1113
- }
1114
- this.triggerEvent("changeSheetInfo", {
1115
- showClose: true,
1116
- });
1117
- this.setData({
1118
- isShowCreateShipper: false,
1119
- backType: 0
1120
- })
1121
- break;
1122
- case 4:
1123
- this.setData({
1124
- isShowAddressManage: false,
1125
- backType: 0
1126
- })
1127
- this.triggerEvent("changeSheetInfo", {
1128
- title: "确认订单",
1129
- showClose: true,
1130
- showBack: false,
1131
- })
1132
- break;
1133
- case 5:
1134
- this.setData({
1135
- isShowEditAddress: false,
1136
- backType: 0
1137
- })
1138
- this.triggerEvent("changeSheetInfo", {
1139
- title: "确认订单",
1140
- showClose: true,
1141
- showBack: false,
1142
- })
1143
- break;
1144
- }
1145
- },
1146
- // 供子组件修改父组件值
1147
- updataData(e) {
1148
- this.setData({
1149
- ...e.detail
1150
- })
1151
- },
1152
- // 初始化数据,请求相应接口
1153
- async initData() {
1154
- this.fetchCollectInfo();
1155
- this.initShopConf();
1156
- this.initDeliveryState();
1157
- this.initPickerInfo();
1158
- this.initBusinessFeatureConf();
1159
- },
1160
- fetchCollectInfo() {
1161
- const { resource_type, resource_id } = this.data.baseInfoQuery;
1162
- const appid = this.data.confirmOrderInfo?.goods_info?.app_id;
1163
- const params = {
1164
- resource_type,
1165
- resource_id,
1166
- scenes: 'buy_page',
1167
- app_id: appid,
1168
- user_id: this.data.aliveInfo?.user_id
1169
- }
1170
- fetchCollectInfo(params).then(res => {
1171
- if (res.data.code === 0) {
1172
- this.setData({
1173
- assertNeedCollectInfo: res.data.data
1174
- })
1175
- }
1176
- })
1177
- },
1178
- // 获取营销活动信息
1179
- initMarketingData() {
1180
- wx.showLoading({
1181
- mask: true,
1182
- title: '加载中'
1183
- })
1184
- let params = {
1185
- spu_id: this.data.baseInfoQuery.id,
1186
- spu_type: this.data.baseInfoQuery.spu_type,
1187
- resource_type: this.data.baseInfoQuery.resource_type,
1188
- }
1189
- return getMarketingInfo(params).then(val => {
1190
- let res = val.data;
1191
- if (res.code === 0) {
1192
- let marketing_info = res.data.marketing_info;
1193
- if (
1194
- marketing_info?.activity_type === 3 &&
1195
- !(
1196
- (marketing_info?.all_stock > 0 &&
1197
- marketing_info?.now_stock > 0) ||
1198
- marketing_info?.all_stock == 0
1199
- ) &&
1200
- ![21, 29, 41, 42].includes(marketing_info.resource_type)
1201
- ) {
1202
- // 这里的逻辑要注意,如果接口返回了营销信息但工程拿不到的话,问题就在这里。
1203
- // 如果是限时折扣,且达到了限量后,就应该不显示限时折扣的信息了,我选择在源头就断了这个数据,但保留了推广员的信息
1204
- // 且这里不能是多规格的商品,因为多规格的商品没有限量的设置,如果你看到的时候已经准备有了,麻烦跟产品说这需求咱不接,咱不受这鸟气
1205
- res.data.marketing_info = null;
1206
- }
1207
- this.setData({
1208
- marketingData: res.data
1209
- })
1210
- } else {
1211
- this.setData({
1212
- marketingDataLoaded: true
1213
- })
1214
- }
1215
- }).catch((err) => console.log(err))
1216
- .finally(() => {
1217
- // // wx.hideLoading()
1218
- })
1219
- },
1220
- // 业务特性信息
1221
- initBusinessFeatureConf() {
1222
- wx.showLoading({
1223
- mask: true,
1224
- title: '加载中'
1225
- })
1226
- let params = {
1227
- spu_id: this.data.baseInfoQuery.id
1228
- }
1229
- getBusinessFeature(params).then(res => {
1230
- if (res.data.code === 0) {
1231
- this.setData({
1232
- businessConf: res.data.data
1233
- })
1234
- }
1235
- }).catch((err) => console.log(err))
1236
- .finally(() => {
1237
- // wx.hideLoading()
1238
- })
1239
- },
1240
- // 获取超级会员相关信息
1241
- initSuperVipInfo() {
1242
- wx.showLoading({
1243
- mask: true,
1244
- title: '加载中'
1245
- })
1246
- let params = {
1247
- resource_id: this.data.baseInfoQuery.resource_id || this.data.resource_id,
1248
- resource_type: this.data.baseInfoQuery.resource_type,
1249
- };
1250
- return getSuperVipInfo(params).then(res => {
1251
- if (res.data.code === 0) {
1252
- this.setData({
1253
- superVipInfo: res.data.data,
1254
- userIsVip: res.data.data?.svip_info?.user_svip_info?.state === 1
1255
- })
1256
- }
1257
- }).catch((err) => console.log(err))
1258
- .finally(() => {
1259
- // wx.hideLoading()
1260
- })
1261
- },
1262
- // 商品的套餐信息
1263
- initGoodsPackage() {
1264
- wx.showLoading({
1265
- mask: true,
1266
- title: '加载中'
1267
- })
1268
- let params = {
1269
- spu_id: this.data.baseInfoQuery.spu_id,
1270
- }
1271
- return getGoodsPackage(params).then(res => {
1272
- let {
1273
- code,
1274
- data: goodsPackage
1275
- } = res.data
1276
- if (code === 0) {
1277
- this.setData({
1278
- goodsPackage,
1279
- hasEntityGoods: goodsPackage.entity_goods_num > 0 ? true : false
1280
- })
1281
- if (this.data.baseInfoQuery.spu_type != "ENT" && goodsPackage.has_package) {
1282
- this.setData({
1283
- distributionMode: goodsPackage.package_delivery
1284
- })
1285
- }
1286
- }
1287
- }).catch((err) => console.log(err))
1288
- .finally(() => {
1289
- // wx.hideLoading()
1290
- })
1291
- },
1292
- // 进入页面 初始化自提人信息
1293
- initPickerInfo() {
1294
- wx.showLoading({
1295
- mask: true,
1296
- title: '加载中'
1297
- })
1298
- let {
1299
- id,
1300
- spu_type,
1301
- } = this.data.baseInfoQuery
1302
- getPickerInfo({
1303
- bizData: {
1304
- spu_id: id,
1305
- spu_type
1306
- }
1307
- }).then(res => {
1308
- const { code, data } = res.data;
1309
- if (code === 0) {
1310
- this.setData({
1311
- 'formData.pickInfo.picker': data,
1312
- 'formData.pickInfo.site': data?.lastSelfPickInfo?.place_name ? data.lastSelfPickInfo : this.data.picksiteInfo,
1313
- picksiteInfo: data.lastSelfPickInfo.place_name ? data.lastSelfPickInfo : {},
1314
- pickerUserInfo: data || {}
1315
- });
1316
- }
1317
- }).catch((err) => console.log(err))
1318
- .finally(() => {
1319
- this.loadingStatus(false);
1320
- })
1321
- },
1322
- async handleInfo() {
1323
- let result = await this.initConfirmOrderInfo();
1324
- this.handleOrderInfo(result);
1325
- this.loadingStatus(false);
1326
- this.doValuate('changeAddress');
1327
- },
1328
- // 初始化订单页基本信息
1329
- initConfirmOrderInfo() {
1330
- let {
1331
- id,
1332
- resource_type,
1333
- spu_type,
1334
- sku
1335
- } = this.data.baseInfoQuery
1336
- let params = {
1337
- spu_id: id,
1338
- resource_type,
1339
- spu_type,
1340
- address_id: this.data.addressInfo.id || "",
1341
- sku_id: sku || "",
1342
- }
1343
- return getConfirmOrderDetail(params)
1344
- },
1345
- // 处理初始化订单页基本信息
1346
- handleOrderInfo(val) {
1347
- let res = val.data
1348
- if (res.code === 0) {
1349
- this.setData({
1350
- confirmOrderInfo: res.data,
1351
- resource_id: res.data.goods_info.resource_id,
1352
- })
1353
- if (this.data.baseInfoQuery.spu_type === "ENT") {
1354
- this.setData({
1355
- distributionMode: res.data.goods_info.distribution_pattern
1356
- })
1357
-
1358
- if (res.data.goods_info.distribution_pattern === 2) {
1359
- this.setData({
1360
- activeMode: 2
1361
- })
1362
- }
1363
- }
1364
- if(this.data.baseInfoQuery.spu_type == "COP"){
1365
- this.setData({
1366
- distributionMode: res.data.goods_info.sku_info.distribution_pattern
1367
- })
1368
- if (res.data.goods_info.sku_info.distribution_pattern === 2) {
1369
- this.setData({
1370
- activeMode: 2
1371
- })
1372
- }
1373
- }
1374
- if (this.data.showAddressSelect) {
1375
- this.initAddressErro();
1376
- }
1377
- if (res.data.goods_info.sku_info?.sku_floor_price){
1378
- this.setData({
1379
- sku_floor_price: res.data.goods_info.sku_info?.sku_floor_price
1380
- })
1381
- }
1382
- }
1383
- },
1384
- initAddressErro() {
1385
- let address_info = this.data.confirmOrderInfo.address_info || {};
1386
- // 兼容老数据,手机号+区号后格式有误提示用户需要修改
1387
- if (address_info?.currentArea) {
1388
- const patt = /^[1][3-9][\d]{9}/.test(address_info.phone);
1389
- if ((address_info.currentArea.nation_code === '' || address_info.currentArea.nation_code === '86') && (address_info.phone.length != 11 || !patt)) {
1390
- address_info = {
1391
- ...address_info,
1392
- calculate_freight: false,
1393
- calculate_freight_text: '手机号码格式有误,请重新输入'
1394
- }
1395
- }
1396
- }
1397
- let addressInfo = Array.isArray(address_info) || !address_info ? {} : address_info;
1398
- this.setData({
1399
- addressInfo: addressInfo,
1400
- formData: {
1401
- ...this.data.formData,
1402
- address: addressInfo
1403
- }
1404
- })
1405
- },
1406
- // 获取商家自提状态
1407
- initDeliveryState() {
1408
- wx.showLoading({
1409
- mask: true,
1410
- title: '加载中'
1411
- })
1412
- const params = {
1413
- spu_id: this.data.baseInfoQuery.id
1414
- }
1415
- getExpressSwitch(params).then(res => {
1416
- if (res.data.code === 0) {
1417
- this.setData({
1418
- userCanPick: res.data.data.self_service_switch,
1419
- isHideSelfPickerInfo: res.data.data.is_hide_self_picker_info
1420
- })
1421
- }
1422
- })
1423
- .catch((err) => console.log(err))
1424
- .finally(() => {
1425
- // wx.hideLoading()
1426
- })
1427
- },
1428
- // 切换配送模式
1429
- changeMode(e) {
1430
- let val = e.detail;
1431
- let num = 0;
1432
- val ? num = 2 : num = 1;
1433
- this.setData({
1434
- activeMode: val,
1435
- express_type: num
1436
- })
1437
- const { address } = this.data.formData;
1438
- if (this.shouldValuateOnDeliveryChange(val, address)) {
1439
- this.doValuate('changeMode');
1440
- }
1441
- },
1442
- // 支付成功
1443
- successCallback(payResult) {
1444
- console.log("支付成功2");
1445
- this.triggerEvent("successCallback", payResult.detail);
1446
- },
1447
- // 支付失败
1448
- failCallback() {
1449
- console.log("支付失败2");
1450
- this.triggerEvent("failCallback");
1451
- },
1452
- onCountChange(val) {
1453
- const {count, isInit} = val.detail;
1454
- if (this.data.formData.count !== count) {
1455
- this.setData({
1456
- formData: {
1457
- ...this.data.formData,
1458
- count
1459
- },
1460
- })
1461
- if (!isInit) {
1462
- this.doValuate('changeCount');
1463
- }
1464
- }
1465
- },
1466
- // 选择优惠券/优惠码
1467
- handleCouponChange(val) {
1468
- const { coupons, promoCode } = val.detail;
1469
- this.setData({
1470
- 'formData.couponInfo': {
1471
- isSelected: true,
1472
- selectedCoupons: coupons
1473
- },
1474
- 'formData.promoCodeInfo': promoCode
1475
- })
1476
- this.doValuate('selectCoupon');
1477
- },
1478
- // 信息采集保存后回调
1479
- handleInfoCollectionChange(val) {
1480
- this.setData({
1481
- 'formData.infoCollectionInfo': val.detail
1482
- })
1483
- },
1484
- // 下单前校验
1485
- validateForm() {
1486
- const { address, pickInfo, infoCollectionInfo } = this.data.formData;
1487
-
1488
- // 地址校验
1489
- if (this.data.showAddressSelect) {
1490
- if (isEmptyObject(address)) {
1491
- wx.showToast({
1492
- title: '请添加收货地址',
1493
- icon: 'none',
1494
- duration: 2000
1495
- })
1496
- return Promise.reject(false);
1497
- }
1498
- }
1499
- // 自提校验
1500
- if(this.data.showPickSelf) {
1501
- if (isEmptyObject(pickInfo?.site)) {
1502
- wx.showToast({
1503
- title: '请选择自提点',
1504
- icon: 'none',
1505
- duration: 2000
1506
- })
1507
- return Promise.reject(false);
1508
- }
1509
- // 提货人白名单
1510
- if (PICKER_WHITE_LIST.includes(this.data.confirmOrderInfo?.goods_info?.app_id)) {
1511
- return Promise.resolve(true);
1512
- }
1513
- if (this.data.isHideSelfPickerInfo === 0 && (isEmptyObject(pickInfo?.picker) || pickInfo?.picker?.id === 0)) {
1514
- wx.showToast({
1515
- title: '请填写提货人',
1516
- icon: 'none',
1517
- duration: 2000
1518
- })
1519
- return Promise.reject(false);
1520
- }
1521
- }
1522
- // 信息采集校验
1523
- if (!infoCollectionInfo) {
1524
- return this.selectComponent('#InfoCollect')?.show();
1525
- }
1526
-
1527
- return Promise.resolve(true);
1528
- },
1529
- // 提交订单
1530
- async submitOrder() {
1531
- // 如果没有批价成功,则先批价再下单
1532
- if (isEmptyObject(this.data.valuateData)) {
1533
- const isSucceed = await this.doValuate('createOrder');
1534
- if (!isSucceed) return;
1535
- }
1536
-
1537
- // 校验表单参数
1538
- const valid = await this.validateForm();
1539
- if (!valid) return;
1540
-
1541
- try {
1542
- const { is_gray, need_collect } = this.data.assertNeedCollectInfo || {};
1543
- if (need_collect && this.data.infoIsLoadSuc && this.data.needCollect) {
1544
- //在白名单内,js还未加载完,必须等待信息采集加载完才给下单
1545
- if(isEmptyObject(this.data.formData.infoCollectionInfo)){
1546
- wx.showToast({
1547
- title: '下单失败,未填写信息采集,请重新提交订单',
1548
- icon: 'none',
1549
- duration: 2000
1550
- })
1551
- return;
1552
- }
1553
- }
1554
- } catch (error) {
1555
- console.log(err)
1556
- }
1557
-
1558
- // 组装下单参数
1559
- const orderParams = this.assembleCreateOrderParams();
1560
- if (isEmptyObject(orderParams)) {
1561
- return;
1562
- }
1563
-
1564
- console.log('orderParams: ', orderParams);
1565
- await this.createOrderFun(orderParams);
1566
- },
1567
- // 下单
1568
- createOrderFun(orderParams) {
1569
- wx.showLoading({
1570
- mask: true,
1571
- title: '努力抢购中'
1572
- });
1573
- const { spu_type, spu_id, resource_id, sku: sku_id } = this.data.baseInfoQuery
1574
-
1575
- return createOrderInLive(orderParams).then(async (res) => {
1576
- const { data, code, msg } = res.data;
1577
- wx.hideLoading();
1578
- switch(code) {
1579
- case 0:
1580
- this.setData({
1581
- payResult: data
1582
- });
1583
- let params = {
1584
- isAlive: 1,
1585
- cart: 0,
1586
- spu_type,
1587
- spu_id,
1588
- resource_id,
1589
- sku_id,
1590
- order_id: data?.order_id
1591
- };
1592
- this.setData({
1593
- successCallbackParams: params
1594
- })
1595
- // 零元单
1596
- if (data.order_pay_status === ORDER_PAY_STATUS.PAID) {
1597
- this.triggerEvent("successCallback", params);
1598
- } else {
1599
- // TODO 后续排期 - 鹅直播支持再次支付后放开接口 - 用于查询营销信息展示挽留弹窗
1600
- // this.queryOrderInfo(data?.order_id);
1601
- this.miniProPay(data?.pay_config?.wx_pay_config,data?.order_id);
1602
- }
1603
- break;
1604
- case 10086:
1605
- wx.showToast({
1606
- title: "当前下单人数过多,请稍后重试",
1607
- icon: 'none',
1608
- duration: 2000
1609
- });
1610
- break;
1611
- case 10060297306:
1612
- case 10060297310:
1613
- wx.showToast({
1614
- title: '商品已删除',
1615
- icon: 'none',
1616
- duration: 2000,
1617
- complete: () => {
1618
- this.triggerEvent("failCallback");
1619
- }
1620
- });
1621
- break;
1622
- // case 10060297401:
1623
- // wx.showToast({
1624
- // title: '配送方式已改变,请重新选择',
1625
- // icon: 'none',
1626
- // duration: 2000,
1627
- // complete: () => {
1628
- // this.triggerEvent("failCallback");
1629
- // }
1630
- // });
1631
- // break;
1632
- case 10060297208:
1633
- wx.showToast({
1634
- title: '自提信息已更新,请重新选择',
1635
- icon: 'none',
1636
- duration: 2000,
1637
- complete: () => {
1638
- this.triggerEvent("failCallback");
1639
- }
1640
- });
1641
- break;
1642
- default:
1643
- wx.showToast({
1644
- title: msg || '下单接口返回异常,请稍后重试',
1645
- icon: 'none',
1646
- duration: 2000
1647
- });
1648
- }
1649
- if (code !== 0) {
1650
- try {
1651
- sensorLog.sensors.track('view_page', {
1652
- page_id: 'e_alive#mini#order',
1653
- page_name: '确认订单页',
1654
- l_program: '鹅直播',
1655
- page_path: '鹅直播#小程序#直播间#确认订单页',
1656
- app_id: this.data.confirmOrderInfo?.goods_info?.app_id,
1657
- c_user_id: this.data.aliveInfo?.user_id,
1658
- cmm1: '下单接口报错',
1659
- cmm2: JSON.stringify(orderParams),
1660
- cmm3: msg
1661
- })
1662
- } catch (error) {
1663
- console.log('上报失败', error);
1664
- }
1665
- }
1666
- }).catch(err => {
1667
- wx.hideLoading();
1668
- });
1669
- },
1670
- assembleCreateOrderParams() {
1671
- const { isIntegral: pointsExchange, shareType, shareUserId, commonAuthCode, step: teamNum, isTeam, isJoin, aliveId, communityIdWindow, communityApplyId, adType, xiaoeCampBusinessAppId, channelId } = this.data.baseInfoQuery;
1672
- // 取至 formData
1673
- const { isSelected, pickInfo, invoiceInfo, infoCollectionInfo, eduInfo, userRemark, activityApplyInfo, promoCodeInfo: promoCode, address, isUseMemberLevel: useMemberLevel } = this.data.formData;
1674
- // 取至批价返回数据
1675
- const { token, identity_info, coupon_info, points_info, goods_list, promo_code_info } = this.data.valuateData;
1676
- const { address_id } = this.data.valuateParams;
1677
-
1678
- const addressId = this.data.activeMode === DELIVERY_MODE.EXPRESSAGE ? (address_id || address?.id || 0) : 0;
1679
- const siteId = pickInfo?.site?.place_id || 0;
1680
- const pickerId = !this.data.showPicker ? 0 : (pickInfo?.picker?.id || 0);
1681
- const place_type = pickInfo?.site?.place_type || 0;
1682
- const extendObjectInfo = {
1683
- activity_manager: activityApplyInfo,
1684
- student_info: eduInfo,
1685
- info_collect_object_info: infoCollectionInfo,
1686
- training_camp: {
1687
- xiaoe_camp_business_app_id: xiaoeCampBusinessAppId || ''
1688
- }
1689
- };
1690
-
1691
- const miscParameter = new MiscParameter(false, shareType, shareUserId, commonAuthCode);
1692
- // 商品信息
1693
- let orderGoodsList = new GoodsOrderList(goods_list, isTeam, teamNum, isJoin).transformApiParams();
1694
- // 身份信息
1695
- const identityType = identity_info?.identity_type;
1696
- const realIdentityType = identityType === IdentityType.FORBID_SVIP ? IdentityType.NONUSE : identityType;
1697
- const identityInfo = new IdentityInfo(realIdentityType).transformApiParams();
1698
- // 优惠券
1699
- const couponInfo = new CouponInfo(isSelected, coupon_info?.selected_coupons?.list).transformOrderParams();
1700
- // 优惠码
1701
- // 兼容优惠码不可用,url上带了优惠码
1702
- // 通过批价接口处理优惠码,如果优惠码不可用,promo_code_info.can_use_promo_code字段为false
1703
- let promoCodeInfo = new PromoCodeInfo(promoCode).transformApiParams();
1704
- if (promo_code_info?.can_use_promo_code === false) {
1705
- promoCodeInfo.promo_code = '';
1706
- }
1707
- // 积分信息
1708
- const { is_use_integral, used_point } = points_info;
1709
- const pointInfo = new PointInfo(!!pointsExchange, !!is_use_integral, used_point || 0).transformCreateOrderParams();
1710
- // 地址、自提相关信息
1711
- const deliveryInfo = new DeliveryInfo(this.data.activeMode === 0 ? 1 : 2, addressId, pickerId, siteId, place_type).transformApiParams();
1712
- // 渠道来源
1713
- const { channelType, channelBusId } = resolveChannelInfo(aliveId, adType, communityIdWindow, communityApplyId, channelId);
1714
- // 会员等级
1715
- const isUseMemberLevel = useMemberLevel === undefined ? 1 : useMemberLevel;
1716
- const level_member_info = new LevelMemberInfo(isUseMemberLevel).transformApiParams()
1717
- // 订单类型 普通订单-1,积分兑换-4
1718
- const tradeType = this.isIntegral ? 4 : 1;
1719
-
1720
- return new Parameter(miscParameter.transformApiParams()) //路由上的一些参数
1721
- .append('token', token) // 批价token
1722
- .append('goods_list', orderGoodsList) // 商品信息
1723
- .append('identity_info', identityInfo) //身份信息
1724
- .append('promo_code_info', promoCodeInfo) //优惠码
1725
- .append('coupon_info', couponInfo) //优惠券
1726
- .append('points_info', pointInfo) //积分信息
1727
- .append('invoice_info', invoiceInfo) //发票信息
1728
- .append('delivery_object_info', deliveryInfo) // 地址、字提人信息
1729
- .append('extend_object_info', extendObjectInfo) //活动管理的学生信息 线下课学生信息 小鹅通训练营订购商家APPID
1730
- .append('user_remark', userRemark) // 留言
1731
- .append('channel_bus_id', channelBusId) // 渠道id
1732
- .append('channel_type', channelType) //渠道类型
1733
- .append('from_shopping_cart', false) //是否是购物车
1734
- .append('merchant_url_id', '') // 页面统计id
1735
- .append('trade_type', tradeType) // 订单类型
1736
- .append('level_member_info', level_member_info) //等级会员
1737
- .append('user_agente_env_type', 'MiniProgram || XiaoEEliveMP') // 鹅直播终端标识
1738
- .append('pay_way', 6); // 微信支付
1739
- },
1740
- miniProPay(payConfig, orderId) {
1741
- let that = this;
1742
- const { timeStamp, nonceStr, package: packages, signType, paySign } = payConfig || {};
1743
- const { trade_id, order_id } = that.data.payResult || {};
1744
- wx.requestPayment({
1745
- timeStamp,
1746
- nonceStr,
1747
- package: packages,
1748
- signType,
1749
- paySign,
1750
- success (res) {},
1751
- fail (res) {
1752
- console.log('cancel pay')
1753
- // https://appweqixw3x3114.h5.xiaoeknow.com/p/t/v1/ecommerce/h5_order/order/order_list?order_state=1
1754
- let copyUrl = `https://${that.data.confirmOrderInfo?.goods_info?.app_id}.h5.xiaoeknow.com/p/t/v1/ecommerce/h5_order/order/order_details?order_id=${orderId}`
1755
- that.triggerEvent("cancelPay",copyUrl);
1756
- },
1757
- complete(res){
1758
- const params = {
1759
- app_id: that.data.confirmOrderInfo?.goods_info?.app_id,
1760
- trade_id,
1761
- order_id,
1762
- };
1763
- queryOrder(params).then(res => {
1764
- console.log('查询订单', res);
1765
- const { data, code } = res.data;
1766
- const payOrderState = data.info.pay_state;
1767
- if (payOrderState === "SUCCESS") {
1768
- that.triggerEvent("successCallback", that.data.successCallbackParams);
1769
- } else {
1770
- that.triggerEvent("failCallback");
1771
- }
1772
- }).catch(err => {
1773
- console.log('查询订单失败', err);
1774
- wx.showToast({
1775
- title: "您的订单未完成支付,请重新支付",
1776
- icon: 'none',
1777
- duration: 2000
1778
- });
1779
- that.triggerEvent("failCallback");
1780
- })
1781
- }
1782
- })
1783
- },
1784
- queryOrderInfo(orderId){
1785
- queryOrderInfo({order_id: orderId}).then(({data}) => {
1786
- if(data && data.code === 0){
1787
- let items = data.data.items
1788
- let discount_list = []
1789
- if(items && items.length > 0){
1790
- items.forEach(item => {
1791
- if(DISCOUNT_SHOW_TYPE.includes(item.discount_sub_type)){
1792
- discount_list.push(DISCOUNT_SHOW_TYPE_MAP[item.discount_sub_type])
1793
- }
1794
- })
1795
- // 使用 Set 去重
1796
- discount_list = [...new Set(discount_list)]
1797
- }
1798
- this.triggerEvent('discountInfo', {
1799
- discount_list,
1800
- cancelTime: data.data.cancel_time,
1801
- orderId,
1802
- priceInfo: this.data.valuateData.price_info
1803
- })
1804
- }
1805
- }).catch(err => {
1806
- console.log('查询订单失败', err);
1807
- })
1808
- },
1809
- handleShowFreightIns(){
1810
- this.setData({
1811
- showFreightIns: true
1812
- })
1813
- },
1814
- handleCloseFreightIns(){
1815
- this.setData({
1816
- showFreightIns: false
1817
- })
1818
- }
1819
- }
1
+ // src/ConfirmOrder/components/ConfirmOrderContent/index.js
2
+ import {
3
+ fetchCollectInfo,
4
+ getBusinessFeature,
5
+ getConfirmOrderDetail,
6
+ getExpressSwitch,
7
+ getGoodsPackage,
8
+ getMarketingInfo,
9
+ getPickerInfo,
10
+ getPrePayInfoV3,
11
+ getShopConf,
12
+ getSuperVipInfo
13
+ } from "../../../common/api/confirmOrder";
14
+ import { ActivityInfo, CouponInfo, DeliveryInfo, GoodsList, GoodsOrderList, IdentityInfo, LevelMemberInfo, MiscParameter, Parameter, PointInfo, PromoCodeInfo, resolveChannelInfo } from "../../../common/transaction/parameter/index.js";
15
+ import { createOrderInLive, queryOrder, queryOrderInfo, valuate } from "../../../common/transaction/valuate/index.js";
16
+ import {
17
+ ASSOCIATION,
18
+ BIG_SPECIAL_COLUMN,
19
+ DELIVERY_METHOD_TEXT,
20
+ DELIVERY_MODE,
21
+ DISCOUNT_SHOW_TYPE,
22
+ DISCOUNT_SHOW_TYPE_MAP,
23
+ MARKETING_FISSION_POSTER,
24
+ MARKETING_SEC_KILL,
25
+ MEMBER,
26
+ SHIELD_ACTIVITY,
27
+ SPECIAL_COLUMN,
28
+ SVIP,
29
+ TRAINING_CAMP
30
+ } from "../../../common/utils/constants.js";
31
+ import eventBus from '../../../common/utils/eventBus.js';
32
+ import {
33
+ isEmptyObject
34
+ } from "../../../common/utils/index";
35
+ import {
36
+ postCouponList
37
+ } from "../../../common/utils/postCouponList";
38
+ import { PICKER_WHITE_LIST } from "../../../common/utils/specialList";
39
+ import {
40
+ debounce
41
+ } from "../../../common/utils/tool.js";
42
+ const { sensorLog } = require("live-mp-tools");
43
+
44
+
45
+ const computedBehavior = require('miniprogram-computed').behavior
46
+
47
+ const IdentityType = {
48
+ NONUSE: -1,//不参加任何身份特权优惠
49
+ ANSWER: 0,//需要后端请求身份信息,选择优惠力度大的那个
50
+ USE_SVIP: 1,//使用超级会员
51
+ FORBID_SVIP: 2//禁止使用超级会员
52
+ }
53
+
54
+ const MINMUM_PRICE_TYPE_MAP = {
55
+ NORMAL: 1,
56
+ SVIP: 2,
57
+ MARKETING: 3
58
+ }
59
+
60
+ // 订单状态 1 未支付 2 支付完成(0元单)
61
+ const ORDER_PAY_STATUS = {
62
+ UNPAID: 1,
63
+ PAID: 2,
64
+ };
65
+
66
+ Component({
67
+ behaviors: [computedBehavior],
68
+ /**
69
+ * 组件的属性列表
70
+ */
71
+ properties: {
72
+ baseInfoQuery: {
73
+ type: Object,
74
+ value: () => {},
75
+ },
76
+ isCart: {
77
+ type: Number,
78
+ value: 0,
79
+ },
80
+ isTeam: {
81
+ type: Boolean,
82
+ default: false,
83
+ },
84
+ aliveInfo:{
85
+ type: Object,
86
+ value:{}
87
+ },
88
+ sensorReportParams:{
89
+ type: Object,
90
+ value:{}
91
+ },
92
+ popPosition: {
93
+ type: String,
94
+ value: 'bottom'
95
+ },
96
+ round:{
97
+ type:Boolean,
98
+ value: true
99
+ },
100
+ showClose:{
101
+ type:Boolean,
102
+ value: true
103
+ },
104
+ invoiceSelectZIndex:{
105
+ type: Number,
106
+ value: 100
107
+ },
108
+ invoiceTipZIndex:{
109
+ type: Number,
110
+ value: 100
111
+ },
112
+ refundTipsZIndex:{
113
+ type: Number,
114
+ value: 100
115
+ },
116
+ zIndex:{
117
+ type: Number,
118
+ value: 100
119
+ },
120
+ },
121
+
122
+ /**
123
+ * 组件的初始数据
124
+ */
125
+ data: {
126
+ activeMode: 0, // 0:快递配送,1:自提
127
+ express_type: 0, // 接口下发配送信息 1-快递配送 2-商品自提
128
+ userCanPick: 1, // 商家是否支持自提 1支持 0不支持
129
+ shopConf: {},
130
+ confirmOrderInfo: {
131
+ // 订单页详细信息(通过查询接口拿到)
132
+ app_info: {},
133
+ goods_info: {},
134
+ },
135
+ distributionMode: 0, // 配送方式 -1全部 1快递配送 2商品自提 (目前只支持实物商品,非实物商品返回0)
136
+ resource_id: "",
137
+ addressInfo: {}, // 地址信息(非自提)
138
+ pickerUserInfo: {}, // 自提人信息
139
+ picksiteInfo:{}, //自提点信息
140
+ hasEntityGoods: false, // 商品套餐是否包含实物商品
141
+ superVipInfo: {}, // 超级会员信息
142
+ userIsVip: false, // 用户是否是超级会员
143
+ businessConf: {},
144
+ marketingData: {}, //营销数据
145
+ isShowPoint: false, // 是否显示选择提货点组件
146
+ isShowSelectShipper: false, // 是否显示选择提货人组件
147
+ isShowCreateShipper: false, // 是否显示新增、编辑提货人组件
148
+ isShowAddressManage: false, // 是否显示地址管理组件(非自提)
149
+ isShowEditAddress: false, // 是否显示新建、编辑组件(非自提)
150
+ addressQuery: {}, // 地址相关组件需要的入参
151
+ marketingDataLoaded: false, //营销数据加载
152
+ cartInfoLoaded: false, //购物车数据加载
153
+ addressInfoLoaded: false, //地址信息加载
154
+ backType: 0, // 弹框顶部返回按钮操作
155
+ backPage: 1, // 1:确认订单页面大组件
156
+ shipperType: 1, // 1:新建自提人;2:编辑自提人
157
+ checkList: {}, // 支付前校验信息
158
+ beforePay: {}, // 支付前校验函数
159
+ afterPay: {}, // 支付后的参数
160
+ afterPayCallback: {}, // 支付后回调
161
+ payParams: {},
162
+ prePayParams: {}, //批价信息参数
163
+ getPrePayInfoReset: null, // 批价防抖函数回调
164
+ //错误信息
165
+ errMsg: {
166
+ 10309: "该商品已售罄",
167
+ 30201: "商家未设置支付方式,请联系商家处理",
168
+ 30202: "支付失败,请联系商家处理",
169
+ 10029: "已拥有,不可重复购买",
170
+ 10067: "该商品已下架,不支持继续购买!",
171
+ 10100: "该商品可能已下架或价格变更,请稍后再试。",
172
+ 10306: "拼团失败,请刷新重试。",
173
+ 10308: "活动即将开始",
174
+ 10310: "商家正努力补货中",
175
+ 10312: "未预约该活动",
176
+ 20012: "购买数量超过活动限制。",
177
+ 20020: "该团已满,请重新下单。",
178
+ 20021: "该活动已结束。",
179
+ 20011: "您已参与本团,不可重复参与。",
180
+ 20077: "配送区域已更新,此收货地址超出配送范围,请重新选择",
181
+ 20023: "单笔订单最多可购买1000件",
182
+ },
183
+ goodsPackageInfo: {}, //商品套餐信息
184
+ isShowSkeleton: true, //是否显示骨架屏
185
+ customDeliveryType: [DELIVERY_METHOD_TEXT.EXPRESSAGE, DELIVERY_METHOD_TEXT.PICK],//自定义配送方式顺序-由b端交易设置修改
186
+ showLoadingE: false, // loading,用于控制能否批价等操作
187
+ valuateParams: new Parameter(),//批价参数
188
+ formData: {
189
+ address: null, // 收货地址
190
+ pickInfo: {
191
+ site: null,
192
+ picker: null
193
+ }, // 自提信息,包括自提人、自提点
194
+ infoCollectionInfo: null,//信息采集参数
195
+ eduInfo: {
196
+ course_id: ''
197
+ }, // 线下课学员信息
198
+ goodsInfo: {}, // 商品信息
199
+ count: 1, // 商品数量
200
+ invoiceInfo: {
201
+ invoice_type: 0
202
+ }, // 发票信息
203
+ userRemark: '', // 留言
204
+ isUseIntegral: false, // 是否使用积分
205
+ isInitPoint: true, //积分抵扣标识
206
+ couponInfo: {
207
+ isSelected: false,
208
+ selectedCoupons: []
209
+ }, // 优惠券信息
210
+ promoCodeInfo: '', // 优惠码信息
211
+ teamBuy: {}, // 拼团
212
+ activityApplyInfo: [], // 活动管理报名信息
213
+ beforePay: {}, // 支付前校验函数
214
+ checkList: {}, // 支付前校验信息
215
+ identityType: IdentityType.ANSWER, // 身份特权类型: -1 不参加任何优惠, 0 都需要查询, 1 超级会员
216
+ },//表单数据,如自提信息、优惠券、信息采集 等等
217
+ sku_floor_price: null, // 商品低价
218
+ valuateData: {},// 批价返回参数
219
+ prePayInfo: {}, // 批价信息
220
+ payResult: {}, // 支付接口返回信息
221
+ assertNeedCollectInfo: {},
222
+ infoIsLoadSuc: true,//信息采集加载状态
223
+ needCollect: true, //信息采集状态二次确认
224
+ successCallbackParams: {}, // 支付成功回调参数
225
+ waitInformation: true, // 是否是第一次批价,用来第一次批价等信息采集接口返回
226
+ setTime: null, // 计时器
227
+ infoCollectionLoaded: [], //信息采集加载完成的时间
228
+ showFreightIns: false, // 运费险
229
+ is_show_freight_ins: false, // 运费险
230
+ isHideSelfPickerInfo: null, // 自提人信息填写状态
231
+ },
232
+ options: {
233
+ addGlobalClass: true
234
+ },
235
+ lifetimes: {
236
+ attached: async function () {
237
+ // 在组件实例进入页面节点树时执行
238
+ eventBus.on('order_onInfoCollectionLoaded', ({needCollect, isLoad}) => {
239
+ console.log(needCollect, isLoad);
240
+ this.setData({
241
+ infoIsLoadSuc: isLoad,
242
+ needCollect,
243
+ waitInformation: false, // 信息采集接口返回成功,不需要等
244
+ })
245
+ if(this.data.setTime){ // 等待中的话
246
+ clearTimeout(this.data.setTime); // 不等待了
247
+ this.loadingStatus(false);
248
+ this.setData({
249
+ setTime: null
250
+ })
251
+ }
252
+ const time = `第${this.data.infoCollectionLoaded.length + 1}_${new Date().getTime()}_${needCollect}`
253
+ const infoCollectionLoaded = this.data.infoCollectionLoaded;
254
+ this.setData({
255
+ infoCollectionLoaded: infoCollectionLoaded.push(time)
256
+ })
257
+ // TODO: 信息采集上报
258
+ });
259
+ // 优先请求下单页基本数据,然后隐藏骨架屏,展示基本内容
260
+ let result = await this.initConfirmOrderInfo();
261
+ console.log('result',result)
262
+ if (result.data.code === 0 & this.data.baseInfoQuery.spu_type == "ENT" & result.data.data.goods_info.distribution_pattern === -1 && this.data.userCanPick === 1) {
263
+ const customDeliveryType = result.data.data.distribution_pattern_config;
264
+ this.setData({
265
+ customDeliveryType: customDeliveryType,
266
+ activeMode: customDeliveryType[0] === DELIVERY_METHOD_TEXT.EXPRESSAGE ? DELIVERY_MODE.EXPRESSAGE : DELIVERY_MODE.PICK
267
+ })
268
+ }
269
+ this.handleOrderInfo(result);
270
+ // 隐藏骨架屏
271
+ this.setData({
272
+ isShowSkeleton: false,
273
+ });
274
+
275
+ // 请求营销活动、超级会员接口,从而进行批价
276
+ await this.initSuperVipInfo();
277
+ await this.initMarketingData();
278
+ await this.initGoodsPackage();
279
+
280
+ this.initData();
281
+
282
+ // 批价
283
+ await this.doValuate('initialize');
284
+ },
285
+ },
286
+ computed: {
287
+ // 是否全屏
288
+ isFullScreen(properties) {
289
+ return properties.popPosition === 'right'
290
+ },
291
+ isShowMain(data) {
292
+ return (
293
+ !data.isShowPoint &&
294
+ !data.isShowSelectShipper &&
295
+ !data.isShowCreateShipper &&
296
+ !data.isShowAddressManage &&
297
+ !data.isShowEditAddress
298
+ )
299
+ },
300
+ //判断模式选择tab栏的显示和隐藏
301
+ showModeSelect(data) {
302
+ return data.distributionMode === -1 && data.userCanPick === 1;
303
+ },
304
+ // 显示地址栏的情况 商品有两种配送方式,商家关闭自提/购物车
305
+ showAddressSelect(data) {
306
+ return (
307
+ data.activeMode === DELIVERY_MODE.EXPRESSAGE &&
308
+ (data.distributionMode === -1 || data.distributionMode === 1)
309
+ );
310
+ },
311
+ // 商品信息
312
+ goodsInfo(data) {
313
+ if (isEmptyObject(data.confirmOrderInfo.goods_info)) {
314
+ return data.baseInfoQuery;
315
+ }
316
+ return data.confirmOrderInfo.goods_info;
317
+ },
318
+ //通过商家是否开启自提和自提选择 决定自提组件的显示和隐藏
319
+ showPickSelf(data) {
320
+ return (data.activeMode === DELIVERY_MODE.PICK || data.distributionMode === 2)
321
+ },
322
+ // 用户信息填写,0-必填,1-可选,2-不填。不填则隐藏提货人
323
+ showPicker(data) {
324
+ return data.isHideSelfPickerInfo !== null && data.isHideSelfPickerInfo !== 2
325
+ },
326
+ // 公共批价请求参数
327
+ commonPrePayParams(data) {
328
+ let spuType = data.baseInfoQuery.spu_type;
329
+ let coursePackage = [
330
+ MEMBER,
331
+ SPECIAL_COLUMN,
332
+ BIG_SPECIAL_COLUMN,
333
+ TRAINING_CAMP,
334
+ ];
335
+ let paymentType15 = [SVIP]
336
+ let paymentType = 2;
337
+ if (coursePackage.includes(spuType)) {
338
+ paymentType = 3;
339
+ }
340
+ if (paymentType15.includes(spuType)) {
341
+ paymentType = 15;
342
+ }
343
+ return {
344
+ pre_pay_type: data.baseInfoQuery.pre_pay_type || 1,
345
+ resource_id: data.baseInfoQuery.resource_id,
346
+ spu_id: data.baseInfoQuery.id,
347
+ count: data.baseInfoQuery.count,
348
+ // product_id: data.baseInfoQuery.id,
349
+ product_id: '',
350
+ resource_type: data.baseInfoQuery.resource_type,
351
+ spu_type: spuType,
352
+ payment_type: paymentType,
353
+ sku_id: data.baseInfoQuery.sku,
354
+ };
355
+ },
356
+ // 通过请求获取的批价参数是否都已加载完毕
357
+ prePayParamsInfoLoaded(data) {
358
+ return (
359
+ ((data.marketingDataLoaded && !data.isCart) ||
360
+ (data.isCart && data.cartInfoLoaded)) &&
361
+ (data.addressInfoLoaded ||
362
+ Object.keys(data.pickerUserInfo).length > 0 ||
363
+ data.activeMode === 0)
364
+ //加入商品自提后,这里判断是否加载完自提人消息来确定批价参数是否加载完毕
365
+ //每次切换提货模式时也要触发商品批价信息
366
+ );
367
+ },
368
+ marketInfo(data) {
369
+ return data.marketingData?.marketing_info || {};
370
+ },
371
+ marketingLowPrice(data) {
372
+ const { activity_type, low_price, is_subscribe, user_subscribed, in_activity, event_has_stock } = data.marketInfo;
373
+ if ([3, 6].includes(activity_type)) {
374
+ return low_price;
375
+ }
376
+ if ([8].includes(activity_type)) {
377
+ if (is_subscribe === 1 && user_subscribed === 0 && in_activity === 1) {
378
+ return null;
379
+ }
380
+ // 如何没库存则按原价来计算券后价
381
+ if (event_has_stock === 0) {
382
+ return null;
383
+ }
384
+ return low_price;
385
+ }
386
+ return null;
387
+ },
388
+ isSvipUseful(data) {
389
+ return (
390
+ data.superVipInfo?.svip_purchase_valid === 1 &&
391
+ data.superVipInfo?.svip_info?.svip_state === 0 &&
392
+ data.superVipInfo?.svip_info?.single_resource_rights?.rights_type === 2 && // 增加超会折扣权益判断
393
+ data.userIsVip
394
+ )
395
+ },
396
+ // 超级会员价
397
+ svipPrice(data) {
398
+ const skuPriceInfo = data.superVipInfo.sku_svip_price_list;
399
+ if (skuPriceInfo && Object.keys(skuPriceInfo).length) {
400
+ const svipPrices = Object.keys(skuPriceInfo).map((sku) => skuPriceInfo[sku]);
401
+ return Math.min.apply(Math, svipPrices);
402
+ }
403
+ return 0;
404
+ },
405
+ zeroPay(data) {
406
+ return data.valuateData?.price_info?.final_price === 0
407
+ },
408
+ // 积分组件需要的信息
409
+ integral(data) {
410
+ return data.valuateData?.points_info || '';
411
+ },
412
+ priceInfo(data) {
413
+ return data.valuateData?.price_info || {};
414
+ },
415
+ showIntegral(data) {
416
+ return data.valuateData?.points_info?.is_show_point;
417
+ }
418
+ },
419
+ observers: {
420
+ distributionMode(val) {
421
+ if (val === 1) {
422
+ this.setData({
423
+ express_type: val
424
+ })
425
+ } else if (val === 2) {
426
+ this.setData({
427
+ express_type: val
428
+ })
429
+ }else if (val === 0) {
430
+ this.setData({
431
+ express_type: val
432
+ })
433
+ }else if (val === -1) {
434
+ this.setData({
435
+ express_type: 1
436
+ })
437
+ }
438
+ },
439
+ marketingData(marketingData) {
440
+ // 这里的逻辑应该是存在拼团的时候那么payment_type就要赋值为13,如果是限时折扣或者是单买的话,payment_type不做赋值默认为2
441
+ if (
442
+ marketingData &&
443
+ marketingData.payment_type &&
444
+ this.data.isTeam === "true"
445
+ ) {
446
+ this.payInfoChange({
447
+ name: "marketingData",
448
+ prePayParams: {
449
+ payment_type: marketingData.payment_type,
450
+ },
451
+ });
452
+ }
453
+ this.setData({
454
+ marketingDataLoaded: true
455
+ })
456
+ },
457
+ isShowCreateShipper(val) {
458
+ if (val) {
459
+ if (this.data.shipperType === 1) {
460
+ this.triggerEvent("changeSheetInfo", {
461
+ title: "新建提货人",
462
+ })
463
+ } else {
464
+ this.triggerEvent("changeSheetInfo", {
465
+ title: "编辑提货人",
466
+ })
467
+ }
468
+ this.triggerEvent("changeSheetInfo", {
469
+ showClose: false,
470
+ showBack: true,
471
+ })
472
+ this.setData({
473
+ backType: 3
474
+ })
475
+ } else {
476
+ this.backClick();
477
+ }
478
+ },
479
+ showPickSelf(val) {
480
+ if (!val) {
481
+ this.payInfoChange({
482
+ name: "pickerUserInfo",
483
+ errMsg: "",
484
+ });
485
+ this.payInfoChange({
486
+ name: "address",
487
+ errMsg: "",
488
+ });
489
+ }
490
+ },
491
+ isShowSelectShipper: function (newData) {
492
+ if (newData) {
493
+ this.triggerEvent("changeSheetInfo", {
494
+ title: "选择提货人",
495
+ showClose: false,
496
+ showBack: true,
497
+ })
498
+ this.setData({
499
+ backType: 2
500
+ })
501
+ } else {
502
+ this.backClick();
503
+ }
504
+ },
505
+ isShowAddressManage(newData) {
506
+ if (newData) {
507
+ this.triggerEvent("changeSheetInfo", {
508
+ title: "选择地址",
509
+ showClose: false,
510
+ showBack: true,
511
+ })
512
+ this.setData({
513
+ backType: 4
514
+ })
515
+ } else {
516
+ if (!this.data.isShowEditAddress) {
517
+ this.backClick()
518
+ }
519
+ }
520
+ },
521
+ isShowEditAddress(newData) {
522
+ if (newData) {
523
+ this.triggerEvent("changeSheetInfo", {
524
+ title: "地址编辑",
525
+ showClose: false,
526
+ showBack: true,
527
+ })
528
+ this.setData({
529
+ backType: 5
530
+ })
531
+ } else {
532
+ this.backClick()
533
+ }
534
+ },
535
+ isShowPoint: function (newData) {
536
+ if (newData) {
537
+ this.triggerEvent("changeSheetInfo", {
538
+ title: "提货地址",
539
+ showClose: false,
540
+ showBack: true,
541
+ })
542
+ this.setData({
543
+ backType: 1
544
+ })
545
+ } else {
546
+ this.backClick();
547
+ }
548
+ },
549
+ prePayParamsInfoLoaded(val) {
550
+ // if (val) {
551
+ // let obj = {
552
+ // ...this.data.commonPrePayParams,
553
+ // ...this.data.prePayParams,
554
+ // }
555
+ // this.setData({
556
+ // getPrePayInfoReset: this.getPrePayInfo(obj)
557
+ // })
558
+ // }
559
+ },
560
+ picksiteInfo(val) {
561
+ this.setData({
562
+ 'formData.pickInfo.site': val,
563
+ })
564
+ const { address } = this.data.formData;
565
+ if (this.shouldValuateOnDeliveryChange(this.data.activeMode, address)) {
566
+ // 触发批价
567
+ this.doValuate('listenPickup');
568
+ }
569
+ },
570
+ pickerUserInfo(val) {
571
+ this.setData({
572
+ 'formData.pickInfo.picker': val,
573
+ })
574
+ },
575
+ addressInfo(newVal) {
576
+ const formData = this.data.formData.address
577
+ this.setData({
578
+ 'formData.address': !newVal?.id ? null : newVal
579
+ })
580
+ if (newVal?.id && newVal?.id !== formData?.id) {
581
+ wx.nextTick(async () => {
582
+ let result = await this.initConfirmOrderInfo();
583
+ this.handleOrderInfo(result);
584
+ this.doValuate('listenAddress')
585
+ })
586
+ }
587
+ },
588
+ showAddressSelect(val) {
589
+ val && this.initAddressErro();
590
+ }
591
+ },
592
+ /**
593
+ * 组件的方法列表
594
+ */
595
+ methods: {
596
+ handleSvipChange(val) {
597
+ let data = {};
598
+ val.detail ? data = val.detail : data = val
599
+ this.setData({
600
+ 'formData.identityType': data?.selectSvip,
601
+ })
602
+ if (data?.trigger) {
603
+ this.$nextTick(() => {
604
+ this.doValuate('selectSvip');
605
+ })
606
+ }
607
+ },
608
+ handleIntegralSelectChange(val) {
609
+ let data = {};
610
+ val.detail ? data = val.detail : data = val
611
+ this.setData({
612
+ 'formData.isUseIntegral': data?.isUseIntegral ? true : false,
613
+ 'formData.isInitPoint': false,
614
+ })
615
+ this.doValuate('selectPoint');
616
+ },
617
+ //判断配送模式/信息变化时是否需要触发批价
618
+ shouldValuateOnDeliveryChange(deliveryMode, addressInfo,) {
619
+ switch (deliveryMode) {
620
+ case DELIVERY_MODE.EXPRESSAGE:
621
+ return addressInfo?.id;
622
+ case DELIVERY_MODE.PICK:
623
+ return true;
624
+ default:
625
+ return false;
626
+ }
627
+ },
628
+ /**
629
+ * 触发批价
630
+ * @description 触发批价的场景
631
+ * changeCount:改变商品数量
632
+ * initialize:初始化
633
+ * selectAddress:选择地址信息
634
+ * changeAddress: 地址编辑、删除回调
635
+ * selectPickup:选择自提人
636
+ * selectCoupon: 选择优惠券/优惠码
637
+ * selectPoint: 选择积分
638
+ * selectSvip: 选择Svip
639
+ * createOrder: 下单前校验批价
640
+ * changeMode: 切换配送方式
641
+ * listenAddress: 地址监听(兜底)
642
+ * listenPickup: 自提监听
643
+ * getCoupon: 领取优惠卷重新批价
644
+ * @param entrance
645
+ */
646
+ async doValuate(entrance) {
647
+ console.log('entrance=>',entrance);
648
+ if (this.data.showLoadingE && entrance !== 1) {
649
+ return;
650
+ }
651
+ this.loadingStatus(true);
652
+
653
+ // 批价
654
+ console.log('this.formData-----------: ', this.data.formData);
655
+ const params = this.assembleValuateParams();
656
+
657
+ if (isEmptyObject(params)) {
658
+ this.loadingStatus(false);
659
+ return;
660
+ }
661
+
662
+ // 商品参数校验
663
+ if (params?.goods_list){
664
+ let missingParameter = false;
665
+ params.goods_list.forEach(val=>{
666
+ if (!val.spu_id || !val.sku_id){
667
+ missingParameter = true
668
+ }
669
+ })
670
+ if (missingParameter) {
671
+ console.log('批价参数校验失败',params)
672
+ this.loadingStatus(false);
673
+ return;
674
+ }
675
+ }else{
676
+ this.loadingStatus(false);
677
+ return;
678
+ }
679
+
680
+ // 当是初始请求批价时,触发帮领取优惠券
681
+ if (entrance === 'initialize') {
682
+ try {
683
+ await this.autoReceiveCoupon()
684
+ }catch (e){
685
+ console.log('领取优惠券失败')
686
+ }
687
+ }
688
+
689
+ params.live_commerce = true
690
+
691
+ return valuate(params).then(async (val) => {
692
+ const { code, data, msg } = val.data;
693
+ this.setData({
694
+ valuateData: data,
695
+ is_show_freight_ins: data.shipment_info?.is_show_freight_ins
696
+ })
697
+ this.triggerEvent('onTipsInfoUpdate', {
698
+ // is_show_freight_ins: data.shipment_info?.is_show_freight_ins && data.price_info?.final_price !== 0,
699
+ is_show_freight_ins: false,
700
+ price_info: data.price_info
701
+ })
702
+ if (code !== 0) {
703
+ try {
704
+ sensorLog.sensors.track('view_page', {
705
+ page_id: 'e_alive#mini#order',
706
+ page_name: '确认订单页',
707
+ l_program: '鹅直播',
708
+ page_path: '鹅直播#小程序#直播间#确认订单页',
709
+ app_id: this.data.confirmOrderInfo?.goods_info?.app_id,
710
+ c_user_id: this.data.aliveInfo?.user_id,
711
+ cmm1: '批价接口报错',
712
+ cmm2: JSON.stringify(params),
713
+ cmm3: msg
714
+ })
715
+ } catch (error) {
716
+ console.log('上报失败', error);
717
+ }
718
+ }
719
+ }).catch((err) => {
720
+
721
+ }).finally(() => {
722
+ this.loadingStatus(false);
723
+ // 初次批价 & 开了信息采集 & 信息采集接口还没返回
724
+ if (this.data.waitInformation){
725
+ this.loadingStatus(true);
726
+ this.setData({
727
+ setTime: setTimeout(() => {
728
+ this.loadingStatus(false);
729
+ this.setData({
730
+ waitInformation: false
731
+ })
732
+ }, 2000)
733
+ })
734
+ }
735
+ })
736
+ },
737
+ // 自动领取优惠券
738
+ async autoReceiveCoupon() {
739
+ const { resource_id, resource_type, spu_id } = this.data.baseInfoQuery;
740
+ const { in_activity, is_super_vip } = this.data.marketInfo;
741
+ const { piece_price } = this.data.goodsInfo;
742
+
743
+ // 营销最低价
744
+ const marketingLowPrice = in_activity && this.marketingLowPrice;
745
+
746
+ // 超会和营销活动是否能叠加
747
+ const isSvipSupportMarketing = is_super_vip === 1;
748
+
749
+ const svipDiscount = this.data.superVipInfo?.svip_info?.svip_info?.discount / 10;
750
+
751
+ let isSvipCanUseCoupon = this.data.superVipInfo.svip_info?.svip_info?.is_coupons === 1;
752
+
753
+ // 原价
754
+ let minimumPrice = piece_price;
755
+ let minimumPriceType = MINMUM_PRICE_TYPE_MAP.NORMAL;
756
+
757
+ // 超级会员营销叠加价格
758
+ const marketingSvipPrice = this.data.isSvipUseful && isSvipSupportMarketing && marketingLowPrice * svipDiscount;
759
+
760
+ // 有超级会员价
761
+ const superVipPrice = this.data.svipPrice;
762
+ if (superVipPrice) {
763
+ if (
764
+ // 没有营销价或者营销价低于超级会员价
765
+ (!marketingLowPrice || marketingLowPrice && superVipPrice < marketingLowPrice) &&
766
+ this.data.userIsVip // 用户是超级会员
767
+ ) {
768
+ // 以超级会员价计算券后价
769
+ minimumPrice = superVipPrice;
770
+ minimumPriceType = MINMUM_PRICE_TYPE_MAP.SVIP;
771
+ }
772
+ }
773
+
774
+ // 当前仍是原价的情况下,有营销价,使用营销价计算券后价
775
+ if (minimumPriceType === MINMUM_PRICE_TYPE_MAP.NORMAL) {
776
+ if (marketingLowPrice) {
777
+ minimumPrice = marketingSvipPrice || marketingLowPrice;
778
+ minimumPriceType = MINMUM_PRICE_TYPE_MAP.MARKETING;
779
+ }
780
+ }
781
+
782
+ let params = {
783
+ resource_type,
784
+ resource_id: resource_id || spu_id,
785
+ minimum_price: minimumPrice,
786
+ minimum_price_type: minimumPriceType,
787
+ svip_coupon_over: this.data.isSvipUseful && isSvipCanUseCoupon,
788
+ spu_id: spu_id
789
+ }
790
+ if (this.data.sku_floor_price){
791
+ params.floor_price = this.data.sku_floor_price
792
+ }
793
+
794
+ await postCouponList(params).then((res) => {
795
+ wx.showToast({
796
+ title: "您已享有最佳优惠,下单更优惠",
797
+ icon: 'none',
798
+ duration: 2000
799
+ })
800
+ }).catch((err) => {
801
+ console.log("优惠券获取列表报错或者没有可领券", err)
802
+ })
803
+ },
804
+ // 封装批价入参
805
+ assembleValuateParams() {
806
+ // 每次批价时,都重置批价参数
807
+ let newValuateParams = new Parameter()
808
+
809
+ const { count, address, identityType } = this.data.formData;
810
+ const { spu_id: spuId, sku_id: skuId } = this.data.goodsInfo;
811
+ const { isFissionPoster, spu_type: spuType, renew } = this.data.baseInfoQuery;
812
+
813
+ const buyNum = count;
814
+ let goodsInfo = [];
815
+ let teamBuyInfo;
816
+ let identityInfo;
817
+
818
+ // 地址信息
819
+ const addressId = this.data.showAddressSelect ? address?.id : 0;
820
+
821
+ // 商品信息
822
+ let { activityId, activityType } = this.handleMarketInfo();
823
+
824
+ let activityInfo;
825
+ if (activityId) {
826
+ //非裂变海报进入的下单,不加活动参数
827
+ if (activityType === MARKETING_FISSION_POSTER && !isFissionPoster) {
828
+ activityInfo = null;
829
+ } else {
830
+ activityInfo = new ActivityInfo(activityId, activityType, teamBuyInfo);
831
+ }
832
+ }
833
+
834
+ goodsInfo = new GoodsList({ spuId, skuId, buyNum }, activityInfo).transformApiParams();
835
+
836
+ // 身份特权信息
837
+ const realIdentityType = identityType === IdentityType.FORBID_SVIP ? IdentityType.ANSWER : identityType
838
+ identityInfo = new IdentityInfo(realIdentityType).transformApiParams();
839
+
840
+ // 优惠券信息
841
+ const { isSelected, selectedCoupons } = this.data.formData.couponInfo;
842
+ const couponInfoData = new CouponInfo(isSelected, selectedCoupons).transformApiParams();
843
+
844
+ // 优惠码信息
845
+ const promoCode = this.data.formData.promoCodeInfo;
846
+ const promoCodeInfo = new PromoCodeInfo(promoCode).transformApiParams();
847
+
848
+ // 积分信息
849
+ const pointsExchange = this.data.baseInfoQuery.isIntegral;
850
+ const usePoints = this.data.formData.isUseIntegral;
851
+ const pointInfo = new PointInfo(pointsExchange, usePoints, 0, this.data.formData?.isInitPoint).transformApiParams();
852
+
853
+ // 会员等级
854
+ const isUseMemberLevel = this.data.formData?.isUseMemberLevel === undefined ? 1 : this.data.formData?.isUseMemberLevel;
855
+ const level_member_info = new LevelMemberInfo(isUseMemberLevel).transformApiParams();
856
+
857
+ // 是否为社群续费
858
+ const communityRenewal = spuType === ASSOCIATION && renew == '1';
859
+
860
+ // 将批价所有参数封装进一个对象中
861
+ addressId && newValuateParams.append('address_id', addressId);
862
+ newValuateParams
863
+ .append('identity_info', identityInfo)
864
+ .append('goods_list', goodsInfo)
865
+ .append('points_info', pointInfo)
866
+ .append('community_renewal', communityRenewal)
867
+ .append('coupon_info', couponInfoData)
868
+ .append('promo_code_info', promoCodeInfo)
869
+ .append('from_shopping_cart', false) // 直播不存在购物车 - 写死false
870
+ .append('is_gift', false) // 直播不存在赠送 - 写死false
871
+ .append('level_member_info', level_member_info);
872
+
873
+ this.setData({
874
+ valuateParams: newValuateParams
875
+ });
876
+
877
+ return this.data.valuateParams;
878
+ },
879
+ // 处理批价的 activity_type 和 activity_id
880
+ handleMarketInfo() {
881
+ let { activity_id: activityId, activity_type: activityType, event_has_stock, in_activity } = this.data.marketInfo || {};
882
+ let isShield = activityId ? SHIELD_ACTIVITY.some(item => activityId.includes(item)) : false;
883
+ if ((activityType === MARKETING_SEC_KILL && (event_has_stock === 0 || in_activity === 0)) || isShield) {
884
+ return {};
885
+ }
886
+ return {
887
+ activityId,
888
+ activityType
889
+ }
890
+ },
891
+ loadingStatus(val) {
892
+ if (val) {
893
+ wx.showLoading({
894
+ mask: true,
895
+ title: '加载中'
896
+ });
897
+ } else {
898
+ wx.hideLoading();
899
+ }
900
+ this.setData({
901
+ showLoadingE: val
902
+ });
903
+ },
904
+ // 初始化店铺设置信息
905
+ initShopConf() {
906
+ getShopConf().then(res => {
907
+ if (res.data.code === 0) {
908
+ this.setData({
909
+ shopConf: res.data.data
910
+ })
911
+ }
912
+ })
913
+ },
914
+ // 做防抖处理,避免短时间触发多次批价
915
+ getPrePayInfo: debounce(function (payload) {
916
+ // console.log("val: ", val);
917
+ // let payload = val[0]
918
+ if (!payload["resource_id"]) {
919
+ payload = {
920
+ ...payload,
921
+ resource_id: this.data.resource_id,
922
+ };
923
+ }
924
+ this.setData({
925
+ prePayParams: payload
926
+ })
927
+ wx.showLoading({
928
+ mask: true,
929
+ title: '加载中'
930
+ })
931
+ return getPrePayInfoV3(payload).then(res => {
932
+ wx.hideLoading()
933
+ if (res.data.code === 0) {
934
+ this.setData({
935
+ prePayInfo: res.data.data
936
+ })
937
+ } else {
938
+ this.handlePreErrorCode(res.data);
939
+ }
940
+ if (wx.getStorageSync('toastWarn')) {
941
+ wx.showToast({
942
+ title: "单笔订单最多可购买1000件",
943
+ icon: 'none',
944
+ duration: 2000
945
+ })
946
+ setTimeout(() => {
947
+ wx.removeStorage({
948
+ key: "toastWarn"
949
+ })
950
+ }, 3000)
951
+ }
952
+ if (res.data.code === 10310 || res.data.code === 10309) {
953
+ this.setData({
954
+ ["checkList.order"]: "商家努力补货中"
955
+ })
956
+ } else {
957
+ this.setData({
958
+ ["checkList.order"]: ""
959
+ })
960
+ }
961
+ }).catch((err) => console.log(err))
962
+ }, 1000),
963
+ handlePreErrorCode(res) {
964
+ if (res.code !== 20077) {
965
+ this.handleErrorCode(res);
966
+ }
967
+ },
968
+ handleErrorCode(res) {
969
+ // 重复支付错误code特殊逻辑,不做toast处理,弹窗处理
970
+ if (res.code === 20022) {
971
+ return;
972
+ }
973
+
974
+ if (res.code === 10061001) {
975
+ wx.showToast({
976
+ title: "订单信息有变化, 请刷新后重试",
977
+ icon: 'none',
978
+ duration: 2000
979
+ })
980
+ setTimeout(() => {
981
+ this.onLoad()
982
+ }, 1000);
983
+ return;
984
+ }
985
+ wx.showToast({
986
+ title: this.data.errMsg[res.code] || res.msg,
987
+ icon: 'none',
988
+ duration: 2000
989
+ })
990
+ },
991
+ /**
992
+ * @description: 支付参数改变事件,用于约束各业务测支付参数传参
993
+ * @param {string} data.name 业务侧名称,用于区分各业务侧参数
994
+ * @param {string} data.errMsg [同步校验]业务侧参数提示信息,用于支付前判断,目前主要用于判空提示(若为disabled标明只禁止提交,不弹提示。如信息采集,必须等信息采集加载完才能进行提交)
995
+ * @param {promise} data.beforePay [异步校验]业务侧用于进行支付前校验的校验方法, 这里为一个function,并返回一个Promise,resolve返回校验成功true或者校验失败false
996
+ * @param {object} data.prePayParams 业务侧涉及的批价参数,当有此参数时,会触发重新批价
997
+ * @param {object} data.payParams 业务侧涉及的支付参数,用于支付时传参
998
+ * @param {object} data.afterPay 业务侧支付后使用的一些参数 callBack: 支付完成后回调,支付完成后就只执行此回调方法,回调可返回支付完成后的跳转页面;
999
+ * srcUrl:支付失败跳转页面;backUrl: 支付成功跳转页面
1000
+ * @param {Boolean} data.triggerPrePay 本次修改是否触发批价
1001
+ */
1002
+ payInfoChange(val) {
1003
+ // console.log('val: ', val);
1004
+ // let data = {};
1005
+ // val.detail ? data = val.detail : data = val
1006
+ // this.setData({
1007
+ // [`checkList.${data.name}`]: data.errMsg || ""
1008
+ // })
1009
+ // if (data.beforePay) {
1010
+ // this.setData({
1011
+ // [`beforePay.${data.name}`]: data.beforePay
1012
+ // })
1013
+ // }
1014
+ // if (data.afterPay) {
1015
+ // let {
1016
+ // callBack,
1017
+ // ...others
1018
+ // } = data.afterPay;
1019
+ // this.setData({
1020
+ // afterPay: {
1021
+ // ...this.data.afterPay,
1022
+ // ...others,
1023
+ // }
1024
+ // })
1025
+ // if (callBack) {
1026
+ // this.setData({
1027
+ // [`afterPayCallback.${data.name}`]: callBack
1028
+ // })
1029
+ // }
1030
+ // }
1031
+ // // 支付参数处理
1032
+ // if (data.payParams) {
1033
+ // this.setData({
1034
+ // payParams: {
1035
+ // ...this.data.payParams,
1036
+ // ...data.payParams,
1037
+ // }
1038
+ // })
1039
+ // }
1040
+ // if (data.prePayParams) {
1041
+ // // 更新业务批价参数
1042
+ // this.setData({
1043
+ // prePayParams: {
1044
+ // ...this.data.prePayParams,
1045
+ // ...data.prePayParams,
1046
+ // }
1047
+ // })
1048
+ // if (this.data.prePayParamsInfoLoaded && data.triggerPrePay !== false) {
1049
+ // let obj = {
1050
+ // ...this.data.commonPrePayParams,
1051
+ // ...this.data.prePayParams,
1052
+ // }
1053
+ // this.setData({
1054
+ // getPrePayInfoReset: this.getPrePayInfo(obj)
1055
+ // })
1056
+ // }
1057
+ // }
1058
+ },
1059
+ // 留言变更
1060
+ handleLeaveWordChange(val) {
1061
+ this.setData({
1062
+ 'formData.userRemark': val.detail,
1063
+ })
1064
+ },
1065
+ // 发票变更
1066
+ handleInvoiceChange(val) {
1067
+ this.setData({
1068
+ 'formData.invoiceInfo': {
1069
+ ...this.data.formData.invoiceInfo,
1070
+ ...val.detail
1071
+ },
1072
+ })
1073
+ },
1074
+ // 返回箭头点击事件
1075
+ backClick() {
1076
+ switch (this.data.backType) {
1077
+ case 1:
1078
+ this.triggerEvent("changeSheetInfo", {
1079
+ title: "确认订单",
1080
+ showClose: true,
1081
+ showBack: false,
1082
+ })
1083
+ this.setData({
1084
+ isShowPoint: false,
1085
+ backType: 0
1086
+ })
1087
+ break;
1088
+ case 2:
1089
+ this.triggerEvent("changeSheetInfo", {
1090
+ title: "确认订单",
1091
+ showClose: true,
1092
+ showBack: false,
1093
+ })
1094
+ this.setData({
1095
+ isShowSelectShipper: false,
1096
+ backType: 0
1097
+ })
1098
+ break;
1099
+ case 3:
1100
+ if (this.data.backPage === 1) {
1101
+ this.triggerEvent("changeSheetInfo", {
1102
+ title: "确认订单",
1103
+ showBack: false,
1104
+ });
1105
+ } else {
1106
+ this.setData({
1107
+ isShowSelectShipper: true,
1108
+ })
1109
+ this.triggerEvent("changeSheetInfo", {
1110
+ title: "选择提货人",
1111
+ showBack: true,
1112
+ });
1113
+ }
1114
+ this.triggerEvent("changeSheetInfo", {
1115
+ showClose: true,
1116
+ });
1117
+ this.setData({
1118
+ isShowCreateShipper: false,
1119
+ backType: 0
1120
+ })
1121
+ break;
1122
+ case 4:
1123
+ this.setData({
1124
+ isShowAddressManage: false,
1125
+ backType: 0
1126
+ })
1127
+ this.triggerEvent("changeSheetInfo", {
1128
+ title: "确认订单",
1129
+ showClose: true,
1130
+ showBack: false,
1131
+ })
1132
+ break;
1133
+ case 5:
1134
+ this.setData({
1135
+ isShowEditAddress: false,
1136
+ backType: 0
1137
+ })
1138
+ this.triggerEvent("changeSheetInfo", {
1139
+ title: "确认订单",
1140
+ showClose: true,
1141
+ showBack: false,
1142
+ })
1143
+ break;
1144
+ }
1145
+ },
1146
+ // 供子组件修改父组件值
1147
+ updataData(e) {
1148
+ this.setData({
1149
+ ...e.detail
1150
+ })
1151
+ },
1152
+ // 初始化数据,请求相应接口
1153
+ async initData() {
1154
+ this.fetchCollectInfo();
1155
+ this.initShopConf();
1156
+ this.initDeliveryState();
1157
+ this.initPickerInfo();
1158
+ this.initBusinessFeatureConf();
1159
+ },
1160
+ fetchCollectInfo() {
1161
+ const { resource_type, resource_id } = this.data.baseInfoQuery;
1162
+ const appid = this.data.confirmOrderInfo?.goods_info?.app_id;
1163
+ const params = {
1164
+ resource_type,
1165
+ resource_id,
1166
+ scenes: 'buy_page',
1167
+ app_id: appid,
1168
+ user_id: this.data.aliveInfo?.user_id
1169
+ }
1170
+ fetchCollectInfo(params).then(res => {
1171
+ if (res.data.code === 0) {
1172
+ this.setData({
1173
+ assertNeedCollectInfo: res.data.data
1174
+ })
1175
+ }
1176
+ })
1177
+ },
1178
+ // 获取营销活动信息
1179
+ initMarketingData() {
1180
+ wx.showLoading({
1181
+ mask: true,
1182
+ title: '加载中'
1183
+ })
1184
+ let params = {
1185
+ spu_id: this.data.baseInfoQuery.id,
1186
+ spu_type: this.data.baseInfoQuery.spu_type,
1187
+ resource_type: this.data.baseInfoQuery.resource_type,
1188
+ }
1189
+ return getMarketingInfo(params).then(val => {
1190
+ let res = val.data;
1191
+ if (res.code === 0) {
1192
+ let marketing_info = res.data.marketing_info;
1193
+ if (
1194
+ marketing_info?.activity_type === 3 &&
1195
+ !(
1196
+ (marketing_info?.all_stock > 0 &&
1197
+ marketing_info?.now_stock > 0) ||
1198
+ marketing_info?.all_stock == 0
1199
+ ) &&
1200
+ ![21, 29, 41, 42].includes(marketing_info.resource_type)
1201
+ ) {
1202
+ // 这里的逻辑要注意,如果接口返回了营销信息但工程拿不到的话,问题就在这里。
1203
+ // 如果是限时折扣,且达到了限量后,就应该不显示限时折扣的信息了,我选择在源头就断了这个数据,但保留了推广员的信息
1204
+ // 且这里不能是多规格的商品,因为多规格的商品没有限量的设置,如果你看到的时候已经准备有了,麻烦跟产品说这需求咱不接,咱不受这鸟气
1205
+ res.data.marketing_info = null;
1206
+ }
1207
+ this.setData({
1208
+ marketingData: res.data
1209
+ })
1210
+ } else {
1211
+ this.setData({
1212
+ marketingDataLoaded: true
1213
+ })
1214
+ }
1215
+ }).catch((err) => console.log(err))
1216
+ .finally(() => {
1217
+ // // wx.hideLoading()
1218
+ })
1219
+ },
1220
+ // 业务特性信息
1221
+ initBusinessFeatureConf() {
1222
+ wx.showLoading({
1223
+ mask: true,
1224
+ title: '加载中'
1225
+ })
1226
+ let params = {
1227
+ spu_id: this.data.baseInfoQuery.id
1228
+ }
1229
+ getBusinessFeature(params).then(res => {
1230
+ if (res.data.code === 0) {
1231
+ this.setData({
1232
+ businessConf: res.data.data
1233
+ })
1234
+ }
1235
+ }).catch((err) => console.log(err))
1236
+ .finally(() => {
1237
+ // wx.hideLoading()
1238
+ })
1239
+ },
1240
+ // 获取超级会员相关信息
1241
+ initSuperVipInfo() {
1242
+ wx.showLoading({
1243
+ mask: true,
1244
+ title: '加载中'
1245
+ })
1246
+ let params = {
1247
+ resource_id: this.data.baseInfoQuery.resource_id || this.data.resource_id,
1248
+ resource_type: this.data.baseInfoQuery.resource_type,
1249
+ };
1250
+ return getSuperVipInfo(params).then(res => {
1251
+ if (res.data.code === 0) {
1252
+ this.setData({
1253
+ superVipInfo: res.data.data,
1254
+ userIsVip: res.data.data?.svip_info?.user_svip_info?.state === 1
1255
+ })
1256
+ }
1257
+ }).catch((err) => console.log(err))
1258
+ .finally(() => {
1259
+ // wx.hideLoading()
1260
+ })
1261
+ },
1262
+ // 商品的套餐信息
1263
+ initGoodsPackage() {
1264
+ wx.showLoading({
1265
+ mask: true,
1266
+ title: '加载中'
1267
+ })
1268
+ let params = {
1269
+ spu_id: this.data.baseInfoQuery.spu_id,
1270
+ }
1271
+ return getGoodsPackage(params).then(res => {
1272
+ let {
1273
+ code,
1274
+ data: goodsPackage
1275
+ } = res.data
1276
+ if (code === 0) {
1277
+ this.setData({
1278
+ goodsPackage,
1279
+ hasEntityGoods: goodsPackage.entity_goods_num > 0 ? true : false
1280
+ })
1281
+ if (this.data.baseInfoQuery.spu_type != "ENT" && goodsPackage.has_package) {
1282
+ this.setData({
1283
+ distributionMode: goodsPackage.package_delivery
1284
+ })
1285
+ }
1286
+ }
1287
+ }).catch((err) => console.log(err))
1288
+ .finally(() => {
1289
+ // wx.hideLoading()
1290
+ })
1291
+ },
1292
+ // 进入页面 初始化自提人信息
1293
+ initPickerInfo() {
1294
+ wx.showLoading({
1295
+ mask: true,
1296
+ title: '加载中'
1297
+ })
1298
+ let {
1299
+ id,
1300
+ spu_type,
1301
+ } = this.data.baseInfoQuery
1302
+ getPickerInfo({
1303
+ bizData: {
1304
+ spu_id: id,
1305
+ spu_type
1306
+ }
1307
+ }).then(res => {
1308
+ const { code, data } = res.data;
1309
+ if (code === 0) {
1310
+ this.setData({
1311
+ 'formData.pickInfo.picker': data,
1312
+ 'formData.pickInfo.site': data?.lastSelfPickInfo?.place_name ? data.lastSelfPickInfo : this.data.picksiteInfo,
1313
+ picksiteInfo: data.lastSelfPickInfo.place_name ? data.lastSelfPickInfo : {},
1314
+ pickerUserInfo: data || {}
1315
+ });
1316
+ }
1317
+ }).catch((err) => console.log(err))
1318
+ .finally(() => {
1319
+ this.loadingStatus(false);
1320
+ })
1321
+ },
1322
+ async handleInfo() {
1323
+ let result = await this.initConfirmOrderInfo();
1324
+ this.handleOrderInfo(result);
1325
+ this.loadingStatus(false);
1326
+ this.doValuate('changeAddress');
1327
+ },
1328
+ // 初始化订单页基本信息
1329
+ initConfirmOrderInfo() {
1330
+ let {
1331
+ id,
1332
+ resource_type,
1333
+ spu_type,
1334
+ sku
1335
+ } = this.data.baseInfoQuery
1336
+ let params = {
1337
+ spu_id: id,
1338
+ resource_type,
1339
+ spu_type,
1340
+ address_id: this.data.addressInfo.id || "",
1341
+ sku_id: sku || "",
1342
+ }
1343
+ return getConfirmOrderDetail(params)
1344
+ },
1345
+ // 处理初始化订单页基本信息
1346
+ handleOrderInfo(val) {
1347
+ let res = val.data
1348
+ if (res.code === 0) {
1349
+ this.setData({
1350
+ confirmOrderInfo: res.data,
1351
+ resource_id: res.data.goods_info.resource_id,
1352
+ })
1353
+ if (this.data.baseInfoQuery.spu_type === "ENT") {
1354
+ this.setData({
1355
+ distributionMode: res.data.goods_info.distribution_pattern
1356
+ })
1357
+
1358
+ if (res.data.goods_info.distribution_pattern === 2) {
1359
+ this.setData({
1360
+ activeMode: 2
1361
+ })
1362
+ }
1363
+ }
1364
+ if(this.data.baseInfoQuery.spu_type == "COP"){
1365
+ this.setData({
1366
+ distributionMode: res.data.goods_info.sku_info.distribution_pattern
1367
+ })
1368
+ if (res.data.goods_info.sku_info.distribution_pattern === 2) {
1369
+ this.setData({
1370
+ activeMode: 2
1371
+ })
1372
+ }
1373
+ }
1374
+ if (this.data.showAddressSelect) {
1375
+ this.initAddressErro();
1376
+ }
1377
+ if (res.data.goods_info.sku_info?.sku_floor_price){
1378
+ this.setData({
1379
+ sku_floor_price: res.data.goods_info.sku_info?.sku_floor_price
1380
+ })
1381
+ }
1382
+ }
1383
+ },
1384
+ initAddressErro() {
1385
+ let address_info = this.data.confirmOrderInfo.address_info || {};
1386
+ // 兼容老数据,手机号+区号后格式有误提示用户需要修改
1387
+ if (address_info?.currentArea) {
1388
+ const patt = /^[1][3-9][\d]{9}/.test(address_info.phone);
1389
+ if ((address_info.currentArea.nation_code === '' || address_info.currentArea.nation_code === '86') && (address_info.phone.length != 11 || !patt)) {
1390
+ address_info = {
1391
+ ...address_info,
1392
+ calculate_freight: false,
1393
+ calculate_freight_text: '手机号码格式有误,请重新输入'
1394
+ }
1395
+ }
1396
+ }
1397
+ let addressInfo = Array.isArray(address_info) || !address_info ? {} : address_info;
1398
+ this.setData({
1399
+ addressInfo: addressInfo,
1400
+ formData: {
1401
+ ...this.data.formData,
1402
+ address: addressInfo
1403
+ }
1404
+ })
1405
+ },
1406
+ // 获取商家自提状态
1407
+ initDeliveryState() {
1408
+ wx.showLoading({
1409
+ mask: true,
1410
+ title: '加载中'
1411
+ })
1412
+ const params = {
1413
+ spu_id: this.data.baseInfoQuery.id
1414
+ }
1415
+ getExpressSwitch(params).then(res => {
1416
+ if (res.data.code === 0) {
1417
+ this.setData({
1418
+ userCanPick: res.data.data.self_service_switch,
1419
+ isHideSelfPickerInfo: res.data.data.is_hide_self_picker_info
1420
+ })
1421
+ }
1422
+ })
1423
+ .catch((err) => console.log(err))
1424
+ .finally(() => {
1425
+ // wx.hideLoading()
1426
+ })
1427
+ },
1428
+ // 切换配送模式
1429
+ changeMode(e) {
1430
+ let val = e.detail;
1431
+ let num = 0;
1432
+ val ? num = 2 : num = 1;
1433
+ this.setData({
1434
+ activeMode: val,
1435
+ express_type: num
1436
+ })
1437
+ const { address } = this.data.formData;
1438
+ if (this.shouldValuateOnDeliveryChange(val, address)) {
1439
+ this.doValuate('changeMode');
1440
+ }
1441
+ },
1442
+ // 支付成功
1443
+ successCallback(payResult) {
1444
+ console.log("支付成功2");
1445
+ this.triggerEvent("successCallback", payResult.detail);
1446
+ },
1447
+ // 支付失败
1448
+ failCallback() {
1449
+ console.log("支付失败2");
1450
+ this.triggerEvent("failCallback");
1451
+ },
1452
+ onCountChange(val) {
1453
+ const {count, isInit} = val.detail;
1454
+ if (this.data.formData.count !== count) {
1455
+ this.setData({
1456
+ formData: {
1457
+ ...this.data.formData,
1458
+ count
1459
+ },
1460
+ })
1461
+ if (!isInit) {
1462
+ this.doValuate('changeCount');
1463
+ }
1464
+ }
1465
+ },
1466
+ // 选择优惠券/优惠码
1467
+ handleCouponChange(val) {
1468
+ const { coupons, promoCode } = val.detail;
1469
+ this.setData({
1470
+ 'formData.couponInfo': {
1471
+ isSelected: true,
1472
+ selectedCoupons: coupons
1473
+ },
1474
+ 'formData.promoCodeInfo': promoCode
1475
+ })
1476
+ this.doValuate('selectCoupon');
1477
+ },
1478
+ // 信息采集保存后回调
1479
+ handleInfoCollectionChange(val) {
1480
+ this.setData({
1481
+ 'formData.infoCollectionInfo': val.detail
1482
+ })
1483
+ },
1484
+ // 下单前校验
1485
+ validateForm() {
1486
+ const { address, pickInfo, infoCollectionInfo } = this.data.formData;
1487
+
1488
+ // 地址校验
1489
+ if (this.data.showAddressSelect) {
1490
+ if (isEmptyObject(address)) {
1491
+ wx.showToast({
1492
+ title: '请添加收货地址',
1493
+ icon: 'none',
1494
+ duration: 2000
1495
+ })
1496
+ return Promise.reject(false);
1497
+ }
1498
+ }
1499
+ // 自提校验
1500
+ if(this.data.showPickSelf) {
1501
+ if (isEmptyObject(pickInfo?.site)) {
1502
+ wx.showToast({
1503
+ title: '请选择自提点',
1504
+ icon: 'none',
1505
+ duration: 2000
1506
+ })
1507
+ return Promise.reject(false);
1508
+ }
1509
+ // 提货人白名单
1510
+ if (PICKER_WHITE_LIST.includes(this.data.confirmOrderInfo?.goods_info?.app_id)) {
1511
+ return Promise.resolve(true);
1512
+ }
1513
+ if (this.data.isHideSelfPickerInfo === 0 && (isEmptyObject(pickInfo?.picker) || pickInfo?.picker?.id === 0)) {
1514
+ wx.showToast({
1515
+ title: '请填写提货人',
1516
+ icon: 'none',
1517
+ duration: 2000
1518
+ })
1519
+ return Promise.reject(false);
1520
+ }
1521
+ }
1522
+ // 信息采集校验
1523
+ if (!infoCollectionInfo) {
1524
+ return this.selectComponent('#InfoCollect')?.show();
1525
+ }
1526
+
1527
+ return Promise.resolve(true);
1528
+ },
1529
+ // 提交订单
1530
+ async submitOrder() {
1531
+ // 如果没有批价成功,则先批价再下单
1532
+ if (isEmptyObject(this.data.valuateData)) {
1533
+ const isSucceed = await this.doValuate('createOrder');
1534
+ if (!isSucceed) return;
1535
+ }
1536
+
1537
+ // 校验表单参数
1538
+ const valid = await this.validateForm();
1539
+ if (!valid) return;
1540
+
1541
+ try {
1542
+ const { is_gray, need_collect } = this.data.assertNeedCollectInfo || {};
1543
+ if (need_collect && this.data.infoIsLoadSuc && this.data.needCollect) {
1544
+ //在白名单内,js还未加载完,必须等待信息采集加载完才给下单
1545
+ if(isEmptyObject(this.data.formData.infoCollectionInfo)){
1546
+ wx.showToast({
1547
+ title: '下单失败,未填写信息采集,请重新提交订单',
1548
+ icon: 'none',
1549
+ duration: 2000
1550
+ })
1551
+ return;
1552
+ }
1553
+ }
1554
+ } catch (error) {
1555
+ console.log(err)
1556
+ }
1557
+
1558
+ // 组装下单参数
1559
+ const orderParams = this.assembleCreateOrderParams();
1560
+ if (isEmptyObject(orderParams)) {
1561
+ return;
1562
+ }
1563
+
1564
+ console.log('orderParams: ', orderParams);
1565
+ await this.createOrderFun(orderParams);
1566
+ },
1567
+ // 下单
1568
+ createOrderFun(orderParams) {
1569
+ wx.showLoading({
1570
+ mask: true,
1571
+ title: '努力抢购中'
1572
+ });
1573
+ const { spu_type, spu_id, resource_id, sku: sku_id } = this.data.baseInfoQuery
1574
+
1575
+ return createOrderInLive(orderParams).then(async (res) => {
1576
+ const { data, code, msg } = res.data;
1577
+ wx.hideLoading();
1578
+ switch(code) {
1579
+ case 0:
1580
+ this.setData({
1581
+ payResult: data
1582
+ });
1583
+ let params = {
1584
+ isAlive: 1,
1585
+ cart: 0,
1586
+ spu_type,
1587
+ spu_id,
1588
+ resource_id,
1589
+ sku_id,
1590
+ order_id: data?.order_id
1591
+ };
1592
+ this.setData({
1593
+ successCallbackParams: params
1594
+ })
1595
+ // 零元单
1596
+ if (data.order_pay_status === ORDER_PAY_STATUS.PAID) {
1597
+ this.triggerEvent("successCallback", params);
1598
+ } else {
1599
+ // TODO 后续排期 - 鹅直播支持再次支付后放开接口 - 用于查询营销信息展示挽留弹窗
1600
+ // this.queryOrderInfo(data?.order_id);
1601
+ this.miniProPay(data?.pay_config?.wx_pay_config,data?.order_id);
1602
+ }
1603
+ break;
1604
+ case 10086:
1605
+ wx.showToast({
1606
+ title: "当前下单人数过多,请稍后重试",
1607
+ icon: 'none',
1608
+ duration: 2000
1609
+ });
1610
+ break;
1611
+ case 10060297306:
1612
+ case 10060297310:
1613
+ wx.showToast({
1614
+ title: '商品已删除',
1615
+ icon: 'none',
1616
+ duration: 2000,
1617
+ complete: () => {
1618
+ this.triggerEvent("failCallback");
1619
+ }
1620
+ });
1621
+ break;
1622
+ // case 10060297401:
1623
+ // wx.showToast({
1624
+ // title: '配送方式已改变,请重新选择',
1625
+ // icon: 'none',
1626
+ // duration: 2000,
1627
+ // complete: () => {
1628
+ // this.triggerEvent("failCallback");
1629
+ // }
1630
+ // });
1631
+ // break;
1632
+ case 10060297208:
1633
+ wx.showToast({
1634
+ title: '自提信息已更新,请重新选择',
1635
+ icon: 'none',
1636
+ duration: 2000,
1637
+ complete: () => {
1638
+ this.triggerEvent("failCallback");
1639
+ }
1640
+ });
1641
+ break;
1642
+ default:
1643
+ wx.showToast({
1644
+ title: msg || '下单接口返回异常,请稍后重试',
1645
+ icon: 'none',
1646
+ duration: 2000
1647
+ });
1648
+ }
1649
+ if (code !== 0) {
1650
+ try {
1651
+ sensorLog.sensors.track('view_page', {
1652
+ page_id: 'e_alive#mini#order',
1653
+ page_name: '确认订单页',
1654
+ l_program: '鹅直播',
1655
+ page_path: '鹅直播#小程序#直播间#确认订单页',
1656
+ app_id: this.data.confirmOrderInfo?.goods_info?.app_id,
1657
+ c_user_id: this.data.aliveInfo?.user_id,
1658
+ cmm1: '下单接口报错',
1659
+ cmm2: JSON.stringify(orderParams),
1660
+ cmm3: msg
1661
+ })
1662
+ } catch (error) {
1663
+ console.log('上报失败', error);
1664
+ }
1665
+ }
1666
+ }).catch(err => {
1667
+ wx.hideLoading();
1668
+ });
1669
+ },
1670
+ assembleCreateOrderParams() {
1671
+ const { isIntegral: pointsExchange, shareType, shareUserId, commonAuthCode, step: teamNum, isTeam, isJoin, aliveId, communityIdWindow, communityApplyId, adType, xiaoeCampBusinessAppId, channelId } = this.data.baseInfoQuery;
1672
+ // 取至 formData
1673
+ const { isSelected, pickInfo, invoiceInfo, infoCollectionInfo, eduInfo, userRemark, activityApplyInfo, promoCodeInfo: promoCode, address, isUseMemberLevel: useMemberLevel } = this.data.formData;
1674
+ // 取至批价返回数据
1675
+ const { token, identity_info, coupon_info, points_info, goods_list, promo_code_info } = this.data.valuateData;
1676
+ const { address_id } = this.data.valuateParams;
1677
+
1678
+ const addressId = this.data.activeMode === DELIVERY_MODE.EXPRESSAGE ? (address_id || address?.id || 0) : 0;
1679
+ const siteId = pickInfo?.site?.place_id || 0;
1680
+ const pickerId = !this.data.showPicker ? 0 : (pickInfo?.picker?.id || 0);
1681
+ const place_type = pickInfo?.site?.place_type || 0;
1682
+ const extendObjectInfo = {
1683
+ activity_manager: activityApplyInfo,
1684
+ student_info: eduInfo,
1685
+ info_collect_object_info: infoCollectionInfo,
1686
+ training_camp: {
1687
+ xiaoe_camp_business_app_id: xiaoeCampBusinessAppId || ''
1688
+ }
1689
+ };
1690
+
1691
+ const miscParameter = new MiscParameter(false, shareType, shareUserId, commonAuthCode);
1692
+ // 商品信息
1693
+ let orderGoodsList = new GoodsOrderList(goods_list, isTeam, teamNum, isJoin).transformApiParams();
1694
+ // 身份信息
1695
+ const identityType = identity_info?.identity_type;
1696
+ const realIdentityType = identityType === IdentityType.FORBID_SVIP ? IdentityType.NONUSE : identityType;
1697
+ const identityInfo = new IdentityInfo(realIdentityType).transformApiParams();
1698
+ // 优惠券
1699
+ const couponInfo = new CouponInfo(isSelected, coupon_info?.selected_coupons?.list).transformOrderParams();
1700
+ // 优惠码
1701
+ // 兼容优惠码不可用,url上带了优惠码
1702
+ // 通过批价接口处理优惠码,如果优惠码不可用,promo_code_info.can_use_promo_code字段为false
1703
+ let promoCodeInfo = new PromoCodeInfo(promoCode).transformApiParams();
1704
+ if (promo_code_info?.can_use_promo_code === false) {
1705
+ promoCodeInfo.promo_code = '';
1706
+ }
1707
+ // 积分信息
1708
+ const { is_use_integral, used_point } = points_info;
1709
+ const pointInfo = new PointInfo(!!pointsExchange, !!is_use_integral, used_point || 0).transformCreateOrderParams();
1710
+ // 地址、自提相关信息
1711
+ const deliveryInfo = new DeliveryInfo(this.data.activeMode === 0 ? 1 : 2, addressId, pickerId, siteId, place_type).transformApiParams();
1712
+ // 渠道来源
1713
+ const { channelType, channelBusId } = resolveChannelInfo(aliveId, adType, communityIdWindow, communityApplyId, channelId);
1714
+ // 会员等级
1715
+ const isUseMemberLevel = useMemberLevel === undefined ? 1 : useMemberLevel;
1716
+ const level_member_info = new LevelMemberInfo(isUseMemberLevel).transformApiParams()
1717
+ // 订单类型 普通订单-1,积分兑换-4
1718
+ const tradeType = this.isIntegral ? 4 : 1;
1719
+
1720
+ return new Parameter(miscParameter.transformApiParams()) //路由上的一些参数
1721
+ .append('token', token) // 批价token
1722
+ .append('goods_list', orderGoodsList) // 商品信息
1723
+ .append('identity_info', identityInfo) //身份信息
1724
+ .append('promo_code_info', promoCodeInfo) //优惠码
1725
+ .append('coupon_info', couponInfo) //优惠券
1726
+ .append('points_info', pointInfo) //积分信息
1727
+ .append('invoice_info', invoiceInfo) //发票信息
1728
+ .append('delivery_object_info', deliveryInfo) // 地址、字提人信息
1729
+ .append('extend_object_info', extendObjectInfo) //活动管理的学生信息 线下课学生信息 小鹅通训练营订购商家APPID
1730
+ .append('user_remark', userRemark) // 留言
1731
+ .append('channel_bus_id', channelBusId) // 渠道id
1732
+ .append('channel_type', channelType) //渠道类型
1733
+ .append('from_shopping_cart', false) //是否是购物车
1734
+ .append('merchant_url_id', '') // 页面统计id
1735
+ .append('trade_type', tradeType) // 订单类型
1736
+ .append('level_member_info', level_member_info) //等级会员
1737
+ .append('user_agente_env_type', 'MiniProgram || XiaoEEliveMP') // 鹅直播终端标识
1738
+ .append('pay_way', 6); // 微信支付
1739
+ },
1740
+ miniProPay(payConfig, orderId) {
1741
+ let that = this;
1742
+ const { timeStamp, nonceStr, package: packages, signType, paySign } = payConfig || {};
1743
+ const { trade_id, order_id } = that.data.payResult || {};
1744
+ wx.requestPayment({
1745
+ timeStamp,
1746
+ nonceStr,
1747
+ package: packages,
1748
+ signType,
1749
+ paySign,
1750
+ success (res) {},
1751
+ fail (res) {
1752
+ console.log('cancel pay')
1753
+ // https://appweqixw3x3114.h5.xiaoeknow.com/p/t/v1/ecommerce/h5_order/order/order_list?order_state=1
1754
+ let copyUrl = `https://${that.data.confirmOrderInfo?.goods_info?.app_id}.h5.xiaoeknow.com/p/t/v1/ecommerce/h5_order/order/order_details?order_id=${orderId}`
1755
+ that.triggerEvent("cancelPay",copyUrl);
1756
+ },
1757
+ complete(res){
1758
+ const params = {
1759
+ app_id: that.data.confirmOrderInfo?.goods_info?.app_id,
1760
+ trade_id,
1761
+ order_id,
1762
+ };
1763
+ queryOrder(params).then(res => {
1764
+ console.log('查询订单', res);
1765
+ const { data, code } = res.data;
1766
+ const payOrderState = data.info.pay_state;
1767
+ if (payOrderState === "SUCCESS") {
1768
+ that.triggerEvent("successCallback", that.data.successCallbackParams);
1769
+ } else {
1770
+ that.triggerEvent("failCallback");
1771
+ }
1772
+ }).catch(err => {
1773
+ console.log('查询订单失败', err);
1774
+ wx.showToast({
1775
+ title: "您的订单未完成支付,请重新支付",
1776
+ icon: 'none',
1777
+ duration: 2000
1778
+ });
1779
+ that.triggerEvent("failCallback");
1780
+ })
1781
+ }
1782
+ })
1783
+ },
1784
+ queryOrderInfo(orderId){
1785
+ queryOrderInfo({order_id: orderId}).then(({data}) => {
1786
+ if(data && data.code === 0){
1787
+ let items = data.data.items
1788
+ let discount_list = []
1789
+ if(items && items.length > 0){
1790
+ items.forEach(item => {
1791
+ if(DISCOUNT_SHOW_TYPE.includes(item.discount_sub_type)){
1792
+ discount_list.push(DISCOUNT_SHOW_TYPE_MAP[item.discount_sub_type])
1793
+ }
1794
+ })
1795
+ // 使用 Set 去重
1796
+ discount_list = [...new Set(discount_list)]
1797
+ }
1798
+ this.triggerEvent('discountInfo', {
1799
+ discount_list,
1800
+ cancelTime: data.data.cancel_time,
1801
+ orderId,
1802
+ priceInfo: this.data.valuateData.price_info
1803
+ })
1804
+ }
1805
+ }).catch(err => {
1806
+ console.log('查询订单失败', err);
1807
+ })
1808
+ },
1809
+ handleShowFreightIns(){
1810
+ this.setData({
1811
+ showFreightIns: true
1812
+ })
1813
+ },
1814
+ handleCloseFreightIns(){
1815
+ this.setData({
1816
+ showFreightIns: false
1817
+ })
1818
+ }
1819
+ }
1820
1820
  })