2022-11-25 10:58:46 +08:00
|
|
|
<template>
|
|
|
|
|
<view class="app">
|
|
|
|
|
<view class="cards">
|
|
|
|
|
<view class="item" :style="{background:listcolor[index]}" @tap='goProductList(item)'
|
|
|
|
|
v-for="(item,index) in goodsCategoryList" :key="index">
|
2022-12-01 16:59:32 +08:00
|
|
|
<image :src="item.goodsCategoryPicture" mode=""></image>
|
|
|
|
|
<view class="title" style="font-size:42rpx">
|
2022-11-25 10:58:46 +08:00
|
|
|
{{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', '#00C176', '#D43953', '#E1AE3C',
|
|
|
|
|
'#4C7BC9', '#9e4dd0',
|
|
|
|
|
], //颜色随动
|
|
|
|
|
};
|
|
|
|
|
},
|
2022-12-28 12:08:50 +08:00
|
|
|
//1.分享给朋友
|
|
|
|
|
onShareAppMessage(res) {
|
2023-01-03 09:02:23 +08:00
|
|
|
let pages = getCurrentPages();
|
|
|
|
|
let url = pages[pages.length - 1].$page.fullPath
|
2022-12-28 12:08:50 +08:00
|
|
|
return {
|
|
|
|
|
title: '泉医到家',
|
2023-01-03 09:02:23 +08:00
|
|
|
path: url,
|
2022-12-28 12:08:50 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
//2.分享到朋友圈
|
|
|
|
|
onShareTimeline(res) {
|
2023-01-03 09:02:23 +08:00
|
|
|
let pages = getCurrentPages();
|
|
|
|
|
let url = pages[pages.length - 1].$page.fullPath
|
2022-12-28 12:08:50 +08:00
|
|
|
return {
|
|
|
|
|
title: '泉医到家',
|
2023-01-03 09:02:23 +08:00
|
|
|
path: url,
|
2022-12-28 12:08:50 +08:00
|
|
|
}
|
|
|
|
|
},
|
2022-12-28 08:50:08 +08:00
|
|
|
//初始化加载
|
|
|
|
|
onLoad(options) {},
|
2022-12-27 09:22:42 +08:00
|
|
|
onShow() {
|
2022-11-25 10:58:46 +08:00
|
|
|
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 => {
|
2022-12-27 09:22:42 +08:00
|
|
|
uni.removeStorageSync('Refresh');
|
2022-12-28 08:50:08 +08:00
|
|
|
if (res.code == 200) {
|
|
|
|
|
res.rows.forEach(e => {
|
|
|
|
|
e.goodsCategoryPicture = baseurl + e.goodsCategoryPicture
|
|
|
|
|
})
|
|
|
|
|
this.goodsCategoryList = res.rows
|
|
|
|
|
this.total = res.total
|
|
|
|
|
}
|
2022-11-25 10:58:46 +08:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onReachBottom() { //下滑加载
|
|
|
|
|
if (this.goodsCategoryList.length >= this.total) {} else {
|
|
|
|
|
this.pageNum++;
|
2022-12-27 09:22:42 +08:00
|
|
|
goodsCategoryList(this.pageSize, this.pageNum).then(res => {
|
|
|
|
|
res.rows.forEach(e => {
|
|
|
|
|
e.goodsCategoryPicture = baseurl + e.goodsCategoryPicture
|
|
|
|
|
this.goodsCategoryList.push(e)
|
|
|
|
|
})
|
|
|
|
|
this.total = res.total
|
|
|
|
|
})
|
2022-11-25 10:58:46 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
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">
|
2022-12-01 16:59:32 +08:00
|
|
|
.app {
|
|
|
|
|
.cards {
|
|
|
|
|
padding: 22px 0 20px 0;
|
|
|
|
|
}
|
2022-11-25 10:58:46 +08:00
|
|
|
}
|
|
|
|
|
</style>
|