best-unit 1.4.7 → 1.4.9

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": "1.4.7",
4
+ "version": "1.4.9",
5
5
  "type": "module",
6
6
  "main": "dist/best-unit.cjs",
7
7
  "module": "dist/best-unit.js",
package/src/api/index.ts CHANGED
@@ -133,7 +133,24 @@ export const calcPaymentAmount = async (data: CalcPaymentAmountParams) => {
133
133
  paymentAmount: data.payment_amount,
134
134
  fee: data.fee,
135
135
  currency: data.currency,
136
- }
136
+ };
137
+ });
138
+ };
139
+
140
+ // /sdk/channel/info
141
+ export const getChannelInfo = async (data: {
142
+ code: string;
143
+ bizType: string;
144
+ }) => {
145
+ return http()
146
+ .get("/channel/info", {
147
+ params: {
148
+ code: data.code,
149
+ biz_type: data.bizType,
150
+ },
151
+ })
152
+ .then((res) => {
153
+ return res.data?.detail || [];
137
154
  });
138
155
  };
139
156
 
@@ -1,6 +1,7 @@
1
1
  import type { FunctionalComponent } from "preact";
2
+ import { useState } from "preact/hooks";
2
3
  import { Upload } from "@/components/common/upload";
3
- import { createOfflineRecharge } from "@/api";
4
+ import { createOfflineRecharge, getChannelInfo } from "@/api";
4
5
  import { message } from "@/components/common/message";
5
6
  import { t } from "@/local";
6
7
  import { Select } from "@/components/common/select";
@@ -29,6 +30,9 @@ export const OfflineTransferForm: FunctionalComponent<
29
30
  const channelDict = allDicts?.channel || [];
30
31
  const theme = getOfflineTransferFormTheme();
31
32
 
33
+ // 渠道信息展示
34
+ const [channelInfo, setChannelInfo] = useState<string[]>([]);
35
+
32
36
  const handleSubmit = async (e: any) => {
33
37
  e.preventDefault();
34
38
  let valid = true;
@@ -69,6 +73,22 @@ export const OfflineTransferForm: FunctionalComponent<
69
73
  message.success(t("提交成功"));
70
74
  };
71
75
 
76
+ function handlePlatformChange(value: string) {
77
+ setFormState((state: any) => ({
78
+ ...state,
79
+ platform: value,
80
+ platformError: value ? "" : state.platformError,
81
+ }));
82
+ console.log(value, "value");
83
+ getChannelInfo({
84
+ code: value,
85
+ bizType: "fulfill",
86
+ }).then((res) => {
87
+ console.log(res, "res");
88
+ // 兼容空值与非数组返回
89
+ setChannelInfo(Array.isArray(res) ? res : res ? [String(res)] : []);
90
+ });
91
+ }
72
92
  return (
73
93
  <form onSubmit={handleSubmit}>
74
94
  <div style={{ marginBottom: 18 }}>
@@ -78,11 +98,7 @@ export const OfflineTransferForm: FunctionalComponent<
78
98
  <Select
79
99
  value={formState.platform}
80
100
  onChange={(value) => {
81
- setFormState((state: any) => ({
82
- ...state,
83
- platform: value,
84
- platformError: value ? "" : state.platformError,
85
- }));
101
+ handlePlatformChange(value);
86
102
  }}
87
103
  options={[
88
104
  ...channelDict?.map((item: any) => ({
@@ -95,6 +111,15 @@ export const OfflineTransferForm: FunctionalComponent<
95
111
  {formState.platformError && (
96
112
  <div style={theme.error}>{formState.platformError}</div>
97
113
  )}
114
+ {channelInfo.length > 0 && (
115
+ <div style={theme.channelInfoBox}>
116
+ {channelInfo.map((line, idx) => (
117
+ <div key={idx} style={theme.channelInfoItem}>
118
+ {line}
119
+ </div>
120
+ ))}
121
+ </div>
122
+ )}
98
123
  </div>
99
124
  <div style={{ marginBottom: 18 }}>
100
125
  <div style={theme.label}>
@@ -104,6 +104,19 @@ function createOfflineTransferFormThemes() {
104
104
  marginTop: size === Size.SMALL ? 2 : 4,
105
105
  textAlign: "left",
106
106
  },
107
+ channelInfoBox: {
108
+ marginTop: size === Size.SMALL ? 8 : 10,
109
+ padding: size === Size.SMALL ? "8px 10px" : "10px 12px",
110
+ borderRadius: 6,
111
+ background: "#F7F8FA",
112
+ border: "1px solid #E5E6EB",
113
+ },
114
+ channelInfoItem: {
115
+ color: "#222",
116
+ fontSize: size === Size.SMALL ? 12 : 13,
117
+ lineHeight: 1.6,
118
+ wordBreak: "break-all",
119
+ },
107
120
  },
108
121
  dark: {
109
122
  label: {
@@ -205,6 +218,19 @@ function createOfflineTransferFormThemes() {
205
218
  marginTop: size === Size.SMALL ? 2 : 4,
206
219
  textAlign: "left",
207
220
  },
221
+ channelInfoBox: {
222
+ marginTop: size === Size.SMALL ? 8 : 10,
223
+ padding: size === Size.SMALL ? "8px 10px" : "10px 12px",
224
+ borderRadius: 6,
225
+ background: "#23262F",
226
+ border: "1px solid #374151",
227
+ },
228
+ channelInfoItem: {
229
+ color: "#fff",
230
+ fontSize: size === Size.SMALL ? 12 : 13,
231
+ lineHeight: 1.6,
232
+ wordBreak: "break-all",
233
+ },
208
234
  },
209
235
  };
210
236
  }
@@ -95,7 +95,6 @@ function StatisticalBalance(props: { popoverPosition?: PopoverPosition }) {
95
95
  useEffect(() => {
96
96
  // 监听refresh-balance事件
97
97
  const handleRefreshBalance = () => {
98
- console.log("handleRefreshBalance");
99
98
  fetchBalance();
100
99
  };
101
100
 
@@ -43,11 +43,11 @@ export interface InitParams {
43
43
 
44
44
  // 获取余额数据并暴露给外部系统
45
45
  export async function getBalanceData() {
46
- let balanceData = JSON.parse(sessionStorage.getItem("balanceData") || "{}");
47
- if (balanceData && Object.keys(balanceData).length > 0) {
48
- return balanceData;
49
- }
50
- balanceData = await getBalance();
46
+ // let balanceData = JSON.parse(sessionStorage.getItem("balanceData") || "{}");
47
+ // if (balanceData && Object.keys(balanceData).length > 0) {
48
+ // return balanceData;
49
+ // }
50
+ const balanceData = await getBalance();
51
51
  return balanceData;
52
52
  }
53
53
 
@@ -121,7 +121,6 @@ export function getInitParams<T = InitParams>(key?: string | string[]): T {
121
121
  * 触发余额刷新事件
122
122
  */
123
123
  export function refreshBalance() {
124
- console.log("refreshBalance");
125
124
  const refreshEvent = new CustomEvent("refresh-balance", {
126
125
  detail: {},
127
126
  bubbles: true,