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/home/search.vue | 484 ++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 384 insertions(+), 100 deletions(-) diff --git a/src/views/home/search.vue b/src/views/home/search.vue index 5852706..6f43d2b 100644 --- a/src/views/home/search.vue +++ b/src/views/home/search.vue @@ -1,116 +1,400 @@ <template> - <div class="contentBox"> - <div class="crumbs"> - <el-breadcrumb separator-class="el-icon-arrow-right"> - <el-breadcrumb-item :to="{ name: '/' }">棣栭〉</el-breadcrumb-item> - <el-breadcrumb-item>鎼滅储缁撴灉</el-breadcrumb-item> - </el-breadcrumb> + <div class="homePage"> + <div class="contentBox" style="margin-top: 50px"> + <!-- <div class="imgBox"> + <img class="autoimg" src="@/assets/images/bookStore/feblei.png" /> + </div> + <div class="classificationBox"> + <div style="width: 100px">鍒嗙被锛�</div> + <div class="classificaListBox"> + <div + class="classificaItem" + :class="{ active: currentLevel == item.value }" + v-for="(item, index) in classfeild" + :key="index" + @click="changeLevel(item)" + > + {{ item.name }} + </div> + </div> + </div> --> + + <div class="bookList"> + <div class="bookfilterList"> + <div class="listTitle"> + <div>缁撴灉锛氬叡璁{ total }}鏉�</div> + </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.authorcaupress_author ? item.caupress_author : '-' }} + </div> + <div class="priceBox"> + <span class="oldPrice" v-if="item.oldPrice">鍘熶环锛毬{ item.oldPrice }}</span> + <span class="price" v-if="item.price && item.price > 0"> + 瀹氫环锛毬� + <span>{{ item.price }}</span> + </span> + <span class="price" v-else> 瀹氫环锛�<span class="freePrice">鍏嶈垂</span> </span> + </div> + </div> + </div> + </div> + </div> + <div v-if="!bookListData.length > 0"> + <el-empty class="noData" description="鏆傛棤鏁版嵁" /> + </div> + + <div class="pagingBox"> + <el-pagination + layout="total, prev, pager, next" + :total="total" + v-model:current-page="currentPage1" + :page-size="20" + @current-change="handleCurrentChange" + hide-on-single-page="true" + /> + </div> + </div> + </div> </div> - <el-row> - <el-button - size="small" - :type="defaultType == 1 ? 'primary' : ''" - @click="switchType(1)" - >鏁欏鏈嶅姟</el-button - > - <el-button - size="small" - :type="defaultType == 2 ? 'primary' : ''" - @click="switchType(2)" - >涔﹀煄</el-button - > - </el-row> - <List - :channel="channel" - :searchFields="searchFields" - :searchValue="searchValue" - :detailRoute="detailRoute" - ></List> </div> </template> -<script> -import List from "@/components/list/data"; -export default { - name: "search", - components: { - List, + +<script setup> +import { ref, onBeforeMount, inject, reactive, onMounted, watch } from 'vue' +import { useRouter, useRoute } from 'vue-router' + +const MG = inject('MG') +const toolClass = inject('toolClass') +const banner = reactive([]) +const feildList = reactive([]) +const classfeild = reactive([]) +import { Search } from '@element-plus/icons-vue' +const input3 = ref('') +let bookListData = ref([]) +let recommendBookListData = ref([]) +const total = ref(0) +const currentPage1 = ref(1) +const route = useRoute() +const router = useRouter() +let currentLevel = ref('all') + +watch( + () => route.query, // 鐩戝惉 path 鍙樺寲 + (newPath, oldPath) => { + console.log('璺敱璺緞浠�', oldPath, '鍙樹负', newPath) + input3.value = newPath.key + getBookList() }, - data() { - return { - searchFields: "", - detailRoute: "bookStore-detail", - channel: "caupress_bookMall", - defaultType: 2, // 榛樿鎼滅储涔﹀煄 - searchValue: "", - }; - }, - created() { - this.searchValue = this.$route.query.searchValue; - }, - methods: { - switchType(type) { - if (type == 1) { - this.defaultType = 1; - this.channel = "caupress_teachingResource"; - this.detailRoute = "teachingServices-detail"; - } else { - this.defaultType = 2; - this.channel = "caupress_bookMall"; - this.detailRoute = "bookStore-detail"; - } +) + +const toDetail = (item) => { + router.push({ + path: '/bookdetail', + query: { + bookId: item.id, }, - }, - watch: { - $route: { - handler: function (val, oldval) { - if (val.name == "search") { - if (this.searchValue != this.$route.query.searchValue) { - this.searchValue = this.$route.query.searchValue; - } - // 濡傛灉鎼滅储鐨勯�夐」鍗′綅浜庢暀瀛︽湇鍔★紝鍒欓粯璁ゆ悳绱㈡暀瀛︽湇鍔� - if (this.$route.query.searchPath == "caupress_teachingResource") { - this.switchType(1); - } - switch (this.$route.query.searchType) { - case "bookName": - this.searchFields = "Name"; - break; - case "isbn": - this.searchFields = "caupress_ISBN"; - break; - case "author": - this.searchFields = "caupress_author"; - break; - case "projectTitle": - this.searchFields = "caupress_projectTitle"; - break; - } - } + }) +} + +const changeLevel = (item) => { + currentLevel.value = item.value + getBookList() +} + +const getBanner = () => { + MG.resource + .getItem({ + path: 'banner\\educationPublishing', + fields: { link: [] }, + paging: { start: 0, size: 20 }, + }) + .then((res) => { + banner.push(...res.datas) + console.log(res.datas) + }) +} + +const handleCurrentChange = (val) => { + currentPage1.value = val + getBookList() +} + +const getRecommendBookList = () => { + MG.store + .getProductList({ + path: 'recommendedTextbooks', + paging: { + start: 0, + size: 5, }, - immediate: true, - deep: true, + fields: { + author: [], + }, + }) + .then((res) => { + console.log(res, '鎺ㄨ崘鏁欐潗') + recommendBookListData.value = res.datas + }) +} + +const getBookList = () => { + const query = { + path: '*', + queryType: '*', + storeInfo: 'defaultGoodsStore1', + paging: { + start: (currentPage1.value - 1) * 20, + size: 20, }, - }, - // 濡傛灉璺宠浆椤甸潰涓嶆槸璇︽儏锛屽垯灏嗗綋鍓嶉〉闈笉缂撳瓨 - beforeRouteLeave(to, from, next) { - if (to.name != "teachingServices-detail" && to.name != "bookStore-detail") { - this.$store.commit("delKeepAlive", from.name); - } - next(); - }, -}; + fields: {}, + } + if (currentLevel.value !== 'all') { + query.fields['teachingLevel='] = currentLevel.value + } + if (input3.value) { + query.fields['Name*'] = input3.value + } + MG.store.getProductList(query).then((res) => { + console.log(res, '11111111111') + bookListData.value = res.datas + total.value = res.total + }) +} + +const classifList = () => { + const query = { + refCodes: ['digitalTextbooks'], + } + MG.resource.getCmsTypeByRefCode(query).then((res) => { + console.log(res, 'res') + const types = toolClass.handleTypeList(res) + const typeData = types[0].cmsTypeLinks[0].children + feildList.push(...typeData) + const temp_classfeild = typeData.find((item) => item.typeField.refCode === 'teachingLevel') + ?.typeField.cfg.option + classfeild.push({ name: '鍏ㄩ儴', value: 'all' }, ...temp_classfeild) + console.log(typeData, 'typeData') + console.log(classfeild, 'classfeild') + }) +} +onMounted(() => { + console.log(route.query, 'router.query') + input3.value = route.query.key + getBanner() + classifList() + getBookList() + getRecommendBookList() +}) </script> + <style lang="less" scoped> -.contentBox { - padding-bottom: 120px; +.homePage { + min-width: 1220px; + min-height: calc(100vh - 61.8%); + background-color: #fff; + padding-bottom: 100px; - .el-row { - margin-bottom: 10px; + .bannerBox { + height: 380px; + 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: 36px; + opacity: 0.45; + margin-top: 20px; + } } - .crumbs { - padding: 35px 0 25px 0; - line-height: 70px; + .classificationBox { + display: flex; + justify-content: space-between; + margin-top: 30px; + .classificaListBox { + display: flex; + flex-wrap: wrap; + .classificaItem { + display: flex; + align-items: center; + justify-content: center; + margin-right: 20px; + margin-bottom: 20px; + padding: 10px 16px; + width: 200px; + line-height: 20px; + background: #f5f5f5; + text-align: center; + } + } } + .bookList { + display: flex; + justify-content: space-between; + padding: 20px; + + .bookfilterList { + width: 100%; + border: 1px solid #e4e7ed; + height: 100%; + border-radius: 10px; + .listTitle { + display: flex; + justify-content: space-between; + align-items: center; + padding: 20px 30px; + } + } + .recommendBox { + width: 19%; + border: 1px solid #e4e7ed; + border-radius: 10px; + .recommendTitle { + height: 50px; + line-height: 50px; + padding-left: 20px; + border-bottom: 1px solid #e4e7ed; + color: #333333; + font-weight: 700; + } + } + } +} +.recommendList { + display: flex; + padding: 20px; + padding-top: 0; + flex-wrap: wrap; + justify-content: start; + + .recommendItem { + margin-right: 20px; + width: 22%; + height: 300px; + background-repeat: no-repeat; + background-size: 100% 100%; + cursor: pointer; + border: 1px solid #dedede; + background-color: #fff; + padding-top: 10px; + margin-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; + } + .author { + margin-top: 10px; + } + .priceBox { + margin-top: 10px; + .oldPrice { + font-size: 16px; + color: #444444; + text-decoration: line-through; + margin-right: 20px; + } + .price { + span { + font-weight: bold; + font-size: 14px; + } + } + } +} + +.newRecommendList { + padding-top: 0; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + .recommendItem { + margin-right: 20px; + height: 300px; + background-repeat: no-repeat; + background-size: 100% 100%; + cursor: pointer; + background-color: #fff; + padding-top: 10px; + margin-top: 10px; + &:last-child { + margin-right: 0; + } + } + .recommendItemImg { + width: 150px; + height: 200px; + position: relative; + margin: 0 auto; + } + .infoBox { + text-align: center; + margin-top: 10px; + } + .author { + margin-top: 10px; + } + .priceBox { + margin-top: 10px; + .oldPrice { + font-size: 16px; + color: #444444; + text-decoration: line-through; + margin-right: 20px; + } + .price { + span { + font-weight: bold; + font-size: 14px; + } + } + } +} +.pagingBox { + display: flex; + justify-content: center; + margin: 20px 0; + padding-bottom: 30px; +} + +.active { + background-color: #ebf8f8; + border: 1px solid #144941; + color: #144941; } </style> -- Gitblit v1.9.1