<template>
  <view class="entry-container">
    <view class="header">
      <text class="title">请选择您要使用的功能</text>
      <text class="subtitle">登录成功后可选择继续操作</text>
    </view>

    <view class="card-list">
      <view class="card" @click="goToWarehouseSelect">
        <view class="card-left">
          <text class="card-title">小程序上书</text>
          <text class="card-desc">进入仓库选择后开始上书</text>
        </view>
        <u-icon name="arrow-right" size="18"></u-icon>
      </view>

      <view class="card" @click="goToCloneTool">
        <view class="card-left">
          <text class="card-title">孔网商品翻新</text>
          <text class="card-desc">会员功能，支持商品翻新</text>
        </view>
        <u-icon name="arrow-right" size="18"></u-icon>
      </view>
    </view>
  </view>
</template>

<script>
import { checkKwfwMember } from '@/components/MemberBookCheck.js'

export default {
  methods: {
    goToWarehouseSelect() {
      uni.navigateTo({
        url: '/pages/warehouse/warehouse-select'
      })
    },
    async goToCloneTool() {
      try {
        const isMember = await checkKwfwMember({
          showToast: true,
          showModal: true,
          modalTitle: '孔网翻新会员'
        })

        if (isMember) {
          uni.navigateTo({
            url: '/pages/clone-tool/index'
          })
        }
      } catch (error) {
        console.error('检查孔网翻新会员状态失败:', error)
        uni.showToast({
          title: '检查会员状态失败，请稍后重试',
          icon: 'none'
        })
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.entry-container {
  padding: 40rpx;
  min-height: 100vh;
  background: #f8f8f8;
}

.header {
  margin-bottom: 40rpx;
}

.title {
  font-size: 36rpx;
  font-weight: 600;
  color: #333;
}

.subtitle {
  display: block;
  margin-top: 12rpx;
  font-size: 26rpx;
  color: #666;
}

.card-list {
  background-color: #fff;
  border-radius: 20rpx;
  padding: 0 30rpx;
}

.card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 30rpx 0;
  border-bottom: 1rpx solid #f5f5f5;
}

.card:last-child {
  border-bottom: none;
}

.card-left {
  display: flex;
  flex-direction: column;
}

.card-title {
  font-size: 32rpx;
  color: #222;
}

.card-desc {
  margin-top: 8rpx;
  font-size: 24rpx;
  color: #888;
}
</style>