<template>
  <view class="sx-card-box">
    <view class="card-head-box">
      <!-- 封面 -->
      <image :src="item.cover" class="head-img"></image>
      <view class="head-right-box">
        <!-- 名称 -->
        <view class="head-title">{{item.name}}</view>
        <!-- 简介 -->
        <view class="head-content">{{item.intro}}</view>
        <!-- 共计 -->
        <view class="head-content">{{item.gongji}}</view>
      </view>
    </view>
    <view class="card-body-box">
      <view class="body-title">请选择学习等级</view>
      <view class="dj-item-row">
        <ezyActiveVue v-for="cItem in item.levelList" class="ezy-btn-active dj-item"
                      @aclick="handleSelect(cItem)" :class="{active: cItem.active}">{{cItem.levelName}}</ezyActiveVue>
      </view>
    </view>
  </view>
</template>

<script setup>
import * as pinduHttp from "@/api/chanpinZiRanPinDu.js"
import * as chaojidanciHttp from "@/api/chaojidanci.js"
import ezyActiveVue from "@/components/ezyActive/ezyActive.vue";
import cacheManager from "@/utils/cacheManager.js";
const porps = defineProps({
  item: {
    type: Object
  }
})
// 选择产品等级
function handleSelect(item) {
	console.log('item',item);

  porps.item.levelList.forEach(citem => {citem.active = false; if (item.dengjiId == citem.dengjiId) {citem.active = true}})
  const opt = {
    dengjiId: item.dengjiId,
  }
  pinduHttp.getDanciChanpinBanbenSave(opt).then(res => {
    if (!res.data) {
      return;
    }
    cacheManager.get('contentInfo') && cacheManager.remove('contentInfo');
    // 跳转
    uni.switchTab({
      url: "/pages/chanpinneirong/index"
    })
  })
}
</script>

<style scoped>

</style>