feat(金币代理页): 对接限制接收金额的接口
This commit is contained in:
parent
d68c312e63
commit
63f0b262dc
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -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>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user