Merge branch 'main'

This commit is contained in:
zhangjing1
2026-03-20 15:52:37 +08:00
2 changed files with 47 additions and 26 deletions

View File

@@ -6,15 +6,11 @@ import React, { useEffect, useRef } from 'react'
import Taro, { useRouter } from '@tarojs/taro'
import { View } from '@tarojs/components'
import { useImmer } from 'use-immer'
import api from '@/api'
import { platformTemplateName, entryLaunch } from '@/utils'
import { SpPage, SpSearchOne, SpTabbar } from '@/components'
import CompsAddPurchase from './comps/comps-category-addCart'
import { SpPage, SpTabbar } from '@/components'
import CategoryFlatLayout from './components/category-flat-layout'
import './index.scss'
const initialState = {
layout: 0, // 0: 默认, 1: 带购物车布局, 2: 带分类布局
containerHeight: '' // 由 SpPage onReady 回填,用于容器高度
}
@@ -23,30 +19,14 @@ function StoreItemList(props) {
const pageRef = useRef(null)
const $router = useRouter()
useEffect(() => {
getCategoryLayout()
pageRef.current.pageLock()
}, [])
const getCategoryLayout = async () => {
const { idListStr, ruleId } = $router?.params
const { idListStr, ruleId } = $router?.params || {}
if (idListStr) {
const shopList = idListStr.split(',')
Taro.setStorageSync('task_shop_list', shopList)
Taro.setStorageSync('task_shop_rule_id', ruleId)
}
const { list } = await api.category.getCategory({
template_name: platformTemplateName,
version: 'v1.0.1',
page_name: 'category'
})
const { addCar, classify } = list?.[0]?.params || {}
console.log('==list==', list)
console.log('==addCar==', addCar)
console.log('==classify==', classify)
setState((draft) => {
draft.layout = addCar && !classify ? 2 : 1
})
}
pageRef.current.pageLock()
}, [])
const handlePageReady = (info) => {
if (info?.height) {
@@ -74,8 +54,7 @@ function StoreItemList(props) {
className='page-category__container'
style={{ height: state.containerHeight || '100%' }}
>
{state.layout === 1 && <CompsAddPurchase />}
{state.layout === 2 && <CategoryFlatLayout />}
<CategoryFlatLayout />
</View>
</SpPage>
)

View File

@@ -15898,5 +15898,47 @@
"en": "",
"zh-tw": "",
"ar": ""
},
"twov0dh": {
"zh-cn": "退款金额由系统计算,商家后台可调整",
"en": "",
"zh-tw": "",
"ar": ""
},
"xbsmy75": {
"zh-cn": "优惠券赠品",
"en": "",
"zh-tw": "",
"ar": ""
},
"cq1sp3": {
"zh-cn": "券赠品",
"en": "",
"zh-tw": "",
"ar": ""
},
"pug2tx5": {
"zh-cn": "满足门槛:",
"en": "",
"zh-tw": "",
"ar": ""
},
"34dpi25": {
"zh-cn": "赠送数量:",
"en": "",
"zh-tw": "",
"ar": ""
},
"n6k3c96": {
"zh-cn": "券模板ID",
"en": "",
"zh-tw": "",
"ar": ""
},
"bq5dbc5": {
"zh-cn": "活动库存:",
"en": "",
"zh-tw": "",
"ar": ""
}
}