Browse Source

购物车

dev_des
1054425342@qq.com 1 month ago
parent
commit
09290d8d06
  1. 2
      static/js/request.js
  2. 27
      subPackages/techan/detail.vue
  3. 40
      subPackages/techan/order.vue

2
static/js/request.js

@ -8,7 +8,7 @@ const DEV_API_URL = 'http://1.13.193.49';
// const PROD_API_URL = 'https://epic.js-dyyj.com'; // const PROD_API_URL = 'https://epic.js-dyyj.com';
const PROD_API_URL = 'http://1.13.193.49'; const PROD_API_URL = 'http://1.13.193.49';
const NEWAPIURL = process.env.NODE_ENV === 'development' ? DEV_API_URL : PROD_API_URL; const NEWAPIURL = process.env.NODE_ENV === 'development' ? DEV_API_URL : PROD_API_URL;
const DEV_API_URL_DES = 'http://192.168.124.177:8083/xcx'; const DEV_API_URL_DES = 'http://192.168.124.118:8083/xcx';
// const DEV_API_URL_DES = 'https://des.js-dyyj.com/xcx'; // const DEV_API_URL_DES = 'https://des.js-dyyj.com/xcx';
// const DEV_API_URL_DES = 'http://1.13.193.49:8083/xcx'; // const DEV_API_URL_DES = 'http://1.13.193.49:8083/xcx';
// const PROD_API_URL_DES = 'https://des.js-dyyj.com/xcx'; // const PROD_API_URL_DES = 'https://des.js-dyyj.com/xcx';

27
subPackages/techan/detail.vue

@ -61,15 +61,14 @@
<template v-if="!popShow"> <template v-if="!popShow">
<view class="btn-list" v-if="!paramData.showCart"> <view class="btn-list" v-if="!paramData.showCart">
<view class="left-box"> <view class="left-box" @click="gotoPath('/subPackages/user/gwc')">
<!-- <view class="img-box" slot="content"> <view class="img-box" slot="content">
<uni-badge class="uni-badge-left-margin" :text="paramData.num" absolute="rightTop" :offset="[5, 5]" size="small" <uni-badge class="uni-badge-left-margin" :text="paramData.num" absolute="rightTop" :offset="[5, 5]" size="small"
:custom-style="{background:'#D90F01',color:'#ffffff',border:'1px solid #ffffff'}"> :custom-style="{background:'#D90F01',color:'#ffffff',border:'1px solid #ffffff'}">
<image @click.stop="showCartClick" :src="showImg('/uploads/20250513/29fd015f8c779f08e53d1016d3643c58.png')" mode="aspectFill" <uni-icons type="cart" size="30"></uni-icons>
style="width: 60rpx;height: 50rpx;"></image>
</uni-badge> </uni-badge>
<text class="text">购物车</text> <text class="text">购物车</text>
</view> --> </view>
</view> </view>
<view class="btn-post"> <view class="btn-post">
<view class="left-btn-buy" @click="openPop(true)">加入购物车</view> <view class="left-btn-buy" @click="openPop(true)">加入购物车</view>
@ -102,7 +101,7 @@
</view> </view>
</template> </template>
<cartDataVue ref="cartDataVueRef" :paramData="paramData" @changeParamData="changeParamData" :key="new Date().getTime()"></cartDataVue> <!-- <cartDataVue ref="cartDataVueRef" :paramData="paramData" @changeParamData="changeParamData" :key="new Date().getTime()"></cartDataVue> -->
<uni-popup ref="popup" type="bottom" @change="changPopShow" <uni-popup ref="popup" type="bottom" @change="changPopShow"
:safe-area="false" style="position: relative;z-index: 50;"> :safe-area="false" style="position: relative;z-index: 50;">
@ -186,18 +185,19 @@
}; };
}, },
onShow() { onShow() {
// this.getShoppingList()
this.Post({
is_post: 1,
}, '/api/shopping/getShoppingList').then(res => {
console.log(res)
})
}, },
onLoad(option) { onLoad(option) {
this.id = option.id; this.id = option.id;
this.getInfo(); this.getInfo();
}, },
methods: { methods: {
getShoppingList() {
this.Post({}, "/framework/cart/list", "DES")
.then((res) => {
this.paramData.num = res.data.length
})
},
changPopShow (e) { changPopShow (e) {
this.popShow = e.show this.popShow = e.show
}, },
@ -318,10 +318,13 @@
if (!currentGoods) { if (!currentGoods) {
selectedData.push(goods.goodsId) selectedData.push(goods.goodsId)
} }
setTimeout(() =>{
uni.showToast({ uni.showToast({
title:'加购成功', title:'加购成功',
icon:'none' icon:'none'
}) })
},400)
this.getShoppingList()
uni.setStorageSync('cartDataInfo', JSON.stringify(selectedData)); uni.setStorageSync('cartDataInfo', JSON.stringify(selectedData));
uni.$emit("updateDataByConnect", {msgType:'updateCartDataInfo',data:null}) uni.$emit("updateDataByConnect", {msgType:'updateCartDataInfo',data:null})
this.closePopup() this.closePopup()

40
subPackages/techan/order.vue

@ -64,7 +64,10 @@
</view> </view>
</view> </view>
<!-- 按供应商分组显示商品 --> <!-- 按供应商分组显示商品 -->
<view v-for="(supplierGroup, supplierIndex) in groupedGoods" :key="supplierGroup.supplierId"> <view
v-for="(supplierGroup, supplierIndex) in groupedGoods"
:key="supplierGroup.supplierId"
>
<!-- 供应商卡片 --> <!-- 供应商卡片 -->
<view class="supplier-card"> <view class="supplier-card">
<!-- 供应商名称 --> <!-- 供应商名称 -->
@ -74,7 +77,11 @@
<!-- 该供应商的商品列表 --> <!-- 该供应商的商品列表 -->
<view class="supplier-goods"> <view class="supplier-goods">
<view class="commodity-item" v-for="(sku, index) in supplierGroup.goods" :key="index"> <view
class="commodity-item"
v-for="(sku, index) in supplierGroup.goods"
:key="index"
>
<view class="commodity box"> <view class="commodity box">
<image <image
class="img" class="img"
@ -96,7 +103,11 @@
</view> </view>
</view> </view>
</view> </view>
<view class="commodity box sb" style="padding-left: 10rpx" v-if="false"> <view
class="commodity box sb"
style="padding-left: 10rpx"
v-if="false"
>
<view class="title" style="font-weight: bold"> 购买数量 </view> <view class="title" style="font-weight: bold"> 购买数量 </view>
<view class="num-box"> <view class="num-box">
<view <view
@ -439,25 +450,25 @@ export default {
// supplierId // supplierId
const supplierMap = new Map(); const supplierMap = new Map();
this.info.forEach(item => { this.info.forEach((item) => {
const supplierId = item.supplierId || 'default'; const supplierId = item.supplierId || "default";
const supplierName = item.supplierName || '默认供应商'; const supplierName = item.supplierName || "默认供应商";
if (!supplierMap.has(supplierId)) { if (!supplierMap.has(supplierId)) {
supplierMap.set(supplierId, { supplierMap.set(supplierId, {
supplierId, supplierId,
supplierName, supplierName,
goods: [] goods: [],
}); });
// //
this.$set(this.supplierRemarks, supplierId, ''); this.$set(this.supplierRemarks, supplierId, "");
} }
supplierMap.get(supplierId).goods.push(item); supplierMap.get(supplierId).goods.push(item);
}); });
this.groupedGoods = Array.from(supplierMap.values()); this.groupedGoods = Array.from(supplierMap.values());
console.log('分组后的商品:', this.groupedGoods); console.log("分组后的商品:", this.groupedGoods);
}, },
// //
@ -632,7 +643,8 @@ export default {
} else if (sku.quantity == 1) { } else if (sku.quantity == 1) {
this.$nextTick(() => { this.$nextTick(() => {
// info // info
const skuIndex = this.info.findIndex(item => const skuIndex = this.info.findIndex(
(item) =>
item.goodsName === sku.goodsName && item.goodsName === sku.goodsName &&
item.specValueOne === sku.specValueOne && item.specValueOne === sku.specValueOne &&
item.specValueTwo === sku.specValueTwo item.specValueTwo === sku.specValueTwo
@ -916,12 +928,13 @@ export default {
// createDtos // createDtos
let createDtos = []; let createDtos = [];
this.groupedGoods.forEach(supplierGroup => { this.groupedGoods.forEach((supplierGroup) => {
const supplierRemark = this.supplierRemarks[supplierGroup.supplierId] || ''; const supplierRemark =
this.supplierRemarks[supplierGroup.supplierId] || "";
createDtos.push({ createDtos.push({
supplierId: supplierGroup.supplierId, supplierId: supplierGroup.supplierId,
remark: supplierRemark, remark: supplierRemark,
shoppingCartBoList: supplierGroup.goods shoppingCartBoList: supplierGroup.goods,
}); });
}); });
@ -931,6 +944,7 @@ export default {
expectedAmount: this.allprice, expectedAmount: this.allprice,
usePoints: this.usePoints ? 0 : 1, // 使 usePoints: this.usePoints ? 0 : 1, // 使
pointsQuantity: parseInt(this.usePoints) || 0, // 使 pointsQuantity: parseInt(this.usePoints) || 0, // 使
shippingFee: 0,
}; };
this.Post( this.Post(

Loading…
Cancel
Save