浏览代码

订阅入口

natasha 1 年之前
父节点
当前提交
ac180c3753
共有 3 个文件被更改,包括 314 次插入143 次删除
  1. 46 15
      src/components/common/BookListModule.vue
  2. 226 0
      src/components/common/BookPeruseCard.vue
  3. 42 128
      src/views/bookStore/index.vue

+ 46 - 15
src/components/common/BookListModule.vue

@@ -28,23 +28,45 @@
                 <img src="../../assets/baozhi-ding.png" class="baozhi-ding" />
             </a>
         </template>
+        <template v-if="name==='jingdu'">
+            <a class="img-box">
+                <img src="../../assets/jingdu-ding.png" class="baozhi-dings" />
+            </a>
+        </template>
         <div class="item-box">
-            <BookCard
-                :item="item"
-                :headerBg="headerBg"
-                :headerBorder="headerBorder"
-                :userBg="userBg"
-                :LoginNavIndex="LoginNavIndex"
-                :previousPage="previousPage"
-                class="item"
-                v-for="(item,index) in list"
-                :key="index+'todayNew'"
-                :style="{
-                    marginLeft:index==0?'0':'24px',
-                }"
-            />
+            <template v-if="name==='jingdu'">
+                <BookPeruseCard
+                    :item="item"
+                    :headerBg="headerBg"
+                    :headerBorder="headerBorder"
+                    :userBg="userBg"
+                    :LoginNavIndex="LoginNavIndex"
+                    :previousPage="previousPage"
+                    class="item item-jingdu"
+                    v-for="(item,index) in list"
+                    :key="index+'todayNew'"
+                    :style="{
+                        marginLeft:index==0?'0':'24px',
+                    }"
+                />
+            </template>
+            <template v-else>
+                <BookCard
+                    :item="item"
+                    :headerBg="headerBg"
+                    :headerBorder="headerBorder"
+                    :userBg="userBg"
+                    :LoginNavIndex="LoginNavIndex"
+                    :previousPage="previousPage"
+                    class="item"
+                    v-for="(item,index) in list"
+                    :key="index+'todayNew'"
+                    :style="{
+                        marginLeft:index==0?'0':'24px',
+                    }"
+                />
+            </template>
         </div>
-        
       </div>
     </div>
   </div>
@@ -54,10 +76,12 @@
 //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
 //例如:import 《组件名称》from ‘《组件路径》';
 import BookCard from "./BookCard.vue"
+import BookPeruseCard from "./BookPeruseCard.vue"
 export default {
   //import引入的组件需要注入到对象中才能使用
   components: {
     BookCard,
+    BookPeruseCard
   },
   props: ["list", "name", "value","LoginNavIndex","userBg","headerBorder","headerBg","previousPage"],
   data() {
@@ -207,6 +231,9 @@ export default {
       border-radius: 8px;
       overflow: hidden;
       background: #ffffff;
+      &.item-jingdu{
+        width: 282px;
+      }
       &:hover{
         box-shadow:  0px 0px 30px rgba(0,0,0,0.1);
       }
@@ -220,5 +247,9 @@ export default {
     width: 450px;
     height: 384px;
   }
+  .baozhi-dings{
+    width: 282px;
+    height: 306px;
+  }
 }
 </style>

+ 226 - 0
src/components/common/BookPeruseCard.vue

@@ -0,0 +1,226 @@
+<template>
+    <div>
+        <el-skeleton style="width: 282px" :loading="true" animated v-if="item.skeleton">
+            <template slot="template">
+                <el-skeleton-item
+                    variant="image"
+                    style="width: 282px; height: 174px;"
+                />
+                <div style="padding: 12px;width: 282px;">
+                    <el-skeleton-item variant="h3" style="width: 100%; height: 48px" />
+                    <el-skeleton-item variant="text" style="margin: 4px 0 12px 0; height: 20px; width:50%;" />
+                    <el-skeleton-item variant="text" style="height: 21px; width:70%;" v-if="!type||type!='bookShelf'" />
+                </div>
+            </template>
+        </el-skeleton>
+        <div class="BookCard" @click="handleLink" v-else>
+            <!-- <div
+            class="image"
+            :style="{height:height?height:'280px'}"
+            ></div> -->
+            <el-image
+                class="image"
+                :src="item.cover_image_url?item.cover_image_url:item.course_type==='baozhi'?require('../../assets/baozhi'+(Math.floor(Math.random()*2)+1)+'.png'):require('../../assets/kecheng'+(Math.floor(Math.random()*3)+1)+'.png')"
+                :fit="'cover'">
+            </el-image>
+            <div class="bottom">
+            <p class="name">{{item.name}}</p>
+            <!-- <template>
+                <el-rate
+                v-model="item.score"
+                disabled
+                show-score
+                :colors="colors"
+                :score-template="score"
+                >
+                </el-rate>
+            </template> -->
+            <p class="author">
+               <span>科普知识与现代技术</span> 
+               <label class="xiaoxue">小学版</label>
+            </p>
+            <template v-if="!type||type!='bookShelf'">
+                <p class="price">
+                <span class="OPPOSans">¥{{item.price_discount?item.price_discount:item.price|cutMoneyFiter}}</span>
+                <s v-if="item.price_discount&&item.price_discount!==item.price">¥{{item.price|cutMoneyFiter}}</s>
+                </p>
+            </template>
+            </div>
+        </div> 
+    </div>
+</template>
+
+<script>
+//这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
+//例如:import 《组件名称》from ‘《组件路径》';
+import { cutMoneyFiter } from '@/utils/defined';
+export default {
+  name: "BookCard",
+  //import引入的组件需要注入到对象中才能使用
+  components: {},
+  props: ["item", "height","type","LoginNavIndex","userBg","headerBorder","headerBg","previousPage","isBuy"],
+  filters:{
+    cutMoneyFiter
+  },
+  data() {
+    //这里存放数据
+    return {
+      goodsTypeList:{
+        0:{
+            type: 'LB'
+        },
+        2:{
+            type: 'baozhi'
+        }
+      }
+    }
+  },
+  //计算属性 类似于data概念
+  computed: {
+    score() {
+      return this.item.score.toFixed(1)
+    }
+  },
+  //监控data中数据变化
+  watch: {},
+  //方法集合
+  methods: {
+    changeData(data) {
+      var datasort = data.sort((a, b) => a.date.localeCompare(b.date));
+      var timeArr = new Set(datasort.map(it => it.date))
+      let newarr = []
+      let rateArr = []
+      timeArr.forEach(item => {
+        let a = {
+          date: "",
+          arr: []
+        }
+        data.forEach(items => {
+          if (item == items.date) {
+            a.date = items.date
+            a.arr.push(items.weight)
+            rateArr.push(items.rate)
+          }
+        })
+        newarr.push(a)
+      })
+      newarr.forEach(item => {
+        if (item.arr.length < 3) {
+          for (let i = 0; i < 3 - (item.arr.length - 1); i++) {
+            item.arr.push(0)
+          }
+        }
+      })
+      return { newarr, timeArr, rateArr }
+    },
+    handleLink(){
+        let url  = this.LoginNavIndex +'&&&1&&&2&&&3&&&' + this.previousPage
+        this.$router.push({
+            path: "/bookItem",
+            query: {
+                headerConfig: encodeURIComponent(url),
+                isBuy:this.isBuy,
+                cardType: this.item.course_type||this.goodsTypeList[this.item.type].type,
+                id: this.item.id
+            },
+        });
+    }
+  },
+  //生命周期 - 创建完成(可以访问当前this实例)
+  created() {
+    // let data = this.changeData(this.dataContext)
+  },
+  //生命周期 - 挂载完成(可以访问DOM元素)
+  mounted() {
+
+  },
+  //生命周期-创建之前
+  beforeCreated() { },
+  //生命周期-挂载之前
+  beforeMount() { },
+  //生命周期-更新之前
+  beforUpdate() { },
+  //生命周期-更新之后
+  updated() { },
+  //生命周期-销毁之前
+  beforeDestory() { },
+  //生命周期-销毁完成
+  destoryed() { },
+  //如果页面有keep-alive缓存功能,这个函数会触发
+  activated() { }
+}
+</script>
+<style lang="scss" scoped>
+/* @import url(); 引入css类 */
+.BookCard {
+  width: 100%;
+  cursor: pointer;
+  .image {
+    width: 100%;
+    height: 174px;
+  }
+  .bottom {
+    // height: 132px;
+    padding: 12px;
+  }
+  p {
+    margin: 0;
+    padding: 0;
+  }
+  .name {
+    width: 100%;
+    height: 48px;
+    font-weight: 400;
+    font-size: 14px;
+    line-height: 22px;
+    color: #2F3742;
+    word-break: break-word;
+    display: -webkit-box;
+    -webkit-box-orient: vertical;
+    -webkit-line-clamp: 2;
+    text-overflow: ellipsis;
+    overflow: hidden;
+  }
+  .author {
+    margin-top: 4px;
+    height: 20px;
+    font-size: 12px;
+    line-height: 20px;
+    font-weight: 500;
+    display: flex;
+    align-items: center;
+    span{
+       padding: 0px 8px; 
+       border-radius: 2px;
+       background: #F2F3F5;
+       color: #1D2129;
+       margin-right: 4px;
+    }
+    .xiaoxue{
+        padding: 0px 8px;
+        border-radius: 2px;
+        background: #E8FFFB;
+        color: #0FC6C2;
+    }
+  }
+  .price {
+    margin-top: 12px;
+    display: flex;
+    align-items: flex-end;
+    :nth-child(1) {
+      font-weight: 700;
+      font-size: 14px;
+      line-height: 22px;
+      color: #EC5E41;
+    }
+    :nth-child(2) {
+      font-weight: 400;
+      font-size: 12px;
+      line-height: 20px;
+      text-decoration-line: line-through;
+      color: #929CA8;
+      margin-left: 8px;
+    }
+  }
+}
+</style>

+ 42 - 128
src/views/bookStore/index.vue

@@ -46,6 +46,17 @@
         :previousPage="'报纸'"
         v-if="IssueList.length>0"
       />
+      <BookListModule
+        name="jingdu"
+        :list="PeruseList"
+        :headerBg="'#1F1F1F'"
+        :headerBorder="'#5C5C5C'"
+        :userBg="'rgba(0, 0, 0, 0.24)'"
+        :LoginNavIndex="0"
+        :previousPage="'精读课堂'"
+        v-if="IssueList.length>0"
+      />
+
       <!-- <BookListModule
         name="xiti"
         :list="BookList"
@@ -93,134 +104,6 @@ export default {
   data() {
     //这里存放数据
     return {
-      BookList: [{
-        src: require('../../assets/huakan2.png'),
-        name: "第96期",
-        price: "23.00",
-        oldprice: "33.00",
-        author: "TEENS",
-        score: 3,
-        progress: "90%"
-      },
-      {
-        src: require('../../assets/huakan3.png'),
-        name: "第87期",
-        price: "27.00",
-        oldprice: "43.00",
-        author: "2022-04-15",
-        score: 3,
-      },
-      {
-        src: require('../../assets/huakan3.png'),
-        name: "第86期 ",
-        price: "19.00",
-        oldprice: "27.00",
-        author: "TEENS",
-        score: 3,
-      },
-      {
-        src: require('../../assets/huakan2.png'),
-        name: "第85期",
-        price: "28.90",
-        oldprice: "39.00",
-        author: "TEENS",
-        score: 3,
-      },
-      {
-        src: require('../../assets/huakan2.png'),
-        name: "第84期",
-        price: "23.00",
-        oldprice: "30.00",
-        author: "TEENS",
-        score: 3,
-      }
-      ],
-      BookList2:[
-        {
-        src: require('../../assets/baozhi2.png'),
-        name: "第815期",
-        price: "43.00",
-        oldprice: "76.00",
-        author: "2023-05-15",
-        score: 3,
-        progress: "90%"
-      },
-      {
-        src: require('../../assets/baozhi1.png'),
-        name: "第814期 ",
-        price: "47.90",
-        oldprice: "66.00",
-        author: "2023-05-08",
-        score: 3,
-      },
-      {
-        src: require('../../assets/baozhi1.png'),
-        name: "第813期  ",
-        price: "22.00",
-        oldprice: "27.00",
-        author: "2023-05-01",
-        score: 3,
-      },
-      {
-        src: require('../../assets/baozhi2.png'),
-        name: "第812期",
-        price: "45.90",
-        oldprice: "78.00",
-        author: "2023-04-24",
-        score: 3,
-      },
-      {
-        src: require('../../assets/baozhi2.png'),
-        name: "第811期",
-        price: "43.00",
-        oldprice: "60.00",
-        author: "2023-04-17",
-        score: 3,
-      }
-      ],
-      BookList3:[
-        {
-        src: require('../../assets/kecheng1.png'),
-        name: "第815期",
-        price: "43.00",
-        oldprice: "76.00",
-        author: "2023-05-15",
-        score: 3,
-        progress: "90%"
-      },
-      {
-        src: require('../../assets/kecheng2.png'),
-        name: "第814期 ",
-        price: "47.90",
-        oldprice: "66.00",
-        author: "2023-05-08",
-        score: 3,
-      },
-      {
-        src: require('../../assets/kecheng3.png'),
-        name: "第813期  ",
-        price: "22.00",
-        oldprice: "27.00",
-        author: "2023-05-01",
-        score: 3,
-      },
-      {
-        src: require('../../assets/kecheng1.png'),
-        name: "第812期",
-        price: "45.90",
-        oldprice: "78.00",
-        author: "2023-04-24",
-        score: 3,
-      },
-      {
-        src: require('../../assets/kecheng2.png'),
-        name: "第811期",
-        price: "43.00",
-        oldprice: "60.00",
-        author: "2023-04-17",
-        score: 3,
-      }
-      ],
       LBCourseList:[
         {
             skeleton: true
@@ -255,6 +138,17 @@ export default {
             skeleton: true
         }
       ], // 报纸列表
+      PeruseList: [
+        {
+            skeleton: true
+        },
+        {
+            skeleton: true
+        },
+        {
+            skeleton: true
+        }
+      ], // 精读列表
       bannerFlag: true // 是否展示广告
     }
   },
@@ -301,12 +195,32 @@ export default {
         .catch(() => {
             
         }); 
+    },
+    // 精读列表
+    getPeruseList(){
+        let MethodName = "/ShopServer/Client/ShopHomeQuery/QueryIssueList";
+        let data = {
+            top_n: 3
+        }
+        getLogin(MethodName, data)
+        .then((res) => {
+            if(res.status===1){
+                res.issue_list.forEach(item => {
+                    item.course_type="jingdu"
+                });
+                this.PeruseList = res.issue_list
+            }
+        })
+        .catch(() => {
+            
+        }); 
     }
   },
   //生命周期 - 创建完成(可以访问当前this实例)
   created() {
     this.getLBCourseList()
     this.getIssueList()
+    this.getPeruseList()
   },
   //生命周期 - 挂载完成(可以访问DOM元素)
   mounted() {