index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  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' }">首页</el-breadcrumb-item>
  9. <el-breadcrumb-item>题库</el-breadcrumb-item>
  10. </el-breadcrumb>
  11. </div>
  12. </div>
  13. <div class="section__body">
  14. <div class="container">
  15. <div class="course-classify">
  16. <div class="course-classify__list">
  17. <div class="left-item">教育类型:</div>
  18. <div class="right-item">
  19. <div class="list">
  20. <!-- <div
  21. class="item"
  22. :class="{ active: typeKey == '' }"
  23. @click="changeType('')"
  24. >
  25. 全部
  26. </div> -->
  27. <div class="item" v-for="(item, index) in typeList" :key="index"
  28. :class="{ active: params.educationTypeId == item.id }" @click="changeType(item)">
  29. {{ item.educationName }}
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. <div class="course-classify__list" v-if="businessList.length > 0">
  35. <div class="left-item">培训项目:</div>
  36. <div class="right-item">
  37. <div class="list">
  38. <!-- <div class="item active">全部</div> -->
  39. <div class="item" v-for="(item, index) in businessList" :key="index"
  40. :class="{ active: params.businessId == item.id }" @click="changeBusiness(item)">
  41. {{ item.aliasName }}
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. <div class="course-classify__list" v-if="subjectList.length > 0">
  47. <div class="left-item">科目分类:</div>
  48. <div class="right-item">
  49. <div class="list">
  50. <div class="item" v-for="(item, index) in subjectList" :key="index"
  51. :class="{ active: params.subjectId == item.id }" @click="changeSubject(item)">
  52. {{ item.subjectName }}
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. <div class="section__footer">
  61. <div class="container">
  62. <div class="course-list">
  63. <div class="course-list__header">
  64. <div class="sort-list">
  65. <div class="sort-list__item" @click="changeSort(1)"
  66. :class="{ active: params.sortType == 1 ? true : false }">
  67. 综合排序
  68. </div>
  69. <div class="sort-list__item" @click="changeSort(2)"
  70. :class="{ active: params.sortType == 2 ? true : false }">
  71. 低价优先
  72. </div>
  73. <div class="sort-list__item" @click="changeSort(3)"
  74. :class="{ active: params.sortType == 3 ? true : false }">
  75. 高价优先
  76. </div>
  77. </div>
  78. </div>
  79. <div class="course-list__body">
  80. <ul class="list clearfix">
  81. <li class="course-item" v-for="(item, index) in goodsList" :key="index">
  82. <GoodsItem :item="item"></GoodsItem>
  83. </li>
  84. </ul>
  85. </div>
  86. </div>
  87. <div class="pagination">
  88. <el-pagination @current-change="currentChange" background layout="prev, pager, next" :total="total"
  89. :pager-count="5" :page-size="params.pageSize">
  90. </el-pagination>
  91. </div>
  92. </div>
  93. </div>
  94. </section>
  95. <ToolBar></ToolBar>
  96. <Footer></Footer>
  97. </div>
  98. </template>
  99. <script>
  100. import Footer from "@/components/footer/index";
  101. import Header from "@/components/header/index";
  102. import ToolBar from "@/components/toolbar/index";
  103. import GoodsItem from "@/components/goodsItem/index";
  104. import { mapMutations } from "vuex";
  105. export default {
  106. name: "PaymentSuccess",
  107. components: {
  108. Footer,
  109. Header,
  110. ToolBar,
  111. GoodsItem,
  112. },
  113. data() {
  114. return {
  115. projectId: "",
  116. typeList: [],
  117. businessList: [],
  118. subjectList: [],
  119. total: 0,
  120. params: {
  121. projectId: "",
  122. educationTypeId: "",
  123. businessId: "",
  124. subjectId: "",
  125. pageNum: 1,
  126. pageSize: 15,
  127. goodsStatus: 1,
  128. goodsType: 2,
  129. sortType: 1,
  130. searchKey: "",
  131. // showStatus: 1
  132. },
  133. goodsList: [],
  134. };
  135. },
  136. mounted() {
  137. this.params.goodsName = this.$route.query.searchKey || "";
  138. // this.params.searchKey = this.$route.query.searchKey || "";
  139. this.params.educationTypeId = this.$route.query.educationId || "";
  140. this.params.projectId = this.$route.query.projectId || "";
  141. this.params.businessId = this.$route.query.businessId || "";
  142. if (this.params.businessId) {
  143. this.getSubjectList();
  144. }
  145. this.getEducationTypeList();
  146. // this.changeSubject();
  147. },
  148. methods: {
  149. ...mapMutations(["getCartCount"]),
  150. search(key) {
  151. this.params.goodsName = key || "";
  152. // this.params.searchKey = key || "";
  153. this.params.projectId = "";
  154. this.params.educationTypeId = "";
  155. this.params.businessId = "";
  156. this.params.subjectId = "";
  157. this.changeSubject();
  158. },
  159. changeSort(sortType) {
  160. if (this.params.sortType == sortType) return;
  161. this.params.sortType = sortType;
  162. this.changeSubject();
  163. },
  164. currentChange(e) {
  165. this.params.pageNum = e;
  166. this.changeSubject();
  167. },
  168. goodsDetail(item) {
  169. this.$router.push({
  170. path: "/bank-detail/" + item.goodsId,
  171. query: {
  172. orderGoodsId: item.orderGoodsId,
  173. },
  174. });
  175. },
  176. addCart(item) {
  177. this.$request
  178. .addCart({ goodsId: item.goodsId })
  179. .then((res) => {
  180. this.getCartCount();
  181. this.$message({
  182. message: "加入购物车成功",
  183. type: "success",
  184. });
  185. })
  186. .catch((err) => {
  187. if (err.code == 500) {
  188. this.$message({
  189. message: err.msg,
  190. type: "warning",
  191. });
  192. }
  193. });
  194. },
  195. changeType(item) {
  196. if (this.params.educationTypeId == item.id) {
  197. return;
  198. }
  199. this.params.educationTypeId = item.id;
  200. this.params.businessId = "";
  201. this.businessList = [];
  202. this.params.subjectId = "";
  203. this.subjectList = [];
  204. this.params.pageNum = 1;
  205. this.getBusinessList();
  206. this.changeSubject();
  207. },
  208. changeSubject(item) {
  209. if (item) {
  210. if (this.params.subjectId != item.id) {
  211. this.params.subjectId = item.id;
  212. this.params.pageNum = 1;
  213. }
  214. }
  215. this.$request.goodsList(this.params).then((res) => {
  216. this.goodsList = res.rows;
  217. this.total = res.total;
  218. });
  219. },
  220. getSubjectList() {
  221. this.$request
  222. .subjectList({
  223. businessId: this.params.businessId,
  224. projectId: this.projectId,
  225. educationId: this.params.educationTypeId,
  226. })
  227. .then((res) => {
  228. this.subjectList = res.rows;
  229. this.subjectList.unshift({ id: 0, subjectName: "全部" });
  230. this.params.subjectId = 0;
  231. this.changeSubject(this.subjectList[0]);
  232. });
  233. },
  234. changeBusiness(item) {
  235. if (this.params.subjectId == item.id) {
  236. return;
  237. }
  238. this.params.businessId = item.id;
  239. this.projectId = item.projectId;
  240. this.params.subjectId = "";
  241. this.subjectList = [];
  242. this.params.pageNum = 1;
  243. this.getSubjectList();
  244. },
  245. getBusinessList() {
  246. this.$request
  247. .businessList({ educationId: this.params.educationTypeId })
  248. .then((res) => {
  249. this.businessList = res.rows.filter((item) => item.aliasName)
  250. this.projectId = this.businessList[0].projectId;
  251. });
  252. },
  253. getEducationTypeList() {
  254. this.$request.educationTypeList().then((res) => {
  255. this.typeList = res.rows;
  256. if (!this.params.educationTypeId) {
  257. this.params.educationTypeId = res.rows[0].id;
  258. this.getBusinessList();
  259. } else {
  260. this.params.educationTypeId = res.rows[0].id;
  261. this.getBusinessList();
  262. }
  263. this.changeSubject();
  264. });
  265. },
  266. },
  267. };
  268. </script>
  269. <!-- Add "scoped" attribute to limit CSS to this component only -->
  270. <style scoped lang="scss">
  271. .payment {
  272. .section {
  273. &__header {
  274. height: 40px;
  275. display: flex;
  276. align-items: center;
  277. padding: 0 20px;
  278. }
  279. &__body {
  280. background: #ebf2fc;
  281. .course-classify {
  282. overflow: hidden;
  283. &__list {
  284. display: flex;
  285. margin: 6px 0;
  286. align-items: flex-start;
  287. .left-item {
  288. margin-top: 10px;
  289. padding: 8px 0;
  290. width: 80px;
  291. font-size: 16px;
  292. font-family: Microsoft YaHei;
  293. font-weight: 400;
  294. color: #333333;
  295. }
  296. .right-item {
  297. flex: 1;
  298. .list {
  299. display: flex;
  300. flex-wrap: wrap;
  301. .item {
  302. cursor: pointer;
  303. border-radius: 8px;
  304. margin: 10px;
  305. padding: 8px 16px;
  306. color: #666666;
  307. font-size: 16px;
  308. background: #f7f9fc;
  309. color: #999;
  310. &.active {
  311. color: #fff;
  312. background: #3f8dfd;
  313. }
  314. }
  315. }
  316. }
  317. }
  318. }
  319. }
  320. &__footer {
  321. .course-list {
  322. &__header {
  323. margin-top: 32px;
  324. .sort-list {
  325. display: flex;
  326. align-items: center;
  327. &__item {
  328. cursor: pointer;
  329. width: 96px;
  330. height: 32px;
  331. border-radius: 16px;
  332. background: #ffffff;
  333. border: 1px solid #bfbfbf;
  334. border-radius: 16px;
  335. text-align: center;
  336. line-height: 30px;
  337. font-size: 16px;
  338. margin-right: 20px;
  339. &.active {
  340. background: #ebf2fc;
  341. border: 1px solid #3f8dfd;
  342. border-radius: 16px;
  343. color: #3f8dfd;
  344. }
  345. }
  346. }
  347. }
  348. &__body {
  349. .list {
  350. width: 100%;
  351. .course-item {
  352. float: left;
  353. }
  354. }
  355. }
  356. &__footer {
  357. overflow: hidden;
  358. .btn {
  359. cursor: pointer;
  360. width: 146px;
  361. height: 40px;
  362. background: #e3eaf7;
  363. border-radius: 8px;
  364. margin: 20px auto 40px;
  365. color: #3f8dfd;
  366. text-align: center;
  367. line-height: 40px;
  368. &:hover {
  369. color: #fff;
  370. box-shadow: 0px 8px 4px 0px rgba(7, 82, 208, 0.08);
  371. background: #3f8dfd;
  372. }
  373. }
  374. }
  375. }
  376. .pagination {
  377. padding: 30px 0;
  378. text-align: center;
  379. }
  380. }
  381. }
  382. }
  383. </style>