import React, { useState } from 'react' import { View, Text, Input, ScrollView } from '@tarojs/components' import Taro from '@tarojs/taro' import { useScrollHeight } from '@/hooks/useScrollHeight' definePageConfig({ navigationBarTitleText: '购买礼品卡', }) const GiftCardPurchasePage: React.FC = () => { const [amount, setAmount] = useState('') const [showCustom, setShowCustom] = useState(false) const scrollHeight = useScrollHeight(60) // 预设金额 const presetAmounts = [100, 200, 500, 1000] // 处理金额选择 const handleAmountSelect = (value: number) => { setAmount(value.toString()) setShowCustom(false) } // 处理自定义金额 const handleCustomAmount = (value: string) => { setAmount(value) } // 处理购买 const handlePurchase = () => { Taro.showModal({ title: '提示', content: '礼品卡购买功能暂未开放,请使用兑换功能。', showCancel: true, confirmText: '去兑换', success: (res) => { if (res.confirm) { Taro.redirectTo({ url: '/pages/gift-card/exchange' }) } } }) } return ( {/* 礼品卡预览 */} 鑫龙家电礼品卡 ¥ {amount || '0'} 送给他/她一份惊喜 {/* 选择金额 */} 选择金额 {presetAmounts.map(amt => ( handleAmountSelect(amt)} > ¥{amt} ))} {/* 自定义金额 */} { setShowCustom(true) setAmount('') }} > {showCustom ? ( ¥ handleCustomAmount(e.detail.value)} placeholder='输入金额' className='text-center text-lg font-bold text-purple-500' style={{ width: '120px' }} /> ) : ( 自定义金额 )} {/* 购买说明 */} 购买说明 1. 礼品卡购买功能暂未开放 2. 请使用兑换功能兑换礼品卡 3. 如有问题,请联系客服 {/* 购买按钮 */} 礼品卡兑换 ) } export default GiftCardPurchasePage