Commit 20e8a156 authored by 张娇(东信)'s avatar 张娇(东信)

预售商品

parent 07fcc92b
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<view style="display: flex; flex-direction: row"> <view style="display: flex; flex-direction: row">
<view <view
class="borderClass" class="borderClass"
@tap="chooseTab(item.categoryId)" @tap="chooseTab(index, item.categoryId)"
v-for="(item, index) in sortList" v-for="(item, index) in sortList"
:key="index" :key="index"
> >
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<view> <view>
<scroll-view class="tabs" show-scrollbar="false" scroll-x :scroll-with-animation="true"> <scroll-view class="tabs" show-scrollbar="false" scroll-x :scroll-with-animation="true">
<text <text
@tap="choice(index, item.categoryId)" @tap="chooseBTab(index, item.categoryId)"
v-for="(item, index) in tabsData" v-for="(item, index) in tabsData"
:key="index" :key="index"
class="text" class="text"
...@@ -138,62 +138,7 @@ const light = ref(0); ...@@ -138,62 +138,7 @@ const light = ref(0);
const sortList = ref([]); const sortList = ref([]);
const tabsData = ref([]); const tabsData = ref([]);
const buyList = ref([]); const buyList = ref([]);
const sortDataList = ref([]);
const shopList = ref([
{ img: '/static/assistingAgriculture/presale/img7.png', price: '29.9', text: '应季好物' },
{ img: '/static/assistingAgriculture/presale/img7.png', price: '29.9', text: '应季好物' },
{ img: '/static/assistingAgriculture/presale/img7.png', price: '29.9', text: '应季好物' },
{ img: '/static/assistingAgriculture/presale/img7.png', price: '29.9', text: '应季好物' },
{ img: '/static/assistingAgriculture/presale/img7.png', price: '29.9', text: '应季好物' },
{ img: '/static/assistingAgriculture/presale/img7.png', price: '29.9', text: '应季好物' },
]);
// 声明需要的数据
const data = reactive({
leftList: [], // 左边列图片
rightList: [], // 右边列图片
leftHeight: 0, // 左边列高度
rightHeight: 0, // 右边列高度
columnWidth: 0, // 列宽度
});
// 总商品数据列表 // 总商品数据列表
const goodList = ref([
{
id: 1,
name: '这是一个商品',
image: '/static/assistingAgriculture/presale/buy.png',
introduction: '商品简介商品简介',
price: 69.9,
},
{
id: 2,
name: '商品二',
image: '/static/assistingAgriculture/presale/img7.png',
introduction: '商品简介商品简介',
price: 69.9,
},
{
id: 3,
name: '商品三',
image: '/static/assistingAgriculture/assets/fruit.png',
introduction: '商品简介商品简介',
price: 69.9,
},
{
id: 4,
name: '商品四',
image: '/static/assistingAgriculture/presale/buy.png',
introduction: '商品简介商品简介',
price: 69.9,
},
{
id: 5,
name: '商品五',
image: '/static/assistingAgriculture/presale/buy.png',
introduction: '商品简介商品简介',
price: 69.9,
},
]);
const router = useRoute(); const router = useRoute();
const params = { const params = {
current: 1, current: 1,
...@@ -203,9 +148,8 @@ const params = { ...@@ -203,9 +148,8 @@ const params = {
const tabsList = ref([]); const tabsList = ref([]);
onMounted(async () => { onMounted(async () => {
getPresale(); getPresale();
getPresaleProd(); // getPresaleProd();
presaleSortList(); presaleSortList();
chooseTab('3287');
}); });
// 预售板块轮播图 // 预售板块轮播图
const getPresale = () => { const getPresale = () => {
...@@ -230,28 +174,38 @@ const presaleSortList = () => { ...@@ -230,28 +174,38 @@ const presaleSortList = () => {
sortList.value = res.data.map((item) => { sortList.value = res.data.map((item) => {
return item.imgUrl; return item.imgUrl;
}); });
console.log(res.data, 111);
sortList.value = res.data; sortList.value = res.data;
chooseTab(0, sortList.value[0].categoryId);
}); });
}; };
const chooseTab = (index) => { const chooseTab = (index, categoryId) => {
getStrictSelection({ parentId: index }).then((res) => { getStrictSelection({ parentId: categoryId }).then((res) => {
res.data.forEach((item, index) => { res.data.forEach((item, index) => {
item.imgUrl = import.meta.env.VITE_APP_IMG_URL + item.pic; item.imgUrl = import.meta.env.VITE_APP_IMG_URL + item.pic;
}); });
tabsData.value = res.data; tabsData.value = res.data;
chooseBTab(0, tabsData.value[0].categoryId);
}); });
}; };
const chooseBTab = (index, categoryId) => {
// 筑农首页-分类查询商品列表 getPresaleProdList({ current: 1, size: 10, categoryId }).then((res) => {
const getPresaleProd = () => {
getPresaleProdList(params).then((res) => {
res.data.records.forEach((item) => { res.data.records.forEach((item) => {
item.img = import.meta.env.VITE_APP_IMG_URL + item.pic; item.img = import.meta.env.VITE_APP_IMG_URL + item.pic;
}); });
buyList.value = res.data.records; buyList.value = res.data.records;
}); });
light.value = index;
}; };
// 筑农首页-分类查询商品列表
// const getPresaleProd = () => {
// getPresaleProdList(params).then((res) => {
// res.data.records.forEach((item) => {
// item.img = import.meta.env.VITE_APP_IMG_URL + item.pic;
// });
// buyList.value = res.data.records;
// });
// };
// 二级分类点击事件 // 二级分类点击事件
const choice = (index, categoryId) => { const choice = (index, categoryId) => {
getPresaleProdList({ current: 1, size: 10, categoryId }).then((res) => { getPresaleProdList({ current: 1, size: 10, categoryId }).then((res) => {
...@@ -259,26 +213,9 @@ const choice = (index, categoryId) => { ...@@ -259,26 +213,9 @@ const choice = (index, categoryId) => {
item.img = import.meta.env.VITE_APP_IMG_URL + item.pic; item.img = import.meta.env.VITE_APP_IMG_URL + item.pic;
}); });
buyList.value = res.data.records; buyList.value = res.data.records;
if (index === 0) {
chooseTab('3287');
choice(0, '3273');
}
}); });
light.value = index; light.value = index;
}; };
// 左侧数据列表
const LeftList = ref([]);
// 右侧数据列表
const RightList = ref([]);
// 将商品信息列表分为左侧右侧两个部分
for (let i = 0; i < goodList.value.length; i++) {
if (i % 2 === 0) {
LeftList.value.push(goodList.value[i]);
} else {
RightList.value.push(goodList.value[i]);
}
}
// 点击商品 跳转详情 // 点击商品 跳转详情
function ToDetail(id) { function ToDetail(id) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment