shop_uniapp/components/goods-column/goods-column.vue

144 lines
3.2 KiB
Vue
Raw Normal View History

2024-06-06 09:55:01 +08:00
<template>
<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
:up="upOption" :down="downOption" v-if="hasData">
2024-12-11 11:50:10 +08:00
<view class="">
<view class="flex row-center zx">
<text class="bold xxl">甄选</text>
<u-image :src="aliOSS + 'uniapp/jh.png'" width="110" height="100" mode="aspectFit"></u-image>
</view>
</view>
2024-06-06 09:55:01 +08:00
<view class="goods-column">
<scroll-view scroll-x="true">
<view class="column-wrap">
<view class="item flex-col m-r-50 muted" v-for="(item, index) in columnList" :key="index" @tap="changeActive(index)">
2024-12-11 11:50:10 +08:00
<view class="sm normal title" :class="{bold: active == index}">{{item.name}}</view>
2024-06-06 09:55:01 +08:00
</view>
</view>
</scroll-view>
</view>
<view class="goods">
<goods-list type="double" :list="goodsList" :price-type="price_type"></goods-list>
</view>
</mescroll-body>
</template>
<script>
import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
import {
getGoodsListColumn,
getGoodsColumn
} from "@/api/store"
export default {
mixins: [MescrollMixin],
props:{
autoGetData: {
type: Boolean,
default:true
}
},
data() {
return {
goodsList: [],
active: 0,
columnList: [],
upOption: {
auto: false,
empty: {
2024-11-15 15:47:51 +08:00
icon: `${this.$aliOSS}uniapp/goods_null.png`,
2024-06-06 09:55:01 +08:00
tip: "暂无商品",
},
toTop: {
bottom: '300rpx'
}
},
downOption:{use: false, isLock: true},
hasData: true,
price_type: 0
}
},
mounted() {
if(this.autoGetData) {
this.getData()
}
},
methods: {
async getData() {
await this.getGoodsColumnFun()
2024-12-16 17:47:48 +08:00
this.mescroll.resetUpScroll()
2024-06-06 09:55:01 +08:00
},
changeActive(index) {
this.active = index
2024-12-16 17:47:48 +08:00
this.$refs.uWaterfall.clear()
this.mescroll.resetUpScroll()
2024-06-06 09:55:01 +08:00
},
upCallback(page) {
const {columnList, active} = this
2024-12-16 17:47:48 +08:00
const pageNum = page.num
const pageSize = page.size
2024-06-06 09:55:01 +08:00
if(!columnList.length) return
const columnId = columnList[active].id
getGoodsListColumn({
page_size: pageSize,
page_no: pageNum,
column_id: columnId,
p_id: this.$store.getters.hasPid,
set: this.$store.getters.hasSetId
}).then(({
data
}) => {
2024-12-16 17:47:48 +08:00
this.price_type = data.set_price_type
let curPageData = data.lists
let curPageLen = curPageData.length
let hasNext = !!data.more
if (page.num == 1) this.goodsList = []
this.goodsList = this.goodsList.concat(curPageData)
this.mescroll.endSuccess(curPageLen, hasNext)
2024-06-06 09:55:01 +08:00
})
},
async getGoodsColumnFun() {
const {
data,
code
} = await getGoodsColumn()
if (code == 1) {
this.columnList = data
this.hasData = data.length ? true : false
}
}
}
}
</script>
<style lang="scss" scoped>
2024-12-11 11:50:10 +08:00
.zx {
2024-12-16 17:47:48 +08:00
background: #fff;
2024-12-11 11:50:10 +08:00
margin: 0 30rpx;
border-radius: 40rpx;
}
2024-12-16 17:47:48 +08:00
.goods {
margin-top: -6rpx;
}
2024-06-06 09:55:01 +08:00
.goods-column {
.column-wrap {
display: inline-block;
white-space: nowrap;
2024-12-16 17:47:48 +08:00
padding: 20rpx 20rpx 0;
2024-06-06 09:55:01 +08:00
.item {
display: inline-block;
position: relative;
overflow: hidden;
.title {
position: relative;
z-index: 1;
2024-12-16 17:47:48 +08:00
background: #fff;
2024-12-11 11:50:10 +08:00
border-radius: 20rpx;
padding: 10rpx 20rpx;
2024-06-06 09:55:01 +08:00
}
}
}
}
</style>