|
@@ -16,6 +16,7 @@ import {
|
|
|
deleteProductItemBuy,
|
|
|
getProductItemBuy,
|
|
|
productPlacing,
|
|
|
+ updateProductItemNums,
|
|
|
} from '../../../../core/libs/requests'
|
|
|
import PageHelper from '@/components/page-helper.vue'
|
|
|
import BottomAppBar from '@/components/bottom-app-bar.vue'
|
|
@@ -77,24 +78,32 @@ const handleDelete = async (product: any) => {
|
|
|
await pageHelperRef.value?.refresh()
|
|
|
}
|
|
|
const handleProductNumsChange = async (nums, product) => {
|
|
|
+ console.log(nums, product.nums)
|
|
|
const changeNums = nums - product.nums
|
|
|
- if (changeNums > 0) {
|
|
|
- await createProductItemBuy({
|
|
|
- doList: [
|
|
|
- {
|
|
|
- userId: userInfo.value.userId,
|
|
|
- productId: product.productId,
|
|
|
- points: product.points,
|
|
|
- nums: Math.abs(changeNums),
|
|
|
- },
|
|
|
- ],
|
|
|
- })
|
|
|
+ if (changeNums !== 0) {
|
|
|
+ await updateProductItemNums({
|
|
|
+ userId: userInfo.value.userId,
|
|
|
+ productId: product.productId,
|
|
|
+ changingNum: changeNums,
|
|
|
+ })
|
|
|
+ // await createProductItemBuy({
|
|
|
+ // doList: [
|
|
|
+ // {
|
|
|
+ // userId: userInfo.value.userId,
|
|
|
+ // productId: product.productId,
|
|
|
+ // points: product.points,
|
|
|
+ // nums: Math.abs(changeNums),
|
|
|
+ // },
|
|
|
+ // ],
|
|
|
+ // })
|
|
|
if (selected.value.map((it) => it.productId).includes(product.productId)) {
|
|
|
selected.value = selected.value.map((it) =>
|
|
|
it.productId === product.productId ? {...it, nums} : it,
|
|
|
)
|
|
|
}
|
|
|
- } if (nums == 0) {
|
|
|
+ }
|
|
|
+
|
|
|
+ if (nums == 0) {
|
|
|
await deleteProductItemBuy({
|
|
|
doList: [
|
|
|
{
|