southnote-mini-sdk 1.0.0

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 (309) hide show
  1. package/app.js +22 -0
  2. package/app.json +53 -0
  3. package/app.wxss +15 -0
  4. package/assets/file/badwords.js +63008 -0
  5. package/assets/file/rules.js +38 -0
  6. package/assets/images/emoji/smile001.png +0 -0
  7. package/assets/images/emoji/smile002.png +0 -0
  8. package/assets/images/emoji/smile003.png +0 -0
  9. package/assets/images/emoji/smile004.png +0 -0
  10. package/assets/images/emoji/smile005.png +0 -0
  11. package/assets/images/emoji/smile006.png +0 -0
  12. package/assets/images/emoji/smile007.png +0 -0
  13. package/assets/images/emoji/smile008.png +0 -0
  14. package/assets/images/emoji/smile009.png +0 -0
  15. package/assets/images/emoji/smile010.png +0 -0
  16. package/assets/images/emoji/smile011.png +0 -0
  17. package/assets/images/emoji/smile012.png +0 -0
  18. package/assets/images/emoji/smile013.png +0 -0
  19. package/assets/images/emoji/smile014.png +0 -0
  20. package/assets/images/emoji/smile015.png +0 -0
  21. package/assets/images/emoji/smile016.png +0 -0
  22. package/assets/images/emoji/smile017.png +0 -0
  23. package/assets/images/emoji/smile018.png +0 -0
  24. package/assets/images/emoji/smile019.png +0 -0
  25. package/assets/images/emoji/smile020.png +0 -0
  26. package/assets/images/emoji/smile021.png +0 -0
  27. package/assets/images/emoji/smile022.png +0 -0
  28. package/assets/images/emoji/smile023.png +0 -0
  29. package/assets/images/emoji/smile024.png +0 -0
  30. package/assets/images/emoji/smile025.png +0 -0
  31. package/assets/images/emoji/smile026.png +0 -0
  32. package/assets/images/emoji/smile027.png +0 -0
  33. package/assets/images/emoji/smile028.png +0 -0
  34. package/assets/images/emoji/smile029.png +0 -0
  35. package/assets/images/emoji/smile030.png +0 -0
  36. package/assets/images/emoji/smile031.png +0 -0
  37. package/assets/images/emoji/smile032.png +0 -0
  38. package/assets/images/emoji/smile033.png +0 -0
  39. package/assets/images/emoji/smile034.png +0 -0
  40. package/assets/images/emoji/smile035.png +0 -0
  41. package/assets/images/emoji/smile036.png +0 -0
  42. package/assets/images/emoji/smile037.png +0 -0
  43. package/assets/images/emoji/smile038.png +0 -0
  44. package/assets/images/emoji/smile039.png +0 -0
  45. package/assets/images/emoji/smile040.png +0 -0
  46. package/assets/images/emoji/smile041.png +0 -0
  47. package/assets/images/emoji/smile042.png +0 -0
  48. package/assets/images/emoji/smile043.png +0 -0
  49. package/assets/images/emoji/smile044.png +0 -0
  50. package/assets/images/emoji/smile045.png +0 -0
  51. package/assets/images/emoji/smile046.png +0 -0
  52. package/assets/images/emoji/smile047.png +0 -0
  53. package/assets/images/emoji/smile048.png +0 -0
  54. package/assets/images/emoji/smile049.png +0 -0
  55. package/assets/images/emoji/smile050.png +0 -0
  56. package/assets/images/emoji/smile051.png +0 -0
  57. package/assets/images/emoji/smile052.png +0 -0
  58. package/assets/images/icons/age1.png +0 -0
  59. package/assets/images/icons/age2.png +0 -0
  60. package/assets/images/icons/age3.png +0 -0
  61. package/assets/images/icons/attachment.png +0 -0
  62. package/assets/images/icons/clear.png +0 -0
  63. package/assets/images/icons/edit_input.png +0 -0
  64. package/assets/images/icons/header_placeholder.png +0 -0
  65. package/assets/images/icons/home_collect.png +0 -0
  66. package/assets/images/icons/home_collected.png +0 -0
  67. package/assets/images/icons/home_comment.png +0 -0
  68. package/assets/images/icons/home_like.png +0 -0
  69. package/assets/images/icons/home_liked.png +0 -0
  70. package/assets/images/icons/home_message.png +0 -0
  71. package/assets/images/icons/home_share.png +0 -0
  72. package/assets/images/icons/icon_more.png +0 -0
  73. package/assets/images/icons/input_game.png +0 -0
  74. package/assets/images/icons/logo.png +0 -0
  75. package/assets/images/icons/lv1.png +0 -0
  76. package/assets/images/icons/lv2.png +0 -0
  77. package/assets/images/icons/lv3.png +0 -0
  78. package/assets/images/icons/lv4.png +0 -0
  79. package/assets/images/icons/search.png +0 -0
  80. package/assets/images/icons/sex1.png +0 -0
  81. package/assets/images/icons/sex2.png +0 -0
  82. package/assets/images/icons/sign_empty.png +0 -0
  83. package/assets/images/icons/sign_login.png +0 -0
  84. package/assets/wheel/wheel_bg.png +0 -0
  85. package/assets/wheel/wheel_bg2.png +0 -0
  86. package/assets/wheel/wheel_fore.png +0 -0
  87. package/assets/wheel/wheel_to.png +0 -0
  88. package/components/bottomSheet/bottomSheet.js +473 -0
  89. package/components/bottomSheet/bottomSheet.json +3 -0
  90. package/components/bottomSheet/bottomSheet.wxml +73 -0
  91. package/components/bottomSheet/bottomSheet.wxss +238 -0
  92. package/components/experience-item/experience-item.js +105 -0
  93. package/components/experience-item/experience-item.json +4 -0
  94. package/components/experience-item/experience-item.wxml +39 -0
  95. package/components/experience-item/experience-item.wxss +110 -0
  96. package/components/grid-item/grid-item.js +8 -0
  97. package/components/grid-item/grid-item.json +4 -0
  98. package/components/grid-item/grid-item.wxml +62 -0
  99. package/components/grid-item/grid-item.wxss +191 -0
  100. package/components/post-item/post-item.js +1085 -0
  101. package/components/post-item/post-item.json +4 -0
  102. package/components/post-item/post-item.wxml +427 -0
  103. package/components/post-item/post-item.wxss +525 -0
  104. package/components/wiki-renderer/wiki-renderer.js +636 -0
  105. package/components/wiki-renderer/wiki-renderer.json +12 -0
  106. package/components/wiki-renderer/wiki-renderer.wxml +150 -0
  107. package/components/wiki-renderer/wiki-renderer.wxss +412 -0
  108. package/components/wiki-tabs/wiki-tabs.js +52 -0
  109. package/components/wiki-tabs/wiki-tabs.json +3 -0
  110. package/components/wiki-tabs/wiki-tabs.wxml +28 -0
  111. package/components/wiki-tabs/wiki-tabs.wxss +43 -0
  112. package/index.js +49 -0
  113. package/package.json +35 -0
  114. package/pages/addGame/addGame.js +454 -0
  115. package/pages/addGame/addGame.json +3 -0
  116. package/pages/addGame/addGame.wxml +71 -0
  117. package/pages/addGame/addGame.wxss +110 -0
  118. package/pages/addSubject/addSubject.js +199 -0
  119. package/pages/addSubject/addSubject.json +4 -0
  120. package/pages/addSubject/addSubject.wxml +78 -0
  121. package/pages/addSubject/addSubject.wxss +85 -0
  122. package/pages/commonLogin/commonLogin.js +269 -0
  123. package/pages/commonLogin/commonLogin.json +4 -0
  124. package/pages/commonLogin/commonLogin.wxml +57 -0
  125. package/pages/commonLogin/commonLogin.wxss +177 -0
  126. package/pages/copyOfficial/copyOfficial.js +25 -0
  127. package/pages/copyOfficial/copyOfficial.json +3 -0
  128. package/pages/copyOfficial/copyOfficial.wxml +22 -0
  129. package/pages/copyOfficial/copyOfficial.wxss +49 -0
  130. package/pages/demo/demo.js +23 -0
  131. package/pages/demo/demo.json +3 -0
  132. package/pages/demo/demo.wxml +8 -0
  133. package/pages/demo/demo.wxss +24 -0
  134. package/pages/game/game.js +1254 -0
  135. package/pages/game/game.json +8 -0
  136. package/pages/game/game.wxml +371 -0
  137. package/pages/game/game.wxss +672 -0
  138. package/pages/home/home.js +665 -0
  139. package/pages/home/home.json +10 -0
  140. package/pages/home/home.wxml +115 -0
  141. package/pages/home/home.wxss +231 -0
  142. package/pages/lottery-winners/lottery-winners.js +60 -0
  143. package/pages/lottery-winners/lottery-winners.json +4 -0
  144. package/pages/lottery-winners/lottery-winners.wxml +53 -0
  145. package/pages/lottery-winners/lottery-winners.wxss +127 -0
  146. package/pages/message/messageCommentsAndAt/messageCommentsAndAt.js +178 -0
  147. package/pages/message/messageCommentsAndAt/messageCommentsAndAt.json +5 -0
  148. package/pages/message/messageCommentsAndAt/messageCommentsAndAt.wxml +93 -0
  149. package/pages/message/messageCommentsAndAt/messageCommentsAndAt.wxss +177 -0
  150. package/pages/message/messageEntire/messageEntire.js +112 -0
  151. package/pages/message/messageEntire/messageEntire.json +4 -0
  152. package/pages/message/messageEntire/messageEntire.wxml +44 -0
  153. package/pages/message/messageEntire/messageEntire.wxss +88 -0
  154. package/pages/message/messageLikeAndCollect/messageLikeAndCollect.js +147 -0
  155. package/pages/message/messageLikeAndCollect/messageLikeAndCollect.json +5 -0
  156. package/pages/message/messageLikeAndCollect/messageLikeAndCollect.wxml +84 -0
  157. package/pages/message/messageLikeAndCollect/messageLikeAndCollect.wxss +166 -0
  158. package/pages/message/messageNewFans/messageNewFans.js +139 -0
  159. package/pages/message/messageNewFans/messageNewFans.json +5 -0
  160. package/pages/message/messageNewFans/messageNewFans.wxml +35 -0
  161. package/pages/message/messageNewFans/messageNewFans.wxss +85 -0
  162. package/pages/officialWebview/officialWebview.js +13 -0
  163. package/pages/officialWebview/officialWebview.json +3 -0
  164. package/pages/officialWebview/officialWebview.wxml +2 -0
  165. package/pages/officialWebview/officialWebview.wxss +1 -0
  166. package/pages/post/post.js +1856 -0
  167. package/pages/post/post.json +6 -0
  168. package/pages/post/post.wxml +694 -0
  169. package/pages/post/post.wxss +1003 -0
  170. package/pages/post-editor/post-editor.js +465 -0
  171. package/pages/post-editor/post-editor.json +4 -0
  172. package/pages/post-editor/post-editor.wxml +63 -0
  173. package/pages/post-editor/post-editor.wxss +195 -0
  174. package/pages/postDialog/postDialog.js +560 -0
  175. package/pages/postDialog/postDialog.json +6 -0
  176. package/pages/postDialog/postDialog.wxml +377 -0
  177. package/pages/postDialog/postDialog.wxss +979 -0
  178. package/pages/report-category/report-category.js +29 -0
  179. package/pages/report-category/report-category.json +4 -0
  180. package/pages/report-category/report-category.wxml +14 -0
  181. package/pages/report-category/report-category.wxss +43 -0
  182. package/pages/report-form/report-form.js +65 -0
  183. package/pages/report-form/report-form.json +3 -0
  184. package/pages/report-form/report-form.wxml +11 -0
  185. package/pages/report-form/report-form.wxss +44 -0
  186. package/pages/sevenDaySignDetail/sevenDaySignDetail.js +273 -0
  187. package/pages/sevenDaySignDetail/sevenDaySignDetail.json +3 -0
  188. package/pages/sevenDaySignDetail/sevenDaySignDetail.wxml +82 -0
  189. package/pages/sevenDaySignDetail/sevenDaySignDetail.wxss +173 -0
  190. package/pages/topic/topic.js +266 -0
  191. package/pages/topic/topic.json +6 -0
  192. package/pages/topic/topic.wxml +77 -0
  193. package/pages/topic/topic.wxss +162 -0
  194. package/pages/user/user.js +939 -0
  195. package/pages/user/user.json +5 -0
  196. package/pages/user/user.wxml +179 -0
  197. package/pages/user/user.wxss +340 -0
  198. package/pages/userDatum/userDatum.js +24 -0
  199. package/pages/userDatum/userDatum.json +4 -0
  200. package/pages/userDatum/userDatum.wxml +36 -0
  201. package/pages/userDatum/userDatum.wxss +41 -0
  202. package/pages/userGameLib/userGameLib.js +105 -0
  203. package/pages/userGameLib/userGameLib.json +4 -0
  204. package/pages/userGameLib/userGameLib.wxml +42 -0
  205. package/pages/userGameLib/userGameLib.wxss +119 -0
  206. package/pages/webview/webview.js +25 -0
  207. package/pages/webview/webview.json +3 -0
  208. package/pages/webview/webview.wxml +22 -0
  209. package/pages/webview/webview.wxss +50 -0
  210. package/pages/wheelActivivty/wheelActivivty.js +492 -0
  211. package/pages/wheelActivivty/wheelActivivty.json +8 -0
  212. package/pages/wheelActivivty/wheelActivivty.wxml +131 -0
  213. package/pages/wheelActivivty/wheelActivivty.wxss +459 -0
  214. package/pages/wiki/wiki.js +138 -0
  215. package/pages/wiki/wiki.json +6 -0
  216. package/pages/wiki/wiki.wxml +20 -0
  217. package/pages/wiki/wiki.wxss +44 -0
  218. package/request/JKRequest.js +177 -0
  219. package/services/home.js +603 -0
  220. package/towxml/config.js +291 -0
  221. package/towxml/decode.js +35 -0
  222. package/towxml/decode.json +11 -0
  223. package/towxml/decode.wxml +137 -0
  224. package/towxml/decode.wxss +0 -0
  225. package/towxml/img/img.js +98 -0
  226. package/towxml/img/img.json +3 -0
  227. package/towxml/img/img.wxml +1 -0
  228. package/towxml/img/img.wxss +0 -0
  229. package/towxml/index.js +19 -0
  230. package/towxml/latex/latex.js +53 -0
  231. package/towxml/latex/latex.json +5 -0
  232. package/towxml/latex/latex.wxml +1 -0
  233. package/towxml/latex/latex.wxss +0 -0
  234. package/towxml/parse/highlight/highlight.js +1 -0
  235. package/towxml/parse/highlight/index.js +8 -0
  236. package/towxml/parse/highlight/languages/bash.js +111 -0
  237. package/towxml/parse/highlight/languages/c-like.js +236 -0
  238. package/towxml/parse/highlight/languages/c.js +22 -0
  239. package/towxml/parse/highlight/languages/css.js +132 -0
  240. package/towxml/parse/highlight/languages/dart.js +134 -0
  241. package/towxml/parse/highlight/languages/go.js +63 -0
  242. package/towxml/parse/highlight/languages/htmlbars.js +80 -0
  243. package/towxml/parse/highlight/languages/java.js +125 -0
  244. package/towxml/parse/highlight/languages/javascript.js +265 -0
  245. package/towxml/parse/highlight/languages/json.js +52 -0
  246. package/towxml/parse/highlight/languages/less.js +148 -0
  247. package/towxml/parse/highlight/languages/nginx.js +101 -0
  248. package/towxml/parse/highlight/languages/php.js +161 -0
  249. package/towxml/parse/highlight/languages/python-repl.js +29 -0
  250. package/towxml/parse/highlight/languages/python.js +131 -0
  251. package/towxml/parse/highlight/languages/scss.js +122 -0
  252. package/towxml/parse/highlight/languages/shell.js +22 -0
  253. package/towxml/parse/highlight/languages/typescript.js +215 -0
  254. package/towxml/parse/highlight/languages/xml.js +139 -0
  255. package/towxml/parse/highlight/style/github.wxss +99 -0
  256. package/towxml/parse/highlight/style/monokai.wxss +70 -0
  257. package/towxml/parse/index.js +118 -0
  258. package/towxml/parse/markdown/index.js +67 -0
  259. package/towxml/parse/markdown/markdown.js +4 -0
  260. package/towxml/parse/markdown/plugins/echarts.js +11 -0
  261. package/towxml/parse/markdown/plugins/emoji.js +2 -0
  262. package/towxml/parse/markdown/plugins/ins.js +1 -0
  263. package/towxml/parse/markdown/plugins/latex.js +158 -0
  264. package/towxml/parse/markdown/plugins/mark.js +1 -0
  265. package/towxml/parse/markdown/plugins/sub.js +1 -0
  266. package/towxml/parse/markdown/plugins/sup.js +1 -0
  267. package/towxml/parse/markdown/plugins/todo.js +147 -0
  268. package/towxml/parse/markdown/plugins/yuml.js +20 -0
  269. package/towxml/parse/parse2/Parser.js +492 -0
  270. package/towxml/parse/parse2/Tokenizer.js +903 -0
  271. package/towxml/parse/parse2/domelementtype/index.js +55 -0
  272. package/towxml/parse/parse2/domhandler/index.js +145 -0
  273. package/towxml/parse/parse2/domhandler/node.js +474 -0
  274. package/towxml/parse/parse2/entities/decode.js +179 -0
  275. package/towxml/parse/parse2/entities/decode_codepoint.js +60 -0
  276. package/towxml/parse/parse2/entities/encode.js +77 -0
  277. package/towxml/parse/parse2/entities/escape.js +112 -0
  278. package/towxml/parse/parse2/entities/generated/decode-data-html.js +9 -0
  279. package/towxml/parse/parse2/entities/generated/decode-data-xml.js +9 -0
  280. package/towxml/parse/parse2/entities/generated/encode-html.js +12 -0
  281. package/towxml/parse/parse2/entities/index.js +137 -0
  282. package/towxml/parse/parse2/index.js +8 -0
  283. package/towxml/style/main.wxss +419 -0
  284. package/towxml/style/theme/dark.wxss +73 -0
  285. package/towxml/style/theme/light.wxss +63 -0
  286. package/towxml/table/table.js +11 -0
  287. package/towxml/table/table.json +6 -0
  288. package/towxml/table/table.wxml +24 -0
  289. package/towxml/table/table.wxss +0 -0
  290. package/towxml/todogroup/todogroup.js +20 -0
  291. package/towxml/todogroup/todogroup.json +6 -0
  292. package/towxml/todogroup/todogroup.wxml +12 -0
  293. package/towxml/todogroup/todogroup.wxss +3 -0
  294. package/towxml/towxml.js +22 -0
  295. package/towxml/towxml.json +6 -0
  296. package/towxml/towxml.wxml +5 -0
  297. package/towxml/towxml.wxss +8 -0
  298. package/towxml/yuml/yuml.js +51 -0
  299. package/towxml/yuml/yuml.json +5 -0
  300. package/towxml/yuml/yuml.wxml +5 -0
  301. package/towxml/yuml/yuml.wxss +0 -0
  302. package/utils/auth.js +17 -0
  303. package/utils/base64.js +67 -0
  304. package/utils/compressImage.js +41 -0
  305. package/utils/exp.js +49 -0
  306. package/utils/formatPost.js +18 -0
  307. package/utils/parseContent.js +191 -0
  308. package/utils/query-select.js +9 -0
  309. package/utils/sensitive.js +82 -0
@@ -0,0 +1,492 @@
1
+ // pages/wheel-activity/index.js
2
+ import {
3
+ queryGameActivityInfo
4
+ } from '../../services/home'
5
+
6
+ Page({
7
+ data: {
8
+ activityData: {},
9
+ showRuleModal: false,
10
+ showGiftModal: false,
11
+ showTaskModal: false,
12
+ canvasSize: 320,
13
+
14
+
15
+ // 计算属性数据
16
+ rewards: {},
17
+ chanceData: {},
18
+ winners: [],
19
+ ownRecord: [],
20
+ wheelItems: [],
21
+ totalChance: 0,
22
+ ruleItems: [],
23
+ taskItems: [],
24
+ taskDetailItems: []
25
+ },
26
+
27
+ // 图片缓存
28
+ imgCache: new Map(),
29
+
30
+ onLoad(options) {
31
+ const activityId = options.activity_id
32
+ this.loadActivityData(activityId)
33
+ },
34
+
35
+ onReady() {
36
+ // 获取容器尺寸并初始化canvas
37
+ this.initCanvas()
38
+ },
39
+
40
+
41
+
42
+ // 加载活动数据
43
+ loadActivityData(activityId) {
44
+ queryGameActivityInfo(activityId).then(res => {
45
+
46
+ const safeData = this.convertToHttps(res.data)
47
+
48
+ this.setData({
49
+ activityData: safeData
50
+ }, () => {
51
+ this.computeDerivedData()
52
+ this.drawWheel()
53
+ })
54
+ })
55
+ },
56
+
57
+ convertToHttps(obj) {
58
+ if (typeof obj === 'string') {
59
+ return obj.replace(/^http:\/\//i, 'https://')
60
+ }
61
+
62
+ if (Array.isArray(obj)) {
63
+ return obj.map(item => this.convertToHttps(item)) // ✅ 加 this
64
+ }
65
+
66
+ if (typeof obj === 'object' && obj !== null) {
67
+ const newObj = {}
68
+ for (const key in obj) {
69
+ newObj[key] = this.convertToHttps(obj[key]) // ✅ 加 this
70
+ }
71
+ return newObj
72
+ }
73
+
74
+ return obj
75
+ },
76
+
77
+
78
+ // 计算派生数据
79
+ computeDerivedData() {
80
+ const { activityData } = this.data
81
+ const rewards = activityData.rewards || {}
82
+ const chanceData = rewards.chance_data || {}
83
+ const winners = Array.isArray(rewards.winners) ? rewards.winners : []
84
+ const ownRecordRaw = Array.isArray(rewards.own_record) ? rewards.own_record : []
85
+ const wheelItems = rewards.wheel || []
86
+ const totalChance = chanceData.total_chance || 0
87
+
88
+ // 格式化活动时间
89
+ const startTimeFormatted = this.formatTime(activityData.start_time)
90
+ const endTimeFormatted = this.formatTime(activityData.end_time)
91
+
92
+ // 为礼包记录添加格式化后的时间字段
93
+ const ownRecord = ownRecordRaw.map(item => ({
94
+ ...item,
95
+ created_at_formatted: this.formatTime(item.created_at)
96
+ }))
97
+
98
+ // 计算规则条目
99
+ const ruleItems = this.computeRuleItems(activityData, chanceData)
100
+ const taskItems = this.computeTaskItems(chanceData)
101
+ const taskDetailItems = this.computeTaskDetailItems(chanceData)
102
+
103
+ this.setData({
104
+ rewards,
105
+ chanceData,
106
+ winners,
107
+ ownRecord,
108
+ wheelItems,
109
+ totalChance,
110
+ ruleItems,
111
+ taskItems,
112
+ taskDetailItems,
113
+ startTimeFormatted,
114
+ endTimeFormatted
115
+ })
116
+ },
117
+
118
+ // 计算规则条目
119
+ computeRuleItems(activityData, chanceData) {
120
+ const items = []
121
+
122
+ if (activityData.activity_desc) {
123
+ items.push({
124
+ type: 'text',
125
+ value: activityData.activity_desc
126
+ })
127
+ }
128
+
129
+ items.push({
130
+ type: 'time',
131
+ value: `${this.formatTime(activityData.start_time)} - ${this.formatTime(activityData.end_time)}`
132
+ })
133
+
134
+ const taskItems = this.computeTaskItems(chanceData)
135
+ if (taskItems.length > 1) {
136
+ items.push({
137
+ type: 'tasks',
138
+ value: ''
139
+ })
140
+ } else if (taskItems.length === 1) {
141
+ items.push({
142
+ type: 'text',
143
+ value: taskItems[0]
144
+ })
145
+ }
146
+
147
+ items.push({
148
+ type: 'text',
149
+ value: '在本页面点击【开始抽奖】,即可抽取对应的礼包,礼包先到先得,抽完为止。'
150
+ })
151
+ items.push({
152
+ type: 'text',
153
+ value: '抽奖次数于每日00:00清零'
154
+ })
155
+
156
+ return items
157
+ },
158
+
159
+ // 计算任务条目
160
+ computeTaskItems(chanceData) {
161
+ const list = []
162
+
163
+ if ('daily_chance' in chanceData) {
164
+ list.push(`每日登录得次数(${chanceData.daily_chance || 0}/1)`)
165
+ }
166
+ if ('comment_chance' in chanceData) {
167
+ list.push(`每日评论得次数(${chanceData.comment_chance || 0}/1)`)
168
+ }
169
+ if ('like_chance' in chanceData) {
170
+ list.push(`每日点赞得次数(${chanceData.like_chance || 0}/1)`)
171
+ }
172
+ if ('topic_chance' in chanceData) {
173
+ list.push(`每日发表话题#${chanceData.topic_name || ''}#得次数(${chanceData.topic_chance || 0}/1)`)
174
+ }
175
+ if ('post_chance' in chanceData) {
176
+ list.push(`每日发帖得次数(${chanceData.post_chance || 0}/1)`)
177
+ }
178
+
179
+ return list
180
+ },
181
+
182
+ // 计算任务详情条目
183
+ computeTaskDetailItems(chanceData) {
184
+ const list = []
185
+
186
+ if ('daily_chance' in chanceData) {
187
+ list.push({
188
+ label: `每日登录得次数(${chanceData.daily_chance || 0}/1)`,
189
+ done: !!chanceData.daily_chance,
190
+ got: chanceData.daily_chance || 0,
191
+ type: 'login'
192
+ })
193
+ }
194
+ if ('comment_chance' in chanceData) {
195
+ list.push({
196
+ label: `每日评论得次数(${chanceData.comment_chance || 0}/1)`,
197
+ done: !!chanceData.comment_chance,
198
+ got: chanceData.comment_chance || 0,
199
+ type: 'comment'
200
+ })
201
+ }
202
+ if ('like_chance' in chanceData) {
203
+ list.push({
204
+ label: `每日点赞得次数(${chanceData.like_chance || 0}/1)`,
205
+ done: !!chanceData.like_chance,
206
+ got: chanceData.like_chance || 0,
207
+ type: 'like'
208
+ })
209
+ }
210
+ if ('topic_chance' in chanceData) {
211
+ list.push({
212
+ label: '',
213
+ done: !!chanceData.topic_chance,
214
+ got: chanceData.topic_chance || 0,
215
+ type: 'topic'
216
+ })
217
+ }
218
+ if ('post_chance' in chanceData) {
219
+ list.push({
220
+ label: `每日发帖得次数(${chanceData.post_chance || 0}/1)`,
221
+ done: !!chanceData.post_chance,
222
+ got: chanceData.post_chance || 0,
223
+ type: 'post'
224
+ })
225
+ }
226
+
227
+ return list
228
+ },
229
+
230
+ // 格式化时间
231
+ formatTime(ts) {
232
+ if (!ts) return ''
233
+ const d = new Date(Number(ts) * 1000)
234
+ const pad = (n) => String(n).padStart(2, '0')
235
+ return `${d.getFullYear()}/${pad(d.getMonth() + 1)}/${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
236
+ },
237
+
238
+ // 初始化Canvas
239
+ initCanvas() {
240
+ const query = wx.createSelectorQuery()
241
+ query.select('#wheelContainer').boundingClientRect()
242
+ query.exec((res) => {
243
+ if (res[0]) {
244
+ const containerWidth = res[0].width
245
+ const size = Math.min(containerWidth, 340)
246
+ this.setData({
247
+ canvasSize: size
248
+ }, () => {
249
+ this.setupCanvas()
250
+ })
251
+ }
252
+ })
253
+ },
254
+
255
+ // 设置Canvas
256
+ setupCanvas() {
257
+ const query = wx.createSelectorQuery()
258
+ query.select('#wheelCanvas')
259
+ .fields({
260
+ node: true,
261
+ size: true
262
+ })
263
+ .exec((res) => {
264
+ if (res[0]) {
265
+ const canvas = res[0].node
266
+ const ctx = canvas.getContext('2d')
267
+
268
+ const dpr = wx.getSystemInfoSync().pixelRatio
269
+ const size = this.data.canvasSize
270
+
271
+ canvas.width = size * dpr
272
+ canvas.height = size * dpr
273
+ ctx.scale(dpr, dpr)
274
+
275
+ this.canvas = canvas
276
+ this.ctx = ctx
277
+
278
+ this.preloadImages().then(() => {
279
+ this.drawWheel()
280
+ })
281
+ }
282
+ })
283
+ },
284
+
285
+ // 预加载图片
286
+ preloadImages() {
287
+ const {
288
+ wheelItems
289
+ } = this.data
290
+ const promises = []
291
+
292
+ wheelItems.forEach((item) => {
293
+ if (!item.item_icon) return
294
+ if (this.imgCache.has(item.item_icon)) return
295
+
296
+ promises.push(
297
+ new Promise((resolve) => {
298
+ const img = this.canvas.createImage()
299
+ img.src = item.item_icon
300
+ img.onload = () => {
301
+ this.imgCache.set(item.item_icon, img)
302
+ resolve()
303
+ }
304
+ img.onerror = () => resolve()
305
+ })
306
+ )
307
+ })
308
+
309
+ return Promise.all(promises)
310
+ },
311
+
312
+ // 绘制转盘
313
+ drawWheel() {
314
+ if (!this.ctx || !this.canvas) return
315
+
316
+ const ctx = this.ctx
317
+ const size = this.data.canvasSize
318
+ const cx = size / 2
319
+ const cy = size / 2
320
+ const r = size / 2 - 4
321
+
322
+ const items = this.data.wheelItems || []
323
+ const count = 6
324
+ const angleStep = (Math.PI * 2) / count
325
+ const colors = ['#fbf7eb', '#faead0']
326
+ const flipIndices = [2, 3]
327
+
328
+ ctx.clearRect(0, 0, size, size)
329
+
330
+ // 整体旋转:让第一个扇区中心对准顶部指针
331
+ ctx.save()
332
+ ctx.translate(cx, cy)
333
+ ctx.rotate(-angleStep / 2)
334
+ ctx.translate(-cx, -cy)
335
+
336
+ for (let i = 0; i < count; i++) {
337
+ const startAngle = -Math.PI / 2 + i * angleStep
338
+ const endAngle = startAngle + angleStep
339
+ const midAngle = startAngle + angleStep / 2
340
+
341
+ // 绘制扇形
342
+ ctx.beginPath()
343
+ ctx.moveTo(cx, cy)
344
+ ctx.arc(cx, cy, r, startAngle, endAngle)
345
+ ctx.closePath()
346
+ ctx.fillStyle = colors[i % 2]
347
+ ctx.fill()
348
+ ctx.strokeStyle = '#e8d5b0'
349
+ ctx.stroke()
350
+
351
+ const item = items.find((it) => it.position === i + 1)
352
+ if (!item) continue
353
+
354
+ const isThankYou = item.item_type === 3
355
+
356
+ // 绘制图片
357
+ ctx.save()
358
+ ctx.translate(cx, cy)
359
+ ctx.rotate(midAngle)
360
+
361
+ if (!isThankYou && item.item_icon) {
362
+ const img = this.imgCache.get(item.item_icon)
363
+ if (img) {
364
+ const imgSize = size * 0.125
365
+ const imgRadius = r * 0.5
366
+ const imgX = imgRadius - imgSize / 2
367
+ const imgY = -imgSize / 2
368
+
369
+ ctx.translate(imgX + imgSize / 2, imgY + imgSize / 2)
370
+ ctx.rotate(Math.PI / 2)
371
+ ctx.translate(-(imgSize / 2), -(imgSize / 2))
372
+ ctx.drawImage(img, 0, 0, imgSize, imgSize)
373
+ }
374
+ }
375
+
376
+ ctx.restore()
377
+
378
+ // 绘制文字
379
+ const textRadius = r * 0.78
380
+ const x = cx + Math.cos(midAngle) * textRadius
381
+ const y = cy + Math.sin(midAngle) * textRadius
382
+
383
+ let textAngle = midAngle + Math.PI / 2
384
+ if (textAngle > Math.PI / 2 && textAngle < (Math.PI * 3) / 2) {
385
+ textAngle += Math.PI
386
+ }
387
+
388
+ if (flipIndices.includes(i)) {
389
+ textAngle += Math.PI
390
+ }
391
+
392
+ ctx.save()
393
+ ctx.translate(x, y)
394
+ ctx.rotate(textAngle)
395
+ ctx.fillStyle = '#bc977f'
396
+ const fontSize = size * 0.044
397
+ ctx.font = `bold ${fontSize}px sans-serif`
398
+ ctx.textAlign = 'center'
399
+ ctx.textBaseline = 'middle'
400
+
401
+ const nameLines = isThankYou ? ['谢谢参与'] : this.wrapText(item.item_name || '', 8)
402
+ nameLines.forEach((line, li) => {
403
+ ctx.fillText(line, 0, (li - (nameLines.length - 1) / 2) * fontSize)
404
+ })
405
+
406
+ ctx.restore()
407
+ }
408
+
409
+ ctx.restore()
410
+ },
411
+
412
+ // 文字换行
413
+ wrapText(text, maxLen) {
414
+ const lines = []
415
+ for (let i = 0; i < text.length; i += maxLen) {
416
+ lines.push(text.slice(i, i + maxLen))
417
+ }
418
+ return lines
419
+ },
420
+
421
+ // 显示规则弹窗
422
+ showRule() {
423
+ this.setData({
424
+ showRuleModal: true
425
+ })
426
+ },
427
+
428
+ hideRule() {
429
+ this.setData({
430
+ showRuleModal: false
431
+ })
432
+ },
433
+
434
+ // 显示礼包弹窗
435
+ showGift() {
436
+ this.setData({
437
+ showGiftModal: true
438
+ })
439
+ },
440
+
441
+ hideGift() {
442
+ this.setData({
443
+ showGiftModal: false
444
+ })
445
+ },
446
+
447
+ // 显示任务弹窗
448
+ showTask() {
449
+ this.setData({
450
+ showTaskModal: true
451
+ })
452
+ },
453
+
454
+ hideTask() {
455
+ this.setData({
456
+ showTaskModal: false
457
+ })
458
+ },
459
+
460
+ // 阻止冒泡
461
+ stopPropagation() {},
462
+
463
+ // 拷贝文本
464
+ copyText(e) {
465
+ const text = e.currentTarget.dataset.text
466
+ wx.setClipboardData({
467
+ data: text,
468
+ success: () => {
469
+ wx.showToast({
470
+ title: '拷贝成功',
471
+ icon: 'success'
472
+ })
473
+ }
474
+ })
475
+ },
476
+
477
+ // 前往APP
478
+ goToApp() {
479
+ // wx.showToast({
480
+ // title: '请前往APP参与抽奖',
481
+ // icon: 'none'
482
+ // })
483
+
484
+ // 小程序跳转逻辑
485
+ // 可以使用 wx.navigateToMiniProgram 跳转到其他小程序
486
+ // 或使用其他方式引导用户下载APP
487
+
488
+ wx.navigateTo({
489
+ url: `/pages/copyOfficial/copyOfficial?url=${encodeURIComponent('https://www.southnote.cn')}`
490
+ });
491
+ }
492
+ })
@@ -0,0 +1,8 @@
1
+ {
2
+ "navigationBarTitleText": "抽奖活动",
3
+ "navigationBarBackgroundColor": "#ffffff",
4
+ "navigationBarTextStyle": "black",
5
+ "backgroundColor": "#f8f8f8",
6
+ "enablePullDownRefresh": false,
7
+ "usingComponents": {}
8
+ }
@@ -0,0 +1,131 @@
1
+ <!-- pages/wheel-activity/index.wxml -->
2
+ <view class="wheel-activity">
3
+ <image class="bg-image" src="../assets/wheel/wheel_bg.png" mode="scaleToFill"></image>
4
+ <!-- 右上角按钮 -->
5
+ <view class="top-right-btns">
6
+ <view class="side-btn" bindtap="showRule">活动规则</view>
7
+ <view class="side-btn" bindtap="showGift">我的礼包</view>
8
+ </view>
9
+
10
+ <!-- title图 -->
11
+ <view class="title-image-wrap" wx:if="{{activityData.rewards.title_image}}">
12
+ <image src="{{activityData.rewards.title_image}}" class="title-image" mode="widthFix" />
13
+ </view>
14
+
15
+ <!-- 活动时间 -->
16
+ <view class="activity-time">
17
+ 活动时间:{{startTimeFormatted}} - {{endTimeFormatted}}
18
+ </view>
19
+
20
+ <!-- 今日剩余抽奖次数 -->
21
+ <view class="chance-bar">
22
+ <image class="chance-bar-bg" src="../assets/wheel/wheel_bg2.png" mode="scaleToFill"></image>
23
+ <text class="chance-label">今日剩余抽奖次数:</text>
24
+ <text class="chance-num">{{totalChance}}</text>
25
+ <text class="chance-label">次</text>
26
+ <text wx:if="{{taskDetailItems.length > 1}}" class="chance-question" bindtap="showTask">?</text>
27
+ </view>
28
+
29
+ <!-- 大转盘 -->
30
+ <view class="wheel-container" id="wheelContainer">
31
+ <view class="wheel-ring">
32
+ <image class="wheel-ring-bg" src="../assets/wheel/wheel_fore.png" mode="scaleToFill"></image>
33
+ </view>
34
+ <view class="wheel-content">
35
+ <canvas
36
+ type="2d"
37
+ id="wheelCanvas"
38
+ class="wheel-canvas"
39
+ style="width: {{canvasSize}}px; height: {{canvasSize}}px;"
40
+ ></canvas>
41
+ </view>
42
+ <!-- 中间指针+文字 -->
43
+ <view class="wheel-center" bindtap="goToApp">
44
+ <image src="../assets/wheel/wheel_to.png" class="wheel-pointer" mode="widthFix" />
45
+ <view class="wheel-start-text">
46
+ <text>开始</text>
47
+ <text>抽奖</text>
48
+ </view>
49
+ </view>
50
+ </view>
51
+
52
+ <!-- 中奖名单 -->
53
+ <view class="winners-section">
54
+ <view class="winners-title">中奖名单</view>
55
+ <scroll-view class="winners-list" scroll-y>
56
+ <view wx:if="{{winners.length === 0}}" class="empty-tip">暂无记录</view>
57
+ <view wx:for="{{winners}}" wx:key="index" class="winner-cell">
58
+ <text class="winner-text">恭喜</text>
59
+ <text class="winner-name">{{item.nickname}}</text>
60
+ <text class="winner-text">获得</text>
61
+ <text class="winner-reward">{{item.reward}}</text>
62
+ </view>
63
+ </scroll-view>
64
+ </view>
65
+
66
+ <!-- 活动规则弹窗 -->
67
+ <view wx:if="{{showRuleModal}}" class="modal-overlay" bindtap="hideRule">
68
+ <view class="modal-box" catchtap="stopPropagation">
69
+ <view class="modal-title">活动规则</view>
70
+ <view style="padding: 15px;">
71
+ <view wx:for="{{ruleItems}}" wx:key="index" class="rule-item">
72
+ <text class="rule-index">{{index + 1}}.</text>
73
+ <block wx:if="{{item.type === 'time'}}">
74
+ <text class="rule-text">活动时间:<text style="color: #002fa7;">{{item.value}}</text>
75
+ </text>
76
+ </block>
77
+ <block wx:elif="{{item.type === 'tasks'}}">
78
+ <text class="rule-text">以下任务可获得抽奖次数
79
+ <block wx:for="{{taskItems}}" wx:for-item="task" wx:key="index">
80
+ <text class="rule-task-item">· {{task}}\n</text>
81
+ </block>
82
+ </text>
83
+ </block>
84
+ <block wx:else>
85
+ <text class="rule-text">{{item.value}}</text>
86
+ </block>
87
+ </view>
88
+ </view>
89
+ <view class="modal-close-btn" bindtap="hideRule">关闭</view>
90
+ </view>
91
+ </view>
92
+
93
+ <!-- 我的礼包弹窗 -->
94
+ <view wx:if="{{showGiftModal}}" class="modal-overlay" bindtap="hideGift">
95
+ <view class="modal-box modal-box-gradient" catchtap="stopPropagation">
96
+ <view class="modal-title">我的礼包</view>
97
+ <view style="padding: 15px;">
98
+ <view wx:if="{{ownRecord.length === 0}}" class="empty-tip">暂无记录</view>
99
+ <view wx:for="{{ownRecord}}" wx:key="record_id" class="gift-item">
100
+ <image src="{{item.item_icon}}" class="gift-icon" mode="aspectFill" />
101
+ <view class="gift-info">
102
+ <view class="gift-name">{{item.item_name}}</view>
103
+ <view class="gift-cdk">兑换码:{{item.cdk}}</view>
104
+ <view class="gift-date">{{item.created_at_formatted}}</view>
105
+
106
+ </view>
107
+ <view class="copy-btn" bindtap="copyText" data-text="{{item.cdk}}">拷贝</view>
108
+ </view>
109
+ </view>
110
+ <view class="modal-close-btn" bindtap="hideGift">关闭</view>
111
+ </view>
112
+ </view>
113
+
114
+ <!-- 我的任务弹窗 -->
115
+ <view wx:if="{{showTaskModal}}" class="modal-overlay" bindtap="hideTask">
116
+ <view class="modal-box" catchtap="stopPropagation">
117
+ <view class="modal-title">我的任务</view>
118
+ <view style="padding: 15px;">
119
+ <view wx:for="{{taskDetailItems}}" wx:key="index" class="task-item {{item.done ? 'task-done' : ''}}">
120
+ <text class="task-index">{{index + 1}}.</text>
121
+ <text class="task-text {{item.done ? 'task-text-done' : 'task-text-active'}}">
122
+ <block wx:if="{{item.type === 'topic'}}">每日发表话题<text style="{{item.done ? '' : 'color:#002fa7;'}}"> #{{chanceData.topic_name}}# </text>得次数({{item.got}}/1)
123
+ </block>
124
+ <block wx:else>{{item.label}}</block>
125
+ </text>
126
+ </view>
127
+ </view>
128
+ <view class="modal-close-btn" bindtap="hideTask">关闭</view>
129
+ </view>
130
+ </view>
131
+ </view>