1、平台课程的收藏功能

2、个人中心的收藏列表样式调整+收藏按钮逻辑
This commit is contained in:
wangzimeng 2025-08-01 17:30:25 +08:00
parent 229adacd44
commit 0e8fc589f7
2 changed files with 178 additions and 48 deletions

View File

@ -240,7 +240,10 @@
icon:'none', icon:'none',
duration: 2000 duration: 2000
}) })
getDetail() setTimeout(() =>{
getDetail()
},1000)
// getDetail()
} }
}) })
@ -258,7 +261,10 @@
icon:'none', icon:'none',
duration: 2000 duration: 2000
}) })
getDetail() setTimeout(() =>{
getDetail()
},1000)
// getDetail()
} }
}) })

View File

@ -25,35 +25,34 @@
<!-- 右侧内容 --> <!-- 右侧内容 -->
<view class="listItem-contents"> <view class="listItem-contents">
<view class="title2" style="margin-bottom: 20rpx;">{{item.platform_title}}</view> <view class="title2" style="margin-bottom: 20rpx;">{{item.platform_title}}</view>
<scroll-view class="score-box"> <view class="score-box">
<view class="fs11 flex cate"> <view class="fs11 flex cate">
<view class="cate-e" v-for="(e,i) in item.cate" :key="i"> <view class="cate-e" v-for="(e,i) in item.cate" :key="i">
<view v-show="e" class="status-tag " style="margin-right: 20rpx;">{{e}} <view class="status-tag " style="margin-right: 20rpx;">{{e}}
</view> </view>
</view> </view>
<!-- <text v-show="item.cate[1]"
class="status-tag" style="margin-right: 20rpx;">{{item.cate[1]}}</text>
<text v-show="item.cate[2]"
class="status-tag">{{item.cate[2]}}</text> -->
</view> </view>
</scroll-view> </view>
<view class="cons-third"> <view class="cons-third">
<view style="display: flex;"> <image style="width: 24rpx;height: 24rpx;"
<image style="width: 24rpx;height: 24rpx;" src="https://jiangxiaoxian.0rui.cn/locationList.png"></image>
src="https://jiangxiaoxian.0rui.cn/locationList.png"></image> <view class="title3" style="margin-left: 10rpx;">{{item.address_city_text}}
<view class="title3" style="margin-left: 10rpx;">{{item.address_city_text}}
</view>
</view> </view>
</view> </view>
</view> </view>
<!-- 右侧收藏 --> <!-- 右侧收藏 -->
<view> <view
<image style="width: 44rpx;height: 44rpx;" style="display: grid;justify-content: center;align-items: center;margin-left: 10rpx;width: 100rpx;"
src="https://jiangxiaoxian.0rui.cn/collected.png"></image> @click="rentColect(item,index)">
<!-- <image style="width: 44rpx;height: 44rpx;" src="https://jiangxiaoxian.0rui.cn/unCollect.png"></image> --> <image v-if="item.is_collect == 1" src="https://jiangxiaoxian.0rui.cn/collected.png"
<view class="fs24 Regular c3">取消收藏</view> style="width: 44rpx;height: 44rpx;margin: 0 auto;"></image>
<!-- <view class="fs24 Regular c9">收藏</view> --> <image v-if="item.is_collect == 0" style="width: 44rpx;height: 44rpx;margin: 0 auto;"
src="https://jiangxiaoxian.0rui.cn/unCollect.png"></image>
<view v-if="item.is_collect == 1" class="fs24 Regular c3" style="margin-top: 15rpx;">
取消收藏</view>
<view class="fs24 Regular c9" v-if="item.is_collect == 0" style="margin-top: 15rpx;">收藏
</view>
</view> </view>
</view> </view>
</view> </view>
@ -62,29 +61,22 @@
<!-- 平台课程 --> <!-- 平台课程 -->
<view class="exChangeBox" v-if="currentTab == 1"> <view class="exChangeBox" v-if="currentTab == 1">
<view class="couponsList" v-for="(item,index) in collectSchoolList" :key="index"> <view class="couponsList">
<view class="list-item"> <view class="list-item" v-for="(item,index) in collectSchoolList" :key="index">
<image style="width: 330rpx;height: 200rpx;" :src="item.image"> <image style="width: 330rpx;height: 200rpx;border-radius: 18rpx 18rpx 0 0;"
:src="item.image">
</image> </image>
<view class="item-text"> <view class="item-text">
<view class="fs30 c3" style="margin: 0 auto;">{{item.title}}</view> <view class="fs30 c3" style="margin: 0 auto;">{{item.title}}</view>
<view class="exchangeBtn"> <view class="exchangeBtn" v-if="item.is_collect == 1" @click="classCollect(item,index)">
取消收藏 取消收藏
</view> </view>
<view class="exchangeBtn1" v-if="item.is_collect == 0" @click="classCollect(item,index)">
收藏
</view>
</view> </view>
</view> </view>
<!-- <view class="list-item">
<image style="width: 330rpx;height: 200rpx;" src="https://jiangxiaoxian.0rui.cn/fullCoupon.png">
</image>
<view class="item-text">
<view class="fs30 c3" style="margin: 0 auto;">优惠券满100减50</view>
<view class="exchangeBtn">
取消收藏
</view>
</view>
</view> -->
</view> </view>
</view> </view>
@ -166,8 +158,10 @@
currentTab.value = e.index currentTab.value = e.index
console.log('切换tabs', currentTab.value); console.log('切换tabs', currentTab.value);
if (currentTab.value == 0) { if (currentTab.value == 0) {
collectRentList.value = [];
getRentList(); getRentList();
} else { } else {
collectSchoolList.value = [];
getSchoolList(); getSchoolList();
} }
} }
@ -180,7 +174,6 @@
limit: listQuery.value.limit, limit: listQuery.value.limit,
order: 'normal', order: 'normal',
status: 1, status: 1,
recommend: 1,
collect: 1, collect: 1,
}); });
@ -206,7 +199,6 @@
page: listQuery.value.schoolPage, page: listQuery.value.schoolPage,
limit: listQuery.value.limit, limit: listQuery.value.limit,
order: 'normal', order: 'normal',
recommend: 1,
collect: 1, collect: 1,
}); });
@ -272,6 +264,78 @@
} }
} }
//
function rentColect(item, index) {
console.log('收藏', item.is_collect);
if (item.is_collect == 1) {
collectRentList.value[index].is_collect = 0
const data = {
id: item.id,
is_collect: item.is_collect
}
sheep.$api.rent.rentCollect(data).then((res) => {
if (res.code == 1) {
uni.showToast({
title: '已取消收藏',
icon: 'none',
duration: 2000
})
}
})
} else {
collectRentList.value[index].is_collect = 1
const data1 = {
id: item.id,
is_collect: item.is_collect
}
sheep.$api.rent.rentCollect(data1).then((res) => {
if (res.code == 1) {
uni.showToast({
title: '已收藏',
icon: 'none',
duration: 2000
})
}
})
}
}
//
function classCollect(item,index) {
console.log('收藏', item.is_collect);
if (item.is_collect == 1) {
collectSchoolList.value[index].is_collect = 0
const data = {
id: item.id,
is_collect: item.is_collect
}
sheep.$api.school.classesCollect(data).then((res) => {
if(res.code == 1) {
uni.showToast({
title:'已取消收藏',
icon:'none',
duration: 2000,
})
}
})
} else {
collectSchoolList.value[index].is_collect = 1
const data1 = {
id: item.id,
is_collect: item.is_collect
}
sheep.$api.school.classesCollect(data1).then((res) => {
if(res.code == 1) {
uni.showToast({
title:'已收藏',
icon:'none',
duration: 2000,
})
}
})
}
}
onReachBottom(() => {}); onReachBottom(() => {});
onLoad(() => { onLoad(() => {
getRentList(); getRentList();
@ -319,17 +383,15 @@
// background-color: #ffffff; // background-color: #ffffff;
.recommend-box { .recommend-box {
margin-top: 30rpx; padding: 0rpx 30rpx;
padding: 20rpx 30rpx;
.rrecommList { .rrecommList {
margin-top: 30rpx; margin-top: 30rpx;
// padding: 30rpx;
.reListItem { .reListItem {
background-color: #ffffff; background-color: #ffffff;
width: 640rpx; width: 640rpx;
height: 190rpx; // height: 190rpx auto;
padding: 30rpx; padding: 30rpx;
display: flex; display: flex;
justify-content: flex-start; justify-content: flex-start;
@ -352,15 +414,24 @@
} }
.listItem-contents { .listItem-contents {
width: 300rpx;
height: auto;
margin-left: 20rpx; margin-left: 20rpx;
.score-box { .score-box {
// width: 300rpx;
display: flex; display: flex;
.cate { .cate {
width: 300rpx;
height: 190rpx auto;
display: flex; display: flex;
justify-content: flex-start; justify-content: flex-start;
align-items: center; align-items: center;
white-space: nowrap;
/* 禁止换行 */
overflow: hidden;
/* 超出部分隐藏 */
.cate-e { .cate-e {
@ -371,15 +442,41 @@
font-weight: 400; font-weight: 400;
line-height: 22rpx; line-height: 22rpx;
background-color: rgba(247, 97, 0, 0.2); background-color: rgba(247, 97, 0, 0.2);
width: 107rpx;
// opacity: 0.2; height: 36rpx;
display: flex;
justify-content: center;
align-items: center;
color: #F76100; color: #F76100;
//flex-shrink: 0
} }
} }
} }
.cate-e {
width: 300rpx;
height: 190rpx auto;
display: flex;
justify-content: flex-start;
align-items: center;
overflow-wrap: break-word;
word-break: break-word;
white-space: normal;
.status-tag {
// padding: 5rpx 15rpx;
border-radius: 5rpx;
font-size: 22rpx;
font-weight: 400;
line-height: 22rpx;
background-color: rgba(247, 97, 0, 0.2);
width: 107rpx;
height: 36rpx;
display: flex;
justify-content: center;
align-items: center;
color: #F76100;
}
}
} }
@ -387,7 +484,7 @@
.cons-third { .cons-third {
margin-top: 20rpx; margin-top: 20rpx;
display: flex; display: flex;
justify-content: space-around; justify-content: flex-start;
align-items: center; align-items: center;
} }
} }
@ -399,24 +496,34 @@
.exChangeBox { .exChangeBox {
background-color: #ffffff; // background-color: #ffffff;
width: 690rpx; width: 690rpx;
margin: 0 auto;
.couponsList { .couponsList {
width: 100%; width: 100%;
padding: 0 30rpx; // padding: 0 30rpx;
display: grid; display: grid;
grid-template-columns: repeat(2, 1fr); grid-template-columns: repeat(2, 1fr);
grid-gap: 20rpx; grid-gap: 20rpx;
box-sizing: border-box; box-sizing: border-box;
margin-top: 30rpx;
.list-item { .list-item {
width: 330rpx; width: 330rpx;
border-radius: 18rpx; border-radius: 18rpx;
box-shadow: 4rpx 4rpx 4rpx 4rpx rgba(153, 153, 153, 0.1); box-shadow: 4rpx 4rpx 4rpx 4rpx rgba(153, 153, 153, 0.1);
background-color: #ffffff;
.item-text { .item-text {
padding: 30rpx; padding: 30rpx;
display: flex;
flex-direction: column;
height: 212rpx;
/* 确保 item-text 填满父容器的高度 */
justify-content: space-between;
/* 将内容分散对齐,顶部和底部 */
.exchangeBtn { .exchangeBtn {
margin-top: 30rpx; margin-top: 30rpx;
@ -433,6 +540,23 @@
line-height: 30rpx; line-height: 30rpx;
font-weight: 400; font-weight: 400;
} }
.exchangeBtn1 {
margin-top: 30rpx;
background-color: #fcc74e;
// border: 2rpx solid #999999;
height: 70rpx;
width: 270rpx;
border-radius: 223rpx;
align-items: center;
justify-content: center;
display: flex;
color: #333333;
font-size: 28rpx;
line-height: 30rpx;
font-weight: 400;
}
} }
} }