杨磊
6 小时以前 5967652081d92180adbc78da809c26cff5cf730a
搜索页面
1个文件已添加
7个文件已修改
528 ■■■■■ 已修改文件
src/layout/baseLayout.vue 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layout/components/headerPage.vue 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main.js 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.js 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/aboutUs/index.vue 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/bookStore/detail.vue 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/bookStore/index.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/home/search.vue 423 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layout/baseLayout.vue
@@ -13,8 +13,18 @@
import Header from './components/headerPage.vue'
import Footer from './components/footerPage.vue'
import login from './components/login.vue'
import { provide, ref } from 'vue'
import { provide, ref, watch } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
watch(
  () => router.currentRoute.value.path,
  (toPath) => {
    const layout = document.getElementById('layout')
    if (layout) layout.scrollTo(0, 0)
  },
  { immediate: true, deep: true },
)
const logIn = () => {
  loginRef.value.logIn()
}
src/layout/components/headerPage.vue
@@ -17,9 +17,9 @@
        <el-input
          style="width: 500px; height: 50px"
          placeholder="请输入内容"
          @change="gotoSearch"
          v-model="searchKey"
          :suffix-icon="Search"
          @keyup.enter="gotoSearch"
        >
        </el-input>
        <div class="loginInfoBox">
@@ -80,6 +80,7 @@
import { Search } from '@element-plus/icons-vue'
import { useUserStore } from '@/store'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
const userStore = useUserStore()
const router = useRouter()
@@ -121,7 +122,14 @@
  console.log(userInfo.value, 'userInfo')
})
const gotoSearch = () => {}
const gotoSearch = () => {
  router.push({
    path: '/search',
    query: {
      key: searchKey.value,
    },
  })
}
const handleCommand = (item) => {
  if (item === 'gotoPersonalCenter') {
    router.push({
@@ -136,7 +144,14 @@
  }
}
const gotoPage = (item) => {
  router.push(item.path)
  if (item.path === '/teachingServices') {
    ElMessage({
      message: '建设中...',
      type: 'warning',
    })
  } else {
    router.push(item.path)
  }
}
</script>
src/main.js
@@ -33,3 +33,8 @@
// })
app.use(ElementPlus, { locale })
app.mount('#app')
router.beforeEach((to, from, next) => {
  window.scrollTo({ top: 0 }) // 将滚动条位置设为0
  next()
})
src/router/index.js
@@ -27,16 +27,33 @@
          path: '/bookdetail',
          name: 'bookdetail',
          component: bookdetail,
          meta: {
            scrollToTop: true,
          },
        },
        {
          path: '/search',
          name: 'search',
          meta: {
            name: '搜索',
          },
          component: () => import('@/views/home/search.vue'),
        },
        {
          path: '/bookStore',
          name: 'bookStore',
          component: bookStore,
          meta: {
            scrollToTop: true,
          },
        },
        {
          path: '/textBookApply',
          name: 'textBookApply',
          component: () => import('@/views/bookStore/textBookApply.vue'),
          meta: {
            scrollToTop: true,
          },
        },
        //个人中心
        {
@@ -265,6 +282,9 @@
      ],
    },
  ],
  scrollBehavior(to, from, savedPosition) {
    return { x: 0, y: 0 }
  },
})
export default router
src/views/aboutUs/index.vue
@@ -1,12 +1,12 @@
<template>
  <div class="homePage">
    <el-carousel :height="screenheight + 'px'">
      <el-carousel-item v-for="(item, index) in banner" :key="index">
        <div class="bannerBox imgBox">
          <img id="autoHeight" class="bannerImg" :src="item.icon" @click="bannerLink(item)" />
        </div>
      </el-carousel-item>
    </el-carousel>
    <div class="bannerBox imgBox">
      <img class="bannerImg" :src="banner[0]?.icon" @click="bannerLink(item)" />
      <div class="bannerText">
        <div>中国协和医科大学出版社</div>
        <div class="enText">ABOUT US</div>
      </div>
    </div>
    <div class="contentBox">
      <div class="crumbs">
@@ -150,7 +150,7 @@
const getBanner = () => {
  MG.resource
    .getItem({
      path: 'banner\\homeBanner',
      path: 'banner\\about',
      fields: { link: [] },
      paging: { start: 0, size: 9 },
    })
@@ -213,6 +213,26 @@
</script>
<style lang="less" scoped>
.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;
  }
}
.homePage {
  min-width: 1220px;
  min-height: calc(100vh - 61.8%);
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>
@@ -277,6 +277,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'
@@ -301,9 +302,11 @@
let recommendBookListData = ref([])
let editableTabsValue = ref('1')
let resourceHave = ref(true)
let loading = ref(false)
var chartDom = null
var myChart = {}
var option = null
const editableTabs = reactive([
  {
    title: '教材信息',
@@ -510,6 +513,7 @@
}
const getBookDetail = (id) => {
  loading.value = true
  const query = {
    path: '*',
    queryType: '*',
@@ -536,6 +540,7 @@
  MG.store.getProductDetail(query).then((res) => {
    console.log(res, 'res')
    bookInfo.value = res.datas
    loading.value = false
    console.log(res.datas, 'res')
  })
}
src/views/bookStore/index.vue
@@ -4,7 +4,7 @@
      <img class="bannerImg" :src="banner[0]?.icon" @click="bannerLink(item)" />
      <div class="bannerText">
        <div>数字教材</div>
        <div class="enText">ABOUT US</div>
        <div class="enText">TEXT BOOK</div>
      </div>
    </div>
    <div class="contentBox" style="margin-top: 50px">
src/views/home/search.vue
New file
@@ -0,0 +1,423 @@
<template>
  <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 style="width: 300px">
              <el-input
                v-model="input3"
                placeholder="输入教材名称、作者姓名、出品方名称搜索"
                class="input-with-select"
              >
                <template #append>
                  <el-button :icon="Search" @click="getBookList" />
                </template>
              </el-input>
            </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 class="recommendBox">
          <div class="recommendTitle">推荐教材</div>
          <div class="newRecommendList">
            <div class="recommendItem" v-for="item in recommendBookListData" :key="item.id">
              <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>
    </div>
  </div>
</template>
<script setup>
import { ref, onBeforeMount, inject, reactive, onMounted } 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')
const toDetail = (item) => {
  router.push({
    path: '/bookdetail',
    query: {
      bookId: item.id,
    },
  })
}
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,
      },
      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,
    },
    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>
.homePage {
  min-width: 1220px;
  min-height: calc(100vh - 61.8%);
  background-color: #fff;
  padding-bottom: 100px;
  .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;
    }
  }
  .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: 80%;
      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;
    }
  }
  .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>