xiaoe_mp_npm 1.0.6 → 1.0.7-alpha2

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 (271) hide show
  1. package/.gitlab-ci.yml +44 -44
  2. package/miniprogram_dist/ConfirmOrder/components/AddressSelect/index.js +160 -160
  3. package/miniprogram_dist/ConfirmOrder/components/ChoosePicker/index.js +115 -115
  4. package/miniprogram_dist/ConfirmOrder/components/ConfirmOrderContent/index.js +890 -890
  5. package/miniprogram_dist/ConfirmOrder/components/ConfirmOrderContent/index.json +23 -23
  6. package/miniprogram_dist/ConfirmOrder/components/ConfirmOrderContent/index.scss +44 -44
  7. package/miniprogram_dist/ConfirmOrder/components/ConfirmOrderContent/index.wxml +188 -188
  8. package/miniprogram_dist/ConfirmOrder/components/GoodsInfo/components/CopGoodsList/index.js +129 -129
  9. package/miniprogram_dist/ConfirmOrder/components/GoodsInfo/components/CopGoodsList/index.json +8 -8
  10. package/miniprogram_dist/ConfirmOrder/components/GoodsInfo/components/CopGoodsList/index.scss +58 -58
  11. package/miniprogram_dist/ConfirmOrder/components/GoodsInfo/components/CopGoodsList/index.wxml +25 -25
  12. package/miniprogram_dist/ConfirmOrder/components/GoodsInfo/index.js +448 -448
  13. package/miniprogram_dist/ConfirmOrder/components/GoodsInfo/index.json +9 -9
  14. package/miniprogram_dist/ConfirmOrder/components/GoodsInfo/index.scss +222 -222
  15. package/miniprogram_dist/ConfirmOrder/components/GoodsInfo/index.wxml +81 -81
  16. package/miniprogram_dist/ConfirmOrder/components/IntegralSelect/index.scss +90 -90
  17. package/miniprogram_dist/ConfirmOrder/components/Invoice/index.scss +60 -60
  18. package/miniprogram_dist/ConfirmOrder/components/LeaveWord/index.scss +39 -39
  19. package/miniprogram_dist/ConfirmOrder/components/PayBar/index.js +249 -249
  20. package/miniprogram_dist/ConfirmOrder/components/PayBar/index.scss +61 -61
  21. package/miniprogram_dist/ConfirmOrder/components/PayDetail/index.scss +40 -40
  22. package/miniprogram_dist/ConfirmOrder/components/PickupSelect/index.js +89 -89
  23. package/miniprogram_dist/ConfirmOrder/components/PickupSelect/index.wxml +13 -13
  24. package/miniprogram_dist/ConfirmOrder/components/SvipSelect/SvipSelect.js +99 -99
  25. package/miniprogram_dist/ConfirmOrder/components/SvipSelect/SvipSelect.json +6 -6
  26. package/miniprogram_dist/ConfirmOrder/components/SvipSelect/SvipSelect.scss +150 -150
  27. package/miniprogram_dist/ConfirmOrder/components/SvipSelect/SvipSelect.wxml +39 -39
  28. package/miniprogram_dist/ConfirmOrder/components/SvipSelect/filter.wxs +6 -6
  29. package/miniprogram_dist/ConfirmOrder/index.js +110 -110
  30. package/miniprogram_dist/CopGoodsCard/constans.js +462 -462
  31. package/miniprogram_dist/CopGoodsCard/index.js +147 -147
  32. package/miniprogram_dist/CopGoodsCard/index.json +2 -2
  33. package/miniprogram_dist/CopGoodsCard/index.scss +100 -100
  34. package/miniprogram_dist/CopGoodsCard/index.wxml +20 -20
  35. package/miniprogram_dist/CouponList/components/CouponItem/index.css +1715 -1715
  36. package/miniprogram_dist/CouponList/components/CouponItem/index.js +325 -319
  37. package/miniprogram_dist/CouponList/components/CouponItem/index.min.css +1 -1
  38. package/miniprogram_dist/CouponList/components/CouponItem/index.scss +591 -591
  39. package/miniprogram_dist/CouponList/components/CouponItem/index.wxml +199 -199
  40. package/miniprogram_dist/CouponList/couponColumn/index.js +176 -176
  41. package/miniprogram_dist/CouponList/couponColumn/index.scss +117 -117
  42. package/miniprogram_dist/CouponList/couponColumn/index.wxml +39 -39
  43. package/miniprogram_dist/CouponReceivePopup/index.js +72 -72
  44. package/miniprogram_dist/CouponReceivePopup/index.json +5 -5
  45. package/miniprogram_dist/CouponReceivePopup/index.scss +99 -99
  46. package/miniprogram_dist/CouponReceivePopup/index.wxml +85 -85
  47. package/miniprogram_dist/CustomPopup/index.js +82 -82
  48. package/miniprogram_dist/CustomPopup/index.wxml +25 -25
  49. package/miniprogram_dist/GoodsItem/index.js +745 -745
  50. package/miniprogram_dist/GoodsItem/index.scss +524 -524
  51. package/miniprogram_dist/GoodsItem/index.wxml +173 -173
  52. package/miniprogram_dist/GoodsItem/index.wxs +18 -18
  53. package/miniprogram_dist/GoodsRecommend/fun.wxs +37 -37
  54. package/miniprogram_dist/GoodsRecommend/index.js +91 -91
  55. package/miniprogram_dist/GoodsRecommend/index.json +3 -3
  56. package/miniprogram_dist/GoodsRecommend/index.less +129 -129
  57. package/miniprogram_dist/GoodsRecommend/index.scss +162 -162
  58. package/miniprogram_dist/GoodsRecommend/index.wxml +47 -47
  59. package/miniprogram_dist/LiveGoodsList/Header/index.scss +78 -78
  60. package/miniprogram_dist/LiveGoodsList/index.js +821 -821
  61. package/miniprogram_dist/LiveGoodsList/index.scss +92 -92
  62. package/miniprogram_dist/LiveGoodsList/index.wxml +106 -106
  63. package/miniprogram_dist/PayModule/button/index.scss +44 -44
  64. package/miniprogram_dist/PayModule/index/index.js +264 -264
  65. package/miniprogram_dist/Task/TaskBubble/index.js +117 -117
  66. package/miniprogram_dist/Task/TaskBubble/index.json +3 -3
  67. package/miniprogram_dist/Task/TaskBubble/index.scss +125 -125
  68. package/miniprogram_dist/Task/TaskBubble/index.wxml +22 -22
  69. package/miniprogram_dist/Task/TaskIcon/index.js +29 -29
  70. package/miniprogram_dist/Task/TaskIcon/index.json +4 -4
  71. package/miniprogram_dist/Task/TaskIcon/index.scss +70 -70
  72. package/miniprogram_dist/Task/TaskIcon/index.wxml +5 -5
  73. package/miniprogram_dist/Task/TaskPopup/component/RewardList/index.js +39 -39
  74. package/miniprogram_dist/Task/TaskPopup/component/RewardList/index.json +6 -6
  75. package/miniprogram_dist/Task/TaskPopup/component/RewardList/index.scss +39 -39
  76. package/miniprogram_dist/Task/TaskPopup/component/RewardList/index.wxml +19 -19
  77. package/miniprogram_dist/Task/TaskPopup/component/TaskItem/index.js +207 -207
  78. package/miniprogram_dist/Task/TaskPopup/component/TaskItem/index.json +5 -5
  79. package/miniprogram_dist/Task/TaskPopup/component/TaskItem/index.scss +139 -139
  80. package/miniprogram_dist/Task/TaskPopup/component/TaskItem/index.wxml +43 -43
  81. package/miniprogram_dist/Task/TaskPopup/component/TaskItem/index.wxs +7 -7
  82. package/miniprogram_dist/Task/TaskPopup/component/TaskList/index.js +146 -146
  83. package/miniprogram_dist/Task/TaskPopup/component/TaskList/index.json +7 -7
  84. package/miniprogram_dist/Task/TaskPopup/component/TaskList/index.scss +66 -66
  85. package/miniprogram_dist/Task/TaskPopup/component/TaskList/index.wxml +39 -39
  86. package/miniprogram_dist/Task/TaskPopup/component/TaskType/index.js +75 -75
  87. package/miniprogram_dist/Task/TaskPopup/component/TaskType/index.json +9 -9
  88. package/miniprogram_dist/Task/TaskPopup/component/TaskType/index.scss +59 -59
  89. package/miniprogram_dist/Task/TaskPopup/component/TaskType/index.wxml +42 -42
  90. package/miniprogram_dist/Task/TaskPopup/index.js +113 -113
  91. package/miniprogram_dist/Task/TaskPopup/index.json +8 -8
  92. package/miniprogram_dist/Task/TaskPopup/index.scss +113 -113
  93. package/miniprogram_dist/Task/TaskPopup/index.wxml +67 -67
  94. package/miniprogram_dist/Task/taskReceivePopup/coupon/index.js +52 -52
  95. package/miniprogram_dist/Task/taskReceivePopup/coupon/index.json +6 -6
  96. package/miniprogram_dist/Task/taskReceivePopup/coupon/index.scss +91 -91
  97. package/miniprogram_dist/Task/taskReceivePopup/coupon/index.wxml +53 -53
  98. package/miniprogram_dist/Task/taskReceivePopup/coupon/index.wxs +48 -48
  99. package/miniprogram_dist/Task/taskReceivePopup/index.js +30 -30
  100. package/miniprogram_dist/Task/taskReceivePopup/index.json +11 -11
  101. package/miniprogram_dist/Task/taskReceivePopup/index.wxml +18 -18
  102. package/miniprogram_dist/Task/taskReceivePopup/integral/index.js +37 -37
  103. package/miniprogram_dist/Task/taskReceivePopup/integral/index.json +6 -6
  104. package/miniprogram_dist/Task/taskReceivePopup/integral/index.scss +60 -60
  105. package/miniprogram_dist/Task/taskReceivePopup/integral/index.wxml +17 -17
  106. package/miniprogram_dist/TeacherGoodsList/index.js +825 -825
  107. package/miniprogram_dist/TeacherGoodsList/index.json +9 -9
  108. package/miniprogram_dist/TeacherGoodsList/index.scss +145 -145
  109. package/miniprogram_dist/TeacherGoodsList/index.wxml +110 -110
  110. package/miniprogram_dist/common/api/confirmOrder.js +223 -223
  111. package/miniprogram_dist/common/api/couponlist.js +2 -63
  112. package/miniprogram_dist/common/api/liveGoodsList.js +89 -89
  113. package/miniprogram_dist/common/api/sku.js +73 -73
  114. package/miniprogram_dist/common/utils/index.js +69 -69
  115. package/miniprogram_dist/coupon/components/CouponItem/index.less +208 -208
  116. package/miniprogram_dist/coupon/components/CouponItem/index.scss +246 -246
  117. package/miniprogram_dist/coupon/components/CouponSelect/index.scss +330 -330
  118. package/miniprogram_dist/coupon/index.js +248 -248
  119. package/miniprogram_dist/coupon/index.scss +83 -83
  120. package/package.json +78 -78
  121. package/src/ConfirmOrder/components/AddressSelect/index.js +160 -160
  122. package/src/ConfirmOrder/components/ChoosePicker/index.js +115 -115
  123. package/src/ConfirmOrder/components/ConfirmOrderContent/index.js +890 -890
  124. package/src/ConfirmOrder/components/ConfirmOrderContent/index.json +23 -23
  125. package/src/ConfirmOrder/components/ConfirmOrderContent/index.scss +44 -44
  126. package/src/ConfirmOrder/components/ConfirmOrderContent/index.wxml +188 -188
  127. package/src/ConfirmOrder/components/ConfirmOrderContent/index.wxss +51 -51
  128. package/src/ConfirmOrder/components/GoodsInfo/components/CopGoodsList/index.js +129 -129
  129. package/src/ConfirmOrder/components/GoodsInfo/components/CopGoodsList/index.json +8 -8
  130. package/src/ConfirmOrder/components/GoodsInfo/components/CopGoodsList/index.scss +58 -58
  131. package/src/ConfirmOrder/components/GoodsInfo/components/CopGoodsList/index.wxml +25 -25
  132. package/src/ConfirmOrder/components/GoodsInfo/components/CopGoodsList/index.wxss +1 -1
  133. package/src/ConfirmOrder/components/GoodsInfo/index.js +448 -448
  134. package/src/ConfirmOrder/components/GoodsInfo/index.json +9 -9
  135. package/src/ConfirmOrder/components/GoodsInfo/index.scss +222 -222
  136. package/src/ConfirmOrder/components/GoodsInfo/index.wxml +81 -81
  137. package/src/ConfirmOrder/components/GoodsInfo/index.wxss +673 -673
  138. package/src/ConfirmOrder/components/IntegralSelect/index.scss +90 -90
  139. package/src/ConfirmOrder/components/IntegralSelect/index.wxss +218 -218
  140. package/src/ConfirmOrder/components/Invoice/index.scss +60 -60
  141. package/src/ConfirmOrder/components/Invoice/index.wxss +93 -93
  142. package/src/ConfirmOrder/components/LeaveWord/index.scss +39 -39
  143. package/src/ConfirmOrder/components/LeaveWord/index.wxss +34 -34
  144. package/src/ConfirmOrder/components/PayBar/index.js +249 -249
  145. package/src/ConfirmOrder/components/PayBar/index.scss +61 -61
  146. package/src/ConfirmOrder/components/PayBar/index.wxss +108 -108
  147. package/src/ConfirmOrder/components/PayDetail/index.scss +40 -40
  148. package/src/ConfirmOrder/components/PayDetail/index.wxss +50 -50
  149. package/src/ConfirmOrder/components/PickupSelect/index.js +89 -89
  150. package/src/ConfirmOrder/components/PickupSelect/index.wxml +13 -13
  151. package/src/ConfirmOrder/components/SvipSelect/SvipSelect.js +99 -99
  152. package/src/ConfirmOrder/components/SvipSelect/SvipSelect.json +6 -6
  153. package/src/ConfirmOrder/components/SvipSelect/SvipSelect.scss +150 -150
  154. package/src/ConfirmOrder/components/SvipSelect/SvipSelect.wxml +39 -39
  155. package/src/ConfirmOrder/components/SvipSelect/SvipSelect.wxss +266 -266
  156. package/src/ConfirmOrder/components/SvipSelect/filter.wxs +6 -6
  157. package/src/ConfirmOrder/index.js +110 -110
  158. package/src/CopGoodsCard/constans.js +462 -462
  159. package/src/CopGoodsCard/index.js +147 -147
  160. package/src/CopGoodsCard/index.json +2 -2
  161. package/src/CopGoodsCard/index.scss +100 -100
  162. package/src/CopGoodsCard/index.wxml +20 -20
  163. package/src/CopGoodsCard/index.wxss +1 -1
  164. package/src/CouponList/components/CouponItem/index.css +1715 -1715
  165. package/src/CouponList/components/CouponItem/index.js +325 -319
  166. package/src/CouponList/components/CouponItem/index.min.css +1 -1
  167. package/src/CouponList/components/CouponItem/index.scss +591 -591
  168. package/src/CouponList/components/CouponItem/index.wxml +199 -199
  169. package/src/CouponList/components/CouponItem/index.wxss +1715 -1715
  170. package/src/CouponList/couponColumn/index.js +176 -176
  171. package/src/CouponList/couponColumn/index.scss +117 -117
  172. package/src/CouponList/couponColumn/index.wxml +39 -39
  173. package/src/CouponList/couponColumn/index.wxss +265 -265
  174. package/src/CouponReceivePopup/index.js +72 -72
  175. package/src/CouponReceivePopup/index.json +5 -5
  176. package/src/CouponReceivePopup/index.scss +99 -99
  177. package/src/CouponReceivePopup/index.wxml +85 -85
  178. package/src/CouponReceivePopup/index.wxss +1 -1
  179. package/src/CustomPopup/index.js +82 -82
  180. package/src/CustomPopup/index.wxml +25 -25
  181. package/src/GoodsItem/index.js +745 -745
  182. package/src/GoodsItem/index.scss +524 -524
  183. package/src/GoodsItem/index.wxml +173 -173
  184. package/src/GoodsItem/index.wxs +18 -18
  185. package/src/GoodsItem/index.wxss +1935 -1935
  186. package/src/GoodsRecommend/fun.wxs +37 -37
  187. package/src/GoodsRecommend/index.js +91 -91
  188. package/src/GoodsRecommend/index.json +3 -3
  189. package/src/GoodsRecommend/index.less +129 -129
  190. package/src/GoodsRecommend/index.scss +162 -162
  191. package/src/GoodsRecommend/index.wxml +47 -47
  192. package/src/GoodsRecommend/index.wxss +537 -537
  193. package/src/LiveGoodsList/Header/index.scss +78 -78
  194. package/src/LiveGoodsList/Header/index.wxss +190 -190
  195. package/src/LiveGoodsList/index.js +821 -821
  196. package/src/LiveGoodsList/index.scss +92 -92
  197. package/src/LiveGoodsList/index.wxml +106 -106
  198. package/src/LiveGoodsList/index.wxss +230 -230
  199. package/src/PayModule/button/index.scss +44 -44
  200. package/src/PayModule/button/index.wxss +58 -58
  201. package/src/PayModule/index/index.js +264 -264
  202. package/src/Sku/commSelect/index.wxss +54 -54
  203. package/src/Task/TaskBubble/index.js +117 -117
  204. package/src/Task/TaskBubble/index.json +3 -3
  205. package/src/Task/TaskBubble/index.scss +125 -125
  206. package/src/Task/TaskBubble/index.wxml +22 -22
  207. package/src/Task/TaskBubble/index.wxss +289 -289
  208. package/src/Task/TaskIcon/index.js +29 -29
  209. package/src/Task/TaskIcon/index.json +4 -4
  210. package/src/Task/TaskIcon/index.scss +70 -70
  211. package/src/Task/TaskIcon/index.wxml +5 -5
  212. package/src/Task/TaskIcon/index.wxss +130 -130
  213. package/src/Task/TaskPopup/component/RewardList/index.js +39 -39
  214. package/src/Task/TaskPopup/component/RewardList/index.json +6 -6
  215. package/src/Task/TaskPopup/component/RewardList/index.scss +39 -39
  216. package/src/Task/TaskPopup/component/RewardList/index.wxml +19 -19
  217. package/src/Task/TaskPopup/component/RewardList/index.wxss +18 -18
  218. package/src/Task/TaskPopup/component/TaskItem/index.js +207 -207
  219. package/src/Task/TaskPopup/component/TaskItem/index.json +5 -5
  220. package/src/Task/TaskPopup/component/TaskItem/index.scss +139 -139
  221. package/src/Task/TaskPopup/component/TaskItem/index.wxml +43 -43
  222. package/src/Task/TaskPopup/component/TaskItem/index.wxs +7 -7
  223. package/src/Task/TaskPopup/component/TaskItem/index.wxss +394 -394
  224. package/src/Task/TaskPopup/component/TaskList/index.js +146 -146
  225. package/src/Task/TaskPopup/component/TaskList/index.json +7 -7
  226. package/src/Task/TaskPopup/component/TaskList/index.scss +66 -66
  227. package/src/Task/TaskPopup/component/TaskList/index.wxml +39 -39
  228. package/src/Task/TaskPopup/component/TaskList/index.wxss +118 -118
  229. package/src/Task/TaskPopup/component/TaskType/index.js +75 -75
  230. package/src/Task/TaskPopup/component/TaskType/index.json +9 -9
  231. package/src/Task/TaskPopup/component/TaskType/index.scss +59 -59
  232. package/src/Task/TaskPopup/component/TaskType/index.wxml +42 -42
  233. package/src/Task/TaskPopup/component/TaskType/index.wxss +98 -98
  234. package/src/Task/TaskPopup/index.js +113 -113
  235. package/src/Task/TaskPopup/index.json +8 -8
  236. package/src/Task/TaskPopup/index.scss +113 -113
  237. package/src/Task/TaskPopup/index.wxml +67 -67
  238. package/src/Task/TaskPopup/index.wxss +306 -306
  239. package/src/Task/taskReceivePopup/coupon/index.js +52 -52
  240. package/src/Task/taskReceivePopup/coupon/index.json +6 -6
  241. package/src/Task/taskReceivePopup/coupon/index.scss +91 -91
  242. package/src/Task/taskReceivePopup/coupon/index.wxml +53 -53
  243. package/src/Task/taskReceivePopup/coupon/index.wxs +48 -48
  244. package/src/Task/taskReceivePopup/coupon/index.wxss +187 -187
  245. package/src/Task/taskReceivePopup/index.js +30 -30
  246. package/src/Task/taskReceivePopup/index.json +11 -11
  247. package/src/Task/taskReceivePopup/index.wxml +18 -18
  248. package/src/Task/taskReceivePopup/index.wxss +1 -1
  249. package/src/Task/taskReceivePopup/integral/index.js +37 -37
  250. package/src/Task/taskReceivePopup/integral/index.json +6 -6
  251. package/src/Task/taskReceivePopup/integral/index.scss +60 -60
  252. package/src/Task/taskReceivePopup/integral/index.wxml +17 -17
  253. package/src/Task/taskReceivePopup/integral/index.wxss +94 -94
  254. package/src/TeacherGoodsList/index.js +825 -825
  255. package/src/TeacherGoodsList/index.json +9 -9
  256. package/src/TeacherGoodsList/index.scss +145 -145
  257. package/src/TeacherGoodsList/index.wxml +110 -110
  258. package/src/TeacherGoodsList/index.wxss +196 -196
  259. package/src/common/api/confirmOrder.js +223 -223
  260. package/src/common/api/couponlist.js +2 -63
  261. package/src/common/api/liveGoodsList.js +89 -89
  262. package/src/common/api/sku.js +73 -73
  263. package/src/common/utils/index.js +69 -69
  264. package/src/coupon/components/CouponItem/index.less +208 -208
  265. package/src/coupon/components/CouponItem/index.scss +246 -246
  266. package/src/coupon/components/CouponItem/index.wxss +821 -821
  267. package/src/coupon/components/CouponSelect/index.scss +330 -330
  268. package/src/coupon/components/CouponSelect/index.wxss +1132 -1132
  269. package/src/coupon/index.js +248 -248
  270. package/src/coupon/index.scss +83 -83
  271. package/src/coupon/index.wxss +216 -216
@@ -1,825 +1,825 @@
1
- /*
2
- * @Descripttion:
3
- * @version:
4
- * @Author: conlinchen
5
- * @Date: 2021-10-28 15:32:24
6
- * @LastEditors: conlinchen
7
- * @LastEditTime: 2021-11-18 19:52:02
8
- */
9
-
10
- import { getGoodsList, requestChangeShow } from "../common/api/liveGoodsList"
11
- const computedBehavior = require('miniprogram-computed').behavior
12
-
13
- let activityCountdownTimer = null // 活动倒计时计时器
14
- let hadActivity = false
15
- let activityList = [] // 参与活动的商品
16
-
17
- // 预热模块
18
- let preheatTimer = null // 预热倒计时计时器
19
- let hadPreheat = false
20
- let preheatList = [] // 参与活动的商品
21
-
22
- let hasActivity = false // 是否有参与活动的商品
23
- let hasPreheat = false // 是否有参与预热的商品
24
-
25
- const SPU_TYPE = {
26
- 1: "图文",
27
- 2: "音频",
28
- 3: "视频",
29
- 4: "直播",
30
- 35: "班课",
31
- 20: "电子书",
32
- 6: "专栏",
33
- 8: "大专栏",
34
- 5: "会员",
35
- 25: "训练营",
36
- 21: "实物商品",
37
- 29: "线下课", //体验课也是29
38
- 22: "分销商品",
39
- 12: "分销商品", //暂时不做
40
- 41: "有价优惠券",
41
- 45: "AI互动课",
42
- 23: "超级会员"
43
- }
44
- const MARKET_ACTIVITY_MAP = {
45
- 3: "限时折扣",
46
- 4: "好友助力",
47
- 5: "裂变海报",
48
- 6: "拼团",
49
- 7: "涨粉神器",
50
- 8: "秒杀",
51
- }
52
-
53
- Component({
54
- behaviors: [computedBehavior],
55
- properties: {
56
- sensorReportParams: {
57
- type: Object,
58
- value: {}
59
- },
60
- aliveInfo: {
61
- type: Object,
62
- value: {
63
- alive_id: 'l_61c2a4dae4b0ad9a9d6887dc',
64
- alive_state: 2
65
- },
66
- },
67
- ENV_NAME: {
68
- type: String,
69
- value: ""
70
- },
71
- showList: {
72
- type: Boolean,
73
- value: false,
74
- observer(newVal) {
75
- this.setData({
76
- refreshing: newVal
77
- })
78
- console.log(newVal)
79
-
80
- newVal && this.onLoad()
81
- if (!newVal) {
82
- clearInterval(activityCountdownTimer)
83
- activityCountdownTimer = null
84
- clearInterval(preheatTimer)
85
- preheatTimer = null
86
- }
87
- }
88
- },
89
- changState: {
90
- type: Object,
91
- value: {}
92
- },
93
- aliveConf: { //is_takegoods: 是否开启直播带货,0-关闭 1-开启
94
- type: Object,
95
- value: {}
96
- },
97
- isFullScreen: {
98
- type: Boolean,
99
- value: false,
100
- },
101
- // im实时同步的带货消息
102
- msgGoodsData: {
103
- type: Object,
104
- value: {},
105
- observer(newVal) {
106
- this.handlerListInfo(newVal)
107
- },
108
- },
109
- isManage: {
110
- type: Boolean,
111
- value: false,
112
- },
113
- sendingGoodId: {
114
- type: String,
115
- value: '',
116
- },
117
- },
118
- data: {
119
- goodsInfo: [],
120
- page_size: 5,
121
- page_index: 1,
122
- total: 0,
123
- refreshing: false,
124
- finishedTxt: '加载中',
125
- finished: false,
126
- sendingIndex: -1,
127
- sending: false,
128
- selectGoods: [], // 多选列表
129
- is_jurisdiction: false, // 操作权限
130
- isSplitSelect: false, // 当前是否是单独勾选
131
- selectGoodsIndexArr: [], // 当前已经选中的商品索引数组
132
- is_show_now: 0, //当前已展示的数量
133
- is_hide_now: 0, // 当前已隐藏的数量
134
- isDisabled: false, // 复选框是否禁用
135
- selectId: '', // 当前点击那一项的goodsId
136
- goodsSwitch: 0, // 带货开关
137
- goodsSwitchOld: -1, // 带货开关旧值,用于区分im上面switch是否是打开还是普通增删改
138
- },
139
- lifetimes: {
140
- // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
141
- attached: function () {
142
- this.setData({
143
- goodsSwitch: this.data.aliveConf.is_takegoods,
144
- goodsSwitchOld: this.data.aliveConf.is_takegoods,
145
- })
146
- },
147
- moved: function () { },
148
- detached: function () { },
149
- },
150
- methods: {
151
- // "sync_goods":{
152
- // "switch":0,//开关:0关1开
153
- // //带货配置列表-最多六条
154
- // "conf_list":[],
155
- // "update_list":[],
156
- // //移除资源id
157
- // "batch_del":["p_63845d8be4b07b05581ebf47"],
158
- // //批量显示隐藏
159
- // "batch_switch":[]
160
- // }
161
- /**
162
- * 带货/优惠券实时同步
163
- * @param {object} msgData im消息体
164
- * @param {string} type 消息类型:带货goods、优惠券coupon
165
- */
166
- handlerListInfo(msgData) {
167
- let type = '',
168
- marketInfo = []
169
- // 遍历获取操作类型
170
- for (let key in msgData) {
171
- switch (key) {
172
- // 带货开关操作
173
- case "switch":
174
- type = "goodsSwitch";
175
- marketInfo = Number(msgData[key]);
176
- break;
177
- // 新增操作
178
- case 'conf_list':
179
- type = 'goodsConfList'
180
- marketInfo = msgData[key]
181
- break
182
- // 修改操作
183
- case 'update_list':
184
- type = 'goodsUpdateList'
185
- marketInfo = msgData[key]
186
- break
187
- // 删除操作
188
- case 'batch_del':
189
- type = 'goodsDelList'
190
- marketInfo = msgData[key]
191
- break
192
- // 显隐操作
193
- case 'batch_switch':
194
- type = 'goodsBatchSwitchList'
195
- marketInfo = msgData[key]
196
- break
197
- default:
198
- break
199
- }
200
- console.log('[teacherGoodList] 带货实时同步im: ', type, marketInfo)
201
- if (marketInfo?.length > 0 || ["goodsSwitch"].includes(type)) {
202
- this.changeGoodsList(type, marketInfo)
203
- type = ''
204
- marketInfo = []
205
- }
206
- }
207
- },
208
- // 处理实时同步的带货逻辑
209
- changeGoodsList(type, marketInfo) {
210
- let goodsInfo = this.data.goodsInfo,
211
- delIndex = -1, // 删除数据的当前下标
212
- selectGoods = this.data.selectGoods, // 批量隐藏数组id
213
- selectGoodsIndexArr = this.data.selectGoodsIndexArr, // 批量隐藏数组索引
214
- total = this.data.total, // 管理商品总数
215
- isHasGoods = false // 是否已有这个商品
216
- switch (type) {
217
- // 带货和优惠券开关操作
218
- case "goodsSwitch":
219
- if ([0, 1].includes(marketInfo)) this.setData({ goodsSwitch: marketInfo })
220
- break;
221
- case 'goodsConfList':
222
- // 如果已经加载完了,可以拼接数据
223
- // 由于看不出为何触发了两次,做id过滤
224
- if (this.data.finished || this.data.finishedTxt === "no-data") {
225
- marketInfo.map((item) => {
226
- for (let index = 0; index < goodsInfo.length; index++) {
227
- if (item.id === goodsInfo[index].id) {
228
- isHasGoods = true;
229
- break
230
- }
231
- }
232
- if (!isHasGoods) {
233
- // 管理商品需要增加
234
- total++
235
- this.formatData([item]);
236
- }
237
- isHasGoods = false;
238
- })
239
- this.setData({
240
- finished: true,
241
- finishedTxt: "没有更多了",
242
- is_jurisdiction: this.data.goodsInfo[0] ? this.data.goodsInfo[0].teacher_auth == 2 : false
243
- })
244
- }
245
- break
246
- case 'goodsUpdateList':
247
- case 'goodsBatchSwitchList':
248
- marketInfo.map((item) => {
249
- for (let index = 0; index < goodsInfo.length; index++) {
250
- if (item.id === goodsInfo[index].id) {
251
- // 遍历插入相应的修改值
252
- for (let key in item) {
253
- goodsInfo[index][key] = item[key]
254
- }
255
- break
256
- }
257
- }
258
- })
259
- this.formatData(goodsInfo, true);
260
- break
261
- case 'goodsDelList':
262
- marketInfo.map((id) => {
263
- for (let index = 0; index < goodsInfo.length; index++) {
264
- if (id === goodsInfo[index].id) {
265
- // 删除操作,获取下标
266
- goodsInfo.splice(index, 1)
267
- delIndex = index
268
- index--
269
- // 管理商品需要减少
270
- total--
271
- }
272
- // 删除后,后面的数据都要权重+1显示
273
- if (delIndex > -1 && index >= delIndex) {
274
- goodsInfo[index].order_weight--
275
- }
276
- }
277
- // 重置删除下标
278
- delIndex = -1
279
-
280
- // 此处处理批量显隐的,删掉了,需要把选择的也删掉
281
- if (selectGoodsIndexArr.length > 0) {
282
- for (let index = 0; index < selectGoodsIndexArr.length; index++) {
283
- if (id === selectGoodsIndexArr[index]) {
284
- // 删除操作,获取下标
285
- selectGoodsIndexArr.splice(index, 1)
286
- selectGoods.splice(index, 1)
287
- index--
288
- }
289
- }
290
- }
291
- })
292
- this.formatData(goodsInfo, true);
293
- if (this.data.goodsInfo.length === 0) {
294
- // 确保第一页没有了数据
295
- this._freshing = true
296
- this.setData({
297
- finished: false,
298
- page_index: 1
299
- })
300
- this.getGoodsList()
301
- }
302
- break
303
- default:
304
- break
305
- }
306
- this.setData({
307
- total,
308
- selectGoods,
309
- selectGoodsIndexArr,
310
- }, () => {
311
- if (!this.data.total) this.triggerEvent("isNullDate")
312
- })
313
- },
314
- // 管理商品多选
315
- onChange(e) {
316
- // this.setData({
317
- // selectGoods:e.detail
318
- // })
319
- let tempGoodsArr = []
320
- e.detail.forEach((item) => {
321
- for (let index = 0; index < this.data.goodsInfo.length; index++) {
322
- if (item === this.data.goodsInfo[index].id) {
323
- tempGoodsArr.push(this.data.goodsInfo[index])
324
- break
325
- }
326
- }
327
- })
328
- this.setData({
329
- selectGoods: tempGoodsArr,
330
- selectGoodsIndexArr: e.detail,
331
- })
332
- },
333
-
334
- // 显示隐藏
335
- // 商品显隐操作
336
- changeShowType(e) {
337
- let { type } = e.target.dataset
338
- // 未选择商品
339
- if (!this.data.selectGoods.length) {
340
- this.showToast('请先选择商品')
341
- return
342
- }
343
-
344
- // 商品是否已是对应的显隐状态
345
- this.data.selectGoods.forEach((item) => {
346
- if (item.is_display_package && type === 'show') {
347
- this.setData({
348
- is_show_now: this.data.is_show_now + 1,
349
- })
350
- } else if (!item.is_display_package && type === 'hide') {
351
- this.setData({
352
- is_hide_now: this.data.is_hide_now + 1,
353
- })
354
- }
355
- })
356
- if (type === 'show') {
357
- if (this.data.is_show_now === this.data.selectGoods.length) {
358
- this.showToast('当前选择的商品已显示')
359
- this.setData({
360
- is_show_now: 0,
361
- })
362
- return
363
- } else {
364
- this.requestChangeShow(1)
365
- return
366
- }
367
- }
368
-
369
- // 隐藏商品确认弹窗
370
- if (type === 'hide') {
371
- if (this.data.is_hide_now === this.data.selectGoods.length) {
372
- this.showToast('当前选择的商品已隐藏')
373
- this.setData({
374
- is_hide_now: 0,
375
- })
376
- return
377
- } else {
378
- wx.showModal({
379
- title: `确认隐藏${this.data.is_hide_now
380
- ? this.data.selectGoods.length - this.data.is_hide_now
381
- : this.data.selectGoods.length
382
- }个商品吗`,
383
- content: '用户端商品列表不展示已隐藏商品,讲师仍可通过讲解发送商品',
384
- confirmText: '确认',
385
- cancelText: '取消',
386
- confirmColor: '#1472FF',
387
- success: (res) => {
388
- if (res.confirm) {
389
- this.requestChangeShow(0)
390
- } else if (res.cancel) {
391
- this.setData({
392
- is_hide_now: 0,
393
- })
394
- }
395
- },
396
- })
397
- return
398
- }
399
- }
400
- },
401
-
402
- // 商品显隐请求
403
- requestChangeShow(state) {
404
- const tempSelectGoodsArr = this.data.selectGoods.map((item) => ({
405
- id: item.id,
406
- type: item.true_type,
407
- }))
408
- const loginData = wx.getStorageSync('login_data')
409
- let params = {
410
- alive_id: this.data.aliveInfo.alive_id,
411
- app_id: this.data.aliveInfo.app_id,
412
- resource_ids: tempSelectGoodsArr,
413
- is_display_package: state,
414
- token: loginData.token,
415
- }
416
-
417
- requestChangeShow(params, false).then((res) => {
418
- let { code } = res.data
419
- if (code === 0) {
420
- // let temp = `marketResource.courseList[${this.data.selectIndex}].is_display_package`
421
- // 操作成功之后,要把当前选中的商品改变状态
422
- let temp = ''
423
- this.data.selectGoodsIndexArr.forEach((item) => {
424
- for (let index = 0; index < this.data.goodsInfo.length; index++) {
425
- if (item === this.data.goodsInfo[index].id) {
426
- temp = `goodsInfo[${index}].is_display_package`
427
- break
428
- }
429
- }
430
- this.setData({
431
- [temp]: state,
432
- })
433
- })
434
- this.setData({
435
- selectGoodsIndexArr: [],
436
- selectGoods: [],
437
- is_hide_now: 0,
438
- is_show_now: 0,
439
- })
440
- this.showToast('操作成功')
441
- } else {
442
- this.setData({
443
- is_hide_now: 0,
444
- is_show_now: 0,
445
- })
446
- this.showToast('操作失败')
447
- }
448
- })
449
- },
450
-
451
- // 商品总活动倒计时
452
- startActivityCountdown(list) {
453
-
454
- clearInterval(activityCountdownTimer)
455
- activityCountdownTimer = setInterval(() => {
456
- hadActivity = false
457
- list.forEach((i) => {
458
- let targetDate = new Date(i.time.replace(/-/g, '/')).getTime() - new Date().getTime()
459
- if (targetDate <= 0) return
460
- hadActivity = true
461
- let temp = `goodsInfo[${i.index}].activityCountdown`
462
- this.setData({
463
- [temp]: targetDate,
464
- })
465
- })
466
- if (!hadActivity) {
467
- clearInterval(activityCountdownTimer)
468
- activityCountdownTimer = null
469
- }
470
- }, 1000)
471
- },
472
- // 预热倒计时
473
- startPreheatCountdown(list) {
474
- clearInterval(preheatTimer)
475
- preheatTimer = setInterval(() => {
476
- hadPreheat = false
477
- list.forEach((i) => {
478
- let targetDate = new Date(i.time.replace(/-/g, '/')).getTime() - new Date().getTime()
479
- if (targetDate <= 0) {
480
- activityList.push({
481
- time: this.data.goodsInfo[i.index].end_at,
482
- index: i.index,
483
- })
484
- this.setData({
485
- [`goodsInfo[${i.index}].preheatTime`]: 0,
486
- })
487
- return
488
- }
489
- hadPreheat = true
490
- let temp = `goodsInfo[${i.index}].preheatTime`
491
- this.setData({
492
- [temp]: targetDate,
493
- })
494
- })
495
- if (!hadPreheat) {
496
- clearInterval(preheatTimer)
497
- preheatTimer = null
498
- }
499
- }, 1000)
500
- },
501
- onLoad() {
502
- if (!this.data.aliveConf.is_takegoods) {
503
- this.setData({
504
- refreshing: false
505
- })
506
- return
507
- }
508
- if (this._freshing) return
509
- this._freshing = true
510
- this.setData({
511
- finished: false,
512
- page_index: 1
513
- })
514
- this.getGoodsList()
515
- },
516
- onScrolltolower() {
517
- if (this.scrolling || this.data.finishedTxt === 'no-data' || !this.data.aliveConf.is_takegoods || this.data.finished) { return }
518
- this.scrolling = true
519
- this.setData({
520
- finishedTxt: this.data.finished ? "没有更多了" : "加载中"
521
- })
522
- if (this.data.finished || this._freshing) {
523
- return
524
- }
525
- this.getGoodsList()
526
- },
527
- getGoodsList() {
528
- let params = {
529
- alive_id: this.data.aliveInfo.alive_id,
530
- type: 1,
531
- page_size: this.data.page_size,
532
- page: this.data.page_index,
533
- port: 2
534
- }
535
- getGoodsList(params).then(res => {
536
- let { data, code } = res.data
537
- if (code === 0) {
538
- var total = data[0] ? data[0].total : this.data.total
539
- var finishedTxt = "加载中"
540
- var finished = false
541
- let is_jurisdiction = data[0] ? data[0].teacher_auth == 2 : false
542
-
543
- if (this._freshing) {
544
- //下拉加载直接赋值
545
- this.formatData(data, true)
546
- } else {
547
- this.formatData(data)
548
- }
549
- // 下拉加载,且数据返回空
550
- if (this._freshing && data.length === 0) {
551
- finishedTxt = "no-data"
552
- } else if (this.data.goodsInfo.length >= total || data.length === 0) {
553
- // 获取到所有数据
554
- finished = true// 没有更多了
555
- finishedTxt = "没有更多了"
556
- this.setData({ finishedTxt })
557
- } else {
558
- finishedTxt = "加载中"
559
- }
560
- this.setData({
561
- refreshing: false,
562
- page_index: this.data.page_index + 1,
563
- finishedTxt,
564
- finished,
565
- total,
566
- is_jurisdiction
567
- })
568
- this._freshing = false
569
- this.scrolling = false
570
- }
571
- })
572
- },
573
- formatData(data, refreshing = false) {
574
- let goodsInfo = this.data.goodsInfo
575
- data.forEach((item, index) => {
576
- this.formatItem(item)
577
- if (!refreshing && item.id) {
578
- goodsInfo.push(item)
579
- }
580
- })
581
- if (refreshing) {
582
- //下拉刷新的时候直接赋值
583
- goodsInfo = JSON.parse(JSON.stringify(data))
584
- }
585
- this.setData({
586
- goodsInfo
587
- }, () => {
588
- this.getActivityStatus(this.data.goodsInfo)
589
- })
590
- },
591
- getActivityStatus(data) {
592
- activityList = []
593
- preheatList = []
594
- data.forEach((item, index) => {
595
- if (item.is_activity && item.end_at) {
596
- hasActivity = true
597
- item.activityCountdown = 0
598
- activityList.push({
599
- time: item.end_at,
600
- index,
601
- })
602
- }
603
- // this.data.isSeckill && this.data.preheating
604
- if (item.activity_type === 8 && item.sec_kill_is_preheat === 1) {
605
- //预热开始时间
606
- let startTime = (item.start_at && new Date(item.start_at.replace(/-/g, '/'))) || new Date()
607
- let times = startTime.getTime() - item.sec_kill_preheat_time * 1000
608
- let preHeatTime = new Date(times) || new Date()
609
-
610
- let startTime2 = (item.start_at && new Date(item.start_at.replace(/-/g, '/'))) || new Date()
611
- let nowTime = new Date().getTime()
612
- let preheating = nowTime > preHeatTime.getTime() && startTime2.getTime() > nowTime
613
-
614
- if (preheating) {
615
- hasPreheat = true
616
- item.preheatTime = 0
617
- preheatList.push({
618
- time: item.start_at,
619
- index,
620
- })
621
- }
622
- }
623
- })
624
- if (hasActivity) this.startActivityCountdown(activityList) //活动倒计时
625
- if (hasPreheat) this.startPreheatCountdown(preheatList) // 预热倒计时
626
- },
627
- formatItem(e) {
628
- e.resourceTypeName = e.resource_type_name // 商品类型
629
- e.leftStock = e.is_activity && e.now_stock ? e.now_stock : e.stock // 商品库存,活动中且有活动库存就用活动库存
630
- // 处理未到活动时间的限时折扣
631
- if (e.activity_type === 3) {
632
- let nowTime = new Date().getTime()
633
- let startTime = new Date(e.start_at.replace(/-/g, "/")).getTime()
634
- let isStart = !!(nowTime - startTime > 0)
635
- if (!isStart) {
636
- e.is_activity = 0 // 未到活动时间的限时折扣 不参与比价
637
- }
638
- }
639
- // 预热前和活动结束后的秒杀不参与比价
640
- if (e.activity_type === 8) {
641
- let startTime = new Date(e.start_at.replace(/-/g, "/")).getTime()
642
- let preHeatTime = startTime - e.sec_kill_preheat_time * 1000 // 预热开始时间
643
- let nowTime = new Date().getTime()
644
- let isStartPreHeat = !!(nowTime - preHeatTime > 0) // 预热时间到了
645
- let endTime = new Date(e.end_at.replace(/-/g, "/")).getTime()
646
- let isEndSecKill = !!(nowTime - endTime > 0) // 秒杀活动结束了
647
- if (!isStartPreHeat || isEndSecKill) {
648
- e.is_activity = 0 // 预热前和活动结束后的秒杀 不参与比价
649
- }
650
- }
651
- //展示购买价处理;取原价、营销活动价、超级会员价到一个数组从小到大排序,最低为购买价。防止价格一样,所以加了权重比较
652
- let arr = []
653
- arr.push({
654
- active: "",
655
- price: e.price,
656
- weight: e.price + 0.0003,
657
- })
658
- // 活动管理、实物商品、有价优惠券、线下课和课时包不能设置活动库存,其他可以设置活动库存得需要判断是否还剩余活动库存;拼团也不能设置活动库存。
659
- let notExistNowStock = [9, 21, 41, 29, 42].indexOf(e.resource_type) > -1
660
- e.is_activity &&
661
- (notExistNowStock ||
662
- typeof e.now_stock === "number" ||
663
- e.activity_type === 6) &&
664
- arr.push({
665
- //参与营销活动且有活动库存的时候加入比较 now_stock -""空字符串的时候代表已经买完 -0代表不限量
666
- active: MARKET_ACTIVITY_MAP[e.activity_type],
667
- price: e.activity_price,
668
- weight: e.activity_price + 0.0001,
669
- })
670
- e.svip_price &&
671
- arr.push({
672
- //判断超级会员价
673
- active: "超级会员",
674
- price: e.svip_price,
675
- weight: e.svip_price + 0.0002,
676
- })
677
- arr.sort((a, b) => a.weight - b.weight)
678
- let svipAllFree = e.resource_rights_type === 1
679
- e.priceShow = arr[0].price //展示的购买价格
680
- e.priceShowInt = svipAllFree ? this.priceInt(e.price) : this.priceInt(e.priceShow) // 展示价格的整数部分
681
- e.priceShowFlow = svipAllFree ? this.priceFlow(e.price) : this.priceFlow(e.priceShow) // 展示是价格的小数部分
682
- e.preferentialShowInt = this.priceInt(e.preferential_price) // 展示券后价的整数部分
683
- e.preferentialShowFlow = this.priceFlow(e.preferential_price) // 展示券后价的小数部分
684
- e.currentActive = arr[0].active //当前适用得营销模式;有可能是原价,超级会员,营销活动
685
- //展示划线价处理;有营销活动、超级会员,划线价是原价;只有原价和原划线价,划线价是原划线价;
686
- if (e.currentActive !== "") {
687
- e.priceLine = e.price
688
- } else {
689
- e.priceLine = e.line_price || 0 //未设置原划线价的时候不展示划线价
690
- }
691
- e.priceLineShowInt = this.priceInt(e.priceLine) // 展示划线价的整数部分
692
- e.priceLineShowFlow = this.priceFlow(e.priceLine) // 展示划线的小数部分
693
- e.entityShowStock = (e.resource_type === 21 || e.resource_type === 41 || e.resource_type === 68) && e.show_stock // 实物商品库存依赖 B端店铺设置(show_stock):详情页展示不展示剩余件数
694
- e.hasStock = [29, 35].indexOf(e.resource_type) > -1 || e.entityShowStock || e.now_stock // 班课、线下课、实物商品、体验课、有活动库存,满足其一即展示库存
695
- },
696
- priceInt(val) {
697
- val = Number(val)
698
- return ((val / 100).toFixed(2) + '').split('.')[0]
699
- },
700
- priceFlow(val) {
701
- val = Number(val)
702
- return ((val / 100).toFixed(2) + '').split('.')[1] || '00'
703
- },
704
- closePop() {
705
- this.triggerEvent("closePop")
706
- },
707
- preventScroll() {
708
- return
709
- },
710
- sendGoodsCard(e) {
711
- console.log("npm", e)
712
- let dataset = e.detail.datas;
713
- this.setData({
714
- sending: true,
715
- sendingIndex: dataset['index']
716
- })
717
- // 触发父组件的send
718
- this.triggerEvent('sendGoodsCard', {
719
- datas: dataset
720
- });
721
- },
722
- clear() {
723
- this.setData({
724
- goodsInfo: [],
725
- finishedTxt: "no-data"
726
- })
727
- },
728
- setIsTakeGoods(value) {
729
- this.setData({
730
- ["aliveConf.is_takegoods"]: value
731
- })
732
- },
733
- deleteGood(id) {
734
- let deleteGoodIndex;
735
- if (!this.data.goodsInfo) return;
736
- this.data.goodsInfo.forEach((goods, index) => {
737
- if (goods.id === id) {
738
- deleteGoodIndex = index;
739
- }
740
- })
741
- deleteGoodIndex !== undefined && this.data.goodsInfo.splice(deleteGoodIndex, 1)
742
- this.setData({
743
- goodsInfo: this.data.goodsInfo
744
- })
745
- },
746
- selectToast(e) {
747
- let tempItemIndex = e.currentTarget.dataset.item
748
- this.setData({
749
- selectId: this.data.goodsInfo[tempItemIndex].id
750
- })
751
- if (this.data.selectGoodsIndexArr.length >= 10 && this.data.selectGoodsIndexArr.indexOf(this.data.selectId) === -1) {
752
- this.showToast('批量操作最多支持10条')
753
- } else {
754
- return
755
- }
756
- },
757
- showToast(title = '') {
758
- wx.showToast({
759
- title,
760
- icon: 'none',
761
- duration: 1000,
762
- })
763
- },
764
- },
765
- observers: {
766
- // 监听点击发送事件
767
- "changState.time": function (newVal) {
768
- // 处理成功回调,主要用于变更按钮发送状态
769
- console.log('changState', newVal, this.properties.changState)
770
- let state = this.properties.changState
771
- if (state && state.index != -1) {
772
- this.setData({
773
- sending: false,
774
- sendingIndex: state.index
775
- })
776
- }
777
- },
778
- "total": function (newVal) {
779
- this.triggerEvent("totalChange", newVal)
780
- },
781
- "isManage": function (newVal) {
782
- this.setData({
783
- selectGoods: []
784
- })
785
- },
786
- "is_jurisdiction": function (newVal) {
787
- this.triggerEvent("jurisdictionChange", newVal)
788
- },
789
- "goodsSwitch": function (newVal) {
790
- if (this.data.goodsSwitchOld === 0 && newVal === 1 && this.data.showList) {
791
- this._freshing = true
792
- this.setData({
793
- finished: false,
794
- page_index: 1
795
- })
796
- this.getGoodsList()
797
- } else if (newVal === 0) {
798
- this.triggerEvent("closePopup")
799
- this.triggerEvent("isNullDate")
800
- this.setData({
801
- goodsInfo: [],
802
- page_size: 5,
803
- page_index: 1,
804
- total: 0,
805
- refreshing: false,
806
- finished: false,
807
- sendingIndex: -1,
808
- sending: false,
809
- selectGoods: [], // 多选列表
810
- is_jurisdiction: false, // 操作权限
811
- isSplitSelect: false, // 当前是否是单独勾选
812
- selectGoodsIndexArr: [], // 当前已经选中的商品索引数组
813
- is_show_now: 0, //当前已展示的数量
814
- is_hide_now: 0, // 当前已隐藏的数量
815
- isDisabled: false, // 复选框是否禁用
816
- selectId: '', // 当前点击那一项的goodsId
817
- })
818
- }
819
- // 设置一下本次更改的开关值
820
- this.setData({
821
- goodsSwitchOld: newVal
822
- })
823
- },
824
- },
825
- })
1
+ /*
2
+ * @Descripttion:
3
+ * @version:
4
+ * @Author: conlinchen
5
+ * @Date: 2021-10-28 15:32:24
6
+ * @LastEditors: conlinchen
7
+ * @LastEditTime: 2021-11-18 19:52:02
8
+ */
9
+
10
+ import { getGoodsList, requestChangeShow } from "../common/api/liveGoodsList"
11
+ const computedBehavior = require('miniprogram-computed').behavior
12
+
13
+ let activityCountdownTimer = null // 活动倒计时计时器
14
+ let hadActivity = false
15
+ let activityList = [] // 参与活动的商品
16
+
17
+ // 预热模块
18
+ let preheatTimer = null // 预热倒计时计时器
19
+ let hadPreheat = false
20
+ let preheatList = [] // 参与活动的商品
21
+
22
+ let hasActivity = false // 是否有参与活动的商品
23
+ let hasPreheat = false // 是否有参与预热的商品
24
+
25
+ const SPU_TYPE = {
26
+ 1: "图文",
27
+ 2: "音频",
28
+ 3: "视频",
29
+ 4: "直播",
30
+ 35: "班课",
31
+ 20: "电子书",
32
+ 6: "专栏",
33
+ 8: "大专栏",
34
+ 5: "会员",
35
+ 25: "训练营",
36
+ 21: "实物商品",
37
+ 29: "线下课", //体验课也是29
38
+ 22: "分销商品",
39
+ 12: "分销商品", //暂时不做
40
+ 41: "有价优惠券",
41
+ 45: "AI互动课",
42
+ 23: "超级会员"
43
+ }
44
+ const MARKET_ACTIVITY_MAP = {
45
+ 3: "限时折扣",
46
+ 4: "好友助力",
47
+ 5: "裂变海报",
48
+ 6: "拼团",
49
+ 7: "涨粉神器",
50
+ 8: "秒杀",
51
+ }
52
+
53
+ Component({
54
+ behaviors: [computedBehavior],
55
+ properties: {
56
+ sensorReportParams: {
57
+ type: Object,
58
+ value: {}
59
+ },
60
+ aliveInfo: {
61
+ type: Object,
62
+ value: {
63
+ alive_id: 'l_61c2a4dae4b0ad9a9d6887dc',
64
+ alive_state: 2
65
+ },
66
+ },
67
+ ENV_NAME: {
68
+ type: String,
69
+ value: ""
70
+ },
71
+ showList: {
72
+ type: Boolean,
73
+ value: false,
74
+ observer(newVal) {
75
+ this.setData({
76
+ refreshing: newVal
77
+ })
78
+ console.log(newVal)
79
+
80
+ newVal && this.onLoad()
81
+ if (!newVal) {
82
+ clearInterval(activityCountdownTimer)
83
+ activityCountdownTimer = null
84
+ clearInterval(preheatTimer)
85
+ preheatTimer = null
86
+ }
87
+ }
88
+ },
89
+ changState: {
90
+ type: Object,
91
+ value: {}
92
+ },
93
+ aliveConf: { //is_takegoods: 是否开启直播带货,0-关闭 1-开启
94
+ type: Object,
95
+ value: {}
96
+ },
97
+ isFullScreen: {
98
+ type: Boolean,
99
+ value: false,
100
+ },
101
+ // im实时同步的带货消息
102
+ msgGoodsData: {
103
+ type: Object,
104
+ value: {},
105
+ observer(newVal) {
106
+ this.handlerListInfo(newVal)
107
+ },
108
+ },
109
+ isManage: {
110
+ type: Boolean,
111
+ value: false,
112
+ },
113
+ sendingGoodId: {
114
+ type: String,
115
+ value: '',
116
+ },
117
+ },
118
+ data: {
119
+ goodsInfo: [],
120
+ page_size: 5,
121
+ page_index: 1,
122
+ total: 0,
123
+ refreshing: false,
124
+ finishedTxt: '加载中',
125
+ finished: false,
126
+ sendingIndex: -1,
127
+ sending: false,
128
+ selectGoods: [], // 多选列表
129
+ is_jurisdiction: false, // 操作权限
130
+ isSplitSelect: false, // 当前是否是单独勾选
131
+ selectGoodsIndexArr: [], // 当前已经选中的商品索引数组
132
+ is_show_now: 0, //当前已展示的数量
133
+ is_hide_now: 0, // 当前已隐藏的数量
134
+ isDisabled: false, // 复选框是否禁用
135
+ selectId: '', // 当前点击那一项的goodsId
136
+ goodsSwitch: 0, // 带货开关
137
+ goodsSwitchOld: -1, // 带货开关旧值,用于区分im上面switch是否是打开还是普通增删改
138
+ },
139
+ lifetimes: {
140
+ // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
141
+ attached: function () {
142
+ this.setData({
143
+ goodsSwitch: this.data.aliveConf.is_takegoods,
144
+ goodsSwitchOld: this.data.aliveConf.is_takegoods,
145
+ })
146
+ },
147
+ moved: function () { },
148
+ detached: function () { },
149
+ },
150
+ methods: {
151
+ // "sync_goods":{
152
+ // "switch":0,//开关:0关1开
153
+ // //带货配置列表-最多六条
154
+ // "conf_list":[],
155
+ // "update_list":[],
156
+ // //移除资源id
157
+ // "batch_del":["p_63845d8be4b07b05581ebf47"],
158
+ // //批量显示隐藏
159
+ // "batch_switch":[]
160
+ // }
161
+ /**
162
+ * 带货/优惠券实时同步
163
+ * @param {object} msgData im消息体
164
+ * @param {string} type 消息类型:带货goods、优惠券coupon
165
+ */
166
+ handlerListInfo(msgData) {
167
+ let type = '',
168
+ marketInfo = []
169
+ // 遍历获取操作类型
170
+ for (let key in msgData) {
171
+ switch (key) {
172
+ // 带货开关操作
173
+ case "switch":
174
+ type = "goodsSwitch";
175
+ marketInfo = Number(msgData[key]);
176
+ break;
177
+ // 新增操作
178
+ case 'conf_list':
179
+ type = 'goodsConfList'
180
+ marketInfo = msgData[key]
181
+ break
182
+ // 修改操作
183
+ case 'update_list':
184
+ type = 'goodsUpdateList'
185
+ marketInfo = msgData[key]
186
+ break
187
+ // 删除操作
188
+ case 'batch_del':
189
+ type = 'goodsDelList'
190
+ marketInfo = msgData[key]
191
+ break
192
+ // 显隐操作
193
+ case 'batch_switch':
194
+ type = 'goodsBatchSwitchList'
195
+ marketInfo = msgData[key]
196
+ break
197
+ default:
198
+ break
199
+ }
200
+ console.log('[teacherGoodList] 带货实时同步im: ', type, marketInfo)
201
+ if (marketInfo?.length > 0 || ["goodsSwitch"].includes(type)) {
202
+ this.changeGoodsList(type, marketInfo)
203
+ type = ''
204
+ marketInfo = []
205
+ }
206
+ }
207
+ },
208
+ // 处理实时同步的带货逻辑
209
+ changeGoodsList(type, marketInfo) {
210
+ let goodsInfo = this.data.goodsInfo,
211
+ delIndex = -1, // 删除数据的当前下标
212
+ selectGoods = this.data.selectGoods, // 批量隐藏数组id
213
+ selectGoodsIndexArr = this.data.selectGoodsIndexArr, // 批量隐藏数组索引
214
+ total = this.data.total, // 管理商品总数
215
+ isHasGoods = false // 是否已有这个商品
216
+ switch (type) {
217
+ // 带货和优惠券开关操作
218
+ case "goodsSwitch":
219
+ if ([0, 1].includes(marketInfo)) this.setData({ goodsSwitch: marketInfo })
220
+ break;
221
+ case 'goodsConfList':
222
+ // 如果已经加载完了,可以拼接数据
223
+ // 由于看不出为何触发了两次,做id过滤
224
+ if (this.data.finished || this.data.finishedTxt === "no-data") {
225
+ marketInfo.map((item) => {
226
+ for (let index = 0; index < goodsInfo.length; index++) {
227
+ if (item.id === goodsInfo[index].id) {
228
+ isHasGoods = true;
229
+ break
230
+ }
231
+ }
232
+ if (!isHasGoods) {
233
+ // 管理商品需要增加
234
+ total++
235
+ this.formatData([item]);
236
+ }
237
+ isHasGoods = false;
238
+ })
239
+ this.setData({
240
+ finished: true,
241
+ finishedTxt: "没有更多了",
242
+ is_jurisdiction: this.data.goodsInfo[0] ? this.data.goodsInfo[0].teacher_auth == 2 : false
243
+ })
244
+ }
245
+ break
246
+ case 'goodsUpdateList':
247
+ case 'goodsBatchSwitchList':
248
+ marketInfo.map((item) => {
249
+ for (let index = 0; index < goodsInfo.length; index++) {
250
+ if (item.id === goodsInfo[index].id) {
251
+ // 遍历插入相应的修改值
252
+ for (let key in item) {
253
+ goodsInfo[index][key] = item[key]
254
+ }
255
+ break
256
+ }
257
+ }
258
+ })
259
+ this.formatData(goodsInfo, true);
260
+ break
261
+ case 'goodsDelList':
262
+ marketInfo.map((id) => {
263
+ for (let index = 0; index < goodsInfo.length; index++) {
264
+ if (id === goodsInfo[index].id) {
265
+ // 删除操作,获取下标
266
+ goodsInfo.splice(index, 1)
267
+ delIndex = index
268
+ index--
269
+ // 管理商品需要减少
270
+ total--
271
+ }
272
+ // 删除后,后面的数据都要权重+1显示
273
+ if (delIndex > -1 && index >= delIndex) {
274
+ goodsInfo[index].order_weight--
275
+ }
276
+ }
277
+ // 重置删除下标
278
+ delIndex = -1
279
+
280
+ // 此处处理批量显隐的,删掉了,需要把选择的也删掉
281
+ if (selectGoodsIndexArr.length > 0) {
282
+ for (let index = 0; index < selectGoodsIndexArr.length; index++) {
283
+ if (id === selectGoodsIndexArr[index]) {
284
+ // 删除操作,获取下标
285
+ selectGoodsIndexArr.splice(index, 1)
286
+ selectGoods.splice(index, 1)
287
+ index--
288
+ }
289
+ }
290
+ }
291
+ })
292
+ this.formatData(goodsInfo, true);
293
+ if (this.data.goodsInfo.length === 0) {
294
+ // 确保第一页没有了数据
295
+ this._freshing = true
296
+ this.setData({
297
+ finished: false,
298
+ page_index: 1
299
+ })
300
+ this.getGoodsList()
301
+ }
302
+ break
303
+ default:
304
+ break
305
+ }
306
+ this.setData({
307
+ total,
308
+ selectGoods,
309
+ selectGoodsIndexArr,
310
+ }, () => {
311
+ if (!this.data.total) this.triggerEvent("isNullDate")
312
+ })
313
+ },
314
+ // 管理商品多选
315
+ onChange(e) {
316
+ // this.setData({
317
+ // selectGoods:e.detail
318
+ // })
319
+ let tempGoodsArr = []
320
+ e.detail.forEach((item) => {
321
+ for (let index = 0; index < this.data.goodsInfo.length; index++) {
322
+ if (item === this.data.goodsInfo[index].id) {
323
+ tempGoodsArr.push(this.data.goodsInfo[index])
324
+ break
325
+ }
326
+ }
327
+ })
328
+ this.setData({
329
+ selectGoods: tempGoodsArr,
330
+ selectGoodsIndexArr: e.detail,
331
+ })
332
+ },
333
+
334
+ // 显示隐藏
335
+ // 商品显隐操作
336
+ changeShowType(e) {
337
+ let { type } = e.target.dataset
338
+ // 未选择商品
339
+ if (!this.data.selectGoods.length) {
340
+ this.showToast('请先选择商品')
341
+ return
342
+ }
343
+
344
+ // 商品是否已是对应的显隐状态
345
+ this.data.selectGoods.forEach((item) => {
346
+ if (item.is_display_package && type === 'show') {
347
+ this.setData({
348
+ is_show_now: this.data.is_show_now + 1,
349
+ })
350
+ } else if (!item.is_display_package && type === 'hide') {
351
+ this.setData({
352
+ is_hide_now: this.data.is_hide_now + 1,
353
+ })
354
+ }
355
+ })
356
+ if (type === 'show') {
357
+ if (this.data.is_show_now === this.data.selectGoods.length) {
358
+ this.showToast('当前选择的商品已显示')
359
+ this.setData({
360
+ is_show_now: 0,
361
+ })
362
+ return
363
+ } else {
364
+ this.requestChangeShow(1)
365
+ return
366
+ }
367
+ }
368
+
369
+ // 隐藏商品确认弹窗
370
+ if (type === 'hide') {
371
+ if (this.data.is_hide_now === this.data.selectGoods.length) {
372
+ this.showToast('当前选择的商品已隐藏')
373
+ this.setData({
374
+ is_hide_now: 0,
375
+ })
376
+ return
377
+ } else {
378
+ wx.showModal({
379
+ title: `确认隐藏${this.data.is_hide_now
380
+ ? this.data.selectGoods.length - this.data.is_hide_now
381
+ : this.data.selectGoods.length
382
+ }个商品吗`,
383
+ content: '用户端商品列表不展示已隐藏商品,讲师仍可通过讲解发送商品',
384
+ confirmText: '确认',
385
+ cancelText: '取消',
386
+ confirmColor: '#1472FF',
387
+ success: (res) => {
388
+ if (res.confirm) {
389
+ this.requestChangeShow(0)
390
+ } else if (res.cancel) {
391
+ this.setData({
392
+ is_hide_now: 0,
393
+ })
394
+ }
395
+ },
396
+ })
397
+ return
398
+ }
399
+ }
400
+ },
401
+
402
+ // 商品显隐请求
403
+ requestChangeShow(state) {
404
+ const tempSelectGoodsArr = this.data.selectGoods.map((item) => ({
405
+ id: item.id,
406
+ type: item.true_type,
407
+ }))
408
+ const loginData = wx.getStorageSync('login_data')
409
+ let params = {
410
+ alive_id: this.data.aliveInfo.alive_id,
411
+ app_id: this.data.aliveInfo.app_id,
412
+ resource_ids: tempSelectGoodsArr,
413
+ is_display_package: state,
414
+ token: loginData.token,
415
+ }
416
+
417
+ requestChangeShow(params, false).then((res) => {
418
+ let { code } = res.data
419
+ if (code === 0) {
420
+ // let temp = `marketResource.courseList[${this.data.selectIndex}].is_display_package`
421
+ // 操作成功之后,要把当前选中的商品改变状态
422
+ let temp = ''
423
+ this.data.selectGoodsIndexArr.forEach((item) => {
424
+ for (let index = 0; index < this.data.goodsInfo.length; index++) {
425
+ if (item === this.data.goodsInfo[index].id) {
426
+ temp = `goodsInfo[${index}].is_display_package`
427
+ break
428
+ }
429
+ }
430
+ this.setData({
431
+ [temp]: state,
432
+ })
433
+ })
434
+ this.setData({
435
+ selectGoodsIndexArr: [],
436
+ selectGoods: [],
437
+ is_hide_now: 0,
438
+ is_show_now: 0,
439
+ })
440
+ this.showToast('操作成功')
441
+ } else {
442
+ this.setData({
443
+ is_hide_now: 0,
444
+ is_show_now: 0,
445
+ })
446
+ this.showToast('操作失败')
447
+ }
448
+ })
449
+ },
450
+
451
+ // 商品总活动倒计时
452
+ startActivityCountdown(list) {
453
+
454
+ clearInterval(activityCountdownTimer)
455
+ activityCountdownTimer = setInterval(() => {
456
+ hadActivity = false
457
+ list.forEach((i) => {
458
+ let targetDate = new Date(i.time.replace(/-/g, '/')).getTime() - new Date().getTime()
459
+ if (targetDate <= 0) return
460
+ hadActivity = true
461
+ let temp = `goodsInfo[${i.index}].activityCountdown`
462
+ this.setData({
463
+ [temp]: targetDate,
464
+ })
465
+ })
466
+ if (!hadActivity) {
467
+ clearInterval(activityCountdownTimer)
468
+ activityCountdownTimer = null
469
+ }
470
+ }, 1000)
471
+ },
472
+ // 预热倒计时
473
+ startPreheatCountdown(list) {
474
+ clearInterval(preheatTimer)
475
+ preheatTimer = setInterval(() => {
476
+ hadPreheat = false
477
+ list.forEach((i) => {
478
+ let targetDate = new Date(i.time.replace(/-/g, '/')).getTime() - new Date().getTime()
479
+ if (targetDate <= 0) {
480
+ activityList.push({
481
+ time: this.data.goodsInfo[i.index].end_at,
482
+ index: i.index,
483
+ })
484
+ this.setData({
485
+ [`goodsInfo[${i.index}].preheatTime`]: 0,
486
+ })
487
+ return
488
+ }
489
+ hadPreheat = true
490
+ let temp = `goodsInfo[${i.index}].preheatTime`
491
+ this.setData({
492
+ [temp]: targetDate,
493
+ })
494
+ })
495
+ if (!hadPreheat) {
496
+ clearInterval(preheatTimer)
497
+ preheatTimer = null
498
+ }
499
+ }, 1000)
500
+ },
501
+ onLoad() {
502
+ if (!this.data.aliveConf.is_takegoods) {
503
+ this.setData({
504
+ refreshing: false
505
+ })
506
+ return
507
+ }
508
+ if (this._freshing) return
509
+ this._freshing = true
510
+ this.setData({
511
+ finished: false,
512
+ page_index: 1
513
+ })
514
+ this.getGoodsList()
515
+ },
516
+ onScrolltolower() {
517
+ if (this.scrolling || this.data.finishedTxt === 'no-data' || !this.data.aliveConf.is_takegoods || this.data.finished) { return }
518
+ this.scrolling = true
519
+ this.setData({
520
+ finishedTxt: this.data.finished ? "没有更多了" : "加载中"
521
+ })
522
+ if (this.data.finished || this._freshing) {
523
+ return
524
+ }
525
+ this.getGoodsList()
526
+ },
527
+ getGoodsList() {
528
+ let params = {
529
+ alive_id: this.data.aliveInfo.alive_id,
530
+ type: 1,
531
+ page_size: this.data.page_size,
532
+ page: this.data.page_index,
533
+ port: 2
534
+ }
535
+ getGoodsList(params).then(res => {
536
+ let { data, code } = res.data
537
+ if (code === 0) {
538
+ var total = data[0] ? data[0].total : this.data.total
539
+ var finishedTxt = "加载中"
540
+ var finished = false
541
+ let is_jurisdiction = data[0] ? data[0].teacher_auth == 2 : false
542
+
543
+ if (this._freshing) {
544
+ //下拉加载直接赋值
545
+ this.formatData(data, true)
546
+ } else {
547
+ this.formatData(data)
548
+ }
549
+ // 下拉加载,且数据返回空
550
+ if (this._freshing && data.length === 0) {
551
+ finishedTxt = "no-data"
552
+ } else if (this.data.goodsInfo.length >= total || data.length === 0) {
553
+ // 获取到所有数据
554
+ finished = true// 没有更多了
555
+ finishedTxt = "没有更多了"
556
+ this.setData({ finishedTxt })
557
+ } else {
558
+ finishedTxt = "加载中"
559
+ }
560
+ this.setData({
561
+ refreshing: false,
562
+ page_index: this.data.page_index + 1,
563
+ finishedTxt,
564
+ finished,
565
+ total,
566
+ is_jurisdiction
567
+ })
568
+ this._freshing = false
569
+ this.scrolling = false
570
+ }
571
+ })
572
+ },
573
+ formatData(data, refreshing = false) {
574
+ let goodsInfo = this.data.goodsInfo
575
+ data.forEach((item, index) => {
576
+ this.formatItem(item)
577
+ if (!refreshing && item.id) {
578
+ goodsInfo.push(item)
579
+ }
580
+ })
581
+ if (refreshing) {
582
+ //下拉刷新的时候直接赋值
583
+ goodsInfo = JSON.parse(JSON.stringify(data))
584
+ }
585
+ this.setData({
586
+ goodsInfo
587
+ }, () => {
588
+ this.getActivityStatus(this.data.goodsInfo)
589
+ })
590
+ },
591
+ getActivityStatus(data) {
592
+ activityList = []
593
+ preheatList = []
594
+ data.forEach((item, index) => {
595
+ if (item.is_activity && item.end_at) {
596
+ hasActivity = true
597
+ item.activityCountdown = 0
598
+ activityList.push({
599
+ time: item.end_at,
600
+ index,
601
+ })
602
+ }
603
+ // this.data.isSeckill && this.data.preheating
604
+ if (item.activity_type === 8 && item.sec_kill_is_preheat === 1) {
605
+ //预热开始时间
606
+ let startTime = (item.start_at && new Date(item.start_at.replace(/-/g, '/'))) || new Date()
607
+ let times = startTime.getTime() - item.sec_kill_preheat_time * 1000
608
+ let preHeatTime = new Date(times) || new Date()
609
+
610
+ let startTime2 = (item.start_at && new Date(item.start_at.replace(/-/g, '/'))) || new Date()
611
+ let nowTime = new Date().getTime()
612
+ let preheating = nowTime > preHeatTime.getTime() && startTime2.getTime() > nowTime
613
+
614
+ if (preheating) {
615
+ hasPreheat = true
616
+ item.preheatTime = 0
617
+ preheatList.push({
618
+ time: item.start_at,
619
+ index,
620
+ })
621
+ }
622
+ }
623
+ })
624
+ if (hasActivity) this.startActivityCountdown(activityList) //活动倒计时
625
+ if (hasPreheat) this.startPreheatCountdown(preheatList) // 预热倒计时
626
+ },
627
+ formatItem(e) {
628
+ e.resourceTypeName = e.resource_type_name // 商品类型
629
+ e.leftStock = e.is_activity && e.now_stock ? e.now_stock : e.stock // 商品库存,活动中且有活动库存就用活动库存
630
+ // 处理未到活动时间的限时折扣
631
+ if (e.activity_type === 3) {
632
+ let nowTime = new Date().getTime()
633
+ let startTime = new Date(e.start_at.replace(/-/g, "/")).getTime()
634
+ let isStart = !!(nowTime - startTime > 0)
635
+ if (!isStart) {
636
+ e.is_activity = 0 // 未到活动时间的限时折扣 不参与比价
637
+ }
638
+ }
639
+ // 预热前和活动结束后的秒杀不参与比价
640
+ if (e.activity_type === 8) {
641
+ let startTime = new Date(e.start_at.replace(/-/g, "/")).getTime()
642
+ let preHeatTime = startTime - e.sec_kill_preheat_time * 1000 // 预热开始时间
643
+ let nowTime = new Date().getTime()
644
+ let isStartPreHeat = !!(nowTime - preHeatTime > 0) // 预热时间到了
645
+ let endTime = new Date(e.end_at.replace(/-/g, "/")).getTime()
646
+ let isEndSecKill = !!(nowTime - endTime > 0) // 秒杀活动结束了
647
+ if (!isStartPreHeat || isEndSecKill) {
648
+ e.is_activity = 0 // 预热前和活动结束后的秒杀 不参与比价
649
+ }
650
+ }
651
+ //展示购买价处理;取原价、营销活动价、超级会员价到一个数组从小到大排序,最低为购买价。防止价格一样,所以加了权重比较
652
+ let arr = []
653
+ arr.push({
654
+ active: "",
655
+ price: e.price,
656
+ weight: e.price + 0.0003,
657
+ })
658
+ // 活动管理、实物商品、有价优惠券、线下课和课时包不能设置活动库存,其他可以设置活动库存得需要判断是否还剩余活动库存;拼团也不能设置活动库存。
659
+ let notExistNowStock = [9, 21, 41, 29, 42].indexOf(e.resource_type) > -1
660
+ e.is_activity &&
661
+ (notExistNowStock ||
662
+ typeof e.now_stock === "number" ||
663
+ e.activity_type === 6) &&
664
+ arr.push({
665
+ //参与营销活动且有活动库存的时候加入比较 now_stock -""空字符串的时候代表已经买完 -0代表不限量
666
+ active: MARKET_ACTIVITY_MAP[e.activity_type],
667
+ price: e.activity_price,
668
+ weight: e.activity_price + 0.0001,
669
+ })
670
+ e.svip_price &&
671
+ arr.push({
672
+ //判断超级会员价
673
+ active: "超级会员",
674
+ price: e.svip_price,
675
+ weight: e.svip_price + 0.0002,
676
+ })
677
+ arr.sort((a, b) => a.weight - b.weight)
678
+ let svipAllFree = e.resource_rights_type === 1
679
+ e.priceShow = arr[0].price //展示的购买价格
680
+ e.priceShowInt = svipAllFree ? this.priceInt(e.price) : this.priceInt(e.priceShow) // 展示价格的整数部分
681
+ e.priceShowFlow = svipAllFree ? this.priceFlow(e.price) : this.priceFlow(e.priceShow) // 展示是价格的小数部分
682
+ e.preferentialShowInt = this.priceInt(e.preferential_price) // 展示券后价的整数部分
683
+ e.preferentialShowFlow = this.priceFlow(e.preferential_price) // 展示券后价的小数部分
684
+ e.currentActive = arr[0].active //当前适用得营销模式;有可能是原价,超级会员,营销活动
685
+ //展示划线价处理;有营销活动、超级会员,划线价是原价;只有原价和原划线价,划线价是原划线价;
686
+ if (e.currentActive !== "") {
687
+ e.priceLine = e.price
688
+ } else {
689
+ e.priceLine = e.line_price || 0 //未设置原划线价的时候不展示划线价
690
+ }
691
+ e.priceLineShowInt = this.priceInt(e.priceLine) // 展示划线价的整数部分
692
+ e.priceLineShowFlow = this.priceFlow(e.priceLine) // 展示划线的小数部分
693
+ e.entityShowStock = (e.resource_type === 21 || e.resource_type === 41 || e.resource_type === 68) && e.show_stock // 实物商品库存依赖 B端店铺设置(show_stock):详情页展示不展示剩余件数
694
+ e.hasStock = [29, 35].indexOf(e.resource_type) > -1 || e.entityShowStock || e.now_stock // 班课、线下课、实物商品、体验课、有活动库存,满足其一即展示库存
695
+ },
696
+ priceInt(val) {
697
+ val = Number(val)
698
+ return ((val / 100).toFixed(2) + '').split('.')[0]
699
+ },
700
+ priceFlow(val) {
701
+ val = Number(val)
702
+ return ((val / 100).toFixed(2) + '').split('.')[1] || '00'
703
+ },
704
+ closePop() {
705
+ this.triggerEvent("closePop")
706
+ },
707
+ preventScroll() {
708
+ return
709
+ },
710
+ sendGoodsCard(e) {
711
+ console.log("npm", e)
712
+ let dataset = e.detail.datas;
713
+ this.setData({
714
+ sending: true,
715
+ sendingIndex: dataset['index']
716
+ })
717
+ // 触发父组件的send
718
+ this.triggerEvent('sendGoodsCard', {
719
+ datas: dataset
720
+ });
721
+ },
722
+ clear() {
723
+ this.setData({
724
+ goodsInfo: [],
725
+ finishedTxt: "no-data"
726
+ })
727
+ },
728
+ setIsTakeGoods(value) {
729
+ this.setData({
730
+ ["aliveConf.is_takegoods"]: value
731
+ })
732
+ },
733
+ deleteGood(id) {
734
+ let deleteGoodIndex;
735
+ if (!this.data.goodsInfo) return;
736
+ this.data.goodsInfo.forEach((goods, index) => {
737
+ if (goods.id === id) {
738
+ deleteGoodIndex = index;
739
+ }
740
+ })
741
+ deleteGoodIndex !== undefined && this.data.goodsInfo.splice(deleteGoodIndex, 1)
742
+ this.setData({
743
+ goodsInfo: this.data.goodsInfo
744
+ })
745
+ },
746
+ selectToast(e) {
747
+ let tempItemIndex = e.currentTarget.dataset.item
748
+ this.setData({
749
+ selectId: this.data.goodsInfo[tempItemIndex].id
750
+ })
751
+ if (this.data.selectGoodsIndexArr.length >= 10 && this.data.selectGoodsIndexArr.indexOf(this.data.selectId) === -1) {
752
+ this.showToast('批量操作最多支持10条')
753
+ } else {
754
+ return
755
+ }
756
+ },
757
+ showToast(title = '') {
758
+ wx.showToast({
759
+ title,
760
+ icon: 'none',
761
+ duration: 1000,
762
+ })
763
+ },
764
+ },
765
+ observers: {
766
+ // 监听点击发送事件
767
+ "changState.time": function (newVal) {
768
+ // 处理成功回调,主要用于变更按钮发送状态
769
+ console.log('changState', newVal, this.properties.changState)
770
+ let state = this.properties.changState
771
+ if (state && state.index != -1) {
772
+ this.setData({
773
+ sending: false,
774
+ sendingIndex: state.index
775
+ })
776
+ }
777
+ },
778
+ "total": function (newVal) {
779
+ this.triggerEvent("totalChange", newVal)
780
+ },
781
+ "isManage": function (newVal) {
782
+ this.setData({
783
+ selectGoods: []
784
+ })
785
+ },
786
+ "is_jurisdiction": function (newVal) {
787
+ this.triggerEvent("jurisdictionChange", newVal)
788
+ },
789
+ "goodsSwitch": function (newVal) {
790
+ if (this.data.goodsSwitchOld === 0 && newVal === 1 && this.data.showList) {
791
+ this._freshing = true
792
+ this.setData({
793
+ finished: false,
794
+ page_index: 1
795
+ })
796
+ this.getGoodsList()
797
+ } else if (newVal === 0) {
798
+ this.triggerEvent("closePopup")
799
+ this.triggerEvent("isNullDate")
800
+ this.setData({
801
+ goodsInfo: [],
802
+ page_size: 5,
803
+ page_index: 1,
804
+ total: 0,
805
+ refreshing: false,
806
+ finished: false,
807
+ sendingIndex: -1,
808
+ sending: false,
809
+ selectGoods: [], // 多选列表
810
+ is_jurisdiction: false, // 操作权限
811
+ isSplitSelect: false, // 当前是否是单独勾选
812
+ selectGoodsIndexArr: [], // 当前已经选中的商品索引数组
813
+ is_show_now: 0, //当前已展示的数量
814
+ is_hide_now: 0, // 当前已隐藏的数量
815
+ isDisabled: false, // 复选框是否禁用
816
+ selectId: '', // 当前点击那一项的goodsId
817
+ })
818
+ }
819
+ // 设置一下本次更改的开关值
820
+ this.setData({
821
+ goodsSwitchOld: newVal
822
+ })
823
+ },
824
+ },
825
+ })