fix: 修复detail页面u-card组件用法和toast调用
- u-card内容需要用<template #body>包裹 - uni.$u.toast.* 替换为 uni.showToast/showLoading/hideLoading - uni.$u.showModal 替换为 uni.showModal
This commit is contained in:
parent
c8dc511560
commit
3f692e0f74
@ -51,8 +51,11 @@
|
|||||||
v-if="portfolioData.logicModel"
|
v-if="portfolioData.logicModel"
|
||||||
:border="false"
|
:border="false"
|
||||||
:shadow="false"
|
:shadow="false"
|
||||||
|
:show-head="false"
|
||||||
|
:show-foot="false"
|
||||||
class="strategy-info-card"
|
class="strategy-info-card"
|
||||||
>
|
>
|
||||||
|
<template #body>
|
||||||
<view class="st-left">
|
<view class="st-left">
|
||||||
<view class="st-icon-box bg-green-100">
|
<view class="st-icon-box bg-green-100">
|
||||||
<text class="st-icon-text text-green">{{ portfolioData.logicModel?.charAt(0) || 'S' }}</text>
|
<text class="st-icon-text text-green">{{ portfolioData.logicModel?.charAt(0) || 'S' }}</text>
|
||||||
@ -71,6 +74,7 @@
|
|||||||
<text class="st-status-text">{{ portfolioData.logicModelStatus || '监控中' }}</text>
|
<text class="st-status-text">{{ portfolioData.logicModelStatus || '监控中' }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
</template>
|
||||||
</u-card>
|
</u-card>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@ -86,8 +90,11 @@
|
|||||||
:key="item.id || index"
|
:key="item.id || index"
|
||||||
:border="false"
|
:border="false"
|
||||||
:shadow="false"
|
:shadow="false"
|
||||||
|
:show-head="false"
|
||||||
|
:show-foot="false"
|
||||||
class="position-card"
|
class="position-card"
|
||||||
>
|
>
|
||||||
|
<template #body>
|
||||||
<view class="pos-top">
|
<view class="pos-top">
|
||||||
<view class="flex-row items-center gap-2">
|
<view class="flex-row items-center gap-2">
|
||||||
<view class="stock-icon" :class="index % 2 === 0 ? 'bg-blue-100 text-blue' : 'bg-orange-100 text-orange'">
|
<view class="stock-icon" :class="index % 2 === 0 ? 'bg-blue-100 text-blue' : 'bg-orange-100 text-orange'">
|
||||||
@ -127,6 +134,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
</template>
|
||||||
</u-card>
|
</u-card>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -430,7 +438,7 @@ const fetchPortfolioData = async () => {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取投资组合数据失败:', error);
|
console.error('获取投资组合数据失败:', error);
|
||||||
uni.$u.toast.error('加载失败,请重试');
|
uni.showToast({ title: '加载失败,请重试', icon: 'none' });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -450,7 +458,7 @@ const fetchTransactions = async () => {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取交易记录失败:', error);
|
console.error('获取交易记录失败:', error);
|
||||||
uni.$u.toast.error('加载交易记录失败');
|
uni.showToast({ title: '加载交易记录失败', icon: 'none' });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -508,18 +516,18 @@ const resetTransactionForm = () => {
|
|||||||
const submitTransaction = async () => {
|
const submitTransaction = async () => {
|
||||||
// 表单验证
|
// 表单验证
|
||||||
if (!transactionForm.value.stockCode) {
|
if (!transactionForm.value.stockCode) {
|
||||||
return uni.$u.toast.error(transactionType.value === 'sell' ? '请选择要卖出的持仓' : '请输入股票代码');
|
return uni.showToast({ title: transactionType.value === 'sell' ? '请选择要卖出的持仓' : '请输入股票代码', icon: 'none' });
|
||||||
}
|
}
|
||||||
const amount = parseFloat(transactionForm.value.amount);
|
const amount = parseFloat(transactionForm.value.amount);
|
||||||
if (!amount || amount <= 0) {
|
if (!amount || amount <= 0) {
|
||||||
return uni.$u.toast.error('请输入有效的数量');
|
return uni.showToast({ title: '请输入有效的数量', icon: 'none' });
|
||||||
}
|
}
|
||||||
// 卖出时校验数量不超过持仓
|
// 卖出时校验数量不超过持仓
|
||||||
if (transactionType.value === 'sell' && amount > maxSellAmount.value) {
|
if (transactionType.value === 'sell' && amount > maxSellAmount.value) {
|
||||||
return uni.$u.toast.error(`卖出数量不能超过持仓数量 ${maxSellAmount.value}`);
|
return uni.showToast({ title: `卖出数量不能超过持仓数量 ${maxSellAmount.value}`, icon: 'none' });
|
||||||
}
|
}
|
||||||
if (!transactionForm.value.price || parseFloat(transactionForm.value.price) <= 0) {
|
if (!transactionForm.value.price || parseFloat(transactionForm.value.price) <= 0) {
|
||||||
return uni.$u.toast.error('请输入有效的价格');
|
return uni.showToast({ title: '请输入有效的价格', icon: 'none' });
|
||||||
}
|
}
|
||||||
|
|
||||||
const transactionData = {
|
const transactionData = {
|
||||||
@ -533,12 +541,13 @@ const submitTransaction = async () => {
|
|||||||
remark: transactionForm.value.remark
|
remark: transactionForm.value.remark
|
||||||
};
|
};
|
||||||
|
|
||||||
uni.$u.toast.loading('提交中...');
|
uni.showLoading({ title: '提交中...', mask: true });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await api.assets.createTransaction(transactionData);
|
const response = await api.assets.createTransaction(transactionData);
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
uni.$u.toast.success('交易提交成功');
|
uni.hideLoading();
|
||||||
|
uni.showToast({ title: '交易提交成功', icon: 'success' });
|
||||||
showTransactionForm.value = false;
|
showTransactionForm.value = false;
|
||||||
|
|
||||||
// 重新获取交易记录
|
// 重新获取交易记录
|
||||||
@ -548,20 +557,21 @@ const submitTransaction = async () => {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('创建交易失败:', error);
|
console.error('创建交易失败:', error);
|
||||||
uni.$u.toast.error('提交失败,请重试');
|
uni.hideLoading();
|
||||||
|
uni.showToast({ title: '提交失败,请重试', icon: 'none' });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 删除组合
|
// 删除组合
|
||||||
const deletePortfolio = async () => {
|
const deletePortfolio = async () => {
|
||||||
uni.$u.showModal({
|
uni.showModal({
|
||||||
title: '确认删除',
|
title: '确认删除',
|
||||||
content: '删除后所有持仓和交易记录都会丢失,确定要删除这个组合吗?',
|
content: '删除后所有持仓和交易记录都会丢失,确定要删除这个组合吗?',
|
||||||
confirmText: '删除',
|
confirmText: '删除',
|
||||||
confirmColor: '#EF4444',
|
confirmColor: '#EF4444',
|
||||||
success: async (res) => {
|
success: async (res) => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
uni.$u.toast.loading('删除中');
|
uni.showLoading({ title: '删除中', mask: true });
|
||||||
try {
|
try {
|
||||||
// 调用删除组合接口
|
// 调用删除组合接口
|
||||||
const response = await uni.request({
|
const response = await uni.request({
|
||||||
@ -573,13 +583,15 @@ const deletePortfolio = async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (response.statusCode === 200) {
|
if (response.statusCode === 200) {
|
||||||
uni.$u.toast.success('删除成功');
|
uni.hideLoading();
|
||||||
|
uni.showToast({ title: '删除成功', icon: 'success' });
|
||||||
setTimeout(() => uni.switchTab({ url: '/pages/index/index' }), 1500);
|
setTimeout(() => uni.switchTab({ url: '/pages/index/index' }), 1500);
|
||||||
} else {
|
} else {
|
||||||
throw new Error('删除失败');
|
throw new Error('删除失败');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
uni.$u.toast.error('删除失败,请重试');
|
uni.hideLoading();
|
||||||
|
uni.showToast({ title: '删除失败,请重试', icon: 'none' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user