vhall-mini-sdk 0.1.0 → 0.1.2

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 (280) hide show
  1. package/lib/components/chat/chat-edit/chat-edit.js +7 -4
  2. package/lib/components/chat/chat-list/chat-list.js +1 -1
  3. package/lib/components/live-landscape/live-landscape.js +11 -7
  4. package/lib/components/live-landscape/live-landscape.wxml +2 -2
  5. package/lib/components/live-portrait/live-portrait.js +11 -7
  6. package/lib/components/live-portrait/live-portrait.wxml +3 -3
  7. package/lib/components/live-portrait/live-portrait.wxss +1 -1
  8. package/lib/components/lottery/lottery.wxml +2 -2
  9. package/lib/components/player/components/online-hot/index.js +2 -2
  10. package/lib/components/player/extensions/observers.js +5 -5
  11. package/lib/components/player/player.js +5 -0
  12. package/lib/components/player/player.wxml +3 -3
  13. package/lib/components/product/product-list/product-list.wxml +3 -11
  14. package/lib/components/signin/signin-dialog.js +1 -0
  15. package/lib/sdk/main/index.js +2 -1
  16. package/lib/sdk/player/index.js +1 -1
  17. package/lib/sdk/plugins/InviteCardServer.js +1 -1
  18. package/lib/sdk/plugins/MallRewardServer.js +1 -1
  19. package/lib/sdk/plugins/ProductServer.js +1 -1
  20. package/lib/shared/RequestUtil.js +1 -1
  21. package/lib/shared/logger.js +1 -1
  22. package/package.json +2 -4
  23. package/postinstall.js +21 -51
  24. package/dist/components/chat/chat-edit/chat-edit.js +0 -127
  25. package/dist/components/chat/chat-edit/chat-edit.json +0 -4
  26. package/dist/components/chat/chat-edit/chat-edit.wxml +0 -7
  27. package/dist/components/chat/chat-edit/chat-edit.wxss +0 -1
  28. package/dist/components/chat/chat-item/chat-item.js +0 -253
  29. package/dist/components/chat/chat-item/chat-item.json +0 -3
  30. package/dist/components/chat/chat-item/chat-item.wxml +0 -96
  31. package/dist/components/chat/chat-item/chat-item.wxss +0 -1
  32. package/dist/components/chat/chat-list/chat-list.js +0 -216
  33. package/dist/components/chat/chat-list/chat-list.json +0 -6
  34. package/dist/components/chat/chat-list/chat-list.wxml +0 -9
  35. package/dist/components/chat/chat-list/chat-list.wxss +0 -1
  36. package/dist/components/chat/chat.js +0 -98
  37. package/dist/components/chat/chat.json +0 -7
  38. package/dist/components/chat/chat.wxml +0 -7
  39. package/dist/components/chat/chat.wxss +0 -1
  40. package/dist/components/gift/gift-display/gift-display.js +0 -118
  41. package/dist/components/gift/gift-display/gift-display.json +0 -3
  42. package/dist/components/gift/gift-display/gift-display.wxml +0 -16
  43. package/dist/components/gift/gift-display/gift-display.wxss +0 -1
  44. package/dist/components/gift/gift-sender/gift-sender.js +0 -63
  45. package/dist/components/gift/gift-sender/gift-sender.json +0 -6
  46. package/dist/components/gift/gift-sender/gift-sender.wxml +0 -19
  47. package/dist/components/gift/gift-sender/gift-sender.wxss +0 -1
  48. package/dist/components/introduction/introduction.js +0 -43
  49. package/dist/components/introduction/introduction.json +0 -3
  50. package/dist/components/introduction/introduction.wxml +0 -8
  51. package/dist/components/introduction/introduction.wxss +0 -1
  52. package/dist/components/invite-rank/img/bronze.png +0 -0
  53. package/dist/components/invite-rank/img/gold.png +0 -0
  54. package/dist/components/invite-rank/img/silver.png +0 -0
  55. package/dist/components/invite-rank/index.js +0 -135
  56. package/dist/components/invite-rank/index.json +0 -8
  57. package/dist/components/invite-rank/index.wxml +0 -42
  58. package/dist/components/invite-rank/index.wxss +0 -1
  59. package/dist/components/invite-rank/invite-rank-item.js +0 -12
  60. package/dist/components/invite-rank/invite-rank-item.json +0 -4
  61. package/dist/components/invite-rank/invite-rank-item.wxml +0 -21
  62. package/dist/components/invite-rank/invite-rank-item.wxss +0 -1
  63. package/dist/components/invite-rank/my-invite-detail.js +0 -82
  64. package/dist/components/invite-rank/my-invite-detail.json +0 -7
  65. package/dist/components/invite-rank/my-invite-detail.wxml +0 -27
  66. package/dist/components/invite-rank/my-invite-detail.wxss +0 -1
  67. package/dist/components/invite-rank/util.wxs +0 -21
  68. package/dist/components/live-landscape/live-landscape.js +0 -216
  69. package/dist/components/live-landscape/live-landscape.json +0 -39
  70. package/dist/components/live-landscape/live-landscape.wxml +0 -73
  71. package/dist/components/live-landscape/live-landscape.wxss +0 -1
  72. package/dist/components/live-portrait/live-portrait.js +0 -274
  73. package/dist/components/live-portrait/live-portrait.json +0 -38
  74. package/dist/components/live-portrait/live-portrait.wxml +0 -106
  75. package/dist/components/live-portrait/live-portrait.wxss +0 -1
  76. package/dist/components/lottery/lottery-accept/index.js +0 -249
  77. package/dist/components/lottery/lottery-accept/index.json +0 -4
  78. package/dist/components/lottery/lottery-accept/index.wxml +0 -49
  79. package/dist/components/lottery/lottery-accept/index.wxss +0 -1
  80. package/dist/components/lottery/lottery-history/index.js +0 -36
  81. package/dist/components/lottery/lottery-history/index.json +0 -3
  82. package/dist/components/lottery/lottery-history/index.wxml +0 -28
  83. package/dist/components/lottery/lottery-history/index.wxss +0 -1
  84. package/dist/components/lottery/lottery-shake/lottery-shake.js +0 -328
  85. package/dist/components/lottery/lottery-shake/lottery-shake.json +0 -1
  86. package/dist/components/lottery/lottery-shake/lottery-shake.wxml +0 -52
  87. package/dist/components/lottery/lottery-shake/lottery-shake.wxss +0 -1
  88. package/dist/components/lottery/lottery-slot/lottery-slot.js +0 -230
  89. package/dist/components/lottery/lottery-slot/lottery-slot.json +0 -1
  90. package/dist/components/lottery/lottery-slot/lottery-slot.wxml +0 -62
  91. package/dist/components/lottery/lottery-slot/lottery-slot.wxss +0 -1
  92. package/dist/components/lottery/lottery-wheel/lottery-wheel.js +0 -153
  93. package/dist/components/lottery/lottery-wheel/lottery-wheel.json +0 -4
  94. package/dist/components/lottery/lottery-wheel/lottery-wheel.wxml +0 -91
  95. package/dist/components/lottery/lottery-wheel/lottery-wheel.wxss +0 -1
  96. package/dist/components/lottery/lottery-winners/index.js +0 -101
  97. package/dist/components/lottery/lottery-winners/index.json +0 -4
  98. package/dist/components/lottery/lottery-winners/index.wxml +0 -39
  99. package/dist/components/lottery/lottery-winners/index.wxss +0 -1
  100. package/dist/components/lottery/lottery.js +0 -388
  101. package/dist/components/lottery/lottery.json +0 -11
  102. package/dist/components/lottery/lottery.wxml +0 -78
  103. package/dist/components/lottery/lottery.wxss +0 -1
  104. package/dist/components/lottery/wheel.json +0 -49
  105. package/dist/components/mall-reward/common/reward-card.wxss +0 -0
  106. package/dist/components/mall-reward/duration-icon/index.js +0 -101
  107. package/dist/components/mall-reward/duration-icon/index.json +0 -3
  108. package/dist/components/mall-reward/duration-icon/index.wxml +0 -7
  109. package/dist/components/mall-reward/duration-icon/index.wxss +0 -1
  110. package/dist/components/mall-reward/f-count-down/index.js +0 -61
  111. package/dist/components/mall-reward/f-count-down/index.json +0 -3
  112. package/dist/components/mall-reward/f-count-down/index.wxml +0 -9
  113. package/dist/components/mall-reward/f-count-down/index.wxss +0 -1
  114. package/dist/components/mall-reward/f-empty/index.js +0 -11
  115. package/dist/components/mall-reward/f-empty/index.json +0 -3
  116. package/dist/components/mall-reward/f-empty/index.wxml +0 -8
  117. package/dist/components/mall-reward/f-empty/index.wxss +0 -1
  118. package/dist/components/mall-reward/f-history/index.js +0 -84
  119. package/dist/components/mall-reward/f-history/index.json +0 -4
  120. package/dist/components/mall-reward/f-history/index.wxml +0 -38
  121. package/dist/components/mall-reward/f-history/index.wxss +0 -1
  122. package/dist/components/mall-reward/f-open/index.js +0 -36
  123. package/dist/components/mall-reward/f-open/index.json +0 -3
  124. package/dist/components/mall-reward/f-open/index.wxml +0 -10
  125. package/dist/components/mall-reward/f-open/index.wxss +0 -1
  126. package/dist/components/mall-reward/f-receive/index.js +0 -36
  127. package/dist/components/mall-reward/f-receive/index.json +0 -3
  128. package/dist/components/mall-reward/f-receive/index.wxml +0 -9
  129. package/dist/components/mall-reward/f-receive/index.wxss +0 -1
  130. package/dist/components/mall-reward/index.js +0 -374
  131. package/dist/components/mall-reward/index.json +0 -8
  132. package/dist/components/mall-reward/index.wxml +0 -4
  133. package/dist/components/mall-reward/index.wxss +0 -0
  134. package/dist/components/mall-reward/main-popup/index.js +0 -46
  135. package/dist/components/mall-reward/main-popup/index.json +0 -12
  136. package/dist/components/mall-reward/main-popup/index.wxml +0 -16
  137. package/dist/components/mall-reward/main-popup/index.wxss +0 -1
  138. package/dist/components/player/assets/image/arrow-left.png +0 -0
  139. package/dist/components/player/assets/image/arrow-right.png +0 -0
  140. package/dist/components/player/assets/image/enterFullScreen.png +0 -0
  141. package/dist/components/player/assets/image/exitFullScreen.png +0 -0
  142. package/dist/components/player/assets/image/fullscreen_1.png +0 -0
  143. package/dist/components/player/assets/image/fullscreen_2.png +0 -0
  144. package/dist/components/player/assets/image/pause.png +0 -0
  145. package/dist/components/player/assets/image/pause_1.png +0 -0
  146. package/dist/components/player/assets/image/play.png +0 -0
  147. package/dist/components/player/assets/image/play_1.png +0 -0
  148. package/dist/components/player/assets/image/refresh.png +0 -0
  149. package/dist/components/player/assets/image/refresh_1.png +0 -0
  150. package/dist/components/player/assets/image/subtitle_close.png +0 -0
  151. package/dist/components/player/assets/image/subtitle_default.png +0 -0
  152. package/dist/components/player/assets/image/volume-off.png +0 -0
  153. package/dist/components/player/assets/image/volume-on.png +0 -0
  154. package/dist/components/player/common/config.js +0 -7
  155. package/dist/components/player/common/veComponent.js +0 -4
  156. package/dist/components/player/components/barrage/barrage-canvas.js +0 -488
  157. package/dist/components/player/components/barrage/barrage-dom.js +0 -471
  158. package/dist/components/player/components/barrage/index.js +0 -62
  159. package/dist/components/player/components/barrage/index.json +0 -4
  160. package/dist/components/player/components/barrage/index.wxml +0 -39
  161. package/dist/components/player/components/barrage/index.wxss +0 -1
  162. package/dist/components/player/components/barrage/utils.js +0 -71
  163. package/dist/components/player/components/controls/controls.js +0 -93
  164. package/dist/components/player/components/controls/controls.json +0 -6
  165. package/dist/components/player/components/controls/controls.wxml +0 -60
  166. package/dist/components/player/components/controls/controls.wxss +0 -1
  167. package/dist/components/player/components/danmaku/danmaku.js +0 -23
  168. package/dist/components/player/components/danmaku/danmaku.json +0 -4
  169. package/dist/components/player/components/danmaku/danmaku.wxml +0 -1
  170. package/dist/components/player/components/danmaku/danmaku.wxss +0 -0
  171. package/dist/components/player/components/error/error.js +0 -15
  172. package/dist/components/player/components/error/error.json +0 -3
  173. package/dist/components/player/components/error/error.wxml +0 -6
  174. package/dist/components/player/components/error/error.wxss +0 -1
  175. package/dist/components/player/components/loading/loading.js +0 -9
  176. package/dist/components/player/components/loading/loading.json +0 -3
  177. package/dist/components/player/components/loading/loading.wxml +0 -4
  178. package/dist/components/player/components/loading/loading.wxss +0 -1
  179. package/dist/components/player/components/main/extensions/data.js +0 -8
  180. package/dist/components/player/components/main/extensions/export.js +0 -83
  181. package/dist/components/player/components/main/extensions/methods.js +0 -110
  182. package/dist/components/player/components/main/extensions/observers.js +0 -41
  183. package/dist/components/player/components/main/extensions/props.js +0 -177
  184. package/dist/components/player/components/main/index.js +0 -44
  185. package/dist/components/player/components/main/index.json +0 -4
  186. package/dist/components/player/components/main/index.wxml +0 -7
  187. package/dist/components/player/components/main/index.wxss +0 -1
  188. package/dist/components/player/components/marquee/marquee.js +0 -304
  189. package/dist/components/player/components/marquee/marquee.json +0 -4
  190. package/dist/components/player/components/marquee/marquee.wxml +0 -14
  191. package/dist/components/player/components/marquee/marquee.wxss +0 -1
  192. package/dist/components/player/components/online-hot/assets/line-hot.png +0 -0
  193. package/dist/components/player/components/online-hot/assets/line-user.png +0 -0
  194. package/dist/components/player/components/online-hot/index.js +0 -66
  195. package/dist/components/player/components/online-hot/index.json +0 -3
  196. package/dist/components/player/components/online-hot/index.wxml +0 -15
  197. package/dist/components/player/components/online-hot/index.wxss +0 -1
  198. package/dist/components/player/components/poster/poster.js +0 -12
  199. package/dist/components/player/components/poster/poster.json +0 -3
  200. package/dist/components/player/components/poster/poster.wxml +0 -5
  201. package/dist/components/player/components/poster/poster.wxss +0 -1
  202. package/dist/components/player/components/watermark/watermark.js +0 -52
  203. package/dist/components/player/components/watermark/watermark.json +0 -4
  204. package/dist/components/player/components/watermark/watermark.wxml +0 -8
  205. package/dist/components/player/components/watermark/watermark.wxss +0 -1
  206. package/dist/components/player/extensions/data.js +0 -63
  207. package/dist/components/player/extensions/export.js +0 -325
  208. package/dist/components/player/extensions/methods.js +0 -406
  209. package/dist/components/player/extensions/observers.js +0 -114
  210. package/dist/components/player/extensions/props.js +0 -162
  211. package/dist/components/player/player.js +0 -83
  212. package/dist/components/player/player.json +0 -33
  213. package/dist/components/player/player.wxml +0 -48
  214. package/dist/components/player/player.wxss +0 -1
  215. package/dist/components/praise/praise.js +0 -150
  216. package/dist/components/praise/praise.json +0 -5
  217. package/dist/components/praise/praise.wxml +0 -17
  218. package/dist/components/praise/praise.wxss +0 -1
  219. package/dist/components/product/product-card/product-card.js +0 -109
  220. package/dist/components/product/product-card/product-card.json +0 -3
  221. package/dist/components/product/product-card/product-card.wxml +0 -47
  222. package/dist/components/product/product-card/product-card.wxss +0 -1
  223. package/dist/components/product/product-detail/product-detail.js +0 -127
  224. package/dist/components/product/product-detail/product-detail.json +0 -3
  225. package/dist/components/product/product-detail/product-detail.wxml +0 -57
  226. package/dist/components/product/product-detail/product-detail.wxss +0 -1
  227. package/dist/components/product/product-item/product-item.js +0 -56
  228. package/dist/components/product/product-item/product-item.json +0 -3
  229. package/dist/components/product/product-item/product-item.wxml +0 -35
  230. package/dist/components/product/product-item/product-item.wxss +0 -1
  231. package/dist/components/product/product-list/product-list.js +0 -67
  232. package/dist/components/product/product-list/product-list.json +0 -6
  233. package/dist/components/product/product-list/product-list.wxml +0 -16
  234. package/dist/components/product/product-list/product-list.wxss +0 -1
  235. package/dist/components/product/product-order/product-order.js +0 -394
  236. package/dist/components/product/product-order/product-order.json +0 -3
  237. package/dist/components/product/product-order/product-order.wxml +0 -75
  238. package/dist/components/product/product-order/product-order.wxss +0 -1
  239. package/dist/components/signin/signin-dialog.js +0 -305
  240. package/dist/components/signin/signin-dialog.json +0 -7
  241. package/dist/components/signin/signin-dialog.wxml +0 -19
  242. package/dist/components/signin/signin-dialog.wxss +0 -1
  243. package/dist/components/top-notify/index.js +0 -14
  244. package/dist/components/top-notify/index.json +0 -3
  245. package/dist/components/top-notify/index.wxml +0 -2
  246. package/dist/components/top-notify/index.wxss +0 -1
  247. package/dist/pubComponents/countdown/countdown.js +0 -97
  248. package/dist/pubComponents/countdown/countdown.json +0 -5
  249. package/dist/pubComponents/countdown/countdown.wxml +0 -19
  250. package/dist/pubComponents/countdown/countdown.wxss +0 -1
  251. package/dist/pubComponents/error-page/index.js +0 -146
  252. package/dist/pubComponents/error-page/index.json +0 -5
  253. package/dist/pubComponents/error-page/index.wxml +0 -37
  254. package/dist/pubComponents/error-page/index.wxss +0 -1
  255. package/dist/pubComponents/popup/popup.js +0 -161
  256. package/dist/pubComponents/popup/popup.json +0 -5
  257. package/dist/pubComponents/popup/popup.wxml +0 -17
  258. package/dist/pubComponents/popup/popup.wxss +0 -1
  259. package/dist/pubComponents/tabs/index.js +0 -95
  260. package/dist/pubComponents/tabs/index.json +0 -4
  261. package/dist/pubComponents/tabs/index.wxml +0 -22
  262. package/dist/pubComponents/tabs/index.wxss +0 -1
  263. package/dist/sdk/config/index.js +0 -1
  264. package/dist/sdk/main/index.js +0 -1
  265. package/dist/sdk/player/index.js +0 -1
  266. package/dist/sdk/plugins/ChatServer.js +0 -1
  267. package/dist/sdk/plugins/CustomMenuServer.js +0 -1
  268. package/dist/sdk/plugins/InteractServer.js +0 -1
  269. package/dist/sdk/plugins/InviteCardServer.js +0 -1
  270. package/dist/sdk/plugins/LotteryServer.js +0 -1
  271. package/dist/sdk/plugins/MallRewardServer.js +0 -1
  272. package/dist/sdk/plugins/ProductServer.js +0 -1
  273. package/dist/shared/RequestUtil.js +0 -1
  274. package/dist/shared/SerializableMap.js +0 -1
  275. package/dist/shared/base.server.js +0 -1
  276. package/dist/shared/cacheUtil.js +0 -1
  277. package/dist/shared/dateUtil.js +0 -1
  278. package/dist/shared/logger.js +0 -1
  279. package/dist/shared/mpUtils.js +0 -1
  280. package/dist/shared/utils.js +0 -1
@@ -1,374 +0,0 @@
1
- import { isEmpty, safeJsonParse, sleep, genRandom } from '../../shared/utils.js';
2
- import createLogger from '../../shared/logger.js';
3
-
4
- const log = createLogger('mall-reward');
5
- Component({
6
- properties: {
7
- sdkInstance: {
8
- type: Object,
9
- value: null,
10
- },
11
- },
12
-
13
- /**
14
- * 组件的初始数据
15
- */
16
- data: {
17
- initTime: 0,
18
-
19
- mallRewardInfo: null,
20
-
21
- activeMallReward: null, // 时间最近的未领取的奖励项
22
- oriOnlineDuration: 0, // 最初始的在线时长(=mallRewardInfo?.online_duration || 0)
23
-
24
- onlineDuration: 0, // 当前在线时长(倒计时会持续变化)
25
-
26
- showIcon: false, // 是否显示小图标
27
-
28
- showPopup: false, // 是否显示弹窗
29
- filler: '', // 当前填充器
30
- currentInfo: null, // 预处理后的当前福利信息,直接传给子组件渲染
31
- isBubble: false, // 是否气泡显示, 因为气泡模式区域太小承载内容有限,且无遮罩,与产品沟通后调整为只有‘无条件+未领取’状态生效
32
- },
33
- observers: {
34
- sdkInstance: function sdkInstance(_sdkInstance) {
35
- if (!_sdkInstance) return;
36
- log.info('mall-reward sdkInstance');
37
- this.sdkInstance = _sdkInstance;
38
- this.setData({
39
- initTime: Date.now(),
40
- });
41
- this.initEventListener();
42
-
43
- this.checkAndFetchMallRewardInfo('refresh');
44
- },
45
- },
46
- lifetimes: {
47
- attached() {
48
- log.info('mall-reward component attached');
49
- },
50
- detached() {
51
- this.unlistener?.();
52
- },
53
- },
54
-
55
- methods: {
56
- // 初始化事件监听
57
- initEventListener() {
58
- this.unlistener?.();
59
- const obj = {};
60
-
61
- // 推送商城奖励
62
- obj[this.sdkInstance.EVENT.MALL_REWARD_PUSH] = (msg) => {
63
- log.info('mallReward open msg:', JSON.stringify(msg));
64
- const watchInitData = this.sdkInstance.store.get('watchInitData');
65
- const webinarType = watchInitData?.webinar?.type;
66
- if (!this.webinarType != 1) {
67
- return;
68
- }
69
- this.checkAndFetchMallRewardInfo('push', { reward_id: msg.data?.id });
70
- // 消息推送
71
- // const data = {
72
- // roleName: msg.data.role_name,
73
- // nickname: msg.data.pusher_name,
74
- // avatar: '//cnstatic01.e.vhall.com/static/images/watch/system.png',
75
- // content: {
76
- // text_content: `${this.$t('chat.chat_1108')}`,
77
- // },
78
- // type: msg.data.type,
79
- // interactStatus: true,
80
- // };
81
- // useChatServer().addChatToList(data);
82
- };
83
-
84
- // 收到商城奖励结束消息
85
- obj[this.sdkInstance.EVENT.MALL_REWARD_END] = (msg) => {
86
- log.info('mallReward ------handleMsgMallRewardEnd-msg:', msg);
87
- this.updateInfo(msg.data.id, { status: 2 });
88
- if (
89
- ['COUNTDOWN', 'OPEN'].includes(this.data.filler) &&
90
- this.data.currentInfo?.reward_id === msg.data.id
91
- ) {
92
- this.changeMainFiller('');
93
- }
94
- };
95
-
96
- // 直播结束
97
- obj[this.sdkInstance.EVENT.LIVE_END] = (msg) => {
98
- log.info('mallReward ------handleMsgMallRewardEnd-msg:', msg);
99
- this.destroyTimer(); // 清除计时器
100
- this.setData({
101
- mallRewardInfo: null,
102
- activeMallReward: null,
103
- oriOnlineDuration: 0,
104
- onlineDuration: 0,
105
- showIcon: false,
106
- showPopup: false,
107
- filler: '',
108
- currentInfo: null,
109
- });
110
- };
111
-
112
- // 上线消息
113
- obj[this.sdkInstance.EVENT.JOIN_MSG] = (msg) => {
114
- log.info('mallReward ------handleMsgJoin-msg:', msg);
115
- // 监听上线消息,刷新商城奖励数据条件:
116
- //(1)上线的人是自己;( 支持多端上线)
117
- //(2)间隔初始化请求时间超过3s(否则每次刷新调用两次请求;是否可以仅使用JOIN消息请求?不行,因为join消息不可靠,有时候收不到)
118
- if (!this.sdkInstance) return;
119
- const watchInitData = this.sdkInstance.store.get('watchInitData');
120
- const thirdPartyUserId = watchInitData?.join_info?.third_party_user_id;
121
- /* prettier-ignore */
122
- if (thirdPartyUserId && msg.sender_id == thirdPartyUserId && Date.now() - this.data.initTime > 3000) {
123
- this.checkAndFetchMallRewardInfo('refresh');
124
- }
125
- };
126
-
127
- // 下线消息
128
- obj[this.sdkInstance.EVENT.LEAVE_MSG] = (msg) => {
129
- log.info('mallReward ------handleMsgLeave-msg:', msg);
130
- if (!this.sdkInstance) return;
131
- const watchInitData = this.sdkInstance.store.get('watchInitData');
132
- const localKickMark = this.sdkInstance.store.get('kickMark');
133
- const localKickID = watchInitData?.sso?.kick_id;
134
- const msgContex = safeJsonParse(msg?.context);
135
- /* prettier-ignore */ // 自己下线了,计时器暂停
136
- if (localKickMark && localKickID && msgContex.kick_id === localKickID && msgContex.kick_mark === localKickMark) {
137
- console.log('mallReward 倒计时暂停');
138
- this.destroyTimer();
139
- }
140
- };
141
-
142
- this.unlistener = this.sdkInstance.on(obj);
143
- },
144
- async checkAndFetchMallRewardInfo(from, extra) {
145
- log.info('mall-reward checkAndFetchMallRewardInfo start');
146
- const mallRewardServer = this.sdkInstance.get('mallRewardServer');
147
- if (!mallRewardServer) return;
148
-
149
- const watchInitData = this.sdkInstance.store.get('watchInitData');
150
- const webinarType = watchInitData?.webinar?.type;
151
-
152
- if (webinarType != 1 && webinarType != 5) return;
153
-
154
- if (from === 'refresh') {
155
- this.destroyTimer();
156
- this.changeMainFiller('');
157
- }
158
-
159
- if (from === 'push') {
160
- // 延迟随机3s以内,再去调用接口,减少大并发
161
- const rnd = genRandom(0, 3000);
162
- await sleep(rnd);
163
- }
164
- const mallRewardInfo = await mallRewardServer.getValidList();
165
- const activeMallReward = mallRewardServer.updateActiveMallReward();
166
- this.setData({
167
- mallRewardInfo: mallRewardInfo,
168
- activeMallReward: activeMallReward,
169
- oriOnlineDuration: mallRewardInfo?.online_duration || 0,
170
- onlineDuration: mallRewardInfo?.online_duration || 0,
171
- });
172
- this.setData({
173
- /* prettier-ignore */
174
- showIcon: (webinarType == 1 || webinarType == 5) && (mallRewardInfo?.is_received == 1 || mallRewardInfo?.list?.length > 0),
175
- });
176
- if (webinarType == 1 || webinarType == 5) {
177
- this.createTimer(); // 创建计时器
178
- }
179
-
180
- // 检查并弹窗
181
- if (from === 'push' && extra?.reward_id && Array.isArray(mallRewardInfo?.list)) {
182
- extra = mallRewardInfo.list.find((item) => item.reward_id == extra.reward_id);
183
- }
184
- this.checkAndOpenPopup(from, extra);
185
- },
186
- /**
187
- * 创建定时器
188
- */
189
- createTimer() {
190
- this.destroyTimer();
191
-
192
- this.timer = setInterval(() => {
193
- const currentTime = Date.now();
194
- if (!this.startTime) {
195
- // 如果还没记录开始时间,说明是刚启动定时器,记录当前时间作为开始时间
196
- this.startTime = currentTime;
197
- }
198
- // 计时,延时问题处理
199
- this.setData({
200
- onlineDuration:
201
- this.data.oriOnlineDuration + parseInt((Date.now() - this.startTime) / 1000),
202
- });
203
- }, 1000);
204
- },
205
- /**
206
- * 销毁定时器
207
- */
208
- destroyTimer() {
209
- if (this.timer) {
210
- clearInterval(this.timer);
211
- this.timer = 0;
212
- }
213
- this.startTime = undefined;
214
- },
215
- // 关闭弹窗
216
- handlePopupClose() {
217
- this.setData({
218
- showPopup: false,
219
- filler: '',
220
- });
221
- },
222
- // 点击icon图标
223
- handleIconClick() {
224
- this.checkAndOpenPopup('icon_click');
225
- },
226
- // 切换对话框视图
227
- async changeMainFiller(filler, payload) {
228
- this.setData({
229
- showPopup: false,
230
- filler: '',
231
- currentInfo: null,
232
- isBubble: false,
233
- });
234
- await sleep(20);
235
- if (filler) {
236
- const currentInfo = payload
237
- ? { ...payload, tip_setting: safeJsonParse(payload.tip_setting) }
238
- : { ...this.data.activeMallReward };
239
- this.setData({
240
- showPopup: true,
241
- filler,
242
- currentInfo,
243
- isBubble:
244
- filler === 'OPEN' &&
245
- currentInfo?.viewing_minutes === 0 &&
246
- currentInfo?.display_of_results === 1,
247
- });
248
- }
249
- },
250
- // 检测并打开对应的弹窗
251
- async checkAndOpenPopup(action, payload) {
252
- console.log('checkAndOpenPopup called with:', { action, payload });
253
- const mallRewardInfo = this.sdkInstance.store.get('mallRewardInfo');
254
- if (isEmpty(mallRewardInfo)) return;
255
- switch (action) {
256
- // 点击icon
257
- case 'icon_click':
258
- if (this.data.mallRewardInfo.list?.length === 1) {
259
- // 列表中只有一条数据
260
- const mrInfo = this.data.mallRewardInfo.list[0];
261
- if (mrInfo.claim_status === 1) {
262
- // 已领取(无论是无条件还是定时奖励),都直接打开“开下收下”弹窗
263
- this.changeMainFiller('RECEIVE', mrInfo);
264
- } else if (
265
- mrInfo.viewing_minutes === 0 &&
266
- mrInfo.status === 1 &&
267
- mrInfo.remaining_quota > 0
268
- ) {
269
- // (未领取)+ 无条件 + 推送中 + 有数量 可以拆商城奖励
270
- this.changeMainFiller('OPEN', mrInfo);
271
- } else if (
272
- mrInfo.viewing_minutes > 0 &&
273
- mrInfo.status === 0 &&
274
- mrInfo.remaining_quota > 0
275
- ) {
276
- // (未领取)+ 定时奖励 + 推送中 + 有数量
277
- if (this.data.onlineDuration <= mrInfo.viewing_minutes * 60) {
278
- this.changeMainFiller('COUNTDOWN', mrInfo);
279
- } else {
280
- this.changeMainFiller('OPEN', mrInfo);
281
- }
282
- } else {
283
- this.changeMainFiller('EMPTY');
284
- }
285
- } else if (this.data.mallRewardInfo.list?.length > 1) {
286
- // 列表中有多条数据
287
- this.changeMainFiller('HISTORY');
288
- }
289
- break;
290
-
291
- // 推送触发
292
- case 'push':
293
- // 如果开了某些弹窗,则不操作
294
- if (['OPEN', 'RECEIVE', 'EMPTY'].includes(this.data.filler)) return;
295
- // 打开“立即领取”弹窗
296
- this.changeMainFiller('OPEN', payload);
297
- break;
298
- }
299
- },
300
- // 更新某个奖励的属性
301
- updateInfo(mallRewardId, attrs) {
302
- if (this.data.mallRewardInfo) {
303
- if (this.data.mallRewardInfo.list?.length > 0) {
304
- for (let item of this.data.mallRewardInfo.list) {
305
- if (item.reward_id === mallRewardId) {
306
- Object.keys(attrs).forEach((k) => {
307
- item[k] = attrs[k];
308
- });
309
- break;
310
- }
311
- }
312
- }
313
- if (attrs?.['claim_status'] == 1) {
314
- this.data.mallRewardInfo.is_received = 1;
315
- }
316
- this.sdkInstance.store.set('mallRewardInfo', this.data.mallRewardInfo);
317
- const mallRewardServer = this.sdkInstance.get('mallRewardServer');
318
- const activeMallReward = mallRewardServer.updateActiveMallReward();
319
- this.setData({
320
- mallRewardInfo: this.data.mallRewardInfo,
321
- activeMallReward: activeMallReward,
322
- });
323
- }
324
- },
325
-
326
- /**
327
- * 立即领取福利
328
- * @param {*} from 来源
329
- * 1. claim_now 用户点击“立即领取”(默认).
330
- * 2. countdown_end 倒计时结束自动立即领取
331
- * @param {*} theInfo
332
- * @returns
333
- */
334
- async claimNowHandler(from = 'claim_now', theInfo) {
335
- console.log('claimNowHandler called with:', { from, theInfo });
336
- const mallRewardServer = this.sdkInstance.get('mallRewardServer');
337
- if (!mallRewardServer) return;
338
-
339
- const rewardId = theInfo?.reward_id;
340
- if (!rewardId) return;
341
-
342
- const res = await mallRewardServer.claimMallReward(rewardId);
343
- console.log('mallreward claim result:', res);
344
- if (res?.code === 520099) {
345
- // 已领光
346
- this.updateInfo(rewardId, { remaining_quota: 0 });
347
- this.changeMainFiller('EMPTY');
348
- } else if (res?.code === 200 || res?.code === 520008) {
349
- // 领取成功 || 已领取过
350
- this.updateInfo(rewardId, { claim_status: 1 });
351
- this.changeMainFiller('RECEIVE', { ...theInfo, claim_status: 1 });
352
- } else {
353
- // 其它错误,如果是手动点击的“立即领取”,有错误提示
354
- if (from === 'claim_now') {
355
- wx.showToast({
356
- title: res?.msg || '领取失败',
357
- icon: 'none',
358
- duration: 2000,
359
- });
360
- } else {
361
- this.changeMainFiller('OPEN', theInfo);
362
- }
363
- }
364
- },
365
- // 立即领取
366
- onPopupClaim(e) {
367
- this.claimNowHandler('claim_now', e.detail);
368
- },
369
- // 倒计时结束,自动领取福利
370
- onCountdownEnd(e) {
371
- this.claimNowHandler('countdown_end', e.detail);
372
- },
373
- },
374
- });
@@ -1,8 +0,0 @@
1
- {
2
- "component": true,
3
- "styleIsolation": "shared",
4
- "usingComponents": {
5
- "duration-icon": "./duration-icon/index",
6
- "main-popup": "./main-popup/index"
7
- }
8
- }
@@ -1,4 +0,0 @@
1
- <!-- 商城奖励浮动小图标 -->
2
- <duration-icon wx:if="{{showIcon}}" mallRewardInfo="{{mallRewardInfo}}" activeMallReward="{{activeMallReward}}" onlineDuration="{{onlineDuration}}" bind:onTapIcon="handleIconClick" bind:countdownEnd="onCountdownEnd"></duration-icon>
3
- <!-- 主弹窗组件 -->
4
- <main-popup show="{{showPopup}}" filler="{{filler}}" currentInfo="{{currentInfo}}" mallRewardInfo="{{mallRewardInfo}}" onlineDuration="{{onlineDuration}}" hasMask="{{true}}" isBubble="{{isBubble}}" bind:close="handlePopupClose" bind:claim="onPopupClaim"></main-popup>
File without changes
@@ -1,46 +0,0 @@
1
- Component({
2
- properties: {
3
- show: { type: Boolean, value: false },
4
- mallRewardInfo: { type: Object, value: null },
5
- filler: { type: String, value: '' },
6
- currentInfo: { type: Object, value: null },
7
- onlineDuration: { type: Number, value: 0 },
8
- isBubble: { type: Boolean, value: false }, //气泡模式
9
- },
10
-
11
- data: {
12
- historyList: [],
13
- tipMode: 1,
14
- position: 'center', // 弹窗位置
15
- showFooterCloseBtn: true,
16
- },
17
-
18
- observers: {
19
- mallRewardInfo: function (newValue) {
20
- if (newValue) {
21
- this.setData({ historyList: newValue?.list || [] });
22
- }
23
- },
24
- filler: function (filler) {
25
- if (filler) {
26
- const position = ['HISTORY'].includes(filler)
27
- ? 'bottom'
28
- : this.properties.isBubble
29
- ? 'bottom-right'
30
- : 'center';
31
-
32
- this.setData({
33
- tipMode: this.properties.currentInfo?.tip_mode || 1,
34
- position: position,
35
- showFooterCloseBtn: position === 'center',
36
- });
37
- }
38
- },
39
- },
40
-
41
- methods: {
42
- onClose() {
43
- this.triggerEvent('close');
44
- },
45
- },
46
- });
@@ -1,12 +0,0 @@
1
- {
2
- "component": true,
3
- "styleIsolation": "shared",
4
- "usingComponents": {
5
- "vh-popup": "../../../pubComponents/popup/popup",
6
- "f-open": "../f-open/index",
7
- "f-count-down": "../f-count-down/index",
8
- "f-history": "../f-history/index",
9
- "f-empty": "../f-empty/index",
10
- "f-receive": "../f-receive/index"
11
- }
12
- }
@@ -1,16 +0,0 @@
1
- <vh-popup wx:if="{{show}}" visible="{{show}}" showClose="{{false}}" mode="{{position}}" hasMask="{{!isBubble}}" maskClosable="{{false}}" hasGap="{{false}}" bgColor="transparent" bind:close="onClose">
2
- <view class="mall-reward-pupup-content">
3
- <!-- 福利领取未到时长,显示倒计时 -->
4
- <f-count-down wx:if="{{filler==='COUNTDOWN'}}" tip-mode="{{tipMode}}" info="{{currentInfo}}" onlineDuration="{{onlineDuration}}" />
5
- <!-- 拆福利(立即领取) -->
6
- <f-open wx:if="{{filler==='OPEN'}}" isBubble="{{isBubble}}" tip-mode="{{tipMode}}" info="{{currentInfo}}" onlineDuration="{{onlineDuration}}" />
7
- <!-- 开心收下 -->
8
- <f-receive wx:if="{{filler==='RECEIVE'}}" tip-mode="{{tipMode}}" info="{{currentInfo}}" />
9
- <!-- 福利已领完 -->
10
- <f-empty wx:if="{{filler==='EMPTY'}}" />
11
- <!-- 福利记录 -->
12
- <f-history wx:if="{{filler==='HISTORY'}}" dataList="{{historyList}}" onlineDuration="{{onlineDuration}}" />
13
- <!-- 是否显示关闭按钮 -->
14
- <view wx:if="{{showFooterCloseBtn}}" class="close-btn" bindtap="onClose">✕</view>
15
- </view>
16
- </vh-popup>
@@ -1 +0,0 @@
1
- .mall-reward-pupup-content{display:flex;flex-direction:column}.mall-reward-pupup-content .close-btn{align-items:center;border:5rpx solid hsla(0,0%,100%,.6);border-radius:50%;color:hsla(0,0%,100%,.8);display:flex;font-size:1.29rem;height:48rpx;justify-content:center;line-height:1;margin:24rpx auto 0;width:48rpx}
@@ -1,7 +0,0 @@
1
- export default {
2
- prefix: "vhall",
3
- };
4
- export const prefix = "vhall";
5
- export const THRESHOLD_TIME = 15000;
6
- export const REPORT_DURATION = 10000;
7
- export const LONG_WAITING_TIME = 5000;
@@ -1,4 +0,0 @@
1
- export const VeComponent = options => {
2
- options.options = Object.assign({ multipleSlots: true, styleIsolation: 'apply-shared', virtualHost: true }, (options.options || {}));
3
- Component(options);
4
- };