hookehuyr

✨ feat(书籍详情页): 新增书籍简介相关功能

1 +/**
2 + * 判断多行省略文本
3 + * @param {*} id 目标dom标签
4 + * @returns
5 + */
6 +const hasEllipsis = (id) => {
7 + let oDiv = document.getElementById(id);
8 + let flag = false
9 + if (oDiv.scrollHeight > oDiv.clientHeight) {
10 + flag = true
11 + }
12 + return flag
13 +}
14 +
15 +export default {
16 + hasEllipsis
17 +}
...\ No newline at end of file ...\ No newline at end of file
...@@ -31,6 +31,14 @@ export default [{ ...@@ -31,6 +31,14 @@ export default [{
31 }, 31 },
32 children: [] 32 children: []
33 }, { 33 }, {
34 + path: '/client/bookDetail',
35 + name: '客户端选择书籍下视频作品',
36 + component: () => import('./views/client/bookDetail.vue'),
37 + meta: {
38 + title: '书籍'
39 + },
40 + children: []
41 +}, {
34 path: '/image', 42 path: '/image',
35 name: 'html转图片', 43 name: 'html转图片',
36 component: () => import('./views/html2canvas.vue'), 44 component: () => import('./views/html2canvas.vue'),
......
1 +<template>
2 + <div class="book-detail-page content-bg">
3 + <div class="modify-top"></div>
4 + <div class="book-detail">
5 + <div style="text-align: center;">
6 + <van-image
7 + width="220"
8 + height="220"
9 + src="https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPngc434046fdf1f9499d251b280af2568ddbe64839799d00a9aee226edbeb710aed"
10 + />
11 + </div>
12 + <div class="book-intro">
13 + <p class="book-post">逃家小兔绘本</p>
14 + <div id="book-intro" :class="{ 'van-multi-ellipsis--l3': isToggle }">
15 + 从前有一只小兔子,总是想要离家出走。有一天他对妈妈说:“我要跑走啦!”“如果你跑走了我就去追你,因为你是我的小宝贝呀!”妈妈说。
16 + 一场爱的捉迷藏就此展开了
17 + </div>
18 + <div v-if="hasToggle">
19 + <div v-if="isToggle" @click="onToggle(false)" class="book-toggle-icon">展开&nbsp;<van-icon style="vertical-align: middle;" size="0.9rem" name="http://gyzs.onwall.cn/icon-zhankai%402x.png" /></div>
20 + <div v-else @click="onToggle(true)" class="book-toggle-icon">折叠&nbsp;<van-icon style="vertical-align: middle;" size="0.9rem" name="http://gyzs.onwall.cn/icon-guanbi%402x.png" /></div>
21 + </div>
22 + </div>
23 + </div>
24 + <div style="height: 1rem;"></div>
25 + <to-me @on-click="gotoMe()"></to-me>
26 + </div>
27 +</template>
28 +
29 +<script setup>
30 +import ToMe from '@/components/ToMe/index.vue'
31 +import tools from '@/common/tool'
32 +import { ref, reactive, onMounted } from 'vue'
33 +import { useRoute, useRouter } from 'vue-router'
34 +import axios from '@/utils/axios';
35 +import $ from 'jquery'
36 +import { Toast } from 'vant';
37 +const $route = useRoute();
38 +const $router = useRouter();
39 +
40 + const items = reactive([])
41 +
42 + const gotoMe = () => {
43 + console.warn('跳转我的地址');
44 + }
45 +
46 + // 判断是否显示简介的展开图标
47 + let hasToggle = ref(false); // 判断是否有展开文字,默认没有
48 + let isToggle = ref(true); // 判断展开状态,默认展开
49 +
50 + const onToggle = (v) => { // 展开/折叠
51 + isToggle.value = v
52 + }
53 +
54 + onMounted(() => {
55 + // 判断是否显示简介的展开图标
56 + hasToggle.value = tools.hasEllipsis('book-intro');
57 + for (let index = 0; index < 20; index++) {
58 + items.push({
59 + id: index,
60 + avatar: 'https://cdn.jsdelivr.net/npm/@vant/assets/cat.jpeg'
61 + })
62 + }
63 + })
64 +</script>
65 +
66 +<script>
67 +import mixin from 'common/mixin';
68 +
69 +export default {
70 + mixins: [mixin.init],
71 + data () {
72 + return {
73 +
74 + }
75 + },
76 + mounted () {
77 +
78 + },
79 + methods: {
80 +
81 + }
82 +}
83 +</script>
84 +
85 +<style lang="less" scoped>
86 +@import url('@css/content-bg.less');
87 + .book-detail-page {
88 + overflow: auto;
89 + .book-detail {
90 + margin: 1rem;
91 + margin-top: 1.25rem;
92 + padding-top: 1rem;
93 + border-radius: 10px;
94 + background-color: rgba(255, 255, 255, 1);
95 + box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.13);
96 + .book-intro {
97 + padding: 1rem;
98 + .book-post {
99 + color: #222222;
100 + font-size: 1.25rem;
101 + font-weight: bold;
102 + }
103 + #book-intro {
104 + color: #333333;
105 + margin-top: 0.25rem;
106 + }
107 + .book-toggle-icon {
108 + text-align: right;
109 + color: #713610;
110 + font-size: 1rem;
111 + }
112 + }
113 + }
114 + }
115 +</style>
...\ No newline at end of file ...\ No newline at end of file
...@@ -45,9 +45,7 @@ onMounted (() => { ...@@ -45,9 +45,7 @@ onMounted (() => {
45 // 进入项目自动打开导航栏 45 // 进入项目自动打开导航栏
46 // window.history.pushState({}, "title", "#"); 46 // window.history.pushState({}, "title", "#");
47 // 背景颜色全屏 47 // 背景颜色全屏
48 - // $('.client-index-page').height($(document).height() - $('.entry-wrapper').outerHeight());
49 $('.client-index-page').height($(document).height()); 48 $('.client-index-page').height($(document).height());
50 - // $('.client-index-page').width($(document).width());
51 }) 49 })
52 </script> 50 </script>
53 51
...@@ -70,24 +68,6 @@ export default { ...@@ -70,24 +68,6 @@ export default {
70 </script> 68 </script>
71 69
72 <style lang="less" scoped> 70 <style lang="less" scoped>
73 - // .client-index-page {
74 - // // 背景图 宽度100% 高度自适应
75 - // background-image: url('@images/yindao@2x-1.png');
76 - // background-repeat: no-repeat;
77 - // width: 100%;
78 - // height: 100%;
79 - // background-size: 100% auto;
80 - // position: relative;
81 - // .cloud-bg {
82 - // background-image: url('@images/bg-white@2x.png');
83 - // background-repeat: no-repeat;
84 - // width: 100%;
85 - // height: 10rem;
86 - // background-size: 100% auto;
87 - // position: absolute;
88 - // bottom: 12rem;
89 - // }
90 - // }
91 .client-index-page { 71 .client-index-page {
92 // 背景图 宽度100% 高度控制 72 // 背景图 宽度100% 高度控制
93 background-image: url('@images/yindao@2x.png'); 73 background-image: url('@images/yindao@2x.png');
......