ToolBook.vue 5.2 KB

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