diff --git a/src/doc/category.js b/src/doc/category.js index eab2fb5e8..142badda0 100644 --- a/src/doc/category.js +++ b/src/doc/category.js @@ -11,7 +11,8 @@ export const CATEGORY_LIST = { hot: 'hot', id: 'id', category_id: 'category_id', - main_category_id: 'main_category_id' + main_category_id: 'main_category_id', + is_main_category: 'is_main_category' } export const CATEGORY_STORE_LIST = { diff --git a/src/pages/category/components/category-flat-layout.jsx b/src/pages/category/components/category-flat-layout.jsx index ad78961a9..1304d0531 100644 --- a/src/pages/category/components/category-flat-layout.jsx +++ b/src/pages/category/components/category-flat-layout.jsx @@ -96,9 +96,17 @@ function CategoryFlatLayout() { console.log('query', item) } + const buildListUrl = (item) => { + const cateName = encodeURIComponent(item.category_name || '') + if (item.is_main_category === true) { + return `/subpages/item/list?main_cat_id=${item.category_id}&cate_name=${cateName}&hide_search=1` + } + return `/subpages/item/list?cat_id=${item.category_id}&cate_name=${cateName}&hide_search=1` + } + const handleSubCategoryClick = (item, pindex, index, category_name) => { Taro.navigateTo({ - url: `/subpages/item/list?cat_id=${item.category_id}&cate_name=${item.category_name}&hide_search=1` + url: buildListUrl(item) }) } @@ -142,7 +150,7 @@ function CategoryFlatLayout() { className='flex justify-between pt-48 pb-24 pl-32 pr-32' onClick={() => { Taro.navigateTo({ - url: `/subpages/item/list?cat_id=${category.category_id}&cate_name=${category.category_name}&hide_search=1` + url: buildListUrl(category) }) }} > diff --git a/src/pages/category/comps/comp-series.js b/src/pages/category/comps/comp-series.js index 77298f0b9..0f36a914a 100644 --- a/src/pages/category/comps/comp-series.js +++ b/src/pages/category/comps/comp-series.js @@ -21,15 +21,14 @@ const CompSeries = (props) => { }, [info]) const handleClickItem = (item) => { - const { category_id, main_category_id } = item + const { category_id, main_category_id, is_main_category } = item console.log('item', item) let url = '' - if (category_id) { + if (is_main_category === true || main_category_id) { + url = `/subpages/item/list?main_cat_id=${main_category_id || category_id}&all=true` + } else if (category_id) { url = `/subpages/item/list?cat_id=${category_id}&all=true` } - if (main_category_id) { - url = `/subpages/item/list?main_cat_id=${main_category_id}&all=true` - } if (url) { Taro.navigateTo({ url diff --git a/src/pages/category/comps/comps-category-addCart.js b/src/pages/category/comps/comps-category-addCart.js index 489099417..bc5f7672c 100644 --- a/src/pages/category/comps/comps-category-addCart.js +++ b/src/pages/category/comps/comps-category-addCart.js @@ -39,7 +39,7 @@ const initialState = { goodsSort: 0, seriesList: [], cat_id: undefined, - cat_type: undefined, + is_main_category: false, show: false, secondList: [], thirdList: [], @@ -65,7 +65,7 @@ function CompsCategoryAddCart(props) { categorySecondIndex, categoryThirdIndex, cat_id, - cat_type, + is_main_category, secondList, thirdList, info, @@ -196,21 +196,21 @@ function CompsCategoryAddCart(props) { name: 'category_name', img: 'image_url', id: 'category_id', - type: !VERSION_PLATFORM, category_id: 'category_id', + is_main_category: 'is_main_category', children: ({ children }) => pickBy(children, { name: 'category_name', img: 'image_url', id: 'category_id', - type: !VERSION_PLATFORM, category_id: 'category_id', + is_main_category: 'is_main_category', children: ({ children: children_ }) => pickBy(children_, { name: 'category_name', img: 'image_url', - type: !VERSION_PLATFORM, - id: 'category_id' + id: 'category_id', + is_main_category: 'is_main_category' }) }) }) @@ -219,7 +219,7 @@ function CompsCategoryAddCart(props) { draft.seriesList = currentList draft.hasSeries = true draft.cat_id = currentList[0]?.id - draft.cat_type = currentList[0]?.type + draft.is_main_category = currentList[0]?.is_main_category === true }) } @@ -237,10 +237,10 @@ function CompsCategoryAddCart(props) { // category_id: cat_id, v_store: cusIndex } - if (cat_type) { - params.category_id = cat_id + if (is_main_category === true) { + params.main_category = cat_id } else { - params.category = cat_id + params.category_id = cat_id } const { list: _list, total_count } = await api.item.search(params) @@ -278,7 +278,7 @@ function CompsCategoryAddCart(props) { draft.categoryThirdIndex = 0 draft.allList = [] draft.cat_id = seriesList[index]?.id - draft.cat_type = seriesList[index]?.type + draft.is_main_category = seriesList[index]?.is_main_category === true }) }, 200) @@ -289,7 +289,10 @@ function CompsCategoryAddCart(props) { draft.categoryThirdIndex = 0 draft.allList = [] draft.cat_id = index == 0 ? seriesList[categoryFirstIndex]?.id : secondList[index]?.id - draft.cat_type = index == 0 ? seriesList[categoryFirstIndex]?.type : secondList[index]?.type + draft.is_main_category = + index == 0 + ? seriesList[categoryFirstIndex]?.is_main_category === true + : secondList[index]?.is_main_category === true }) }, 200) @@ -299,7 +302,10 @@ function CompsCategoryAddCart(props) { draft.categoryThirdIndex = index draft.allList = [] draft.cat_id = index == 0 ? secondList[categorySecondIndex]?.id : thirdList[index]?.id - draft.cat_type = index == 0 ? secondList[categorySecondIndex]?.type : thirdList[index]?.type + draft.is_main_category = + index == 0 + ? secondList[categorySecondIndex]?.is_main_category === true + : thirdList[index]?.is_main_category === true }) }, 200) diff --git a/src/pages/category/comps/comps-category-tile.js b/src/pages/category/comps/comps-category-tile.js index 65d45fbf1..dd2befa78 100644 --- a/src/pages/category/comps/comps-category-tile.js +++ b/src/pages/category/comps/comps-category-tile.js @@ -61,6 +61,7 @@ const CompsCategoryTile = (props) => { id: 'id', category_id: 'category_id', main_category_id: 'main_category_id', + is_main_category: 'is_main_category', children: ({ children }) => pickBy(children, { name: 'category_name', @@ -68,12 +69,14 @@ const CompsCategoryTile = (props) => { id: 'id', category_id: 'category_id', main_category_id: 'main_category_id', + is_main_category: 'is_main_category', children: ({ children }) => pickBy(children, { name: 'category_name', img: 'image_url', category_id: 'category_id', - main_category_id: 'main_category_id' + main_category_id: 'main_category_id', + is_main_category: 'is_main_category' }) }) }) diff --git a/src/pages/home/wgts/classify.jsx b/src/pages/home/wgts/classify.jsx index 3d55a2bf1..946b27683 100644 --- a/src/pages/home/wgts/classify.jsx +++ b/src/pages/home/wgts/classify.jsx @@ -32,7 +32,7 @@ function WgtClassify(props) { } else { //销售分类 Taro.navigateTo({ - url: `/subpages/item/list?category_id=${category_id}&store_ids=${store_ids}&hide_search=1` + url: `/subpages/item/list?cat_id=${category_id}&store_ids=${store_ids}&hide_search=1` }) } } diff --git a/src/pages/home/wgts/classify/index.jsx b/src/pages/home/wgts/classify/index.jsx index bce66b28a..7e3a871d8 100644 --- a/src/pages/home/wgts/classify/index.jsx +++ b/src/pages/home/wgts/classify/index.jsx @@ -42,7 +42,7 @@ function WgtClassify(props) { } else { //销售分类 Taro.navigateTo({ - url: `/subpages/item/list?category_id=${category_id}&store_ids=${store_ids}&hide_search=1` + url: `/subpages/item/list?cat_id=${category_id}&store_ids=${store_ids}&hide_search=1` }) } } diff --git a/src/subpages/item/list.js b/src/subpages/item/list.js index f28d7a72e..0b7a7afd7 100644 --- a/src/subpages/item/list.js +++ b/src/subpages/item/list.js @@ -128,12 +128,22 @@ function ItemList() { useEffect(() => { // card_id, user_card_id: 兑换券参数 - entryLaunch.getRouteParams($instance?.router?.params).then((params) => { - const { cat_id, keywords, main_cat_id, tag_id, card_id, user_card_id, all = false } = params + // 分类挂件跳转传 category_id,兼容历史 cat_id + entryLaunch.getRouteParams({ params: $instance?.router?.params }).then((params) => { + const { + cat_id, + category_id, + keywords, + main_cat_id, + tag_id, + card_id, + user_card_id, + all = false + } = params setState((draft) => { draft.routerParams = { - cat_id, + cat_id: cat_id || category_id, keywords, main_cat_id, tag_id, diff --git a/src/subpages/purchase/list.js b/src/subpages/purchase/list.js index cd0a72150..0c2d7a29f 100644 --- a/src/subpages/purchase/list.js +++ b/src/subpages/purchase/list.js @@ -110,12 +110,13 @@ function ItemList() { useEffect(() => { // card_id, user_card_id: 兑换券参数 - entryLaunch.getRouteParams($instance?.router?.params).then((params) => { - const { cat_id, main_cat_id, tag_id, card_id, user_card_id } = params + // 分类挂件跳转传 category_id,兼容历史 cat_id + entryLaunch.getRouteParams({ params: $instance?.router?.params || router?.params }).then((params) => { + const { cat_id, category_id, main_cat_id, tag_id, card_id, user_card_id } = params setState((draft) => { draft.routerParams = { - cat_id, + cat_id: cat_id || category_id, main_cat_id, tag_id, card_id, @@ -232,7 +233,7 @@ function ItemList() { } if (main_cat_id) { - params['main_category'] = main_cat_id + params['main_cat_id'] = main_cat_id } if (VERSION_STANDARD) { diff --git a/src/subpages/store/categorys.js b/src/subpages/store/categorys.js index 2ee2c3dbf..9f0274402 100644 --- a/src/subpages/store/categorys.js +++ b/src/subpages/store/categorys.js @@ -28,7 +28,7 @@ const initialState = { goodsSort: 0, seriesList: [], cat_id: undefined, - show: false, + is_main_category: false, secondList: [], thirdList: [] } @@ -49,6 +49,7 @@ function StoreItemList(props) { categorySecondIndex, categoryThirdIndex, cat_id, + is_main_category, secondList, thirdList } = state @@ -81,17 +82,20 @@ function StoreItemList(props) { img: 'image_url', id: 'category_id', category_id: 'category_id', + is_main_category: 'is_main_category', children: ({ children }) => pickBy(children, { name: 'category_name', img: 'image_url', id: 'category_id', category_id: 'category_id', + is_main_category: 'is_main_category', children: ({ children: children_ }) => pickBy(children_, { name: 'category_name', img: 'image_url', - id: 'category_id' + id: 'category_id', + is_main_category: 'is_main_category' }) }) }) @@ -99,6 +103,7 @@ function StoreItemList(props) { draft.seriesList = currentList draft.hasSeries = true draft.cat_id = currentList[0].id + draft.is_main_category = currentList[0]?.is_main_category === true }) } @@ -114,9 +119,13 @@ function StoreItemList(props) { distributor_id: dtid, // distributor_id: dis_id || Taro.getStorageSync('distributor_id'), goodsSort, - category_id: cat_id, v_store: cusIndex } + if (is_main_category === true) { + params.main_category = cat_id + } else { + params.category_id = cat_id + } const { list: _list, total_count } = await api.item.search(params) @@ -153,6 +162,7 @@ function StoreItemList(props) { draft.categoryThirdIndex = 0 draft.allList = [] draft.cat_id = seriesList[index]?.id + draft.is_main_category = seriesList[index]?.is_main_category === true }) }, 200) @@ -163,6 +173,10 @@ function StoreItemList(props) { draft.categoryThirdIndex = 0 draft.allList = [] draft.cat_id = index == 0 ? seriesList[categoryFirstIndex]?.id : secondList[index]?.id + draft.is_main_category = + index == 0 + ? seriesList[categoryFirstIndex]?.is_main_category === true + : secondList[index]?.is_main_category === true }) }, 200) @@ -172,6 +186,10 @@ function StoreItemList(props) { draft.categoryThirdIndex = index draft.allList = [] draft.cat_id = index == 0 ? secondList[categorySecondIndex]?.id : thirdList[index]?.id + draft.is_main_category = + index == 0 + ? secondList[categorySecondIndex]?.is_main_category === true + : thirdList[index]?.is_main_category === true }) }, 200) diff --git a/src/subpages/store/index.js b/src/subpages/store/index.js index 0f28eb606..ba42f5b1e 100644 --- a/src/subpages/store/index.js +++ b/src/subpages/store/index.js @@ -20,7 +20,8 @@ import { SpRecommend, SpSkuSelect, SpLogin, - SpPoweredBy + SpPoweredBy, + SpImage } from '@/components' import api from '@/api' import doc from '@/doc' @@ -63,7 +64,9 @@ const initState = { open: false, hideClose: true, /** 页面滚动超过 20px 时搜索条白底 */ - searchSolidBg: false + searchSolidBg: false, + /** 自定义导航高度,沉浸式时用于顶起搜索/头图内容 */ + navbarHeight: 0 } function StoreIndex() { @@ -87,7 +90,8 @@ function StoreIndex() { skuPanelOpen, selectType, open, - searchSolidBg + searchSolidBg, + navbarHeight } = state const dispatch = useDispatch() @@ -347,7 +351,19 @@ function StoreIndex() { scrollToTopBtn ref={pageRef} showpoweredBy={false} - pageConfig={pageData?.base} + immersive + pageConfig={{ + ...(pageData?.base || {}), + // 未滚动时导航透明,让店铺 banner 顶到屏幕顶部 + navigateBackgroundColor: searchSolidBg + ? pageData?.base?.navigateBackgroundColor || '#fff' + : 'transparent' + }} + onReady={({ gNavbarH }) => { + setState((draft) => { + draft.navbarHeight = gNavbarH || 0 + }) + }} renderFloat={ )} - + + {/* widthFix:按原图比例完整展示,高度随图片自适应 */} + {storeInfo?.banner ? ( + + ) : ( + + )} diff --git a/src/subpages/store/index.scss b/src/subpages/store/index.scss index 0d395941d..f6a7ea1fc 100644 --- a/src/subpages/store/index.scss +++ b/src/subpages/store/index.scss @@ -38,6 +38,7 @@ .search { width: 100%; position: fixed; + top: 0; left: 0; right: 0; z-index: 2; @@ -65,14 +66,28 @@ padding: 0 15px; } - .header-block { - padding-top: 150px; - // background: transparent; - // box-shadow: inset 0px -242px 700px 0px rgba(255, 255, 255, 0.4); - } - + .header-block, .header-block-pad { - padding-top: 80px; + position: relative; + + .store-banner { + width: 100%; + display: block; + vertical-align: top; + + &--empty { + width: 100%; + height: 150px; + background: #f5f5f5; + } + } + + // 店铺信息卡叠在 banner 底部,保留原圆角压图效果 + .comp-shop-brand { + position: relative; + z-index: 1; + margin-top: -48px; + } } .icon-huiyuanzhongxin { diff --git a/src/subpages/trade/after-sale-list.js b/src/subpages/trade/after-sale-list.js index 9849b24d6..60cce95f4 100644 --- a/src/subpages/trade/after-sale-list.js +++ b/src/subpages/trade/after-sale-list.js @@ -2,11 +2,10 @@ * Copyright © ShopeX (http://www.shopex.cn). All rights reserved. * See LICENSE file for license details. */ -import React, { useEffect, useRef, useMemo } from 'react' +import React, { useEffect, useRef, useMemo, useCallback } from 'react' import { useSelector } from 'react-redux' -import Taro, { useRouter } from '@tarojs/taro' +import Taro, { useRouter, useDidShow } from '@tarojs/taro' import { View, ScrollView } from '@tarojs/components' -import { AtButton } from 'taro-ui' import { useImmer } from 'use-immer' import { SpPage, SpScrollView, SpSearchBar } from '@/components' import { SpTagBar } from '@/subpages/components' @@ -24,15 +23,22 @@ const initialState = { typeVal: '0', tradeList: [], refresherTriggered: false, - order_id: '', - selectAftersn: [] + order_id: '' } function TradeAfterSaleList(props) { useTranslation() const { setNavigationBarTitle } = useNavigation() const [state, setState] = useImmer(initialState) - const { status, tradeList, refresherTriggered, typeVal, order_id, selectAftersn } = state + const { status, tradeList, refresherTriggered, typeVal, order_id } = state const tradeRef = useRef() + const needRefreshRef = useRef(false) + + const refreshList = useCallback(() => { + setState((draft) => { + draft.tradeList = [] + }) + tradeRef.current?.reset() + }, [setState]) const tradeStatus = useMemo( () => [ @@ -53,19 +59,26 @@ function TradeAfterSaleList(props) { }, [setNavigationBarTitle]) useEffect(() => { - // 撤销售后事件 - Taro.eventCenter.on('onEventAfterSalesCancel', () => { - setState((draft) => { - draft.tradeList = [] - }) - tradeRef.current.reset() - }) + const handleRefresh = () => { + needRefreshRef.current = true + } + // 撤销售后 / 填写物流回寄成功后刷新列表 + Taro.eventCenter.on('onEventAfterSalesCancel', handleRefresh) + Taro.eventCenter.on('onEventAfterSalesSendback', handleRefresh) return () => { - Taro.eventCenter.off('onEventAfterSalesCancel') + Taro.eventCenter.off('onEventAfterSalesCancel', handleRefresh) + Taro.eventCenter.off('onEventAfterSalesSendback', handleRefresh) } }, []) + useDidShow(() => { + if (needRefreshRef.current) { + needRefreshRef.current = false + refreshList() + } + }) + useEffect(() => { setState((draft) => { draft.tradeList = [] @@ -94,7 +107,6 @@ function TradeAfterSaleList(props) { const onChangeTradeState = (e) => { setState((draft) => { draft.status = tradeStatus[e].value - draft.selectAftersn = [] }) } @@ -135,46 +147,8 @@ function TradeAfterSaleList(props) { await tradeRef.current.reset() } - const onSelect = (sn) => { - let list = [...selectAftersn] - const index = list.indexOf(sn) - if (index > -1) { - list.splice(index, 1) - } else { - list.push(sn) - } - setState((draft) => { - draft.selectAftersn = list - }) - } - - const onSubmit = () => { - console.log(tradeList, selectAftersn) - const fliterList = tradeList?.filter( - (item) => selectAftersn.includes(item.aftersalesBn) && item.aftersalesAddress - ) - debugger - const address = fliterList[0].aftersalesAddress - Taro.setStorageSync('moreAftersalesBn', { - aftersalesBn: selectAftersn, - address - }) - Taro.navigateTo({ url: `/subpages/trade/logistics-info?type=more` }) - } - - const renderFooter = () => { - if (status != '1') return null - return ( - - - {$t('b1e93f22.ba7290')} - - - ) - } - return ( - + {tradeList.map((item, index) => ( - + ))} diff --git a/src/subpages/trade/after-sale-list.scss b/src/subpages/trade/after-sale-list.scss index 1c39f3e76..451aed285 100644 --- a/src/subpages/trade/after-sale-list.scss +++ b/src/subpages/trade/after-sale-list.scss @@ -32,4 +32,8 @@ $tag-bar-height: 90px; .comp-tradeitem .shop-info .shop-name { width: 400px; } + .btn-wrap { + width: 80%; + margin: 20px auto; + } } diff --git a/src/subpages/trade/comps/comp-aftertrade-item.js b/src/subpages/trade/comps/comp-aftertrade-item.js index d6005ebc7..a40b21adf 100644 --- a/src/subpages/trade/comps/comp-aftertrade-item.js +++ b/src/subpages/trade/comps/comp-aftertrade-item.js @@ -7,7 +7,7 @@ import { useSelector } from 'react-redux' import Taro from '@tarojs/taro' import { View, Text } from '@tarojs/components' import { AtButton } from 'taro-ui' -import { SpImage, SpPrice, SpTradeItem, SpCheckboxNew, SpPoint } from '@/components' +import { SpImage, SpPrice, SpTradeItem, SpPoint } from '@/components' import { VERSION_STANDARD } from '@/utils' import { useTranslation, $t, ti } from '@/i18n' import { AFTER_SALE_STATUS } from '@/consts' @@ -16,7 +16,7 @@ import './comp-aftertrade-item.scss' function CompTradeItem(props) { useTranslation() const { pointName } = useSelector((state) => state.sys) - const { info, isShowChecked = false, selectAftersn = [], onSelect = () => {} } = props + const { info } = props if (!info) { return null } @@ -67,7 +67,7 @@ function CompTradeItem(props) { - + {distributorInfo?.name} {!VERSION_STANDARD && } diff --git a/src/subpages/trade/comps/comp-aftertrade-item.scss b/src/subpages/trade/comps/comp-aftertrade-item.scss index 876ee90b0..d616c04d2 100644 --- a/src/subpages/trade/comps/comp-aftertrade-item.scss +++ b/src/subpages/trade/comps/comp-aftertrade-item.scss @@ -74,9 +74,15 @@ display: flex; align-items: center; + .aftersale-checkbox { + margin-right: 24px; + flex-shrink: 0; + } + .sp-image { border-radius: 16px; overflow: hidden; + margin-right: 16px; } .nochecked { margin-left: 0px !important; diff --git a/src/subpages/trade/logistics-info.js b/src/subpages/trade/logistics-info.js index 4de54654e..213b5694b 100644 --- a/src/subpages/trade/logistics-info.js +++ b/src/subpages/trade/logistics-info.js @@ -76,9 +76,11 @@ function TradeLogisticsInfo(props) { aftersales_data: aftersInfo?.aftersalesBn }) showToast($t('3d2b7bcd.33130f')) + Taro.eventCenter.trigger('onEventAfterSalesSendback') setTimeout(() => { + // 批量:列表→物流 回 1 层;单笔:详情→物流 回 2 层到列表 Taro.navigateBack({ - delta: 2 + delta: type == 'more' ? 1 : 2 }) }, 1000) } catch (error) { diff --git a/src/utils/entryLaunch.js b/src/utils/entryLaunch.js index af65d97ad..ef4f959fa 100644 --- a/src/utils/entryLaunch.js +++ b/src/utils/entryLaunch.js @@ -58,9 +58,17 @@ class EntryLaunch { const routerParams = $instance?.router?.params || {} const h5Query = Taro.getEnv() === Taro.ENV_TYPE.WEB ? getH5LocationQuery() : {} // H5 useDidShow(options) 往往不含 query,需合并 location / 实时 router + // 兼容直接传入扁平 params:getRouteParams(router.params) + const isFlatParams = + options && + typeof options === 'object' && + !options.params && + !options.query && + !options.path const params = { ...h5Query, ...routerParams, + ...(isFlatParams ? options : {}), ...(options?.params || {}), ...(options?.query && typeof options.query === 'object' && !Array.isArray(options.query) ? options.query