fix(api): 替换所有接口请求的域名为 guilixu-api.websoft.top
- 将获取 STS Token 的接口地址由 paopao-api 改为 guilixu-api - 更新图片上传接口地址为新的 guilixu-api 域名 - 修改用户推广页面中邀请码链接和二维码接口的域名 - 更改注册页微信登录接口请求的域名为 guilixu-api
This commit is contained in:
@@ -7,6 +7,8 @@ import { pageShopGoods } from '@/api/shop/shopGoods'
|
||||
import type { ShopGoods } from '@/api/shop/shopGoods/model'
|
||||
import EmptyState from '@/components/common/EmptyState'
|
||||
import Loading from '@/components/common/Loading'
|
||||
import { isGuest } from '@/utils/auth'
|
||||
import { requireLogin } from '@/utils/login-guard'
|
||||
|
||||
definePageConfig({
|
||||
navigationBarTitleText: '购物车',
|
||||
@@ -15,6 +17,7 @@ definePageConfig({
|
||||
const CartPage: React.FC = () => {
|
||||
const { items, selectedCount, selectedPrice, updateQuantity, toggleSelect, selectAll, removeItem, refresh, loading, removeSelected, addItem } = useCartContext()
|
||||
const { isLoggedIn } = useUserContext()
|
||||
const [recommendGoods, setRecommendGoods] = useState<ShopGoods[]>([])
|
||||
const [recommendPage, setRecommendPage] = useState(1)
|
||||
const [refreshingRecommend, setRefreshingRecommend] = useState(false)
|
||||
|
||||
@@ -58,6 +61,7 @@ const CartPage: React.FC = () => {
|
||||
}
|
||||
|
||||
const handleCheckout = () => {
|
||||
if (!requireLogin({ action: 'checkout', redirect: '/pages/shop/cart' })) return
|
||||
if (selectedCount === 0) {
|
||||
Taro.showToast({ title: '请选择商品', icon: 'none' })
|
||||
return
|
||||
@@ -65,17 +69,57 @@ const CartPage: React.FC = () => {
|
||||
Taro.navigateTo({ url: '/pages/shop/checkout' })
|
||||
}
|
||||
|
||||
// 未登录状态
|
||||
// 未登录状态:展示"购物车是空的"+ 推荐位商品(游客可正常浏览),
|
||||
// 不再直接弹登录页,避免被审核判"拒绝服务"。
|
||||
if (!isLoggedIn) {
|
||||
return (
|
||||
<View className="min-h-screen bg-gray-50 flex flex-col">
|
||||
<View className="flex-1 flex items-center justify-center">
|
||||
<EmptyState
|
||||
text="请先登录"
|
||||
actionText="去登录"
|
||||
onAction={() => Taro.navigateTo({ url: '/pages/passport/login' })}
|
||||
/>
|
||||
</View>
|
||||
<View className='min-h-screen bg-gray-50 flex flex-col'>
|
||||
<ScrollView scrollY className='flex-1'>
|
||||
<View className='flex items-center justify-center py-16'>
|
||||
<EmptyState
|
||||
text='购物车是空的'
|
||||
actionText='去登录后查看购物车'
|
||||
onAction={() => requireLogin({ action: 'viewOrder', redirect: '/pages/shop/cart', silent: true })}
|
||||
/>
|
||||
</View>
|
||||
{recommendGoods.length > 0 && (
|
||||
<View className='p-3'>
|
||||
<View className='flex items-center justify-between mb-2'>
|
||||
<Text className='text-sm font-medium text-gray-700'>猜你喜欢</Text>
|
||||
<Text className='text-xs text-gray-400' onClick={handleRefreshRecommend}>
|
||||
{refreshingRecommend ? '加载中...' : '换一批'}
|
||||
</Text>
|
||||
</View>
|
||||
<ScrollView scrollX className='whitespace-nowrap' style={{ width: '100%', height: '180px' }}>
|
||||
<View className='flex gap-2' style={{ display: 'inline-flex' }}>
|
||||
{recommendGoods.map(goods => (
|
||||
<View
|
||||
key={goods.goodsId}
|
||||
className='bg-white rounded-lg p-2 inline-block'
|
||||
style={{ width: '110px', flexShrink: 0 }}
|
||||
onClick={() => Taro.navigateTo({ url: `/pages/shop/product-detail?id=${goods.goodsId}` })}
|
||||
>
|
||||
<Image
|
||||
className='w-full rounded-md bg-gray-100'
|
||||
src={goods.image || ''}
|
||||
mode='aspectFill'
|
||||
style={{ height: '90px' }}
|
||||
/>
|
||||
<Text className='text-xs text-gray-700 mt-1 block' style={{ width: '100px' }} ellipsizeMode='tail' numberOfLines={1}>
|
||||
{goods.name || goods.goodsName || '商品名称'}
|
||||
</Text>
|
||||
<View className='flex items-center justify-between mt-1'>
|
||||
<Text className='text-xs text-gray-400'>
|
||||
登录后查看价格
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
)}
|
||||
</ScrollView>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user