656 lines
15 KiB
Vue
Raw Normal View History

<template>
2025-08-01 18:02:24 +08:00
<s-layout title="搜索结果" :bgStyle="{ color: '#ffffff' }">
<!-- <view>搜索页面</view> -->
<view class="container">
<view class="top">
<!-- 顶部-地址&搜索 -->
<view class="locTop">
<view class="locTop-right">
<uni-section style="border-radius: 192rpx;padding: 0;" type="line">
<uni-search-bar v-model="listQuery.keywords" @confirm="search"
style="border-radius: 192rpx;" radius="23" placeholder="搜索您需要的信息" bgColor="#EEEEEE"
clearButton="none" cancelButton="none" />
</uni-section>
<!-- @confirm="search" -->
</view>
</view>
</view>
2025-08-01 18:02:24 +08:00
<!-- 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">
<view class="reListItem" v-for="(item,index) in searchRentList" :key="index"
@click="toDetail(item)">
<!-- 左侧图片 -->
<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]" mode="aspectFill"></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 class="title3">{{item.release_time_text}}</view>
<view style="display: flex;">
<image style="width: 24rpx;height: 24rpx;"
src="https://jiangxiaoxian.0rui.cn/eye.png"></image>
<view class="title3" style="margin-left: 10rpx;">{{item.views}}</view>
</view>
</view>
</view>
</view>
</view>
</view>
<!-- 平台课程 -->
<view class="exChangeBox" v-if="currentTab == 1">
<view class="couponsList">
<view class="list-item" v-for="(item,index) in searchClassesList" :key="index"
@click="toDetail(item)">
<image style="width: 100%;height: 200rpx;border-radius: 30rpx 30rpx 0 0;" :src="item.image">
</image>
<image v-if="item.status == 1"
style="width: 77rpx;height: 36rpx;z-index: 100;position: relative;bottom: 190rpx;left: 20rpx;"
src="https://jiangxiaoxian.0rui.cn/schoolText.png"></image>
<image v-if="item.status == 2"
style="width: 77rpx;height: 36rpx;z-index: 100;position: relative;bottom: 190rpx;left: 20rpx;"
src="https://jiangxiaoxian.0rui.cn/schoolVideo.png"></image>
<view class="item-text">
<view class="fs30 c3 classTitle" style="">{{item.title}}</view>
<view class="cons-third">
<view class="title3">{{item.release_time_text}}</view>
<view style="display: flex;">
<image style="width: 24rpx;height: 24rpx;"
src="https://jiangxiaoxian.0rui.cn/eye.png">
</image>
<view class="title3" style="margin-left: 10rpx;">{{item.views}}</view>
</view>
</view>
</view>
</view>
</view>
</view>
<!-- 原料商城 -->
<view class="goodsBox" v-if="currentTab == 2">
<view class="goodsList">
<view class="list-item" v-for="(item,index) in mallList" :key="index"
@click="sheep.$router.go('/pages/goods/index', { id: item.id })">
<image style="width: 330rpx;height: 200rpx;border-radius: 18rpx 18rpx 0 0;"
:src="item.full_image">
</image>
<view class="item-text">
<view class="fs30 c3 goodsTitle" style="margin: 0 auto;width: 300rpx;">{{item.title}}
</view>
<view class="cons-third">
<view class="title3">{{item.release_time_text}}</view>
<view style="display: flex;">
<image style="width: 24rpx;height: 24rpx;"
src="https://jiangxiaoxian.0rui.cn/eye.png">
</image>
<view class="title3" style="margin-left: 10rpx;">{{item.views}}</view>
</view>
</view>
</view>
</view>
</view>
</view>
<!-- 无数据展示 -->
<view class="flex flex-column justify-center align-items" style="margin-top: 230rpx;"
v-if="( currentTab == 0 && searchRentList.length == 0) || (currentTab == 1 && searchClassesList.length == 0) || (currentTab == 2 && mallList.length == 0)">
<image src="https://jiangxiaoxian.0rui.cn/noneList.png" mode=""
style="width: 520rpx;height: 259rpx;">
</image>
<view v-if="listQuery.keywords == ''" style="margin-top: 30rpx;font-size: 28rpx;color: #323232;">
请输入要搜索的内容</view>
<view v-else style="margin-top: 30rpx;font-size: 28rpx;color: #323232;">暂无相关数据</view>
</view>
</scroll-view>
2025-08-01 18:02:24 +08:00
</view>
</s-layout>
</template>
2025-08-01 18:02:24 +08:00
<script setup>
import sheep from '@/sheep';
import {
reactive,
ref
} from 'vue';
import {
onLoad,
onReachBottom
} from '@dcloudio/uni-app';
import _ from 'lodash';
2025-08-01 18:02:24 +08:00
// const
const tabMaps = [{
name: '食堂招租',
value: '0',
},
{
name: '平台学院',
value: '1',
},
{
name: '原料商城',
value: '2',
},
];
const currentTab = ref(0)
const searchRentList = ref([])
2025-08-01 18:02:24 +08:00
const rentCount = ref(0)
const searchClassesList = ref([])
2025-08-01 18:02:24 +08:00
const schoolCount = ref(0)
const mallList = ref([])
const mallCount = ref(0)
const homrS = ref(false)
const loadStatus = ref('')
const listQuery = ref({
keywords: null,
add_type: null,
type: null,
my: null,
page: 1,
list_rows: 10,
2025-08-01 18:02:24 +08:00
rentPage: 1,
schoolPage: 1,
mallPage: 1,
2025-08-01 18:02:24 +08:00
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,
})
//切换tabs
function onChange(e) {
console.log('onChange', e);
currentTab.value = e.index
console.log('切换tabs', currentTab.value, listQuery.value.keywords);
if (listQuery.value.keywords != null) {
if (currentTab.value == 0) {
searchRentList.value = [];
if(listQuery.value.keywords == null || listQuery.value.keywords == '') {
}else {
getRentList();
}
} else if (currentTab.value == 1) {
searchClassesList.value = [];
if(listQuery.value.keywords == null || listQuery.value.keywords == '') {
}else {
getSchoolList();
}
} else {
mallList.value = [];
if(listQuery.value.keywords == null || listQuery.value.keywords == '') {
}else {
getGoods();
// getRentList();
}
}
}
}
function search(e) {
console.log('搜索', e.value);
2025-08-01 18:02:24 +08:00
if (currentTab.value == 0) {
searchRentList.value = [];
2025-08-01 18:02:24 +08:00
getRentList();
} else if (currentTab.value == 1) {
searchClassesList.value = [];
2025-08-01 18:02:24 +08:00
getSchoolList();
} else {
mallList.value = [];
getGoods();
2025-08-01 18:02:24 +08:00
}
}
//商品
function getGoods() {
console.log('商品', listQuery.value.keywords);
// const listQuery =
sheep.$api.goods.list({
page: listQuery.value.mallPage,
list_rows: listQuery.value.list_rows,
keyword: listQuery.value.keywords,
}).then((res) => {
if (res.code == 1) {
console.log('商品搜素列表:', res.data);
mallList.value = res.data.data
mallCount.value = res.data.total
}
})
}
2025-08-01 18:02:24 +08:00
//招租列表
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,
});
console.log('招租收藏列表', res);
2025-08-01 18:02:24 +08:00
if (res.code == 1) {
searchRentList.value = [...searchRentList.value, ...res.data.list];
2025-08-01 18:02:24 +08:00
rentCount.value = res.data.count
for(let i=0;i<searchRentList.value.length;i++){
searchRentList.value[i].release_time_text = searchRentList.value[i].release_time_text.substring(0, 10)
}
2025-08-01 18:02:24 +08:00
} else {
// Handle case where data is not in expected format
searchRentList.value = [];
2025-08-01 18:02:24 +08:00
uni.showToast({
title: res.msg,
icon: 'none'
})
}
console.log('getList', searchRentList.value);
2025-08-01 18:02:24 +08:00
}
//平台课程列表
async function getSchoolList() {
const res = await sheep.$api.school.schoolList({
keywords: listQuery.value.keywords,
page: listQuery.value.schoolPage,
limit: listQuery.value.limit,
order: 'normal',
});
console.log('平台课程收藏列表', res);
2025-08-01 18:02:24 +08:00
if (res.code == 1) {
searchClassesList.value = [...searchClassesList.value, ...res.data.list];
2025-08-01 18:02:24 +08:00
schoolCount.value = res.data.count
} else {
// Handle case where data is not in expected format
searchClassesList.value = [];
2025-08-01 18:02:24 +08:00
uni.showToast({
title: res.msg,
icon: 'none'
})
}
console.log('平台课程收藏列表-222', searchClassesList.value);
2025-08-01 18:02:24 +08:00
}
2025-08-01 18:02:24 +08:00
//加载更多
function onScrolltolower() {
if (currentTab.value == 0) {
if (searchRentList.value.length < rentCount.value) {
2025-08-01 18:02:24 +08:00
listQuery.value.rentPage += 1;
getRentList();
}
} else if (currentTab.value == 1) {
if (searchClassesList.value.length < schoolCount.value) {
2025-08-01 18:02:24 +08:00
listQuery.value.schoolPage += 1;
getSchoolList();
}
} else {
if (mallList.value.length < mallCount.value) {
listQuery.value.mallPage += 1;
getGoods();
}
2025-08-01 18:02:24 +08:00
}
2025-08-01 18:02:24 +08:00
}
//下拉刷新
function onS() {
homrS.value = true;
listQuery.value.keywords = ''
2025-08-01 18:02:24 +08:00
uni.showLoading({
title: '加载中...'
});
resetLists();
setTimeout(() => {
homrS.value = false;
uni.hideLoading();
uni.stopPullDownRefresh();
}, 2000)
}
// 重置列表
function resetLists() {
if (currentTab.value == 0) {
listQuery.value.rentPage = 1;
searchRentList.value = [];
2025-08-01 18:02:24 +08:00
loadStatus.value = "loading";
getRentList();
} else if (currentTab.value == 1) {
2025-08-01 18:02:24 +08:00
listQuery.value.schoolPage = 1;
searchClassesList.value = [];
2025-08-01 18:02:24 +08:00
loadStatus.value = "loading";
getSchoolList();
} else {
listQuery.value.mallPage = 1;
mallList.value = [];
loadStatus.value = "loading";
getGoods();
2025-08-01 18:02:24 +08:00
}
}
</script>
2025-08-01 18:02:24 +08:00
<style lang="scss" scoped>
.flex {
display: flex;
}
.align-start {
align-items: flex-start;
}
.justify-center {
justify-content: center;
}
.align-items {
align-items: center;
}
.flex-column {
flex-flow: column;
}
.search-result {
padding-top: 10px;
padding-bottom: 20px;
text-align: center;
}
.search-result-text {
text-align: center;
font-size: 14px;
color: #666;
}
.example-body {
/* #ifndef APP-NVUE */
display: block;
/* #endif */
padding: 0px;
}
.uni-mt-10 {
margin-top: 10px;
}
.title2 {
color: #3d3d3d;
font-size: 30rpx;
font-weight: 800;
line-height: 42rpx;
}
.title3 {
font-size: 20rpx;
font-weight: 400;
color: #999999;
line-height: 22rpx;
}
2025-08-01 18:02:24 +08:00
.container {
.top {
height: 70rpx;
background-size: 100%;
padding: 30rpx;
display: grid;
.locTop {
width: 100%;
height: 70rpx;
display: flex;
.locTop-right {
width: 690rpx;
height: 70rpx;
}
}
}
.recommend-box {
padding: 0rpx 30rpx;
.rrecommList {
// margin-top: 30rpx;
.reListItem {
background-color: #ffffff;
width: 640rpx;
height: 190rpx;
padding: 30rpx;
display: flex;
margin-top: 20rpx;
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;
border-radius: 12rpx;
}
}
.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;
width: 430rpx;
display: flex;
justify-content: space-between;
align-items: center;
}
}
}
}
}
.exChangeBox {
width: 690rpx;
margin: 0 auto;
.couponsList {
width: 100%;
// padding: 0 30rpx;
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-gap: 20rpx;
box-sizing: border-box;
margin-top: 30rpx;
.list-item {
width: 330rpx;
border-radius: 18rpx;
box-shadow: 4rpx 4rpx 4rpx 4rpx rgba(153, 153, 153, 0.1);
background-color: #ffffff;
.item-text {
padding: 0rpx 20rpx 0rpx 20rpx;
height: 120rpx;
position: relative;
bottom: 30rpx;
// text-align: center;
.classTitle {
height: 80rpx;
width: 300rpx;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
.cons-third {
margin-top: 20rpx;
display: flex;
justify-content: space-between;
align-items: center;
}
}
}
}
}
.goodsBox {
width: 690rpx;
margin: 0 auto;
.goodsList {
width: 100%;
// padding: 0 30rpx;
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-gap: 20rpx;
box-sizing: border-box;
margin-top: 30rpx;
.list-item {
width: 330rpx;
border-radius: 18rpx;
box-shadow: 4rpx 4rpx 4rpx 4rpx rgba(153, 153, 153, 0.1);
background-color: #ffffff;
.item-text {
padding: 20rpx;
min-height: 140rpx;
position: relative;
bottom: 0rpx;
// text-align: center;
.goodsTitle {
min-height: 100rpx;
width: 300rpx;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
.cons-third {
margin-top: 20rpx;
display: flex;
justify-content: space-between;
align-items: center;
}
}
}
}
}
2025-08-01 18:02:24 +08:00
}
</style>