<template>
  <view class="scenario-wrapper" :style="{ top: contentTop, bottom: contentBottom }">
    <scroll-view class="content-scroll" scroll-y="true">
      <view class="category-section two-column">
        <view class="category-header">
          <text class="category-icon">🏷️</text>
          <text class="category-title">接待页面标签</text>
        </view>
        <view class="function-grid">
          <view class="function-item" @click="openReceptionTab('reception')">
            <view class="function-icon">🛎️</view>
            <text class="function-name">开始接待</text>
            <text class="function-desc">进入接待页并切到开始接待</text>
          </view>
          <view class="function-item" @click="openReceptionTab('status')">
            <view class="function-icon">📌</view>
            <text class="function-name">服务中</text>
            <text class="function-desc">进入接待页并切到服务中</text>
          </view>
          
          <view class="function-item" @click="openReceptionTab('tag')">
            <view class="function-icon">🗂️</view>
            <text class="function-name">标签管理</text>
            <text class="function-desc">进入接待页并切到标签管理</text>
          </view>
        </view>
      </view>

      <view class="category-section two-column">
        <view class="category-header">
          <text class="category-icon">👤</text>
          <text class="category-title">客户页面标签</text>
        </view>
        <view class="function-grid">
          <view class="function-item" @click="openCustomerTab('service')">
            <view class="function-icon">📝</view>
            <text class="function-name">服务记录</text>
            <text class="function-desc">进入客户页并切到服务记录</text>
          </view>
          <view class="function-item" @click="openCustomerTab('customer')">
            <view class="function-icon">👥</view>
            <text class="function-name">客户</text>
            <text class="function-desc">进入客户页并切到客户列表</text>
          </view>
        </view>
      </view>
    </scroll-view>
  </view>
</template>

<script>
export default {
  name: 'SalesScenarioNew',
  props: {
    contentTop: {
      type: String,
      default: '0rpx',
    },
    contentBottom: {
      type: String,
      default: '0rpx',
    },
  },
  methods: {
    openReceptionTab(tab) {
      this.switchTabWithQuery('/pages/furniture_reception/furniture_reception', tab);
    },
    openCustomerTab(tab) {
      const url = `/pages-subpackage/furniture_customer/furniture_customer?tab=${tab}`;
      uni.navigateTo({ url });
    },
    switchTabWithQuery(basePath, tab) {
      if (basePath === '/pages/furniture_reception/furniture_reception') {
        uni.setStorageSync('workbench-reception-tab', tab);
      }
      uni.switchTab({
        url: basePath,
        fail: () => {
          const fallbackUrl = `${basePath}?tab=${tab}`;
          uni.navigateTo({ url: fallbackUrl });
        },
      });
    },
  },
};
</script>

<style scoped>
.scenario-wrapper {
  position: absolute;
  left: 0;
  right: 0;
}

.content-scroll {
  height: 100%;
}

.category-section {
  margin: 20rpx 30rpx;
  background: #ffffff;
  border-radius: 16rpx;
  overflow: hidden;
  box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
}

.category-section:first-child {
  margin-top: 0;
}

.category-section:last-child {
  margin-bottom: 0;
}

.category-header {
  display: flex;
  align-items: center;
  padding: 30rpx;
  background: #ffffff;
  border-bottom: 1rpx solid #f0f0f0;
}

.category-icon {
  font-size: 32rpx;
  margin-right: 20rpx;
}

.category-title {
  font-size: 32rpx;
  font-weight: 500;
  color: #333;
}

.function-grid {
  display: flex;
  flex-wrap: wrap;
  padding: 10rpx;
}

/* 与 ai_analysis 页面保持一致的两列卡片风格 */
.two-column .function-item {
  flex: 1;
  background: #ffffff;
  border-radius: 12rpx;
  padding: 24rpx 16rpx;
  margin: 0 5rpx;
  text-align: center;
  box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.04);
  transition: all 0.3s ease;
  border: 1rpx solid #f0f0f0;
}

.function-item {
  min-width: 42%;
}

.function-item:active {
  transform: scale(0.95);
  box-shadow: 0 1rpx 2rpx rgba(0, 0, 0, 0.1);
}

.function-icon {
  font-size: 48rpx;
  margin-bottom: 12rpx;
}

.function-name {
  display: block;
  font-size: 28rpx;
  font-weight: 500;
  color: #333;
  margin-bottom: 8rpx;
}

.function-desc {
  display: block;
  font-size: 24rpx;
  color: #666;
  line-height: 1.4;
}
</style>
