<template>
  <h2 class="contentTitle">
    <div class="Levelone">
			{{ lang.ssPracticeCenter }}
		</div>
  </h2>
  <el-row :gutter="20">
    <el-col :span="6">
      <div class="grid-content" @click="openApplication('szdjgCocooroboX')">
        <!-- <router-link to="/iframe/实践中心/图形化"> -->
        <img :src="GraphicsImg" alt="">
        <div>
          <p class="title">{{ lang.ssGraphics }}</p>
          <p :title="lang.ssGraphicsDesc">{{ lang.ssGraphicsDesc }}</p>
        </div>
        <!-- </router-link> -->

      </div>
    </el-col>
    <el-col :span="6">
      <div class="grid-content" @click="openApplication('szdjgPython')">
        <!-- <router-link to="/iframe/实践中心/Python"> -->
        <img :src="pythonImg" alt="">
        <div>
          <p class="title">{{ lang.ssPython }}</p>
          <p :title="lang.ssPythonDesc">{{ lang.ssPythonDesc }}</p>
        </div>
        <!-- </router-link> -->

      </div>
    </el-col>
    <!-- <el-col :span="6" v-if="isLogin">
      <div class="grid-content" @click="openApplications('study')">
        <img :src="Img2" alt="">
        <span class="course_down" @click="courseDown($event)">课件下载</span>
        <div>
          <p class="title" title="拓展课程">拓展课程</p>
          <p title="教师使用预置或自定义补充资源开展授课。">教师使用预置或自定义补充资源开展授课。</p>
        </div>
      </div>
    </el-col> -->
  </el-row>
  <el-dialog v-model="dialogVisible" :before-close="handleClose" width=1200 >
    <template #header>
      <div class="dialog-header img_text_middle">
        <!-- <img :src="WarningImg" alt=""> -->
        <span class="warning_text">{{ lang.ssCourseCenter }}</span>
      </div>
    </template>
    <CourseSelect :classDown="false"></CourseSelect>
    <template #footer>
      <div class="dialog-footer">
        <!-- <el-button type="primary" @click="updateReduction()">
          确认修改
        </el-button> -->
        <el-button @click="dialogVisible = false">{{ lang.ssCancel }}</el-button>
      </div>
    </template>
  </el-dialog>
</template>
<script setup>
import { ref, watchEffect, inject } from 'vue';
import CourseSelect from './downloadCourse.vue';
import GraphicsImg from '@/assets/icon/图形化icon-1.png'
import pythonImg from '@/assets/icon/Frame.png'
import Img2 from '@/assets/icon/课程中心.png'
import { userInfoStore } from '@/stores/counter'

const lang = inject('lang')

const dialogVisible = ref(false)
const InfoStore = userInfoStore()
const isLogin = ref(false)


const openApplication = (type) => {
  if ( type == 'szdjgCocooroboX') {
    if (lang.lang == 'hk') {
      top.U.MD.D.I.openInApplication('setUrl',{url:'https://pi.cocorobo.hk/?lang=zh-hant',title: lang.ssGraphicsProg,id:new Date().getTime()})
    }else if (lang.lang == 'en') {
      top.U.MD.D.I.openInApplication('setUrl',{url:'https://pi.cocorobo.cn/?lang=zh-hans',title: lang.ssGraphicsProg,id:new Date().getTime()})
    }else{
      top.U.MD.D.I.openInApplication('setUrl',{url:'https://pi.cocorobo.cn/?lang=zh-hans',title: lang.ssGraphicsProg,id:new Date().getTime()})
    }
  }else{
    if (lang.lang == 'hk') {
      top.U.MD.D.I.openInApplication('setUrl',{url:'https://pi.cocorobo.hk/python/?lang=zh-hant',title: lang.ssPythonProg,id:new Date().getTime()})
    }else if (lang.lang == 'en') {
      top.U.MD.D.I.openInApplication('setUrl',{url:'https://pi.cocorobo.cn/python/?lang=zh-hans',title: lang.ssPythonProg,id:new Date().getTime()})
    }else{
      top.U.MD.D.I.openInApplication('setUrl',{url:'https://pi.cocorobo.cn/python/?lang=zh-hans',title: lang.ssPythonProg,id:new Date().getTime()})
    }
  }
  // top.U.MD.D.I.openApplication(type)
  // if (lang.lang == 'hk') {
  //   window.open('https://cloud.cocorobo.cn//#/' + type)
  // }else{
  //   window.open('https://cloud.cocorobo.cn//#/' + type)
  // }
  
}
const handleClose = () => {
  dialogVisible.value = false
}
// const openApplications = (type) => {
//   if (type) {
//     console.log(type, InfoStore.user)
//     window.open('https://cloud.cocorobo.cn//#/' + type)
//   }else{
//     window.open("https://knowledge.cocorobo.cn/zh-CN/story-telling/643a21ae-d2ef-11ef-9d05-12e77c4cb76b")
//   }
// }
// const courseDown = e => {
//   dialogVisible.value = true
//   e.stopPropagation();
// }
watchEffect(() => {
  // console.log('111111111111',CurrentRole, user.user)
  if (JSON.stringify(InfoStore.user) != "{}") {
    isLogin.value = true
  }
})
</script>
<style lang="scss" scoped>
.el-row {
  margin-bottom: 20px;

  .el-col {
    border-radius: 4px;

    .grid-content {
      border-radius: 4px;
      min-height: 36px;
      background: #fff;
      border-radius: 10px;
      position: relative;
      padding: 16px;
      display: flex;
      align-items: center;

      img {
        width: 56px;
        height: fit-content;
        margin-right: 5px;
      }

      .course_down {
        // display: inline-block;
        padding: 5px 8px;
        position: absolute;
        background-color: #efefef;
        top: 5px;
        right: 8px;
        border-radius: 5px;
        font-size: 12px;
        color: #555;
        cursor: pointer;
        z-index: 10;
      }

      div {
        // position: absolute;
        // left: 80px;
        // top: 16px;
        width: calc(100% - 56px);
        cursor: pointer;


        .title {
          display: -webkit-box;
          -webkit-line-clamp: 1;
          width: 100%;
          color: rgba(0, 0, 0, 0.9);
          font-size: 14px;
          margin-bottom: 10px;
          font-weight: 400;
          text-overflow: ellipsis;
          overflow: hidden;
          word-break: break-all;
        }

        p {
          color: rgba(0, 0, 0, 0.4);
          font-size: 12px;
          padding-right: 20px;
          overflow: hidden;
          text-overflow: ellipsis;
          -webkit-line-clamp: 2;
          display: -webkit-box;
          -webkit-box-orient: vertical;
        }
      }
    }
  }


}

.el-row:last-child {
  margin-bottom: 0;
}
.Levelone{
  width: 120px;
  background: #E0EAFB;
  border-radius: 5px;
  color: #5D8AFB;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 33px;
  font-size: 16px;
  font-weight: 500;
}
</style>