refactor(invite): 重构邀请二维码生成逻辑

- 优化了 generateMiniProgramCode 函数,直接返回完整的二维码 URL
- 移除了未使用的 getInviteStats 函数调用
- 增加了二维码加载失败时的错误处理和重新生成逻辑
-调整了页面布局,隐藏了邀请统计数据部分
This commit is contained in:
2025-08-23 05:54:10 +08:00
parent a15333da07
commit 0b83e67ac1
5 changed files with 307 additions and 157 deletions

View File

@@ -1,6 +1,7 @@
import {useEffect, useState} from "react";
import {Cell, CellGroup, Image, Space, Button} from '@nutui/nutui-react-taro'
import Taro from '@tarojs/taro'
import {View} from '@tarojs/components'
import {ShopOrder} from "@/api/shop/shopOrder/model";
import {getShopOrder, updateShopOrder} from "@/api/shop/shopOrder";
import {listShopOrderGoods} from "@/api/shop/shopOrderGoods";
@@ -27,7 +28,7 @@ const OrderDetail = () => {
});
// 更新本地状态
setOrder(prev => prev ? { ...prev, orderStatus: 2 } : null);
setOrder(prev => prev ? {...prev, orderStatus: 2} : null);
Taro.showToast({
title: '订单已自动取消',
@@ -65,25 +66,33 @@ const OrderDetail = () => {
const getPayTypeText = (payType?: number) => {
switch (payType) {
case 0: return '余额支付';
case 1: return '微信支付';
case 102: return '微信Native';
case 2: return '会员卡支付';
case 3: return '支付宝';
case 4: return '现金';
case 5: return 'POS机';
default: return '未知支付方式';
case 0:
return '余额支付';
case 1:
return '微信支付';
case 102:
return '微信Native';
case 2:
return '会员卡支付';
case 3:
return '支付宝';
case 4:
return '现金';
case 5:
return 'POS机';
default:
return '未知支付方式';
}
};
useEffect(() => {
if (orderId) {
console.log('shop-goods',orderId)
console.log('shop-goods', orderId)
getShopOrder(Number(orderId)).then(async (res) => {
setOrder(res);
// 获取订单商品列表
const goodsRes = await listShopOrderGoods({ orderId: Number(orderId) });
const goodsRes = await listShopOrderGoods({orderId: Number(orderId)});
if (goodsRes && goodsRes.length > 0) {
setOrderGoodsList(goodsRes);
}
@@ -101,7 +110,7 @@ const OrderDetail = () => {
<div className={'order-detail-page'}>
{/* 支付倒计时显示 - 详情页实时更新 */}
{!order.payStatus && order.orderStatus !== 2 && (
<div className="order-detail-countdown flex justify-center p-4 bg-red-50 border-b border-red-100">
<div className="order-detail-countdown flex justify-center p-4 border-b border-gray-50">
<PaymentCountdown
createTime={order.createTime}
payStatus={order.payStatus}
@@ -113,17 +122,11 @@ const OrderDetail = () => {
</div>
)}
<CellGroup title="订单信息">
<Cell title="订单编号" description={order.orderNo} />
<Cell title="下单时间" description={dayjs(order.createTime).format('YYYY-MM-DD HH:mm:ss')} />
<Cell title="订单状态" description={getOrderStatusText(order)} />
</CellGroup>
<CellGroup title="商品信息">
<CellGroup>
{orderGoodsList.map((item, index) => (
<Cell key={index}>
<div className={'flex items-center'}>
<Image src={item.image || '/default-goods.png'} width="80" height="80" lazyLoad={false} />
<Image src={item.image || '/default-goods.png'} width="80" height="80" lazyLoad={false}/>
<div className={'ml-2'}>
<div className={'text-sm font-bold'}>{item.goodsName}</div>
{item.spec && <div className={'text-gray-500 text-xs'}>{item.spec}</div>}
@@ -135,25 +138,36 @@ const OrderDetail = () => {
))}
</CellGroup>
<CellGroup title="收货信息">
<Cell title="收货人" description={order.realName} />
<Cell title="手机号" description={order.phone} />
<Cell title="收货地址" description={order.address} />
<CellGroup>
<Cell title="订单编号" description={order.orderNo}/>
<Cell title="下单时间" description={dayjs(order.createTime).format('YYYY-MM-DD HH:mm:ss')}/>
<Cell title="订单状态" description={getOrderStatusText(order)}/>
</CellGroup>
<CellGroup title="支付信息">
<Cell title="支付方式" description={getPayTypeText(order.payType)} />
<Cell title="实付金额" description={`${order.payPrice}`} />
<CellGroup>
<Cell title="收货人" description={order.realName}/>
<Cell title="手机号" description={order.phone}/>
<Cell title="收货地址" description={order.address}/>
</CellGroup>
<div className={'fixed-bottom'}>
<Space>
{!order.payStatus && <Button onClick={() => console.log('取消订单')}></Button>}
{!order.payStatus && <Button type="primary" onClick={() => console.log('立即支付')}></Button>}
{order.orderStatus === 1 && <Button onClick={() => console.log('申请退款')}>退</Button>}
{order.deliveryStatus === 20 && <Button type="primary" onClick={() => console.log('确认收货')}></Button>}
</Space>
</div>
{order.payStatus && (
<CellGroup>
<Cell title="支付方式" description={getPayTypeText(order.payType)}/>
<Cell title="实付金额" description={`${order.payPrice}`}/>
</CellGroup>
)}
<View className={'h5-div fixed z-50 bg-white w-full bottom-0 left-0 pt-4 pb-5 border-t border-gray-200'}>
<View className={'flex justify-end px-4'}>
<Space>
{!order.payStatus && <Button onClick={() => console.log('取消订单')}></Button>}
{!order.payStatus && <Button type="primary" onClick={() => console.log('立即支付')}></Button>}
{order.orderStatus === 1 && <Button onClick={() => console.log('申请退款')}>退</Button>}
{order.deliveryStatus === 20 &&
<Button type="primary" onClick={() => console.log('确认收货')}></Button>}
</Space>
</View>
</View>
</div>
);
};