当前位置: 首页 > article >正文

网络书店前端代码

<template>
  <el-container>
    <el-header >
      <el-menu
          mode="horizontal"
          background-color="#545c64"
          text-color="#fff">
        <el-menu-item index="1">在线书城</el-menu-item>
        <el-menu-item index="2">首页</el-menu-item>

        <el-submenu index="3">
          <template slot="title">图书类型</template>
          <el-menu-item index="3-1">哲学</el-menu-item>
          <el-menu-item index="3-2">政治</el-menu-item>
          <el-menu-item index="3-3">经济</el-menu-item>
        </el-submenu>
        <el-menu-item index="4">登录</el-menu-item>
        <el-menu-item index="5">安全退出</el-menu-item>
        <el-menu-item index="6">注册</el-menu-item>
        <el-menu-item index="7" class="el-icon-shopping-cart-full">订单管理</el-menu-item>
        <el-menu-item style="right: 5%; position:fixed" >
              <el-input placeholder="请输入图书名称" clearable  v-model="bookSearch"></el-input>
              <el-button type="primary" icon="el-icon-search" style="height: 40px;margin-left:5px;margin-top: 2px"></el-button>
        </el-menu-item>


      </el-menu>
    </el-header>


    <el-main>
      <el-row>
        <el-col :span="24" style="height: 300px">
    <el-carousel indicator-position="none" style="height: 300px">
      <el-carousel-item v-for="item in imgList" :key="item.id">
        <img :src="item.idView" class="image" style="width: 100%;height: 300px" >
      </el-carousel-item>
    </el-carousel>
        </el-col>
      </el-row>


      <el-row >
        <el-col :span="6" v-for="(b,index) in booksList" :key="index" >
          <el-card>
            <img :src="require('../assets/'+b.image)" class="image">
            <div style="font-size: 18px;padding-top: 5px">
              {{b.name}}
            </div>
            <div style="font-size: 10px;text-align: left;padding-top: 5px">
              作者:{{b.author}}
            </div>


            <el-popover class="button"
                        placement="right"
                        width="400"
                        trigger="click">
              <el-descriptions title="书籍信息">
                <el-descriptions-item label="书名">{{book.bookName}}}</el-descriptions-item>
                <el-descriptions-item label="作者">{{book.author}}</el-descriptions-item>
                <el-descriptions-item label="价格">{{book.price}}</el-descriptions-item>
                <el-descriptions-item label="简介">{{book.description}}</el-descriptions-item>
              </el-descriptions>
              <el-button type="text" slot="reference" @click="open(b.id)">更多信息</el-button>
            </el-popover>






          </el-card>
        </el-col>
      </el-row>


      <el-row>
        <el-col>
          <div class="block">
            <el-pagination
                :page-sizes="[2,4]"
                :page-size="pageSize"
                :current-page="pageNum"
                @current-change="handleCurrentChange"
                @prev-click="prevPage"
                @next-click="nextPage"
                @size-change="changePage"
                layout="total,sizes,prev, pager, next"
                :total="total">
            </el-pagination>
          </div>
        </el-col>
      </el-row>





    </el-main>
  </el-container>
</template>
<script>

export default {
data(){
  return{
    total:0,
    pageNum:1,
    pageSize:4,
    bookSearch:'',
    ing:'.jpg',
    imgList: [
      {id:0,idView:require("@/assets/1.jpg")},
      {id:1,idView:require("@/assets/2.jpg")},
      {id:2,idView:require("@/assets/3.jpg")},
      {id:3,idView:require("@/assets/4.jpg")},
    ],
    booksList: {},
    book:{
      bookName:'',
      author:'',
      price:'',
      description:'',
    },
    }

  },
  methods:{
    open(id) {
      console.log(id)
      this.$axios.get(
          'api/book/findBookInformation?id='+id,
          {headers:{"jwt":localStorage.getItem("jwt")}})
          .then(res =>{
            console.log(res.data);
            this.book = res.data.data
          })
    },
    requestBookList(){
      let param = {};
          param.pageNum = this.pageNum;
          param.pageSize = this.pageSize;
          this.$axios.post(
              'api/book/findBookList',
              param,
              {headers:{"jwt":localStorage.getItem("jwt")}})
              .then(res =>{
                console.log(res.data)
                this.pageSize = res.data.data.pageSize;
                this.pageNum = res.data.data.pageNum;
                this.booksList = res.data.data.list;
                this.total = res.data.data.total
                console.log(this.booksList)
              })
    },
    prevPage(val){
      this.pageNum = val
      this.requestBookList();
    },
    nextPage(val){
      this.pageNum = val
      this.requestBookList();
    },
    changePage(val){
      this.pageNum = 1;
      this.pageSize = val;
      this.requestBookList();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.pageNum = val
      this.requestBookList();
    },


  },
  created() {
  this.requestBookList();
  }


}
</script>

<style scoped>
.el-header {
  background-color: #545c64;
  color: #333;
  text-align: center;
  line-height: 60px;
}
.el-main {
  background-color: #E9EEF3;
  color: #333;
  text-align: center;
}


.image {
  width: 100%;
  display: block;
}



.button {
  padding: 0;
  float: left;
}

.group-item-vo {
  display: flex;
  justify-content: flex-start;
  padding-bottom: 14px;
}


</style>

http://www.kler.cn/a/9631.html

相关文章:

  • 【Pikachu】目录遍历实战
  • AMD CPU下pytorch 多GPU运行卡死和死锁解决
  • 【机器学习】机器学习中用到的高等数学知识-2.概率论与统计 (Probability and Statistics)
  • Gurobi学术版+Anaconda安装步骤
  • React Native 全新架构来了
  • Nginx配置自带的stub状态实现活动监控指标
  • 1.docker-安装及使用
  • item_history_price-获取商品历史价格信息 API接入参数及说明
  • 2023年MathorCup数模B题赛题
  • 如何自学JAVA
  • SQL Server的事务日志
  • CentOS7 内网安装mosquitto
  • 【单片机/普中A2】学习笔记2-LED
  • Python json详解
  • Python 进阶指南(编程轻松进阶):五、发现代码异味
  • Oracle之表的设计
  • 接口自动化测试如何做?测试老鸟总结,接口测试数据构造大全......
  • DJ3-4 传输层(第四节课)
  • java File和IO流处理
  • 高效办公——Excel表格-02篇(if函数常见用法 + 条件格式的使用)
  • 解决macOS IntelliJ IDEA 卡顿问题
  • 突发!ChatGPT疯了!
  • 热点数据和冷数据是什么?
  • Jvm学习笔记(一)内存模型
  • 强大到让人无法想象的ChatGPT-5即将发布,上千名人士却紧急叫停
  • mybatis plus同时使用逻辑删除和唯一索引的问题及解决办法