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.
- package/app.js +22 -0
- package/app.json +53 -0
- package/app.wxss +15 -0
- package/assets/file/badwords.js +63008 -0
- package/assets/file/rules.js +38 -0
- package/assets/images/emoji/smile001.png +0 -0
- package/assets/images/emoji/smile002.png +0 -0
- package/assets/images/emoji/smile003.png +0 -0
- package/assets/images/emoji/smile004.png +0 -0
- package/assets/images/emoji/smile005.png +0 -0
- package/assets/images/emoji/smile006.png +0 -0
- package/assets/images/emoji/smile007.png +0 -0
- package/assets/images/emoji/smile008.png +0 -0
- package/assets/images/emoji/smile009.png +0 -0
- package/assets/images/emoji/smile010.png +0 -0
- package/assets/images/emoji/smile011.png +0 -0
- package/assets/images/emoji/smile012.png +0 -0
- package/assets/images/emoji/smile013.png +0 -0
- package/assets/images/emoji/smile014.png +0 -0
- package/assets/images/emoji/smile015.png +0 -0
- package/assets/images/emoji/smile016.png +0 -0
- package/assets/images/emoji/smile017.png +0 -0
- package/assets/images/emoji/smile018.png +0 -0
- package/assets/images/emoji/smile019.png +0 -0
- package/assets/images/emoji/smile020.png +0 -0
- package/assets/images/emoji/smile021.png +0 -0
- package/assets/images/emoji/smile022.png +0 -0
- package/assets/images/emoji/smile023.png +0 -0
- package/assets/images/emoji/smile024.png +0 -0
- package/assets/images/emoji/smile025.png +0 -0
- package/assets/images/emoji/smile026.png +0 -0
- package/assets/images/emoji/smile027.png +0 -0
- package/assets/images/emoji/smile028.png +0 -0
- package/assets/images/emoji/smile029.png +0 -0
- package/assets/images/emoji/smile030.png +0 -0
- package/assets/images/emoji/smile031.png +0 -0
- package/assets/images/emoji/smile032.png +0 -0
- package/assets/images/emoji/smile033.png +0 -0
- package/assets/images/emoji/smile034.png +0 -0
- package/assets/images/emoji/smile035.png +0 -0
- package/assets/images/emoji/smile036.png +0 -0
- package/assets/images/emoji/smile037.png +0 -0
- package/assets/images/emoji/smile038.png +0 -0
- package/assets/images/emoji/smile039.png +0 -0
- package/assets/images/emoji/smile040.png +0 -0
- package/assets/images/emoji/smile041.png +0 -0
- package/assets/images/emoji/smile042.png +0 -0
- package/assets/images/emoji/smile043.png +0 -0
- package/assets/images/emoji/smile044.png +0 -0
- package/assets/images/emoji/smile045.png +0 -0
- package/assets/images/emoji/smile046.png +0 -0
- package/assets/images/emoji/smile047.png +0 -0
- package/assets/images/emoji/smile048.png +0 -0
- package/assets/images/emoji/smile049.png +0 -0
- package/assets/images/emoji/smile050.png +0 -0
- package/assets/images/emoji/smile051.png +0 -0
- package/assets/images/emoji/smile052.png +0 -0
- package/assets/images/icons/age1.png +0 -0
- package/assets/images/icons/age2.png +0 -0
- package/assets/images/icons/age3.png +0 -0
- package/assets/images/icons/attachment.png +0 -0
- package/assets/images/icons/clear.png +0 -0
- package/assets/images/icons/edit_input.png +0 -0
- package/assets/images/icons/header_placeholder.png +0 -0
- package/assets/images/icons/home_collect.png +0 -0
- package/assets/images/icons/home_collected.png +0 -0
- package/assets/images/icons/home_comment.png +0 -0
- package/assets/images/icons/home_like.png +0 -0
- package/assets/images/icons/home_liked.png +0 -0
- package/assets/images/icons/home_message.png +0 -0
- package/assets/images/icons/home_share.png +0 -0
- package/assets/images/icons/icon_more.png +0 -0
- package/assets/images/icons/input_game.png +0 -0
- package/assets/images/icons/logo.png +0 -0
- package/assets/images/icons/lv1.png +0 -0
- package/assets/images/icons/lv2.png +0 -0
- package/assets/images/icons/lv3.png +0 -0
- package/assets/images/icons/lv4.png +0 -0
- package/assets/images/icons/search.png +0 -0
- package/assets/images/icons/sex1.png +0 -0
- package/assets/images/icons/sex2.png +0 -0
- package/assets/images/icons/sign_empty.png +0 -0
- package/assets/images/icons/sign_login.png +0 -0
- package/assets/wheel/wheel_bg.png +0 -0
- package/assets/wheel/wheel_bg2.png +0 -0
- package/assets/wheel/wheel_fore.png +0 -0
- package/assets/wheel/wheel_to.png +0 -0
- package/components/bottomSheet/bottomSheet.js +473 -0
- package/components/bottomSheet/bottomSheet.json +3 -0
- package/components/bottomSheet/bottomSheet.wxml +73 -0
- package/components/bottomSheet/bottomSheet.wxss +238 -0
- package/components/experience-item/experience-item.js +105 -0
- package/components/experience-item/experience-item.json +4 -0
- package/components/experience-item/experience-item.wxml +39 -0
- package/components/experience-item/experience-item.wxss +110 -0
- package/components/grid-item/grid-item.js +8 -0
- package/components/grid-item/grid-item.json +4 -0
- package/components/grid-item/grid-item.wxml +62 -0
- package/components/grid-item/grid-item.wxss +191 -0
- package/components/post-item/post-item.js +1085 -0
- package/components/post-item/post-item.json +4 -0
- package/components/post-item/post-item.wxml +427 -0
- package/components/post-item/post-item.wxss +525 -0
- package/components/wiki-renderer/wiki-renderer.js +636 -0
- package/components/wiki-renderer/wiki-renderer.json +12 -0
- package/components/wiki-renderer/wiki-renderer.wxml +150 -0
- package/components/wiki-renderer/wiki-renderer.wxss +412 -0
- package/components/wiki-tabs/wiki-tabs.js +52 -0
- package/components/wiki-tabs/wiki-tabs.json +3 -0
- package/components/wiki-tabs/wiki-tabs.wxml +28 -0
- package/components/wiki-tabs/wiki-tabs.wxss +43 -0
- package/index.js +49 -0
- package/package.json +35 -0
- package/pages/addGame/addGame.js +454 -0
- package/pages/addGame/addGame.json +3 -0
- package/pages/addGame/addGame.wxml +71 -0
- package/pages/addGame/addGame.wxss +110 -0
- package/pages/addSubject/addSubject.js +199 -0
- package/pages/addSubject/addSubject.json +4 -0
- package/pages/addSubject/addSubject.wxml +78 -0
- package/pages/addSubject/addSubject.wxss +85 -0
- package/pages/commonLogin/commonLogin.js +269 -0
- package/pages/commonLogin/commonLogin.json +4 -0
- package/pages/commonLogin/commonLogin.wxml +57 -0
- package/pages/commonLogin/commonLogin.wxss +177 -0
- package/pages/copyOfficial/copyOfficial.js +25 -0
- package/pages/copyOfficial/copyOfficial.json +3 -0
- package/pages/copyOfficial/copyOfficial.wxml +22 -0
- package/pages/copyOfficial/copyOfficial.wxss +49 -0
- package/pages/demo/demo.js +23 -0
- package/pages/demo/demo.json +3 -0
- package/pages/demo/demo.wxml +8 -0
- package/pages/demo/demo.wxss +24 -0
- package/pages/game/game.js +1254 -0
- package/pages/game/game.json +8 -0
- package/pages/game/game.wxml +371 -0
- package/pages/game/game.wxss +672 -0
- package/pages/home/home.js +665 -0
- package/pages/home/home.json +10 -0
- package/pages/home/home.wxml +115 -0
- package/pages/home/home.wxss +231 -0
- package/pages/lottery-winners/lottery-winners.js +60 -0
- package/pages/lottery-winners/lottery-winners.json +4 -0
- package/pages/lottery-winners/lottery-winners.wxml +53 -0
- package/pages/lottery-winners/lottery-winners.wxss +127 -0
- package/pages/message/messageCommentsAndAt/messageCommentsAndAt.js +178 -0
- package/pages/message/messageCommentsAndAt/messageCommentsAndAt.json +5 -0
- package/pages/message/messageCommentsAndAt/messageCommentsAndAt.wxml +93 -0
- package/pages/message/messageCommentsAndAt/messageCommentsAndAt.wxss +177 -0
- package/pages/message/messageEntire/messageEntire.js +112 -0
- package/pages/message/messageEntire/messageEntire.json +4 -0
- package/pages/message/messageEntire/messageEntire.wxml +44 -0
- package/pages/message/messageEntire/messageEntire.wxss +88 -0
- package/pages/message/messageLikeAndCollect/messageLikeAndCollect.js +147 -0
- package/pages/message/messageLikeAndCollect/messageLikeAndCollect.json +5 -0
- package/pages/message/messageLikeAndCollect/messageLikeAndCollect.wxml +84 -0
- package/pages/message/messageLikeAndCollect/messageLikeAndCollect.wxss +166 -0
- package/pages/message/messageNewFans/messageNewFans.js +139 -0
- package/pages/message/messageNewFans/messageNewFans.json +5 -0
- package/pages/message/messageNewFans/messageNewFans.wxml +35 -0
- package/pages/message/messageNewFans/messageNewFans.wxss +85 -0
- package/pages/officialWebview/officialWebview.js +13 -0
- package/pages/officialWebview/officialWebview.json +3 -0
- package/pages/officialWebview/officialWebview.wxml +2 -0
- package/pages/officialWebview/officialWebview.wxss +1 -0
- package/pages/post/post.js +1856 -0
- package/pages/post/post.json +6 -0
- package/pages/post/post.wxml +694 -0
- package/pages/post/post.wxss +1003 -0
- package/pages/post-editor/post-editor.js +465 -0
- package/pages/post-editor/post-editor.json +4 -0
- package/pages/post-editor/post-editor.wxml +63 -0
- package/pages/post-editor/post-editor.wxss +195 -0
- package/pages/postDialog/postDialog.js +560 -0
- package/pages/postDialog/postDialog.json +6 -0
- package/pages/postDialog/postDialog.wxml +377 -0
- package/pages/postDialog/postDialog.wxss +979 -0
- package/pages/report-category/report-category.js +29 -0
- package/pages/report-category/report-category.json +4 -0
- package/pages/report-category/report-category.wxml +14 -0
- package/pages/report-category/report-category.wxss +43 -0
- package/pages/report-form/report-form.js +65 -0
- package/pages/report-form/report-form.json +3 -0
- package/pages/report-form/report-form.wxml +11 -0
- package/pages/report-form/report-form.wxss +44 -0
- package/pages/sevenDaySignDetail/sevenDaySignDetail.js +273 -0
- package/pages/sevenDaySignDetail/sevenDaySignDetail.json +3 -0
- package/pages/sevenDaySignDetail/sevenDaySignDetail.wxml +82 -0
- package/pages/sevenDaySignDetail/sevenDaySignDetail.wxss +173 -0
- package/pages/topic/topic.js +266 -0
- package/pages/topic/topic.json +6 -0
- package/pages/topic/topic.wxml +77 -0
- package/pages/topic/topic.wxss +162 -0
- package/pages/user/user.js +939 -0
- package/pages/user/user.json +5 -0
- package/pages/user/user.wxml +179 -0
- package/pages/user/user.wxss +340 -0
- package/pages/userDatum/userDatum.js +24 -0
- package/pages/userDatum/userDatum.json +4 -0
- package/pages/userDatum/userDatum.wxml +36 -0
- package/pages/userDatum/userDatum.wxss +41 -0
- package/pages/userGameLib/userGameLib.js +105 -0
- package/pages/userGameLib/userGameLib.json +4 -0
- package/pages/userGameLib/userGameLib.wxml +42 -0
- package/pages/userGameLib/userGameLib.wxss +119 -0
- package/pages/webview/webview.js +25 -0
- package/pages/webview/webview.json +3 -0
- package/pages/webview/webview.wxml +22 -0
- package/pages/webview/webview.wxss +50 -0
- package/pages/wheelActivivty/wheelActivivty.js +492 -0
- package/pages/wheelActivivty/wheelActivivty.json +8 -0
- package/pages/wheelActivivty/wheelActivivty.wxml +131 -0
- package/pages/wheelActivivty/wheelActivivty.wxss +459 -0
- package/pages/wiki/wiki.js +138 -0
- package/pages/wiki/wiki.json +6 -0
- package/pages/wiki/wiki.wxml +20 -0
- package/pages/wiki/wiki.wxss +44 -0
- package/request/JKRequest.js +177 -0
- package/services/home.js +603 -0
- package/towxml/config.js +291 -0
- package/towxml/decode.js +35 -0
- package/towxml/decode.json +11 -0
- package/towxml/decode.wxml +137 -0
- package/towxml/decode.wxss +0 -0
- package/towxml/img/img.js +98 -0
- package/towxml/img/img.json +3 -0
- package/towxml/img/img.wxml +1 -0
- package/towxml/img/img.wxss +0 -0
- package/towxml/index.js +19 -0
- package/towxml/latex/latex.js +53 -0
- package/towxml/latex/latex.json +5 -0
- package/towxml/latex/latex.wxml +1 -0
- package/towxml/latex/latex.wxss +0 -0
- package/towxml/parse/highlight/highlight.js +1 -0
- package/towxml/parse/highlight/index.js +8 -0
- package/towxml/parse/highlight/languages/bash.js +111 -0
- package/towxml/parse/highlight/languages/c-like.js +236 -0
- package/towxml/parse/highlight/languages/c.js +22 -0
- package/towxml/parse/highlight/languages/css.js +132 -0
- package/towxml/parse/highlight/languages/dart.js +134 -0
- package/towxml/parse/highlight/languages/go.js +63 -0
- package/towxml/parse/highlight/languages/htmlbars.js +80 -0
- package/towxml/parse/highlight/languages/java.js +125 -0
- package/towxml/parse/highlight/languages/javascript.js +265 -0
- package/towxml/parse/highlight/languages/json.js +52 -0
- package/towxml/parse/highlight/languages/less.js +148 -0
- package/towxml/parse/highlight/languages/nginx.js +101 -0
- package/towxml/parse/highlight/languages/php.js +161 -0
- package/towxml/parse/highlight/languages/python-repl.js +29 -0
- package/towxml/parse/highlight/languages/python.js +131 -0
- package/towxml/parse/highlight/languages/scss.js +122 -0
- package/towxml/parse/highlight/languages/shell.js +22 -0
- package/towxml/parse/highlight/languages/typescript.js +215 -0
- package/towxml/parse/highlight/languages/xml.js +139 -0
- package/towxml/parse/highlight/style/github.wxss +99 -0
- package/towxml/parse/highlight/style/monokai.wxss +70 -0
- package/towxml/parse/index.js +118 -0
- package/towxml/parse/markdown/index.js +67 -0
- package/towxml/parse/markdown/markdown.js +4 -0
- package/towxml/parse/markdown/plugins/echarts.js +11 -0
- package/towxml/parse/markdown/plugins/emoji.js +2 -0
- package/towxml/parse/markdown/plugins/ins.js +1 -0
- package/towxml/parse/markdown/plugins/latex.js +158 -0
- package/towxml/parse/markdown/plugins/mark.js +1 -0
- package/towxml/parse/markdown/plugins/sub.js +1 -0
- package/towxml/parse/markdown/plugins/sup.js +1 -0
- package/towxml/parse/markdown/plugins/todo.js +147 -0
- package/towxml/parse/markdown/plugins/yuml.js +20 -0
- package/towxml/parse/parse2/Parser.js +492 -0
- package/towxml/parse/parse2/Tokenizer.js +903 -0
- package/towxml/parse/parse2/domelementtype/index.js +55 -0
- package/towxml/parse/parse2/domhandler/index.js +145 -0
- package/towxml/parse/parse2/domhandler/node.js +474 -0
- package/towxml/parse/parse2/entities/decode.js +179 -0
- package/towxml/parse/parse2/entities/decode_codepoint.js +60 -0
- package/towxml/parse/parse2/entities/encode.js +77 -0
- package/towxml/parse/parse2/entities/escape.js +112 -0
- package/towxml/parse/parse2/entities/generated/decode-data-html.js +9 -0
- package/towxml/parse/parse2/entities/generated/decode-data-xml.js +9 -0
- package/towxml/parse/parse2/entities/generated/encode-html.js +12 -0
- package/towxml/parse/parse2/entities/index.js +137 -0
- package/towxml/parse/parse2/index.js +8 -0
- package/towxml/style/main.wxss +419 -0
- package/towxml/style/theme/dark.wxss +73 -0
- package/towxml/style/theme/light.wxss +63 -0
- package/towxml/table/table.js +11 -0
- package/towxml/table/table.json +6 -0
- package/towxml/table/table.wxml +24 -0
- package/towxml/table/table.wxss +0 -0
- package/towxml/todogroup/todogroup.js +20 -0
- package/towxml/todogroup/todogroup.json +6 -0
- package/towxml/todogroup/todogroup.wxml +12 -0
- package/towxml/todogroup/todogroup.wxss +3 -0
- package/towxml/towxml.js +22 -0
- package/towxml/towxml.json +6 -0
- package/towxml/towxml.wxml +5 -0
- package/towxml/towxml.wxss +8 -0
- package/towxml/yuml/yuml.js +51 -0
- package/towxml/yuml/yuml.json +5 -0
- package/towxml/yuml/yuml.wxml +5 -0
- package/towxml/yuml/yuml.wxss +0 -0
- package/utils/auth.js +17 -0
- package/utils/base64.js +67 -0
- package/utils/compressImage.js +41 -0
- package/utils/exp.js +49 -0
- package/utils/formatPost.js +18 -0
- package/utils/parseContent.js +191 -0
- package/utils/query-select.js +9 -0
- package/utils/sensitive.js +82 -0
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
import {
|
|
2
|
+
emojiMap
|
|
3
|
+
} from "../../components/post-item/post-item"
|
|
4
|
+
import {
|
|
5
|
+
queryMoreShareComments,
|
|
6
|
+
|
|
7
|
+
} from "../../services/home";
|
|
8
|
+
import formatUTC from "../../utils/formatPost.js"
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
checkLogin
|
|
12
|
+
} from "../../utils/auth"
|
|
13
|
+
|
|
14
|
+
Page({
|
|
15
|
+
data: {
|
|
16
|
+
item: {},
|
|
17
|
+
itemDetial: {},
|
|
18
|
+
postId: 0,
|
|
19
|
+
contentParts: [],
|
|
20
|
+
commentedContentParts: [],
|
|
21
|
+
sharedContentParts: [],
|
|
22
|
+
comments: [],
|
|
23
|
+
likes: [],
|
|
24
|
+
shares: [],
|
|
25
|
+
showFull: false,
|
|
26
|
+
needShowReadMore: false,
|
|
27
|
+
isLongImage: false,
|
|
28
|
+
isSuperLongImage: false,
|
|
29
|
+
isHorizonImage: false,
|
|
30
|
+
loading: true,
|
|
31
|
+
floorPage: 1,
|
|
32
|
+
floorHasMore: true,
|
|
33
|
+
isLoadingMore: false
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
onLoad(options) {
|
|
37
|
+
const postId = options.id;
|
|
38
|
+
const isCommentIn = options.isCommentIn
|
|
39
|
+
this.setData({
|
|
40
|
+
postId,
|
|
41
|
+
isCommentIn
|
|
42
|
+
});
|
|
43
|
+
this.fetchPostDetail(postId).then(res => {
|
|
44
|
+
const currentUserId = wx.getStorageSync('appuid');
|
|
45
|
+
const isOwner = this.data.item.user.id === currentUserId;
|
|
46
|
+
this.setData({
|
|
47
|
+
isOwner
|
|
48
|
+
});
|
|
49
|
+
if (this.data.isCommentIn) {
|
|
50
|
+
this.setData({
|
|
51
|
+
showSheet: true,
|
|
52
|
+
originPost: this.data.item,
|
|
53
|
+
commentData: null
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
onImageLoad(e) {
|
|
60
|
+
const {
|
|
61
|
+
width,
|
|
62
|
+
height
|
|
63
|
+
} = e.detail;
|
|
64
|
+
const ratio = height / width;
|
|
65
|
+
|
|
66
|
+
this.setData({
|
|
67
|
+
isLongImage: ratio > 3 && ratio <= 4,
|
|
68
|
+
isSuperLongImage: ratio > 4,
|
|
69
|
+
isHorizonImage: ratio < 1
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
async fetchPostDetail(postId) {
|
|
74
|
+
try {
|
|
75
|
+
const res = await queryMoreShareComments(postId, 1);
|
|
76
|
+
|
|
77
|
+
if (res.code !== 0 || !Array.isArray(res.data)) {
|
|
78
|
+
this.setData({
|
|
79
|
+
loading: false
|
|
80
|
+
});
|
|
81
|
+
wx.showToast({
|
|
82
|
+
title: '加载失败',
|
|
83
|
+
icon: 'none'
|
|
84
|
+
});
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const dataList = res.data.map(item => this.formatPost(item));
|
|
89
|
+
|
|
90
|
+
// 第一个是楼主
|
|
91
|
+
const mainPostItem = dataList[0];
|
|
92
|
+
// 初始化楼主图片 meta(只取第一张,和你原逻辑一致)
|
|
93
|
+
const mainFirstImg = mainPostItem.post.imageArray?.[0] || null;
|
|
94
|
+
if (mainFirstImg) {
|
|
95
|
+
mainPostItem.imageMeta = {
|
|
96
|
+
src: mainFirstImg,
|
|
97
|
+
isLong: false,
|
|
98
|
+
isSuperLong: false,
|
|
99
|
+
isHorizon: false
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
const contentParts = this.injectTitle(
|
|
105
|
+
this.parseContent(mainPostItem.post.content, mainPostItem.post.imageArray),
|
|
106
|
+
mainPostItem.post.title
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
this.initVoteData(mainPostItem.post.vote);
|
|
110
|
+
this.initLotteryData(mainPostItem.post.lottery);
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
// 剩余楼层
|
|
114
|
+
const floorPosts = dataList.slice(1).map(item => {
|
|
115
|
+
return {
|
|
116
|
+
...item,
|
|
117
|
+
contentParts: this.parseContent(item.post.content)
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
this.setData({
|
|
122
|
+
loading: false,
|
|
123
|
+
item: mainPostItem,
|
|
124
|
+
contentParts,
|
|
125
|
+
floorPosts
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
} catch (err) {
|
|
129
|
+
this.setData({
|
|
130
|
+
loading: false
|
|
131
|
+
});
|
|
132
|
+
console.error('加载帖子详情失败:', err);
|
|
133
|
+
wx.showToast({
|
|
134
|
+
title: '加载失败',
|
|
135
|
+
icon: 'none'
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
onReachBottom() {
|
|
141
|
+
this.loadMoreFloors();
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
async loadMoreFloors() {
|
|
145
|
+
if (this.data.isLoadingMore || !this.data.floorHasMore) return;
|
|
146
|
+
|
|
147
|
+
this.setData({
|
|
148
|
+
isLoadingMore: true
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
const nextPage = this.data.floorPage + 1;
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
const res = await queryMoreShareComments(this.data.postId, nextPage);
|
|
155
|
+
|
|
156
|
+
if (res.code !== 0 || !Array.isArray(res.data) || res.data.length === 0) {
|
|
157
|
+
this.setData({
|
|
158
|
+
floorHasMore: false,
|
|
159
|
+
isLoadingMore: false
|
|
160
|
+
});
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const newFloors = res.data.map(item => {
|
|
165
|
+
const formatted = this.formatPost(item);
|
|
166
|
+
return {
|
|
167
|
+
...formatted,
|
|
168
|
+
contentParts: this.parseContent(formatted.post.content)
|
|
169
|
+
};
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
this.setData({
|
|
173
|
+
floorPosts: this.data.floorPosts.concat(newFloors),
|
|
174
|
+
floorPage: nextPage,
|
|
175
|
+
isLoadingMore: true
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// 如果这页数据量很少,认为没更多了
|
|
179
|
+
if (res.data.length < 15) {
|
|
180
|
+
this.setData({
|
|
181
|
+
floorHasMore: false
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
} catch (err) {
|
|
186
|
+
console.error('加载更多失败', err);
|
|
187
|
+
} finally {
|
|
188
|
+
this.setData({
|
|
189
|
+
isLoadingMore: false
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
initVoteData(vote) {
|
|
194
|
+
if (!vote) return;
|
|
195
|
+
|
|
196
|
+
const userVotes = vote.user_votes || [];
|
|
197
|
+
const isVoted = userVotes.length > 0;
|
|
198
|
+
const isVoteEnded = Date.now() > vote.end_time * 1000;
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
// 处理选项
|
|
202
|
+
const voteOptions = vote.options.map(o => ({
|
|
203
|
+
...o,
|
|
204
|
+
_selected: userVotes.includes(o.id),
|
|
205
|
+
vote_count: o.vote_count || 0
|
|
206
|
+
}));
|
|
207
|
+
|
|
208
|
+
const hasAnyImage = voteOptions.some(o => o.option_image); // 假设选项图片字段是 o.image
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
// 如果已投票,计算百分比
|
|
212
|
+
if (isVoted || isVoteEnded) {
|
|
213
|
+
const total = voteOptions.reduce((sum, o) => sum + o.vote_count, 0);
|
|
214
|
+
voteOptions.forEach(o => {
|
|
215
|
+
o.percent = total > 0 ? ((o.vote_count / total) * 100).toFixed(1) : '0.0';
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
this.setData({
|
|
220
|
+
voteOptions,
|
|
221
|
+
isVoted,
|
|
222
|
+
selectedVotes: [],
|
|
223
|
+
isVoteEnded: Date.now() > vote.end_time * 1000,
|
|
224
|
+
voteEndTime: vote.end_time ? this.formatTime(vote.end_time) : null,
|
|
225
|
+
voteTitle: this.getVoteTitle(isVoted, vote),
|
|
226
|
+
showVoteImages: hasAnyImage
|
|
227
|
+
|
|
228
|
+
});
|
|
229
|
+
},
|
|
230
|
+
getVoteTitle(isVoted, vote) {
|
|
231
|
+
const typeName = vote.max_choices === 1 ? "单选" : `${vote.max_choices}选`;
|
|
232
|
+
this.setData({
|
|
233
|
+
typeName: typeName
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
if (Date.now() > vote.end_time * 1000) {
|
|
237
|
+
return `投票已结束`;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return isVoted ? `已投票` : `参与投票`;
|
|
241
|
+
},
|
|
242
|
+
formatTime(ts) {
|
|
243
|
+
const d = new Date(ts * 1000);
|
|
244
|
+
|
|
245
|
+
const Y = d.getFullYear();
|
|
246
|
+
const M = String(d.getMonth() + 1).padStart(2, '0');
|
|
247
|
+
const D = String(d.getDate()).padStart(2, '0');
|
|
248
|
+
const h = String(d.getHours()).padStart(2, '0');
|
|
249
|
+
const m = String(d.getMinutes()).padStart(2, '0');
|
|
250
|
+
|
|
251
|
+
return `${Y}-${M}-${D} ${h}:${m}`;
|
|
252
|
+
},
|
|
253
|
+
|
|
254
|
+
initLotteryData(lottery) {
|
|
255
|
+
if (!lottery) return;
|
|
256
|
+
|
|
257
|
+
const now = Date.now() / 1000;
|
|
258
|
+
const isEnded = now > lottery.end_time;
|
|
259
|
+
|
|
260
|
+
const conditionTextMap = {
|
|
261
|
+
1: '评论此贴',
|
|
262
|
+
2: '转发此贴',
|
|
263
|
+
3: '评论并转发此贴',
|
|
264
|
+
4: '发表话题',
|
|
265
|
+
5: '关注作者',
|
|
266
|
+
6: '关注游戏'
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
const lotteryConditions = (lottery.conditions || []).map((cond, idx) => {
|
|
270
|
+
let parts = [];
|
|
271
|
+
|
|
272
|
+
switch (cond.condition_type) {
|
|
273
|
+
case 1:
|
|
274
|
+
case 2:
|
|
275
|
+
case 3:
|
|
276
|
+
case 5:
|
|
277
|
+
parts.push({
|
|
278
|
+
text: conditionTextMap[cond.condition_type],
|
|
279
|
+
color: '#333',
|
|
280
|
+
clickable: false
|
|
281
|
+
});
|
|
282
|
+
break;
|
|
283
|
+
|
|
284
|
+
case 4: // 发表话题
|
|
285
|
+
parts.push({
|
|
286
|
+
text: '发表话题',
|
|
287
|
+
color: '#333',
|
|
288
|
+
clickable: false
|
|
289
|
+
});
|
|
290
|
+
parts.push({
|
|
291
|
+
text: `#${cond.condition_value}#`,
|
|
292
|
+
color: '#406ce3',
|
|
293
|
+
clickable: true,
|
|
294
|
+
data: {
|
|
295
|
+
type: 'topic',
|
|
296
|
+
name: cond.condition_value
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
break;
|
|
300
|
+
|
|
301
|
+
case 6: // 关注游戏
|
|
302
|
+
parts.push({
|
|
303
|
+
text: '关注游戏',
|
|
304
|
+
color: '#333',
|
|
305
|
+
clickable: false
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
parts.push({
|
|
310
|
+
text: `$${cond.condition_value.game_name}`,
|
|
311
|
+
color: '#406ce3',
|
|
312
|
+
clickable: true,
|
|
313
|
+
data: {
|
|
314
|
+
type: 'game',
|
|
315
|
+
id: cond.condition_value.game_id
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return {
|
|
322
|
+
index: idx + 1,
|
|
323
|
+
parts
|
|
324
|
+
};
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
this.setData({
|
|
328
|
+
lotteryInfo: {
|
|
329
|
+
...lottery,
|
|
330
|
+
isEnded,
|
|
331
|
+
winnerCount: lottery.winner_count,
|
|
332
|
+
conditions: lotteryConditions,
|
|
333
|
+
endTimeText: this.formatTime(lottery.end_time)
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
},
|
|
337
|
+
|
|
338
|
+
// 点击抽奖条件(话题/游戏)
|
|
339
|
+
onLotteryConditionTap(e) {
|
|
340
|
+
const {
|
|
341
|
+
type,
|
|
342
|
+
name,
|
|
343
|
+
id
|
|
344
|
+
} = e.currentTarget.dataset;
|
|
345
|
+
if (!type) return;
|
|
346
|
+
|
|
347
|
+
if (type === 'topic') {
|
|
348
|
+
wx.navigateTo({
|
|
349
|
+
url: `/pages/topic/topic?topic_name=${encodeURIComponent(name)}`
|
|
350
|
+
});
|
|
351
|
+
} else if (type === 'game') {
|
|
352
|
+
wx.navigateTo({
|
|
353
|
+
url: `/pages/game/game?id=${id}`
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
|
|
358
|
+
// 查看中奖名单
|
|
359
|
+
// 查看中奖名单
|
|
360
|
+
onViewWinners() {
|
|
361
|
+
if (!checkLogin()) return;
|
|
362
|
+
const postItem = this.data.item;
|
|
363
|
+
|
|
364
|
+
// 构造抽奖公示页需要的最小帖子对象
|
|
365
|
+
const post = {
|
|
366
|
+
id: postItem.post.id,
|
|
367
|
+
user_id: postItem.user.id, // 发帖人 id(用于判断发起人)
|
|
368
|
+
nickname: postItem.user.nickname, // 发帖人昵称
|
|
369
|
+
avatar: postItem.user.avatar, // 发帖人头像
|
|
370
|
+
cover: postItem.post.imageArray?.[0] || '', // 帖子图(第一张)
|
|
371
|
+
content: postItem.post.content // 帖子内容
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
wx.navigateTo({
|
|
375
|
+
url: `/pages/lottery-winners/lottery-winners?post=${encodeURIComponent(
|
|
376
|
+
JSON.stringify(post)
|
|
377
|
+
)}`
|
|
378
|
+
});
|
|
379
|
+
},
|
|
380
|
+
injectTitle(parts, title) {
|
|
381
|
+
if (!title) return parts;
|
|
382
|
+
parts.unshift({
|
|
383
|
+
text: title,
|
|
384
|
+
color: '#000',
|
|
385
|
+
type: 'title'
|
|
386
|
+
});
|
|
387
|
+
parts.splice(1, 0, {
|
|
388
|
+
type: 'br'
|
|
389
|
+
});
|
|
390
|
+
return parts;
|
|
391
|
+
},
|
|
392
|
+
|
|
393
|
+
// 以下解析、点赞、收藏、关注、投票、评论等逻辑保留
|
|
394
|
+
parseContent(content, images = [], isShared) {
|
|
395
|
+
const parts = [];
|
|
396
|
+
const regex = /(#[^#]+#)|(\{@(.*?)\|(\d+)\})|<font bold=true>|<font bold=false>|<sign_line>|<feature_blog>|<img src='([^']+)'>|<click_img src='[^']+' text='([^']+)'>|<color_grey text='([^']+)'>|<local_img src='([^']+).image'>|<jump_url url='([^']+)'>|(\[\/\d+\])|{\$([^|]+)\|([^}]+)}/g;
|
|
397
|
+
let lastIndex = 0,
|
|
398
|
+
match;
|
|
399
|
+
while ((match = regex.exec(content)) !== null) {
|
|
400
|
+
if (match.index > lastIndex) {
|
|
401
|
+
const plainText = content.slice(lastIndex, match.index);
|
|
402
|
+
this.pushWithLineBreak(parts, plainText);
|
|
403
|
+
}
|
|
404
|
+
if (match[1]) parts.push({
|
|
405
|
+
text: match[1],
|
|
406
|
+
color: '#406ce3',
|
|
407
|
+
type: 'topic'
|
|
408
|
+
});
|
|
409
|
+
else if (match[2]) parts.push({
|
|
410
|
+
text: `@${match[3]}`,
|
|
411
|
+
color: '#406ce3',
|
|
412
|
+
type: 'at',
|
|
413
|
+
userId: match[4]
|
|
414
|
+
});
|
|
415
|
+
else if (match[5]) parts.push({
|
|
416
|
+
text: '[图片]',
|
|
417
|
+
src: match[5],
|
|
418
|
+
type: 'img'
|
|
419
|
+
});
|
|
420
|
+
else if (match[6]) parts.push({
|
|
421
|
+
text: match[6],
|
|
422
|
+
src: match[6],
|
|
423
|
+
type: 'click_img'
|
|
424
|
+
});
|
|
425
|
+
else if (match[7]) parts.push({
|
|
426
|
+
text: match[7],
|
|
427
|
+
color: '#999'
|
|
428
|
+
});
|
|
429
|
+
else if (match[8]) parts.push({
|
|
430
|
+
text: '',
|
|
431
|
+
src: match[8],
|
|
432
|
+
type: 'local_img'
|
|
433
|
+
});
|
|
434
|
+
else if (match[9]) parts.push({
|
|
435
|
+
text: '§网页链接',
|
|
436
|
+
url: match[9],
|
|
437
|
+
type: 'jump_url',
|
|
438
|
+
color: '#406ce3'
|
|
439
|
+
});
|
|
440
|
+
else if (match[10]) {
|
|
441
|
+
const code = match[10].match(/\[\/(\d+)\]/)[1];
|
|
442
|
+
const file = emojiMap[code];
|
|
443
|
+
parts.push(file ? {
|
|
444
|
+
type: 'emoji',
|
|
445
|
+
src: `../../assets/images/emoji/${file}`
|
|
446
|
+
} : {
|
|
447
|
+
text: match[10],
|
|
448
|
+
color: '#333'
|
|
449
|
+
});
|
|
450
|
+
} else if (match[11] && match[12]) parts.push({
|
|
451
|
+
text: `$${match[11]}`,
|
|
452
|
+
gameId: match[12],
|
|
453
|
+
type: 'game',
|
|
454
|
+
color: '#406ce3'
|
|
455
|
+
});
|
|
456
|
+
else if (match[0] === '<font bold=true>') parts.push({
|
|
457
|
+
text: '',
|
|
458
|
+
bold: true
|
|
459
|
+
});
|
|
460
|
+
else if (match[0] === '<font bold=false>') parts.push({
|
|
461
|
+
text: '',
|
|
462
|
+
bold: false
|
|
463
|
+
});
|
|
464
|
+
else if (match[0] === '<sign_line>') parts.push({
|
|
465
|
+
text: '————',
|
|
466
|
+
type: 'line'
|
|
467
|
+
});
|
|
468
|
+
else if (match[0] === '<feature_blog>') parts.push({
|
|
469
|
+
text: '[加精]',
|
|
470
|
+
type: 'feature'
|
|
471
|
+
});
|
|
472
|
+
lastIndex = regex.lastIndex;
|
|
473
|
+
}
|
|
474
|
+
if (lastIndex < content?.length) this.pushWithLineBreak(parts, content.slice(lastIndex));
|
|
475
|
+
if (isShared && images.length) images.forEach(src => parts.push({
|
|
476
|
+
type: 'image',
|
|
477
|
+
text: '[查看图片]',
|
|
478
|
+
color: '#406ce3',
|
|
479
|
+
src
|
|
480
|
+
}));
|
|
481
|
+
return parts;
|
|
482
|
+
},
|
|
483
|
+
|
|
484
|
+
pushWithLineBreak(parts, text) {
|
|
485
|
+
const segments = text.split(/(\r\n|\n|\r)/);
|
|
486
|
+
segments.forEach(seg => {
|
|
487
|
+
if (seg.match(/\r\n|\n|\r/)) parts.push({
|
|
488
|
+
type: 'br'
|
|
489
|
+
});
|
|
490
|
+
else if (seg.length > 0) parts.push({
|
|
491
|
+
text: seg,
|
|
492
|
+
color: '#333'
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
},
|
|
496
|
+
|
|
497
|
+
formatPost(item) {
|
|
498
|
+
const newItem = {
|
|
499
|
+
...item,
|
|
500
|
+
post: {
|
|
501
|
+
...item.post,
|
|
502
|
+
formatTime: formatUTC(item.post.created_at),
|
|
503
|
+
imageArray: item.post.images ? item.post.images.split(',') : []
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
if (item.shared && item.shared.post) {
|
|
507
|
+
newItem.shared = {
|
|
508
|
+
...item.shared,
|
|
509
|
+
post: {
|
|
510
|
+
...item.shared.post,
|
|
511
|
+
formatTime: formatUTC(item.shared.post.created_at),
|
|
512
|
+
imageArray: item.shared.post.images ? item.shared.post.images.split(',') : []
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
return newItem;
|
|
517
|
+
},
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
onPartTap(e) {
|
|
521
|
+
const {
|
|
522
|
+
type,
|
|
523
|
+
id,
|
|
524
|
+
text
|
|
525
|
+
} = e.currentTarget.dataset;
|
|
526
|
+
switch (type) {
|
|
527
|
+
case 'topic':
|
|
528
|
+
const topicText = text;
|
|
529
|
+
const topicName = topicText.replace(/#/g, ''); // 去掉首尾 #
|
|
530
|
+
wx.navigateTo({
|
|
531
|
+
url: `/pages/topic/topic?topic_name=${encodeURIComponent(topicName)}`
|
|
532
|
+
});
|
|
533
|
+
break;
|
|
534
|
+
|
|
535
|
+
case 'at':
|
|
536
|
+
wx.navigateTo({
|
|
537
|
+
url: `/pages/user/user?id=${id}`
|
|
538
|
+
});
|
|
539
|
+
break;
|
|
540
|
+
|
|
541
|
+
case 'game':
|
|
542
|
+
wx.navigateTo({
|
|
543
|
+
url: `/pages/game/game?id=${id}`
|
|
544
|
+
});
|
|
545
|
+
break;
|
|
546
|
+
|
|
547
|
+
}
|
|
548
|
+
},
|
|
549
|
+
|
|
550
|
+
onJumpUrlTap(e) {
|
|
551
|
+
const url = e.currentTarget.dataset.url;
|
|
552
|
+
|
|
553
|
+
if (!url) return;
|
|
554
|
+
|
|
555
|
+
wx.navigateTo({
|
|
556
|
+
url: `/pages/webview/webview?url=${encodeURIComponent(url)}`
|
|
557
|
+
});
|
|
558
|
+
},
|
|
559
|
+
|
|
560
|
+
});
|