279 lines
6.2 KiB
Vue
279 lines
6.2 KiB
Vue
|
|
<!-- 普通专题推荐位 -->
|
||
|
|
<template>
|
||
|
|
<view class="whole">
|
||
|
|
<view class="searchBox flex1">
|
||
|
|
<view class="box" @click="toSearch">
|
||
|
|
<up-icon name="search" size="18" color="#656565" />
|
||
|
|
<text> 请输入搜索关键词</text>
|
||
|
|
</view>
|
||
|
|
</view>
|
||
|
|
<view class="goodbox two">
|
||
|
|
<view class="item" v-for="(item, index) in goodsList" :key="item.id" @click="toGroups(item.id)">
|
||
|
|
<div class="imgbox">
|
||
|
|
<image :src="item.face_img + '?x-oss-process=image/format,webp'" :webp="true" mode="aspectFill" class="img"></image>
|
||
|
|
<view class="out flex" v-if="item.sold_status === 2">
|
||
|
|
<img src="https://ct-upimg.yx090.com/ju8hn6/shop/image/2024/01/16/Cr6cRRhhqYNhScigxIyumyV9hXXMI3vKvsE1jgt0.png" class="out_img" />
|
||
|
|
</view>
|
||
|
|
<view class="out flex" v-else-if="item.sold_status === 0">
|
||
|
|
<img src="https://ct-upimg.yx090.com/ju8hn6/shop/image/2024/08/21/QBhUheeYWSJ3OGM27fkAufJAlFSA8GBhWjpY5oNy.png" class="out_img" />
|
||
|
|
</view>
|
||
|
|
<view class="out flex" v-else-if="item.total_stock === 0">
|
||
|
|
<img src="https://ct-upimg.yx090.com/ju8hn6/shop/image/2024/08/21/pMTv6QiZZEpSqkJmk7hMcbEzIuNzMyp7YVBbe42H.png" class="out_img" />
|
||
|
|
</view>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<view class="box">
|
||
|
|
<view class="tit">{{item.title}}</view>
|
||
|
|
<view class="flex1">
|
||
|
|
<view class="text">
|
||
|
|
<text class="prefix">¥</text>
|
||
|
|
<text class="txt1" v-if="parseFloat(item.min_price) == parseFloat(item.max_price)">{{item.min_price}}</text>
|
||
|
|
<text class="txt1" v-else>{{item.min_price * 1}}~{{item.max_price}}</text>
|
||
|
|
</view>
|
||
|
|
</view>
|
||
|
|
</view>
|
||
|
|
</view>
|
||
|
|
<view v-if="loading" class="loadbox">
|
||
|
|
<up-loading-icon text="加载中..." textSize="14"></up-loading-icon>
|
||
|
|
</view>
|
||
|
|
<view class="bottom" v-if="page >= last_page && goodsList.length">
|
||
|
|
— 没有更多了 —
|
||
|
|
</view>
|
||
|
|
</view>
|
||
|
|
|
||
|
|
<!-- 返回顶部 -->
|
||
|
|
<div @click="handleTop" v-if="showTop" class="top">
|
||
|
|
<up-icon name="arrow-upward" color="#000" size="24" />
|
||
|
|
</div>
|
||
|
|
|
||
|
|
</view>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
import { ref, reactive, toRefs } from 'vue'
|
||
|
|
import { get, post } from '@/api/request.js'
|
||
|
|
import { Style } from '@/utils/list.js'
|
||
|
|
|
||
|
|
export default {
|
||
|
|
setup() {
|
||
|
|
const data = reactive({
|
||
|
|
page: 1,
|
||
|
|
last_page: 0,
|
||
|
|
goodsList: [],
|
||
|
|
loading: false,
|
||
|
|
showTop: false,
|
||
|
|
pageInfo: {},
|
||
|
|
Color: '',
|
||
|
|
priceColor: '',
|
||
|
|
bgColor: ''
|
||
|
|
})
|
||
|
|
|
||
|
|
async function getFetchList(val = 1) {
|
||
|
|
uni.showLoading({
|
||
|
|
mask: true,
|
||
|
|
title: '加载中'
|
||
|
|
})
|
||
|
|
data.loading = true
|
||
|
|
await get('/api/app/groupGoods/all', { page: data.page, pageSize: 20 }).then((res) => {
|
||
|
|
data.last_page = res.meta.last_page
|
||
|
|
data.goodsList = val == 1 ? data.goodsList.concat(res.data) : res.data
|
||
|
|
uni.hideLoading()
|
||
|
|
data.loading = false
|
||
|
|
}).catch(() => {
|
||
|
|
data.loading = false
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
const handleTop = () => {
|
||
|
|
uni.pageScrollTo({
|
||
|
|
scrollTop: 0,
|
||
|
|
duration: 300
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
const toGroups = (id) => {
|
||
|
|
uni.navigateTo({
|
||
|
|
url: '/pages/groups/index?id=' + id
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
function toSearch() {
|
||
|
|
uni.navigateTo({
|
||
|
|
url: '/pages/search/index'
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
return {
|
||
|
|
...toRefs(data),
|
||
|
|
getFetchList,
|
||
|
|
handleTop,
|
||
|
|
toGroups,
|
||
|
|
toSearch
|
||
|
|
}
|
||
|
|
},
|
||
|
|
onReachBottom() {
|
||
|
|
if (this.page < this.last_page) {
|
||
|
|
this.page ++
|
||
|
|
this.getFetchList()
|
||
|
|
}
|
||
|
|
},
|
||
|
|
onPageScroll(e) {
|
||
|
|
if (e.scrollTop > 300) {
|
||
|
|
this.showTop = true
|
||
|
|
} else {
|
||
|
|
this.showTop = false
|
||
|
|
}
|
||
|
|
},
|
||
|
|
async onLoad(options) {
|
||
|
|
// await this.$onLaunched
|
||
|
|
await this.getFetchList()
|
||
|
|
this.Color = uni.getStorageSync('theme_color')
|
||
|
|
this.priceColor = Style[uni.getStorageSync('theme_index') * 1].priceColor
|
||
|
|
this.bgColor = Style[uni.getStorageSync('theme_index') * 1].bgColor
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<style lang="scss" scoped>
|
||
|
|
.flex{
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
justify-content: center;
|
||
|
|
}
|
||
|
|
.flex1{
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
justify-content: space-between;
|
||
|
|
}
|
||
|
|
.whole{
|
||
|
|
.searchBox{
|
||
|
|
padding: 20rpx;
|
||
|
|
font-size: 28rpx;
|
||
|
|
color: #C7C7C7;
|
||
|
|
box-sizing: border-box;
|
||
|
|
.box{
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
padding: 0 20rpx;
|
||
|
|
box-sizing: border-box;
|
||
|
|
background-color: #fff;
|
||
|
|
border-radius: 60rpx;
|
||
|
|
height: 60rpx;
|
||
|
|
width: 100%;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
.goodbox{
|
||
|
|
padding: 0 24rpx 1px;
|
||
|
|
display: flex;
|
||
|
|
flex-wrap: wrap;
|
||
|
|
.item{
|
||
|
|
margin: 0 24rpx 24rpx 0;
|
||
|
|
background: #fff;
|
||
|
|
padding: 24rpx;
|
||
|
|
box-sizing: border-box;
|
||
|
|
border-radius: 10rpx;
|
||
|
|
width: calc(50% - 14rpx);
|
||
|
|
&:nth-child(2n+2){
|
||
|
|
margin: 0 0 24rpx 0;
|
||
|
|
}
|
||
|
|
.imgbox{
|
||
|
|
position: relative;
|
||
|
|
width: 100%;
|
||
|
|
.out{
|
||
|
|
position: absolute;
|
||
|
|
width: 100%;
|
||
|
|
height: 100%;
|
||
|
|
top: 0;
|
||
|
|
left: 0;
|
||
|
|
.out_img{
|
||
|
|
width: 150rpx;
|
||
|
|
height: 150rpx;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
.img{
|
||
|
|
width: 100%;
|
||
|
|
height: 292rpx;
|
||
|
|
border-radius: 10rpx;
|
||
|
|
}
|
||
|
|
.box{
|
||
|
|
display: flex;
|
||
|
|
width: 100%;
|
||
|
|
height: auto;
|
||
|
|
flex-direction: column;
|
||
|
|
justify-content: space-between;
|
||
|
|
.txt1{
|
||
|
|
font-size: 28rpx;
|
||
|
|
}
|
||
|
|
.tit{
|
||
|
|
font-size: 28rpx;
|
||
|
|
color: #2C2C2C;
|
||
|
|
display: -webkit-box;
|
||
|
|
-webkit-box-orient: vertical;
|
||
|
|
-webkit-line-clamp: 2;
|
||
|
|
overflow: hidden;
|
||
|
|
line-height: 40rpx;
|
||
|
|
height: 80rpx;
|
||
|
|
margin: 10rpx 0;
|
||
|
|
}
|
||
|
|
.ation{
|
||
|
|
font-size: 22rpx;
|
||
|
|
text{
|
||
|
|
margin: 0 8rpx 8rpx 0;
|
||
|
|
border-radius: 6rpx;
|
||
|
|
padding: 6rpx 10rpx;
|
||
|
|
line-height: 1;
|
||
|
|
color: v-bind('Color');
|
||
|
|
display: inline-block;
|
||
|
|
}
|
||
|
|
.quan{
|
||
|
|
border: 1px solid v-bind('Color');
|
||
|
|
}
|
||
|
|
.man{
|
||
|
|
background-color: v-bind('bgColor');
|
||
|
|
border: 1px solid v-bind('bgColor');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
.text{
|
||
|
|
color: v-bind('priceColor');
|
||
|
|
.prefix{
|
||
|
|
font-size: 24rpx;
|
||
|
|
}
|
||
|
|
text{
|
||
|
|
font-size: 34rpx;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
.top {
|
||
|
|
position: fixed;
|
||
|
|
bottom: 15%;
|
||
|
|
right: 5%;
|
||
|
|
background: #fff;
|
||
|
|
width: 80rpx;
|
||
|
|
height: 80rpx;
|
||
|
|
line-height: 107rpx;
|
||
|
|
border-radius: 50%;
|
||
|
|
text-align: center;
|
||
|
|
box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.2);
|
||
|
|
z-index: 10;
|
||
|
|
}
|
||
|
|
.loadbox{
|
||
|
|
padding: 30rpx 0;
|
||
|
|
text-align: center;
|
||
|
|
font-size: 24rpx;
|
||
|
|
color: #98989f;
|
||
|
|
margin: 0 auto;
|
||
|
|
}
|
||
|
|
.bottom {
|
||
|
|
text-align: center;
|
||
|
|
font-size: 24rpx;
|
||
|
|
color: #999;
|
||
|
|
margin: auto;
|
||
|
|
padding: 20rpx 0 40rpx;
|
||
|
|
width: 100%;
|
||
|
|
}
|
||
|
|
</style>
|