<template>
  <view class="content">
    <!-- 基础信息 -->
    <view class="section-header" v-show="auth.hasPermi('invest:bankcard:list')">
      <text class="section-title">基础信息</text>
    </view>
    <view class="grid-body" v-show="auth.hasPermi('invest:bankcard:list')">
      <view class="grid-wrapper">
        <view 
          v-for="(item, index) in baseGridList" 
          :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:accounts:list')">
      <text class="section-title">记账管理</text>
    </view>
    <view class="grid-body" v-show="auth.hasPermi('invest:accounts: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:installmentHistory:list')">
      <text class="section-title">账单管理</text>
    </view>
    <view class="grid-body" v-show="auth.hasPermi('invest:installmentHistory: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>
  <!-- <refresh></refresh> -->
</template>

<script setup>
import auth from "@/plugins/auth"; // 建议使用auth进行鉴权操作

// 也可以使用下面的方式
	import { ref } from "vue";
  const commonGridList=ref([
      
      ])
  const baseGridList=ref([
        { path: '/pages/work/base/debitCard/list', text: '储蓄账户管理', icon: 'home-filled', color: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)', permission: 'invest:debitCard'  },
        { path: '/pages/work/base/creditCard/list', text: '信用卡管理', icon: 'vip-filled', color: 'linear-gradient(135deg, #fa709a 0%, #fee140 100%)', permission: 'invest:creditCard'  },
        { path: '/pages/work/base/lend/list', text: '借贷账户管理', icon: 'upload-filled', color: 'linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%)', permission: 'invest:onlineLend'  },
         { path: '/pages/work/product/productInfor/list', text: '商品信息', icon: 'gift-filled', color: 'linear-gradient(135deg, #fd79a8 0%, #e84393 100%)', permission: 'invest:productInfor:list'  },
        { path: '/pages/work/base/posmachine/list', text: 'pos机管理', icon: 'navigate-filled', color: 'linear-gradient(135deg, #0be881 0%, #0fbcf9 100%)', permission: 'invest:posmachine:list' },
        { path: '/pages/work/base/financials/list', text: '理财账户管理', icon: 'star', color: 'linear-gradient(135deg, #f6d365 0%, #fda085 100%)', permission: 'invest:futureStocks:list'  },
        { path: '/pages/work/base/stocks/list', text: '股票账户管理', icon: 'arrow-up', color: 'linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%)', permission: 'invest:futureStocks:list'  },
        { path: '/pages/work/base/futures/list', text: '期货账户管理', icon: 'fire', color: 'linear-gradient(135deg, #fc5c65 0%, #fd79a8 100%)', permission: 'invest:futureStocks:list'  },
        { path: '/pages/work/base/bankBaseInfo/list', text: '银行基础信息', icon: 'home', color: 'linear-gradient(135deg, #5b51d8 0%, #6b21a8 100%)', permission: 'invest:bankBaseInfo:list'  },

      ])
      const billGridList=ref([
         { path: '/pages/work/bill/creditCardBill/list', text: '信用卡账单', icon: 'wallet-filled', color: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)', permission: 'invest:creditCardBill:list'   },
        { path: '/pages/work/bill/creditInstallmentHistory/list', text: '信用卡分期账单', icon: 'calendar-filled', color: 'linear-gradient(135deg, #f6d365 0%, #fda085 100%)', permission: 'invest:creditCard'  },
          { path: '/pages/work/bill/onlineLendHistory/list', text: '贷款账单', icon: 'calendar', color: 'linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%)', permission: 'invest:onlineLend'  },
           { path: '/pages/work/bill/peopleLendHistory/list', text: '人情账单', icon: 'person-filled', color: 'linear-gradient(135deg, #fa8231 0%, #f7971e 100%)', permission: 'invest:onlineLend'  },
        { path: '/pages/work/bill/creditQueryRecord/list', text: '征信查询记录', icon: 'search', color: 'linear-gradient(135deg, #5f72bd 0%, #9b23ea 100%)', permission: 'invest:creditQueryRecord:list'  },
        { path: '/pages/work/bill/futuresBill/list', text: '期货账单', icon: 'chatboxes', color: 'linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)', permission: 'invest:futureStocksBill:list'  },
        { path: '/pages/work/bill/stocksBill/list', text: '股票账单', icon: 'flag-filled', color: 'linear-gradient(135deg, #5f72bd 0%, #9b23ea 100%)', permission: 'invest:futureStocksBill:list'  }
      ])
      const accountGridList=ref([
          { path: '/pages/work/heartJourney/list', text: '心路历程', icon: 'heart-filled', color: 'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)', permission: 'invest:heartJourney:list'  },
        { path: '/pages/work/accounts/accounts/list', text: '记账账户', icon: 'wallet', color: 'linear-gradient(135deg, #f6d365 0%, #fda085 100%)', permission: 'invest:accounts:list'  },
        { path: '/pages/work/accounts/accountDealRecord/list', text: '账户交易记录', icon: 'list', color: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)', permission: 'invest:accountDealRecord:list'  },
         { path: '/pages/work/accounts/debitTransferRecord/list', text: '储蓄账户转账', icon: 'loop', color: 'linear-gradient(135deg, #11998e 0%, #38ef7d 100%)', permission: 'invest:debitCard'  },
         { path: '/pages/work/accounts/creditTransferRecord/list', text: '信用卡还款', icon: 'redo', color: 'linear-gradient(135deg, #fa709a 0%, #fee140 100%)', permission: 'invest:creditCard'  },
        { path: '/pages/work/accounts/lendTransferRecord/list', text: '借贷账户记账', icon: 'link', color: 'linear-gradient(135deg, #fd79a8 0%, #e84393 100%)', permission: 'invest:onlineLend'  },
        { path: '/pages/work/product/productPriceRecord/list', text: '物价记录', icon: 'cart-filled', color: 'linear-gradient(135deg, #0be881 0%, #0fbcf9 100%)', permission: 'invest:productPriceRecord:list'  },
          { path: '/pages/work/accounts/posadvice/list', text: 'POS刷卡推荐', icon: 'star-filled', color: 'linear-gradient(135deg, #d38cff 0%, #9d50bb 100%)', permission: 'invest:posmachine:list'  },
        { path: '/pages/work/accounts/posTransferRecord/list', text: 'POS机刷卡记账', icon: 'checkmarkempty', color: 'linear-gradient(135deg, #17c0eb 0%, #f368e0 100%)', permission: 'invest:posmachine:list'  },
        { path: '/pages/work/accounts/investAccountDeal/list', text: '投资交易记录', icon: 'bars', color: 'linear-gradient(135deg, #00b4db 0%, #0083b0 100%)', permission: 'invest:futureStocks:list'  },
        { path: '/pages/work/accounts/investTransferRecord/list', text: '投资账户记账', icon: 'compose', color: 'linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)', permission: 'invest:futureStocks:list'  },
        
      ])
	function navigateTo(path) {
    uni.navigateTo({
        url: path
      });
	}
</script>

<style lang="scss">
  /* #ifndef APP-NVUE */
  /* #endif */

  .content {
    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>
