feat: 添加金种子包配置

This commit is contained in:
2026-09-30 10:39:45 +08:00
parent 82f6737820
commit 0cbbf4309d
2 changed files with 32 additions and 10 deletions
+21 -10
View File
@@ -120,10 +120,10 @@
<view class="popup-fixed-box"> <view class="popup-fixed-box">
<view class="popup-fixed-label">本次兑换</view> <view class="popup-fixed-label">本次兑换</view>
<view class="popup-fixed-value"> <view class="popup-fixed-value">
<text class="popup-fixed-num">{{ FIXED_EXCHANGE_AMOUNT }}</text> <text class="popup-fixed-num">{{ exchangeAmount }}</text>
<text class="popup-fixed-unit">枚</text> <text class="popup-fixed-unit">枚</text>
</view> </view>
<view class="popup-fixed-tag">每笔固定 {{ FIXED_EXCHANGE_AMOUNT }} 金种子</view> <view class="popup-fixed-tag">每笔固定 {{ exchangeAmount }} 金种子</view>
</view> </view>
<view class="popup-tip"> <view class="popup-tip">
<uni-icons type="info" color="#C6C6C6" size="20" /> <uni-icons type="info" color="#C6C6C6" size="20" />
@@ -146,9 +146,9 @@ import sheep from '@/sheep';
import * as homeApi from '@/sheep/api/home/index'; import * as homeApi from '@/sheep/api/home/index';
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const FIXED_EXCHANGE_AMOUNT = 100;
const PAGE_SIZE = 20; const PAGE_SIZE = 20;
const exchangeAmount = ref(100);
const popupVisible = ref(false); const popupVisible = ref(false);
const detailList = ref([]); const detailList = ref([]);
const dataObj = reactive({}); const dataObj = reactive({});
@@ -220,6 +220,16 @@ const formatDateTime = (val) => {
return `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())} ${pad2(d.getHours())}:${pad2(d.getMinutes())}`; return `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())} ${pad2(d.getHours())}:${pad2(d.getMinutes())}`;
}; };
const fetchExchangeConfig = async () => {
const res = await homeApi.goldSeedExchangeGetConfig();
if (res?.code === 0) {
const n = Number(res?.data);
if (Number.isFinite(n) && n > 0) {
exchangeAmount.value = n;
}
}
};
const fetchAsset = async () => { const fetchAsset = async () => {
const res = await homeApi.goldSeedIndex(); const res = await homeApi.goldSeedIndex();
load.value = true; load.value = true;
@@ -263,7 +273,8 @@ const refresh = async () => {
try { uni.stopPullDownRefresh(); } catch (e) {} try { uni.stopPullDownRefresh(); } catch (e) {}
}; };
const openExchangePopup = () => { const openExchangePopup = async () => {
await fetchExchangeConfig();
popupVisible.value = true; popupVisible.value = true;
}; };
@@ -272,16 +283,16 @@ const closeExchangePopup = () => {
}; };
const submitExchange = async () => { const submitExchange = async () => {
const hold = Number(dataObj?.myCount) || 0; const amount = Number(exchangeAmount.value) || 0;
if (hold < FIXED_EXCHANGE_AMOUNT) { const res = await homeApi.goldSeedExchangeCreate({ packageAmount: amount });
sheep.$helper.toast(`持有数量不足,每笔需 ${FIXED_EXCHANGE_AMOUNT} 金种子`);
return;
}
const res = await homeApi.goldSeedExchangeCreate({ packageAmount: FIXED_EXCHANGE_AMOUNT });
if (res?.code === 0) { if (res?.code === 0) {
closeExchangePopup(); closeExchangePopup();
fetchAsset(); fetchAsset();
setTimeout(() => getList(true), 300); setTimeout(() => getList(true), 300);
} else if (res && res.code !== undefined && res.code !== 0) {
if (res?.msg) {
sheep.$helper.toast(res.msg);
}
} }
}; };
+11
View File
@@ -80,6 +80,17 @@ export const goldSeedExchangePage = (params) => {
params: params, params: params,
}); });
}; };
// 获取金种子兑换配置
export const goldSeedExchangeGetConfig = (params) => {
return request({
url: '/member/app/gold-seed-exchange/get-config',
method: 'GET',
params: params,
custom: {
showLoading: false,
},
});
};
// 创建金种子兑换申请 // 创建金种子兑换申请
export const goldSeedExchangeCreate = (params) => { export const goldSeedExchangeCreate = (params) => {
return request({ return request({