diff --git a/src/components/sp-sku-select/index.js b/src/components/sp-sku-select/index.js index 9692eb2b4..1675ea5d7 100644 --- a/src/components/sp-sku-select/index.js +++ b/src/components/sp-sku-select/index.js @@ -61,7 +61,6 @@ const initialState = { const $instance = Taro.getCurrentInstance() function SpSkuSelect(props) { - useTranslation() const { info, open = false, @@ -109,13 +108,18 @@ function SpSkuSelect(props) { // }, [open]) const init = () => { - const { skuList, specItems } = info + const { skuList, specItems, curItem } = info console.log('skuList:', skuList) console.log('specItems:', specItems) + skuDictRef.current = {} specItems.forEach((item) => { const key = item.specItem.map((spec) => spec.specId).join('_') skuDictRef.current[key] = item }) + // 优先使用上一次已选择的规格,避免重新打开后回退到默认规格 + const matchedSelectedSpecItem = curItem?.itemId + ? specItems.find((item) => `${item.itemId}` === `${curItem.itemId}`) + : null // 默认选中有库存并且前端可销售的sku let defaultSpecItem = specItems.find( (item) => item.store > 0 && ['onsale'].includes(item.approveStatus) @@ -126,8 +130,9 @@ function SpSkuSelect(props) { } let selection = Array(skuList.length).fill(null) - if (defaultSpecItem) { - selection = defaultSpecItem.specItem.map((item) => item.specId) + const targetSpecItem = matchedSelectedSpecItem || defaultSpecItem + if (targetSpecItem) { + selection = targetSpecItem.specItem.map((item) => item.specId) } calcDisabled(selection) diff --git a/src/pages/cart/espier-index.js b/src/pages/cart/espier-index.js index d23d1de9e..55253d412 100644 --- a/src/pages/cart/espier-index.js +++ b/src/pages/cart/espier-index.js @@ -25,7 +25,7 @@ import { SpCheckboxNew, SpPrivacyModal } from '@/components' -import { useTranslation, $t } from '@/i18n' +import { useTranslation, $t, ti } from '@/i18n' import CompGoodsItem from './comps/comp-goodsitem' @@ -338,10 +338,6 @@ function CartIndex() { const allChecked = all_item.cart_total_count == all_item.list.length return ( - - - {all_item.shop_name || $t('f9ef9536.491c0c')} - {all_item.shop_name || $t('f9ef9536.491c0c')} @@ -451,30 +447,41 @@ function CartIndex() { {/** 结算/全选操作开始 */} - - + + + + - - - - - - {$t('f9ef9536.7b2864')} - - - {all_item.discount_fee > 0 && ( - - {$t('f9ef9536.1784cf')} - + + + + + {$t('f9ef9536.7b2864')} + - )} + {all_item.discount_fee > 0 && ( + + {$t('f9ef9536.1784cf')} + + + )} + + handleCheckout(all_item)} + > + {ti('f9ef9536.605bad', [all_item.cart_total_num])} +