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.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 1934083..b8ec5a4 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 ec03a0d..b499286 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([]); @@ -191,10 +194,12 @@ longitude: null, latitude: null, auditor: null, - status: null, + status: 0, 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: 0, + 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,12 @@ const bgColor = ref('rgba(170, 0, 0, 0)'); onLoad(() => { - getLoginUserinfo().then(res => { - uni.setStorageSync('loginUserPost', res.data) - }) + uni.$on('refreshData',() => { + reactiveList(); + }) + getLoginUserinfo().then(res => { + uni.setStorageSync('loginUserPost', res.data) + }) onPageScroll((e) => { // console.log("滚动距离为:" + e.scrollTop); if (e.scrollTop >= 70) { @@ -252,6 +324,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 +355,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 +389,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) { @@ -432,12 +436,51 @@ }; const click = (item) => { + if (item.index == 1 && viewIndex.value == 0) { + queryParams.value.pageNum = 1; + getList(); + } viewIndex.value = 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) { + queryParams.value.pageNum = 1; + postList.value = []; + getList(); + } else if (viewIndex.value == 0) { + getFollowList(); + } setTimeout(() => { searchOpen.value = !searchOpen.value; }, 350); @@ -462,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 50d8aac..f9bbaa3 100644 --- a/pages/post/postInfo/postInfo.vue +++ b/pages/post/postInfo/postInfo.vue @@ -1,8 +1,8 @@