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,473 @@
|
|
|
1
|
+
import {
|
|
2
|
+
compressImages
|
|
3
|
+
} from "../../utils/compressImage"
|
|
4
|
+
import sensitive from '../../utils/sensitive'
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
commentPostNew,
|
|
8
|
+
getUploadToken
|
|
9
|
+
} from "../../services/home"
|
|
10
|
+
Component({
|
|
11
|
+
properties: {
|
|
12
|
+
visible: {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
value: false
|
|
15
|
+
},
|
|
16
|
+
mode: {
|
|
17
|
+
type: String,
|
|
18
|
+
value: 'forward' // 'forward' or 'comment'
|
|
19
|
+
},
|
|
20
|
+
// 帖子内容+user信息
|
|
21
|
+
originData: {
|
|
22
|
+
type: Object,
|
|
23
|
+
value: null
|
|
24
|
+
},
|
|
25
|
+
// 回复的评论内容
|
|
26
|
+
commentData: {
|
|
27
|
+
type: Object,
|
|
28
|
+
value: null
|
|
29
|
+
},
|
|
30
|
+
autoFocus: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
value: false
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
data: {
|
|
39
|
+
content: '',
|
|
40
|
+
alsoComment: false,
|
|
41
|
+
images: [],
|
|
42
|
+
|
|
43
|
+
emojiVisible: false,
|
|
44
|
+
emojiList: [],
|
|
45
|
+
|
|
46
|
+
cursor: 0, // 光标位置
|
|
47
|
+
textareaHeight: 'calc(100vh - 180rpx)', // 默认高度
|
|
48
|
+
|
|
49
|
+
keyboardHeight: 0, // 当前键盘高度
|
|
50
|
+
sheetBottom: 420, // sheet 的偏移(被顶上去的距离)
|
|
51
|
+
|
|
52
|
+
selectedTopic: {}, //转发或者评论选择的话题
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
observers: {
|
|
56
|
+
|
|
57
|
+
'selectedTopic': function (topic) {
|
|
58
|
+
if (topic && topic.name) {
|
|
59
|
+
this.insertSelectedTopic();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
lifetimes: {
|
|
68
|
+
|
|
69
|
+
attached() {
|
|
70
|
+
|
|
71
|
+
// 初始化 emoji 列表
|
|
72
|
+
let list = [];
|
|
73
|
+
for (let i = 1; i <= 44; i++) {
|
|
74
|
+
const num = i.toString().padStart(3, '0');
|
|
75
|
+
list.push(`/assets/images/emoji/smile${num}.png`);
|
|
76
|
+
}
|
|
77
|
+
this.setData({
|
|
78
|
+
emojiList: list
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
wx.onKeyboardHeightChange(res => {
|
|
83
|
+
|
|
84
|
+
console.log('键盘高度变化:', res.height);
|
|
85
|
+
if (res.height > 0) {
|
|
86
|
+
wx.setStorageSync('height', res.height)
|
|
87
|
+
this.setData({
|
|
88
|
+
keyboardHeight: res.height,
|
|
89
|
+
emojiVisible: false, // 有键盘时隐藏emoji面板
|
|
90
|
+
});
|
|
91
|
+
} else {
|
|
92
|
+
this.setData({
|
|
93
|
+
keyboardHeight: 0,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
this.updateSheetPosition(res.height);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
detached() {
|
|
104
|
+
wx.offKeyboardHeightChange(); // 组件卸载时移除监听
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
methods: {
|
|
110
|
+
insertSelectedTopic() {
|
|
111
|
+
const topic = this.data.selectedTopic;
|
|
112
|
+
|
|
113
|
+
if (!topic || !topic.name) return;
|
|
114
|
+
|
|
115
|
+
const {
|
|
116
|
+
content,
|
|
117
|
+
cursor
|
|
118
|
+
} = this.data;
|
|
119
|
+
const topicText = `#${topic.name}#`;
|
|
120
|
+
const newContent =
|
|
121
|
+
content.slice(0, cursor) + topicText + content.slice(cursor);
|
|
122
|
+
|
|
123
|
+
this.setData({
|
|
124
|
+
content: newContent,
|
|
125
|
+
cursor: cursor + topicText.length,
|
|
126
|
+
selectedTopic: null // 插入完清空,避免重复插入
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// 通知外层或父组件(可选)
|
|
130
|
+
this.triggerEvent("input", {
|
|
131
|
+
value: newContent,
|
|
132
|
+
cursor: this.data.cursor
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
updateSheetPosition(height) {
|
|
138
|
+
const bottom = height;
|
|
139
|
+
this.setData({
|
|
140
|
+
sheetBottom: bottom
|
|
141
|
+
});
|
|
142
|
+
},
|
|
143
|
+
// 点击遮罩时关闭
|
|
144
|
+
onOverlayTap() {
|
|
145
|
+
this.closeSheet();
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
stopTap() {},
|
|
149
|
+
|
|
150
|
+
closeSheet() {
|
|
151
|
+
this.setData({
|
|
152
|
+
visible: false,
|
|
153
|
+
content: '',
|
|
154
|
+
alsoComment: false,
|
|
155
|
+
emojiVisible: false,
|
|
156
|
+
images: [],
|
|
157
|
+
cursor: 0
|
|
158
|
+
});
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
onInput(e) {
|
|
162
|
+
const v = e.detail.value || '';
|
|
163
|
+
this.setData({
|
|
164
|
+
content: v.slice(0, 300),
|
|
165
|
+
cursor: e.detail.cursor || 0
|
|
166
|
+
});
|
|
167
|
+
this.triggerEvent('input', {
|
|
168
|
+
value: this.data.content,
|
|
169
|
+
cursor: this.data.cursor
|
|
170
|
+
});
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
onBlur(e) {
|
|
174
|
+
this.setData({
|
|
175
|
+
cursor: e.detail.cursor || 0
|
|
176
|
+
});
|
|
177
|
+
this.triggerEvent('blur', {
|
|
178
|
+
cursor: this.data.cursor
|
|
179
|
+
});
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
onToggleAlsoComment(e) {
|
|
183
|
+
const checked = !!(e.detail.value && e.detail.value.length > 0);
|
|
184
|
+
this.setData({
|
|
185
|
+
alsoComment: checked
|
|
186
|
+
});
|
|
187
|
+
this.triggerEvent('toggleAlsoComment', {
|
|
188
|
+
value: checked
|
|
189
|
+
});
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
updateTextareaHeight() {
|
|
193
|
+
const {
|
|
194
|
+
emojiVisible,
|
|
195
|
+
images
|
|
196
|
+
} = this.data;
|
|
197
|
+
let height = 'calc(100vh - 180rpx)';
|
|
198
|
+
|
|
199
|
+
if (emojiVisible && images.length > 0) height = 'calc(100vh - 780rpx)';
|
|
200
|
+
else if (emojiVisible) height = 'calc(100vh)';
|
|
201
|
+
else if (images.length > 0) height = 'calc(100vh - 350rpx)';
|
|
202
|
+
|
|
203
|
+
this.setData({
|
|
204
|
+
textareaHeight: height
|
|
205
|
+
});
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
/** 选择图片(限制1张) */
|
|
209
|
+
chooseImage() {
|
|
210
|
+
if (this.data.images.length >= 1) {
|
|
211
|
+
wx.showToast({
|
|
212
|
+
title: '评论只能选取1张照片',
|
|
213
|
+
icon: 'none'
|
|
214
|
+
});
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
wx.chooseMedia({
|
|
219
|
+
count: 1,
|
|
220
|
+
mediaType: ['image'],
|
|
221
|
+
sourceType: ['album', 'camera'],
|
|
222
|
+
success: async (res) => {
|
|
223
|
+
const newImages = [];
|
|
224
|
+
|
|
225
|
+
for (let file of res.tempFiles) {
|
|
226
|
+
const compressed = await compressImages(file.tempFilePath);
|
|
227
|
+
const info = await new Promise((resolve, reject) => {
|
|
228
|
+
wx.getFileInfo({
|
|
229
|
+
filePath: compressed,
|
|
230
|
+
success: resolve,
|
|
231
|
+
fail: reject
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
console.log('压缩后图片路径:', compressed);
|
|
236
|
+
console.log('压缩后大小(MB):', (info.size / 1024 / 1024).toFixed(2));
|
|
237
|
+
|
|
238
|
+
newImages.push(compressed);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const images = this.data.images.concat(newImages).slice(0, 1);
|
|
242
|
+
this.setData({
|
|
243
|
+
images
|
|
244
|
+
}, this.updateTextareaHeight);
|
|
245
|
+
},
|
|
246
|
+
fail: (err) => {
|
|
247
|
+
console.error('选择图片失败:', err);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
},
|
|
251
|
+
|
|
252
|
+
removeImage(e) {
|
|
253
|
+
const index = e.currentTarget.dataset.index;
|
|
254
|
+
const images = [...this.data.images];
|
|
255
|
+
images.splice(index, 1);
|
|
256
|
+
this.setData({
|
|
257
|
+
images
|
|
258
|
+
}, this.updateTextareaHeight);
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
chooseTopic() {
|
|
262
|
+
// this.triggerEvent('chooseTopic', {});
|
|
263
|
+
wx.navigateTo({
|
|
264
|
+
url: '/pages/addSubject/addSubject',
|
|
265
|
+
});
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
/** 切换表情面板 */
|
|
271
|
+
toggleEmoji() {
|
|
272
|
+
const visible = !this.data.emojiVisible;
|
|
273
|
+
|
|
274
|
+
if (visible) {
|
|
275
|
+
// 打开 emoji 面板时收起键盘
|
|
276
|
+
wx.hideKeyboard();
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
this.setData({
|
|
280
|
+
emojiVisible: visible,
|
|
281
|
+
keyboardHeight: 0
|
|
282
|
+
}, () => {
|
|
283
|
+
// 更新 sheet 位置
|
|
284
|
+
this.updateSheetPosition(0);
|
|
285
|
+
});
|
|
286
|
+
},
|
|
287
|
+
|
|
288
|
+
/** 选择表情并插入到输入框光标处 */
|
|
289
|
+
selectEmoji(e) {
|
|
290
|
+
const index = e.currentTarget.dataset.index;
|
|
291
|
+
const emojiText = `[/` + (index + 1) + `]`;
|
|
292
|
+
|
|
293
|
+
setTimeout(() => {
|
|
294
|
+
const {
|
|
295
|
+
content,
|
|
296
|
+
cursor
|
|
297
|
+
} = this.data;
|
|
298
|
+
const newContent = content.slice(0, cursor) + emojiText + content.slice(cursor);
|
|
299
|
+
this.setData({
|
|
300
|
+
content: newContent,
|
|
301
|
+
cursor: cursor + emojiText.length
|
|
302
|
+
});
|
|
303
|
+
}, 100);
|
|
304
|
+
},
|
|
305
|
+
|
|
306
|
+
toBase64(str) {
|
|
307
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
308
|
+
let result = '';
|
|
309
|
+
let i = 0;
|
|
310
|
+
|
|
311
|
+
str = unescape(encodeURIComponent(str)); // 处理中文
|
|
312
|
+
|
|
313
|
+
while (i < str.length) {
|
|
314
|
+
const byte1 = str.charCodeAt(i++);
|
|
315
|
+
const byte2 = str.charCodeAt(i++);
|
|
316
|
+
const byte3 = str.charCodeAt(i++);
|
|
317
|
+
|
|
318
|
+
const enc1 = byte1 >> 2;
|
|
319
|
+
const enc2 = ((byte1 & 3) << 4) | (byte2 >> 4);
|
|
320
|
+
const enc3 = isNaN(byte2) ? 64 : (((byte2 & 15) << 2) | (byte3 >> 6));
|
|
321
|
+
const enc4 = isNaN(byte3) ? 64 : (byte3 & 63);
|
|
322
|
+
|
|
323
|
+
result += chars.charAt(enc1);
|
|
324
|
+
result += chars.charAt(enc2);
|
|
325
|
+
result += enc3 === 64 ? '=' : chars.charAt(enc3);
|
|
326
|
+
result += enc4 === 64 ? '=' : chars.charAt(enc4);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
return result;
|
|
330
|
+
},
|
|
331
|
+
|
|
332
|
+
/** 提交评论或转发 */
|
|
333
|
+
async onSubmit() {
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
const content = (this.data.content || '').trim();
|
|
337
|
+
if (!content && this.data.images.length === 0) {
|
|
338
|
+
wx.showToast({
|
|
339
|
+
title: '请输入内容或选择图片',
|
|
340
|
+
icon: 'none'
|
|
341
|
+
});
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// 敏感词检测
|
|
346
|
+
const hit = sensitive.detect(content)
|
|
347
|
+
if (hit) {
|
|
348
|
+
return wx.showToast({
|
|
349
|
+
title: `敏感词 ${sensitive.mask(hit)}`,
|
|
350
|
+
icon: 'none'
|
|
351
|
+
})
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
try {
|
|
355
|
+
|
|
356
|
+
wx.showLoading({
|
|
357
|
+
title: '发布中...',
|
|
358
|
+
mask: true
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
const post_id = this.data.originData.post.id
|
|
362
|
+
const base64Content = this.toBase64(content)
|
|
363
|
+
let nType
|
|
364
|
+
if (this.data.alsoComment) {
|
|
365
|
+
nType = 3
|
|
366
|
+
} else {
|
|
367
|
+
nType = this.properties.mode === 'forward' ? 2 : 1;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
let images = null
|
|
371
|
+
let tokenId = null;
|
|
372
|
+
|
|
373
|
+
if (this.data.images.length > 0) {
|
|
374
|
+
images = this.data.images; // 这里是图片临时路径数组
|
|
375
|
+
tokenId = await this.uploadImagesToOSS(images);
|
|
376
|
+
console.log('上传成功:', tokenId);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
let parent_comment_id = null
|
|
380
|
+
if (this.data.commentData) {
|
|
381
|
+
parent_comment_id = this.data.commentData.id
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
await commentPostNew(post_id, base64Content, tokenId, parent_comment_id, nType, false)
|
|
385
|
+
wx.hideLoading();
|
|
386
|
+
|
|
387
|
+
setTimeout(() => {
|
|
388
|
+
wx.showToast({
|
|
389
|
+
title: '发布成功',
|
|
390
|
+
icon: 'success'
|
|
391
|
+
});
|
|
392
|
+
}, 200);
|
|
393
|
+
|
|
394
|
+
this.triggerEvent('submitSuccess', {
|
|
395
|
+
postId: post_id,
|
|
396
|
+
mode: this.data.mode,
|
|
397
|
+
content: content,
|
|
398
|
+
images: this.data.images
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
this.closeSheet();
|
|
403
|
+
} catch (err) {
|
|
404
|
+
wx.hideLoading();
|
|
405
|
+
wx.showToast({
|
|
406
|
+
title: '发布失败' + err,
|
|
407
|
+
icon: 'none'
|
|
408
|
+
});
|
|
409
|
+
} finally {
|
|
410
|
+
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
|
|
414
|
+
async uploadImagesToOSS(images) {
|
|
415
|
+
try {
|
|
416
|
+
const tokenRes = await getUploadToken(images.map(() => 1), false);
|
|
417
|
+
const {
|
|
418
|
+
host,
|
|
419
|
+
list,
|
|
420
|
+
accessid,
|
|
421
|
+
id
|
|
422
|
+
} = tokenRes.data;
|
|
423
|
+
|
|
424
|
+
// 生成每张图片的上传 Promise
|
|
425
|
+
const uploadPromises = images.map((filePath, i) => {
|
|
426
|
+
const {
|
|
427
|
+
dir,
|
|
428
|
+
policy,
|
|
429
|
+
signature
|
|
430
|
+
} = list[i];
|
|
431
|
+
|
|
432
|
+
return new Promise((resolve, reject) => {
|
|
433
|
+
wx.uploadFile({
|
|
434
|
+
url: host,
|
|
435
|
+
filePath,
|
|
436
|
+
name: 'file',
|
|
437
|
+
formData: {
|
|
438
|
+
key: dir,
|
|
439
|
+
policy,
|
|
440
|
+
OSSAccessKeyId: accessid,
|
|
441
|
+
signature,
|
|
442
|
+
success_action_status: '200'
|
|
443
|
+
},
|
|
444
|
+
success(res) {
|
|
445
|
+
if (res.statusCode === 200) {
|
|
446
|
+
resolve(); // 当前图片上传成功
|
|
447
|
+
} else {
|
|
448
|
+
reject(res);
|
|
449
|
+
}
|
|
450
|
+
},
|
|
451
|
+
fail(err) {
|
|
452
|
+
reject(err);
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
// 等待所有图片上传完成
|
|
459
|
+
await Promise.all(uploadPromises);
|
|
460
|
+
|
|
461
|
+
return id; // 所有上传完成后返回 token id
|
|
462
|
+
} catch (err) {
|
|
463
|
+
console.error('上传失败', err);
|
|
464
|
+
wx.showToast({
|
|
465
|
+
title: '上传失败' + err,
|
|
466
|
+
})
|
|
467
|
+
throw err;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
}
|
|
473
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<view wx:if="{{visible}}" class="overlay" catchtouchmove="true" catch:tap="onOverlayTap">
|
|
2
|
+
<!-- 弹窗sheet -->
|
|
3
|
+
<view class="sheet" catchtap="stopTap" style="bottom: {{sheetBottom}}px;">
|
|
4
|
+
|
|
5
|
+
<!-- 顶部栏 -->
|
|
6
|
+
<view class="sheet-header">
|
|
7
|
+
<view class="close-btn" bindtap="closeSheet">×</view>
|
|
8
|
+
<text class="sheet-title">{{mode === 'forward' ? '转发' : '评论'}}</text>
|
|
9
|
+
<view class="submit-btn {{content.length === 0 ? 'disabled' : ''}}" catch:tap="onSubmit" data-disabled="{{content.length === 0}}">发布</view>
|
|
10
|
+
</view>
|
|
11
|
+
|
|
12
|
+
<!-- 输入框 -->
|
|
13
|
+
<view class="textarea-wrapper">
|
|
14
|
+
<textarea class="post-input" style="height: 100px;margin-top: 20rpx;" placeholder-style="color: #c1c1c1;" placeholder="{{commentData ?('回复@'+commentData.reply_nickname):((mode === 'forward' ? '转发':'回复')+'@'+originData.user.nickname) }}" maxlength="300" bindinput="onInput" value="{{content}}" cursor="{{cursor}}" bindblur="onBlur" bindfocus="onFocus" focus="{{true}}" adjust-position="{{false}}" />
|
|
15
|
+
|
|
16
|
+
<view class="char-count">{{content.length}}/300</view>
|
|
17
|
+
|
|
18
|
+
<view class="origin-wrapper">
|
|
19
|
+
<image class="origin-img" src="{{commentData ? (commentData.avatar): (originData.post.imageArray.length > 0 ? originData.post.imageArray[0] : (originData.user.avatar || '/assets/images/icons/header_placeholder.png' ))}}" mode="aspectFill" />
|
|
20
|
+
<view class="origin-text">{{commentData ? ('@'+commentData.reply_nickname+':'+ commentData.content): ('@'+originData.user.nickname+':'+originData.post.content)}}</view>
|
|
21
|
+
</view>
|
|
22
|
+
</view>
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
<!-- 图片预览 -->
|
|
27
|
+
<scroll-view class="image-preview" scroll-x="true" enable-flex="true" wx:if="{{images.length > 0}}">
|
|
28
|
+
<view class="image-container">
|
|
29
|
+
<view class="image-item" wx:for="{{images}}" wx:key="index">
|
|
30
|
+
<image src="{{item}}" mode="aspectFill" class="preview-img" />
|
|
31
|
+
<view class="delete-btn" bindtap="removeImage" data-index="{{index}}">
|
|
32
|
+
<van-icon name="clear" size="25px" />
|
|
33
|
+
</view>
|
|
34
|
+
</view>
|
|
35
|
+
<view wx:if="{{images.length < 1}}" class="image-item add-image" bindtap="chooseImage">+</view>
|
|
36
|
+
</view>
|
|
37
|
+
</scroll-view>
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
<!-- 底部工具栏 -->
|
|
42
|
+
<view class="toolbar">
|
|
43
|
+
<view class="toolbar-left">
|
|
44
|
+
<checkbox-group bindchange="onToggleAlsoComment">
|
|
45
|
+
<label class="toolbar-left">
|
|
46
|
+
<checkbox value="1" checked="{{alsoComment}}" />
|
|
47
|
+
<text class="checkbox-text">{{mode ==='forward' ? '转发并评论':'评论并转发'}}</text>
|
|
48
|
+
</label>
|
|
49
|
+
</checkbox-group>
|
|
50
|
+
</view>
|
|
51
|
+
<view class="toolbar-right">
|
|
52
|
+
<view class="toolbar-btn" bindtap="chooseImage">
|
|
53
|
+
<van-icon name="photo-o" size="50rpx" />
|
|
54
|
+
</view>
|
|
55
|
+
<view class="toolbar-btn" bindtap="chooseTopic">
|
|
56
|
+
<text style="font-size: 50rpx;">#</text>
|
|
57
|
+
</view>
|
|
58
|
+
<view class="toolbar-btn" bindtap="toggleEmoji">
|
|
59
|
+
<van-icon name="smile-o" size="50rpx" />
|
|
60
|
+
</view>
|
|
61
|
+
</view>
|
|
62
|
+
</view>
|
|
63
|
+
|
|
64
|
+
<!-- emoji 面板 -->
|
|
65
|
+
<scroll-view class="emoji-panel" wx:if="{{emojiVisible}}" scroll-y="true">
|
|
66
|
+
<view class="emoji-grid">
|
|
67
|
+
<block wx:for="{{emojiList}}" wx:key="index">
|
|
68
|
+
<image src="{{item}}" class="emoji-img" bindtap="selectEmoji" data-index="{{index}}" mode="aspectFit" />
|
|
69
|
+
</block>
|
|
70
|
+
</view>
|
|
71
|
+
</scroll-view>
|
|
72
|
+
</view>
|
|
73
|
+
</view>
|