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 |  320 +++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 238 insertions(+), 82 deletions(-)

diff --git a/src/views/bookStore/detail.vue b/src/views/bookStore/detail.vue
index 8f3f4dd..6fbb16d 100644
--- a/src/views/bookStore/detail.vue
+++ b/src/views/bookStore/detail.vue
@@ -20,9 +20,9 @@
             </div>
           </el-tooltip>
         </div>
-        <div class="bookDetail">
+        <div class="bookDetail" v-loading="loading">
           <div class="bookImg">
-            <img class="autoImg" :src="bookInfo.icon" alt="" />
+            <img class="autoImg" :src="bookInfo.icon ? bookInfo.icon : defaultImg" alt="" />
           </div>
           <span class="iconfont icon-tubiaozhizuo"></span>
 
@@ -35,24 +35,27 @@
                 {{ bookInfo.seriesName }}
               </div>
               <div class="collectBox">
+                <div class="collectText" @click="collectBook" v-if="bookInfo.isFavourite">
+                  宸叉敹钘�
+                </div>
                 <img
                   @click="collectBook"
                   v-if="bookInfo.isFavourite"
                   class="buyIcon"
-                  src="@/assets/images/bookStore/shoucang.svg"
+                  src="@/assets/images/xiehe/detail/Collection_fill.png"
                   style="margin-right: 10px"
                 />
-                <span
-                  @click="collectBook"
-                  v-else
-                  class="iconfont icon-shoucang"
-                  style="margin-right: 10px"
-                >
-                </span>
-                <div class="collectText" @click="collectBook" v-if="bookInfo.isFavourite">
-                  宸叉敹钘�
+                <span v-else class="iconfont icon-shoucang" style="margin-right: 10px"> </span>
+
+                <div class="collectText" @click="collectBook" v-else>
+                  鏀惰棌
+
+                  <img
+                    class="buyIcon"
+                    src="@/assets/images/xiehe/detail/Collection.png"
+                    style="margin-right: 10px"
+                  />
                 </div>
-                <div class="collectText" @click="collectBook" v-else>鏀惰棌</div>
               </div>
             </div>
             <div class="authorBox">
@@ -87,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>
 
@@ -167,67 +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>
-        <el-dialog title="鑱旂郴缂栬緫" :visible.sync="contactVisible" width="30%" :lock-scroll="false">
-          <div class="contactBox" v-if="bookInfo.editor">
-            <div class="contacItem">
-              <i class="iconfont icon-renwu-ren contacIcon"></i>
-              {{ bookInfo.editor.name }}
-            </div>
-            <div class="contacItem">
-              <i class="iconfont icon-QQ contacIcon"></i>
-              {{ bookInfo.editor.qq }}
-            </div>
-            <div class="contacItem">
-              <i class="iconfont icon-tongxunlu contacIcon"></i>
-              {{ bookInfo.editor.phone }}
-            </div>
-            <div class="contacItem">
-              <i class="iconfont icon-dianhua contacIcon"></i>
-              {{ bookInfo.editor.telephone }}
-            </div>
-          </div>
-          <el-empty v-else description="鏆傛棤鏁版嵁" class="empty" :image-size="100"></el-empty>
-        </el-dialog>
-        <el-dialog title="淇℃伅鍙嶉" :visible.sync="dialogVisible" width="50%" :lock-scroll="false">
-          <div class="infoDialog">
-            <el-input
-              type="textarea"
-              :rows="8"
-              placeholder="璇︾粏鎻忚堪鎮ㄦ墍閬囧埌鐨勯棶棰橈紝鏈夊姪浜庡揩閫熺粰鎮ㄥ弽棣堬紒"
-              v-model="textarea"
-            >
-            </el-input>
-            <div class="subBtn">
-              <el-button type="primary" @click="sendDiscuss">鎻愪氦</el-button>
-            </div>
-            <div class="infoList">
-              <div class="infoItem" v-for="(item, index) in commentList" :key="index">
-                <div class="infoImg">
-                  <img v-if="item.icon" class="autoImg" :src="item.icon" alt="" />
-                  <i v-else class="el-icon-user-solid"></i>
-                </div>
-                <div class="infoContent">
-                  <div class="infoTitle">
-                    <div class="userNameBox">{{ item.content.name }}</div>
-                    <div class="userNameBox">
-                      {{ moment(item.createDate).format('YYYY-MM-DD') }}
-                    </div>
-                  </div>
-                  <div class="infoText">
-                    {{ item.content.content }}
-                  </div>
-                </div>
-              </div>
-            </div>
-          </div>
-        </el-dialog>
       </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,13 +233,14 @@
           </div>
         </div>
         <div v-else-if="editableTabsValue == '2'" class="catalogue">
-          <el-empty description="鏆傛棤鏁版嵁" />
+          <div v-if="bookInfo.catalogue" v-html="bookInfo.catalogue" class="catalogueContent"></div>
+          <el-empty description="鏆傛棤鏁版嵁" v-else />
         </div>
         <div v-else-if="editableTabsValue == '6'" class="supportingResources">
           <div class="resourcesBox">
             <el-empty v-if="!resourceHave" :image-size="150" description="鏆傛棤鍐呭"></el-empty>
             <div class="distribution" v-if="resourceHave">
-              <div class="title">璧勬簮鍒嗗竷</div>
+              <div class="titleBorderBox">璧勬簮鍒嗗竷</div>
               <div class="echartsBox">
                 <div class="left">
                   <div id="chartsContent" style="width: 600px; height: 400px"></div>
@@ -314,6 +285,7 @@
         </div>
       </div>
     </div>
+    <teacherCertification :isShow="teacherDialog" @dialog-Change="dialogChange" />
   </div>
 </template>
 
@@ -321,6 +293,7 @@
 import moment from 'moment'
 import axios from 'axios'
 import * as echarts from 'echarts'
+import defaultImg from '@/assets/images/book-cover.png'
 import imgIcon from '@/assets/images/digitalTextbooks/img.png'
 import AudioIcon from '@/assets/images/digitalTextbooks/Audio.png'
 import DIcon from '@/assets/images/digitalTextbooks/3D.png'
@@ -331,9 +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()
@@ -343,10 +323,15 @@
 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
+
 const editableTabs = reactive([
   {
     title: '鏁欐潗淇℃伅',
@@ -378,6 +363,7 @@
   digitalTextId.value = route.query.bookId
   getBookDetail(digitalTextId.value)
   getRecommendBookList()
+  getTextBookList()
 })
 
 watchEffect(() => {
@@ -386,12 +372,163 @@
   }
 })
 
+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 = () => {
+  if (localStorage.getItem(config.tokenKey)) {
+    if (bookInfo.value.isFavourite) {
+      MG.store
+        .delProductLink({
+          productIds: [bookInfo.value.id],
+          linkType: 'FavoriteBookCity',
+        })
+        .then(() => {
+          bookInfo.value.isFavourite = false
+        })
+    } else {
+      let params = {
+        productIds: [bookInfo.value.id],
+        linkType: 'FavoriteBookCity',
+      }
+      MG.store.addProductLink(params).then((res) => {
+        bookInfo.value.isFavourite = true
+      })
+    }
+  } else {
+    logIn()
+    console.log(logIn)
+  }
+}
+
 //鐢宠璇曠敤
-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 = () => {
@@ -526,6 +663,7 @@
 }
 
 const getBookDetail = (id) => {
+  loading.value = true
   const query = {
     path: '*',
     queryType: '*',
@@ -552,6 +690,7 @@
   MG.store.getProductDetail(query).then((res) => {
     console.log(res, 'res')
     bookInfo.value = res.datas
+    loading.value = false
     console.log(res.datas, 'res')
   })
 }
@@ -642,8 +781,8 @@
   box-sizing: border-box;
 }
 .collectText {
-  font-size: 16px;
-  line-height: 25px;
+  font-size: 18px;
+  line-height: 18px;
   display: inline-block;
 }
 .bookName {
@@ -829,6 +968,7 @@
     display: flex;
     justify-content: space-between;
     margin-bottom: 20px;
+    margin-top: 20px;
   }
   .left {
   }
@@ -938,4 +1078,20 @@
     }
   }
 }
+.textbookContent,
+.authorInfo {
+  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