zhongtuanCatering/pages/user/goods-collect.vue
wangzimeng 984c79350a 1、收藏两个一行展示列表的css调整
2、食堂招租列表的列表改为scroll-view的内部,新增加载更多和下来刷新的方法
3、平台学院列表改为scroll-view的内部,新增加载更多和下来刷新的方法
4、食堂详情页面:详情静态+数据对接
2025-07-25 18:05:25 +08:00

444 lines
9.8 KiB
Vue

<template>
<s-layout title="我的收藏">
<view class="container">
<!-- tabs页签 -->
<view class="tabs-box">
<su-tabs :list="tabMaps" @change="onChange" :scrollable="false" :current="currentTab"></su-tabs>
</view>
<scroll-view @scrolltolower="onScrolltolower" :refresher-enabled="true" :refresher-triggered="homrS"
@refresherrefresh="onS" scroll-y="true" class="flex align-items"
style="height: 1250rpx;box-sizing: border-box;">
<!-- 食堂招租 -->
<view class="recommend-box" v-if="currentTab == 0">
<view class="rrecommList" v-for="(item,index) in collectRentList" :key="index">
<view class="reListItem">
<!-- 左侧图片 -->
<view class="listItem-images">
<image v-if="item.recommend == 1"
style="width: 77rpx;height: 36rpx;z-index: 100;position: relative;top: 34rpx;left: 0rpx;"
src="https://jiangxiaoxian.0rui.cn/hot.png"></image>
<image class="iamges-mainImg" :src="item.images[0]"></image>
</view>
<!-- 右侧内容 -->
<view class="listItem-contents">
<view class="title2" style="margin-bottom: 20rpx;">{{item.platform_title}}</view>
<scroll-view class="score-box">
<view class="fs11 flex cate">
<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>
</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>
</scroll-view>
<view class="cons-third">
<view style="display: flex;">
<image style="width: 24rpx;height: 24rpx;"
src="https://jiangxiaoxian.0rui.cn/locationList.png"></image>
<view class="title3" style="margin-left: 10rpx;">{{item.address_city_text}}
</view>
</view>
</view>
</view>
<!-- 右侧收藏 -->
<view>
<image style="width: 44rpx;height: 44rpx;"
src="https://jiangxiaoxian.0rui.cn/collected.png"></image>
<!-- <image style="width: 44rpx;height: 44rpx;" src="https://jiangxiaoxian.0rui.cn/unCollect.png"></image> -->
<view class="fs24 Regular c3">取消收藏</view>
<!-- <view class="fs24 Regular c9">收藏</view> -->
</view>
</view>
</view>
</view>
<!-- 平台课程 -->
<view class="exChangeBox" v-if="currentTab == 1">
<view class="couponsList" v-for="(item,index) in collectSchoolList" :key="index">
<view class="list-item">
<image style="width: 330rpx;height: 200rpx;" :src="item.image">
</image>
<view class="item-text">
<view class="fs30 c3" style="margin: 0 auto;">{{item.title}}</view>
<view class="exchangeBtn">
取消收藏
</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 class="flex flex-column flex-start align-items" style="margin-top: 400rpx;"
v-if="( currentTab == 0 && collectRentList.length == 0) || (currentTab == 1 && collectSchoolList.length == 0)">
<image src="https://jiangxiaoxian.0rui.cn/noneList.png" mode=""
style="width: 520rpx;height: 259rpx;">
</image>
<view style="margin-top: 30rpx;font-size: 28rpx;color: #323232;">暂无数据信息</view>
</view>
</scroll-view>
</view>
</s-layout>
</template>
<script setup>
import sheep from '@/sheep';
import {
reactive,
ref
} from 'vue';
import {
onLoad,
onReachBottom
} from '@dcloudio/uni-app';
import _ from 'lodash';
const sys_navBar = sheep.$platform.navbar;
const listQuery = ref({
keywords: null,
add_type: null,
type: null,
my: null,
page: 1,
rentPage: 1,
schoolPage: 1,
limit: 10,
cate_ids: '',
province: null,
city: null,
district: null,
status: null,
recommend: null,
collect: null,
order: null,
nearby: null,
latitude: null,
longitude: '',
area: null,
})
// const
const tabMaps = [{
name: '食堂招租',
value: '0',
},
{
name: '平台学院',
value: '1',
},
];
const currentTab = ref(0)
const collectRentList = ref([])
const rentCount = ref(0)
const collectSchoolList = ref([])
const schoolCount = ref(0)
const homrS = ref(false)
const loadStatus = ref('')
//切换tabs
function onChange(e) {
console.log('onChange', e);
currentTab.value = e.index
console.log('切换tabs', currentTab.value);
if (currentTab.value == 0) {
getRentList();
} else {
getSchoolList();
}
}
//招租收藏列表
async function getRentList() {
const res = await sheep.$api.rent.rentlist({
keywords: listQuery.value.keywords,
page: listQuery.value.rentPage,
limit: listQuery.value.limit,
order: 'normal',
status: 1,
recommend: 1,
collect: 1,
});
console.log('招租收藏列表', res);
if (res.code == 1) {
collectRentList.value = [...collectRentList.value, ...res.data.list];
rentCount.value = res.data.count
} else {
// Handle case where data is not in expected format
collectRentList.value = [];
uni.showToast({
title: res.msg,
icon: 'none'
})
}
console.log('getList', collectRentList.value);
}
//平台课程收藏列表
async function getSchoolList() {
const res = await sheep.$api.school.schoolList({
keywords: listQuery.value.keywords,
page: listQuery.value.schoolPage,
limit: listQuery.value.limit,
order: 'normal',
recommend: 1,
collect: 1,
});
console.log('平台课程收藏列表', res);
if (res.code == 1) {
collectSchoolList.value = [...collectSchoolList.value, ...res.data.list];
schoolCount.value = res.data.count
} else {
// Handle case where data is not in expected format
collectSchoolList.value = [];
uni.showToast({
title: res.msg,
icon: 'none'
})
}
console.log('平台课程收藏列表-222', collectSchoolList.value);
}
//加载更多
function onScrolltolower() {
if (currentTab.value == 0) {
if (collectRentList.value.length < rentCount.value) {
listQuery.value.rentPage += 1;
getRentList();
}
} else {
if (collectSchoolList.value.length < schoolCount.value) {
listQuery.value.schoolPage += 1;
getSchoolList();
}
}
}
//下拉刷新
function onS() {
homrS.value = true
uni.showLoading({
title: '加载中...'
});
resetLists();
if (currentTab.value == 0) {
getRentList();
} else {
getSchoolList();
}
setTimeout(() => {
homrS.value = false;
uni.hideLoading();
uni.stopPullDownRefresh();
}, 2000)
}
// 重置列表
function resetLists() {
if (currentTab.value == 0) {
listQuery.value.rentPage = 1;
collectRentList.value = [];
loadStatus.value = "loading";
} else {
listQuery.value.schoolPage = 1;
collectSchoolList.value = [];
loadStatus.value = "loading";
}
}
onReachBottom(() => {});
onLoad(() => {
getRentList();
});
</script>
<style lang="scss" scoped>
.flex {
display: flex;
}
.flex-start {
align-items: flex-start;
}
.justify-center {
justify-content: center;
}
.align-items {
align-items: center;
}
.flex-column {
flex-flow: column;
}
.fs24 {
font-size: 24rpx;
}
.Regular {
font-weight: 400;
}
.c3 {
color: #333333;
}
.c9 {
color: #999999;
}
.container {
// background-color: #ffffff;
.recommend-box {
margin-top: 30rpx;
padding: 20rpx 30rpx;
.rrecommList {
margin-top: 30rpx;
// padding: 30rpx;
.reListItem {
background-color: #ffffff;
width: 640rpx;
height: 190rpx;
padding: 30rpx;
display: flex;
justify-content: flex-start;
align-items: center;
border-radius: 18rpx;
.listItem-images {
display: grid;
justify-content: flex-start;
.iamges-mainImg {
width: 190rpx;
height: 190rpx;
position: relative;
right: 0rpx;
bottom: 18rpx;
z-index: 1;
}
}
.listItem-contents {
margin-left: 20rpx;
.score-box {
display: flex;
.cate {
display: flex;
justify-content: flex-start;
align-items: center;
.cate-e {
.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);
// opacity: 0.2;
color: #F76100;
//flex-shrink: 0
}
}
}
}
.cons-third {
margin-top: 20rpx;
display: flex;
justify-content: space-around;
align-items: center;
}
}
}
}
}
.exChangeBox {
background-color: #ffffff;
width: 690rpx;
.couponsList {
width: 100%;
padding: 0 30rpx;
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-gap: 20rpx;
box-sizing: border-box;
.list-item {
width: 330rpx;
border-radius: 18rpx;
box-shadow: 4rpx 4rpx 4rpx 4rpx rgba(153, 153, 153, 0.1);
.item-text {
padding: 30rpx;
.exchangeBtn {
margin-top: 30rpx;
background-color: #ffffff;
border: 2rpx solid #999999;
height: 70rpx;
width: 270rpx;
border-radius: 223rpx;
align-items: center;
justify-content: center;
display: flex;
color: #999999;
font-size: 28rpx;
line-height: 30rpx;
font-weight: 400;
}
}
}
}
}
}
</style>