添加:立即进货 - 购物车添加完成
This commit is contained in:
parent
7c4c64edaa
commit
21b1340734
|
|
@ -16,7 +16,20 @@ export function supplierApplyInfo(data) {
|
||||||
export function supplierGoodsList(data) {
|
export function supplierGoodsList(data) {
|
||||||
return request.get(`supplier/goods_list`, data);
|
return request.get(`supplier/goods_list`, data);
|
||||||
}
|
}
|
||||||
|
// 进货购物车 - 获取购物车列表
|
||||||
|
export function withGoodsCartList() {
|
||||||
|
return request.get(`supplier/cart_list`);
|
||||||
|
}
|
||||||
|
// 进货购物车 - 获取购物车所有商品id
|
||||||
|
export function withGoodsCartIds() {
|
||||||
|
return request.get(`supplier/cart_ids`);
|
||||||
|
}
|
||||||
|
// 进货购物车 - 添加商品
|
||||||
|
export function withGoodsCartAdd(data) {
|
||||||
|
return request.post(`supplier/cart_add`, data);
|
||||||
|
}
|
||||||
|
// 进货购物车 - 删除商品
|
||||||
|
export function withGoodsCartDel(data) {
|
||||||
|
return request.post(`supplier/cart_del`, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
type='number'
|
type='number'
|
||||||
@click="buyFlowAddBuyNum('click', item)"
|
@click="buyFlowAddBuyNum('click', item)"
|
||||||
:disabled="Object.values(item.attrValue).length > 1"
|
:disabled="Object.values(item.attrValue).length > 1"
|
||||||
@input="buyFlowInputBuyNum($event, item.attrValue[0])"
|
@input="buyFlowInputBuyNum($event, item.attrValue[0], item)"
|
||||||
/>
|
/>
|
||||||
<text class="iconfont icon-shangpinshuliang-jia" @click="buyFlowAddBuyNum('add', item)" ></text>
|
<text class="iconfont icon-shangpinshuliang-jia" @click="buyFlowAddBuyNum('add', item)" ></text>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -65,12 +65,13 @@
|
||||||
合计:<text class="total-price">¥{{ totalPrice }}</text>
|
合计:<text class="total-price">¥{{ totalPrice }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="settlement-btn">立即结算</view>
|
<view class="settlement-btn" @click="settlementCart" v-if="Object.values(buyList).length > 0">立即结算</view>
|
||||||
|
<view class="settlement-btn not-btn" v-else>立即结算</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 授权登录 -->
|
<!-- 授权登录 -->
|
||||||
<authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authClose"></authorize>
|
<authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authClose"></authorize>
|
||||||
<!--多规格商品选择弹框-->
|
<!-- 多规格商品选择弹框 -->
|
||||||
<uni-popup ref="moreSpecsSelect" type="bottom" :is-mask-click="false">
|
<uni-popup ref="moreSpecsSelect" type="bottom" :is-mask-click="false">
|
||||||
<view class="more-spec-content">
|
<view class="more-spec-content">
|
||||||
<!--顶部商品信息-->
|
<!--顶部商品信息-->
|
||||||
|
|
@ -113,34 +114,29 @@
|
||||||
<view class="num-change">
|
<view class="num-change">
|
||||||
<text class="iconfont icon-shangpinshuliang-jian" @click="buyFlowChangeNum('reduce', currentGoods.selected)"></text>
|
<text class="iconfont icon-shangpinshuliang-jian" @click="buyFlowChangeNum('reduce', currentGoods.selected)"></text>
|
||||||
<input
|
<input
|
||||||
:value="buyList[currentGoods.selected.product_id] ? (buyList[currentGoods.selected.product_id].specs ? (buyList[currentGoods.selected.product_id].specs[currentGoods.selected.unique].cart_num || 0) : 0) : 0"
|
:value="specInputValue"
|
||||||
class="num-input"
|
class="num-input"
|
||||||
type='number'
|
type='number'
|
||||||
@input="buyFlowInputBuyNum($event, currentGoods.selected)"
|
@input="buyFlowInputBuyNum($event, currentGoods.selected, currentGoods)"
|
||||||
/>
|
/>
|
||||||
<text class="iconfont icon-shangpinshuliang-jia" @click="buyFlowChangeNum('add', currentGoods.selected)"></text>
|
<text class="iconfont icon-shangpinshuliang-jia" @click="buyFlowChangeNum('add', currentGoods.selected)"></text>
|
||||||
</view>
|
</view>
|
||||||
<!--单位-->
|
<!--单位-->
|
||||||
<view v-if="(batch_list[currentGoods.product_id] || 0) == 1" class="unit">
|
<view v-if="(batch_list[currentGoods.product_id] || 0) == 1" class="unit">
|
||||||
{{ currentGoods.batch_unit }} 共{{ (buyList[currentGoods.selected.product_id] ? (buyList[currentGoods.selected.product_id].specs ? (buyList[currentGoods.selected.product_id].specs[currentGoods.selected.unique].cart_num || 0) : 0) : 0) * (buyList[currentGoods.product_id].batch_num || 1) }}{{ currentGoods.unit_name }}
|
{{ currentGoods.batch_unit }} 共{{ (specInputValue) * (buyList[currentGoods.product_id].batch_num || 1) }}{{ currentGoods.unit_name }}
|
||||||
</view>
|
</view>
|
||||||
<view v-else class="unit">{{ currentGoods.unit_name }}</view>
|
<view v-else class="unit">{{ currentGoods.unit_name }}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</uni-popup>
|
</uni-popup>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {mapGetters} from "vuex";
|
import {mapGetters} from "vuex";
|
||||||
import authorize from '@/components/Authorize';
|
import authorize from '@/components/Authorize';
|
||||||
import {supplierGoodsList} from "@/api/supplier";
|
import {supplierGoodsList, withGoodsCartAdd} from "@/api/supplier";
|
||||||
|
import {withGoodsCartDel, withGoodsCartIds, withGoodsCartList, withGoodsChangeNum} from "../../../api/supplier";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'business',
|
name: 'business',
|
||||||
|
|
@ -148,6 +144,16 @@ export default {
|
||||||
authorize,
|
authorize,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
specInputValue(){
|
||||||
|
let selected = this.currentGoods.selected || {};
|
||||||
|
let productId = selected.product_id || 0;
|
||||||
|
let unique = selected.unique || '';
|
||||||
|
let good = this.buyList[productId] || {};
|
||||||
|
let specs = good.specs || {};
|
||||||
|
let spec = specs[unique] || {};
|
||||||
|
|
||||||
|
return spec.cart_num || 0;
|
||||||
|
},
|
||||||
...mapGetters(['isLogin', 'uid', 'userInfo', 'viewColor','shopToken', 'shopIsLogin', 'shopMerId'])
|
...mapGetters(['isLogin', 'uid', 'userInfo', 'viewColor','shopToken', 'shopIsLogin', 'shopMerId'])
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
|
@ -166,7 +172,7 @@ export default {
|
||||||
totalPrice: 0.00,
|
totalPrice: 0.00,
|
||||||
buyList: {},
|
buyList: {},
|
||||||
batch_list: {},
|
batch_list: {},
|
||||||
currentGoods: {},
|
currentGoods: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
|
|
@ -182,35 +188,30 @@ export default {
|
||||||
'currentGoods.selected_spec': {
|
'currentGoods.selected_spec': {
|
||||||
handler() {
|
handler() {
|
||||||
let good = Object.assign({}, this.currentGoods)
|
let good = Object.assign({}, this.currentGoods)
|
||||||
let defaultName = Object.values(good.selected_spec).join(',');
|
if(good.selected_spec){
|
||||||
// 赋值
|
let defaultName = Object.values(good.selected_spec).join(',');
|
||||||
this.currentGoods.selected = good.attrValue[defaultName] || {};
|
// 赋值
|
||||||
|
this.$set(this.currentGoods, 'selected', good.attrValue[defaultName] || {});
|
||||||
|
}else{
|
||||||
|
this.$set(this.currentGoods, 'selected', {});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
deep: true
|
deep: true
|
||||||
},
|
},
|
||||||
// 计算总数
|
// 购买信息列表变更
|
||||||
'buyList': {
|
'buyList': {
|
||||||
handler() {
|
handler() {
|
||||||
let totalNum = 0;
|
this.BuyFlowComputeTotal();
|
||||||
let totalPrice = 0.00;
|
|
||||||
Object.values(this.buyList).forEach(item => {
|
|
||||||
totalNum += item.total_num;
|
|
||||||
Object.values(item.specs).forEach(value => {
|
|
||||||
let price = value.price * value.cart_num;
|
|
||||||
let currentBatchType = this.batch_list[value.product_id] || 0;
|
|
||||||
// 判断:如果是批量购买 当前价格需要乘以每批的数量
|
|
||||||
if(currentBatchType == 1) price = price * item.batch_num;
|
|
||||||
|
|
||||||
totalPrice += price;
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
// 赋值
|
|
||||||
this.totalNum = totalNum;
|
|
||||||
this.totalPrice = totalPrice;
|
|
||||||
},
|
},
|
||||||
deep: true
|
deep: true
|
||||||
},
|
},
|
||||||
|
// 购买类型列表信息变更
|
||||||
|
'batch_list':{
|
||||||
|
handler() {
|
||||||
|
this.BuyFlowComputeTotal();
|
||||||
|
},
|
||||||
|
deep: true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 授权回调
|
// 授权回调
|
||||||
|
|
@ -249,6 +250,8 @@ export default {
|
||||||
}
|
}
|
||||||
// 商户已经登录 进行后续操作
|
// 商户已经登录 进行后续操作
|
||||||
this.getGoodsList();
|
this.getGoodsList();
|
||||||
|
// 获取购物车列表
|
||||||
|
this.cartGetList();
|
||||||
},
|
},
|
||||||
// 供应商商品列表
|
// 供应商商品列表
|
||||||
getGoodsList(page = 0) {
|
getGoodsList(page = 0) {
|
||||||
|
|
@ -268,9 +271,10 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 输入购买数量
|
// 输入购买数量
|
||||||
buyFlowInputBuyNum(event, spec){
|
buyFlowInputBuyNum(event, spec, currentGoods){
|
||||||
// 指定数量
|
// 指定数量
|
||||||
spec.input_num = Number(event.detail.value || event.target.value);
|
spec.input_num = Number(event.detail.value || event.target.value);
|
||||||
|
this.currentGoods = currentGoods;
|
||||||
|
|
||||||
this.buyFlowChangeNum('input', spec);
|
this.buyFlowChangeNum('input', spec);
|
||||||
},
|
},
|
||||||
|
|
@ -278,6 +282,7 @@ export default {
|
||||||
buyFlowAddBuyNum(type, item){
|
buyFlowAddBuyNum(type, item){
|
||||||
let isMoreSpecs = Object.values(item.attrValue).length || 0;
|
let isMoreSpecs = Object.values(item.attrValue).length || 0;
|
||||||
let good = Object.assign({}, item);
|
let good = Object.assign({}, item);
|
||||||
|
good.is_batch = this.batch_list[good.product_id] || 0;
|
||||||
if(Number(isMoreSpecs) > 1){
|
if(Number(isMoreSpecs) > 1){
|
||||||
// 多规格 初始化选中项
|
// 多规格 初始化选中项
|
||||||
let selected_spec = {};
|
let selected_spec = {};
|
||||||
|
|
@ -299,7 +304,8 @@ export default {
|
||||||
},
|
},
|
||||||
// 购买流程 - 数量改变(添加 || 减少)
|
// 购买流程 - 数量改变(添加 || 减少)
|
||||||
buyFlowChangeNum(type, spec){
|
buyFlowChangeNum(type, spec){
|
||||||
let currentProduct = this.buyList[spec.product_id] || {};
|
let isBatch = this.batch_list[spec.product_id] || 0;// 0=单个购买,1=批量购买
|
||||||
|
let currentProduct = Object.assign({}, this.buyList[spec.product_id] || {});
|
||||||
if(Object.values(currentProduct).length > 0){
|
if(Object.values(currentProduct).length > 0){
|
||||||
// 商品已经存在
|
// 商品已经存在
|
||||||
let currentSpec = currentProduct.specs[spec.unique] || {};
|
let currentSpec = currentProduct.specs[spec.unique] || {};
|
||||||
|
|
@ -314,18 +320,31 @@ export default {
|
||||||
if(type === 'add') currentSpec.cart_num += 1;
|
if(type === 'add') currentSpec.cart_num += 1;
|
||||||
else if(type === 'reduce') currentSpec.cart_num -= 1;
|
else if(type === 'reduce') currentSpec.cart_num -= 1;
|
||||||
else if(type === 'input') currentSpec.cart_num = spec.input_num || 0;
|
else if(type === 'input') currentSpec.cart_num = spec.input_num || 0;
|
||||||
|
// 判断:是否超出库存
|
||||||
|
let stock = currentSpec.stock || 0;
|
||||||
|
if(isBatch == 1) stock = Math.floor(stock / (this.currentGoods.batch_num || ''));//批量购买时 库存需要除以每批数量
|
||||||
|
if(Number(stock) < Number(currentSpec.cart_num)) currentSpec.cart_num = stock;
|
||||||
// 计算变更数量
|
// 计算变更数量
|
||||||
let currentNum = currentSpec.cart_num || 0;
|
let currentNum = currentSpec.cart_num || 0;
|
||||||
let changeNum = Number(oldNum) - Number(currentNum);
|
let changeNum = Number(oldNum) - Number(currentNum);
|
||||||
// 判断:购买数量是否已经为0 是则删除
|
// 判断:购买数量是否已经为0 是则删除
|
||||||
if(currentSpec.cart_num <= 0) delete currentProduct.specs[spec.unique];
|
if(currentSpec.cart_num <= 0) {
|
||||||
else currentProduct.specs[spec.unique] = currentSpec;
|
this.cartDel(currentSpec);
|
||||||
|
delete currentProduct.specs[spec.unique];
|
||||||
|
} else {
|
||||||
|
currentProduct.specs[spec.unique] = currentSpec;
|
||||||
|
// 增加购物车信息 存在即修改
|
||||||
|
currentSpec.batch_num = this.currentGoods.batch_num || '';
|
||||||
|
currentSpec.is_batch = this.currentGoods.is_batch || 0;
|
||||||
|
this.cartSubmitEdit(currentSpec);
|
||||||
|
}
|
||||||
// 判断:当前商品不存在任何购买规格
|
// 判断:当前商品不存在任何购买规格
|
||||||
if(Object.values(currentProduct.specs).length <= 0){
|
if(Object.values(currentProduct.specs).length <= 0){
|
||||||
this.$set(this.buyList, spec.product_id, {});
|
this.$set(this.buyList, spec.product_id, {});
|
||||||
delete this.buyList[spec.product_id];
|
delete this.buyList[spec.product_id];
|
||||||
}else{
|
}else{
|
||||||
currentProduct.total_num -= changeNum;
|
currentProduct.total_num -= changeNum;
|
||||||
|
|
||||||
this.$set(this.buyList, spec.product_id, currentProduct);
|
this.$set(this.buyList, spec.product_id, currentProduct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -334,6 +353,10 @@ export default {
|
||||||
if(type === 'add') spec.cart_num = 1;
|
if(type === 'add') spec.cart_num = 1;
|
||||||
else if(type === 'reduce') return false;
|
else if(type === 'reduce') return false;
|
||||||
else if(type === 'input') spec.cart_num = spec.input_num || 0;
|
else if(type === 'input') spec.cart_num = spec.input_num || 0;
|
||||||
|
// 判断:是否超出库存
|
||||||
|
let stock = spec.stock || 0;
|
||||||
|
if(isBatch == 1) stock = Math.floor(stock / (this.currentGoods.batch_num || ''));//批量购买时 库存需要除以每批数量
|
||||||
|
if(Number(stock) < Number(spec.cart_num)) spec.cart_num = stock;
|
||||||
// 初始化
|
// 初始化
|
||||||
this.$set(this.buyList, spec.product_id, {
|
this.$set(this.buyList, spec.product_id, {
|
||||||
// 购买单位类型
|
// 购买单位类型
|
||||||
|
|
@ -348,6 +371,11 @@ export default {
|
||||||
[spec.unique]: spec,
|
[spec.unique]: spec,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 增加购物车信息
|
||||||
|
spec.batch_num = this.currentGoods.batch_num || '';
|
||||||
|
spec.is_batch = this.currentGoods.is_batch || 0;
|
||||||
|
this.cartSubmitEdit(spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$forceUpdate();
|
this.$forceUpdate();
|
||||||
|
|
@ -362,41 +390,163 @@ export default {
|
||||||
},
|
},
|
||||||
// 购买流程 - 切换购买单位
|
// 购买流程 - 切换购买单位
|
||||||
changeBatchType(productId){
|
changeBatchType(productId){
|
||||||
|
// 获取切换后购买单位
|
||||||
let currentBatchType = this.batch_list[productId] || 0;
|
let currentBatchType = this.batch_list[productId] || 0;
|
||||||
this.batch_list[productId] = currentBatchType == 0 ? 1 : 0;
|
let negation = currentBatchType == 0 ? 1 : 0;
|
||||||
|
// 切换商品购买数量
|
||||||
|
let currentProduct = Object.assign({}, this.buyList[productId] || {});
|
||||||
|
this.$set(this.batch_list, productId, negation);
|
||||||
|
if(Object.values(currentProduct).length > 0){
|
||||||
|
let specs = currentProduct.specs || {};
|
||||||
|
let totalNum = 0;
|
||||||
|
Object.values(specs).forEach(item => {
|
||||||
|
let stock = item.stock || 0;
|
||||||
|
let cartNum = 0;
|
||||||
|
if(negation == 1){
|
||||||
|
// 批量购买 当前购买数量除以每批的数量
|
||||||
|
cartNum = Math.floor(item.cart_num / currentProduct.batch_num);
|
||||||
|
stock = Math.floor(stock / currentProduct.batch_num);
|
||||||
|
}else{
|
||||||
|
// 单个购买 当前购买数量乘以每批的数量
|
||||||
|
cartNum = Math.floor(item.cart_num * currentProduct.batch_num);
|
||||||
|
}
|
||||||
|
// 判断:是否超出库存
|
||||||
|
cartNum = cartNum <= 0 ? 1 : cartNum;
|
||||||
|
if(stock < cartNum) cartNum = stock;
|
||||||
|
totalNum += cartNum;
|
||||||
|
currentProduct.specs[item.unique].cart_num = cartNum || 1;
|
||||||
|
// 修改购物车信息
|
||||||
|
let spec = currentProduct.specs[item.unique] || {};
|
||||||
|
spec.batch_num = currentProduct.batch_num || '';
|
||||||
|
spec.is_batch = negation || 0;
|
||||||
|
this.cartSubmitEdit(spec);
|
||||||
|
})
|
||||||
|
currentProduct.total_num = totalNum;
|
||||||
|
this.$set(this.buyList, productId, currentProduct);
|
||||||
|
}
|
||||||
|
// 赋值
|
||||||
this.$forceUpdate();
|
this.$forceUpdate();
|
||||||
},
|
},
|
||||||
|
// 购买流程 - 计算总价值和总数量
|
||||||
|
BuyFlowComputeTotal(){
|
||||||
|
let totalNum = 0;
|
||||||
|
let totalPrice = 0.00;
|
||||||
|
Object.values(this.buyList).forEach(item => {
|
||||||
|
totalNum += item.total_num;
|
||||||
|
Object.values(item.specs).forEach(value => {
|
||||||
|
let price = value.price * value.cart_num;
|
||||||
|
let currentBatchType = this.batch_list[value.product_id] || 0;
|
||||||
|
// 判断:如果是批量购买 当前价格需要乘以每批的数量
|
||||||
|
if(currentBatchType == 1) price = price * item.batch_num;
|
||||||
|
|
||||||
|
totalPrice += price;
|
||||||
|
})
|
||||||
|
})
|
||||||
|
// 赋值
|
||||||
|
this.totalNum = totalNum.toFixed(0);
|
||||||
|
this.totalPrice = totalPrice.toFixed(2);
|
||||||
|
},
|
||||||
// 购物车 - 获取已存在列表
|
// 购物车 - 获取已存在列表
|
||||||
cartGetList(){},
|
cartGetList(){
|
||||||
// 购物车 - 购物车总数
|
let _this = this;
|
||||||
cartGetCount(){},
|
// 数据查询
|
||||||
|
withGoodsCartList().then(res => {
|
||||||
|
if(res.status == 200){
|
||||||
|
let data = res.data || {};
|
||||||
|
let buyList = {};
|
||||||
|
let batchList = {};
|
||||||
|
Object.values(data).forEach( item => {
|
||||||
|
// 获取规格信息
|
||||||
|
let spec = item.productAttr || {};
|
||||||
|
spec.cart_num = item.cart_num || 0;
|
||||||
|
// 赋值
|
||||||
|
let good = buyList[item.product_id] || {};
|
||||||
|
if(Object.values(good).length > 0){
|
||||||
|
// 商品已经存在
|
||||||
|
buyList[item.product_id].specs[item.product_attr_unique] = spec;
|
||||||
|
buyList[item.product_id].total_num += item.cart_num;
|
||||||
|
}else{
|
||||||
|
// 商品不存在
|
||||||
|
buyList[item.product_id] = {
|
||||||
|
// 购买单位类型
|
||||||
|
is_batch: item.is_batch,// 是否支持按照批次购买
|
||||||
|
batch_num: item.batch_num,// 一批等于多少件
|
||||||
|
unit_name: item.product.unit_name,// 单件单位
|
||||||
|
batch_unit: item.product.batch_unit,// 一批次的单位
|
||||||
|
// 其他信息
|
||||||
|
product_id: item.product_id,
|
||||||
|
total_num: item.cart_num,
|
||||||
|
store_name: item.product.store_name,
|
||||||
|
specs: {
|
||||||
|
[item.product_attr_unique]: spec,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// 购买类型
|
||||||
|
batchList[item.product_id] = item.is_batch || 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.buyList = Object.assign({}, buyList);
|
||||||
|
this.batch_list = Object.assign({}, batchList);
|
||||||
|
}
|
||||||
|
}).catch(err => {
|
||||||
|
_this.$util.Tips({title: err});
|
||||||
|
});
|
||||||
|
},
|
||||||
// 购物车 - 提交购物车
|
// 购物车 - 提交购物车
|
||||||
cartSubmitEdit(){},
|
cartSubmitEdit(spec){
|
||||||
|
let _this = this;
|
||||||
|
let params = {
|
||||||
|
cart_num: spec.cart_num,
|
||||||
// cart_num: 10
|
product_attr_unique: spec.unique,
|
||||||
// is_new: 0
|
product_id: spec.product_id,
|
||||||
// product_attr_unique: "598aa5ec4390"
|
// 购买单位类型
|
||||||
// product_id: "247"
|
is_batch: spec.is_batch || 0,// 0=单个购买,1=批量购买
|
||||||
// product_type: 0
|
batch_num: spec.batch_num || '',// 一批等于多少件
|
||||||
// spread_id: ""
|
};
|
||||||
//
|
// 数据查询
|
||||||
//
|
withGoodsCartAdd(params).then(res => {
|
||||||
//
|
// console.log(res)
|
||||||
//
|
}).catch(err => {
|
||||||
//
|
_this.cartGetList();
|
||||||
// cart_num: 8
|
this.$util.Tips({title: err});
|
||||||
// is_new: 0
|
});
|
||||||
// product_attr_unique: "53cd849c89f0"
|
},
|
||||||
// product_id: "248"
|
// 购物车 - 删除购物车商品信息
|
||||||
// product_type: 0
|
cartDel(spec){
|
||||||
// spread_id: ""
|
let _this = this;
|
||||||
|
let params = {
|
||||||
|
product_attr_unique: spec.unique,
|
||||||
|
product_id: spec.product_id,
|
||||||
|
};
|
||||||
|
// 数据查询
|
||||||
|
withGoodsCartDel(params).then(res => {
|
||||||
|
// console.log(res)
|
||||||
|
}).catch(err => {
|
||||||
|
_this.cartGetList();
|
||||||
|
this.$util.Tips({title: err});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 立即结算
|
||||||
|
settlementCart(){
|
||||||
|
let _this = this;
|
||||||
|
// 数据查询
|
||||||
|
withGoodsCartIds().then(res => {
|
||||||
|
if(res.status == 200){
|
||||||
|
let data = res.data || {};
|
||||||
|
if(Object.values(data).length <= 0){
|
||||||
|
_this.$util.Tips({title: '请选择商品!'});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 去结算
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/users/order_confirm/index?cartId=' + data.join(',')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).catch(err => {
|
||||||
|
_this.$util.Tips({title: err});
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// 滚动到底部
|
// 滚动到底部
|
||||||
onReachBottom() {
|
onReachBottom() {
|
||||||
|
|
@ -569,7 +719,7 @@ export default {
|
||||||
.num-input{
|
.num-input{
|
||||||
border-left: 2rpx solid var(--border-color-);
|
border-left: 2rpx solid var(--border-color-);
|
||||||
border-right: 2rpx solid var(--border-color-);
|
border-right: 2rpx solid var(--border-color-);
|
||||||
width: 60rpx;
|
width: 100rpx;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -640,6 +790,11 @@ export default {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
border-radius: 100rpx;
|
border-radius: 100rpx;
|
||||||
}
|
}
|
||||||
|
.not-btn{
|
||||||
|
background-color: #909399!important;
|
||||||
|
border-color: #909399!important;
|
||||||
|
color: #fff!important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 多规格选择弹框
|
// 多规格选择弹框
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue