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

111 lines
4.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React, { useState, useEffect } from 'react'
import { View, Text, ScrollView, Button } from '@tarojs/components'
import Taro from '@tarojs/taro'
import { useUser } from '@/hooks/useUser'
import { useScrollHeight } from '@/hooks/useScrollHeight'
definePageConfig({
navigationBarTitleText: '分销推广',
})
const PromotionPage: React.FC = () => {
const { user, isLoggedIn } = useUser()
const [inviteCode, setInviteCode] = useState('')
const [inviteLink, setInviteLink] = useState('')
const scrollHeight = useScrollHeight(44)
useEffect(() => {
if (!isLoggedIn) {
Taro.navigateTo({ url: '/passport/login' })
return
}
// 生成邀请码和链接
const code = user?.id?.toString() || ''
setInviteCode(code)
setInviteLink(`https://shop-api.websoft.top/invite?ref=${code}`)
}, [isLoggedIn, user])
const handleCopyLink = () => {
Taro.setClipboardData({
data: inviteLink,
success: () => {
Taro.showToast({ title: '链接已复制', icon: 'success' })
},
})
}
const handleShare = () => {
Taro.showToast({ title: '请点击右上角分享', icon: 'none' })
}
if (!isLoggedIn) {
return null
}
return (
<View className='min-h-screen bg-gray-50'>
<ScrollView scrollY style={{ height: scrollHeight }}>
{/* 推广卡片 */}
<View className='mx-3 mt-3 p-4 rounded-xl' style={{ background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)' }}>
<Text className='text-white text-lg font-bold mb-1 block'>广</Text>
<Text className='text-white text-sm opacity-80 mb-3 block'></Text>
<View className='bg-white rounded-lg p-3'>
<Text className='text-xs text-gray-500 mb-1 block'></Text>
<Text className='text-base font-bold text-gray-800'>{inviteCode}</Text>
</View>
</View>
{/* 推广链接 */}
<View className='mx-3 mt-3 p-4 bg-white rounded-lg'>
<Text className='text-sm font-medium text-gray-800 mb-2 block'>广</Text>
<View className='bg-gray-50 rounded-lg p-3 mb-3'>
<Text className='text-xs text-gray-600 break-all'>{inviteLink}</Text>
</View>
<View className='grid grid-cols-2 gap-2'>
<Button
className='rounded-full'
style={{ backgroundColor: '#0e932e' }}
onClick={handleCopyLink}
>
</Button>
<Button
className='rounded-full'
style={{ backgroundColor: '#1989fa' }}
onClick={handleShare}
>
</Button>
</View>
</View>
{/* 推广说明 */}
<View className='mx-3 mt-3 p-4 bg-white rounded-lg'>
<Text className='text-sm font-medium text-gray-800 mb-3 block'>广</Text>
<View className='flex items-start gap-2 mb-2'>
<Text className='text-green-500 mt-0'>1.</Text>
<Text className='text-sm text-gray-600 flex-1'></Text>
</View>
<View className='flex items-start gap-2 mb-2'>
<Text className='text-green-500 mt-0'>2.</Text>
<Text className='text-sm text-gray-600 flex-1'></Text>
</View>
<View className='flex items-start gap-2 mb-2'>
<Text className='text-green-500 mt-0'>3.</Text>
<Text className='text-sm text-gray-600 flex-1'></Text>
</View>
<View className='flex items-start gap-2'>
<Text className='text-green-500 mt-0'>4.</Text>
<Text className='text-sm text-gray-600 flex-1'></Text>
</View>
</View>
<View className='h-6' />
</ScrollView>
</View>
)
}
export default PromotionPage