|
|
|
@ -6,6 +6,7 @@ import navv from "@/components/nav/nav.vue"; |
|
|
|
import topTitle from "@/components/topTitle/topTitle.vue"; |
|
|
|
import { |
|
|
|
addCartApi, |
|
|
|
deleteFromCartApi, |
|
|
|
editDefaultAddressApi, |
|
|
|
getCartInfoApi, |
|
|
|
getMyAreaApi, |
|
|
|
@ -103,9 +104,19 @@ const startY = ref(0); |
|
|
|
*/ |
|
|
|
function onGoSelectAddress() { } |
|
|
|
/** |
|
|
|
* 点击管理购物车 |
|
|
|
* 点击去逛逛 |
|
|
|
*/ |
|
|
|
function onManageCart() { } |
|
|
|
function onGotoAlls() { |
|
|
|
uni.switchTab({ |
|
|
|
url: "/pages/allDish/allDish", |
|
|
|
}); |
|
|
|
} |
|
|
|
/** |
|
|
|
* 点击管理购物车 编辑和完成 |
|
|
|
*/ |
|
|
|
function onManageCart() { |
|
|
|
finished.value = !finished.value; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 计算滑动角度 |
|
|
|
* @param {object} start 起点坐标 |
|
|
|
@ -244,18 +255,69 @@ function flyY(bottomY, ballY, duration = 400) { |
|
|
|
*/ |
|
|
|
function onMinus(e, item) { |
|
|
|
// 判空为 0, 否则转换为数字 |
|
|
|
item.sum = Number(item.sum) || 0; |
|
|
|
item.quantity = Number(item.quantity) || 0; |
|
|
|
// 达到起订量(item.minNum)直接清空, 否则每次-1 |
|
|
|
const minNum = item.minNum || 1; |
|
|
|
const diff = -(item.sum === minNum ? minNum : 1); |
|
|
|
item.sum += diff; |
|
|
|
const diff = -(item.quantity === minNum ? minNum : 1); |
|
|
|
item.quantity += diff; |
|
|
|
|
|
|
|
toCart(item, diff); |
|
|
|
} |
|
|
|
function onDelete() {} |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
*/ |
|
|
|
function onDelete(index) { |
|
|
|
uni.showModal({ |
|
|
|
title: "警告", |
|
|
|
content: "确定删除当前商品?", |
|
|
|
confirmColor: "#3cc51f", |
|
|
|
async success(res) { |
|
|
|
if (res.cancel) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const res2 = await deleteFromCartApi({ |
|
|
|
ids: cartLists.value[index].id, |
|
|
|
}); |
|
|
|
if (res2.code !== "0") { |
|
|
|
return; |
|
|
|
} |
|
|
|
cartLists.value.splice(index, 1); |
|
|
|
initCartInfo(); |
|
|
|
}, |
|
|
|
}); |
|
|
|
} |
|
|
|
function onSelectAllGoods() {} |
|
|
|
function onGotoOrder() {} |
|
|
|
function onDeleteCart() {} |
|
|
|
|
|
|
|
/** |
|
|
|
* 删除所选 |
|
|
|
*/ |
|
|
|
function onDeleteCart() { |
|
|
|
uni.showModal({ |
|
|
|
title: "警告", |
|
|
|
content: "确定删除选中商品?", |
|
|
|
confirmColor: "#3cc51f", |
|
|
|
async success(res) { |
|
|
|
if (res.cancel) { |
|
|
|
return; |
|
|
|
} |
|
|
|
const res2 = await deleteFromCartApi({ |
|
|
|
ids: checkedItems.value.join(","), |
|
|
|
}); |
|
|
|
if (res2.code !== "0") { |
|
|
|
return; |
|
|
|
} |
|
|
|
cartLists.value = cartLists.value.filter(item => !checkedItems.value.includes(item.id)); |
|
|
|
initCartInfo(); |
|
|
|
}, |
|
|
|
}); |
|
|
|
// uni.showToast({ |
|
|
|
// title: "删除所选商品", |
|
|
|
// icon: "none", |
|
|
|
// }); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 更新购物车 |
|
|
|
@ -593,7 +655,7 @@ onLoad(() => { |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="delete" @click="onDelete"> |
|
|
|
<view class="delete" @click="() => onDelete(index)"> |
|
|
|
删除 |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
@ -650,6 +712,16 @@ onLoad(() => { |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view v-if="cartLists.length == 0" class="empty-box"> |
|
|
|
<image class="icon" src="@/static/shoppingCart/pic.png" mode="widthFix" /> |
|
|
|
<text class="tips"> |
|
|
|
这里空空如也,快去添加吧~ |
|
|
|
</text> |
|
|
|
<view class="btn" @click="onGotoAlls"> |
|
|
|
去逛逛 |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 购物车小球 --> |
|
|
|
<view |
|
|
|
v-if="showBall" |
|
|
|
|