index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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: 6,
  165. sortType: 1,
  166. searchKey: "",
  167. },
  168. goodsList: [],
  169. };
  170. },
  171. mounted() {
  172. this.params.searchKey = this.$route.query.searchKey || "";
  173. this.params.educationTypeId = this.$route.query.educationId || "";
  174. this.params.projectId = this.$route.query.projectId || "";
  175. this.params.businessId = this.$route.query.businessId || "";
  176. if (this.params.businessId) {
  177. this.getSubjectList();
  178. }
  179. this.getEducationTypeList();
  180. // this.changeSubject();
  181. },
  182. methods: {
  183. ...mapMutations(["getCartCount"]),
  184. search(key) {
  185. this.params.searchKey = key || "";
  186. this.params.projectId = "";
  187. this.params.educationTypeId = "";
  188. this.params.businessId = "";
  189. this.params.subjectId = "";
  190. this.changeSubject();
  191. },
  192. changeSort(sortType) {
  193. if (this.params.sortType == sortType) return;
  194. this.params.sortType = sortType;
  195. this.changeSubject();
  196. },
  197. currentChange(e) {
  198. this.params.pageNum = e;
  199. this.changeSubject();
  200. },
  201. goodsDetail(item) {
  202. this.$router.push({
  203. path: "/bank-detail/" + item.goodsId,
  204. query: {
  205. orderGoodsId: item.orderGoodsId,
  206. },
  207. });
  208. },
  209. addCart(item) {
  210. this.$request
  211. .addCart({ goodsId: item.goodsId })
  212. .then((res) => {
  213. this.getCartCount();
  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. if (!this.params.educationTypeId) {
  290. this.params.educationTypeId = res.rows[0].id;
  291. this.getBusinessList();
  292. } else {
  293. this.params.educationTypeId = res.rows[0].id;
  294. this.getBusinessList();
  295. }
  296. this.changeSubject();
  297. });
  298. },
  299. },
  300. };
  301. </script>
  302. <!-- Add "scoped" attribute to limit CSS to this component only -->
  303. <style scoped lang="scss">
  304. .payment {
  305. .section {
  306. &__header {
  307. height: 40px;
  308. display: flex;
  309. align-items: center;
  310. padding: 0 20px;
  311. }
  312. &__body {
  313. background: #ebf2fc;
  314. .course-classify {
  315. overflow: hidden;
  316. &__list {
  317. display: flex;
  318. margin: 6px 0;
  319. align-items: flex-start;
  320. .left-item {
  321. margin-top: 10px;
  322. padding: 8px 0;
  323. width: 80px;
  324. font-size: 16px;
  325. font-family: Microsoft YaHei;
  326. font-weight: 400;
  327. color: #333333;
  328. }
  329. .right-item {
  330. flex: 1;
  331. .list {
  332. display: flex;
  333. flex-wrap: wrap;
  334. .item {
  335. cursor: pointer;
  336. border-radius: 8px;
  337. margin: 10px;
  338. padding: 8px 16px;
  339. color: #666666;
  340. font-size: 16px;
  341. background: #f7f9fc;
  342. color: #999;
  343. &.active {
  344. color: #fff;
  345. background: #3f8dfd;
  346. }
  347. }
  348. }
  349. }
  350. }
  351. }
  352. }
  353. &__footer {
  354. .course-list {
  355. &__header {
  356. margin-top: 32px;
  357. .sort-list {
  358. display: flex;
  359. align-items: center;
  360. &__item {
  361. cursor: pointer;
  362. width: 96px;
  363. height: 32px;
  364. border-radius: 16px;
  365. background: #ffffff;
  366. border: 1px solid #bfbfbf;
  367. border-radius: 16px;
  368. text-align: center;
  369. line-height: 30px;
  370. font-size: 16px;
  371. margin-right: 20px;
  372. &.active {
  373. background: #ebf2fc;
  374. border: 1px solid #3f8dfd;
  375. border-radius: 16px;
  376. color: #3f8dfd;
  377. }
  378. }
  379. }
  380. }
  381. &__body {
  382. .list {
  383. width: 100%;
  384. .course-item {
  385. float: left;
  386. }
  387. }
  388. }
  389. &__footer {
  390. overflow: hidden;
  391. .btn {
  392. cursor: pointer;
  393. width: 146px;
  394. height: 40px;
  395. background: #e3eaf7;
  396. border-radius: 8px;
  397. margin: 20px auto 40px;
  398. color: #3f8dfd;
  399. text-align: center;
  400. line-height: 40px;
  401. &:hover {
  402. color: #fff;
  403. box-shadow: 0px 8px 4px 0px rgba(7, 82, 208, 0.08);
  404. background: #3f8dfd;
  405. }
  406. }
  407. }
  408. }
  409. .pagination {
  410. padding: 30px 0;
  411. text-align: center;
  412. }
  413. }
  414. }
  415. }
  416. </style>