From 9cad6a832c786989be620573b09badccfe7e3b51 Mon Sep 17 00:00:00 2001
From: QYF-GitLab1 <1940665526@qq.com>
Date: 星期一, 25 八月 2025 15:11:37 +0800
Subject: [PATCH] 首页头部,样式调整

---
 src/views/bookStore/detail.vue |  202 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 185 insertions(+), 17 deletions(-)

diff --git a/src/views/bookStore/detail.vue b/src/views/bookStore/detail.vue
index 1aa0a9d..6fbb16d 100644
--- a/src/views/bookStore/detail.vue
+++ b/src/views/bookStore/detail.vue
@@ -35,6 +35,9 @@
                 {{ bookInfo.seriesName }}
               </div>
               <div class="collectBox">
+                <div class="collectText" @click="collectBook" v-if="bookInfo.isFavourite">
+                  宸叉敹钘�
+                </div>
                 <img
                   @click="collectBook"
                   v-if="bookInfo.isFavourite"
@@ -43,17 +46,15 @@
                   style="margin-right: 10px"
                 />
                 <span v-else class="iconfont icon-shoucang" style="margin-right: 10px"> </span>
-                <div class="collectText" @click="collectBook" v-if="bookInfo.isFavourite">
-                  宸叉敹钘�
-                </div>
 
                 <div class="collectText" @click="collectBook" v-else>
+                  鏀惰棌
+
                   <img
                     class="buyIcon"
                     src="@/assets/images/xiehe/detail/Collection.png"
                     style="margin-right: 10px"
                   />
-                  鏀惰棌
                 </div>
               </div>
             </div>
@@ -89,18 +90,16 @@
             </div>
             <div class="authorBox" style="box-sizing: border-box">
               <div class="titleBox1">
-                <div>涓�绾у垎绫伙細</div>
-                <div>浜岀骇鍒嗙被锛�</div>
+                <div>鍒嗙被锛�</div>
               </div>
               <div class="valueBox">
                 <div>鍏ㄥ浗楂樼瓑鑱屼笟鏁欒偛棰勯槻鍖诲涓撲笟瑙勫垝鏁欐潗</div>
-                <div>楂樼瓑鑱屼笟鏁欒偛</div>
               </div>
             </div>
             <div class="purchaseBox">
               <div class="priceBox">
                 <span v-if="bookInfo.price && bookInfo.price > 0">
-                  <span>瀹氫环锛�</span><span>锟�</span> <span>{{ bookInfo.price || '-' }}</span
+                  <span>鏁板瓧鏁欐潗</span><span>锟�</span> <span>{{ bookInfo.price || '-' }}</span
                   ><span v-if="bookInfo.VirtualPrice">鍘熶环锛氾骏{{ bookInfo.VirtualPrice }}</span>
                 </span>
 
@@ -169,13 +168,36 @@
               <el-button v-if="currentRoute == 'teachingServices'" plain @click="addPaperBook"
                 >绾歌川鏍蜂功</el-button
               >
-              <el-button plain @click="applyTextBook">鐢宠璇曠敤</el-button>
+              <el-button
+                plain
+                @click="applyTextBook"
+                v-if="!bookInfo.alreadyBuy && currentBook?.state !== 'Normal'"
+                >鐢宠璇曠敤</el-button
+              >
+              <el-button plain @click="useCode" v-if="!bookInfo.alreadyBuy">浣跨敤璐功鐮�</el-button>
+              <el-button
+                plain
+                @click="read"
+                v-if="bookInfo.alreadyBuy || currentBook?.state == 'Normal'"
+                >寮�濮嬮槄璇�</el-button
+              >
             </div>
           </div>
         </div>
       </div>
     </div>
-
+    <el-dialog v-model="buyBookCodeDialog" title="璐功" width="30%">
+      <div class="buyBookCode">
+        <div style="line-height: 30px">璐功鐮� 锛�</div>
+        <el-input style="width: 70%" v-model="activateCode" clearable />
+      </div>
+      <template #footer>
+        <span class="dialog-footer">
+          <el-button @click="buyBookCodeDialog = false">鍙栨秷</el-button>
+          <el-button type="primary" @click="userActiveCodeGet"> 婵�娲� </el-button>
+        </span>
+      </template>
+    </el-dialog>
     <div class="detailContent contentBox">
       <div class="resourceBox">
         <div class="tabsBox">
@@ -263,6 +285,7 @@
         </div>
       </div>
     </div>
+    <teacherCertification :isShow="teacherDialog" @dialog-Change="dialogChange" />
   </div>
 </template>
 
@@ -281,10 +304,16 @@
 import videoIcon from '@/assets/images/digitalTextbooks/video.png'
 import VRIcon from '@/assets/images/digitalTextbooks/VR.png'
 import ziliaoIcon from '@/assets/images/digitalTextbooks/ziliao.png'
+import teacherCertification from '@/views/personalCenter/teacherCertification.vue'
+import { ElMessage, ElMessageBox } from 'element-plus'
 import { ref, onBeforeMount, inject, reactive, onMounted, watchEffect } from 'vue'
 const MG = inject('MG')
 const config = inject('config')
 const logIn = inject('logIn')
+import { useUserStore } from '@/store'
+const userStore = useUserStore()
+let teacherDialog = ref(false)
+
 import { useRouter, useRoute } from 'vue-router'
 import { applyBookStore } from '@/store'
 const route = useRoute()
@@ -294,8 +323,11 @@
 let resourceData = ref([])
 let recommendBookListData = ref([])
 let editableTabsValue = ref('1')
+let activateCode = ref('')
 let resourceHave = ref(true)
+let currentBook = ref(null)
 let loading = ref(false)
+let buyBookCodeDialog = ref(false)
 var chartDom = null
 var myChart = {}
 var option = null
@@ -331,6 +363,7 @@
   digitalTextId.value = route.query.bookId
   getBookDetail(digitalTextId.value)
   getRecommendBookList()
+  getTextBookList()
 })
 
 watchEffect(() => {
@@ -338,6 +371,106 @@
     getBookResource()
   }
 })
+
+const getTextBookList = async () => {
+  const data = {
+    start: 0,
+    size: 9999,
+    topicIdOrRefCode: 'applyDigitalBook',
+    appRefCode: config.appRefCode,
+    sort: {
+      type: 'Desc',
+      field: 'CreateDate',
+    },
+  }
+  const res = await MG.ugc.getTopicMessageList(data)
+  if (res.datas && res.datas.length > 0) {
+    for (let i = 0; i < res.datas.length; i++) {
+      const item = res.datas[i]
+      item.content = JSON.parse(item.content)[0]
+      item.productId = item.content.id
+    }
+    currentBook.value = res.datas.find((item) => item.productId == digitalTextId.value)
+  }
+}
+
+const read = () => {
+  let token = localStorage.getItem(config.tokenKey)
+  const url = config.textBookResourceUrl + '?bookId=' + bookInfo.value.refCode + '&token=' + token
+  window.open(url)
+}
+
+const userActiveCodeGet = () => {
+  let lock = true
+  console.log(activateCode.value, 'activateCode.value')
+
+  if (activateCode.value == '') {
+    ElMessage({
+      type: 'error',
+      message: '璇疯緭鍏ユ縺娲荤爜锛�',
+    })
+  } else {
+    if (lock) {
+      lock = false
+
+      MG.store
+        .getActiveCode({
+          code: activateCode.value,
+        })
+        .then((res) => {
+          console.log(res, 'res')
+          const cfg = JSON.parse(res.config)
+          console.log(cfg, 'cfg')
+          if (cfg && cfg.length > 0) {
+            const isActive = cfg.findIndex((item) => item.id == digitalTextId.value)
+
+            if (isActive > -1) {
+              MG.store
+                .userActiveCode({
+                  code: activateCode.value,
+                })
+                .then((res) => {
+                  ElMessage({
+                    type: res == '婵�娲绘垚鍔�' ? 'success' : 'error',
+                    message: res,
+                  })
+                  activateCode.value = ''
+                  buyBookCodeDialog.value = false
+                  getBookDetail(digitalTextId.value)
+                  lock = true
+                })
+            } else {
+              ElMessage({
+                type: 'error',
+                message: '鎮ㄨ緭鍏ョ殑璐功鐮佹湁璇�',
+              })
+            }
+          } else {
+            ElMessage({
+              type: 'error',
+              message: '鎮ㄨ緭鍏ョ殑璐功鐮佹湁璇�',
+            })
+          }
+        })
+    }
+  }
+}
+
+const useCode = () => {
+  if (localStorage.getItem(config.tokenKey)) {
+    buyBookCodeDialog.value = true
+  } else {
+    logIn()
+  }
+}
+
+const dialogChange = (val) => {
+  if (val == false) {
+    teacherDialog.value = false
+  } else {
+    teacherDialog.value = true
+  }
+}
 
 //鏀惰棌涔︾睄
 const collectBook = () => {
@@ -367,11 +500,35 @@
 }
 
 //鐢宠璇曠敤
-const applyTextBook = () => {
-  localStorage.setItem('applyBookInfo', JSON.stringify(bookInfo.value))
-  router.push({
-    path: '/textBookApply',
-  })
+const applyTextBook = async () => {
+  if (currentBook.value?.state == 'WaitAudit') {
+    ElMessageBox.confirm('鎮ㄥ凡鐢宠璇曠敤璇ヤ功锛屾槸鍚﹀墠寰�鏌ョ湅', '鎻愮ず', {
+      confirmButtonText: '纭畾',
+      cancelButtonText: '鍙栨秷',
+      type: 'warning',
+    }).then(() => {
+      router.push({
+        path: '/myApply',
+      })
+    })
+  } else {
+    toApply()
+  }
+}
+
+const toApply = () => {
+  if (localStorage.getItem(config.tokenKey)) {
+    if (userStore.userInfo && userStore.userInfo.role == 'Teacher') {
+      localStorage.setItem('applyBookInfo', JSON.stringify(bookInfo.value))
+      router.push({
+        path: '/textBookApply',
+      })
+    } else {
+      teacherDialog.value = true
+    }
+  } else {
+    logIn()
+  }
 }
 
 const getRecommendBookList = () => {
@@ -624,8 +781,8 @@
   box-sizing: border-box;
 }
 .collectText {
-  font-size: 16px;
-  line-height: 25px;
+  font-size: 18px;
+  line-height: 18px;
   display: inline-block;
 }
 .bookName {
@@ -926,4 +1083,15 @@
   margin-top: 20px;
   line-height: 28px;
 }
+.buyBookCode {
+  width: 100%;
+  display: flex;
+  padding: 40px 10px;
+  text-align: center;
+  align-items: center;
+}
+.tab-name {
+  width: 100px;
+  height: 40px;
+}
 </style>

--
Gitblit v1.9.1