forked from gxwebsoft/mp-10550
Compare commits
15 Commits
ab61aa9ee0
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 81c63e0e65 | |||
| 86f7506422 | |||
| fae144549e | |||
| 718eddff63 | |||
| a4a0a922fc | |||
| ca2436a2e8 | |||
| 83ba49d860 | |||
| 7375a3b1ce | |||
| 756b548bf9 | |||
| 76e76c62ef | |||
| 546d90cc28 | |||
| d4fd61376c | |||
| b27421fd6e | |||
| b929b8d35e | |||
| 23af704c68 |
@@ -9,6 +9,6 @@ export const BaseUrl = API_BASE_URL;
|
||||
// 当前版本
|
||||
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 ./
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#### 新增功能
|
||||
- 用户头像和基本信息展示
|
||||
- 佣金统计(可提现、冻结中、累计收益)
|
||||
- 佣金统计(可提现、待使用、累计收益)
|
||||
- 团队统计(一级、二级、三级成员)
|
||||
- 功能导航网格(分销订单、提现申请、我的团队、推广二维码)
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ dealer: {
|
||||
// 金额相关
|
||||
money: {
|
||||
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%)' // 累计 - 橙色
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default definePageConfig({
|
||||
navigationBarTitleText: '桂乐淘分享中心'
|
||||
navigationBarTitleText: '账户管理中心'
|
||||
})
|
||||
|
||||
@@ -134,7 +134,7 @@ const DealerIndex: React.FC = () => {
|
||||
<View className="grid grid-cols-3 gap-3">
|
||||
<View className="text-center p-3 rounded-lg flex flex-col" style={{
|
||||
background: businessGradients.money.available
|
||||
}}>
|
||||
}} onClick={() => navigateToPage('/dealer/withdraw/index')}>
|
||||
<Text className="text-lg font-bold mb-1 text-white">
|
||||
{formatMoney(dealerUser.money)}
|
||||
</Text>
|
||||
@@ -146,7 +146,7 @@ const DealerIndex: React.FC = () => {
|
||||
<Text className="text-lg font-bold mb-1 text-white">
|
||||
{formatMoney(dealerUser.freezeMoney)}
|
||||
</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 className="text-center p-3 rounded-lg flex flex-col" style={{
|
||||
background: businessGradients.money.total
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export default definePageConfig({
|
||||
navigationBarTitleText: '桂乐淘分享中心',
|
||||
navigationBarTitleText: '账户管理中心',
|
||||
// Enable "Share to friends" and "Share to Moments" (timeline) for this page.
|
||||
enableShareAppMessage: true,
|
||||
enableShareTimeline: true
|
||||
|
||||
@@ -98,7 +98,7 @@ const normalizeMoneyString = (money: unknown) => {
|
||||
}
|
||||
|
||||
const DealerWithdraw: React.FC = () => {
|
||||
const [activeTab, setActiveTab] = useState<string | number>('0')
|
||||
const [activeTab, setActiveTab] = useState<string>('0')
|
||||
const [loading, setLoading] = useState<boolean>(false)
|
||||
const [refreshing, setRefreshing] = useState<boolean>(false)
|
||||
const [submitting, setSubmitting] = useState<boolean>(false)
|
||||
@@ -114,10 +114,11 @@ const DealerWithdraw: React.FC = () => {
|
||||
// Tab 切换处理函数
|
||||
const handleTabChange = (value: string | number) => {
|
||||
console.log('Tab切换到:', value)
|
||||
setActiveTab(value)
|
||||
const next = String(value)
|
||||
setActiveTab(next)
|
||||
|
||||
// 如果切换到提现记录页面,刷新数据
|
||||
if (String(value) === '1') {
|
||||
if (next === '1') {
|
||||
fetchWithdrawRecords()
|
||||
}
|
||||
}
|
||||
@@ -310,7 +311,7 @@ const DealerWithdraw: React.FC = () => {
|
||||
if (amount > available) {
|
||||
Taro.showToast({
|
||||
title: '提现金额超过可用余额',
|
||||
icon: 'error'
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -487,7 +488,7 @@ const DealerWithdraw: React.FC = () => {
|
||||
labelPosition="top"
|
||||
>
|
||||
<CellGroup>
|
||||
<Form.Item name="amount" label="提现金额" required>
|
||||
<Form.Item name="amount" label="提现金额">
|
||||
<Input
|
||||
placeholder="请输入提现金额"
|
||||
type="number"
|
||||
@@ -522,7 +523,7 @@ const DealerWithdraw: React.FC = () => {
|
||||
<Text className="text-sm text-red-500">
|
||||
注意事项:
|
||||
1. 提取佣金必须完成实名认证。
|
||||
2. 佣金非自动到账,再您提取佣金申请通过后,请手动到我的申请记录点击领取。
|
||||
2. 佣金非自动到账,在您提取佣金申请通过后,请手动到我的申请记录点击领取。
|
||||
3. 桂乐淘温馨提示,请您依法依规申报所得,缴税相关税费。
|
||||
</Text>
|
||||
</View>
|
||||
@@ -628,13 +629,12 @@ const DealerWithdraw: React.FC = () => {
|
||||
<View className="bg-gray-50 min-h-screen">
|
||||
<Tabs value={activeTab} onChange={handleTabChange}>
|
||||
<Tabs.TabPane title="申请提现" value="0">
|
||||
{renderWithdrawForm()}
|
||||
</Tabs.TabPane>
|
||||
|
||||
<Tabs.TabPane title="提现记录" value="1">
|
||||
{renderWithdrawRecords()}
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
{activeTab === '0' ? renderWithdrawForm() : renderWithdrawRecords()}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import Banner from './Banner'
|
||||
import Taro, { useDidShow, useShareAppMessage } from '@tarojs/taro'
|
||||
import { View, Text, Image, ScrollView } from '@tarojs/components'
|
||||
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 { checkAndHandleInviteRelation, hasPendingInvite } from '@/utils/invite'
|
||||
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 { ensureLoggedIn } from '@/utils/auth'
|
||||
import './index.scss'
|
||||
// import navTo from "@/utils/common";
|
||||
|
||||
function Home() {
|
||||
const [activeTabKey, setActiveTabKey] = useState('recommend')
|
||||
@@ -289,6 +290,20 @@ function Home() {
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<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>
|
||||
<View className="home-tabs__inner">
|
||||
@@ -306,7 +321,6 @@ function Home() {
|
||||
})}
|
||||
</View>
|
||||
</ScrollView>
|
||||
|
||||
{/* 商品列表 */}
|
||||
<View className="goods-grid">
|
||||
{visibleGoods.map((item) => (
|
||||
@@ -329,20 +343,20 @@ function Home() {
|
||||
<Text className="goods-card__sold">已购:{item.sales || 0}人</Text>
|
||||
<View className="goods-card__price">
|
||||
<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 className="goods-card__actions">
|
||||
<View
|
||||
className="goods-card__btn goods-card__btn--ghost"
|
||||
onClick={() => {
|
||||
if (!ensureLoggedIn('/shop/orderConfirm/index?goodsId=10074')) return
|
||||
Taro.navigateTo({ url: '/shop/orderConfirm/index?goodsId=10074' })
|
||||
}}
|
||||
>
|
||||
<Text className="goods-card__btnText">买水票更优惠</Text>
|
||||
</View>
|
||||
{/*<View*/}
|
||||
{/* className="goods-card__btn goods-card__btn--ghost"*/}
|
||||
{/* onClick={() => {*/}
|
||||
{/* if (!ensureLoggedIn('/shop/orderConfirm/index?goodsId=10074')) return*/}
|
||||
{/* Taro.navigateTo({ url: '/shop/orderConfirm/index?goodsId=10074' })*/}
|
||||
{/* }}*/}
|
||||
{/*>*/}
|
||||
{/* <Text className="goods-card__btnText">买水票更优惠</Text>*/}
|
||||
{/*</View>*/}
|
||||
<View
|
||||
className="goods-card__btn goods-card__btn--primary"
|
||||
onClick={() =>
|
||||
@@ -356,6 +370,7 @@ function Home() {
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
|
||||
@@ -52,7 +52,7 @@ const IsDealer = () => {
|
||||
<View style={{display: 'inline-flex', alignItems: 'center'}}>
|
||||
<Reward className={'text-orange-100 '} size={16}/>
|
||||
<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>*/}
|
||||
</View>
|
||||
}
|
||||
@@ -76,7 +76,7 @@ const IsDealer = () => {
|
||||
title={
|
||||
<View style={{display: 'inline-flex', alignItems: 'center'}}>
|
||||
<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>
|
||||
</View>
|
||||
}
|
||||
|
||||
@@ -47,8 +47,9 @@ const UserFooter = () => {
|
||||
return (
|
||||
<>
|
||||
<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'}>Copyright © { new Date().getFullYear() } {Copyright}</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}</div>
|
||||
</div>
|
||||
|
||||
<Popup
|
||||
|
||||
@@ -39,7 +39,7 @@ const UserCell = () => {
|
||||
return (
|
||||
<>
|
||||
<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>
|
||||
<Grid
|
||||
columns={4}
|
||||
|
||||
@@ -130,7 +130,7 @@ const DealerIndex: React.FC = () => {
|
||||
{dealerUser && (
|
||||
<View className="mx-4 -mt-6 rounded-xl p-4 relative z-10" style={cardGradients.elevated}>
|
||||
<View className="mb-4">
|
||||
<Text className="font-semibold text-gray-800">工资统计</Text>
|
||||
<Text className="font-semibold text-gray-800">配送提成</Text>
|
||||
</View>
|
||||
<View className="grid grid-cols-3 gap-3">
|
||||
<View className="text-center p-3 rounded-lg flex flex-col" style={{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,51 +1,57 @@
|
||||
import {Image} from '@nutui/nutui-react-taro'
|
||||
import {Share} from '@nutui/icons-react-taro'
|
||||
import {View, Text} from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import './GoodsList.scss'
|
||||
import {ShopGoods} from "@/api/shop/shopGoods/model";
|
||||
|
||||
|
||||
const GoodsList = (props: any) => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className={'py-3'}>
|
||||
<View className={'flex flex-col justify-between items-center rounded-lg px-2'}>
|
||||
{props.data?.map((item: any, index: number) => {
|
||||
return (
|
||||
<View key={index} className={'flex flex-col rounded-lg bg-white shadow-sm w-full mb-5'}>
|
||||
<Image src={item.image} mode={'aspectFit'} lazyLoad={false}
|
||||
radius="10px 10px 0 0" height="180"
|
||||
onClick={() => Taro.navigateTo({url: '/shop/goodsDetail/index?id=' + item.goodsId})}/>
|
||||
<View className={'flex flex-col p-2 rounded-lg'}>
|
||||
<View>
|
||||
<View className={'car-no text-sm'}>{item.name}</View>
|
||||
<View className={'flex justify-between text-xs py-1'}>
|
||||
<Text className={'text-orange-500'}>{item.comments}</Text>
|
||||
<Text className={'text-gray-400'}>已售 {item.sales}</Text>
|
||||
<View className={'p-3'}>
|
||||
|
||||
<View className="goods-grid">
|
||||
{props.data?.map((item: ShopGoods) => (
|
||||
<View key={item.goodsId} className="goods-card">
|
||||
<View className="goods-card__imgWrap">
|
||||
<Image
|
||||
className="goods-card__img"
|
||||
src={item.image || ''}
|
||||
mode="aspectFill"
|
||||
width="100%"
|
||||
height="280rpx"
|
||||
radius="18rpx"
|
||||
lazyLoad={false}
|
||||
onClick={() =>
|
||||
Taro.navigateTo({ url: `/shop/goodsDetail/index?id=${item.goodsId}` })
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
<View className={'flex justify-between items-center py-2'}>
|
||||
<View className={'flex text-red-500 text-xl items-baseline'}>
|
||||
<Text className={'text-xs'}>¥</Text>
|
||||
<Text className={'font-bold text-2xl'}>{item.price}</Text>
|
||||
<Text className={'text-xs px-1'}>会员价</Text>
|
||||
<Text className={'text-xs text-gray-400 line-through'}>¥{item.salePrice}</Text>
|
||||
|
||||
<View className="goods-card__body">
|
||||
<Text className="goods-card__title">{item.name}</Text>
|
||||
<View className="goods-card__meta">
|
||||
<Text className="goods-card__sold">已购:{item.sales || 0}人</Text>
|
||||
<View className="goods-card__price">
|
||||
<Text className="goods-card__priceUnit">¥</Text>
|
||||
<Text className="goods-card__priceValue">{item.buyingPrice}</Text>
|
||||
</View>
|
||||
<View className={'buy-btn'}>
|
||||
<View className={'cart-icon'}>
|
||||
<Share size={20} className={'mx-4 mt-2'}
|
||||
onClick={() => Taro.navigateTo({url: '/shop/goodsDetail/index?id=' + item.goodsId})}/>
|
||||
</View>
|
||||
<View className={'text-white pl-4 pr-5'}
|
||||
onClick={() => Taro.navigateTo({url: '/shop/goodsDetail/index?id=' + item.goodsId})}>购买
|
||||
|
||||
<View className="goods-card__actions">
|
||||
<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>
|
||||
</>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Taro from '@tarojs/taro'
|
||||
import GoodsList from './components/GoodsList'
|
||||
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 {useRouter} from '@tarojs/taro'
|
||||
import './index.scss'
|
||||
@@ -21,7 +21,7 @@ function Category() {
|
||||
// 1.加载远程数据
|
||||
const id = Number(params.id)
|
||||
const nav = await getCmsNavigation(id)
|
||||
const shopGoods = await pageShopGoods({categoryId: id})
|
||||
const shopGoods = await pageShopGoods({categoryId: id, status: 0})
|
||||
|
||||
// 2.处理业务逻辑
|
||||
setCategoryId(id)
|
||||
@@ -59,6 +59,12 @@ function Category() {
|
||||
)
|
||||
}
|
||||
|
||||
if(list.length == 0){
|
||||
return (
|
||||
<Empty description="暂无数据"/>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={'flex flex-col'}>
|
||||
|
||||
@@ -366,9 +366,9 @@ const GoodsDetail = () => {
|
||||
<View className={'flex justify-between'}>
|
||||
<View className={'flex text-red-500 text-xl items-baseline'}>
|
||||
<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 text-gray-400 line-through'}>¥{goods.salePrice}</Text>
|
||||
<Text className={'text-xs text-gray-400 line-through'}>¥{goods.salePrice}/{goods.unitName}</Text>
|
||||
</View>
|
||||
<span className={"text-gray-400 text-xs"}>已售 {goods.sales}</span>
|
||||
</View>
|
||||
|
||||
@@ -430,6 +430,7 @@ const OrderConfirm = () => {
|
||||
* 统一支付入口
|
||||
*/
|
||||
const onPay = async (goods: ShopGoods) => {
|
||||
let skipFinallyResetPayLoading = false
|
||||
try {
|
||||
setPayLoading(true)
|
||||
|
||||
@@ -603,6 +604,29 @@ const OrderConfirm = () => {
|
||||
// })
|
||||
} catch (error: any) {
|
||||
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 =
|
||||
message.includes('不在配送范围') ||
|
||||
message.includes('配送范围') ||
|
||||
@@ -632,8 +656,10 @@ const OrderConfirm = () => {
|
||||
Taro.showToast({ title: message || '支付失败,请重试', icon: 'none' })
|
||||
}
|
||||
} finally {
|
||||
if (!skipFinallyResetPayLoading) {
|
||||
setPayLoading(false)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 统一的数据加载函数
|
||||
@@ -858,12 +884,9 @@ const OrderConfirm = () => {
|
||||
value={quantity}
|
||||
min={isTicketTemplateActive ? minBuyQty : 1}
|
||||
max={goods.stock || 999}
|
||||
step={10}
|
||||
step={minBuyQty === 1 ? 1 : 10}
|
||||
readOnly
|
||||
disabled={
|
||||
(((goods.canBuyNumber ?? 0) !== 0) && !isTicketTemplateActive) ||
|
||||
(isTicketTemplateActive && minBuyQty === 1)
|
||||
}
|
||||
disabled={((goods.canBuyNumber ?? 0) !== 0) && !isTicketTemplateActive}
|
||||
onChange={handleQuantityChange}
|
||||
/>
|
||||
</ConfigProvider>
|
||||
|
||||
@@ -3,7 +3,7 @@ import {Cell, CellGroup, Image, Space, Button, Dialog} from '@nutui/nutui-react-
|
||||
import Taro from '@tarojs/taro'
|
||||
import {View} from '@tarojs/components'
|
||||
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 {ShopOrderGoods} from "@/api/shop/shopOrderGoods/model";
|
||||
import dayjs from "dayjs";
|
||||
@@ -69,7 +69,7 @@ const OrderDetail = () => {
|
||||
Taro.showLoading({ title: '提交中...' })
|
||||
|
||||
// 退款相关操作使用退款接口:PUT /api/shop/shop-order/refund
|
||||
await refundShopOrder({
|
||||
await updateShopOrder({
|
||||
orderId: order.orderId,
|
||||
refundMoney: order.payPrice || order.totalPrice,
|
||||
orderStatus: 7
|
||||
|
||||
@@ -47,6 +47,7 @@ const AddUserAddress = () => {
|
||||
const [FormData, setFormData] = useState<ShopUserAddress>({})
|
||||
const [inputText, setInputText] = useState<string>('')
|
||||
const [selectedLocation, setSelectedLocation] = useState<SelectedLocation | null>(null)
|
||||
const [regionLocked, setRegionLocked] = useState(false)
|
||||
const formRef = useRef<any>(null)
|
||||
const wxDraftRef = useRef<Partial<ShopUserAddress> | null>(null)
|
||||
const wxDraftPatchedRef = useRef(false)
|
||||
@@ -120,7 +121,12 @@ const AddUserAddress = () => {
|
||||
// 设置所在地区
|
||||
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) {
|
||||
console.error('加载地址失败:', error)
|
||||
Taro.showToast({
|
||||
@@ -172,30 +178,39 @@ const AddUserAddress = () => {
|
||||
const result = parseAddressText(inputText);
|
||||
|
||||
// 更新表单数据
|
||||
const newFormData = {
|
||||
const newFormData: any = {
|
||||
...FormData,
|
||||
name: result.name || FormData.name,
|
||||
phone: result.phone || FormData.phone,
|
||||
address: result.address || FormData.address,
|
||||
province: result.province || FormData.province,
|
||||
city: result.city || FormData.city,
|
||||
region: result.region || FormData.region
|
||||
address: result.address || FormData.address
|
||||
};
|
||||
|
||||
if (!regionLocked) {
|
||||
newFormData.province = result.province || FormData.province
|
||||
newFormData.city = result.city || FormData.city
|
||||
newFormData.region = result.region || FormData.region
|
||||
}
|
||||
|
||||
setFormData(newFormData);
|
||||
|
||||
// 更新地区显示文本
|
||||
if (result.province && result.city && result.region) {
|
||||
if (!regionLocked && result.province && result.city && result.region) {
|
||||
setText(`${result.province} ${result.city} ${result.region}`);
|
||||
}
|
||||
|
||||
// 更新表单字段值
|
||||
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({
|
||||
title: '识别成功',
|
||||
title: regionLocked ? '识别成功(所在地区以定位为准)' : '识别成功',
|
||||
icon: 'success'
|
||||
});
|
||||
|
||||
@@ -311,7 +326,6 @@ const AddUserAddress = () => {
|
||||
name: res.name,
|
||||
address: res.address
|
||||
}
|
||||
setSelectedLocation(next)
|
||||
|
||||
// 尝试从地图返回的 address 文本解析省市区(best-effort)
|
||||
const regionResult = res?.provinceName || res?.cityName || res?.adName
|
||||
@@ -322,15 +336,22 @@ const AddUserAddress = () => {
|
||||
}
|
||||
: 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 rawAddr = String(res.address || '').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 往往包含省市区,这里尽量剥离掉,避免和表单的省市区字段重复
|
||||
let detail = rawAddr
|
||||
for (const part of [province, city, region]) {
|
||||
@@ -350,20 +371,18 @@ const AddUserAddress = () => {
|
||||
lng: next.lng,
|
||||
lat: next.lat,
|
||||
address: nextDetailAddress || prev.address,
|
||||
province: regionResult?.province || prev.province,
|
||||
city: regionResult?.city || prev.city,
|
||||
region: regionResult?.region || prev.region
|
||||
province,
|
||||
city,
|
||||
region
|
||||
}))
|
||||
|
||||
if (regionResult?.province && regionResult?.city && regionResult?.region) {
|
||||
setText(`${regionResult.province} ${regionResult.city} ${regionResult.region}`)
|
||||
}
|
||||
setText(`${province} ${city} ${region}`)
|
||||
|
||||
// 更新表单展示值(Form initialValues 不会跟随 FormData 变化)
|
||||
if (formRef.current) {
|
||||
const patch: any = {}
|
||||
if (nextDetailAddress) patch.address = nextDetailAddress
|
||||
if (regionResult?.region) patch.region = regionResult.region
|
||||
patch.region = region
|
||||
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 loc =
|
||||
@@ -416,6 +443,10 @@ const AddUserAddress = () => {
|
||||
Taro.showToast({ title: '请选择定位', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!FormData.province || !FormData.city || !FormData.region) {
|
||||
Taro.showToast({ title: '请先选择定位以自动填写所在地区', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
// 准备提交的数据
|
||||
@@ -487,6 +518,12 @@ const AddUserAddress = () => {
|
||||
})
|
||||
}, [fromWx, isEditMode]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!regionLocked) return
|
||||
if (!visible) return
|
||||
setVisible(false)
|
||||
}, [regionLocked, visible])
|
||||
|
||||
// NutUI Form 的 initialValues 在首次渲染后不再响应更新;微信导入时做一次 setFieldsValue 兜底回填。
|
||||
useEffect(() => {
|
||||
if (loading) return
|
||||
@@ -523,7 +560,7 @@ const AddUserAddress = () => {
|
||||
onFinishFailed={(errors) => submitFailed(errors)}
|
||||
>
|
||||
<CellGroup className={'px-3'}>
|
||||
<div
|
||||
<View
|
||||
style={{
|
||||
border: '1px dashed #22c55e',
|
||||
display: 'flex',
|
||||
@@ -549,7 +586,7 @@ const AddUserAddress = () => {
|
||||
>
|
||||
识别
|
||||
</Button>
|
||||
</div>
|
||||
</View>
|
||||
</CellGroup>
|
||||
<View className={'bg-gray-100 h-3'}></View>
|
||||
<CellGroup style={{padding: '4px 0'}}>
|
||||
@@ -581,10 +618,10 @@ const AddUserAddress = () => {
|
||||
rules={[{message: '请输入您的所在地区'}]}
|
||||
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/>
|
||||
<ArrowRight className={'text-gray-400'}/>
|
||||
</div>
|
||||
</View>
|
||||
</Form.Item>
|
||||
<Form.Item name="address" label="收货地址" initialValue={FormData.address} required>
|
||||
<TextArea maxLength={50} placeholder="请输入详细收货地址"/>
|
||||
@@ -598,15 +635,15 @@ const AddUserAddress = () => {
|
||||
(selectedLocation ? `经纬度:${selectedLocation.lng}, ${selectedLocation.lat}` : '用于计算是否超出配送范围')
|
||||
}
|
||||
extra={(
|
||||
<div className={'flex items-center gap-2'}>
|
||||
<div
|
||||
<View className={'flex items-center gap-2'}>
|
||||
<View
|
||||
className={'text-gray-900 text-sm'}
|
||||
style={{maxWidth: '200px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap'}}
|
||||
>
|
||||
{selectedLocation?.name || (selectedLocation ? '已选择' : '请选择')}
|
||||
</div>
|
||||
</View>
|
||||
<ArrowRight className={'text-gray-400'}/>
|
||||
</div>
|
||||
</View>
|
||||
)}
|
||||
onClick={chooseGeoLocation}
|
||||
/>
|
||||
@@ -618,6 +655,10 @@ const AddUserAddress = () => {
|
||||
options={optionsDemo1}
|
||||
title="选择地址"
|
||||
onChange={(value, _) => {
|
||||
if (regionLocked) {
|
||||
Taro.showToast({ title: '所在地区已由定位确定,修改请重新选择定位', icon: 'none' })
|
||||
return
|
||||
}
|
||||
setFormData({
|
||||
...FormData,
|
||||
province: `${value[0]}`,
|
||||
|
||||
@@ -104,6 +104,10 @@ interface OrderListProps {
|
||||
baseParams?: ShopOrderParam;
|
||||
// 只读模式:隐藏“支付/取消/确认收货/退款”等用户操作按钮
|
||||
readOnly?: boolean;
|
||||
// 是否自动取消“支付已过期”的待支付订单(仅 user 模式生效)
|
||||
autoCancelExpired?: boolean;
|
||||
// 支付超时时间(小时),默认 24 小时
|
||||
paymentTimeoutHours?: number;
|
||||
}
|
||||
|
||||
function OrderList(props: OrderListProps) {
|
||||
@@ -111,6 +115,8 @@ function OrderList(props: OrderListProps) {
|
||||
const pageRef = useRef(1)
|
||||
const [hasMore, setHasMore] = useState(true)
|
||||
const [payingOrderId, setPayingOrderId] = useState<number | null>(null)
|
||||
const autoCanceledOrderIdsRef = useRef<Set<number>>(new Set())
|
||||
const autoCancelRunningRef = useRef(false)
|
||||
// 根据传入的statusFilter设置初始tab索引
|
||||
const getInitialTabIndex = () => {
|
||||
if (props.searchParams?.statusFilter !== undefined) {
|
||||
@@ -138,6 +144,26 @@ function OrderList(props: OrderListProps) {
|
||||
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(待发货/待收货) 与状态文案不同步
|
||||
const isOrderCompleted = (order: ShopOrder) => toNum(order.orderStatus) === 1;
|
||||
|
||||
@@ -249,23 +275,81 @@ function OrderList(props: OrderListProps) {
|
||||
});
|
||||
|
||||
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:列表直接使用该字段
|
||||
const incoming = res.list as ShopOrder[];
|
||||
|
||||
// 使用函数式更新避免依赖 list
|
||||
setList(prevList => {
|
||||
const newList = resetPage ? incoming : (prevList || []).concat(incoming);
|
||||
return newList;
|
||||
});
|
||||
if (incoming.length > 0) {
|
||||
setList(prevList => (resetPage ? incoming : (prevList || []).concat(incoming)));
|
||||
} else {
|
||||
// 本页数据全部被自动取消过滤掉:不清空历史列表,仅保持现状
|
||||
setList(prevList => (resetPage ? [] : prevList));
|
||||
}
|
||||
|
||||
// 正确判断是否还有更多数据
|
||||
const hasMoreData = incoming.length >= 10; // 假设每页10条数据
|
||||
// 正确判断是否还有更多数据(以服务端返回条数为准)
|
||||
const hasMoreData = rawIncomingLength >= 10; // 假设每页10条数据
|
||||
setHasMore(hasMoreData);
|
||||
} else {
|
||||
setList(prevList => resetPage ? [] : prevList);
|
||||
// 服务端已无更多数据
|
||||
setList(prevList => (resetPage ? [] : prevList));
|
||||
setHasMore(false);
|
||||
}
|
||||
|
||||
@@ -281,7 +365,7 @@ function OrderList(props: OrderListProps) {
|
||||
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 () => {
|
||||
if (loading || !hasMore) return; // 防止重复加载
|
||||
@@ -820,12 +904,12 @@ function OrderList(props: OrderListProps) {
|
||||
<Button size={'small'} onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
void cancelOrder(item);
|
||||
}}>取消订单</Button>
|
||||
}}>取消</Button>
|
||||
{(!item.createTime || !isPaymentExpired(item.createTime, 24)) && (
|
||||
<Button size={'small'} type="primary" onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
void payOrder(item);
|
||||
}}>立即支付</Button>
|
||||
}}>继续支付</Button>
|
||||
)}
|
||||
</Space>
|
||||
)}
|
||||
|
||||
@@ -164,6 +164,7 @@ function Order() {
|
||||
onReload={() => reload(searchParams)}
|
||||
searchParams={searchParams}
|
||||
showSearch={showSearch}
|
||||
autoCancelExpired
|
||||
onSearchParamsChange={(newParams) => {
|
||||
console.log('父组件接收到searchParams变化:', newParams);
|
||||
setSearchParams(newParams);
|
||||
|
||||
Reference in New Issue
Block a user