2025-10-10

项目收藏
This commit is contained in:
2025-10-10 14:16:01 +08:00
parent 793bf62680
commit f53ec45c51
6 changed files with 153 additions and 35 deletions

View File

@@ -2,7 +2,7 @@ import {
http
} from "../util/api"
const baseURL = "http://192.168.0.15:3007"
const baseURL = "http://192.168.0.12:3005/chat"
// 项目相关API
export const messageAPI = {

View File

@@ -2,14 +2,19 @@ import {
http
} from "../util/api"
const baseURL = "http://192.168.0.15:3006"
const baseURL = "http://192.168.0.12:3005/term"
// 项目相关API
export const programAPI = {
// 列表
getList: (params) => http.get(baseURL + '/program/list', params),
isChat: (params) => http.get(baseURL + "/program/isChat", params),
getProgram: (id) => http.get(baseURL + "/program/" + id)
getProgram: (id) => http.get(baseURL + "/program/" + id),
collect: (data) => http.post(baseURL + '/program/collect', data), // 收藏
unCollect: (data) => http.post(baseURL + '/program/uncollect', data), // 取消收藏
collectList: (params) => http.get(baseURL + '/program/collectList', params), // 收藏列表
isCollect: (params) => http.get(baseURL + '/program/isCollect', params), // 是否收藏
randomNext: (params) => http.get(baseURL + '/program/random',params)
}
export default {

View File

@@ -4,7 +4,7 @@
<!-- 可滚动的内容区域 -->
<view class="content-container">
<view>
<view id="fixedHeadId" style="padding: 32rpx 32rpx 0;">
<view id="fixedHeadId" style="padding: 32rpx 32rpx 0;" class="u-m-b-20">
<view class="head-box1">
<view class="title">
容讯聊天室
@@ -49,7 +49,8 @@
</view>
</view>
<view class="menu-list">
<!-- 全部/已投资/未读/不感兴趣 -->
<!-- <view class="menu-list">
<view class="menu-item" v-for="(item,index) in menuList" @click="handleMenuChange(index)">
<view class="menu-title">{{item.name + '(' + item.count +')'}}
</view>
@@ -57,11 +58,12 @@
:src="currentMenu==index?'/static/icon/Chevron down.png':'/static/icon/Chevron right Menu.png'"
mode=""></image>
</view>
</view>
</view> -->
</view>
<scroll-view scroll-y="true" class="message-list" :style="'height:'+height+'px'">
<view class="message-item" v-for="item in messageList">
<scroll-view scroll-y="true" class="message-list" :style="'height:'+height+'px'"
@scrolltolower="loadData">
<view class="message-item" v-for="(item, index) in messageList">
<u-swipe-action bgColor="#F8FBFF" :index="item.groupId" class="other-program"
@content-click="handleChat(item)" v-if="item.program.linkmanId !== params.userId"
:options="options">
@@ -75,7 +77,7 @@
{{ item.program.startDate + "至" + item.program.endDate }}
</view> -->
<view class="item-unread" v-if="item.userUnread.length!=0">
未读 {{item.userUnread.length}}
消息未读 {{item.userUnread.length}}
</view>
</u-swipe-action>
<u-swipe-action bgColor="#F8FBFF" class="my-program" @content-click="handleChat(item)" v-else
@@ -87,10 +89,11 @@
{{'咨询人:' + maskPhoneNumber(item.user.username) }}
</view>
<view class="item-unread" v-if="item.chargeUnread.length!=0">
未读 {{item.chargeUnread.length}}
消息未读 {{item.chargeUnread.length}}
</view>
</u-swipe-action>
</view>
<u-loadmore :status="status" color="#fff" />
<view class="placeholder-box"></view>
</scroll-view>
</view>
@@ -128,11 +131,11 @@
// 搜索
const keyword = ref('')
// 系统消息
const handleNavigateTo = () => {
uni.navigateTo({
url:'/pages/message/systemMessage'
url: '/pages/message/systemMessage'
})
}
@@ -157,6 +160,13 @@
currentMenu.value = val
}
// 进入聊天
const handleChat = (item) => {
uni.navigateTo({
url: '/pages/message/chat?groupId=' + item.groupId
})
}
// 消息
const messageList = ref([])
const user = ref()
@@ -167,6 +177,8 @@
userId: '',
customerId: '',
})
const pages = ref(0)
const status = ref('loadmore')
const options = [
{
text: '收藏',
@@ -182,21 +194,24 @@
}
]
const handleChat = (item) => {
uni.navigateTo({
url: '/pages/message/chat?groupId=' + item.groupId
})
}
const loadData = () => {
if (status.value == 'nomore') return
groupAPI.getList(params.value).then((res) => {
messageList.value = res.data.list
console.log(messageList.value);
pages.value = res.data.pages
messageList.value = messageList.value.concat(res.data.list)
params.value.page++
if (params.value.page > pages.value) {
status.value = 'nomore'
}
})
}
onPullDownRefresh(async () => {
await loadData()
// 重新刷新,将参数初始化
params.value.page = 1
messageList.value = []
status.value = 'loadmore'
loadData()
uni.stopPullDownRefresh()
})
@@ -319,26 +334,34 @@
}
.message-list {
margin-top: 10rpx;
margin-top: 20rpx;
.message-item {
// border: 1px solid #000;
.other-message {
.other-program {
padding: 20rpx 0rpx 20rpx 20rpx;
background-color: #F8FBFF;
;
border-bottom: 2rpx solid #f1f4ff;
.item-unread{
color: red;
}
}
.my-program {
padding: 20rpx 0rpx 20rpx 20rpx;
background-color: #F8FBFF;
border-bottom: 2rpx solid #f1f4ff;
.item-unread{
color: red;
}
}
}
.placeholder-box{
.placeholder-box {
width: 100%;
height: 50rpx;
}

View File

@@ -42,7 +42,7 @@
</view>
</view>
</view>
<u-loadmore :status="status" />
<u-loadmore color="#fff" :status="status" />
<view class="box-div"></view>
</scroll-view>

View File

@@ -3,7 +3,8 @@
<u-navbar :is-fixed="false" title="项目详情" :background="{background: 'transparent' }" :border-bottom="false"
back-icon-color="#fff" title-color="#fff">
<template v-slot:right>
<image class="collection" src="/static/icon/Bookmark.png" mode=""></image>
<image @click="handleCollect" class="collection"
:src="isCollect?'/static/icon/Bookmark-active.png':'/static/icon/Bookmark.png'" mode=""></image>
</template>
</u-navbar>
@@ -101,6 +102,8 @@
<u-col span="3"><u-button class="btn" type="success" @click="handleOpen">立刻融</u-button></u-col>
</u-row>
<u-link class="change-next" @click="handleChange">不感兴趣换一个</u-link>
<u-modal v-model="showWarning" border-radius="20" ref="warningRef" :mask-close-able="true"
:show-confirm-button="false" :show-title="false">
@@ -174,7 +177,7 @@
import { programAPI } from '../../api/program';
import { onLoad } from '@dcloudio/uni-app'
import { groupAPI } from '../../api/group';
const pdMsgRef = ref()
const userId = ref()
@@ -193,6 +196,64 @@
createDate: '',
user: {}
})
const isCollect = ref(false)
// 是否收藏项目
const isCollectMethod = () => {
let params = {
programId: programId.value,
userId: userId.value
}
programAPI.isCollect(params).then(res => {
if (res.code == 200) {
isCollect.value = res.data.isCollect
} else {
pdMsgRef.value.show({
title: res.msg,
type: 'error'
})
}
})
}
// 收藏项目
const handleCollect = () => {
let data = {
programId: programId.value,
userId: userId.value
}
if (isCollect.value) {
programAPI.unCollect(data).then(res => {
if (res.code == 200) {
isCollect.value = false
pdMsgRef.value.show({
title: "取消收藏",
type: 'success'
})
} else {
pdMsgRef.value.show({
title: res.msg,
type: 'error'
})
}
})
} else {
programAPI.collect(data).then(res => {
if (res.code == 200) {
isCollect.value = true
pdMsgRef.value.show({
title: "收藏成功",
type: 'success'
})
} else {
pdMsgRef.value.show({
title: res.msg,
type: 'error'
})
}
})
}
}
const loadData = () => {
programAPI.isChat({
@@ -215,14 +276,15 @@
})
onMounted(() => {
isCollectMethod()
loadData()
})
const handleChat = () => {
if (isChat.value) {
// 继续聊
groupAPI.getOne({programId: programId.value, userId: userId.value}).then(res=>{
if(res.code==200){
groupAPI.getOne({ programId: programId.value, userId: userId.value }).then(res => {
if (res.code == 200) {
// 进入聊天
uni.redirectTo({
url: '/pages/message/chat?groupId=' + res.data.groupId
@@ -232,13 +294,12 @@
} else {
// 开启群组聊天
groupAPI.add({ programId: programId.value, userId: userId.value }).then(res => {
console.log(res);
if(res.code==200){
if (res.code == 200) {
// 创建成功,进入聊天
uni.redirectTo({
url: '/pages/message/chat?groupId=' + res.data.groupId
})
}else{
} else {
pdMsgRef.value.show({
title: res.msg,
type: 'error'
@@ -271,7 +332,6 @@
// 立刻融 确认选择
const handleChose = () => {
if (!is_agree.value) {
console.log("change");
showErrMsg.value = true
return
}
@@ -299,6 +359,27 @@
showFile.value = false
showWarning.value = true
}
// 不感兴趣,换一个
const handleChange = () => {
const params = {
userId: userId.value,
programId: programId.value
}
programAPI.randomNext(params).then(res => {
if (res.code == 200) {
const nextPid = res.data.id
uni.redirectTo({
url: '/pages/program/programDetail?programId=' + nextPid
})
} else {
pdMsgRef.value.show({
title: res.msg,
type: 'error'
})
}
})
}
</script>
<style scoped lang="scss">
@@ -433,6 +514,15 @@
}
}
.change-next {
position: absolute;
bottom: 0%;
left: 0%;
right: 0%;
text-align: center;
margin-bottom: 20rpx;
}
// 按钮设置
.btn-group {
font-family: Work Sans;

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 B