best-unit 2.0.12 → 2.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "best-unit",
3
3
  "private": false,
4
- "version": "2.0.12",
4
+ "version": "2.0.13",
5
5
  "type": "module",
6
6
  "main": "dist/best-unit.cjs",
7
7
  "module": "dist/best-unit.js",
package/src/api/index.ts CHANGED
@@ -46,6 +46,27 @@ export const getAllDicts = async () => {
46
46
  });
47
47
  };
48
48
 
49
+ // 获取所有币种
50
+ export const getAllCurrencies = async () => {
51
+ const fundUnitParams = JSON.parse(
52
+ sessionStorage.getItem("fund_unit_params") || "{}"
53
+ );
54
+ return http()
55
+ .get("/currency", {
56
+ params: {
57
+ biz_type: fundUnitParams.bizType,
58
+ },
59
+ })
60
+ .then((res) => {
61
+ return (
62
+ res.data.currency.map((item: any) => ({
63
+ value: item.value,
64
+ label: item.label,
65
+ })) || []
66
+ );
67
+ });
68
+ };
69
+
49
70
  // 上传文件
50
71
  export const uploadFile = async (
51
72
  file: any,
@@ -1,7 +1,11 @@
1
1
  import { useState, useEffect } from "preact/hooks";
2
2
  import { t } from "@/local";
3
3
  import { getSelectPaymentTheme } from "./theme";
4
- import { getOfflineChannelMap, calculateBusinessExchangeRate } from "@/api";
4
+ import {
5
+ getOfflineChannelMap,
6
+ calculateBusinessExchangeRate,
7
+ getAllCurrencies,
8
+ } from "@/api";
5
9
  import { useRef } from "preact/hooks";
6
10
 
7
11
  interface SelectPaymentProps {
@@ -25,9 +29,8 @@ export function SelectPayment({
25
29
  }: SelectPaymentProps) {
26
30
  const theme = getSelectPaymentTheme();
27
31
 
28
- // 币种从本地字典读取;渠道通过接口获取
29
- const allDicts = JSON.parse(sessionStorage.getItem("all_dicts") || "{}");
30
- const currencyDict = allDicts?.currency || [];
32
+ // 币种通过接口获取;渠道通过接口获取
33
+ const [currencyDict, setCurrencyDict] = useState<any[]>([]);
31
34
  const [onlineChannelDict, setOnlineChannelDict] = useState<any[]>([]);
32
35
  const [bankChannelDict, setBankChannelDict] = useState<any[]>([]);
33
36
 
@@ -72,6 +75,13 @@ export function SelectPayment({
72
75
  }, 300);
73
76
  };
74
77
 
78
+ // 获取币种字典
79
+ useEffect(() => {
80
+ getAllCurrencies().then((res) => {
81
+ setCurrencyDict(res || []);
82
+ });
83
+ }, []);
84
+
75
85
  // 根据币种拉取线上/线下渠道映射,初始化默认选项
76
86
  useEffect(() => {
77
87
  getOfflineChannelMap({ currency: formState.currency }).then((res) => {