index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. <template>
  2. <div class="payment">
  3. <Header></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. },
  178. goodsList: [],
  179. };
  180. },
  181. mounted() {
  182. this.getEducationTypeList();
  183. this.changeSubject();
  184. },
  185. methods: {
  186. changeSort(sortType) {
  187. if (this.params.sortType == sortType) return;
  188. this.params.sortType = sortType;
  189. this.changeSubject();
  190. },
  191. currentChange(e) {
  192. this.params.pageNum = e;
  193. this.changeSubject();
  194. },
  195. goodsDetail(item) {
  196. this.$router.push({
  197. path: "/bank-detail/" + item.goodsId,
  198. });
  199. },
  200. addCart(item) {
  201. this.$request
  202. .addCart({ goodsId: item.goodsId })
  203. .then((res) => {
  204. this.$message({
  205. message: "加入购物车成功",
  206. type: "success",
  207. });
  208. })
  209. .catch((err) => {
  210. this.$message({
  211. message: err.msg,
  212. type: "warning",
  213. });
  214. });
  215. },
  216. changeType(item) {
  217. if (this.params.educationTypeId == item.id) {
  218. return;
  219. }
  220. this.params.educationTypeId = item.id;
  221. this.params.businessId = "";
  222. this.businessList = [];
  223. this.params.subjectId = "";
  224. this.subjectList = [];
  225. this.params.pageNum = 1;
  226. this.getBusinessList();
  227. this.changeSubject();
  228. },
  229. changeSubject(item) {
  230. if (item) {
  231. if (this.params.subjectId != item.id) {
  232. this.params.subjectId = item.id;
  233. this.params.pageNum = 1;
  234. }
  235. }
  236. this.$request.goodsList(this.params).then((res) => {
  237. this.goodsList = res.rows;
  238. this.total = res.total;
  239. });
  240. },
  241. getSubjectList() {
  242. this.$request
  243. .subjectList({
  244. businessId: this.params.businessId,
  245. projectId: this.projectId,
  246. educationId: this.params.educationTypeId,
  247. })
  248. .then((res) => {
  249. this.subjectList = res.rows;
  250. this.subjectList.unshift({ id: 0, subjectName: "全部" });
  251. this.params.subjectId = 0;
  252. this.changeSubject(this.subjectList[0]);
  253. });
  254. },
  255. changeBusiness(item) {
  256. if (this.params.subjectId == item.id) {
  257. return;
  258. }
  259. this.params.businessId = item.id;
  260. this.projectId = item.projectId;
  261. this.params.subjectId = "";
  262. this.subjectList = [];
  263. this.params.pageNum = 1;
  264. this.getSubjectList();
  265. },
  266. getBusinessList() {
  267. this.$request
  268. .businessList({ educationId: this.params.educationTypeId })
  269. .then((res) => {
  270. this.businessList = res.rows;
  271. this.projectId = this.businessList[0].projectId;
  272. });
  273. },
  274. getEducationTypeList() {
  275. this.$request.educationTypeList().then((res) => {
  276. this.typeList = res.rows;
  277. });
  278. },
  279. },
  280. };
  281. </script>
  282. <!-- Add "scoped" attribute to limit CSS to this component only -->
  283. <style scoped lang="scss">
  284. .payment {
  285. .section {
  286. &__header {
  287. height: 40px;
  288. display: flex;
  289. align-items: center;
  290. padding: 0 20px;
  291. }
  292. &__body {
  293. background: #f5f7fa;
  294. .course-classify {
  295. overflow: hidden;
  296. &__list {
  297. display: flex;
  298. margin: 24px 0;
  299. align-items: flex-start;
  300. .left-item {
  301. padding: 8px 0;
  302. width: 80px;
  303. font-size: 16px;
  304. font-family: Microsoft YaHei;
  305. font-weight: 400;
  306. color: #333333;
  307. }
  308. .right-item {
  309. flex: 1;
  310. .list {
  311. display: flex;
  312. flex-wrap: wrap;
  313. .item {
  314. cursor: pointer;
  315. border-radius: 8px;
  316. margin: 0 10px;
  317. padding: 8px 16px;
  318. color: #666666;
  319. font-size: 16px;
  320. &.active {
  321. color: #fff;
  322. background: #3f8dfd;
  323. }
  324. }
  325. }
  326. }
  327. }
  328. }
  329. }
  330. &__footer {
  331. .course-list {
  332. &__header {
  333. margin-top: 32px;
  334. .sort-list {
  335. display: flex;
  336. align-items: center;
  337. &__item {
  338. cursor: pointer;
  339. width: 96px;
  340. height: 32px;
  341. border-radius: 16px;
  342. text-align: center;
  343. line-height: 32px;
  344. margin-right: 20px;
  345. &.active {
  346. color: #fff;
  347. background: #666666;
  348. }
  349. }
  350. }
  351. }
  352. &__body {
  353. .list {
  354. width: 100%;
  355. .course-item {
  356. float: left;
  357. margin: 110px 9px 0;
  358. width: 300px;
  359. height: 178px;
  360. background: #ffffff;
  361. box-shadow: 0px 10px 13px 3px rgba(63, 141, 253, 0.1);
  362. border-radius: 10px;
  363. position: relative;
  364. background: #fff;
  365. padding-top: 100px;
  366. cursor: pointer;
  367. &__img {
  368. width: 280px;
  369. height: 178px;
  370. background: #ffffff;
  371. box-shadow: 0px 0px 9px 1px rgba(0, 0, 0, 0.08);
  372. border-radius: 10px;
  373. position: absolute;
  374. left: 10px;
  375. top: -78px;
  376. overflow: hidden;
  377. .note {
  378. position: absolute;
  379. left: 0;
  380. top: 0;
  381. width: 80px;
  382. height: 24px;
  383. background: #d94404;
  384. box-shadow: 0px 1px 1px 0px rgba(248, 78, 5, 0.4);
  385. border-radius: 10px 0px 20px 0px;
  386. text-align: center;
  387. line-height: 24px;
  388. color: #fff;
  389. }
  390. }
  391. &__title {
  392. margin: 0 8px;
  393. font-size: 14px;
  394. font-family: Microsoft YaHei;
  395. font-weight: 400;
  396. color: #333333;
  397. line-height: 24px;
  398. overflow: hidden;
  399. text-overflow: ellipsis;
  400. display: -webkit-box;
  401. -webkit-line-clamp: 2;
  402. -webkit-box-orient: vertical;
  403. }
  404. &__desc {
  405. height: 32px;
  406. position: absolute;
  407. left: 0;
  408. right: 0;
  409. bottom: 0;
  410. margin-left: 8px;
  411. display: flex;
  412. justify-content: space-between;
  413. .price {
  414. font-size: 18px;
  415. font-family: Microsoft YaHei;
  416. font-weight: bold;
  417. color: #ff2d55;
  418. line-height: 32px;
  419. }
  420. .add {
  421. display: block;
  422. width: 118px;
  423. height: 32px;
  424. line-height: 30px;
  425. background: #f2f4f7;
  426. border-radius: 10px 0px 10px 0px;
  427. font-size: 16px;
  428. color: #3f8dfd;
  429. text-align: center;
  430. &:hover {
  431. background: #3f8dfd;
  432. color: #f2f4f7;
  433. }
  434. }
  435. }
  436. }
  437. }
  438. }
  439. &__footer {
  440. overflow: hidden;
  441. .btn {
  442. cursor: pointer;
  443. width: 146px;
  444. height: 40px;
  445. background: #e3eaf7;
  446. border-radius: 8px;
  447. margin: 20px auto 40px;
  448. color: #3f8dfd;
  449. text-align: center;
  450. line-height: 40px;
  451. &:hover {
  452. color: #fff;
  453. box-shadow: 0px 8px 4px 0px rgba(7, 82, 208, 0.08);
  454. background: #3f8dfd;
  455. }
  456. }
  457. }
  458. }
  459. .pagination {
  460. padding: 30px 0;
  461. text-align: center;
  462. }
  463. }
  464. }
  465. }
  466. </style>