index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. <template>
  2. <div class="payment">
  3. <Header @search="search($event)"></Header>
  4. <section class="section">
  5. <div class="section__header">
  6. <div class="container">
  7. <el-breadcrumb separator="/">
  8. <el-breadcrumb-item :to="{ path: '/index' }"
  9. >首页</el-breadcrumb-item
  10. >
  11. <el-breadcrumb-item>题库</el-breadcrumb-item>
  12. </el-breadcrumb>
  13. </div>
  14. </div>
  15. <div class="section__body">
  16. <div class="container">
  17. <div class="course-classify">
  18. <div class="course-classify__list">
  19. <div class="left-item">教育类型:</div>
  20. <div class="right-item">
  21. <div class="list">
  22. <!-- <div
  23. class="item"
  24. :class="{ active: typeKey == '' }"
  25. @click="changeType('')"
  26. >
  27. 全部
  28. </div> -->
  29. <div
  30. class="item"
  31. v-for="(item, index) in typeList"
  32. :key="index"
  33. :class="{ active: params.educationTypeId == item.id }"
  34. @click="changeType(item)"
  35. >
  36. {{ item.educationName }}
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="course-classify__list" v-if="businessList.length > 0">
  42. <div class="left-item">业务层次:</div>
  43. <div class="right-item">
  44. <div class="list">
  45. <!-- <div class="item active">全部</div> -->
  46. <div
  47. class="item"
  48. v-for="(item, index) in businessList"
  49. :key="index"
  50. :class="{ active: params.businessId == item.id }"
  51. @click="changeBusiness(item)"
  52. >
  53. {{ item.projectName }} - {{ item.businessName }}
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. <div class="course-classify__list" v-if="subjectList.length > 0">
  59. <div class="left-item">科目分类:</div>
  60. <div class="right-item">
  61. <div class="list">
  62. <div
  63. class="item"
  64. v-for="(item, index) in subjectList"
  65. :key="index"
  66. :class="{ active: params.subjectId == item.id }"
  67. @click="changeSubject(item)"
  68. >
  69. {{ item.subjectName }}
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. <div class="section__footer">
  78. <div class="container">
  79. <div class="course-list">
  80. <div class="course-list__header">
  81. <div class="sort-list">
  82. <div
  83. class="sort-list__item"
  84. @click="changeSort(1)"
  85. :class="{ active: params.sortType == 1 ? true : false }"
  86. >
  87. 综合排序
  88. </div>
  89. <div
  90. class="sort-list__item"
  91. @click="changeSort(2)"
  92. :class="{ active: params.sortType == 2 ? true : false }"
  93. >
  94. 低价优先
  95. </div>
  96. <div
  97. class="sort-list__item"
  98. @click="changeSort(3)"
  99. :class="{ active: params.sortType == 3 ? true : false }"
  100. >
  101. 高价优先
  102. </div>
  103. </div>
  104. </div>
  105. <div class="course-list__body">
  106. <ul class="list clearfix">
  107. <li
  108. class="course-item"
  109. v-for="(item, index) in goodsList"
  110. :key="index"
  111. @click="goodsDetail(item)"
  112. >
  113. <div class="course-item__img">
  114. <img
  115. :src="$tools.splitImgHost(item.coverUrl, true, 280)"
  116. alt=""
  117. />
  118. <div class="note" v-if="item.year">{{ item.year }}</div>
  119. </div>
  120. <div class="course-item__title">
  121. {{ item.goodsName }}
  122. </div>
  123. <div class="course-item__desc">
  124. <div class="price">¥{{ item.standPrice | toFixed }}</div>
  125. <a class="add" @click.stop="addCart(item)">加购物车</a>
  126. </div>
  127. </li>
  128. </ul>
  129. </div>
  130. </div>
  131. <div class="pagination">
  132. <el-pagination
  133. @current-change="currentChange"
  134. background
  135. layout="prev, pager, next"
  136. :total="total"
  137. :pager-count="5"
  138. :page-size="params.pageSize"
  139. >
  140. </el-pagination>
  141. </div>
  142. </div>
  143. </div>
  144. </section>
  145. <ToolBar></ToolBar>
  146. <Footer></Footer>
  147. </div>
  148. </template>
  149. <script>
  150. import Footer from "@/components/footer/index";
  151. import Header from "@/components/header/index";
  152. import ToolBar from "@/components/toolbar/index";
  153. export default {
  154. name: "PaymentSuccess",
  155. components: {
  156. Footer,
  157. Header,
  158. ToolBar,
  159. },
  160. data() {
  161. return {
  162. projectId: "",
  163. typeList: [],
  164. businessList: [],
  165. subjectList: [],
  166. total: 0,
  167. params: {
  168. projectId: "",
  169. educationTypeId: "",
  170. businessId: "",
  171. subjectId: "",
  172. pageNum: 1,
  173. pageSize: 12,
  174. goodsStatus: 1,
  175. goodsType: 2,
  176. sortType: 1,
  177. searchKey: "",
  178. },
  179. goodsList: [],
  180. };
  181. },
  182. mounted() {
  183. this.params.searchKey = this.$route.query.searchKey || "";
  184. this.getEducationTypeList();
  185. this.changeSubject();
  186. },
  187. methods: {
  188. search(key) {
  189. this.params.searchKey = key || "";
  190. this.params.projectId = "";
  191. this.params.educationTypeId = "";
  192. this.params.businessId = "";
  193. this.params.subjectId = "";
  194. this.changeSubject();
  195. },
  196. changeSort(sortType) {
  197. if (this.params.sortType == sortType) return;
  198. this.params.sortType = sortType;
  199. this.changeSubject();
  200. },
  201. currentChange(e) {
  202. this.params.pageNum = e;
  203. this.changeSubject();
  204. },
  205. goodsDetail(item) {
  206. this.$router.push({
  207. path: "/bank-detail/" + item.goodsId,
  208. });
  209. },
  210. addCart(item) {
  211. this.$request
  212. .addCart({ goodsId: item.goodsId })
  213. .then((res) => {
  214. this.$message({
  215. message: "加入购物车成功",
  216. type: "success",
  217. });
  218. })
  219. .catch((err) => {
  220. if (err.code == 500) {
  221. this.$message({
  222. message: err.msg,
  223. type: "warning",
  224. });
  225. }
  226. });
  227. },
  228. changeType(item) {
  229. if (this.params.educationTypeId == item.id) {
  230. return;
  231. }
  232. this.params.educationTypeId = item.id;
  233. this.params.businessId = "";
  234. this.businessList = [];
  235. this.params.subjectId = "";
  236. this.subjectList = [];
  237. this.params.pageNum = 1;
  238. this.getBusinessList();
  239. this.changeSubject();
  240. },
  241. changeSubject(item) {
  242. if (item) {
  243. if (this.params.subjectId != item.id) {
  244. this.params.subjectId = item.id;
  245. this.params.pageNum = 1;
  246. }
  247. }
  248. this.$request.goodsList(this.params).then((res) => {
  249. this.goodsList = res.rows;
  250. this.total = res.total;
  251. });
  252. },
  253. getSubjectList() {
  254. this.$request
  255. .subjectList({
  256. businessId: this.params.businessId,
  257. projectId: this.projectId,
  258. educationId: this.params.educationTypeId,
  259. })
  260. .then((res) => {
  261. this.subjectList = res.rows;
  262. this.subjectList.unshift({ id: 0, subjectName: "全部" });
  263. this.params.subjectId = 0;
  264. this.changeSubject(this.subjectList[0]);
  265. });
  266. },
  267. changeBusiness(item) {
  268. if (this.params.subjectId == item.id) {
  269. return;
  270. }
  271. this.params.businessId = item.id;
  272. this.projectId = item.projectId;
  273. this.params.subjectId = "";
  274. this.subjectList = [];
  275. this.params.pageNum = 1;
  276. this.getSubjectList();
  277. },
  278. getBusinessList() {
  279. this.$request
  280. .businessList({ educationId: this.params.educationTypeId })
  281. .then((res) => {
  282. this.businessList = res.rows;
  283. this.projectId = this.businessList[0].projectId;
  284. });
  285. },
  286. getEducationTypeList() {
  287. this.$request.educationTypeList().then((res) => {
  288. this.typeList = res.rows;
  289. });
  290. },
  291. },
  292. };
  293. </script>
  294. <!-- Add "scoped" attribute to limit CSS to this component only -->
  295. <style scoped lang="scss">
  296. .payment {
  297. .section {
  298. &__header {
  299. height: 40px;
  300. display: flex;
  301. align-items: center;
  302. padding: 0 20px;
  303. }
  304. &__body {
  305. background: #f5f7fa;
  306. .course-classify {
  307. overflow: hidden;
  308. &__list {
  309. display: flex;
  310. margin: 24px 0;
  311. align-items: flex-start;
  312. .left-item {
  313. padding: 8px 0;
  314. width: 80px;
  315. font-size: 16px;
  316. font-family: Microsoft YaHei;
  317. font-weight: 400;
  318. color: #333333;
  319. }
  320. .right-item {
  321. flex: 1;
  322. .list {
  323. display: flex;
  324. flex-wrap: wrap;
  325. .item {
  326. cursor: pointer;
  327. border-radius: 8px;
  328. margin: 0 10px;
  329. padding: 8px 16px;
  330. color: #666666;
  331. font-size: 16px;
  332. &.active {
  333. color: #fff;
  334. background: #3f8dfd;
  335. }
  336. }
  337. }
  338. }
  339. }
  340. }
  341. }
  342. &__footer {
  343. .course-list {
  344. &__header {
  345. margin-top: 32px;
  346. .sort-list {
  347. display: flex;
  348. align-items: center;
  349. &__item {
  350. cursor: pointer;
  351. width: 96px;
  352. height: 32px;
  353. border-radius: 16px;
  354. text-align: center;
  355. line-height: 32px;
  356. margin-right: 20px;
  357. &.active {
  358. color: #fff;
  359. background: #666666;
  360. }
  361. }
  362. }
  363. }
  364. &__body {
  365. .list {
  366. width: 100%;
  367. .course-item {
  368. float: left;
  369. margin: 110px 9px 0;
  370. width: 300px;
  371. height: 178px;
  372. background: #ffffff;
  373. box-shadow: 0px 10px 13px 3px rgba(63, 141, 253, 0.1);
  374. border-radius: 10px;
  375. position: relative;
  376. background: #fff;
  377. padding-top: 100px;
  378. cursor: pointer;
  379. &__img {
  380. width: 280px;
  381. height: 178px;
  382. background: #ffffff;
  383. box-shadow: 0px 0px 9px 1px rgba(0, 0, 0, 0.08);
  384. border-radius: 10px;
  385. position: absolute;
  386. left: 10px;
  387. top: -78px;
  388. overflow: hidden;
  389. .note {
  390. position: absolute;
  391. left: 0;
  392. top: 0;
  393. width: 80px;
  394. height: 24px;
  395. background: #d94404;
  396. box-shadow: 0px 1px 1px 0px rgba(248, 78, 5, 0.4);
  397. border-radius: 10px 0px 20px 0px;
  398. text-align: center;
  399. line-height: 24px;
  400. color: #fff;
  401. }
  402. }
  403. &__title {
  404. margin: 0 8px;
  405. font-size: 14px;
  406. font-family: Microsoft YaHei;
  407. font-weight: 400;
  408. color: #333333;
  409. line-height: 24px;
  410. overflow: hidden;
  411. text-overflow: ellipsis;
  412. display: -webkit-box;
  413. -webkit-line-clamp: 2;
  414. -webkit-box-orient: vertical;
  415. }
  416. &__desc {
  417. height: 32px;
  418. position: absolute;
  419. left: 0;
  420. right: 0;
  421. bottom: 0;
  422. margin-left: 8px;
  423. display: flex;
  424. justify-content: space-between;
  425. .price {
  426. font-size: 18px;
  427. font-family: Microsoft YaHei;
  428. font-weight: bold;
  429. color: #ff2d55;
  430. line-height: 32px;
  431. }
  432. .add {
  433. display: block;
  434. width: 118px;
  435. height: 32px;
  436. line-height: 30px;
  437. background: #f2f4f7;
  438. border-radius: 10px 0px 10px 0px;
  439. font-size: 16px;
  440. color: #3f8dfd;
  441. text-align: center;
  442. &:hover {
  443. background: #3f8dfd;
  444. color: #f2f4f7;
  445. }
  446. }
  447. }
  448. }
  449. }
  450. }
  451. &__footer {
  452. overflow: hidden;
  453. .btn {
  454. cursor: pointer;
  455. width: 146px;
  456. height: 40px;
  457. background: #e3eaf7;
  458. border-radius: 8px;
  459. margin: 20px auto 40px;
  460. color: #3f8dfd;
  461. text-align: center;
  462. line-height: 40px;
  463. &:hover {
  464. color: #fff;
  465. box-shadow: 0px 8px 4px 0px rgba(7, 82, 208, 0.08);
  466. background: #3f8dfd;
  467. }
  468. }
  469. }
  470. }
  471. .pagination {
  472. padding: 30px 0;
  473. text-align: center;
  474. }
  475. }
  476. }
  477. }
  478. </style>