import { PAGE_CHECKOUT_CART } from '@/utils/pageRoute'
import { CART_CHECKOUT_IDS_KEY } from '@/constants/checkout'

/** 购物车同店去结算 → 多商品确认页 */
export function goCartCheckout(cartItemIds) {
  const ids = (cartItemIds || []).filter(Boolean)
  if (!ids.length) return
  try {
    uni.setStorageSync(CART_CHECKOUT_IDS_KEY, ids)
  } catch (e) {
    // ignore
  }
  uni.navigateTo({
    url: `${PAGE_CHECKOUT_CART}?cartItemIds=${ids.join(',')}`
  })
}
