feat: 1. 新增策略删除功能(编辑页);2. 新增组合删除功能(详情页);3. 限制货币选择框宽度,避免过长
This commit is contained in:
parent
beb96c535f
commit
6c8900ecd5
@ -134,6 +134,9 @@
|
||||
</view>
|
||||
|
||||
<view class="action-section fixed-bottom">
|
||||
<button class="action-btn btn-delete" @click="deletePortfolio">
|
||||
<uni-icons type="trash" size="20" color="#DC2626"></uni-icons>
|
||||
</button>
|
||||
<button class="action-btn btn-buy" @click="handleBuy">
|
||||
<uni-icons type="download" size="20" color="#FFFFFF"></uni-icons>
|
||||
<text class="btn-text">增加</text>
|
||||
@ -441,6 +444,40 @@ const submitTransaction = async () => {
|
||||
uni.showToast({ title: '提交失败,请重试', icon: 'none' });
|
||||
}
|
||||
};
|
||||
|
||||
// 删除组合
|
||||
const deletePortfolio = async () => {
|
||||
uni.showModal({
|
||||
title: '确认删除',
|
||||
content: '删除后所有持仓和交易记录都会丢失,确定要删除这个组合吗?',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
uni.showLoading({ title: '删除中' });
|
||||
try {
|
||||
// 调用删除组合接口
|
||||
const response = await uni.request({
|
||||
url: `${import.meta.env.VITE_API_BASE_URL || 'https://localhost:7040/'}api/v1/portfolio/${portfolioId.value}`,
|
||||
method: 'DELETE',
|
||||
header: {
|
||||
'Authorization': `Bearer ${uni.getStorageSync('token')}`
|
||||
}
|
||||
});
|
||||
|
||||
if (response.statusCode === 200) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: '删除成功', icon: 'success' });
|
||||
setTimeout(() => uni.switchTab({ url: '/pages/index/index' }), 1500);
|
||||
} else {
|
||||
throw new Error('删除失败');
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: '删除失败,请重试', icon: 'none' });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@ -612,6 +649,14 @@ const submitTransaction = async () => {
|
||||
padding: 0 16rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.btn-delete {
|
||||
flex: 0 0 96rpx;
|
||||
background-color: #FEE2E2;
|
||||
color: #DC2626;
|
||||
}
|
||||
.btn-delete:active {
|
||||
background-color: #FECACA;
|
||||
}
|
||||
.btn-text {
|
||||
font-size: 30rpx;
|
||||
font-weight: 700;
|
||||
@ -763,6 +808,7 @@ const submitTransaction = async () => {
|
||||
|
||||
.form-select {
|
||||
width: 100%;
|
||||
max-width: 200rpx; /* 限制货币选择框最大宽度 */
|
||||
height: 72rpx;
|
||||
border: 1rpx solid #E5E7EB;
|
||||
border-radius: 12rpx;
|
||||
|
||||
@ -171,7 +171,11 @@
|
||||
</view>
|
||||
|
||||
<view class="footer-bar">
|
||||
<button class="submit-btn" @click="submit">{{ isEditMode ? '更新策略配置' : '保存策略配置' }}</button>
|
||||
<view class="btn-row" v-if="isEditMode">
|
||||
<button class="delete-btn" @click="deleteStrategy">删除策略</button>
|
||||
<button class="submit-btn" @click="submit">更新策略配置</button>
|
||||
</view>
|
||||
<button class="submit-btn" @click="submit" v-else>保存策略配置</button>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
@ -484,6 +488,28 @@ const loadStrategyDetail = async (id) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 删除策略
|
||||
const deleteStrategy = async () => {
|
||||
uni.showModal({
|
||||
title: '确认删除',
|
||||
content: '删除后无法恢复,确定要删除这个策略吗?',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
uni.showLoading({ title: '删除中' });
|
||||
try {
|
||||
await api.strategies.deleteStrategy(strategyId.value);
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: '删除成功', icon: 'success' });
|
||||
setTimeout(() => uni.navigateBack(), 1500);
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: '删除失败,请重试', icon: 'none' });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 页面加载时检查是否是编辑模式
|
||||
onMounted(() => {
|
||||
const pages = getCurrentPages();
|
||||
@ -818,7 +844,12 @@ onMounted(() => {
|
||||
box-shadow: 0 -4rpx 16rpx rgba(0,0,0,0.05);
|
||||
z-index: 99;
|
||||
}
|
||||
.btn-row {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
}
|
||||
.submit-btn {
|
||||
flex: 1;
|
||||
background-color: #064E3B;
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
@ -826,7 +857,18 @@ onMounted(() => {
|
||||
height: 96rpx;
|
||||
line-height: 96rpx;
|
||||
font-size: 30rpx;
|
||||
width: 100%;
|
||||
}
|
||||
.submit-btn:active { opacity: 0.9; }
|
||||
.delete-btn {
|
||||
flex: 0 0 120rpx;
|
||||
background-color: #FEE2E2;
|
||||
color: #DC2626;
|
||||
font-weight: 700;
|
||||
border-radius: 24rpx;
|
||||
height: 96rpx;
|
||||
line-height: 96rpx;
|
||||
font-size: 24rpx;
|
||||
border: none;
|
||||
}
|
||||
.delete-btn:active { background-color: #FECACA; }
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user