修改计算服务费用api
This commit is contained in:
parent
ba1f2d16b9
commit
33d24527dd
115
api/user/user.js
115
api/user/user.js
|
|
@ -1,5 +1,13 @@
|
||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
import { mockUserInfo, mockFinancialData, mockAgentStats, mockAgentList, mockWithdrawInfo, mockBanks, createMockResponse } from './mockData.js'
|
import {
|
||||||
|
mockUserInfo,
|
||||||
|
mockFinancialData,
|
||||||
|
mockAgentStats,
|
||||||
|
mockAgentList,
|
||||||
|
mockWithdrawInfo,
|
||||||
|
mockBanks,
|
||||||
|
createMockResponse,
|
||||||
|
} from './mockData.js'
|
||||||
import { uploadFile } from '@/utils/request.js'
|
import { uploadFile } from '@/utils/request.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -11,24 +19,26 @@ export function getUserInfo() {
|
||||||
url: '/app/user/getUser',
|
url: '/app/user/getUser',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
showLoading: false,
|
showLoading: false,
|
||||||
}).then(response => {
|
|
||||||
// 如果API调用成功,将用户ID存入本地存储
|
|
||||||
if (response.code === 200 && response.data && response.data.userId) {
|
|
||||||
uni.setStorageSync('userId', response.data.userId)
|
|
||||||
console.log('用户ID已存入本地存储:', response.data.userId)
|
|
||||||
}
|
|
||||||
return response
|
|
||||||
}).catch(error => {
|
|
||||||
console.warn('用户信息API调用失败,使用模拟数据:', error)
|
|
||||||
// 如果API调用失败,返回模拟数据
|
|
||||||
const mockResponse = createMockResponse(mockUserInfo)
|
|
||||||
// 模拟数据中如果有用户ID,也存入本地存储
|
|
||||||
if (mockResponse.data && mockResponse.data.userId) {
|
|
||||||
uni.setStorageSync('userId', mockResponse.data.userId)
|
|
||||||
console.log('模拟数据用户ID已存入本地存储:', mockResponse.data.userId)
|
|
||||||
}
|
|
||||||
return mockResponse
|
|
||||||
})
|
})
|
||||||
|
.then(response => {
|
||||||
|
// 如果API调用成功,将用户ID存入本地存储
|
||||||
|
if (response.code === 200 && response.data && response.data.userId) {
|
||||||
|
uni.setStorageSync('userId', response.data.userId)
|
||||||
|
console.log('用户ID已存入本地存储:', response.data.userId)
|
||||||
|
}
|
||||||
|
return response
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.warn('用户信息API调用失败,使用模拟数据:', error)
|
||||||
|
// 如果API调用失败,返回模拟数据
|
||||||
|
const mockResponse = createMockResponse(mockUserInfo)
|
||||||
|
// 模拟数据中如果有用户ID,也存入本地存储
|
||||||
|
if (mockResponse.data && mockResponse.data.userId) {
|
||||||
|
uni.setStorageSync('userId', mockResponse.data.userId)
|
||||||
|
console.log('模拟数据用户ID已存入本地存储:', mockResponse.data.userId)
|
||||||
|
}
|
||||||
|
return mockResponse
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -78,7 +88,7 @@ export function getAgentCount() {
|
||||||
return createMockResponse({
|
return createMockResponse({
|
||||||
userNum: 4,
|
userNum: 4,
|
||||||
deviceNum: 1,
|
deviceNum: 1,
|
||||||
rentAmount: 2
|
rentAmount: 2,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -87,7 +97,7 @@ export function getAgentCount() {
|
||||||
* 获取代理用户列表
|
* 获取代理用户列表
|
||||||
* @param {Object} params - 查询参数
|
* @param {Object} params - 查询参数
|
||||||
* @param {string} params.beginTime - 开始时间
|
* @param {string} params.beginTime - 开始时间
|
||||||
* @param {string} params.endTime - 结束时间
|
* @param {string} params.endTime - 结束时间
|
||||||
* @param {string} params.name - 用户昵称搜索
|
* @param {string} params.name - 用户昵称搜索
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
|
|
@ -157,7 +167,7 @@ export function getUserAvatar(userId) {
|
||||||
params: { userId },
|
params: { userId },
|
||||||
showLoading: false,
|
showLoading: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取提现信息
|
* 获取提现信息
|
||||||
|
|
@ -174,6 +184,21 @@ export function getWithdrawInfo() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取服务费用明细
|
||||||
|
* @returns {Promise} 返回服务费用明细
|
||||||
|
*/
|
||||||
|
export function computedServiceAmount() {
|
||||||
|
return request({
|
||||||
|
url: '/app/withdraw/serviceAmount',
|
||||||
|
method: 'GET',
|
||||||
|
showLoading: false,
|
||||||
|
}).catch(error => {
|
||||||
|
console.warn('服务费用API调用失败,使用模拟数据:', error)
|
||||||
|
return createMockResponse(mockWithdrawInfo)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提交提现申请
|
* 提交提现申请
|
||||||
* @param {Object} data 提现数据
|
* @param {Object} data 提现数据
|
||||||
|
|
@ -191,7 +216,7 @@ export function submitWithdraw(data) {
|
||||||
console.warn('提现申请API调用失败:', error)
|
console.warn('提现申请API调用失败:', error)
|
||||||
throw error
|
throw error
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传头像
|
* 上传头像
|
||||||
|
|
@ -199,24 +224,32 @@ export function submitWithdraw(data) {
|
||||||
* @returns {Promise} 返回上传结果
|
* @returns {Promise} 返回上传结果
|
||||||
*/
|
*/
|
||||||
export function uploadAvatar(filePath) {
|
export function uploadAvatar(filePath) {
|
||||||
return uploadFile('/app/user/avatar', filePath, 'avatarfile', {}, {
|
return uploadFile(
|
||||||
timeout: 60000
|
'/app/user/avatar',
|
||||||
}).then(data => {
|
filePath,
|
||||||
// 上传成功后更新本地存储
|
'avatarfile',
|
||||||
const userInfo = uni.getStorageSync('userInfo') || {}
|
{},
|
||||||
userInfo.avatar = data.data?.avatar || data.data
|
{
|
||||||
uni.setStorageSync('userInfo', userInfo)
|
timeout: 60000,
|
||||||
|
}
|
||||||
// 通知其他页面更新头像
|
)
|
||||||
uni.$emit('avatarUpdated', userInfo.avatar)
|
.then(data => {
|
||||||
|
// 上传成功后更新本地存储
|
||||||
console.log('头像上传成功,已更新本地存储:', userInfo.avatar)
|
const userInfo = uni.getStorageSync('userInfo') || {}
|
||||||
return data
|
userInfo.avatar = data.data?.avatar || data.data
|
||||||
}).catch(error => {
|
uni.setStorageSync('userInfo', userInfo)
|
||||||
console.error('头像上传失败:', error)
|
|
||||||
throw error
|
// 通知其他页面更新头像
|
||||||
})
|
uni.$emit('avatarUpdated', userInfo.avatar)
|
||||||
}
|
|
||||||
|
console.log('头像上传成功,已更新本地存储:', userInfo.avatar)
|
||||||
|
return data
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('头像上传失败:', error)
|
||||||
|
throw error
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取本地存储的用户ID
|
* 获取本地存储的用户ID
|
||||||
|
|
@ -232,4 +265,4 @@ export function getLocalUserId() {
|
||||||
export function clearLocalUserId() {
|
export function clearLocalUserId() {
|
||||||
uni.removeStorageSync('userId')
|
uni.removeStorageSync('userId')
|
||||||
console.log('本地用户ID已清除')
|
console.log('本地用户ID已清除')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -127,8 +127,8 @@ export default {
|
||||||
balance: '10000.00',
|
balance: '10000.00',
|
||||||
unsettled: '0.00',
|
unsettled: '0.00',
|
||||||
available: '10000.00',
|
available: '10000.00',
|
||||||
fee: 1.0,
|
fee: 5.0,
|
||||||
minAmount: 100.0,
|
minAmount: 5.0,
|
||||||
maxAmount: 50000.0,
|
maxAmount: 50000.0,
|
||||||
},
|
},
|
||||||
withdrawalData: {
|
withdrawalData: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user