Mycollect.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. <template>
  2. <!-- 购买记录 -->
  3. <div class="OrderManage personal-center">
  4. <EditTitle
  5. title="我的收藏"
  6. :isDel="1"
  7. :isShowCheckBox="isShowCheckBox"
  8. :changeIsDel="changeIsDel"
  9. :changeIsCancle="changeIsCancle"
  10. :deleteMyCollection="deleteMyCollection"
  11. :listCount="listCount"
  12. :delCount="delCount"
  13. />
  14. <div>
  15. <el-menu
  16. :default-active="activeIndex"
  17. class="el-menu-demo"
  18. mode="horizontal"
  19. @select="handleSelect"
  20. >
  21. <!-- <el-menu-item index="all">全部</el-menu-item> -->
  22. <el-menu-item index="book">教材</el-menu-item>
  23. <el-menu-item index="teaching">教学课程</el-menu-item>
  24. <el-menu-item index="video">视频</el-menu-item>
  25. <el-menu-item index="live">直播</el-menu-item>
  26. <el-menu-item index="jiaoyan">教研资料</el-menu-item>
  27. <el-menu-item index="hanzi">字词</el-menu-item>
  28. <el-menu-item index="sentence">句子</el-menu-item>
  29. </el-menu>
  30. </div>
  31. <div class="list" v-loading="loading">
  32. <template v-if="!isEmpty">
  33. <div class="main" v-for="(item, index) in list" :key="'order' + index">
  34. <div class="main-content" v-if="item.goods_type == 501">
  35. <div
  36. v-if="isShowCheckBox"
  37. class="checkBox"
  38. @click.stop="selecedGoods(item, index)"
  39. >
  40. <img
  41. :src="item.checked ? checked_img : check_img"
  42. class="check-img"
  43. />
  44. </div>
  45. <Hanzi
  46. :item="item"
  47. :index="index"
  48. @getMyCollectionList="getMyCollectionList"
  49. />
  50. </div>
  51. <div class="main-content" v-else-if="item.goods_type == 502">
  52. <div
  53. v-if="isShowCheckBox"
  54. class="checkBox"
  55. @click.stop="selecedGoods(item, index)"
  56. >
  57. <img
  58. :src="item.checked ? checked_img : check_img"
  59. class="check-img"
  60. />
  61. </div>
  62. <Sentence
  63. :key="item.id"
  64. :sItem="item"
  65. :index="index"
  66. @getMyCollectionList="getMyCollectionList"
  67. />
  68. </div>
  69. <div class="main-content" v-else>
  70. <div class="main-content-left" @click.stop="jump(item)">
  71. <div
  72. v-if="isShowCheckBox"
  73. class="checkBox"
  74. @click.stop="selecedGoods(item, index)"
  75. >
  76. <img
  77. :src="item.checked ? checked_img : check_img"
  78. class="check-img"
  79. />
  80. </div>
  81. <div class="coverUrl">
  82. <img :src="item.goods_picture_url" />
  83. </div>
  84. <div class="order-infor">
  85. <p class="name">{{ item.goods_name }}</p>
  86. <Goodstype :item="item" />
  87. <p class="author">{{ item.creator_name }}</p>
  88. </div>
  89. </div>
  90. <div class="main-content-right">
  91. <p class="collectTime">{{ item.create_time }}</p>
  92. <div class="order-btn">
  93. <div class="price">
  94. ¥<span class="price_num" v-html="item.goods_price_str"></span>
  95. </div>
  96. <button
  97. class="goPay"
  98. v-if="item.goods_is_buy == 'false'"
  99. @click="reOrder(item)"
  100. >
  101. 购买
  102. </button>
  103. <button class="goPay hasPay" v-if="item.goods_is_buy == 'true'">
  104. 已购买
  105. </button>
  106. </div>
  107. </div>
  108. </div>
  109. </div>
  110. <div class="paging">
  111. <el-pagination
  112. background
  113. layout="prev, pager, next"
  114. :current-page="pageNum"
  115. :total="total"
  116. :page-size="pageSize"
  117. @current-change="changecurrentPage"
  118. />
  119. </div>
  120. </template>
  121. <template v-else>
  122. <Empty :navType="navType" />
  123. </template>
  124. </div>
  125. <el-dialog
  126. class="orderDialog"
  127. title="商品详情"
  128. :visible.sync="isConfirmorder"
  129. width="720px"
  130. :before-close="closeConfirmorder"
  131. >
  132. <Confirmorder
  133. ref="Confirmorder"
  134. :data="goods_Data"
  135. :changeOrderNumber="changeOrderNumber"
  136. />
  137. </el-dialog>
  138. <el-dialog
  139. class="orderDialog"
  140. top="50px"
  141. :title="'订单号:' + orderNumber"
  142. :visible.sync="isPayment"
  143. width="720px"
  144. :before-close="closePayment"
  145. >
  146. <Payment
  147. :data="goods_Data"
  148. :orderNumber="orderNumber"
  149. :judgePayResult="judgePayResult"
  150. />
  151. </el-dialog>
  152. </div>
  153. </template>
  154. <script>
  155. import EditTitle from "../common/EditTitle.vue";
  156. import Empty from "../common/Empty.vue";
  157. import Goodstype from "../common/Goodstype.vue";
  158. import Cookies from "js-cookie";
  159. import { getLearnWebContent } from "@/api/ajax";
  160. import Confirmorder from "../common/Confirmorder.vue";
  161. import Payment from "../common/Payment.vue";
  162. import { jumpPath } from "@/utils/jumpPath";
  163. import Hanzi from "../common/Hanzi.vue";
  164. import Sentence from "../common/Sentence.vue";
  165. export default {
  166. name: "MyCollect",
  167. //import引入的组件需要注入到对象中才能使用
  168. components: {
  169. EditTitle,
  170. Empty,
  171. Goodstype,
  172. Confirmorder,
  173. Payment,
  174. Hanzi,
  175. Sentence,
  176. },
  177. props: {},
  178. data() {
  179. //这里存放数据
  180. return {
  181. navType: "6",
  182. isEmpty: false,
  183. activeIndex: "all",
  184. list: [],
  185. goods_name: "", // 商品名称,模糊查询,空表示查询所有
  186. goods_id_list: [], // 商品 ID 列表,空表示查询所有商品
  187. goods_type_list: [101], // 商品类型列表,具体参看数据字典 6.9,商品类型。空表示查询所有类型
  188. total: 0,
  189. pageSize: 20,
  190. pageNum: 1,
  191. currPageNum: 0,
  192. loading: false,
  193. isShowCheckBox: false,
  194. selecedGoodsList: [],
  195. check_img: require("../../assets/Personalcenter/check.png"),
  196. checked_img: require("../../assets/Personalcenter/checked.png"),
  197. listCount: 0,
  198. delCount: 0,
  199. isPayment: false,
  200. isConfirmorder: false,
  201. orderNumber: "",
  202. goods_Data: null,
  203. };
  204. },
  205. //计算属性 类似于data概念
  206. computed: {},
  207. //监控data中数据变化
  208. watch: {},
  209. //方法集合
  210. methods: {
  211. jump(item) {
  212. jumpPath(item);
  213. },
  214. //完成
  215. changeIsDel(isShowCheckBox) {
  216. this.isShowCheckBox = isShowCheckBox;
  217. this.selecedGoodsList = [];
  218. this.delCount = 0;
  219. this.currPageNum = 0;
  220. this.list.map((item) => {
  221. item.checked = false;
  222. return item;
  223. });
  224. },
  225. //取消
  226. changeIsCancle(isShowCheckBox) {
  227. this.selecedGoodsList = [];
  228. this.delCount = 0;
  229. this.currPageNum = 0;
  230. this.list.map((item) => {
  231. item.checked = false;
  232. return item;
  233. });
  234. },
  235. changecurrentPage(val) {
  236. this.pageNum = val;
  237. this.getMyCollectionList();
  238. },
  239. getMyCollectionList() {
  240. let _this = this;
  241. _this.loading = true;
  242. _this.delCount = 0;
  243. if (_this.currPageNum != _this.pageNum) {
  244. _this.isShowCheckBox = false;
  245. }
  246. let MethodName = "page_query-PageQueryMyCollectionList";
  247. let data = {
  248. goods_id_list: [],
  249. goods_type_list: this.goods_type_list,
  250. goods_name: _this.goods_name,
  251. page_capacity: _this.pageSize,
  252. cur_page: _this.pageNum,
  253. };
  254. getLearnWebContent(MethodName, data)
  255. .then((res) => {
  256. _this.loading = false;
  257. _this.total = res.total_count;
  258. let collection_list = res.collection_list;
  259. if (collection_list.length > 0) {
  260. this.list = collection_list.map((item) => {
  261. let obj = this.handleGoodsType(item.goods_type);
  262. item.className = obj.className;
  263. item.goods_type_root_name = obj.rootName;
  264. if (item.goods_price) {
  265. let goods_price = this.handlePrice(item.goods_price);
  266. item.goods_price_str = goods_price.price_str;
  267. //item.goods_price = goods_price.price;
  268. }
  269. // if (item.discount_money) {
  270. // let dis_price = this.handlePrice(item.goods_price);
  271. // item.discount_money = dis_price.price;
  272. // }
  273. // if (item.receivables_money) {
  274. // let rec_price = this.handlePrice(item.receivables_money);
  275. // item.receivables_money = rec_price.rprice;
  276. // }
  277. item.checked = false;
  278. return item;
  279. });
  280. this.isEmpty = false;
  281. this.listCount = this.list.length;
  282. } else {
  283. this.isEmpty = true;
  284. this.list = [];
  285. this.listCount = 0;
  286. }
  287. console.log(this.list);
  288. })
  289. .catch((error) => {
  290. _this.loading = false;
  291. });
  292. },
  293. handlePrice(price) {
  294. let priceArr = price.toString().split(".");
  295. if (priceArr.length > 1 && priceArr[1]) {
  296. } else {
  297. price = priceArr[0] + ".00";
  298. }
  299. let price_str = this.handlePrice2(price);
  300. return { price: price, price_str: price_str };
  301. },
  302. handlePrice2(price) {
  303. price = price.toString();
  304. let arr = price.split(".");
  305. let str = `<span style="font-size:24px;">${arr[0]}</span>.<span style="font-size:16px;">${arr[1]}</span>`;
  306. return str;
  307. },
  308. handleGoodsType(type) {
  309. let className = "",
  310. rootName = "";
  311. if (type) {
  312. type = type.toString();
  313. if (type.indexOf("10") > -1) {
  314. className = "type10";
  315. rootName = "教材";
  316. }
  317. if (type.indexOf("20") > -1) {
  318. rootName = "教学课程";
  319. className = "type20";
  320. }
  321. if (type.indexOf("30") > -1) {
  322. className = "type30";
  323. rootName = "教培课程";
  324. }
  325. if (type.indexOf("40") > -1) {
  326. className = "type40";
  327. rootName = "教研资料";
  328. }
  329. }
  330. return { className: className, rootName: rootName };
  331. },
  332. handleSelect(val) {
  333. let _this = this;
  334. _this.activeIndex = val;
  335. _this.pageNum = 1;
  336. _this.goods_name = "";
  337. _this.selecedGoodsList = [];
  338. if (_this.activeIndex == "all") {
  339. _this.goods_type_list = [];
  340. } else if (_this.activeIndex == "book") {
  341. _this.goods_type_list = [101];
  342. } else if (_this.activeIndex == "teaching") {
  343. _this.goods_type_list = [201];
  344. } else if (_this.activeIndex == "video") {
  345. _this.goods_type_list = [302];
  346. } else if (_this.activeIndex == "live") {
  347. _this.goods_type_list = [301];
  348. } else if (_this.activeIndex == "jiaoyan") {
  349. _this.goods_type_list = [401];
  350. } else if (_this.activeIndex == "hanzi") {
  351. _this.goods_type_list = [501];
  352. } else if (_this.activeIndex == "sentence") {
  353. _this.goods_type_list = [502];
  354. }
  355. _this.getMyCollectionList();
  356. },
  357. //勾选我的收藏
  358. selecedGoods(item, index) {
  359. let _this = this;
  360. if (item.checked) {
  361. item.checked = false;
  362. this.delCount--;
  363. let selecedGoodsList = JSON.parse(
  364. JSON.stringify(_this.selecedGoodsList)
  365. );
  366. selecedGoodsList = selecedGoodsList.filter((ele) => ele != item.id);
  367. _this.selecedGoodsList = selecedGoodsList;
  368. } else {
  369. item.checked = true;
  370. this.delCount++;
  371. _this.selecedGoodsList.push(item.id);
  372. }
  373. },
  374. //删除我的收藏
  375. deleteMyCollection() {
  376. let _this = this;
  377. if (_this.selecedGoodsList.length < 1) {
  378. this.$message.warning("请先勾选");
  379. return;
  380. }
  381. return new Promise((resolve) => {
  382. _this.loading = true;
  383. let MethodName = "order-collection_manager-DeleteMyCollection";
  384. let data = {
  385. id_list: _this.selecedGoodsList,
  386. };
  387. getLearnWebContent(MethodName, data).then((res) => {
  388. _this.$message.success("删除成功!");
  389. _this.loading = false;
  390. setTimeout(() => {
  391. _this.currPageNum = _this.pageNum;
  392. _this.goods_name = "";
  393. _this.selecedGoodsList = [];
  394. _this.getMyCollectionList();
  395. }, 500);
  396. resolve();
  397. });
  398. });
  399. },
  400. //获取订单编号
  401. changeOrderNumber(
  402. id,
  403. back_discount_code,
  404. discount_money,
  405. receivables_money
  406. ) {
  407. this.isConfirmorder = false;
  408. this.orderNumber = id;
  409. this.isPayment = true;
  410. this.goods_Data.discount_code = back_discount_code;
  411. this.goods_Data.discount_money = discount_money;
  412. this.goods_Data.receivables_money = receivables_money;
  413. console.log(this.goods_Data);
  414. },
  415. //去购买
  416. reOrder(item) {
  417. this.isConfirmorder = true;
  418. this.goods_Data = item;
  419. console.log(this.goods_Data);
  420. },
  421. closeConfirmorder() {
  422. this.isConfirmorder = false;
  423. this.$refs.Confirmorder.clearData();
  424. },
  425. closePayment() {
  426. this.isPayment = false;
  427. this.$refs.Confirmorder.clearData();
  428. },
  429. judgePayResult(bool) {
  430. this.isPayment = false;
  431. this.isConfirmorder = false;
  432. if (bool) {
  433. this.$message.success("支付成功");
  434. } else {
  435. this.$message.warning("支付失败");
  436. }
  437. this.getMyCollectionList();
  438. },
  439. },
  440. //生命周期 - 创建完成(可以访问当前this实例)
  441. created() {},
  442. //生命周期 - 挂载完成(可以访问DOM元素)
  443. mounted() {
  444. this.getMyCollectionList();
  445. },
  446. //生命周期-创建之前
  447. beforeCreated() {},
  448. //生命周期-挂载之前
  449. beforeMount() {},
  450. //生命周期-更新之前
  451. beforUpdate() {},
  452. //生命周期-更新之后
  453. updated() {},
  454. //生命周期-销毁之前
  455. beforeDestory() {},
  456. //生命周期-销毁完成
  457. destoryed() {},
  458. //如果页面有keep-alive缓存功能,这个函数会触发
  459. activated() {},
  460. };
  461. </script>
  462. <style lang="scss" scoped>
  463. /* @import url(); 引入css类 */
  464. .OrderManage {
  465. .list {
  466. width: 100%;
  467. min-height: 400px;
  468. .main {
  469. width: 100%;
  470. box-sizing: border-box;
  471. padding: 16px 16px 16px 16px;
  472. background: #ffffff;
  473. box-shadow: inset 0px -1px 0px rgba(0, 0, 0, 0.15);
  474. .checkBox {
  475. display: flex;
  476. justify-content: center;
  477. align-items: center;
  478. height: 88px;
  479. margin-right: 16px;
  480. cursor: pointer;
  481. .check-img {
  482. width: 16px;
  483. height: 16px;
  484. }
  485. }
  486. &-top {
  487. width: 100%;
  488. display: flex;
  489. justify-content: space-between;
  490. align-items: center;
  491. margin-bottom: 16px;
  492. &-left {
  493. display: flex;
  494. justify-content: flex-start;
  495. align-items: center;
  496. cursor: pointer;
  497. .orderTime {
  498. font-weight: bold;
  499. font-size: 14px;
  500. line-height: 150%;
  501. text-align: right;
  502. color: #2c2c2c;
  503. margin-right: 16px;
  504. }
  505. .orderNo {
  506. font-weight: normal;
  507. font-size: 14px;
  508. line-height: 150%;
  509. color: #2c2c2c;
  510. }
  511. }
  512. .del-order {
  513. width: 16px;
  514. height: 16px;
  515. cursor: pointer;
  516. }
  517. }
  518. &-content {
  519. display: flex;
  520. justify-content: space-between;
  521. &-left {
  522. display: flex;
  523. justify-content: flex-start;
  524. .coverUrl {
  525. width: 88px;
  526. height: 88px;
  527. margin-right: 24px;
  528. border-radius: 4px;
  529. display: flex;
  530. justify-content: center;
  531. align-items: center;
  532. > img {
  533. max-height: 100%;
  534. max-width: 100%;
  535. }
  536. }
  537. .order-infor {
  538. width: 528px;
  539. display: flex;
  540. flex-direction: column;
  541. align-items: flex-start;
  542. .name {
  543. font-weight: normal;
  544. font-size: 16px;
  545. line-height: 150%;
  546. color: #2c2c2c;
  547. overflow: hidden;
  548. white-space: nowrap;
  549. text-overflow: ellipsis;
  550. }
  551. .intro {
  552. font-weight: normal;
  553. font-size: 16px;
  554. line-height: 150%;
  555. color: #2c2c2c;
  556. opacity: 0.7;
  557. overflow: hidden;
  558. white-space: nowrap;
  559. text-overflow: ellipsis;
  560. }
  561. .author {
  562. font-weight: normal;
  563. font-size: 14px;
  564. line-height: 150%;
  565. color: #2c2c2c;
  566. opacity: 0.7;
  567. }
  568. .pinyin {
  569. font-weight: normal;
  570. font-size: 20px;
  571. line-height: 23px;
  572. color: #2c2c2c;
  573. }
  574. .en {
  575. font-style: normal;
  576. font-weight: 600;
  577. font-size: 20px;
  578. line-height: 25px;
  579. color: #2c2c2c;
  580. margin: 4px 0 12px;
  581. }
  582. .hanzi-btn {
  583. display: flex;
  584. justify-content: flex-start;
  585. align-items: center;
  586. &-img {
  587. display: flex;
  588. justify-content: center;
  589. align-items: center;
  590. width: 24px;
  591. height: 24px;
  592. background: #ff5757;
  593. border-radius: 4px;
  594. margin-right: 8px;
  595. cursor: pointer;
  596. > img {
  597. width: 16px;
  598. height: 16px;
  599. }
  600. }
  601. .more-intp {
  602. font-weight: normal;
  603. font-size: 14px;
  604. line-height: 20px;
  605. color: #2c2c2c;
  606. opacity: 0.5;
  607. cursor: pointer;
  608. }
  609. }
  610. }
  611. .hanzi {
  612. display: flex;
  613. justify-content: center;
  614. align-items: center;
  615. width: 88px;
  616. height: 88px;
  617. background: #ffffff;
  618. border: 1px solid #e0e0e0;
  619. box-sizing: border-box;
  620. border-radius: 4px;
  621. font-weight: normal;
  622. font-size: 48px;
  623. line-height: 100%;
  624. display: flex;
  625. align-items: center;
  626. text-align: center;
  627. color: #2c2c2c;
  628. margin-right: 16px;
  629. }
  630. }
  631. &-right {
  632. display: flex;
  633. flex-direction: column;
  634. justify-content: space-around;
  635. .collectTime {
  636. font-weight: normal;
  637. font-size: 14px;
  638. line-height: 150%;
  639. text-align: right;
  640. color: #2c2c2c;
  641. opacity: 0.5;
  642. margin-bottom: 16px;
  643. }
  644. .order-btn {
  645. display: flex;
  646. justify-content: flex-end;
  647. align-items: center;
  648. height: 40px;
  649. width: 240px;
  650. .price {
  651. font-weight: normal;
  652. font-size: 24px;
  653. line-height: 40px;
  654. color: #2c2c2c;
  655. margin-right: 12px;
  656. }
  657. .goPay {
  658. width: 120px;
  659. height: 40px;
  660. background: #ff9900;
  661. border-radius: 4px;
  662. font-weight: normal;
  663. font-size: 16px;
  664. line-height: 40px;
  665. text-align: center;
  666. text-transform: uppercase;
  667. color: #ffffff;
  668. cursor: pointer;
  669. border: 0;
  670. outline: 0;
  671. &.hasPay {
  672. background: #e5e5e5;
  673. color: #919191;
  674. }
  675. }
  676. }
  677. &.hanzi-right {
  678. justify-content: center;
  679. align-items: flex-start;
  680. padding-right: 24px;
  681. .resource {
  682. font-style: normal;
  683. font-weight: normal;
  684. font-size: 14px;
  685. line-height: 20px;
  686. color: #2c2c2c;
  687. opacity: 0.5;
  688. margin-bottom: 8px;
  689. }
  690. .collectTime {
  691. font-weight: normal;
  692. font-size: 14px;
  693. line-height: 20px;
  694. color: #2c2c2c;
  695. opacity: 0.5;
  696. margin: 0;
  697. }
  698. }
  699. }
  700. }
  701. }
  702. }
  703. .paging {
  704. margin-left: 16px;
  705. margin-top: 20px;
  706. }
  707. }
  708. </style>
  709. <style lang="scss">
  710. .OrderManage {
  711. .el-menu.el-menu--horizontal {
  712. border: 0;
  713. padding: 0 32px;
  714. }
  715. .el-menu--horizontal > .el-menu-item {
  716. height: 44px;
  717. font-size: 16px;
  718. line-height: 44px;
  719. text-align: center;
  720. padding: 0;
  721. margin-right: 24px;
  722. }
  723. .el-menu--horizontal > .el-menu-item.is-active {
  724. border-bottom: 1px solid #ff9900;
  725. color: #ff9900;
  726. }
  727. .el-pagination.is-background .el-pager li:not(.disabled).active {
  728. background: #ff9900;
  729. color: #fff;
  730. }
  731. }
  732. </style>