index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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.aliasName }}
  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. >
  112. <GoodsItem :item="item"></GoodsItem>
  113. </li>
  114. </ul>
  115. </div>
  116. </div>
  117. <div class="pagination">
  118. <el-pagination
  119. @current-change="currentChange"
  120. background
  121. layout="prev, pager, next"
  122. :total="total"
  123. :pager-count="5"
  124. :page-size="params.pageSize"
  125. >
  126. </el-pagination>
  127. </div>
  128. </div>
  129. </div>
  130. </section>
  131. <ToolBar></ToolBar>
  132. <Footer></Footer>
  133. </div>
  134. </template>
  135. <script>
  136. import Footer from "@/components/footer/index";
  137. import Header from "@/components/header/index";
  138. import ToolBar from "@/components/toolbar/index";
  139. import GoodsItem from "@/components/goodsItem/index";
  140. import { mapMutations } from "vuex";
  141. export default {
  142. name: "PaymentSuccess",
  143. components: {
  144. Footer,
  145. Header,
  146. ToolBar,
  147. GoodsItem,
  148. },
  149. data() {
  150. return {
  151. projectId: "",
  152. typeList: [],
  153. businessList: [],
  154. subjectList: [],
  155. total: 0,
  156. params: {
  157. projectId: "",
  158. educationTypeId: "",
  159. businessId: "",
  160. subjectId: "",
  161. pageNum: 1,
  162. pageSize: 15,
  163. goodsStatus: 1,
  164. goodsType: 2,
  165. sortType: 1,
  166. searchKey: "",
  167. },
  168. goodsList: [],
  169. };
  170. },
  171. mounted() {
  172. this.params.goodsName = this.$route.query.searchKey || "";
  173. // this.params.searchKey = this.$route.query.searchKey || "";
  174. this.params.educationTypeId = this.$route.query.educationId || "";
  175. this.params.projectId = this.$route.query.projectId || "";
  176. this.params.businessId = this.$route.query.businessId || "";
  177. if (this.params.businessId) {
  178. this.getSubjectList();
  179. }
  180. this.getEducationTypeList();
  181. // this.changeSubject();
  182. },
  183. methods: {
  184. ...mapMutations(["getCartCount"]),
  185. search(key) {
  186. this.params.goodsName = key || "";
  187. // this.params.searchKey = key || "";
  188. this.params.projectId = "";
  189. this.params.educationTypeId = "";
  190. this.params.businessId = "";
  191. this.params.subjectId = "";
  192. this.changeSubject();
  193. },
  194. changeSort(sortType) {
  195. if (this.params.sortType == sortType) return;
  196. this.params.sortType = sortType;
  197. this.changeSubject();
  198. },
  199. currentChange(e) {
  200. this.params.pageNum = e;
  201. this.changeSubject();
  202. },
  203. goodsDetail(item) {
  204. this.$router.push({
  205. path: "/bank-detail/" + item.goodsId,
  206. query: {
  207. orderGoodsId: item.orderGoodsId,
  208. },
  209. });
  210. },
  211. addCart(item) {
  212. this.$request
  213. .addCart({ goodsId: item.goodsId })
  214. .then((res) => {
  215. this.getCartCount();
  216. this.$message({
  217. message: "加入购物车成功",
  218. type: "success",
  219. });
  220. })
  221. .catch((err) => {
  222. if (err.code == 500) {
  223. this.$message({
  224. message: err.msg,
  225. type: "warning",
  226. });
  227. }
  228. });
  229. },
  230. changeType(item) {
  231. if (this.params.educationTypeId == item.id) {
  232. return;
  233. }
  234. this.params.educationTypeId = item.id;
  235. this.params.businessId = "";
  236. this.businessList = [];
  237. this.params.subjectId = "";
  238. this.subjectList = [];
  239. this.params.pageNum = 1;
  240. this.getBusinessList();
  241. this.changeSubject();
  242. },
  243. changeSubject(item) {
  244. if (item) {
  245. if (this.params.subjectId != item.id) {
  246. this.params.subjectId = item.id;
  247. this.params.pageNum = 1;
  248. }
  249. }
  250. this.$request.goodsList(this.params).then((res) => {
  251. this.goodsList = res.rows;
  252. this.total = res.total;
  253. });
  254. },
  255. getSubjectList() {
  256. this.$request
  257. .subjectList({
  258. businessId: this.params.businessId,
  259. projectId: this.projectId,
  260. educationId: this.params.educationTypeId,
  261. })
  262. .then((res) => {
  263. this.subjectList = res.rows;
  264. this.subjectList.unshift({ id: 0, subjectName: "全部" });
  265. this.params.subjectId = 0;
  266. this.changeSubject(this.subjectList[0]);
  267. });
  268. },
  269. changeBusiness(item) {
  270. if (this.params.subjectId == item.id) {
  271. return;
  272. }
  273. this.params.businessId = item.id;
  274. this.projectId = item.projectId;
  275. this.params.subjectId = "";
  276. this.subjectList = [];
  277. this.params.pageNum = 1;
  278. this.getSubjectList();
  279. },
  280. getBusinessList() {
  281. this.$request
  282. .businessList({ educationId: this.params.educationTypeId })
  283. .then((res) => {
  284. this.businessList = res.rows.filter((item) => item.aliasName)
  285. this.projectId = this.businessList[0].projectId;
  286. });
  287. },
  288. getEducationTypeList() {
  289. this.$request.educationTypeList().then((res) => {
  290. this.typeList = res.rows;
  291. if (!this.params.educationTypeId) {
  292. this.params.educationTypeId = res.rows[0].id;
  293. this.getBusinessList();
  294. } else {
  295. this.params.educationTypeId = res.rows[0].id;
  296. this.getBusinessList();
  297. }
  298. this.changeSubject();
  299. });
  300. },
  301. },
  302. };
  303. </script>
  304. <!-- Add "scoped" attribute to limit CSS to this component only -->
  305. <style scoped lang="scss">
  306. .payment {
  307. .section {
  308. &__header {
  309. height: 40px;
  310. display: flex;
  311. align-items: center;
  312. padding: 0 20px;
  313. }
  314. &__body {
  315. background: #ebf2fc;
  316. .course-classify {
  317. overflow: hidden;
  318. &__list {
  319. display: flex;
  320. margin: 6px 0;
  321. align-items: flex-start;
  322. .left-item {
  323. margin-top: 10px;
  324. padding: 8px 0;
  325. width: 80px;
  326. font-size: 16px;
  327. font-family: Microsoft YaHei;
  328. font-weight: 400;
  329. color: #333333;
  330. }
  331. .right-item {
  332. flex: 1;
  333. .list {
  334. display: flex;
  335. flex-wrap: wrap;
  336. .item {
  337. cursor: pointer;
  338. border-radius: 8px;
  339. margin: 10px;
  340. padding: 8px 16px;
  341. color: #666666;
  342. font-size: 16px;
  343. background: #f7f9fc;
  344. color: #999;
  345. &.active {
  346. color: #fff;
  347. background: #3f8dfd;
  348. }
  349. }
  350. }
  351. }
  352. }
  353. }
  354. }
  355. &__footer {
  356. .course-list {
  357. &__header {
  358. margin-top: 32px;
  359. .sort-list {
  360. display: flex;
  361. align-items: center;
  362. &__item {
  363. cursor: pointer;
  364. width: 96px;
  365. height: 32px;
  366. border-radius: 16px;
  367. background: #ffffff;
  368. border: 1px solid #bfbfbf;
  369. border-radius: 16px;
  370. text-align: center;
  371. line-height: 30px;
  372. font-size: 16px;
  373. margin-right: 20px;
  374. &.active {
  375. background: #ebf2fc;
  376. border: 1px solid #3f8dfd;
  377. border-radius: 16px;
  378. color: #3f8dfd;
  379. }
  380. }
  381. }
  382. }
  383. &__body {
  384. .list {
  385. width: 100%;
  386. .course-item {
  387. float: left;
  388. }
  389. }
  390. }
  391. &__footer {
  392. overflow: hidden;
  393. .btn {
  394. cursor: pointer;
  395. width: 146px;
  396. height: 40px;
  397. background: #e3eaf7;
  398. border-radius: 8px;
  399. margin: 20px auto 40px;
  400. color: #3f8dfd;
  401. text-align: center;
  402. line-height: 40px;
  403. &:hover {
  404. color: #fff;
  405. box-shadow: 0px 8px 4px 0px rgba(7, 82, 208, 0.08);
  406. background: #3f8dfd;
  407. }
  408. }
  409. }
  410. }
  411. .pagination {
  412. padding: 30px 0;
  413. text-align: center;
  414. }
  415. }
  416. }
  417. }
  418. </style>