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