Commit 6adfc6d6 authored by 石建新(贵阳日报)'s avatar 石建新(贵阳日报)
parents cc79079d 66413769
......@@ -23,6 +23,16 @@ export function addOrder(data) {
data,
});
}
// 获取购物车列表
export function getshoppingCartList(data) {
return request({
url: `/sgyrdd/sgyBasket/list`,
method: 'GET',
data,
});
}
// 套餐详情
export function getCollect(data) {
return request({
......
......@@ -69,7 +69,7 @@
<view class="sort-text">客服</view>
</view> -->
<view class="borderClass" @tap="toCart">
<wd-badge modelValue="4">
<wd-badge :modelValue="subscript">
<img
src="/static/assistingAgriculture/detail/car.png"
style="width: 40rpx; height: 40rpx"
......@@ -104,6 +104,7 @@ import {
getProdDetail,
getEvalNumber,
addOrder,
getshoppingCartList,
getCollect,
getCouponShopList,
receiveCoupon,
......@@ -131,10 +132,12 @@ const storeList = ref([
let prodId;
const dataDetails = ref({});
const commentData = ref({});
const subscript = ref(0);
onLoad((options) => {
prodId = '43834';
getProdDetailFn();
getEvalNumberFn();
getshoppingCartListFn();
});
function handleClick(e) {
console.log(e);
......@@ -170,14 +173,27 @@ const getEvalNumberFn = () => {
// 加入购物车
const addOrderFn = () => {
const orderParams = {
shopId: dataDetails.value.prod.prodId,
prodId: dataDetails.value.prodParameters.prodId,
shopId: dataDetails.value.prod.shopId,
prodId: dataDetails.value.skus[0].prodId,
skuId: dataDetails.value.skus[0].skuId,
shopType: 3,
shopType: '3',
basketCount: 1,
};
addOrder(orderParams).then((res) => {
console.log('加入购物车', res);
xma.showToast({
title: res.msg,
duration: 1500,
icon: 'none',
});
});
};
// 获取购物车列表
const getshoppingCartListFn = () => {
getshoppingCartList({}).then((res) => {
res.data.forEach((item) => {
// item.img = imgUrl + item.img;
});
subscript.value = res.data.length;
});
};
// 进入页面回到顶部
......
......@@ -24,7 +24,7 @@
<view style="display: flex; flex-direction: row">
<view
class="borderClass"
@tap="chooseTab(item.categoryId)"
@tap="chooseTab(index, item.categoryId)"
v-for="(item, index) in sortList"
:key="index"
>
......@@ -37,7 +37,7 @@
<view>
<scroll-view class="tabs" show-scrollbar="false" scroll-x :scroll-with-animation="true">
<text
@tap="choice(index, item.categoryId)"
@tap="chooseBTab(index, item.categoryId)"
v-for="(item, index) in tabsData"
:key="index"
class="text"
......@@ -138,62 +138,7 @@ const light = ref(0);
const sortList = ref([]);
const tabsData = 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 params = {
current: 1,
......@@ -203,9 +148,8 @@ const params = {
const tabsList = ref([]);
onMounted(async () => {
getPresale();
getPresaleProd();
// getPresaleProd();
presaleSortList();
chooseTab('3287');
});
// 预售板块轮播图
const getPresale = () => {
......@@ -230,28 +174,38 @@ const presaleSortList = () => {
sortList.value = res.data.map((item) => {
return item.imgUrl;
});
console.log(res.data, 111);
sortList.value = res.data;
chooseTab(0, sortList.value[0].categoryId);
});
};
const chooseTab = (index) => {
getStrictSelection({ parentId: index }).then((res) => {
const chooseTab = (index, categoryId) => {
getStrictSelection({ parentId: categoryId }).then((res) => {
res.data.forEach((item, index) => {
item.imgUrl = import.meta.env.VITE_APP_IMG_URL + item.pic;
});
tabsData.value = res.data;
chooseBTab(0, tabsData.value[0].categoryId);
});
};
// 筑农首页-分类查询商品列表
const getPresaleProd = () => {
getPresaleProdList(params).then((res) => {
const chooseBTab = (index, categoryId) => {
getPresaleProdList({ current: 1, size: 10, categoryId }).then((res) => {
res.data.records.forEach((item) => {
item.img = import.meta.env.VITE_APP_IMG_URL + item.pic;
});
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) => {
getPresaleProdList({ current: 1, size: 10, categoryId }).then((res) => {
......@@ -259,26 +213,9 @@ const choice = (index, categoryId) => {
item.img = import.meta.env.VITE_APP_IMG_URL + item.pic;
});
buyList.value = res.data.records;
if (index === 0) {
chooseTab('3287');
choice(0, '3273');
}
});
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) {
......
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