Textbook.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <!-- 教科书 -->
  3. <div class="Textbook">
  4. <div class="top">
  5. <div class="title">
  6. <span class="text"> 教材 </span>
  7. <div class="more" @click="goMore">
  8. <span> 查看更多 </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
  17. :src="
  18. require('../../assets/teacherdev/' + getimgurl(item) + '.png')
  19. "
  20. alt=""
  21. />
  22. <!-- <span v-else>加载失败</span> -->
  23. </div>
  24. <!-- <el-image
  25. lazy
  26. :src="require('../../assets/teacherdev/' + getimgurl(item) + '.png')"
  27. alt=""
  28. ></el-image> -->
  29. <p class="one_name">{{ item.name }}</p>
  30. <p class="price">
  31. <span class="price_1" v-text="changePrice('1', item.price)"></span>
  32. <span class="price_2" v-text="changePrice('2', item.price)"></span>
  33. </p>
  34. </div>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. export default {
  40. props: ["classList", "type"],
  41. data() {
  42. return {};
  43. },
  44. methods: {
  45. // 前往更多
  46. goMore() {
  47. this.$router.push({
  48. path: "/Viewmore",
  49. query: {
  50. classify: "TEXTBOOK",
  51. },
  52. });
  53. },
  54. gopreview(item) {
  55. this.$router.push({
  56. path: "/Preview",
  57. query: {
  58. id: item.id,
  59. },
  60. });
  61. },
  62. // 根据不同的文件类型展示不同图片
  63. getimgurl(item) {
  64. let index = item.tag.indexOf("downloadable");
  65. let type = "";
  66. if (index != -1) {
  67. type = item.tag[2];
  68. } else {
  69. type = item.tag[1];
  70. }
  71. switch (type) {
  72. case "ppt":
  73. return "ppt";
  74. case "pdf":
  75. return "pdf";
  76. case "xlsx":
  77. return "exceil";
  78. case "xls":
  79. return "exceil";
  80. case "doc":
  81. return "word";
  82. case "word":
  83. return "word";
  84. default:
  85. return "word";
  86. }
  87. },
  88. // 处理价格
  89. changePrice(type, item) {
  90. if (item.indexOf(".") != -1) {
  91. if (type == 1) {
  92. return item.split(".")[0];
  93. } else if (type == 2) {
  94. if (item.split(".")[1] * 1 >= 10) {
  95. return "." + item.split(".")[1];
  96. } else {
  97. return "." + item.split(".")[1] + "0";
  98. }
  99. }
  100. } else {
  101. if (type == 1) {
  102. return item;
  103. }
  104. if (type == 2) {
  105. return ".00";
  106. }
  107. }
  108. },
  109. },
  110. created() {},
  111. };
  112. </script>
  113. <style lang="scss" scoped>
  114. .Textbook {
  115. .top {
  116. width: 1200px;
  117. margin: 0 auto;
  118. display: flex;
  119. justify-content: space-between;
  120. .title {
  121. width: 100%;
  122. height: 90px;
  123. display: flex;
  124. justify-content: space-between;
  125. align-items: center;
  126. .text {
  127. position: relative;
  128. font-size: 24px;
  129. font-weight: bold;
  130. }
  131. .more {
  132. cursor: pointer;
  133. font-size: 16px;
  134. display: flex;
  135. align-items: center;
  136. span {
  137. opacity: 0.4;
  138. }
  139. img {
  140. width: 25px;
  141. height: 19px;
  142. }
  143. }
  144. }
  145. }
  146. .class_list {
  147. width: 1160px;
  148. margin: 0 auto;
  149. background: #fff;
  150. height: 778px;
  151. display: flex;
  152. flex-wrap: wrap;
  153. justify-content: flex-start;
  154. padding-top: 50px;
  155. padding-left: 20px;
  156. padding-right: 20px;
  157. > div {
  158. width: 192px;
  159. margin-left: 20px;
  160. margin-right: 20px;
  161. transition: all 1s;
  162. cursor: pointer;
  163. .one_name {
  164. height: 48px;
  165. margin-top: 16px;
  166. line-height: 150%;
  167. word-break: break-all;
  168. display: -webkit-box;
  169. -webkit-box-orient: vertical;
  170. -webkit-line-clamp: 2;
  171. text-overflow: ellipsis;
  172. overflow: hidden;
  173. font-size: 16px;
  174. color: #2c2c2c;
  175. cursor: pointer;
  176. padding-left: 4px;
  177. }
  178. .price {
  179. font-weight: bold;
  180. color: #2c2c2c;
  181. font-size: 24px;
  182. margin-bottom: 32px;
  183. .price_2 {
  184. font-size: 16px;
  185. }
  186. }
  187. p {
  188. font-size: 16px;
  189. }
  190. .listImage {
  191. display: flex;
  192. justify-content: center;
  193. align-items: center;
  194. width: 100%;
  195. height: 256px;
  196. // border: 1px solid rgba(0, 0, 0, 0.15);
  197. img {
  198. max-width: 100%;
  199. max-height: 100%;
  200. }
  201. color: #c0c4cc;
  202. }
  203. .gray {
  204. color: #a3a3a3;
  205. }
  206. .origin {
  207. color: #ff9900;
  208. }
  209. }
  210. .more {
  211. background: url("../../assets/teacherdev/image 13.png") center;
  212. position: relative;
  213. .shade {
  214. position: absolute;
  215. width: 100%;
  216. height: 100%;
  217. background: #000000;
  218. opacity: 0.6;
  219. cursor: pointer;
  220. display: flex;
  221. justify-content: center;
  222. align-items: center;
  223. > div {
  224. img {
  225. width: 58px;
  226. height: 58px;
  227. }
  228. span {
  229. position: relative;
  230. color: white;
  231. top: -20px;
  232. }
  233. }
  234. }
  235. }
  236. }
  237. }
  238. </style>