index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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. >
  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: 1,
  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. },
  182. methods: {
  183. ...mapMutations(["getCartCount"]),
  184. search(key) {
  185. this.params.goodsName = key || "";
  186. // this.params.searchKey = key || "";
  187. this.params.projectId = "";
  188. this.params.educationTypeId = "";
  189. this.params.businessId = "";
  190. this.params.subjectId = "";
  191. this.changeSubject();
  192. },
  193. changeSort(sortType) {
  194. if (this.params.sortType == sortType) return;
  195. this.params.sortType = sortType;
  196. this.changeSubject();
  197. },
  198. currentChange(e) {
  199. this.params.pageNum = e;
  200. this.changeSubject();
  201. },
  202. toGoodsDetail(item) {
  203. this.$router.push({
  204. path: "/course-detail/" + item.goodsId,
  205. });
  206. },
  207. addCart(item) {
  208. this.$request
  209. .addCart({ goodsId: item.goodsId })
  210. .then((res) => {
  211. this.getCartCount();
  212. this.$message({
  213. message: "加入购物车成功",
  214. type: "success",
  215. });
  216. })
  217. .catch((err) => {
  218. if (err.code == 500) {
  219. this.$message({
  220. message: err.msg,
  221. type: "warning",
  222. });
  223. }
  224. });
  225. },
  226. /**
  227. * 切换教育类型
  228. */
  229. changeType(item) {
  230. if (this.params.educationTypeId == item.id) {
  231. return;
  232. }
  233. this.params.educationTypeId = item.id;
  234. this.params.businessId = "";
  235. this.businessList = [];
  236. this.params.subjectId = "";
  237. this.subjectList = [];
  238. this.params.pageNum = 1;
  239. this.getBusinessList();
  240. this.changeSubject();
  241. },
  242. /**
  243. * 切换科目分类
  244. */
  245. changeSubject(item) {
  246. if (item) {
  247. if (this.params.subjectId != item.id) {
  248. this.params.subjectId = item.id;
  249. this.params.pageNum = 1;
  250. }
  251. }
  252. this.$request.goodsList(this.params).then((res) => {
  253. this.goodsList = res.rows;
  254. this.total = res.total;
  255. });
  256. },
  257. /**
  258. * 获取科目分类
  259. */
  260. getSubjectList() {
  261. this.$request
  262. .subjectList({
  263. businessId: this.params.businessId,
  264. projectId: this.projectId,
  265. educationId: this.params.educationTypeId,
  266. })
  267. .then((res) => {
  268. this.subjectList = res.rows;
  269. this.subjectList.unshift({ id: 0, subjectName: "全部" });
  270. this.params.subjectId = 0;
  271. this.changeSubject(this.subjectList[0]);
  272. });
  273. },
  274. /**
  275. * 切换业务层级
  276. */
  277. changeBusiness(item) {
  278. if (this.params.subjectId == item.id) {
  279. return;
  280. }
  281. this.params.businessId = item.id;
  282. this.projectId = item.projectId;
  283. this.params.subjectId = "";
  284. this.subjectList = [];
  285. this.params.pageNum = 1;
  286. this.getSubjectList();
  287. },
  288. /**
  289. * 获取业务层级
  290. */
  291. getBusinessList() {
  292. this.$request
  293. .businessList({ educationId: this.params.educationTypeId })
  294. .then((res) => {
  295. this.businessList = res.rows;
  296. this.projectId = this.businessList[0].projectId;
  297. });
  298. },
  299. /**
  300. * 获取教育类型
  301. */
  302. getEducationTypeList() {
  303. this.$request.educationTypeList().then((res) => {
  304. this.typeList = res.rows;
  305. //有传入教育类型
  306. if (this.params.educationTypeId) {
  307. this.getBusinessList();
  308. } else {
  309. this.params.educationTypeId = res.rows[0].id;
  310. this.getBusinessList();
  311. }
  312. this.changeSubject();
  313. });
  314. },
  315. },
  316. };
  317. </script>
  318. <!-- Add "scoped" attribute to limit CSS to this component only -->
  319. <style scoped lang="scss">
  320. .payment {
  321. .section {
  322. &__header {
  323. height: 40px;
  324. display: flex;
  325. align-items: center;
  326. padding: 0 20px;
  327. }
  328. &__body {
  329. background: #ebf2fc;
  330. .course-classify {
  331. overflow: hidden;
  332. &__list {
  333. display: flex;
  334. margin: 6px 0;
  335. align-items: flex-start;
  336. .left-item {
  337. margin-top: 10px;
  338. padding: 8px 0;
  339. width: 80px;
  340. font-size: 16px;
  341. font-family: Microsoft YaHei;
  342. font-weight: 400;
  343. color: #333333;
  344. }
  345. .right-item {
  346. flex: 1;
  347. .list {
  348. display: flex;
  349. flex-wrap: wrap;
  350. .item {
  351. cursor: pointer;
  352. border-radius: 8px;
  353. margin: 10px;
  354. padding: 8px 16px;
  355. color: #666666;
  356. font-size: 16px;
  357. background: #f7f9fc;
  358. color: #999;
  359. &.active {
  360. color: #fff;
  361. background: #3f8dfd;
  362. }
  363. }
  364. }
  365. }
  366. }
  367. }
  368. }
  369. &__footer {
  370. .course-list {
  371. &__header {
  372. margin-top: 32px;
  373. .sort-list {
  374. display: flex;
  375. align-items: center;
  376. &__item {
  377. cursor: pointer;
  378. width: 96px;
  379. height: 32px;
  380. border-radius: 16px;
  381. background: #ffffff;
  382. border: 1px solid #bfbfbf;
  383. border-radius: 16px;
  384. text-align: center;
  385. line-height: 30px;
  386. font-size: 16px;
  387. margin-right: 20px;
  388. &.active {
  389. background: #ebf2fc;
  390. border: 1px solid #3f8dfd;
  391. border-radius: 16px;
  392. color: #3f8dfd;
  393. }
  394. }
  395. }
  396. }
  397. &__body {
  398. .list {
  399. width: 100%;
  400. .course-item {
  401. float: left;
  402. }
  403. }
  404. }
  405. &__footer {
  406. overflow: hidden;
  407. .btn {
  408. cursor: pointer;
  409. width: 146px;
  410. height: 40px;
  411. background: #e3eaf7;
  412. border-radius: 8px;
  413. margin: 20px auto 40px;
  414. color: #3f8dfd;
  415. text-align: center;
  416. line-height: 40px;
  417. &:hover {
  418. color: #fff;
  419. box-shadow: 0px 8px 4px 0px rgba(7, 82, 208, 0.08);
  420. background: #3f8dfd;
  421. }
  422. }
  423. }
  424. }
  425. .pagination {
  426. padding: 30px 0;
  427. text-align: center;
  428. }
  429. }
  430. }
  431. }
  432. </style>