<template>
  <view class="container">
    <!-- 金额显示 -->
    <view class="amount-section">
      <text class="amount">{{ balanceDetail.prefix == 1 ? "+" : "-" }}{{ balanceDetail.amount }}</text>
      <text class="description">{{ balanceDetail.description }}</text>
    </view>

    <!-- 交易信息 -->
    <view class="details-section">
      <view class="detail-item">
        <text class="label">交易类型</text>
        <text class="value">{{ balanceDetail.prefix == 1 ? "收入" : "支出" }}</text>
      </view>
      <view class="detail-item">
        <text class="label">交易时间</text>
        <text class="value">{{ common.timestampToString(balanceDetail.insert_time) }}</text>
      </view>
      <view class="detail-item">
        <text class="label">记录编码</text>
        <text class="value">{{ balanceDetail.id_code }}</text>
      </view>
      <view class="detail-item">
        <text class="label">交易后余额</text>
        <text class="value">￥{{ balanceDetail.balance }}</text>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref } from "vue";
import { onLoad } from "@dcloudio/uni-app";

import http from "@/utils/request";
import common from "@/utils/common";

const balanceDetail = ref({});

onLoad((options) => {
  // 获取传递的参数
  _getBalanceDetail(options.record_id);
});

const _getBalanceDetail = async (record_id) => {
  const callback = await http.request("api/custom_amount/get_record_info", { record_id });
  if (callback.code == "success") {
    balanceDetail.value = callback.data;
  }
};
</script>

<style scoped>
/* 容器样式 */
.container {
  padding: 16px;
  background-color: #ffffff;
  min-height: 100vh;
  font-size: 16px;
}

/* 金额显示样式 */
.amount-section {
  margin: 20px 0;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.amount {
  font-size: 32px;
  color: #ff5e00;
  font-weight: bold;
}

.description {
  font-size: 16px;
  color: #666;
  margin-top: 5px;
}

/* 交易详情样式 */
.details-section {
  margin-top: 20px;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
}

.label {
  color: #666;
}

.value {
  color: #333;
}
</style>
