Textbook.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <!-- 教科书 -->
  3. <div class="Textbook">
  4. <div class="top">
  5. <div class="title">
  6. <span class="text"> <!-- 教研资料 -->{{ $t('Key554') }} </span>
  7. <div class="more" @click="goMore">
  8. <span> <!-- 查看更多 -->{{ $t('Key47') }} </span>
  9. <img src="../../assets/teacherdev/moreImage.png" alt="" />
  10. </div>
  11. </div>
  12. </div>
  13. <div class="class_list">
  14. <div v-for="(item, i) in classList" :key="i" @click="gopreview(item)">
  15. <div class="listImage">
  16. <img :src="getCoverImg(item)" alt="封面" />
  17. </div>
  18. <p class="one_name">{{ item.name }}</p>
  19. <p v-if="item.price * 1 > 0" class="price">
  20. ¥<span class="price_1" v-html="changePrice(item.price * 1, 24, 16)"></span>
  21. </p>
  22. </div>
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. import { getCoverImg } from '@/utils/index';
  28. export default {
  29. props: {
  30. classList: {
  31. type: Array,
  32. default: () => [],
  33. },
  34. },
  35. data() {
  36. return {
  37. getCoverImg,
  38. };
  39. },
  40. methods: {
  41. // 前往更多
  42. goMore() {
  43. this.$router.push({
  44. path: '/Viewmore',
  45. query: {
  46. classify: 'TEXTBOOK',
  47. },
  48. });
  49. },
  50. gopreview(item) {
  51. this.$router.push({
  52. path: '/Preview',
  53. query: {
  54. id: item.id,
  55. },
  56. });
  57. },
  58. // 处理价格
  59. changePrice(price, fontSize1, fontSize2) {
  60. let _price = price || 0;
  61. _price = _price.toFixed(2).toString();
  62. let arr = _price.split('.');
  63. let str = `<span style="font-size: ${fontSize1 || 16}px;">${arr[0]}</span>.<span style="font-size: ${
  64. fontSize2 || 16
  65. }px;">${arr[1]}</span>`;
  66. return str;
  67. },
  68. },
  69. };
  70. </script>
  71. <style lang="scss" scoped>
  72. .Textbook {
  73. .top {
  74. display: flex;
  75. justify-content: space-between;
  76. width: 1200px;
  77. margin: 0 auto;
  78. .title {
  79. display: flex;
  80. align-items: center;
  81. justify-content: space-between;
  82. width: 100%;
  83. height: 90px;
  84. .text {
  85. position: relative;
  86. font-size: 24px;
  87. font-weight: bold;
  88. }
  89. .more {
  90. display: flex;
  91. align-items: center;
  92. font-size: 16px;
  93. cursor: pointer;
  94. span {
  95. opacity: 0.4;
  96. }
  97. img {
  98. width: 25px;
  99. height: 19px;
  100. }
  101. }
  102. }
  103. }
  104. .class_list {
  105. box-sizing: border-box;
  106. display: flex;
  107. flex-wrap: wrap;
  108. justify-content: flex-start;
  109. width: 1200px;
  110. padding: 50px 20px 8px;
  111. margin: 0 auto;
  112. background: #fff;
  113. > div {
  114. width: 192px;
  115. margin-right: 20px;
  116. margin-left: 20px;
  117. cursor: pointer;
  118. transition: all 1s;
  119. .one_name {
  120. display: -webkit-box;
  121. height: 48px;
  122. padding-left: 4px;
  123. margin-top: 16px;
  124. overflow: hidden;
  125. font-size: 16px;
  126. line-height: 150%;
  127. color: #2c2c2c;
  128. text-overflow: ellipsis;
  129. word-break: break-all;
  130. cursor: pointer;
  131. -webkit-box-orient: vertical;
  132. -webkit-line-clamp: 2;
  133. }
  134. .price {
  135. margin-bottom: 32px;
  136. font-size: 24px;
  137. font-weight: bold;
  138. color: #2c2c2c;
  139. .price_2 {
  140. font-size: 16px;
  141. }
  142. }
  143. p {
  144. font-size: 16px;
  145. }
  146. .listImage {
  147. display: flex;
  148. align-items: center;
  149. justify-content: center;
  150. width: 100%;
  151. height: 256px;
  152. color: #c0c4cc;
  153. // border: 1px solid rgba(0, 0, 0, 0.15);
  154. img {
  155. max-width: 100%;
  156. max-height: 100%;
  157. }
  158. }
  159. .gray {
  160. color: #a3a3a3;
  161. }
  162. .origin {
  163. color: #f90;
  164. }
  165. }
  166. .more {
  167. position: relative;
  168. background: url('../../assets/teacherdev/image 13.png') center;
  169. .shade {
  170. position: absolute;
  171. display: flex;
  172. align-items: center;
  173. justify-content: center;
  174. width: 100%;
  175. height: 100%;
  176. cursor: pointer;
  177. background: #000;
  178. opacity: 0.6;
  179. > div {
  180. img {
  181. width: 58px;
  182. height: 58px;
  183. }
  184. span {
  185. position: relative;
  186. top: -20px;
  187. color: white;
  188. }
  189. }
  190. }
  191. }
  192. }
  193. }
  194. </style>