<template>
    <view class="container" style="paddingBottom:1rpx;">
      <u-navbar
			leftIconSize="40rpx"
			leftIconColor="#ffffff"
			title="投资交易记录详情"
			:bgColor="'linear-gradient(135deg, #667eea 0%, #764ba2 100%)'"
			:titleStyle="{ color: '#ffffff', fontSize: '36rpx', fontWeight: '600' }"
		>
		</u-navbar>
      
      <view class="header-card">
        <view class="header-icon">
          <uni-icons type="bars" size="28" color="#ffffff"></uni-icons>
        </view>
        <text class="account-name">{{ detailInfo.accountName }}</text>
        <text class="type-text" :class="detailInfo.dealType === '亏损' ? 'loss' : 'profit'">{{ detailInfo.dealType }}</text>
        <text class="amount-value" :class="detailInfo.dealType === '亏损' ? 'loss' : 'profit'">{{ detailInfo.dealType === '亏损' ? '-' : '+' }}{{ detailInfo.amount }}元</text>
      </view>
      
      <view class="detail-card">
        <view class="card-body">
          <view class="info-section">
            <view class="section-title">
              <view class="title-icon"></view>
              <text>交易信息</text>
            </view>
            <view class="info-list">
              <view class="list-item">
                <text class="item-label">账户类型</text>
                <text class="item-value">{{ detailInfo.type }}</text>
              </view>
              <view class="list-item">
                <text class="item-label">交易类别</text>
                <text class="item-value">{{ detailInfo.dealCategory }}</text>
              </view>
              <view class="list-item">
                <text class="item-label">余额</text>
                <text class="item-value orange">{{ detailInfo.currentBalance }}元</text>
              </view>
              <view class="list-item">
                <text class="item-label">交易时间</text>
                <text class="item-value">{{ detailInfo.createTime }}</text>
              </view>
            </view>
          </view>
          
          <view class="info-section" v-if="detailInfo.remark">
            <view class="section-title">
              <view class="title-icon"></view>
              <text>备注</text>
            </view>
            <view class="remark-content">
              <text>{{ detailInfo.remark }}</text>
            </view>
          </view>
        </view>
      </view>
   
      <u-toast ref="uToast"></u-toast>
    </view>
  </template>
  
<script setup>
import { getAccountDealRecord} from '@/api/invest/accountDealRecord'
import {onLoad} from "@dcloudio/uni-app";
import { getDicts } from '@/api/system/dict/data.js'
import {reactive ,toRefs,ref,computed }from "vue";
const id = ref('')
const data = reactive({
  detailInfo: {} 
})
const {detailInfo} = toRefs(data)
onLoad((option) => {
    id.value = option.id
    getInfo()
  })
  function getInfo() {
    getAccountDealRecord(id.value).then(res => {
          detailInfo.value = res.data
          // 类型
        getDicts('account_type').then(result => {
          detailInfo.value.type=dictStr(detailInfo.value.type, result.data)
      })
       // 类型
          getDicts('profit_loss').then(result => {
         detailInfo.value.dealType=dictStr(detailInfo.value.dealType, result.data)
      })
          // 类型
        getDicts('deal_category').then(result => {
         detailInfo.value.dealCategory=dictStr(detailInfo.value.dealCategory, result.data)
      })
        })
  }
  function dictStr(val, arr) {
      let str = ''
      arr.map(item => {
        if (item.dictValue === val) {
          str = item.dictLabel
        }
      })
      return str
    }
  </script>
  
  <style lang="scss" scoped>
  page {
    overflow: hidden;
  }
  

  
.header-card {
  margin: 24rpx;
  padding: 24rpx;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 16rpx;
  box-shadow: 0 6rpx 20rpx rgba(102, 126, 234, 0.25);
  display: flex;
  align-items: center;
  gap: 16rpx;
  
  .header-icon {
    width: 48rpx;
    height: 48rpx;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  
  .account-name {
    font-size: 28rpx;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.2;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .type-text {
    font-size: 28rpx;
    font-weight: 600;
    line-height: 1;
    flex-shrink: 0;
    margin-right: 8rpx;
    
    &.profit {
      color: #52c41a;
    }
    
    &.loss {
      color: #f5576c;
    }
  }
  
  .amount-value {
    font-size: 32rpx;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
    
    &.profit {
      color: #52c41a;
    }
    
    &.loss {
      color: #f5576c;
    }
  }
}

.detail-card {
  margin: 24rpx;
  background: #ffffff;
  border-radius: 16rpx;
  box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.card-body {
  padding: 24rpx;
}

.info-section {
  margin-bottom: 32rpx;
  
  &:last-child {
    margin-bottom: 0;
  }
  
  .section-title {
    display: flex;
    align-items: center;
    margin-bottom: 20rpx;
    
    .title-icon {
      width: 6rpx;
      height: 28rpx;
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      border-radius: 3rpx;
      margin-right: 12rpx;
    }
    
    text {
      color: #2c3e50;
      font-size: 28rpx;
      font-weight: 600;
    }
  }
  
  .info-list {
    .list-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 20rpx;
      background: #f8f9fa;
      border-radius: 8rpx;
      margin-bottom: 12rpx;
      
      &:last-child {
        margin-bottom: 0;
      }
      
      .item-label {
        color: #7f8c8d;
        font-size: 26rpx;
      }
      
      .item-value {
        color: #2c3e50;
        font-size: 28rpx;
        font-weight: 500;
        text-align: right;
        
        &.orange {
          color: #fa8c16;
        }
      }
    }
  }
  
  .remark-content {
    padding: 20rpx;
    background: #f8f9fa;
    border-radius: 8rpx;
    
    text {
      color: #2c3e50;
      font-size: 26rpx;
      line-height: 1.6;
    }
  }
}
</style>