feat(金币代理页): 对接限制接收金额的接口

This commit is contained in:
hzj 2025-12-05 20:18:07 +08:00
parent d68c312e63
commit 63f0b262dc
2 changed files with 93 additions and 53 deletions

View File

@ -392,3 +392,29 @@ export const apiExchange = async (data) => {
throw error
}
}
/**
* 获取金币代理最小收入金额
* @returns {Promise} 返回当前的余额信息
*/
export const apiGetFreightThreshold = async (account) => {
try {
const response = await get(`/wallet/freight/threshold?account=${account}`)
return response
} catch (error) {
console.error('Failed to fetch get freight threshold:', error)
console.error('error:' + error.response.errorMsg)
throw error
}
}
// 金币代理设置最小收入金额
export const apiSetThreshold = async (data) => {
try {
const response = await post('/wallet/freight/threshold', data)
return response
} catch (error) {
console.error('Failed to set threshold:', error)
throw error
}
}

View File

@ -89,7 +89,7 @@
</div>
<!-- 设置最小接收金额 -->
<!-- <div
<div
style="
background-color: white;
padding: 16px;
@ -135,7 +135,7 @@
<div style="font-weight: 700">{{ amountItem.type }}</div>
</div>
</div>
</div> -->
</div>
<!-- 用户搜索部分 -->
<div class="user-section">
@ -322,13 +322,20 @@
import { ref, computed, onMounted, onUnmounted } from 'vue'
import { useRouter } from 'vue-router'
import { useI18n } from 'vue-i18n'
import { getUserId } from '@/utils/userStore.js'
import { setDocumentDirection } from '@/locales/i18n'
import { getSelectedUser } from '@/utils/coinSellerStore.js'
import { showError, showSuccess } from '@/utils/toast.js'
import { usePageInitializationWithConfig } from '@/utils/pageConfig.js'
import { handleAvatarImageError } from '@/utils/imageHandler.js'
import { checkFreightDealer, getFreightBalance, freightRecharge } from '@/api/wallet.js'
import {
checkFreightDealer,
getFreightBalance,
freightRecharge,
apiGetFreightThreshold, //
apiSetThreshold, //
} from '@/api/wallet.js'
import GeneralHeader from '@/components/GeneralHeader.vue'
import maskLayer from '@/components/MaskLayer.vue'
@ -347,43 +354,40 @@ const checkingAccess = ref(true)
const coinsAmount = ref('0')
const loadingBalance = ref(false)
const AmountList = ref([
{
id: 1,
type: '>$0',
selectedStatus: true,
},
{
id: 2,
type: '>=$10',
selectedStatus: false,
},
{
id: 3,
type: '>=$20',
selectedStatus: false,
},
{
id: 4,
type: '>=$50',
selectedStatus: false,
},
])
const selectedAmount = ref({})
//
const isFirstDay = ref(false)
const AmountList = computed(() => {
return [
{
id: 1,
type: '>$0',
value: 0,
selectedStatus: freightThreshold.value.deliveryThreshold == 0,
},
{
id: 2,
type: '>=$10',
value: 10,
selectedStatus: freightThreshold.value.deliveryThreshold == 10,
},
{
id: 3,
type: '>=$50',
value: 50,
selectedStatus: freightThreshold.value.deliveryThreshold == 50,
},
]
})
//
const updateIsFirstDay = () => {
const today = new Date()
isFirstDay.value = today.getDate() === 1
}
const selectedAmount = ref({})
//
const isAbleSelect = ref(false)
const freightThreshold = ref(null)
//
const amountStyle = (amountItem) => {
if (amountItem.selectedStatus) {
return 'border: 1px solid #7726ff;background: #fff;'
} else if (isFirstDay.value) {
} else if (isAbleSelect.value) {
return 'border: 1px solid transparent;background: transparent;'
} else {
return 'border: 1px solid transparent;background: rgba(0, 0, 0, 0.2);'
@ -411,8 +415,8 @@ const closedPopup = () => {
//
const selectAmount = (amountItem) => {
//
if (!isFirstDay.value || amountItem.selectedStatus) return
//
if (!isAbleSelect.value || amountItem.selectedStatus) return
console.log('选择限制转账金额', amountItem)
selectedAmount.value = amountItem //
@ -432,8 +436,7 @@ const Confirm = () => {
console.log('确认选择')
//
try {
} catch (error) {}
setThreshold()
closedPopup()
}
@ -479,6 +482,30 @@ const fetchFreightBalance = async () => {
}
}
//
const getFreightThreshold = async () => {
const resFreightThreshold = await apiGetFreightThreshold(userInfo.id)
console.log('任务列表:', resFreightThreshold)
if (resFreightThreshold.status && resFreightThreshold.body) {
freightThreshold.value = resFreightThreshold.body
isAbleSelect.value = !resFreightThreshold.body?.settinged //
}
}
//
const setThreshold = async () => {
try {
let data = {
deliveryThreshold: selectedAmount.value.value,
}
await apiSetThreshold(data) //
selectedAmount.value = {}
getFreightThreshold() //
} catch (error) {
console.log('设置失败:', error)
}
}
//
const initializeUser = () => {
const savedUser = getSelectedUser()
@ -569,24 +596,11 @@ const { userInfo } = usePageInitializationWithConfig('COIN_SELLER', {
checkDealerAccess()
fetchFreightBalance()
initializeUser()
getFreightThreshold() //
},
})
//
let dayCheckInterval = null
onMounted(() => {
//
updateIsFirstDay()
//
dayCheckInterval = setInterval(updateIsFirstDay, 60 * 60 * 1000)
})
onUnmounted(() => {
if (dayCheckInterval) {
clearInterval(dayCheckInterval)
}
})
onMounted(() => {})
</script>
<style scoped>