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,665 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getBanner,
|
|
3
|
+
queryPublicPost,
|
|
4
|
+
commentPost,
|
|
5
|
+
queryUserNotRead,
|
|
6
|
+
followUser,
|
|
7
|
+
likePost,
|
|
8
|
+
deleteContent,
|
|
9
|
+
collectPost,
|
|
10
|
+
setUserPostTop
|
|
11
|
+
} from "../../services/home"
|
|
12
|
+
import {
|
|
13
|
+
getLevelByExp,
|
|
14
|
+
getLevelImg
|
|
15
|
+
} from '../../utils/exp';
|
|
16
|
+
import querySelect from "../../utils/query-select"
|
|
17
|
+
import formatUTC from "../../utils/formatPost.js"
|
|
18
|
+
import {
|
|
19
|
+
throttle
|
|
20
|
+
} from "underscore"
|
|
21
|
+
import {
|
|
22
|
+
checkLogin
|
|
23
|
+
} from "../../utils/auth"
|
|
24
|
+
|
|
25
|
+
const throttleQuerySelect = throttle(querySelect, 100)
|
|
26
|
+
|
|
27
|
+
Page({
|
|
28
|
+
data: {
|
|
29
|
+
|
|
30
|
+
statusBarHeight: 0, // 动态计算
|
|
31
|
+
|
|
32
|
+
showMenu: false,
|
|
33
|
+
navTotalHeight: 88,
|
|
34
|
+
|
|
35
|
+
banners: [],
|
|
36
|
+
bannerHeight: 0,
|
|
37
|
+
currentPage: 1,
|
|
38
|
+
posts: [],
|
|
39
|
+
isLoading: false,
|
|
40
|
+
hasMore: true,
|
|
41
|
+
|
|
42
|
+
showSheet: false,
|
|
43
|
+
sheetMode: 'forward',
|
|
44
|
+
originPost: {},
|
|
45
|
+
avatar: '',
|
|
46
|
+
|
|
47
|
+
unreadCount: 0, // 消息角标数量
|
|
48
|
+
|
|
49
|
+
moreSheetVisible: false,
|
|
50
|
+
moreSheetItem: {},
|
|
51
|
+
isOwner: false, //当前cell是否是自己
|
|
52
|
+
loading: true, //骨架屏
|
|
53
|
+
|
|
54
|
+
currentPlayingVideoId: null, //当前播放视频帖子id
|
|
55
|
+
},
|
|
56
|
+
gotoMessagePage() {
|
|
57
|
+
this.pauseCurrentPlayingVideo()
|
|
58
|
+
if (!checkLogin()) return;
|
|
59
|
+
wx.navigateTo({
|
|
60
|
+
url: '/pages/message/messageEntire/messageEntire',
|
|
61
|
+
})
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
gotoUserCenter() {
|
|
65
|
+
this.pauseCurrentPlayingVideo()
|
|
66
|
+
if (!checkLogin()) return;
|
|
67
|
+
const userId = wx.getStorageSync('appuid')
|
|
68
|
+
if (!userId) return;
|
|
69
|
+
wx.navigateTo({
|
|
70
|
+
url: `/pages/user/user?id=${userId}`
|
|
71
|
+
});
|
|
72
|
+
this.setData({
|
|
73
|
+
showMenu: false
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
toggleMenu() {
|
|
77
|
+
this.pauseCurrentPlayingVideo()
|
|
78
|
+
if (!checkLogin()) return;
|
|
79
|
+
this.setData({
|
|
80
|
+
showMenu: !this.data.showMenu
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
hideMenu() {
|
|
85
|
+
this.setData({
|
|
86
|
+
showMenu: false
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
logout() {
|
|
91
|
+
wx.clearStorageSync('token');
|
|
92
|
+
wx.clearStorageSync('appuid');
|
|
93
|
+
wx.clearStorageSync('nickname');
|
|
94
|
+
wx.clearStorageSync('avatar');
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
this.setData({
|
|
98
|
+
showMenu: false
|
|
99
|
+
});
|
|
100
|
+
wx.showToast({
|
|
101
|
+
title: '已退出登录',
|
|
102
|
+
icon: 'success'
|
|
103
|
+
});
|
|
104
|
+
wx.startPullDownRefresh();
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
onShowSheet(topic) {
|
|
109
|
+
const sheet = this.selectComponent('#bottomSheet');
|
|
110
|
+
if (sheet) {
|
|
111
|
+
sheet.setData({
|
|
112
|
+
selectedTopic: topic,
|
|
113
|
+
visible: true
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
// 发布按钮点击
|
|
118
|
+
onPublish() {
|
|
119
|
+
const token = wx.getStorageSync('token'); // 读取缓存里的 token
|
|
120
|
+
this.pauseCurrentPlayingVideo()
|
|
121
|
+
if (token) {
|
|
122
|
+
// 已登录,跳转到发布页面
|
|
123
|
+
wx.navigateTo({
|
|
124
|
+
url: '/pages/post-editor/post-editor',
|
|
125
|
+
// url:'/pages/demo/demo'
|
|
126
|
+
});
|
|
127
|
+
} else {
|
|
128
|
+
// 未登录,跳转登录页面
|
|
129
|
+
wx.navigateTo({
|
|
130
|
+
url: '/pages/commonLogin/commonLogin',
|
|
131
|
+
// url:'/pages/login/login'
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
setNavHeight() {
|
|
136
|
+
const info = wx.getWindowInfo();
|
|
137
|
+
const statusBarHeight = info.statusBarHeight;
|
|
138
|
+
|
|
139
|
+
this.setData({
|
|
140
|
+
statusBarHeight,
|
|
141
|
+
navTotalHeight: statusBarHeight + 44
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
onLoad(options) {
|
|
145
|
+
this.setNavHeight()
|
|
146
|
+
// 1️⃣ 优先使用 app 全局参数(从分享打开时)
|
|
147
|
+
const app = getApp();
|
|
148
|
+
const query = app.globalData.launchQuery || options;
|
|
149
|
+
// 游戏社区
|
|
150
|
+
if (query.type === 'game' && query.id) {
|
|
151
|
+
app.globalData.launchQuery = null;
|
|
152
|
+
wx.redirectTo({
|
|
153
|
+
url: `/pages/game/game?id=${query.id}`,
|
|
154
|
+
});
|
|
155
|
+
} else if (query.type === 'user' && query.id) {
|
|
156
|
+
// 用户中心
|
|
157
|
+
app.globalData.launchQuery = null;
|
|
158
|
+
wx.redirectTo({
|
|
159
|
+
url: `/pages/user/user?id=${query.id}`
|
|
160
|
+
});
|
|
161
|
+
} else if (query.type === 'post' && query.id) {
|
|
162
|
+
// 帖子详情
|
|
163
|
+
app.globalData.launchQuery = null;
|
|
164
|
+
wx.redirectTo({
|
|
165
|
+
url: `/pages/post/post?id=${query.id}`,
|
|
166
|
+
});
|
|
167
|
+
} else if (query.type === 'topic' && query.id) {
|
|
168
|
+
// 话题
|
|
169
|
+
app.globalData.launchQuery = null;
|
|
170
|
+
wx.redirectTo({
|
|
171
|
+
url: `/pages/topic/topic?id=${query.id}`,
|
|
172
|
+
});
|
|
173
|
+
} else {
|
|
174
|
+
// console.log('无参数,留在首页');
|
|
175
|
+
this.getData()
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
},
|
|
179
|
+
onShow() {
|
|
180
|
+
this.setData({
|
|
181
|
+
avatar: wx.getStorageSync('avatar'),
|
|
182
|
+
});
|
|
183
|
+
if (!wx.getStorageSync('token')) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
queryUserNotRead().then(res => {
|
|
187
|
+
if (!res.count) {
|
|
188
|
+
this.setData({
|
|
189
|
+
unreadCount: 0
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
if (res.count && Array.isArray(res.count)) {
|
|
193
|
+
const topCount = res.count.slice(0, 3).reduce((sum, item) => sum + item, 0);
|
|
194
|
+
this.setData({
|
|
195
|
+
unreadCount: topCount
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
async getData() {
|
|
204
|
+
try {
|
|
205
|
+
const res = await getBanner()
|
|
206
|
+
this.setData({
|
|
207
|
+
banners: res.data
|
|
208
|
+
})
|
|
209
|
+
const post = await queryPublicPost(1, 2)
|
|
210
|
+
|
|
211
|
+
this.setData({
|
|
212
|
+
posts: this.formatPost(post),
|
|
213
|
+
currentPage: 1,
|
|
214
|
+
hasMore: post.data.length > 0,
|
|
215
|
+
loading: false
|
|
216
|
+
})
|
|
217
|
+
} catch (err) {
|
|
218
|
+
console.error('加载失败', err)
|
|
219
|
+
} finally {
|
|
220
|
+
this.setData({
|
|
221
|
+
loading: false
|
|
222
|
+
})
|
|
223
|
+
wx.stopPullDownRefresh()
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
|
|
227
|
+
formatPost(post) {
|
|
228
|
+
// data为空时返回的是空对象{}
|
|
229
|
+
if (!Array.isArray(post.data)) return [];
|
|
230
|
+
const formatPost = post.data.map(item => {
|
|
231
|
+
const user = item.user || {};
|
|
232
|
+
// 处理用户等级
|
|
233
|
+
if (item.game?.exp != null) {
|
|
234
|
+
// user.level = getLevelByExp(item.game.exp);
|
|
235
|
+
// user.levelImg = getLevelImg(user.level)
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const newItem = {
|
|
239
|
+
...item,
|
|
240
|
+
post: {
|
|
241
|
+
...item.post,
|
|
242
|
+
formatTime: formatUTC(item.post.created_at),
|
|
243
|
+
imageArray: item.post.images ? item.post.images.split(',') : [],
|
|
244
|
+
vote: item.post.vote || null
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
// 处理转发的原始帖
|
|
249
|
+
if (item.shared && item.shared.post) {
|
|
250
|
+
newItem.shared = {
|
|
251
|
+
...item.shared,
|
|
252
|
+
post: {
|
|
253
|
+
...item.shared.post,
|
|
254
|
+
formatTime: formatUTC(item.shared.post.created_at),
|
|
255
|
+
imageArray: item.shared.post.images ? item.shared.post.images.split(',') : [],
|
|
256
|
+
vote: item.shared.post.vote || null
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
return newItem;
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
return formatPost;
|
|
264
|
+
},
|
|
265
|
+
|
|
266
|
+
onBannerImageLoad() {
|
|
267
|
+
this.getBannerHeight()
|
|
268
|
+
},
|
|
269
|
+
|
|
270
|
+
getBannerHeight() {
|
|
271
|
+
// querySelect(".cover-image").then(res => {
|
|
272
|
+
// this.setData({
|
|
273
|
+
// bannerHeight: res[0].height
|
|
274
|
+
// });
|
|
275
|
+
// });
|
|
276
|
+
},
|
|
277
|
+
|
|
278
|
+
onPullDownRefresh() {
|
|
279
|
+
this.getData()
|
|
280
|
+
},
|
|
281
|
+
// 页面触底事件
|
|
282
|
+
async onReachBottom() {
|
|
283
|
+
if (this.data.isLoading || !this.data.hasMore) return
|
|
284
|
+
|
|
285
|
+
this.setData({
|
|
286
|
+
isLoading: true
|
|
287
|
+
})
|
|
288
|
+
|
|
289
|
+
const nextPage = this.data.currentPage + 1
|
|
290
|
+
|
|
291
|
+
try {
|
|
292
|
+
const res = await queryPublicPost(nextPage, 2)
|
|
293
|
+
const formatPost = this.formatPost(res)
|
|
294
|
+
const currentLength = this.data.posts.length
|
|
295
|
+
|
|
296
|
+
// 1. 更新 currentPage, hasMore, isLoading
|
|
297
|
+
this.setData({
|
|
298
|
+
currentPage: nextPage,
|
|
299
|
+
hasMore: res.data?.length > 0,
|
|
300
|
+
isLoading: false
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
// 2. 批量新增 posts(只更新新增数据,不替换整个数组)
|
|
304
|
+
let update = {}
|
|
305
|
+
formatPost.forEach((item, index) => {
|
|
306
|
+
update[`posts[${currentLength + index}]`] = item
|
|
307
|
+
})
|
|
308
|
+
this.setData(update)
|
|
309
|
+
|
|
310
|
+
} catch (err) {
|
|
311
|
+
console.error("加载更多失败", err)
|
|
312
|
+
this.setData({
|
|
313
|
+
isLoading: false
|
|
314
|
+
})
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
|
|
318
|
+
gotoGameCenter(e) {
|
|
319
|
+
const gameId = e.currentTarget.dataset.id;
|
|
320
|
+
this.pauseCurrentPlayingVideo()
|
|
321
|
+
wx.navigateTo({
|
|
322
|
+
url: `/pages/game/game?id=${gameId}`
|
|
323
|
+
});
|
|
324
|
+
},
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
onFollowChanged(e) {
|
|
328
|
+
const {
|
|
329
|
+
userId,
|
|
330
|
+
isFans
|
|
331
|
+
} = e.detail;
|
|
332
|
+
|
|
333
|
+
const updatedPosts = this.data.posts.map(p => {
|
|
334
|
+
if (p.user.id === userId) {
|
|
335
|
+
p.user.is_fans = isFans;
|
|
336
|
+
}
|
|
337
|
+
return p;
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
this.setData({
|
|
341
|
+
posts: updatedPosts
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
wx.showToast({
|
|
345
|
+
title: isFans ? '关注成功' : '已取消关注',
|
|
346
|
+
icon: 'success'
|
|
347
|
+
});
|
|
348
|
+
},
|
|
349
|
+
onShareTap(e) {
|
|
350
|
+
this.setData({
|
|
351
|
+
sheetMode: 'forward',
|
|
352
|
+
showSheet: true,
|
|
353
|
+
originPost: e.detail.item,
|
|
354
|
+
commentData: null
|
|
355
|
+
}, () => {
|
|
356
|
+
const sheet = this.selectComponent('#bottomSheet');
|
|
357
|
+
if (sheet) {
|
|
358
|
+
if (wx.getStorageSync('height') != 0) {
|
|
359
|
+
sheet.updateSheetPosition(wx.getStorageSync('height'));
|
|
360
|
+
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
},
|
|
365
|
+
onCommentTap(e) {
|
|
366
|
+
// this.setData({
|
|
367
|
+
// sheetMode: 'comment',
|
|
368
|
+
// showSheet: true,
|
|
369
|
+
// originPost: e.detail.item
|
|
370
|
+
// })
|
|
371
|
+
|
|
372
|
+
const postId = e.detail.item.post.id;
|
|
373
|
+
this.pauseCurrentPlayingVideo()
|
|
374
|
+
wx.navigateTo({
|
|
375
|
+
url: `/pages/post/post?id=${postId}&isCommentIn=true`
|
|
376
|
+
});
|
|
377
|
+
},
|
|
378
|
+
|
|
379
|
+
chooseTopic(e) {
|
|
380
|
+
this.pauseCurrentPlayingVideo()
|
|
381
|
+
wx.navigateTo({
|
|
382
|
+
url: '/pages/addSubject/addSubject',
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
},
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
// 底部弹窗
|
|
390
|
+
|
|
391
|
+
onMoreTap(e) {
|
|
392
|
+
const index = e.currentTarget.dataset.index; // 当前帖子的索引
|
|
393
|
+
|
|
394
|
+
const item = e.detail.item;
|
|
395
|
+
const currentUserId = wx.getStorageSync('appuid'); // 当前登录用户id
|
|
396
|
+
const isOwner = item.user.id === currentUserId;
|
|
397
|
+
this.setData({
|
|
398
|
+
isOwner,
|
|
399
|
+
moreSheetVisible: true,
|
|
400
|
+
moreSheetItem: item,
|
|
401
|
+
currentPostIndex: index
|
|
402
|
+
});
|
|
403
|
+
},
|
|
404
|
+
|
|
405
|
+
onPinTap() {
|
|
406
|
+
const post = this.data.moreSheetItem.post;
|
|
407
|
+
const type = this.data.isPinned ? 2 : 1; // 1置顶,2取消置顶
|
|
408
|
+
|
|
409
|
+
wx.showLoading({
|
|
410
|
+
title: '处理中...'
|
|
411
|
+
});
|
|
412
|
+
setUserPostTop(post.id, type).then(res => {
|
|
413
|
+
wx.hideLoading();
|
|
414
|
+
if (res.code === 0) {
|
|
415
|
+
wx.showToast({
|
|
416
|
+
title: type === 1 ? '置顶成功' : '取消置顶成功',
|
|
417
|
+
icon: 'success'
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
// 更新当前组件状态
|
|
421
|
+
this.setData({
|
|
422
|
+
'item.post.is_user_top': type === 1 ? 1 : 0,
|
|
423
|
+
isPinned: type === 1 ? 1 : 0
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
this.onCloseMoreSheet();
|
|
427
|
+
|
|
428
|
+
// 如果置顶,则需要移动帖子到列表第一位,取消其他帖子置顶,并滚动到顶部
|
|
429
|
+
if (type === 1) {
|
|
430
|
+
const pages = getCurrentPages();
|
|
431
|
+
const currentPage = pages[pages.length - 1];
|
|
432
|
+
|
|
433
|
+
if (currentPage.route === 'pages/user/user') {
|
|
434
|
+
let postsData = currentPage.data.posts;
|
|
435
|
+
|
|
436
|
+
if (Array.isArray(postsData)) {
|
|
437
|
+
// 先取消其他帖子置顶
|
|
438
|
+
postsData = postsData.map(p => {
|
|
439
|
+
if (p.post.id !== post.id && p.post.is_user_top === 1) {
|
|
440
|
+
p.post.is_user_top = 0;
|
|
441
|
+
}
|
|
442
|
+
return p;
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
// 找到当前帖子在数组中的索引
|
|
446
|
+
const currentIndex = postsData.findIndex(p => p.post.id === post.id);
|
|
447
|
+
if (currentIndex > -1) {
|
|
448
|
+
const [pinnedPost] = postsData.splice(currentIndex, 1);
|
|
449
|
+
pinnedPost.post.is_user_top = 1
|
|
450
|
+
// 插入到数组第一个位置
|
|
451
|
+
postsData.unshift(pinnedPost);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
currentPage.setData({
|
|
455
|
+
posts: postsData
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
// 页面滚动到顶部
|
|
459
|
+
wx.pageScrollTo({
|
|
460
|
+
scrollTop: 0,
|
|
461
|
+
duration: 300
|
|
462
|
+
});
|
|
463
|
+
} else if (postsData && typeof postsData === 'object') {
|
|
464
|
+
const newPostsObj = {};
|
|
465
|
+
Object.keys(postsData).forEach(key => {
|
|
466
|
+
if (Array.isArray(postsData[key])) {
|
|
467
|
+
// 取消其他帖子置顶
|
|
468
|
+
let arr = postsData[key].map(p => {
|
|
469
|
+
if (p.post.id !== post.id && p.post.is_user_top === 1) {
|
|
470
|
+
p.post.is_user_top = 0;
|
|
471
|
+
}
|
|
472
|
+
return p;
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
// 将当前帖子移动到第一个
|
|
476
|
+
const currentIndex = arr.findIndex(p => p.post.id === post.id);
|
|
477
|
+
if (currentIndex > -1) {
|
|
478
|
+
const [pinnedPost] = arr.splice(currentIndex, 1);
|
|
479
|
+
pinnedPost.post.is_user_top = 1
|
|
480
|
+
arr.unshift(pinnedPost);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
newPostsObj[key] = arr;
|
|
484
|
+
} else {
|
|
485
|
+
newPostsObj[key] = postsData[key];
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
currentPage.setData({
|
|
490
|
+
posts: newPostsObj
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
wx.pageScrollTo({
|
|
494
|
+
scrollTop: 0,
|
|
495
|
+
duration: 300
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
} else {
|
|
501
|
+
wx.showToast({
|
|
502
|
+
title: res.msg || '操作失败',
|
|
503
|
+
icon: 'error'
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
},
|
|
508
|
+
// 关闭弹窗
|
|
509
|
+
onCloseMoreSheet() {
|
|
510
|
+
this.setData({
|
|
511
|
+
moreSheetVisible: false
|
|
512
|
+
});
|
|
513
|
+
},
|
|
514
|
+
|
|
515
|
+
// 弹窗选项点击
|
|
516
|
+
onDelete() {
|
|
517
|
+
const postId = this.data.moreSheetItem.post.id;
|
|
518
|
+
deleteContent(postId).then(res => {
|
|
519
|
+
if (res.code === 0) {
|
|
520
|
+
wx.showToast({
|
|
521
|
+
title: '删除成功',
|
|
522
|
+
icon: 'success'
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
// 删除父页面列表里的帖子(兼容数组和对象)
|
|
526
|
+
const pages = getCurrentPages();
|
|
527
|
+
const currentPage = pages[pages.length - 1]; // 当前页
|
|
528
|
+
|
|
529
|
+
const postsData = currentPage.data.posts;
|
|
530
|
+
if (Array.isArray(postsData)) {
|
|
531
|
+
// posts 是数组
|
|
532
|
+
currentPage.setData({
|
|
533
|
+
posts: postsData.filter(p => p.post.id !== postId)
|
|
534
|
+
});
|
|
535
|
+
} else if (postsData && typeof postsData === 'object') {
|
|
536
|
+
// posts 是对象,每个 value 都可能是帖子数组
|
|
537
|
+
const newPosts = {};
|
|
538
|
+
Object.keys(postsData).forEach(key => {
|
|
539
|
+
if (Array.isArray(postsData[key])) {
|
|
540
|
+
newPosts[key] = postsData[key].filter(p => p.post.id !== postId);
|
|
541
|
+
} else {
|
|
542
|
+
newPosts[key] = postsData[key]; // 保留原值
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
currentPage.setData({
|
|
546
|
+
posts: newPosts
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
this.triggerEvent('deletePost', {
|
|
552
|
+
post: this.data.moreSheetItem.post
|
|
553
|
+
});
|
|
554
|
+
this.onCloseMoreSheet();
|
|
555
|
+
} else {
|
|
556
|
+
wx.showToast({
|
|
557
|
+
title: res.msg || '删除失败',
|
|
558
|
+
icon: 'error'
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
},
|
|
563
|
+
|
|
564
|
+
// 举报帖子
|
|
565
|
+
onReport() {
|
|
566
|
+
this.pauseCurrentPlayingVideo()
|
|
567
|
+
wx.navigateTo({
|
|
568
|
+
url: `/pages/report-category/report-category?postId=${this.data.moreSheetItem.post.id}`,
|
|
569
|
+
})
|
|
570
|
+
|
|
571
|
+
this.triggerEvent('reportPost', {
|
|
572
|
+
post: this.data.moreSheetItem.post
|
|
573
|
+
});
|
|
574
|
+
this.onCloseMoreSheet();
|
|
575
|
+
},
|
|
576
|
+
|
|
577
|
+
// 收藏/取消收藏
|
|
578
|
+
onFavorite() {
|
|
579
|
+
const index = this.data.currentPostIndex;
|
|
580
|
+
const post = this.data.posts[index].post;
|
|
581
|
+
const nType = post.is_collect === 1 ? 2 : 1; // 1收藏,2取消收藏
|
|
582
|
+
|
|
583
|
+
collectPost(post.id, nType).then(res => {
|
|
584
|
+
if (res.code === 0) {
|
|
585
|
+
wx.showToast({
|
|
586
|
+
title: nType === 1 ? '已收藏' : '取消收藏',
|
|
587
|
+
icon: 'success'
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
// 更新 posts 列表里的状态
|
|
591
|
+
const key = `posts[${index}].post.is_collect`;
|
|
592
|
+
this.setData({
|
|
593
|
+
[key]: nType === 1 ? 1 : 0
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
this.onCloseMoreSheet();
|
|
597
|
+
} else {
|
|
598
|
+
wx.showToast({
|
|
599
|
+
title: res.msg || (nType === 1 ? '收藏失败' : '取消收藏失败'),
|
|
600
|
+
icon: 'error'
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
},
|
|
605
|
+
|
|
606
|
+
onVideoPlay(e) {
|
|
607
|
+
|
|
608
|
+
const postId = e.detail.id;
|
|
609
|
+
const prevId = this.data.currentPlayingVideoId;
|
|
610
|
+
|
|
611
|
+
if (prevId && prevId !== postId) {
|
|
612
|
+
// 1️⃣ 获取上一个视频所在的组件实例
|
|
613
|
+
const prevIndex = this.data.posts.findIndex(p => p.post.id === prevId);
|
|
614
|
+
const prevComponent = this.selectComponent(`#postItem-${prevIndex}`);
|
|
615
|
+
if (prevComponent) {
|
|
616
|
+
prevComponent.pauseVideo();
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
// 更新当前播放视频
|
|
621
|
+
this.setData({
|
|
622
|
+
currentPlayingVideoId: postId
|
|
623
|
+
});
|
|
624
|
+
},
|
|
625
|
+
|
|
626
|
+
onPauseAllVideo() {
|
|
627
|
+
this.pauseCurrentPlayingVideo()
|
|
628
|
+
},
|
|
629
|
+
/**
|
|
630
|
+
* 暂停当前页面正在播放的视频
|
|
631
|
+
*/
|
|
632
|
+
pauseCurrentPlayingVideo() {
|
|
633
|
+
const playingId = this.data.currentPlayingVideoId;
|
|
634
|
+
if (!playingId) return;
|
|
635
|
+
|
|
636
|
+
// 找到该 post 在 posts 中的 index
|
|
637
|
+
const index = this.data.posts.findIndex(
|
|
638
|
+
item => item.post.id === playingId
|
|
639
|
+
);
|
|
640
|
+
|
|
641
|
+
if (index === -1) return;
|
|
642
|
+
|
|
643
|
+
// 拿到对应的 postItem 组件
|
|
644
|
+
const postItem = this.selectComponent(`#postItem-${index}`);
|
|
645
|
+
|
|
646
|
+
if (postItem && typeof postItem.pauseVideo === 'function') {
|
|
647
|
+
postItem.pauseVideo();
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
// 清空当前播放状态
|
|
651
|
+
this.setData({
|
|
652
|
+
currentPlayingVideoId: null
|
|
653
|
+
});
|
|
654
|
+
},
|
|
655
|
+
|
|
656
|
+
gotoTest() {
|
|
657
|
+
wx.navigateTo({
|
|
658
|
+
url: `/pages/officialWebview/officialWebview?url=${encodeURIComponent('https://www.southnote.cn')}`
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"usingComponents": {
|
|
3
|
+
"van-search": "@vant/weapp/search/index",
|
|
4
|
+
"post-item":"/components/post-item/post-item",
|
|
5
|
+
"bottomSheet":"/components/bottomSheet/bottomSheet"
|
|
6
|
+
},
|
|
7
|
+
"navigationBarTitleText": "首页",
|
|
8
|
+
"enablePullDownRefresh": true,
|
|
9
|
+
"navigationStyle": "custom"
|
|
10
|
+
}
|