支付组件统一使用二维码展示
This commit is contained in:
@@ -6,10 +6,9 @@ export const usePlatformType = (): TradePlatform => {
|
||||
// 在SSR环境下返回默认值
|
||||
const [platform, setPlatform] = useState<TradePlatform>(() => {
|
||||
if (typeof window === 'undefined') return TradePlatform.Desktop
|
||||
// return window.matchMedia('(max-width: 768px)').matches
|
||||
// ? TradePlatform.Mobile
|
||||
// : TradePlatform.Desktop
|
||||
return TradePlatform.Desktop
|
||||
return window.matchMedia('(max-width: 768px)').matches
|
||||
? TradePlatform.Mobile
|
||||
: TradePlatform.Desktop
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -1,16 +1,26 @@
|
||||
import {StaticImageData} from 'next/image'
|
||||
import wechat from '@/components/composites/purchase/_assets/wechat.svg'
|
||||
import alipay from '@/components/composites/purchase/_assets/alipay.svg'
|
||||
import balance from '@/components/composites/purchase/_assets/balance.svg'
|
||||
|
||||
export const TradeMethodDecoration = {
|
||||
alipay: {
|
||||
text: '支付宝',
|
||||
icon: alipay,
|
||||
},
|
||||
wechat: {
|
||||
text: '微信支付',
|
||||
icon: wechat,
|
||||
},
|
||||
export function getTradeMethodDecoration(method: TradeMethod) {
|
||||
switch (method) {
|
||||
case TradeMethod.Alipay:
|
||||
return {
|
||||
text: '支付宝',
|
||||
icon: alipay,
|
||||
}
|
||||
case TradeMethod.Wechat:
|
||||
return {
|
||||
text: '微信支付',
|
||||
icon: wechat,
|
||||
}
|
||||
default:
|
||||
return {
|
||||
text: '扫码支付',
|
||||
icon: balance,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 支付方法枚举
|
||||
|
||||
Reference in New Issue
Block a user