This commit is contained in:
moyayu
2026-05-16 22:01:40 +08:00
parent 359441ecba
commit ee5aacd83c
2 changed files with 43 additions and 31 deletions

View File

@@ -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)

View File

@@ -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 (
<View className='shop-cart-item' key={`shop-cart-item__${all_index}`}>
<View className='shop-cart-item-hd'>
<Text className='iconfont icon-shop' />
{all_item.shop_name || $t('f9ef9536.491c0c')}
</View>
<View className='shop-cart-item-shadow'>
<View className='shop-cart-item-hd'>
{all_item.shop_name || $t('f9ef9536.491c0c')}
@@ -451,30 +447,41 @@ function CartIndex() {
{/** 结算/全选操作开始 */}
<View className='shop-cart-item-ft'>
<View className='lf'>
<SpCheckboxNew
checked={allChecked}
label={$t('f9ef9536.66eeac')}
onChange={onChangeGoodsIsCheck.bind(this, all_item, 'all')}
/>
<View>
<View className='lf'>
<SpCheckboxNew
checked={allChecked}
label={$t('f9ef9536.66eeac')}
onChange={onChangeGoodsIsCheck.bind(this, all_item, 'all')}
/>
</View>
</View>
</View>
<View className='shop-cart-item-ft'>
<View className='rg'>
<View className='rg-lt'>
<View className='total-price-wrap'>
{$t('f9ef9536.7b2864')}
<SpPrice className='total-pirce' value={all_item.total_fee / 100} />
</View>
{all_item.discount_fee > 0 && (
<View className='discount-price-wrap'>
{$t('f9ef9536.1784cf')}
<SpPrice
className='total-pirce'
value={all_item.discount_fee / 100}
/>
<View>
<View className='rg'>
<View className='rg-lt'>
<View className='total-price-wrap'>
{$t('f9ef9536.7b2864')}
<SpPrice className='total-pirce' value={all_item.total_fee / 100} />
</View>
)}
{all_item.discount_fee > 0 && (
<View className='discount-price-wrap'>
{$t('f9ef9536.1784cf')}
<SpPrice
className='total-pirce'
value={all_item.discount_fee / 100}
/>
</View>
)}
</View>
<AtButton
className='btn-calc'
type='primary'
circle
disabled={all_item.cart_total_num <= 0}
onClick={() => handleCheckout(all_item)}
>
{ti('f9ef9536.605bad', [all_item.cart_total_num])}
</AtButton>
</View>
</View>
</View>