From 72dbfec77a747b9a08bc71b630464d4383877082 Mon Sep 17 00:00:00 2001
From: 杨磊 <505174330@qq.com>
Date: 星期一, 25 八月 2025 01:15:02 +0800
Subject: [PATCH] 按钮判断

---
 src/views/home/index.vue |  584 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 584 insertions(+), 0 deletions(-)

diff --git a/src/views/home/index.vue b/src/views/home/index.vue
new file mode 100644
index 0000000..4112f60
--- /dev/null
+++ b/src/views/home/index.vue
@@ -0,0 +1,584 @@
+<template>
+  <div class="homePage">
+    <div class="bannerBox imgBox">
+      <img class="bannerImg" :src="banner[0]?.icon" @click="bannerLink(item)" />
+    </div>
+    <div v-if="informationList.length > 0" class="contentBox" style="margin-top: 50px">
+      <div class="informationBox">
+        <div class="bookListTitle">
+          <div class="title">鏂伴椈璧勮</div>
+          <div class="more" @click="toMore">鏇村></div>
+        </div>
+        <div class="informationList">
+          <div class="informationItem" v-for="(item, index) in informationList" :key="index">
+            <div class="imgBox"><img class="autoImg" :src="item.icon" alt="" /></div>
+            <div class="informationContent">
+              <div class="informationTitle" :alt="item.name">{{ item.name }}</div>
+              <div class="informationDate">{{ moment(item.publishDate).format('YYYY-MM-DD') }}</div>
+              <div class="informationText">{{ item.description }}</div>
+            </div>
+          </div>
+        </div>
+      </div>
+    </div>
+    <div class="bookListBox">
+      <div class="contentBox">
+        <div class="bookListTitle">
+          <div class="title">鎺ㄨ崘鏁欐潗</div>
+          <div class="more" @click="toMore">鏇村></div>
+        </div>
+        <div class="recommendList">
+          <div
+            class="recommendItem"
+            v-for="item in bookListData"
+            :key="item.id"
+            @click="toDetail(item)"
+          >
+            <div class="recommendItemImg">
+              <img class="autoImg" :src="item.icon" />
+            </div>
+            <div class="infoBox">
+              <div class="bookName">{{ item.name }}</div>
+              <div class="author">浣滆�咃細{{ item.author ? item.author : '-' }}</div>
+              <div class="priceBox">
+                <span class="price" v-if="item.price && item.price > 0">
+                  <span> 楼{{ item.price }}</span>
+                </span>
+                <span class="oldPrice" v-if="item.oldPrice"> 楼{{ item.oldPrice }}</span>
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+    </div>
+    <div class="contentBox">
+      <div class="funBox">
+        <div class="authentication">
+          <div class="cardNav" @click="toAuthentication(true)">
+            <div class="cardTitle">鏁欏笀璁よ瘉</div>
+            <div class="cardText">
+              瀛︽牎浠昏鑰佸笀涓婁紶鏁欏笀璇佹槑鏂囦欢锛岄�氳繃璁よ瘉鍚庯紝鍙繘琛屾牱涔︿笌鏁欏璧勬簮涓嬭浇鐢宠
+            </div>
+          </div>
+        </div>
+        <div class="manual">
+          <div class="cardNav" @click="toAuthentication(false)">
+            <div class="cardTitle">鎿嶄綔鎵嬪唽</div>
+            <div class="cardText">蹇�熶簡瑙d娇鐢ㄦ楠わ紝杞绘澗寮�鍚暀瀛︽敮鎸佷箣鏃呫��</div>
+          </div>
+        </div>
+      </div>
+
+      <div class="bookListTitle">
+        <div class="title" style="display: flex; line-height: 50px">
+          <div>鏁欏瀵艰埅</div>
+          <div class="titleTabs" v-if="classfeild.length > 0">
+            <el-tabs v-model="activeName" @tab-change="handleClick">
+              <el-tab-pane
+                v-for="item in classfeild"
+                :key="item.value"
+                :label="item.name"
+                :name="item.value"
+              />
+            </el-tabs>
+          </div>
+          <div class="more" style="margin-left: 30px; font-weight: normal" @click="toMore">
+            鏇村>
+          </div>
+        </div>
+      </div>
+      <div class="recommendList">
+        <div
+          class="recommendItem"
+          v-for="item in navBookList"
+          :key="item.id"
+          @click="toDetail(item)"
+        >
+          <div class="recommendItemImg">
+            <img class="autoImg" :src="item.icon" />
+          </div>
+          <div class="infoBox">
+            <div class="bookName">{{ item.name }}</div>
+            <div class="author">浣滆�咃細{{ item.author ? item.author : '-' }}</div>
+            <div class="priceBox">
+              <span class="price" v-if="item.price && item.price > 0">
+                <span>楼{{ item.price }}</span>
+              </span>
+              <span class="oldPrice" v-if="item.oldPrice">楼{{ item.oldPrice }}</span>
+            </div>
+          </div>
+        </div>
+      </div>
+    </div>
+    <teacherCertification :isShow="teacherDialog" @dialog-Change="dialogChange" />
+  </div>
+</template>
+
+<script setup>
+import moment from 'moment'
+import { ElMessage } from 'element-plus'
+import teacherCertification from '@/views/personalCenter/teacherCertification.vue'
+import { ref, onBeforeMount, inject, reactive, onMounted, watch } from 'vue'
+let screenheight = ref(document.documentElement.clientHeight / 2)
+import { useRouter, useRoute } from 'vue-router'
+const router = useRouter()
+const route = useRoute()
+
+const MG = inject('MG')
+const config = inject('config')
+const logIn = inject('logIn')
+const tool = inject('tool')
+const toolClass = inject('toolClass')
+const banner = reactive([])
+const informationList = reactive([])
+let classfeild = ref([])
+let activeName = ref('A1')
+let callbackLink = ref(null)
+
+let bookListData = ref([])
+let navBookList = ref([])
+let teacherDialog = ref(false)
+onBeforeMount(() => {
+  console.log(document.documentElement.clientWidth / 2.628)
+  window.onresize = () => {
+    let c = 2.628
+    if (document.documentElement.clientWidth >= 1220) {
+      screenheight.value = document.documentElement.clientWidth / c
+      console.log(document.documentElement.clientWidth / c)
+    }
+  }
+})
+
+// 鑾峰彇url鍙傛暟
+const getUrlParams = () => {
+  let url = window.location.href
+  let params = url.split('?')[1]
+  let paramsObj = {}
+  if (params) {
+    paramsObj = params.split('&').reduce((pre, cur) => {
+      pre[cur.split('=')[0]] = cur.split('=')[1]
+      return pre
+    }, {})
+  }
+  return paramsObj
+}
+
+onMounted(() => {
+  // 鐩戝惉鏄惁鏉ヨ嚜鏁板瓧闃呰
+  const params = getUrlParams()
+  if (params.login) {
+    localStorage.setItem('loginBack', decodeURIComponent(params.callBackUrl))
+    logIn()
+  }
+  getBanner()
+  classifList()
+  getInformationList()
+  getBookList()
+  getNavBookList()
+})
+
+watch(
+  () => route, // 鐩戝惉 path 鍙樺寲
+  (newPath, oldPath) => {
+    console.log('璺敱璺緞浠�', oldPath, '鍙樹负', newPath)
+  },
+)
+
+const toMore = () => {
+  router.push({
+    path: '/bookStore',
+  })
+}
+
+const toDetail = (item) => {
+  router.push({
+    path: '/bookdetail',
+    query: {
+      bookId: item.id,
+    },
+  })
+}
+
+const handleClick = (tab, event) => {
+  console.log(tab)
+
+  activeName.value = tab
+  getNavBookList()
+}
+
+const classifList = () => {
+  const query = {
+    refCodes: ['digitalTextbooks'],
+  }
+  MG.resource.getCmsTypeByRefCode(query).then((res) => {
+    const types = toolClass.handleTypeList(res)
+    const typeData = types[0].cmsTypeLinks[0].children
+    const temp_classfeild = typeData.find((item) => item.typeField.refCode === 'teachingLevel')
+      ?.typeField.cfg.option
+
+    const noCheck = temp_classfeild.map((item) => {
+      return {
+        name: item.name,
+        value: item.value,
+      }
+    })
+    console.log(noCheck, 'noCheck')
+
+    classfeild.value = noCheck
+    console.log(classfeild, 'classfeild')
+  })
+}
+
+const getNavBookList = () => {
+  MG.store
+    .getProductList({
+      path: '*',
+      queryType: '*',
+      storeInfo: 'defaultGoodsStore1',
+      paging: {
+        start: 0,
+        size: 5,
+      },
+      fields: {
+        'teachingLevel=': activeName.value,
+        author: [],
+      },
+    })
+    .then((res) => {
+      console.log(res, '11111111111')
+      navBookList.value = res.datas
+    })
+}
+
+const dialogChange = (val) => {
+  getTeacherInfo()
+  if (val == false) {
+    teacherDialog.value = false
+  } else {
+    teacherDialog.value = true
+  }
+}
+
+//鏁欏笀淇℃伅
+function getTeacherInfo() {
+  const data = {
+    start: 0,
+    size: 10,
+    topicIdOrRefCode: 'teacherRoleApproval',
+    appRefCode: config.appRefCode,
+    sort: {
+      type: 'Desc',
+      field: 'CreateDate',
+    },
+  }
+  MG.ugc.getTopicMessageList(data).then((res) => {
+    try {
+      const resData = res.datas.find((i) => i.appUserCreator.userId == userId.value)
+      if (resData) {
+        teacherState.value = resData.state
+        if (resData.feedBack != null) {
+          reasonTxt.value = JSON.parse(resData.feedBack).reason
+        }
+      } else {
+        teacherState.value = ''
+      }
+      loading.value = false
+    } catch (error) {
+      loading.value = false
+    }
+  })
+}
+
+const toAuthentication = (type) => {
+  if (type) {
+    if (localStorage.getItem(config.tokenKey)) {
+      teacherDialog.value = true
+    } else {
+      logIn()
+    }
+  } else {
+    ElMessage({
+      message: '寤鸿涓�...',
+      type: 'warning',
+    })
+  }
+}
+
+const getBookList = () => {
+  MG.store
+    .getProductList({
+      path: 'recommendedTextbooks',
+      paging: {
+        start: 0,
+        size: 5,
+      },
+      fields: {
+        author: [],
+      },
+    })
+    .then((res) => {
+      console.log(res, '鎺ㄨ崘鏁欐潗')
+      bookListData.value = res.datas
+    })
+}
+
+const getInformationList = () => {
+  MG.resource
+    .getItem({
+      path: 'information',
+      fields: { publishDate: [], content: [] },
+      paging: { start: 0, size: 9 },
+    })
+    .then((res) => {
+      informationList.push(...res.datas)
+      console.log(res.datas)
+    })
+}
+
+const getBanner = () => {
+  MG.resource
+    .getItem({
+      path: 'banner\\homeBanner',
+      fields: { link: [] },
+      paging: { start: 0, size: 9 },
+    })
+    .then((res) => {
+      banner.push(...res.datas)
+      console.log(res.datas)
+    })
+}
+</script>
+
+<style lang="less" scoped>
+.homePage {
+  min-width: 1220px;
+  min-height: calc(100vh - 61.8%);
+  background-color: #fff;
+  padding-bottom: 100px;
+
+  .bannerBox {
+    height: 615px;
+    position: relative;
+    .bannerText {
+      position: absolute;
+      top: 50%;
+      left: 50%;
+      transform: translate(-50%, -50%);
+      font-size: 36px;
+      font-weight: 700;
+      color: #fff;
+      text-shadow: 0px 0px 10px #000000;
+      text-align: center;
+    }
+    .enText {
+      font-size: 28px;
+      opacity: 0.45;
+      margin-top: 10px;
+    }
+  }
+}
+.el-carousel__item h3 {
+  color: #475669;
+  opacity: 0.75;
+  line-height: 150px;
+  margin: 0;
+  text-align: center;
+}
+
+.el-carousel__item:nth-child(2n) {
+  background-color: #99a9bf;
+}
+
+.el-carousel__item:nth-child(2n + 1) {
+  background-color: #d3dce6;
+}
+
+.informationList {
+  display: flex;
+  flex-wrap: wrap;
+  .informationItem {
+    display: flex;
+    width: 42%;
+    min-height: 100px;
+    margin-right: 5%;
+    margin-bottom: 20px;
+    border: 1px solid #ebebeb;
+    border-radius: 10px;
+    padding: 10px;
+    cursor: pointer;
+    .imgBox {
+      width: 30%;
+      height: 100%;
+      position: relative;
+    }
+    .informationContent {
+      width: 70%;
+      padding-left: 10px;
+      .informationTitle {
+        font-size: 14px;
+        width: 100%;
+        white-space: nowrap;
+        overflow: hidden;
+        text-overflow: ellipsis;
+        color: #333333;
+        font-weight: bold;
+        margin-bottom: 10px;
+      }
+      .informationDate {
+        margin-top: 10px;
+      }
+      .informationText {
+        color: #666666;
+        overflow: hidden;
+        text-overflow: ellipsis;
+        display: -webkit-box;
+        margin-top: 10px;
+        display: -webkit-box; /* 灏嗗璞′綔涓哄脊鎬т几缂╃洅瀛愭ā鍨嬫樉绀� */
+        -webkit-line-clamp: 3; /* 鏄剧ず鐨勮鏁� */
+        -webkit-box-orient: vertical; /* 璁剧疆鎴栨绱几缂╃洅瀵硅薄鐨勫瓙鍏冪礌鐨勬帓鍒楁柟寮� */
+        overflow: hidden; /* 婧㈠嚭闅愯棌 */
+      }
+    }
+  }
+  .informationItem:hover {
+    border: 1px solid #019e58;
+  }
+}
+.bookListBox {
+  width: 100%;
+  padding: 80px 0;
+  background-repeat: no-repeat;
+  background-size: 100% 100%;
+  background-image: url('@/assets/images/tuijian-bg.png');
+  background-repeat: no-repeat;
+  background-size: 100% 100%;
+}
+
+.recommendList {
+  display: flex;
+  padding-top: 20px;
+
+  .recommendItem {
+    flex: 1;
+    margin-right: 20px;
+    height: 300px;
+    background-repeat: no-repeat;
+    background-size: 100% 100%;
+    cursor: pointer;
+    border: 1px solid #dedede;
+    background-color: #fff;
+    padding-top: 10px;
+    &:last-child {
+      margin-right: 0;
+    }
+  }
+  .recommendItem:hover {
+    background-image: url(@/assets/images/Mouse_fill.png);
+  }
+}
+
+.recommendItemImg {
+  width: 150px;
+  height: 200px;
+  position: relative;
+  margin: 0 auto;
+}
+
+.infoBox {
+  text-align: center;
+  margin-top: 10px;
+}
+.bookName {
+  font-weight: 700;
+}
+.author {
+  margin-top: 10px;
+  color: #333333;
+}
+.priceBox {
+  margin-top: 10px;
+  .oldPrice {
+    font-size: 16px;
+    color: #999999;
+    text-decoration: line-through;
+    margin-left: 20px;
+  }
+  .price {
+    span {
+      font-weight: bold;
+      font-size: 14px;
+      color: #d91523;
+    }
+  }
+}
+
+.funBox {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  margin-top: 60px;
+  margin-bottom: 60px;
+  .authentication {
+    width: 48%;
+    height: 123px;
+    background-repeat: no-repeat;
+    background-size: 100% 100%;
+    background-image: url('@/assets/images/xiehe/home/jiaoshirenzheng.png');
+  }
+  .manual {
+    width: 48%;
+    height: 123px;
+    background-repeat: no-repeat;
+    background-size: 100% 100%;
+    background-image: url('@/assets/images/xiehe/home/caozuoshouce.png');
+  }
+}
+
+.titleTabs {
+  margin-left: 50px;
+  width: 85%;
+}
+.bookListTitle {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  margin-bottom: 20px;
+  border-bottom: 1px solid #ebebeb;
+
+  padding-bottom: 20px;
+  .title {
+    font-size: 20px;
+    color: #333333;
+    font-weight: bold;
+  }
+  .more {
+    font-size: 14px;
+    color: #999999;
+    cursor: pointer;
+  }
+}
+.cardNav {
+  margin-left: 30%;
+  margin-top: 20px;
+  padding-right: 20px;
+  cursor: pointer;
+  .cardTitle {
+    font-size: 28px;
+    color: #ffffff;
+  }
+  .cardText {
+    font-size: 14px;
+    color: #ccc;
+    margin-top: 10px;
+    line-height: 20px;
+  }
+}
+
+::v-deep(.el-tabs__item) {
+  align-items: stretch;
+  height: 60px !important;
+  line-height: 20px;
+  text-align: center;
+  white-space: pre-wrap !important;
+}
+</style>

--
Gitblit v1.9.1