90 lines
2.2 KiB
Vue
90 lines
2.2 KiB
Vue
<template>
|
|
<view class="app">
|
|
<view class="cards">
|
|
<view class="item" :style="{background:listcolor[index % listcolor.length]}" @tap='goProductList(item)'
|
|
v-for="(item,index) in goodsCategoryList" :key="index">
|
|
<image :src="item.goodsCategoryPicture" mode=""></image>
|
|
<view class="title" style="font-size:42rpx">
|
|
{{item.goodsCategoryName}}
|
|
</view>
|
|
</view>
|
|
<view style="width:43%" v-if="goodsCategoryList.length%2!=0">
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
<script>
|
|
import {
|
|
goodsCategoryList
|
|
} from '@/api/shopping/shopping.js';
|
|
import baseurl from '@/api/baseurl.js'
|
|
export default {
|
|
data() {
|
|
return {
|
|
pageNum: 1, //页
|
|
pageSize: 10, //列
|
|
total: 0, //list总长度
|
|
goodsCategoryList: [], //商品列表list
|
|
listimg: [{
|
|
img: '../../static/sp.png',
|
|
},
|
|
{
|
|
img: '../../static/yyss.png',
|
|
},
|
|
{
|
|
img: '../../static/znsb.png',
|
|
},
|
|
{
|
|
img: '../../static/cp.png',
|
|
},
|
|
],
|
|
listcolor: ['#00C176', '#D43953', '#E1AE3C', '#4C7BC9', '#9e4dd0'], //颜色随动
|
|
};
|
|
},
|
|
onLoad(options) { //初始化加载
|
|
this.pageNum = 1
|
|
this.goodsCategory()
|
|
},
|
|
methods: {
|
|
//跳转到商品列表页面
|
|
goProductList(item) {
|
|
uni.navigateTo({
|
|
url: `/pages/ProductList/ProductList?title=${item.goodsCategoryName}&goodsCategoryId=${item.id}`
|
|
})
|
|
},
|
|
//获取商城信息
|
|
goodsCategory() {
|
|
goodsCategoryList(this.pageSize, this.pageNum).then(res => {
|
|
res.rows.forEach(e => {
|
|
e.goodsCategoryPicture = baseurl + e.goodsCategoryPicture
|
|
this.goodsCategoryList.push(e)
|
|
})
|
|
this.total = res.total
|
|
})
|
|
}
|
|
},
|
|
onReachBottom() { //下滑加载
|
|
if (this.goodsCategoryList.length >= this.total) {} else {
|
|
this.pageNum++;
|
|
this.goodsCategory()
|
|
}
|
|
},
|
|
onPullDownRefresh() { //下拉刷新
|
|
this.pageNum = 1;
|
|
goodsCategoryList(this.pageSize, this.pageNum).then(res => {
|
|
res.rows.forEach(e => {
|
|
e.goodsCategoryPicture = baseurl + e.goodsCategoryPicture
|
|
})
|
|
this.goodsCategoryList = res.rows
|
|
this.total = res.total
|
|
})
|
|
setTimeout(function() {
|
|
uni.stopPullDownRefresh();
|
|
}, 1000);
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
</style>
|