Files
xinlong-shop-taro/src_bak/pages/group-buy-list.tsx
赵忠林 1fa58040f3 feat(user): 新增收货地址管理及售后申请页面
- 新增地址类型定义,增强前端地址数据结构
- 新增地址编辑页面,支持地址智能识别和定位选点功能
- 地址编辑支持省市区选择及默认地址设置
- 新增地址列表页面,支持地址展示、删除、编辑和选择功能
- 实现售后申请页面,支持选择售后类型和退款原因
- 售后申请支持商品选择、退款金额计算和凭证上传
- 新增售后详情页面,支持售后状态展示及申请取消
- 优化页面加载和用户交互体验,增加错误提示和权限处理
2026-07-01 12:11:56 +08:00

120 lines
4.2 KiB
TypeScript

import React, { useEffect, useState } from 'react'
import { View, Text, Image, ScrollView } from '@tarojs/components'
import Taro from '@tarojs/taro'
import { pageShopGroupBuy } from '@/api/shop/shopGroupBuy'
import type { ShopGroupBuy } from '@/api/shop/shopGroupBuy/model'
import EmptyState from '@/components/common/EmptyState'
definePageConfig({
navigationBarTitleText: '拼团活动',
})
const GroupBuyListPage: React.FC = () => {
const [groupBuyList, setGroupBuyList] = useState<ShopGroupBuy[]>([])
const [loading, setLoading] = useState(true)
useEffect(() => {
fetchGroupBuyList()
}, [])
const fetchGroupBuyList = async () => {
try {
setLoading(true)
const res = await pageShopGroupBuy({ page: 1, pageSize: 20, status: 1 })
if (res.code === 0 && res.data) {
setGroupBuyList(res.data.items || [])
}
} catch (err) {
console.error('获取拼团列表失败', err)
Taro.showToast({ title: '加载失败', icon: 'none' })
} finally {
setLoading(false)
}
}
const handleGroupBuyClick = (item: ShopGroupBuy) => {
Taro.navigateTo({
url: `/pages/shop/group-buy-detail?groupBuyId=${item.id}`
})
}
const getStatusText = (item: ShopGroupBuy) => {
const remaining = item.groupSize - item.currentSize
if (remaining <= 0) return '已满员'
return `还差${remaining}人成团`
}
const getStatusColor = (item: ShopGroupBuy) => {
const remaining = item.groupSize - item.currentSize
if (remaining <= 0) return '#999'
return '#ff4d4f'
}
return (
<View className='min-h-screen bg-gray-50'>
<ScrollView scrollY className='h-screen'>
<View className='p-3'>
{loading ? (
<View className='flex items-center justify-center py-20'>
<Text className='text-gray-400 text-sm'>...</Text>
</View>
) : groupBuyList.length === 0 ? (
<View className='pt-20'>
<EmptyState text='暂无拼团活动' />
</View>
) : (
<View className="flex flex-col" style={{ gap: '12px' }}>
{groupBuyList.map(item => (
<View
key={item.id}
className='bg-white rounded-lg p-3 flex gap-3'
onClick={() => handleGroupBuyClick(item)}
>
<Image
className='w-24 h-24 rounded-md bg-gray-100 flex-shrink-0'
src={item.goodsImage || item.product?.image || ''}
mode='aspectFill'
/>
<View className='flex-1 flex flex-col justify-between'>
<Text className='text-sm text-gray-700 font-medium line-clamp-2'>
{item.goodsName || item.product?.name || '商品名称'}
</Text>
<View className='flex items-center gap-2 mt-1'>
<View className='bg-red-50 px-2 py-1 rounded'>
<Text className='text-xs text-red-500'>{item.groupSize}</Text>
</View>
<Text className='text-xs' style={{ color: getStatusColor(item) }}>
{getStatusText(item)}
</Text>
</View>
<View className='flex items-center justify-between mt-1'>
<View className='flex items-baseline gap-1'>
<Text className='text-lg font-bold text-red-500'>
{'\u00A5'}{item.groupPrice}
</Text>
<Text className='text-xs text-gray-400 line-through'>
{'\u00A5'}{item.product?.price || 0}
</Text>
</View>
<View
className='px-3 py-1 rounded-full text-white text-xs'
style={{ backgroundColor: '#ff4d4f' }}
>
<Text></Text>
</View>
</View>
</View>
</View>
))}
</View>
)}
</View>
</ScrollView>
</View>
)
}
export default GroupBuyListPage