From d4c8ed324e0e619f2f54483f1f0690794d0c1958 Mon Sep 17 00:00:00 2001 From: Connor <1813766834@qq.com> Date: Sun, 16 Jun 2024 13:51:53 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=AE=8C=E5=96=84=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=EF=BC=88=E6=8E=A8=E8=8D=90=E3=80=81=E5=85=B3=E6=B3=A8=EF=BC=89?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E3=80=81=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/talk/post.js | 9 ++ pages/common/postview/index.vue | 13 +- pages/index.vue | 223 ++++++++++++++++++------------- pages/post/postInfo/postInfo.vue | 89 +----------- 4 files changed, 150 insertions(+), 184 deletions(-) diff --git a/api/talk/post.js b/api/talk/post.js index b7a18cf..9303ff1 100644 --- a/api/talk/post.js +++ b/api/talk/post.js @@ -9,6 +9,15 @@ export function listPost(query) { }) } +// 查询该用户关注的话题投稿new列表 +export function listPostFollow(query) { + return request({ + url: '/talk/post/follow', + method: 'get', + params: query + }) +} + // 查询话题投稿new详细 export function getPost(id) { return request({ diff --git a/pages/common/postview/index.vue b/pages/common/postview/index.vue index 1934083..bba2ee8 100644 --- a/pages/common/postview/index.vue +++ b/pages/common/postview/index.vue @@ -19,7 +19,7 @@ - + 已关注 关注 @@ -174,8 +174,10 @@ addPostFavorite } from "@/api/postFavorite/postFavorite"; + const loginUser = reactive(uni.getStorageSync('loginUserPost')); const dictPostTab = ref([]) onLoad((options) => { + getDicts('post_tab').then(e => { dictPostTab.value = e.data }) @@ -191,7 +193,7 @@ postViewIndex: Number, postViewType: Number }); - + const postListStorage = ref(uni.getStorageSync('postList')); const upPostListStorage = () => { @@ -412,6 +414,13 @@ /* 垂直结束对齐 */ height: 30rpx; line-height: 30rpx; + display: block; + width: 480rpx; + // display: flex; /* 设置为弹性盒子 */ + // max-width: 450rpx; /* 最大宽度为 300rpx */ + overflow: hidden; /* 超出部分隐藏 */ + text-overflow: ellipsis; /* 超出部分用省略号表示 */ + white-space: nowrap; /* 不换行 */ } .no-focus-text { diff --git a/pages/index.vue b/pages/index.vue index ec03a0d..3d0eed2 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -54,8 +54,8 @@ - {{item.uname}} + :src="getAvatar(item.avatar)"> + {{item.nickName}} @@ -145,12 +145,14 @@ import PostView from "@/pages/common/postview/index.vue"; import { listPost, + listPostFollow, getPost, delPost, addPost, updatePost, getLoginUserinfo } from "@/api/talk/post"; + import { listFollowUser, getFollowUser, delFollowUser, addFollowUser, updateFollowUser } from "@/api/followUser/followUser"; import { useStore } from 'vuex'; @@ -159,6 +161,7 @@ proxy } = getCurrentInstance(); + const loginUser = reactive(uni.getStorageSync('loginUserPost')); const QNDomain = store.state.user.QNDomain; const postList = ref([]); @@ -195,6 +198,8 @@ auditTime: null, auditAdvice: null, cut: null, + sortField: null, + sortDirection: null, }, rules: { status: [{ @@ -215,18 +220,82 @@ form, rules } = toRefs(data); + + const followTotal = ref(0); + const queryFollowParams = reactive({ + pageNum: 1, + pageSize: 10, + uid: null, + topicId: null, + discussId: null, + voteId: null, + title: null, + content: null, + media: null, + tab: null, + readCount: null, + transmitCount: null, + likeCount: null, + commentCount: null, + favoriteCount: null, + postTop: null, + type: null, + anonymity: null, + postPrivate: null, + address: null, + longitude: null, + latitude: null, + auditor: null, + status: null, + auditTime: null, + auditAdvice: null, + cut: null, + sortField: null, + sortDirection: null, + }) /** 查询话题投稿new列表 */ function getList() { - queryParams.value.params = {}; + if (searchPrerequisite.value == '热门') { + queryParams.value.sortField = 'like_count'; + } else if (searchPrerequisite.value == '最新') { + queryParams.value.sortField = 'create_time'; + } listPost(queryParams.value).then(response => { - uni.setStorageSync('postList', response.rows) + console.log('看一下查了啥啊',response.rows) + if (queryParams.value.pageNum > 1) { + postList.value.push(...response.rows); + uni.setStorageSync('postList', postList.value) + } else { + uni.setStorageSync('postList', response.rows) + } postList.value = uni.getStorageSync('postList'); // postList.value = response.rows; total.value = response.total; }); } + + function getFollowList() { + if (searchPrerequisite.value == '热门') { + queryFollowParams.sortField = 'like_count'; + } else if (searchPrerequisite.value == '最新') { + queryFollowParams.sortField = 'create_time'; + } + listPostFollow(queryFollowParams).then(response => { + console.log('看一下查了啥啊关注',response) + if (queryFollowParams.pageNum > 1) { + postList.value.push(...response.rows); + } else { + postList.value = response.rows; + } + + followTotal.value = response.total; + }); + } + function getAvatar(avatar) { + return QNDomain + avatar; + } const toimage = (url) => { if (typeof url === 'string') { let info = url.split(","); @@ -239,9 +308,9 @@ const bgColor = ref('rgba(170, 0, 0, 0)'); onLoad(() => { - getLoginUserinfo().then(res => { - uni.setStorageSync('loginUserPost', res.data) - }) + getLoginUserinfo().then(res => { + uni.setStorageSync('loginUserPost', res.data) + }) onPageScroll((e) => { // console.log("滚动距离为:" + e.scrollTop); if (e.scrollTop >= 70) { @@ -252,6 +321,18 @@ }); onReachBottom(() => { console.log('触底了') + if (viewIndex.value == 1) { + if (total.value > postList.value.length) { + queryParams.value.pageNum += 1; + getList(); + } + } + if (viewIndex.value == 0) { + if (followTotal.value > postList.value.length) { + queryFollowParams.pageNum += 1; + getFollowList(); + } + } }) InspectionData() }) @@ -271,7 +352,12 @@ } onShow(() => { - postList.value = uni.getStorageSync('postList'); + if (viewIndex.value == 1) { + postList.value = uni.getStorageSync('postList'); + } + if (viewIndex.value == 0) { + selectFollowView(); + } }) const viewIndex = ref(1); @@ -300,92 +386,7 @@ } ]); - const focusList = reactive([{ - avatar: 'https://k.sinaimg.cn/n/sports/transform/400/w600h600/20220130/dd38-eed53ba750d1d8c87eca8b57eda879a5.jpg/w700d1q75cms.jpg?by=cms_fixed_width', - uname: '爱吃饭的小张' - }, - { - avatar: 'https://oss.1381801.com/forum/202308/11/093616ccxkx99wchwrrw1a.jpg', - uname: '喜欢你没道理' - }, - { - avatar: 'https://picx.zhimg.com/v2-02f89d05a781ffed9fd2e32654d93135_720w.jpg?source=172ae18b', - uname: '恋爱60秒' - }, - { - avatar: 'https://www.tboxn.com/wp-content/uploads/2022/11/%E5%A4%B4%E5%83%8F.png', - uname: '爱吃饭的小张' - } - ]); - - // const postList = reactive([ - // { - // avatar: 'https://k.sinaimg.cn/n/sports/transform/400/w600h600/20220130/dd38-eed53ba750d1d8c87eca8b57eda879a5.jpg/w700d1q75cms.jpg?by=cms_fixed_width', - // uname: '爱吃饭的小张', - // createTime: '11分钟前', - // address: '南开大学', - // isFocus: false, - // isOfficial: true, - // title: '怎么评论爱德华·艾尔加这位音乐家及其他的作品,欢迎大家发表自己的看法?', - // content: '八年前,学弟在工地上杀了一个工友,杀人前,他给警察打了电话,预告杀人的时间和地点,并超出部分测试超出部分测试超出部分测试超出部分测试......超出部分测试超出部分测试超出部分测试超出部分测试', - // type: '1', - // media: [ - // 'https://img1.baidu.com/it/u=1179199327,1946315836&fm=253&fmt=auto&app=138&f=JPEG?w=1364&h=800', - // 'https://www4.bing.com//th?id=OHR.CopenhagenBicycles_ZH-CN3047958346_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp&w=360&h=202', - // 'https://www4.bing.com//th?id=OHR.CarnavalTenerife_ZH-CN1559136778_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp&w=360&h=202', - // 'https://www4.bing.com//th?id=OHR.StJamesPool_ZH-CN5930624359_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp&w=360&h=202', - // ], - // tab: ['学术讨论组', '校园风景'], - // transmitCount: 136, - // isLike: true, - // likeCount: 999, - // commentCount: 136, - // ifFavorite: true, - // favoriteCount: 136 - // }, - // { - // avatar: 'https://oss.1381801.com/forum/202308/11/093616ccxkx99wchwrrw1a.jpg', - // uname: '喜欢你没道理', - // createTime: '2024-5-5', - // address: '南开大学', - // isFocus: false, - // isOfficial: false, - // content: '是一个中文互联网高质量问答社区和创作者聚集的原创内容平台,于2011年1月正式上线', - // type: '1', - // media: [ - // 'https://www4.bing.com//th?id=OHR.BambooPanda_ZH-CN8455481760_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp&w=360&h=202', - // ], - // tab: ['校园风景'], - // transmitCount: 13, - // isLike: false, - // likeCount: 99, - // commentCount: 13, - // ifFavorite: true, - // favoriteCount: 13 - // }, - // { - // avatar: 'https://picx.zhimg.com/v2-02f89d05a781ffed9fd2e32654d93135_720w.jpg?source=172ae18b', - // uname: '恋爱60秒', - // createTime: '2024-5-4', - // address: '理工大学', - // isFocus: false, - // isOfficial: false, - // title: '怎么评论爱德华·艾尔加这位音乐家及其他的作品,欢迎大家发表自己的看法?', - // content: '是一个中文互联网高质量问答社区和创作者聚集的原创内容平台,于2011年1月正式上线', - // type: '1', - // media: [ - // 'https://www4.bing.com//th?id=OHR.PlitviceWinter_ZH-CN0407572344_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp&w=360&h=202', - // 'https://www4.bing.com//th?id=OHR.HawkOwl_ZH-CN3401920167_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp&w=360&h=202' - // ], - // tab: ['校园风景'], - // transmitCount: 13, - // isLike: false, - // likeCount: 99, - // commentCount: 13, - // ifFavorite: false, - // favoriteCount: 13 - // } - // ]); + const focusList = ref([]); const publishTalk = (item) => { if (item.id === 1) { @@ -433,11 +434,45 @@ const click = (item) => { viewIndex.value = item.index; + console.log("看看这里是个啥", item.index) + if (item.index == 0) { + selectFollowView(); + } + if (item.index == 1) { + postList.value = uni.getStorageSync('postList'); + } }; + + const selectFollowView = () => { + const FollowUser ={ + userId: loginUser.userId + }; + listFollowUser(FollowUser).then(res => { + console.log(res.rows); + queryFollowParams.pageNum = 1; + postList.value = []; + if (res.rows.length == 0) { + const noFollew ={ + avatar: 'noFollew', + nickName: '暂无关注' + }; + res.rows.push(noFollew); + focusList.value = res.rows; + return; + }; + focusList.value = res.rows; + getFollowList(); + }) + } const handerLi = (res) => { lefther.value = res; searchPrerequisite.value = searchPrerequisiteList[res]; + if (viewIndex.value == 1) { + getList(); + } else if (viewIndex.value == 0) { + getFollowList(); + } setTimeout(() => { searchOpen.value = !searchOpen.value; }, 350); diff --git a/pages/post/postInfo/postInfo.vue b/pages/post/postInfo/postInfo.vue index 50d8aac..0485563 100644 --- a/pages/post/postInfo/postInfo.vue +++ b/pages/post/postInfo/postInfo.vue @@ -213,66 +213,6 @@ address: null, }); - const postList = reactive([{ - avatar: 'https://k.sinaimg.cn/n/sports/transform/400/w600h600/20220130/dd38-eed53ba750d1d8c87eca8b57eda879a5.jpg/w700d1q75cms.jpg?by=cms_fixed_width', - nickName: '爱吃饭的小张', - address: '南开大学', - content: '大家来评论', - createTime: '7分钟前', - isOfficial: true, - deployment: false, - answerCommentAllCount: 4, - answerCommentPage: 0, - answerCommentDisplayCount: 0, - answerCommentList: [{ - avatar: 'https://picx.zhimg.com/v2-02f89d05a781ffed9fd2e32654d93135_720w.jpg?source=172ae18b', - nickName: '恋爱60秒', - createTime: '2024.05.04', - isOfficial: false, - address: '理工大学', - content: '来了', - }, - { - avatar: 'https://oss.1381801.com/forum/202308/11/093616ccxkx99wchwrrw1a.jpg', - nickName: '喜欢你没道理', - createTime: '2024.05.04', - isOfficial: false, - address: '理工大学', - content: '你干嘛~', - toUserName: '恋爱60秒', - }, - { - avatar: 'https://www.tboxn.com/wp-content/uploads/2022/11/%E5%A4%B4%E5%83%8F.png', - nickName: '神奇宝贝', - createTime: '2024.05.04', - isOfficial: false, - address: '理工大学', - content: '哎呦~', - toUserName: '喜欢你没道理', - }, - { - avatar: 'https://files.codelife.cc/wallhaven/full/wq/wallhaven-wqkw2r.jpg?x-oss-process=image/resize,limit_0,m_fill,w_307,h_158/quality,Q_92/format,webp', - nickName: '皮卡丘', - createTime: '2024.05.04', - isOfficial: true, - address: '理工大学', - content: '要再点一下才能看到我', - toUserName: '喜欢你没道理', - }, - ] - }, - { - avatar: 'https://picx.zhimg.com/v2-02f89d05a781ffed9fd2e32654d93135_720w.jpg?source=172ae18b', - nickName: '恋爱60秒', - createTime: '2024.05.04', - isOfficial: false, - deployment: false, - address: '理工大学', - content: '评论区上线了', - answerCommentList: [] - } - ]); - const getPostInfo = () => { queryParams.postId = postValue.id; listComment(queryParams).then(res => { @@ -281,32 +221,7 @@ total.value = res.total }); }; - // const postValue = reactive( - // { - // avatar: 'https://k.sinaimg.cn/n/sports/transform/400/w600h600/20220130/dd38-eed53ba750d1d8c87eca8b57eda879a5.jpg/w700d1q75cms.jpg?by=cms_fixed_width', - // uname: '爱吃饭的小张', - // createTime: '11分钟前', - // address: '南开大学', - // isFocus: false, - // isOfficial: true, - // title: '怎么评论爱德华·艾尔加这位音乐家及其他的作品,欢迎大家发表自己的看法?', - // content: '八年前,学弟在工地上杀了一个工友,上杀了一个工友,杀人前,他给警察打了电话,预告杀人的时间和地点,和地点,并......', - // type: '1', - // media: [ - // 'https://img1.baidu.com/it/u=1179199327,1946315836&fm=253&fmt=auto&app=138&f=JPEG?w=1364&h=800', - // 'https://www4.bing.com//th?id=OHR.CopenhagenBicycles_ZH-CN3047958346_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp&w=360&h=202', - // 'https://www4.bing.com//th?id=OHR.CarnavalTenerife_ZH-CN1559136778_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp&w=360&h=202', - // 'https://www4.bing.com//th?id=OHR.StJamesPool_ZH-CN5930624359_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp&w=360&h=202', - // ], - // tab: ['学术讨论组', '校园风景'], - // transmitCount: 136, - // like: true, - // likeCount: 999, - // commentCount: 136, - // favorite: true, - // favoriteCount: 136 - // } - // ); + const store = useStore(); const QNDomain = store.state.user.QNDomain; @@ -537,9 +452,7 @@ queryParamsSon.rootId = comment.id; queryParamsSon.pageNum = comment.answerCommentPage; listComment(queryParamsSon).then(res => { - console.log('看看子评论', res.rows); comment.answerCommentList.push(...res.rows); - console.log(postCommentList.value[index]); }); if (comment.answerCommentDisplayCount + increment <= comment.answerCommentAllCount) { comment.answerCommentDisplayCount += increment; From b443bb02508f96e40d52c23ddff085ce5fa338e5 Mon Sep 17 00:00:00 2001 From: Connor <1813766834@qq.com> Date: Sun, 16 Jun 2024 22:21:29 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=88=91=E7=9A=84?= =?UTF-8?q?=E8=AF=9D=E9=A2=98=E6=A8=A1=E5=9D=97=E3=80=81=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E3=80=81=E4=BF=AE=E5=A4=8D=E8=8B=A5=E5=B9=B2?= =?UTF-8?q?=E5=B0=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages.json | 14 +++ pages/common/postview/index.vue | 106 ++++++++++++++++- pages/index.vue | 20 +++- pages/mine/index.vue | 8 ++ pages/mine/myActivity/index.vue | 4 +- pages/mine/myPost/draft/draft.vue | 123 +++++++++++++++++++ pages/mine/myPost/myPost.vue | 191 ++++++++++++++++++++++++++++++ pages/post/postInfo/postInfo.vue | 4 +- static/images/icon/sang-1.png | Bin 0 -> 955 bytes 9 files changed, 457 insertions(+), 13 deletions(-) create mode 100644 pages/mine/myPost/draft/draft.vue create mode 100644 pages/mine/myPost/myPost.vue create mode 100644 static/images/icon/sang-1.png diff --git a/pages.json b/pages.json index 7e9e779..82e8229 100644 --- a/pages.json +++ b/pages.json @@ -407,6 +407,20 @@ "navigationBarTitleText": "消息切换", "navigationStyle": "custom" } + }, + { + "path" : "pages/mine/myPost/myPost", + "style" : + { + "navigationBarTitleText" : "我的话题" + } + }, + { + "path" : "pages/mine/myPost/draft/draft", + "style" : + { + "navigationBarTitleText" : "草稿箱" + } } ], "tabBar": { diff --git a/pages/common/postview/index.vue b/pages/common/postview/index.vue index bba2ee8..c1fd26b 100644 --- a/pages/common/postview/index.vue +++ b/pages/common/postview/index.vue @@ -2,7 +2,7 @@ - + @@ -19,16 +19,28 @@ + 已关注 关注 + + + 已发布 + 审核中 + 未通过 + + + + + {{postValue.title}} {{postValue.content}} + v-if="postValue.content && postViewIndex == 3 || postViewIndex == 0 || postViewIndex == 1 || postViewIndex == 2">{{postValue.content}} {{postValue.content}} + v-else>{{postValue.content}} @@ -137,6 +149,8 @@ + + \ No newline at end of file diff --git a/pages/index.vue b/pages/index.vue index 3d0eed2..b499286 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -194,7 +194,7 @@ longitude: null, latitude: null, auditor: null, - status: null, + status: 0, auditTime: null, auditAdvice: null, cut: null, @@ -246,7 +246,7 @@ longitude: null, latitude: null, auditor: null, - status: null, + status: 0, auditTime: null, auditAdvice: null, cut: null, @@ -308,6 +308,9 @@ const bgColor = ref('rgba(170, 0, 0, 0)'); onLoad(() => { + uni.$on('refreshData',() => { + reactiveList(); + }) getLoginUserinfo().then(res => { uni.setStorageSync('loginUserPost', res.data) }) @@ -433,8 +436,11 @@ }; const click = (item) => { + if (item.index == 1 && viewIndex.value == 0) { + queryParams.value.pageNum = 1; + getList(); + } viewIndex.value = item.index; - console.log("看看这里是个啥", item.index) if (item.index == 0) { selectFollowView(); } @@ -469,6 +475,8 @@ lefther.value = res; searchPrerequisite.value = searchPrerequisiteList[res]; if (viewIndex.value == 1) { + queryParams.value.pageNum = 1; + postList.value = []; getList(); } else if (viewIndex.value == 0) { getFollowList(); @@ -497,6 +505,12 @@ postList.value = uni.getStorageSync('postList'); // console.log('关注' + uni.getStorageSync('postList')) } + + const reactiveList = () => { + queryParams.value.pageNum = 1; + getList(); + } + getList(); diff --git a/pages/mine/index.vue b/pages/mine/index.vue index 1245f1a..5990cf8 100644 --- a/pages/mine/index.vue +++ b/pages/mine/index.vue @@ -233,6 +233,14 @@ function handleLogout() { onPullDownRefresh((options) => { proxy.$router.go(0) }) +const grid1Click1 = (e) => { + console.log(e) + if (e == 4) { + proxy.$tab.navigateTo('/pages/mine/myPost/draft/draft') + } else { + proxy.$tab.navigateTo('/pages/mine/myPost/myPost?type=' + e) + } +} const grid1Click2 = (e) => { if (e == 4) { proxy.$tab.navigateTo('/pages/mine/myActivity/draft') diff --git a/pages/mine/myActivity/index.vue b/pages/mine/myActivity/index.vue index 15da2ff..f432f1f 100644 --- a/pages/mine/myActivity/index.vue +++ b/pages/mine/myActivity/index.vue @@ -255,9 +255,7 @@ const getDictLabelByValue = (state) => { diff --git a/pages/mine/myPost/myPost.vue b/pages/mine/myPost/myPost.vue new file mode 100644 index 0000000..f5ee556 --- /dev/null +++ b/pages/mine/myPost/myPost.vue @@ -0,0 +1,191 @@ + + + + + diff --git a/pages/post/postInfo/postInfo.vue b/pages/post/postInfo/postInfo.vue index 0485563..f9bbaa3 100644 --- a/pages/post/postInfo/postInfo.vue +++ b/pages/post/postInfo/postInfo.vue @@ -1,8 +1,8 @@