Commit 6adfc6d6 authored by 石建新(贵阳日报)'s avatar 石建新(贵阳日报)
parents cc79079d 66413769
...@@ -23,6 +23,16 @@ export function addOrder(data) { ...@@ -23,6 +23,16 @@ export function addOrder(data) {
data, data,
}); });
} }
// 获取购物车列表
export function getshoppingCartList(data) {
return request({
url: `/sgyrdd/sgyBasket/list`,
method: 'GET',
data,
});
}
// 套餐详情 // 套餐详情
export function getCollect(data) { export function getCollect(data) {
return request({ return request({
......
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
<view class="sort-text">客服</view> <view class="sort-text">客服</view>
</view> --> </view> -->
<view class="borderClass" @tap="toCart"> <view class="borderClass" @tap="toCart">
<wd-badge modelValue="4"> <wd-badge :modelValue="subscript">
<img <img
src="/static/assistingAgriculture/detail/car.png" src="/static/assistingAgriculture/detail/car.png"
style="width: 40rpx; height: 40rpx" style="width: 40rpx; height: 40rpx"
...@@ -104,6 +104,7 @@ import { ...@@ -104,6 +104,7 @@ import {
getProdDetail, getProdDetail,
getEvalNumber, getEvalNumber,
addOrder, addOrder,
getshoppingCartList,
getCollect, getCollect,
getCouponShopList, getCouponShopList,
receiveCoupon, receiveCoupon,
...@@ -131,10 +132,12 @@ const storeList = ref([ ...@@ -131,10 +132,12 @@ const storeList = ref([
let prodId; let prodId;
const dataDetails = ref({}); const dataDetails = ref({});
const commentData = ref({}); const commentData = ref({});
const subscript = ref(0);
onLoad((options) => { onLoad((options) => {
prodId = '43834'; prodId = '43834';
getProdDetailFn(); getProdDetailFn();
getEvalNumberFn(); getEvalNumberFn();
getshoppingCartListFn();
}); });
function handleClick(e) { function handleClick(e) {
console.log(e); console.log(e);
...@@ -170,14 +173,27 @@ const getEvalNumberFn = () => { ...@@ -170,14 +173,27 @@ const getEvalNumberFn = () => {
// 加入购物车 // 加入购物车
const addOrderFn = () => { const addOrderFn = () => {
const orderParams = { const orderParams = {
shopId: dataDetails.value.prod.prodId, shopId: dataDetails.value.prod.shopId,
prodId: dataDetails.value.prodParameters.prodId, prodId: dataDetails.value.skus[0].prodId,
skuId: dataDetails.value.skus[0].skuId, skuId: dataDetails.value.skus[0].skuId,
shopType: 3, shopType: '3',
basketCount: 1, basketCount: 1,
}; };
addOrder(orderParams).then((res) => { 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 @@ ...@@ -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