diff --git a/CoreCms.Net.Uni-App/CoreShop/core/api/cart.ts b/CoreCms.Net.Uni-App/CoreShop/core/api/cart.ts index a1473f61..95ecf138 100644 --- a/CoreCms.Net.Uni-App/CoreShop/core/api/cart.ts +++ b/CoreCms.Net.Uni-App/CoreShop/core/api/cart.ts @@ -51,4 +51,8 @@ export const queryRemoveCart = (data : any) : Promise> => { return post('Api/Cart/DoDelete', { data, }, true); +} + +export const setCartProductNum = (productId : number, nums : number) => { + return post('api/Cart/SetCartNum', { data: { id: productId, nums } }) } \ No newline at end of file diff --git a/CoreCms.Net.Uni-App/CoreShop/pages/cart/cart.vue b/CoreCms.Net.Uni-App/CoreShop/pages/cart/cart.vue index 34d4b5b2..cfc3aa10 100644 --- a/CoreCms.Net.Uni-App/CoreShop/pages/cart/cart.vue +++ b/CoreCms.Net.Uni-App/CoreShop/pages/cart/cart.vue @@ -1,5 +1,5 @@ @@ -109,7 +109,7 @@ import { reactive, nextTick, computed, ref } from 'vue'; import { onShow, onPullDownRefresh } from '@dcloudio/uni-app'; import { handleStaticResources, hanldeShowModal, handleRouteSwitchTab, handleRouteNavigateTo, handleShowToast } from '@/core/utils'; - import { queryCartList, deleteGoodsSingle, deleteGoodsSome } from '@/core/api'; + import { queryCartList, deleteGoodsSingle, deleteGoodsSome, setCartProductNum } from '@/core/api'; import type { Response, CartListType, ShopConfigStoreType } from '@/core/models'; import { useShopConfigStore } from '@/core/store'; import { @@ -244,11 +244,10 @@ } /** 商品加减 */ - const handleChangeGoodsNum = (e : any, item : any) => { + const handleChangeGoodsNum = async (e : any, item : CartListType) => { + await setCartProductNum(item.productId, e.value); item.nums = e.value; - nextTick(() => { - handleCalculatePrice(); - }) + handleCalculatePrice(); } /** 单个删除 */