Compare commits

...

15 Commits

Author SHA1 Message Date
81c63e0e65 feat(order): 添加订单自动取消过期功能
- 在OrderList组件中新增autoCancelExpired和paymentTimeoutHours属性
- 实现支付过期订单的自动检测和取消逻辑
- 添加parseTime和isOrderPaymentExpiredSafe辅助函数
- 使用useRef管理自动取消状态避免重复执行
- 支持单次最多处理20笔过期订单避免接口风暴
- 区分resetPage和loadMore场景下的列表状态同步
- 更新useEffect依赖数组包含新的属性参数
2026-03-08 13:08:35 +08:00
86f7506422 fix(order): 解决支付取消后加载状态未正确重置问题
- 在支付流程中添加 skipFinallyResetPayLoading 标志来控制加载状态
- 检测用户取消支付情况并跳转到待付款订单列表页面
- 优化支付取消后的页面导航逻辑,支持 redirectTo 和 navigateTo 两种方式
- 修改订单列表中的按钮文案"取消订单"为"取消"
- 修改订单列表中的按钮文案"立即支付"为"继续支付"
2026-03-08 10:41:00 +08:00
fae144549e style(goods): 商品列表卡片样式优化
- 为商品图片添加固定宽高和圆角样式
- 在政企采购专区卡片上添加点击跳转功能
- 在桂乐淘福利区卡片上添加点击跳转功能
- 为两个专区卡片添加箭头图标指示跳转
- 从 NutUI 图标库导入箭头图标组件
2026-03-07 16:13:52 +08:00
718eddff63 refactor(home): 移除未使用的导航功能
- 删除未使用的 navTo 导入语句
- 注释掉政企采购专区的点击跳转功能
- 注释掉桂乐淘福利惊爆区的点击跳转功能
- 保留卡片展示样式但移除交互逻辑
2026-03-07 15:41:49 +08:00
a4a0a922fc refactor(home): 移除未使用的导航功能
- 删除未使用的 navTo 导入语句
- 注释掉政企采购专区的点击跳转功能
- 注释掉桂乐淘福利惊爆区的点击跳转功能
- 保留卡片展示样式但移除交互逻辑
2026-03-07 15:41:00 +08:00
ca2436a2e8 feat(shop): 商品列表组件重构并优化页面展示
- 新增 GoodsList.scss 样式文件,实现网格布局和商品卡片样式
- 重构 GoodsList.tsx 组件,使用新的样式结构和 ShopGoods 类型
- 移除 Share 图标依赖,简化购买按钮设计
- 注释掉首页的桶装水和水票套餐分类入口
- 更新政企采购专区跳转链接至正确分类ID
- 在商品列表页面添加空状态显示组件
- 修改商品列表请求参数,增加状态过滤条件
2026-03-07 15:39:31 +08:00
83ba49d860 fix(home): 更新首页商品分类配置并优化跳转功能
- 修改开发环境API_BASE_URL配置
- 引入通用导航工具函数navTo
- 更新商品分类标签名称为桶装水和水票套餐
- 添加政企采购专区卡片组件
- 集成桂乐淘福利惊爆区跳转功能
- 修复页面布局结构中的多余空行问题
2026-03-07 15:20:16 +08:00
7375a3b1ce fix(order): 修复订单退款功能并调整开发环境配置
- 将开发环境API地址切换回本地服务
- 移除订单详情页面中的退款接口导入
- 将退款操作改为更新订单状态方式实现
- 注释掉用户页面底部版本号显示
2026-03-07 13:13:44 +08:00
756b548bf9 fix(dealer): 修复提现页面跳转和提示图标问题
- 将提现金额超限提示的图标从 'error' 改为 'none'
- 修复经销商首页可提现金额区域的点击跳转功能
- 移除重复的 onClick 事件绑定,统一在父容器上处理点击事件
2026-03-07 02:08:42 +08:00
76e76c62ef fix(withdraw): 修复经销商提现页面类型定义和渲染逻辑
- 将 activeTab 状态类型从 string | number 限定为 string
- 统一 Tab 切换处理中的值转换逻辑,避免类型不一致问题
- 修复条件判断中的字符串比较,确保类型安全
- 调整组件渲染方式,改为按需渲染当前选中的标签页内容
- 更新骑手页面工资统计标题为配送提成以匹配实际业务逻辑
2026-03-07 02:01:10 +08:00
546d90cc28 feat(app): 更新版权信息和分类标题
- 修改版权信息从公司名称变更为品牌宣传语
- 更新首页分类标签名称为政企采购专区和桂乐淘福利惊爆区
- 调整用户页脚版权显示格式,移除年份和Copyright标识
2026-03-07 01:44:12 +08:00
d4fd61376c fix(dealer): 更新页面标题和文案内容
- 将导航栏标题从"桂乐淘分享中心"改为"账户管理中心"
- 移除提现金额表单项的必填标识
- 修复提现注意事项中的错别字"再"改为"在"
- 统一更新用户组件中的页面标题显示
- 将用户网格组件中的"我的服务"改为"桂乐淘服务中心"
2026-03-07 01:38:27 +08:00
b27421fd6e fix(dealer): 更新佣金状态文案并修复商品价格显示
- 将佣金统计中的"冻结中"改为"待使用"
- 为可提现金额添加点击跳转到提现页面的功能
- 更新商品详情页价格字段从price改为buyingPrice
- 注释掉首页商品卡片中的买水票优惠按钮
- 在商品详情页价格后添加单位显示
2026-03-07 01:13:51 +08:00
b929b8d35e feat(user): 添加地址编辑时的地区锁定功能
- 新增 regionLocked 状态管理地区锁定状态
- 编辑模式下有经纬度时自动锁定地区,防止被识别覆盖
- 地图选点后锁定地区并验证省市区完整性
- 锁定状态下点击地区选择器显示提示信息
- 表单提交前验证必填的省市区字段
- 使用 View 组件替换 div 优化 Taro 兼容性
- 识别成功时根据锁定状态显示不同提示文案
2026-03-06 11:39:47 +08:00
23af704c68 fix(shop): 修复订单确认页面数量输入组件逻辑
- 调整步长设置逻辑,根据最小购买数量动态设置步长值
- 移除票据模板激活时的禁用条件限制
- 简化数量输入框的禁用状态判断逻辑
2026-03-01 12:22:23 +08:00
21 changed files with 424 additions and 125 deletions

View File

@@ -9,6 +9,6 @@ export const BaseUrl = API_BASE_URL;
// 当前版本 // 当前版本
export const Version = 'v3.0.8'; export const Version = 'v3.0.8';
// 版权信息 // 版权信息
export const Copyright = 'WebSoft Inc.'; export const Copyright = '桂乐淘·购享无界 乐惠万家';
// java -jar CertificateDownloader.jar -k 0kF5OlPr482EZwtn9zGufUcqa7ovgxRL -m 1723321338 -f ./apiclient_key.pem -s 2B933F7C35014A1C363642623E4A62364B34C4EB -o ./ // java -jar CertificateDownloader.jar -k 0kF5OlPr482EZwtn9zGufUcqa7ovgxRL -m 1723321338 -f ./apiclient_key.pem -s 2B933F7C35014A1C363642623E4A62364B34C4EB -o ./

View File

@@ -20,7 +20,7 @@
#### 新增功能 #### 新增功能
- 用户头像和基本信息展示 - 用户头像和基本信息展示
- 佣金统计(可提现、冻结中、累计收益) - 佣金统计(可提现、待使用、累计收益)
- 团队统计(一级、二级、三级成员) - 团队统计(一级、二级、三级成员)
- 功能导航网格(分销订单、提现申请、我的团队、推广二维码) - 功能导航网格(分销订单、提现申请、我的团队、推广二维码)

View File

@@ -35,7 +35,7 @@ dealer: {
// 金额相关 // 金额相关
money: { money: {
available: 'linear-gradient(135deg, #10b981 0%, #059669 100%)', // 可提现 - 绿色 available: 'linear-gradient(135deg, #10b981 0%, #059669 100%)', // 可提现 - 绿色
frozen: 'linear-gradient(135deg, #3b82f6 0%, #2563eb 100%)', // 冻结中 - 蓝色 frozen: 'linear-gradient(135deg, #3b82f6 0%, #2563eb 100%)', // 待使用 - 蓝色
total: 'linear-gradient(135deg, #f59e0b 0%, #d97706 100%)' // 累计 - 橙色 total: 'linear-gradient(135deg, #f59e0b 0%, #d97706 100%)' // 累计 - 橙色
} }
``` ```

View File

@@ -1,3 +1,3 @@
export default definePageConfig({ export default definePageConfig({
navigationBarTitleText: '桂乐淘分享中心' navigationBarTitleText: '账户管理中心'
}) })

View File

@@ -134,7 +134,7 @@ const DealerIndex: React.FC = () => {
<View className="grid grid-cols-3 gap-3"> <View className="grid grid-cols-3 gap-3">
<View className="text-center p-3 rounded-lg flex flex-col" style={{ <View className="text-center p-3 rounded-lg flex flex-col" style={{
background: businessGradients.money.available background: businessGradients.money.available
}}> }} onClick={() => navigateToPage('/dealer/withdraw/index')}>
<Text className="text-lg font-bold mb-1 text-white"> <Text className="text-lg font-bold mb-1 text-white">
{formatMoney(dealerUser.money)} {formatMoney(dealerUser.money)}
</Text> </Text>
@@ -146,7 +146,7 @@ const DealerIndex: React.FC = () => {
<Text className="text-lg font-bold mb-1 text-white"> <Text className="text-lg font-bold mb-1 text-white">
{formatMoney(dealerUser.freezeMoney)} {formatMoney(dealerUser.freezeMoney)}
</Text> </Text>
<Text className="text-xs" style={{ color: 'rgba(255, 255, 255, 0.9)' }}></Text> <Text className="text-xs" style={{ color: 'rgba(255, 255, 255, 0.9)' }}>使</Text>
</View> </View>
<View className="text-center p-3 rounded-lg flex flex-col" style={{ <View className="text-center p-3 rounded-lg flex flex-col" style={{
background: businessGradients.money.total background: businessGradients.money.total

View File

@@ -1,5 +1,5 @@
export default definePageConfig({ export default definePageConfig({
navigationBarTitleText: '桂乐淘分享中心', navigationBarTitleText: '账户管理中心',
// Enable "Share to friends" and "Share to Moments" (timeline) for this page. // Enable "Share to friends" and "Share to Moments" (timeline) for this page.
enableShareAppMessage: true, enableShareAppMessage: true,
enableShareTimeline: true enableShareTimeline: true

View File

@@ -98,7 +98,7 @@ const normalizeMoneyString = (money: unknown) => {
} }
const DealerWithdraw: React.FC = () => { const DealerWithdraw: React.FC = () => {
const [activeTab, setActiveTab] = useState<string | number>('0') const [activeTab, setActiveTab] = useState<string>('0')
const [loading, setLoading] = useState<boolean>(false) const [loading, setLoading] = useState<boolean>(false)
const [refreshing, setRefreshing] = useState<boolean>(false) const [refreshing, setRefreshing] = useState<boolean>(false)
const [submitting, setSubmitting] = useState<boolean>(false) const [submitting, setSubmitting] = useState<boolean>(false)
@@ -114,10 +114,11 @@ const DealerWithdraw: React.FC = () => {
// Tab 切换处理函数 // Tab 切换处理函数
const handleTabChange = (value: string | number) => { const handleTabChange = (value: string | number) => {
console.log('Tab切换到:', value) console.log('Tab切换到:', value)
setActiveTab(value) const next = String(value)
setActiveTab(next)
// 如果切换到提现记录页面,刷新数据 // 如果切换到提现记录页面,刷新数据
if (String(value) === '1') { if (next === '1') {
fetchWithdrawRecords() fetchWithdrawRecords()
} }
} }
@@ -310,7 +311,7 @@ const DealerWithdraw: React.FC = () => {
if (amount > available) { if (amount > available) {
Taro.showToast({ Taro.showToast({
title: '提现金额超过可用余额', title: '提现金额超过可用余额',
icon: 'error' icon: 'none'
}) })
return return
} }
@@ -487,7 +488,7 @@ const DealerWithdraw: React.FC = () => {
labelPosition="top" labelPosition="top"
> >
<CellGroup> <CellGroup>
<Form.Item name="amount" label="提现金额" required> <Form.Item name="amount" label="提现金额">
<Input <Input
placeholder="请输入提现金额" placeholder="请输入提现金额"
type="number" type="number"
@@ -522,7 +523,7 @@ const DealerWithdraw: React.FC = () => {
<Text className="text-sm text-red-500"> <Text className="text-sm text-red-500">
1. 1.
2. 2.
3. 3.
</Text> </Text>
</View> </View>
@@ -628,13 +629,12 @@ const DealerWithdraw: React.FC = () => {
<View className="bg-gray-50 min-h-screen"> <View className="bg-gray-50 min-h-screen">
<Tabs value={activeTab} onChange={handleTabChange}> <Tabs value={activeTab} onChange={handleTabChange}>
<Tabs.TabPane title="申请提现" value="0"> <Tabs.TabPane title="申请提现" value="0">
{renderWithdrawForm()}
</Tabs.TabPane> </Tabs.TabPane>
<Tabs.TabPane title="提现记录" value="1"> <Tabs.TabPane title="提现记录" value="1">
{renderWithdrawRecords()}
</Tabs.TabPane> </Tabs.TabPane>
</Tabs> </Tabs>
{activeTab === '0' ? renderWithdrawForm() : renderWithdrawRecords()}
</View> </View>
) )
} }

View File

@@ -3,7 +3,7 @@ import Banner from './Banner'
import Taro, { useDidShow, useShareAppMessage } from '@tarojs/taro' import Taro, { useDidShow, useShareAppMessage } from '@tarojs/taro'
import { View, Text, Image, ScrollView } from '@tarojs/components' import { View, Text, Image, ScrollView } from '@tarojs/components'
import { useEffect, useMemo, useState, type ReactNode } from 'react' import { useEffect, useMemo, useState, type ReactNode } from 'react'
import { Cart, Gift, Ticket, Agenda } from '@nutui/icons-react-taro' import { Cart, Gift, Ticket, Agenda, ArrowRight } from '@nutui/icons-react-taro'
import { getShopInfo } from '@/api/layout' import { getShopInfo } from '@/api/layout'
import { checkAndHandleInviteRelation, hasPendingInvite } from '@/utils/invite' import { checkAndHandleInviteRelation, hasPendingInvite } from '@/utils/invite'
import { pageShopGoods } from '@/api/shop/shopGoods' import { pageShopGoods } from '@/api/shop/shopGoods'
@@ -11,6 +11,7 @@ import type { ShopGoods, ShopGoodsParam } from '@/api/shop/shopGoods/model'
import { getMyGltUserTicketTotal } from '@/api/glt/gltUserTicket' import { getMyGltUserTicketTotal } from '@/api/glt/gltUserTicket'
import { ensureLoggedIn } from '@/utils/auth' import { ensureLoggedIn } from '@/utils/auth'
import './index.scss' import './index.scss'
// import navTo from "@/utils/common";
function Home() { function Home() {
const [activeTabKey, setActiveTabKey] = useState('recommend') const [activeTabKey, setActiveTabKey] = useState('recommend')
@@ -289,7 +290,21 @@ function Home() {
</View> </View>
</View> </View>
{/* 分类Tabs */} <View className="ticket-card" onClick={() => Taro.navigateTo({ url: `/shop/category/index?id=4560` })}>
<View className="ticket-card__head">
<Text className="ticket-card__title"></Text>
<ArrowRight className={'text-gray-50'} size={16} />
</View>
</View>
<View className="ticket-card" onClick={() => Taro.navigateTo({ url: `/shop/category/index?id=4556` })}>
<View className="ticket-card__head">
<Text className="ticket-card__title">·</Text>
<ArrowRight className={'text-gray-50'} size={16} />
</View>
</View>
{/*分类Tabs*/}
<ScrollView className="home-tabs" scrollX enableFlex> <ScrollView className="home-tabs" scrollX enableFlex>
<View className="home-tabs__inner"> <View className="home-tabs__inner">
{tabs.map((tab) => { {tabs.map((tab) => {
@@ -306,7 +321,6 @@ function Home() {
})} })}
</View> </View>
</ScrollView> </ScrollView>
{/* 商品列表 */} {/* 商品列表 */}
<View className="goods-grid"> <View className="goods-grid">
{visibleGoods.map((item) => ( {visibleGoods.map((item) => (
@@ -329,20 +343,20 @@ function Home() {
<Text className="goods-card__sold">:{item.sales || 0}</Text> <Text className="goods-card__sold">:{item.sales || 0}</Text>
<View className="goods-card__price"> <View className="goods-card__price">
<Text className="goods-card__priceUnit"></Text> <Text className="goods-card__priceUnit"></Text>
<Text className="goods-card__priceValue">{item.price}</Text> <Text className="goods-card__priceValue">{item.buyingPrice}</Text>
</View> </View>
</View> </View>
<View className="goods-card__actions"> <View className="goods-card__actions">
<View {/*<View*/}
className="goods-card__btn goods-card__btn--ghost" {/* className="goods-card__btn goods-card__btn--ghost"*/}
onClick={() => { {/* onClick={() => {*/}
if (!ensureLoggedIn('/shop/orderConfirm/index?goodsId=10074')) return {/* if (!ensureLoggedIn('/shop/orderConfirm/index?goodsId=10074')) return*/}
Taro.navigateTo({ url: '/shop/orderConfirm/index?goodsId=10074' }) {/* Taro.navigateTo({ url: '/shop/orderConfirm/index?goodsId=10074' })*/}
}} {/* }}*/}
> {/*>*/}
<Text className="goods-card__btnText"></Text> {/* <Text className="goods-card__btnText">买水票更优惠</Text>*/}
</View> {/*</View>*/}
<View <View
className="goods-card__btn goods-card__btn--primary" className="goods-card__btn goods-card__btn--primary"
onClick={() => onClick={() =>
@@ -356,6 +370,7 @@ function Home() {
</View> </View>
))} ))}
</View> </View>
</View> </View>
</> </>
) )

View File

@@ -52,7 +52,7 @@ const IsDealer = () => {
<View style={{display: 'inline-flex', alignItems: 'center'}}> <View style={{display: 'inline-flex', alignItems: 'center'}}>
<Reward className={'text-orange-100 '} size={16}/> <Reward className={'text-orange-100 '} size={16}/>
<Text style={{fontSize: '16px'}} <Text style={{fontSize: '16px'}}
className={'pl-3 text-orange-100 font-medium'}>{config?.vipText || '桂乐淘分享中心'}</Text> className={'pl-3 text-orange-100 font-medium'}>{config?.vipText || '账户管理中心'}</Text>
{/*<Text className={'text-white opacity-80 pl-3'}>门店核销</Text>*/} {/*<Text className={'text-white opacity-80 pl-3'}>门店核销</Text>*/}
</View> </View>
} }
@@ -76,7 +76,7 @@ const IsDealer = () => {
title={ title={
<View style={{display: 'inline-flex', alignItems: 'center'}}> <View style={{display: 'inline-flex', alignItems: 'center'}}>
<Reward className={'text-orange-100 '} size={16}/> <Reward className={'text-orange-100 '} size={16}/>
<Text style={{fontSize: '16px'}} className={'pl-3 text-orange-100 font-medium'}>{config?.vipText || '桂乐淘分享中心'}</Text> <Text style={{fontSize: '16px'}} className={'pl-3 text-orange-100 font-medium'}>{config?.vipText || '账户管理中心'}</Text>
<Text className={'text-white opacity-80 pl-3'}>{config?.vipComments || ''}</Text> <Text className={'text-white opacity-80 pl-3'}>{config?.vipComments || ''}</Text>
</View> </View>
} }

View File

@@ -47,8 +47,9 @@ const UserFooter = () => {
return ( return (
<> <>
<div className={'text-center py-4 w-full text-gray-300'} onClick={onLoginByPhone}> <div className={'text-center py-4 w-full text-gray-300'} onClick={onLoginByPhone}>
<div className={'text-xs text-gray-400 py-1'}>{Version}</div> {/*<div className={'text-xs text-gray-400 py-1'}>当前版本:{Version}</div>*/}
<div className={'text-xs text-gray-400 py-1'}>Copyright © { new Date().getFullYear() } {Copyright}</div> {/*<div className={'text-xs text-gray-400 py-1'}>Copyright © { new Date().getFullYear() } {Copyright}</div>*/}
<div className={'text-xs text-gray-400 py-1'}>{Copyright}</div>
</div> </div>
<Popup <Popup

View File

@@ -39,7 +39,7 @@ const UserCell = () => {
return ( return (
<> <>
<View className="bg-white mx-4 mt-4 rounded-xl"> <View className="bg-white mx-4 mt-4 rounded-xl">
<View className="font-semibold text-gray-800 pt-4 pl-4"></View> <View className="font-semibold text-gray-800 pt-4 pl-4"></View>
<ConfigProvider> <ConfigProvider>
<Grid <Grid
columns={4} columns={4}

View File

@@ -130,7 +130,7 @@ const DealerIndex: React.FC = () => {
{dealerUser && ( {dealerUser && (
<View className="mx-4 -mt-6 rounded-xl p-4 relative z-10" style={cardGradients.elevated}> <View className="mx-4 -mt-6 rounded-xl p-4 relative z-10" style={cardGradients.elevated}>
<View className="mb-4"> <View className="mb-4">
<Text className="font-semibold text-gray-800"></Text> <Text className="font-semibold text-gray-800"></Text>
</View> </View>
<View className="grid grid-cols-3 gap-3"> <View className="grid grid-cols-3 gap-3">
<View className="text-center p-3 rounded-lg flex flex-col" style={{ <View className="text-center p-3 rounded-lg flex flex-col" style={{

View File

@@ -0,0 +1,122 @@
.goods-grid {
margin-top: 18rpx;
display: grid;
grid-template-columns: 1fr 1fr;
gap: 18rpx;
}
.goods-card {
border-radius: 22rpx;
overflow: hidden;
background: #ffffff;
box-shadow: 0 18rpx 36rpx rgba(0, 0, 0, 0.06);
}
.goods-card__imgWrap {
padding: 18rpx 18rpx 0;
}
.goods-card__img {
width: 100%;
height: 280rpx;
border-radius: 18rpx;
background: #f4f4f4;
}
.goods-card__body {
padding: 18rpx 18rpx 20rpx;
}
.goods-card__title {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
font-size: 26rpx;
font-weight: 700;
color: #1c1c1c;
min-height: 72rpx;
}
.goods-card__meta {
margin-top: 10rpx;
display: flex;
justify-content: space-between;
align-items: flex-end;
gap: 10rpx;
}
.goods-card__sold {
font-size: 22rpx;
color: #9a9a9a;
white-space: nowrap;
}
.goods-card__price {
display: flex;
align-items: baseline;
gap: 4rpx;
color: #27c86b;
white-space: nowrap;
}
.goods-card__priceUnit {
font-size: 22rpx;
font-weight: 800;
}
.goods-card__priceValue {
font-size: 36rpx;
font-weight: 900;
}
.goods-card__actions {
margin-top: 16rpx;
display: flex;
gap: 14rpx;
}
.goods-card__btn {
flex: 1;
height: 64rpx;
border-radius: 999rpx;
display: flex;
align-items: center;
justify-content: center;
}
.goods-card__btn--ghost {
border: 2rpx solid rgba(32, 194, 106, 0.7);
background: #ffffff;
}
.goods-card__btn--primary {
background: linear-gradient(90deg, #24d34c 0%, #6df09a 100%);
}
.goods-card__btnText {
font-size: 24rpx;
font-weight: 700;
color: #18b85a;
white-space: nowrap;
}
.goods-card__btnText--primary {
color: #ffffff;
}
.buy-btn{
height: 70px;
background: linear-gradient(to bottom, #1cd98a, #24ca94);
border-radius: 100px;
color: #ffffff;
display: flex;
align-items: center;
justify-content: space-around;
.cart-icon{
background: linear-gradient(to bottom, #bbe094, #4ee265);
border-radius: 100px 0 0 100px;
height: 70px;
}
}

View File

@@ -1,51 +1,57 @@
import {Image} from '@nutui/nutui-react-taro' import {Image} from '@nutui/nutui-react-taro'
import {Share} from '@nutui/icons-react-taro'
import {View, Text} from '@tarojs/components' import {View, Text} from '@tarojs/components'
import Taro from '@tarojs/taro' import Taro from '@tarojs/taro'
import './GoodsList.scss' import './GoodsList.scss'
import {ShopGoods} from "@/api/shop/shopGoods/model";
const GoodsList = (props: any) => { const GoodsList = (props: any) => {
return ( return (
<> <>
<View className={'py-3'}> <View className={'p-3'}>
<View className={'flex flex-col justify-between items-center rounded-lg px-2'}>
{props.data?.map((item: any, index: number) => { <View className="goods-grid">
return ( {props.data?.map((item: ShopGoods) => (
<View key={index} className={'flex flex-col rounded-lg bg-white shadow-sm w-full mb-5'}> <View key={item.goodsId} className="goods-card">
<Image src={item.image} mode={'aspectFit'} lazyLoad={false} <View className="goods-card__imgWrap">
radius="10px 10px 0 0" height="180" <Image
onClick={() => Taro.navigateTo({url: '/shop/goodsDetail/index?id=' + item.goodsId})}/> className="goods-card__img"
<View className={'flex flex-col p-2 rounded-lg'}> src={item.image || ''}
<View> mode="aspectFill"
<View className={'car-no text-sm'}>{item.name}</View> width="100%"
<View className={'flex justify-between text-xs py-1'}> height="280rpx"
<Text className={'text-orange-500'}>{item.comments}</Text> radius="18rpx"
<Text className={'text-gray-400'}> {item.sales}</Text> lazyLoad={false}
</View> onClick={() =>
<View className={'flex justify-between items-center py-2'}> Taro.navigateTo({ url: `/shop/goodsDetail/index?id=${item.goodsId}` })
<View className={'flex text-red-500 text-xl items-baseline'}> }
<Text className={'text-xs'}></Text> />
<Text className={'font-bold text-2xl'}>{item.price}</Text> </View>
<Text className={'text-xs px-1'}></Text>
<Text className={'text-xs text-gray-400 line-through'}>{item.salePrice}</Text> <View className="goods-card__body">
</View> <Text className="goods-card__title">{item.name}</Text>
<View className={'buy-btn'}> <View className="goods-card__meta">
<View className={'cart-icon'}> <Text className="goods-card__sold">:{item.sales || 0}</Text>
<Share size={20} className={'mx-4 mt-2'} <View className="goods-card__price">
onClick={() => Taro.navigateTo({url: '/shop/goodsDetail/index?id=' + item.goodsId})}/> <Text className="goods-card__priceUnit"></Text>
</View> <Text className="goods-card__priceValue">{item.buyingPrice}</Text>
<View className={'text-white pl-4 pr-5'} </View>
onClick={() => Taro.navigateTo({url: '/shop/goodsDetail/index?id=' + item.goodsId})}> </View>
</View>
</View> <View className="goods-card__actions">
</View> <View
className="goods-card__btn goods-card__btn--primary"
onClick={() =>
Taro.navigateTo({ url: `/shop/goodsDetail/index?id=${item.goodsId}` })
}
>
<Text className="goods-card__btnText goods-card__btnText--primary"></Text>
</View> </View>
</View> </View>
</View> </View>
) </View>
})} ))}
</View> </View>
</View> </View>
</> </>

View File

@@ -1,7 +1,7 @@
import Taro from '@tarojs/taro' import Taro from '@tarojs/taro'
import GoodsList from './components/GoodsList' import GoodsList from './components/GoodsList'
import {useShareAppMessage} from "@tarojs/taro" import {useShareAppMessage} from "@tarojs/taro"
import {Loading} from '@nutui/nutui-react-taro' import {Loading,Empty} from '@nutui/nutui-react-taro'
import {useEffect, useState} from "react" import {useEffect, useState} from "react"
import {useRouter} from '@tarojs/taro' import {useRouter} from '@tarojs/taro'
import './index.scss' import './index.scss'
@@ -21,7 +21,7 @@ function Category() {
// 1.加载远程数据 // 1.加载远程数据
const id = Number(params.id) const id = Number(params.id)
const nav = await getCmsNavigation(id) const nav = await getCmsNavigation(id)
const shopGoods = await pageShopGoods({categoryId: id}) const shopGoods = await pageShopGoods({categoryId: id, status: 0})
// 2.处理业务逻辑 // 2.处理业务逻辑
setCategoryId(id) setCategoryId(id)
@@ -59,6 +59,12 @@ function Category() {
) )
} }
if(list.length == 0){
return (
<Empty description="暂无数据"/>
)
}
return ( return (
<> <>
<div className={'flex flex-col'}> <div className={'flex flex-col'}>

View File

@@ -366,9 +366,9 @@ const GoodsDetail = () => {
<View className={'flex justify-between'}> <View className={'flex justify-between'}>
<View className={'flex text-red-500 text-xl items-baseline'}> <View className={'flex text-red-500 text-xl items-baseline'}>
<Text className={'text-xs'}></Text> <Text className={'text-xs'}></Text>
<Text className={'font-bold text-2xl'}>{goods.price}</Text> <Text className={'font-bold text-2xl'}>{goods.buyingPrice}</Text>
<Text className={'text-xs px-1'}></Text> <Text className={'text-xs px-1'}></Text>
<Text className={'text-xs text-gray-400 line-through'}>{goods.salePrice}</Text> <Text className={'text-xs text-gray-400 line-through'}>{goods.salePrice}/{goods.unitName}</Text>
</View> </View>
<span className={"text-gray-400 text-xs"}> {goods.sales}</span> <span className={"text-gray-400 text-xs"}> {goods.sales}</span>
</View> </View>

View File

@@ -430,6 +430,7 @@ const OrderConfirm = () => {
* 统一支付入口 * 统一支付入口
*/ */
const onPay = async (goods: ShopGoods) => { const onPay = async (goods: ShopGoods) => {
let skipFinallyResetPayLoading = false
try { try {
setPayLoading(true) setPayLoading(true)
@@ -603,6 +604,29 @@ const OrderConfirm = () => {
// }) // })
} catch (error: any) { } catch (error: any) {
const message = String(error?.message || '') const message = String(error?.message || '')
const isUserCancelPay =
message.includes('用户取消支付') ||
message.includes('取消支付') ||
message.toLowerCase().includes('requestpayment:fail cancel') ||
message.toLowerCase().includes('cancel')
// 用户取消支付:跳转到待付款列表,方便继续支付
if (isUserCancelPay) {
skipFinallyResetPayLoading = true
setPayLoading(false)
const url = '/user/order/order?statusFilter=0'
try {
await Taro.redirectTo({ url })
} catch (_e) {
try {
await Taro.navigateTo({ url })
} catch (_e2) {
// ignore
}
}
return
}
const isOutOfDeliveryRange = const isOutOfDeliveryRange =
message.includes('不在配送范围') || message.includes('不在配送范围') ||
message.includes('配送范围') || message.includes('配送范围') ||
@@ -632,7 +656,9 @@ const OrderConfirm = () => {
Taro.showToast({ title: message || '支付失败,请重试', icon: 'none' }) Taro.showToast({ title: message || '支付失败,请重试', icon: 'none' })
} }
} finally { } finally {
setPayLoading(false) if (!skipFinallyResetPayLoading) {
setPayLoading(false)
}
} }
}; };
@@ -858,12 +884,9 @@ const OrderConfirm = () => {
value={quantity} value={quantity}
min={isTicketTemplateActive ? minBuyQty : 1} min={isTicketTemplateActive ? minBuyQty : 1}
max={goods.stock || 999} max={goods.stock || 999}
step={10} step={minBuyQty === 1 ? 1 : 10}
readOnly readOnly
disabled={ disabled={((goods.canBuyNumber ?? 0) !== 0) && !isTicketTemplateActive}
(((goods.canBuyNumber ?? 0) !== 0) && !isTicketTemplateActive) ||
(isTicketTemplateActive && minBuyQty === 1)
}
onChange={handleQuantityChange} onChange={handleQuantityChange}
/> />
</ConfigProvider> </ConfigProvider>

View File

@@ -3,7 +3,7 @@ import {Cell, CellGroup, Image, Space, Button, Dialog} from '@nutui/nutui-react-
import Taro from '@tarojs/taro' import Taro from '@tarojs/taro'
import {View} from '@tarojs/components' import {View} from '@tarojs/components'
import {ShopOrder} from "@/api/shop/shopOrder/model"; import {ShopOrder} from "@/api/shop/shopOrder/model";
import {getShopOrder, updateShopOrder, refundShopOrder} from "@/api/shop/shopOrder"; import {getShopOrder, updateShopOrder} from "@/api/shop/shopOrder";
import {listShopOrderGoods} from "@/api/shop/shopOrderGoods"; import {listShopOrderGoods} from "@/api/shop/shopOrderGoods";
import {ShopOrderGoods} from "@/api/shop/shopOrderGoods/model"; import {ShopOrderGoods} from "@/api/shop/shopOrderGoods/model";
import dayjs from "dayjs"; import dayjs from "dayjs";
@@ -69,7 +69,7 @@ const OrderDetail = () => {
Taro.showLoading({ title: '提交中...' }) Taro.showLoading({ title: '提交中...' })
// 退款相关操作使用退款接口PUT /api/shop/shop-order/refund // 退款相关操作使用退款接口PUT /api/shop/shop-order/refund
await refundShopOrder({ await updateShopOrder({
orderId: order.orderId, orderId: order.orderId,
refundMoney: order.payPrice || order.totalPrice, refundMoney: order.payPrice || order.totalPrice,
orderStatus: 7 orderStatus: 7

View File

@@ -47,6 +47,7 @@ const AddUserAddress = () => {
const [FormData, setFormData] = useState<ShopUserAddress>({}) const [FormData, setFormData] = useState<ShopUserAddress>({})
const [inputText, setInputText] = useState<string>('') const [inputText, setInputText] = useState<string>('')
const [selectedLocation, setSelectedLocation] = useState<SelectedLocation | null>(null) const [selectedLocation, setSelectedLocation] = useState<SelectedLocation | null>(null)
const [regionLocked, setRegionLocked] = useState(false)
const formRef = useRef<any>(null) const formRef = useRef<any>(null)
const wxDraftRef = useRef<Partial<ShopUserAddress> | null>(null) const wxDraftRef = useRef<Partial<ShopUserAddress> | null>(null)
const wxDraftPatchedRef = useRef(false) const wxDraftPatchedRef = useRef(false)
@@ -120,7 +121,12 @@ const AddUserAddress = () => {
// 设置所在地区 // 设置所在地区
setText(`${address.province} ${address.city} ${address.region}`) setText(`${address.province} ${address.city} ${address.region}`)
// 回显已保存的经纬度(编辑模式) // 回显已保存的经纬度(编辑模式)
if (hasValidLngLat(address)) setSelectedLocation({ lng: String(address.lng), lat: String(address.lat) }) if (hasValidLngLat(address)) {
setSelectedLocation({ lng: String(address.lng), lat: String(address.lat) })
setRegionLocked(true)
} else {
setRegionLocked(false)
}
} catch (error) { } catch (error) {
console.error('加载地址失败:', error) console.error('加载地址失败:', error)
Taro.showToast({ Taro.showToast({
@@ -172,30 +178,39 @@ const AddUserAddress = () => {
const result = parseAddressText(inputText); const result = parseAddressText(inputText);
// 更新表单数据 // 更新表单数据
const newFormData = { const newFormData: any = {
...FormData, ...FormData,
name: result.name || FormData.name, name: result.name || FormData.name,
phone: result.phone || FormData.phone, phone: result.phone || FormData.phone,
address: result.address || FormData.address, address: result.address || FormData.address
province: result.province || FormData.province,
city: result.city || FormData.city,
region: result.region || FormData.region
}; };
if (!regionLocked) {
newFormData.province = result.province || FormData.province
newFormData.city = result.city || FormData.city
newFormData.region = result.region || FormData.region
}
setFormData(newFormData); setFormData(newFormData);
// 更新地区显示文本 // 更新地区显示文本
if (result.province && result.city && result.region) { if (!regionLocked && result.province && result.city && result.region) {
setText(`${result.province} ${result.city} ${result.region}`); setText(`${result.province} ${result.city} ${result.region}`);
} }
// 更新表单字段值 // 更新表单字段值
if (formRef.current) { if (formRef.current) {
formRef.current.setFieldsValue(newFormData); const patch: any = {
name: newFormData.name,
phone: newFormData.phone,
address: newFormData.address
}
if (!regionLocked && newFormData.region) patch.region = newFormData.region
formRef.current.setFieldsValue(patch);
} }
Taro.showToast({ Taro.showToast({
title: '识别成功', title: regionLocked ? '识别成功(所在地区以定位为准)' : '识别成功',
icon: 'success' icon: 'success'
}); });
@@ -311,7 +326,6 @@ const AddUserAddress = () => {
name: res.name, name: res.name,
address: res.address address: res.address
} }
setSelectedLocation(next)
// 尝试从地图返回的 address 文本解析省市区best-effort // 尝试从地图返回的 address 文本解析省市区best-effort
const regionResult = res?.provinceName || res?.cityName || res?.adName const regionResult = res?.provinceName || res?.cityName || res?.adName
@@ -322,15 +336,22 @@ const AddUserAddress = () => {
} }
: parseRegion(String(res.address || '')) : parseRegion(String(res.address || ''))
const province = String(regionResult?.province || '').trim()
const city = String(regionResult?.city || '').trim()
const region = String(regionResult?.region || '').trim()
if (!province || !city || !region) {
Taro.showToast({ title: '定位未识别到所在地区,请重新选择定位', icon: 'none' })
return
}
setSelectedLocation(next)
setRegionLocked(true)
// 将地图选点的地址同步到“收货地址”(不额外拼接省市区字段,省市区由独立字段保存) // 将地图选点的地址同步到“收货地址”(不额外拼接省市区字段,省市区由独立字段保存)
const nextDetailAddress = (() => { const nextDetailAddress = (() => {
const rawAddr = String(res.address || '').trim() const rawAddr = String(res.address || '').trim()
const name = String(res.name || '').trim() const name = String(res.name || '').trim()
const province = String(regionResult?.province || '').trim()
const city = String(regionResult?.city || '').trim()
const region = String(regionResult?.region || '').trim()
// 选择定位返回的 address 往往包含省市区,这里尽量剥离掉,避免和表单的省市区字段重复 // 选择定位返回的 address 往往包含省市区,这里尽量剥离掉,避免和表单的省市区字段重复
let detail = rawAddr let detail = rawAddr
for (const part of [province, city, region]) { for (const part of [province, city, region]) {
@@ -350,20 +371,18 @@ const AddUserAddress = () => {
lng: next.lng, lng: next.lng,
lat: next.lat, lat: next.lat,
address: nextDetailAddress || prev.address, address: nextDetailAddress || prev.address,
province: regionResult?.province || prev.province, province,
city: regionResult?.city || prev.city, city,
region: regionResult?.region || prev.region region
})) }))
if (regionResult?.province && regionResult?.city && regionResult?.region) { setText(`${province} ${city} ${region}`)
setText(`${regionResult.province} ${regionResult.city} ${regionResult.region}`)
}
// 更新表单展示值Form initialValues 不会跟随 FormData 变化) // 更新表单展示值Form initialValues 不会跟随 FormData 变化)
if (formRef.current) { if (formRef.current) {
const patch: any = {} const patch: any = {}
if (nextDetailAddress) patch.address = nextDetailAddress if (nextDetailAddress) patch.address = nextDetailAddress
if (regionResult?.region) patch.region = regionResult.region patch.region = region
formRef.current.setFieldsValue(patch) formRef.current.setFieldsValue(patch)
} }
} }
@@ -407,6 +426,14 @@ const AddUserAddress = () => {
} }
} }
const openRegionPicker = () => {
if (regionLocked) {
Taro.showToast({ title: '所在地区已由定位确定,修改请重新选择定位', icon: 'none' })
return
}
setVisible(true)
}
// 提交表单 // 提交表单
const submitSucceed = async (values: any) => { const submitSucceed = async (values: any) => {
const loc = const loc =
@@ -416,6 +443,10 @@ const AddUserAddress = () => {
Taro.showToast({ title: '请选择定位', icon: 'none' }) Taro.showToast({ title: '请选择定位', icon: 'none' })
return return
} }
if (!FormData.province || !FormData.city || !FormData.region) {
Taro.showToast({ title: '请先选择定位以自动填写所在地区', icon: 'none' })
return
}
try { try {
// 准备提交的数据 // 准备提交的数据
@@ -487,6 +518,12 @@ const AddUserAddress = () => {
}) })
}, [fromWx, isEditMode]); }, [fromWx, isEditMode]);
useEffect(() => {
if (!regionLocked) return
if (!visible) return
setVisible(false)
}, [regionLocked, visible])
// NutUI Form 的 initialValues 在首次渲染后不再响应更新;微信导入时做一次 setFieldsValue 兜底回填。 // NutUI Form 的 initialValues 在首次渲染后不再响应更新;微信导入时做一次 setFieldsValue 兜底回填。
useEffect(() => { useEffect(() => {
if (loading) return if (loading) return
@@ -523,7 +560,7 @@ const AddUserAddress = () => {
onFinishFailed={(errors) => submitFailed(errors)} onFinishFailed={(errors) => submitFailed(errors)}
> >
<CellGroup className={'px-3'}> <CellGroup className={'px-3'}>
<div <View
style={{ style={{
border: '1px dashed #22c55e', border: '1px dashed #22c55e',
display: 'flex', display: 'flex',
@@ -549,7 +586,7 @@ const AddUserAddress = () => {
> >
</Button> </Button>
</div> </View>
</CellGroup> </CellGroup>
<View className={'bg-gray-100 h-3'}></View> <View className={'bg-gray-100 h-3'}></View>
<CellGroup style={{padding: '4px 0'}}> <CellGroup style={{padding: '4px 0'}}>
@@ -581,10 +618,10 @@ const AddUserAddress = () => {
rules={[{message: '请输入您的所在地区'}]} rules={[{message: '请输入您的所在地区'}]}
required required
> >
<div className={'flex justify-between items-center'} onClick={() => setVisible(true)}> <View className={'flex justify-between items-center'} onClick={openRegionPicker}>
<Input placeholder="选择所在地区" value={text} disabled/> <Input placeholder="选择所在地区" value={text} disabled/>
<ArrowRight className={'text-gray-400'}/> <ArrowRight className={'text-gray-400'}/>
</div> </View>
</Form.Item> </Form.Item>
<Form.Item name="address" label="收货地址" initialValue={FormData.address} required> <Form.Item name="address" label="收货地址" initialValue={FormData.address} required>
<TextArea maxLength={50} placeholder="请输入详细收货地址"/> <TextArea maxLength={50} placeholder="请输入详细收货地址"/>
@@ -598,15 +635,15 @@ const AddUserAddress = () => {
(selectedLocation ? `经纬度:${selectedLocation.lng}, ${selectedLocation.lat}` : '用于计算是否超出配送范围') (selectedLocation ? `经纬度:${selectedLocation.lng}, ${selectedLocation.lat}` : '用于计算是否超出配送范围')
} }
extra={( extra={(
<div className={'flex items-center gap-2'}> <View className={'flex items-center gap-2'}>
<div <View
className={'text-gray-900 text-sm'} className={'text-gray-900 text-sm'}
style={{maxWidth: '200px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap'}} style={{maxWidth: '200px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap'}}
> >
{selectedLocation?.name || (selectedLocation ? '已选择' : '请选择')} {selectedLocation?.name || (selectedLocation ? '已选择' : '请选择')}
</div> </View>
<ArrowRight className={'text-gray-400'}/> <ArrowRight className={'text-gray-400'}/>
</div> </View>
)} )}
onClick={chooseGeoLocation} onClick={chooseGeoLocation}
/> />
@@ -618,6 +655,10 @@ const AddUserAddress = () => {
options={optionsDemo1} options={optionsDemo1}
title="选择地址" title="选择地址"
onChange={(value, _) => { onChange={(value, _) => {
if (regionLocked) {
Taro.showToast({ title: '所在地区已由定位确定,修改请重新选择定位', icon: 'none' })
return
}
setFormData({ setFormData({
...FormData, ...FormData,
province: `${value[0]}`, province: `${value[0]}`,

View File

@@ -104,6 +104,10 @@ interface OrderListProps {
baseParams?: ShopOrderParam; baseParams?: ShopOrderParam;
// 只读模式:隐藏“支付/取消/确认收货/退款”等用户操作按钮 // 只读模式:隐藏“支付/取消/确认收货/退款”等用户操作按钮
readOnly?: boolean; readOnly?: boolean;
// 是否自动取消“支付已过期”的待支付订单(仅 user 模式生效)
autoCancelExpired?: boolean;
// 支付超时时间(小时),默认 24 小时
paymentTimeoutHours?: number;
} }
function OrderList(props: OrderListProps) { function OrderList(props: OrderListProps) {
@@ -111,6 +115,8 @@ function OrderList(props: OrderListProps) {
const pageRef = useRef(1) const pageRef = useRef(1)
const [hasMore, setHasMore] = useState(true) const [hasMore, setHasMore] = useState(true)
const [payingOrderId, setPayingOrderId] = useState<number | null>(null) const [payingOrderId, setPayingOrderId] = useState<number | null>(null)
const autoCanceledOrderIdsRef = useRef<Set<number>>(new Set())
const autoCancelRunningRef = useRef(false)
// 根据传入的statusFilter设置初始tab索引 // 根据传入的statusFilter设置初始tab索引
const getInitialTabIndex = () => { const getInitialTabIndex = () => {
if (props.searchParams?.statusFilter !== undefined) { if (props.searchParams?.statusFilter !== undefined) {
@@ -138,6 +144,26 @@ function OrderList(props: OrderListProps) {
return Number.isFinite(n) ? n : undefined; return Number.isFinite(n) ? n : undefined;
}; };
const parseTime = (raw: any): dayjs.Dayjs | null => {
const text = String(raw ?? '').trim();
if (!text) return null;
const t = /^\d+$/.test(text)
? dayjs(Number(text) < 1e12 ? Number(text) * 1000 : Number(text))
: dayjs(text);
return t.isValid() ? t : null;
};
const isOrderPaymentExpiredSafe = (order: ShopOrder, timeoutHours: number) => {
if (order.payStatus) return false;
if (toNum(order.orderStatus) === 2) return false;
const expiration = parseTime(order.expirationTime);
if (expiration) return dayjs().isAfter(expiration);
if (order.createTime) return isPaymentExpired(order.createTime, timeoutHours);
return false;
};
// “已完成”应以订单状态为准不要用商品ID等字段推断完成态否则会造成 Tab(待发货/待收货) 与状态文案不同步 // “已完成”应以订单状态为准不要用商品ID等字段推断完成态否则会造成 Tab(待发货/待收货) 与状态文案不同步
const isOrderCompleted = (order: ShopOrder) => toNum(order.orderStatus) === 1; const isOrderCompleted = (order: ShopOrder) => toNum(order.orderStatus) === 1;
@@ -248,24 +274,82 @@ function OrderList(props: OrderListProps) {
finalStatusFilter: searchConditions.statusFilter finalStatusFilter: searchConditions.statusFilter
}); });
try { try {
const res = await pageShopOrder(searchConditions); const timeoutHours = typeof props.paymentTimeoutHours === 'number' ? props.paymentTimeoutHours : 24;
const canAutoCancelExpired =
!!props.autoCancelExpired &&
(!props.mode || props.mode === 'user') &&
!props.readOnly;
const isPendingPayList = statusParams.statusFilter === 0;
if (res?.list && res?.list.length > 0) { const fetchOrders = async () => pageShopOrder(searchConditions);
let res = await fetchOrders();
let incoming = (res?.list || []) as ShopOrder[];
let rawIncomingLength = incoming.length;
// 自动取消“支付已过期”的待支付订单(避免用户看到一堆不可支付的过期单)
if (canAutoCancelExpired && incoming.length && !autoCancelRunningRef.current) {
const expiredToCancel = incoming
.filter(o => !!o?.orderId)
.filter(o => !autoCanceledOrderIdsRef.current.has(o.orderId as number))
.filter(o => isOrderPaymentExpiredSafe(o, timeoutHours));
if (expiredToCancel.length) {
autoCancelRunningRef.current = true;
const justCanceled = new Set<number>();
try {
// 单次最多处理 20 笔,避免接口风暴
for (const order of expiredToCancel.slice(0, 20)) {
try {
await updateShopOrder({ orderId: order.orderId, orderStatus: 2 });
autoCanceledOrderIdsRef.current.add(order.orderId as number);
justCanceled.add(order.orderId as number);
} catch (e) {
console.warn('自动取消过期订单失败:', order?.orderId, e);
}
}
} finally {
autoCancelRunningRef.current = false;
}
if (justCanceled.size > 0) {
if (resetPage) {
// resetPage 时重新拉取一次,确保列表状态与服务端一致
res = await fetchOrders();
incoming = (res?.list || []) as ShopOrder[];
rawIncomingLength = incoming.length;
Taro.showToast({ title: '已自动取消过期订单', icon: 'none' });
} else {
// loadMore 时不重新拉取,避免破坏滚动;仅在本地列表中做最小同步
if (isPendingPayList) {
incoming = incoming.filter(o => !justCanceled.has(o.orderId as number));
} else {
incoming = incoming.map(o => (
justCanceled.has(o.orderId as number) ? { ...o, orderStatus: 2 } : o
));
}
}
}
}
}
if (rawIncomingLength > 0) {
// 订单分页接口已返回 orderGoods列表直接使用该字段 // 订单分页接口已返回 orderGoods列表直接使用该字段
const incoming = res.list as ShopOrder[];
// 使用函数式更新避免依赖 list // 使用函数式更新避免依赖 list
setList(prevList => { if (incoming.length > 0) {
const newList = resetPage ? incoming : (prevList || []).concat(incoming); setList(prevList => (resetPage ? incoming : (prevList || []).concat(incoming)));
return newList; } else {
}); // 本页数据全部被自动取消过滤掉:不清空历史列表,仅保持现状
setList(prevList => (resetPage ? [] : prevList));
}
// 正确判断是否还有更多数据 // 正确判断是否还有更多数据(以服务端返回条数为准)
const hasMoreData = incoming.length >= 10; // 假设每页10条数据 const hasMoreData = rawIncomingLength >= 10; // 假设每页10条数据
setHasMore(hasMoreData); setHasMore(hasMoreData);
} else { } else {
setList(prevList => resetPage ? [] : prevList); // 服务端已无更多数据
setList(prevList => (resetPage ? [] : prevList));
setHasMore(false); setHasMore(false);
} }
@@ -281,7 +365,7 @@ function OrderList(props: OrderListProps) {
icon: 'none' icon: 'none'
}); });
} }
}, [tapIndex, props.searchParams]); // 移除 list/page 依赖避免useEffect触发循环 }, [tapIndex, props.searchParams, props.baseParams, props.mode, props.readOnly, props.autoCancelExpired, props.paymentTimeoutHours]); // 移除 list/page 依赖避免useEffect触发循环
const reloadMore = useCallback(async () => { const reloadMore = useCallback(async () => {
if (loading || !hasMore) return; // 防止重复加载 if (loading || !hasMore) return; // 防止重复加载
@@ -820,12 +904,12 @@ function OrderList(props: OrderListProps) {
<Button size={'small'} onClick={(e) => { <Button size={'small'} onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
void cancelOrder(item); void cancelOrder(item);
}}></Button> }}></Button>
{(!item.createTime || !isPaymentExpired(item.createTime, 24)) && ( {(!item.createTime || !isPaymentExpired(item.createTime, 24)) && (
<Button size={'small'} type="primary" onClick={(e) => { <Button size={'small'} type="primary" onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
void payOrder(item); void payOrder(item);
}}></Button> }}></Button>
)} )}
</Space> </Space>
)} )}

View File

@@ -164,6 +164,7 @@ function Order() {
onReload={() => reload(searchParams)} onReload={() => reload(searchParams)}
searchParams={searchParams} searchParams={searchParams}
showSearch={showSearch} showSearch={showSearch}
autoCancelExpired
onSearchParamsChange={(newParams) => { onSearchParamsChange={(newParams) => {
console.log('父组件接收到searchParams变化:', newParams); console.log('父组件接收到searchParams变化:', newParams);
setSearchParams(newParams); setSearchParams(newParams);