feat:多货币以及支付方式配置
This commit is contained in:
39
src/views/billing/rule/modules/currency.ts
Normal file
39
src/views/billing/rule/modules/currency.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
interface CurrencyOption {
|
||||
code: string
|
||||
symbol: string
|
||||
name: string
|
||||
}
|
||||
|
||||
interface CurrencyState {
|
||||
currentCurrency: CurrencyOption
|
||||
}
|
||||
|
||||
export const availableCurrencies: CurrencyOption[] = [
|
||||
{ code: 'USD', symbol: '$', name: '美元' },
|
||||
{ code: 'CNY', symbol: '¥', name: '人民币' },
|
||||
{ code: 'EUR', symbol: '€', name: '欧元' },
|
||||
{ code: 'GBP', symbol: '£', name: '英镑' },
|
||||
]
|
||||
|
||||
export const useCurrencyStore = defineStore('currency', {
|
||||
state: (): CurrencyState => ({
|
||||
currentCurrency: availableCurrencies[0]
|
||||
}),
|
||||
|
||||
actions: {
|
||||
setCurrency(currencyCode: string) {
|
||||
const currency = availableCurrencies.find(c => c.code === currencyCode)
|
||||
if (currency) {
|
||||
this.currentCurrency = currency
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getters: {
|
||||
symbol: (state: CurrencyState): string => state.currentCurrency.symbol,
|
||||
code: (state: CurrencyState): string => state.currentCurrency.code,
|
||||
name: (state: CurrencyState): string => state.currentCurrency.name
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user