uniapp【修复】: 购物车商品增/减数量没有调用接口更新

This commit is contained in:
21世纪小八路
2024-10-26 16:37:32 +08:00
parent 6574be0ea2
commit 7dc19e8caa
2 changed files with 11 additions and 8 deletions

View File

@@ -52,3 +52,7 @@ export const queryRemoveCart = (data : any) : Promise<Response<any>> => {
data,
}, true);
}
export const setCartProductNum = (productId : number, nums : number) => {
return post('api/Cart/SetCartNum', { data: { id: productId, nums } })
}

View File

@@ -100,8 +100,8 @@
</view>
</view>
</view>
<uv-loading-page :loading="loading" loading-text="加载中..." color="#d33123" loadingColor="#d33123" font-size="24rpx"
bgColor="rgba(255, 255, 255, 0.2)"></uv-loading-page>
<uv-loading-page :loading="loading" loading-text="加载中..." color="#d33123" loadingColor="#d33123"
font-size="24rpx" bgColor="rgba(255, 255, 255, 0.2)"></uv-loading-page>
</view>
</template>
@@ -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();
}
/** 单个删除 */