Textbook.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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 "pptx":
  75. return "ppt";
  76. case "pdf":
  77. return "pdf";
  78. case "xlsx":
  79. return "exceil";
  80. case "xls":
  81. return "exceil";
  82. case "doc":
  83. return "word";
  84. case "docx":
  85. return "word";
  86. case "word":
  87. return "word";
  88. default:
  89. return "word";
  90. }
  91. },
  92. // 处理价格
  93. changePrice(type, item) {
  94. if (item.indexOf(".") != -1) {
  95. if (type == 1) {
  96. return item.split(".")[0];
  97. } else if (type == 2) {
  98. if (item.split(".")[1] * 1 >= 10) {
  99. return "." + item.split(".")[1];
  100. } else {
  101. return "." + item.split(".")[1] + "0";
  102. }
  103. }
  104. } else {
  105. if (type == 1) {
  106. return item;
  107. }
  108. if (type == 2) {
  109. return ".00";
  110. }
  111. }
  112. },
  113. },
  114. created() {},
  115. };
  116. </script>
  117. <style lang="scss" scoped>
  118. .Textbook {
  119. .top {
  120. width: 1200px;
  121. margin: 0 auto;
  122. display: flex;
  123. justify-content: space-between;
  124. .title {
  125. width: 100%;
  126. height: 90px;
  127. display: flex;
  128. justify-content: space-between;
  129. align-items: center;
  130. .text {
  131. position: relative;
  132. font-size: 24px;
  133. font-weight: bold;
  134. }
  135. .more {
  136. cursor: pointer;
  137. font-size: 16px;
  138. display: flex;
  139. align-items: center;
  140. span {
  141. opacity: 0.4;
  142. }
  143. img {
  144. width: 25px;
  145. height: 19px;
  146. }
  147. }
  148. }
  149. }
  150. .class_list {
  151. width: 1200px;
  152. box-sizing: border-box;
  153. margin: 0 auto;
  154. background: #fff;
  155. display: flex;
  156. flex-wrap: wrap;
  157. justify-content: flex-start;
  158. padding: 50px 20px 8px 20px;
  159. > div {
  160. width: 192px;
  161. margin-left: 20px;
  162. margin-right: 20px;
  163. transition: all 1s;
  164. cursor: pointer;
  165. .one_name {
  166. height: 48px;
  167. margin-top: 16px;
  168. line-height: 150%;
  169. word-break: break-all;
  170. display: -webkit-box;
  171. -webkit-box-orient: vertical;
  172. -webkit-line-clamp: 2;
  173. text-overflow: ellipsis;
  174. overflow: hidden;
  175. font-size: 16px;
  176. color: #2c2c2c;
  177. cursor: pointer;
  178. padding-left: 4px;
  179. }
  180. .price {
  181. font-weight: bold;
  182. color: #2c2c2c;
  183. font-size: 24px;
  184. margin-bottom: 32px;
  185. .price_2 {
  186. font-size: 16px;
  187. }
  188. }
  189. p {
  190. font-size: 16px;
  191. }
  192. .listImage {
  193. display: flex;
  194. justify-content: center;
  195. align-items: center;
  196. width: 100%;
  197. height: 256px;
  198. // border: 1px solid rgba(0, 0, 0, 0.15);
  199. img {
  200. max-width: 100%;
  201. max-height: 100%;
  202. }
  203. color: #c0c4cc;
  204. }
  205. .gray {
  206. color: #a3a3a3;
  207. }
  208. .origin {
  209. color: #ff9900;
  210. }
  211. }
  212. .more {
  213. background: url("../../assets/teacherdev/image 13.png") center;
  214. position: relative;
  215. .shade {
  216. position: absolute;
  217. width: 100%;
  218. height: 100%;
  219. background: #000000;
  220. opacity: 0.6;
  221. cursor: pointer;
  222. display: flex;
  223. justify-content: center;
  224. align-items: center;
  225. > div {
  226. img {
  227. width: 58px;
  228. height: 58px;
  229. }
  230. span {
  231. position: relative;
  232. color: white;
  233. top: -20px;
  234. }
  235. }
  236. }
  237. }
  238. }
  239. }
  240. </style>