<template>
  <view class="work-container">

    <!-- 账单统计分析 -->
    <view class="section-header" v-show="auth.hasPermi('invest:creditAnalysis:list')">
      <text class="section-title">账单统计分析</text>
    </view>
    <view class="grid-body" v-show="auth.hasPermi('invest:creditAnalysis:list')">
      <view class="grid-wrapper">
        <view 
          v-for="(item, index) in billGridList" 
          :key="index" 
          v-show="auth.hasPermi(item.permission)" 
          @click="navigateTo(item.path)"
          class="grid-item">
          <view class="item-icon" :style="{ background: item.color }">
            <uni-icons :type="item.icon" size="22" color="#ffffff"></uni-icons>
          </view>
          <text class="item-text">{{ item.text }}</text>
        </view>
      </view>
    </view>

    <!-- 记账统计分析 -->
    <view class="section-header" v-show="auth.hasPermi('invest:accountsBalance:list')">
      <text class="section-title">记账统计分析</text>
    </view>
    <view class="grid-body" v-show="auth.hasPermi('invest:accountsBalance:list')">
      <view class="grid-wrapper">
        <view 
          v-for="(item, index) in accountGridList" 
          :key="index" 
          v-show="auth.hasPermi(item.permission)" 
          @click="navigateTo(item.path)"
          class="grid-item">
          <view class="item-icon" :style="{ background: item.color }">
            <uni-icons :type="item.icon" size="22" color="#ffffff"></uni-icons>
          </view>
          <text class="item-text">{{ item.text }}</text>
        </view>
      </view>
    </view>

    <!-- 投资统计分析 -->
    <view class="section-header" v-show="auth.hasPermi('invest:accountsBalance:list')">
      <text class="section-title">投资统计分析</text>
    </view>
    <view class="grid-body" v-show="auth.hasPermi('invest:accountsBalance:list')">
      <view class="grid-wrapper">
        <view 
          v-for="(item, index) in investGridList" 
          :key="index" 
          v-show="auth.hasPermi(item.permission)" 
          @click="navigateTo(item.path)"
          class="grid-item">
          <view class="item-icon" :style="{ background: item.color }">
            <uni-icons :type="item.icon" size="22" color="#ffffff"></uni-icons>
          </view>
          <text class="item-text">{{ item.text }}</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
	import { ref } from "vue";
  import auth from "@/plugins/auth"; // 建议使用auth进行鉴权操作
  const billGridList=ref([
        { path: '/pages/statistic/bill/creditBillAnalysis/index', text: '信用卡账单统计', icon: 'wallet-filled', color: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)', permission: 'invest:creditAnalysis:list'  },
        { path: '/pages/statistic/bill/creditInstallmentAnalysis/index', text: '信用卡分期待还', icon: 'calendar-filled', color: 'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)', permission: 'invest:creditInstallment:list'  },
        { path: '/pages/statistic/bill/creditInstallmentSettledAnalysis/index', text: '信用卡分期已还', icon: 'checkmarkempty', color: 'linear-gradient(135deg, #11998e 0%, #38ef7d 100%)', permission: 'invest:creditInstallmentSettledAnalysis:list'  },
        { path: '/pages/statistic/bill/onlineLendAnalysis/index', text: '贷款待还统计', icon: 'upload-filled', color: 'linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%)', permission: 'invest:onlineLendAnalysis:list'  },
        { path: '/pages/statistic/bill/onlineLendSettledAnalysis/index', text: '贷款已还统计', icon: 'download-filled', color: 'linear-gradient(135deg, #0be881 0%, #0fbcf9 100%)', permission: 'invest:onlineLendSettledAnalysis:list'  },
        { path: '/pages/statistic/bill/creditRecordAnalysis/index', text: '征信查询统计', icon: 'search', color: 'linear-gradient(135deg, #5f72bd 0%, #9b23ea 100%)', permission: 'invest:creditRecordAnalysis:list'  }
      ])
      const accountGridList=ref([
        { path: '/pages/statistic/accounts/accountsBalance/index', text: '记账账户统计', icon: 'home-filled', color: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)', permission: 'invest:accountsBalance:list' },
        { path: '/pages/statistic/accounts/accountDealAnalysis/index', text: '账户收支统计', icon: 'list', color: 'linear-gradient(135deg, #fa709a 0%, #fee140 100%)', permission: 'invest:accountDealAnalysis:list'  },
        { path: '/pages/statistic/accounts/dailyExpensesAnalysis/index', text: '日常支出统计', icon: 'wallet', color: 'linear-gradient(135deg, #f6d365 0%, #fda085 100%)', permission: 'invest:dailyExpensesAnalysis:list' },
        { path: '/pages/statistic/accounts/creditCardDealAnalysis/index', text: '信用卡收支统计', icon: 'vip-filled', color: 'linear-gradient(135deg, #d38cff 0%, #9d50bb 100%)', permission: 'invest:creditCard' },
        { path: '/pages/statistic/accounts/debitDealAnalysis/index', text: '储蓄账户统计', icon: 'paperplane', color: 'linear-gradient(135deg, #00b4db 0%, #0083b0 100%)', permission: 'invest:debitCard'  },
        { path: '/pages/statistic/accounts/debitCardAnalysis/index', text: '结算卡统计', icon: 'star', color: 'linear-gradient(135deg, #fa8231 0%, #f7971e 100%)', permission: 'invest:debitCardAnalysis:list' },
        { path: '/pages/statistic/accounts/posStatics/index', text: 'POS机统计', icon: 'navigate-filled', color: 'linear-gradient(135deg, #0be881 0%, #0fbcf9 100%)', permission: 'invest:posmachine:list' },
        { path: '/pages/statistic/accounts/posAnalysis/index', text: 'POS刷卡统计', icon: 'scan', color: 'linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%)', permission: 'invest:posStatics:list' },
        { path: '/pages/statistic/accounts/sleepAccounts/index', text: '睡眠账户统计', icon: 'eye-slash-filled', color: 'linear-gradient(135deg, #636e72 0%, #2d3436 100%)', permission: 'invest:debitCard' },
        { path: '/pages/statistic/accounts/openCardStatics/index', text: '储蓄卡开卡统计', icon: 'gift-filled', color: 'linear-gradient(135deg, #fd79a8 0%, #e84393 100%)', permission: 'invest:debitCard' },
        { path: '/pages/statistic/accounts/dailyLiabilities/index', text: '每日净资产统计', icon: 'bars', color: 'linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%)', permission: 'invest:dailyLiabilities:list' },
      ])
      const investGridList=ref([
      { path: '/pages/statistic/accounts/investDealAnalysis/index', text: '投资收益统计', icon: 'arrow-up', color: 'linear-gradient(135deg, #11998e 0%, #38ef7d 100%)', permission: 'invest:investDealAnalysis:list'  },
      { path: '/pages/statistic/bill/investAnalysis/index', text: '收益统计分析', icon: 'settings', color: 'linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%)', permission: 'invest:investAnalysis:list'},
      { path: '/pages/statistic/bill/futuresAnalysis/index', text: '期货统计分析', icon: 'fire', color: 'linear-gradient(135deg, #fc5c65 0%, #fd79a8 100%)', permission: 'invest:futuresAnalysis:list'},
      { path: '/pages/statistic/bill/stocksAnalysis/index', text: '股票统计分析', icon: 'flag-filled', color: 'linear-gradient(135deg, #5f72bd 0%, #9b23ea 100%)', permission: 'invest:stocksAnalysis:list'  }
      ])
	function navigateTo(path) {
    uni.navigateTo({
        url: path
      });
	}

</script>

<style lang="scss">
  /* #ifndef APP-NVUE */
  page {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    background-color: #f5f7fa;
    min-height: 100%;
    height: auto;
  }

  /* #endif */

  .work-container {
    padding: 12rpx 0;
  }

  .section-header {
    padding: 12rpx 24rpx 8rpx;
  }

  .section-title {
    font-size: 28rpx;
    font-weight: 700;
    color: #333;
    position: relative;
    padding-left: 16rpx;
  }

  .section-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6rpx;
    height: 28rpx;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 3rpx;
  }

  .grid-body {
    padding: 0 16rpx;
  }

  .grid-wrapper {
    display: flex;
    flex-wrap: wrap;
  }

  .grid-item {
    width: 25%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16rpx 8rpx;
    box-sizing: border-box;
  }

  .item-icon {
    width: 80rpx;
    height: 80rpx;
    border-radius: 20rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12rpx;
    box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
  }

  .grid-item:active .item-icon {
    transform: scale(0.95);
    box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.15);
  }

  .item-text {
    text-align: center;
    font-size: 22rpx;
    color: #333;
    font-weight: 500;
    line-height: 1.3;
  }
</style>
