123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743 |
- <template>
- <!-- 购买记录 -->
- <div class="OrderManage personal-center">
- <EditTitle
- title="我的收藏"
- :isDel="1"
- :isShowCheckBox="isShowCheckBox"
- :changeIsDel="changeIsDel"
- :changeIsCancle="changeIsCancle"
- :deleteMyCollection="deleteMyCollection"
- :listCount="listCount"
- :delCount="delCount"
- />
- <div>
- <el-menu
- :default-active="activeIndex"
- class="el-menu-demo"
- mode="horizontal"
- @select="handleSelect"
- >
- <!-- <el-menu-item index="all">全部</el-menu-item> -->
- <el-menu-item index="book">教材</el-menu-item>
- <el-menu-item index="teaching">教学课程</el-menu-item>
- <el-menu-item index="video">视频</el-menu-item>
- <el-menu-item index="live">直播</el-menu-item>
- <el-menu-item index="jiaoyan">教研资料</el-menu-item>
- <el-menu-item index="hanzi">字词</el-menu-item>
- <el-menu-item index="sentence">句子</el-menu-item>
- </el-menu>
- </div>
- <div class="list" v-loading="loading">
- <template v-if="!isEmpty">
- <div class="main" v-for="(item, index) in list" :key="'order' + index">
- <div class="main-content" v-if="item.goods_type == 501">
- <div
- v-if="isShowCheckBox"
- class="checkBox"
- @click.stop="selecedGoods(item, index)"
- >
- <img
- :src="item.checked ? checked_img : check_img"
- class="check-img"
- />
- </div>
- <Hanzi
- :item="item"
- :index="index"
- @getMyCollectionList="getMyCollectionList"
- />
- </div>
- <div class="main-content" v-else-if="item.goods_type == 502">
- <div
- v-if="isShowCheckBox"
- class="checkBox"
- @click.stop="selecedGoods(item, index)"
- >
- <img
- :src="item.checked ? checked_img : check_img"
- class="check-img"
- />
- </div>
- <Sentence
- :key="item.id"
- :sItem="item"
- :index="index"
- @getMyCollectionList="getMyCollectionList"
- />
- </div>
- <div class="main-content" v-else>
- <div class="main-content-left" @click.stop="jump(item)">
- <div
- v-if="isShowCheckBox"
- class="checkBox"
- @click.stop="selecedGoods(item, index)"
- >
- <img
- :src="item.checked ? checked_img : check_img"
- class="check-img"
- />
- </div>
- <div class="coverUrl">
- <img :src="item.goods_picture_url" />
- </div>
- <div class="order-infor">
- <p class="name">{{ item.goods_name }}</p>
- <Goodstype :item="item" />
- <p class="author">{{ item.creator_name }}</p>
- </div>
- </div>
- <div class="main-content-right">
- <p class="collectTime">{{ item.create_time }}</p>
- <div class="order-btn">
- <div class="price">
- ¥<span class="price_num" v-html="item.goods_price_str"></span>
- </div>
- <button
- class="goPay"
- v-if="item.goods_is_buy == 'false'"
- @click="reOrder(item)"
- >
- 购买
- </button>
- <button class="goPay hasPay" v-if="item.goods_is_buy == 'true'">
- 已购买
- </button>
- </div>
- </div>
- </div>
- </div>
- <div class="paging">
- <el-pagination
- background
- layout="prev, pager, next"
- :current-page="pageNum"
- :total="total"
- :page-size="pageSize"
- @current-change="changecurrentPage"
- />
- </div>
- </template>
- <template v-else>
- <Empty :navType="navType" />
- </template>
- </div>
- <el-dialog
- class="orderDialog"
- title="商品详情"
- :visible.sync="isConfirmorder"
- width="720px"
- :before-close="closeConfirmorder"
- >
- <Confirmorder
- ref="Confirmorder"
- :data="goods_Data"
- :changeOrderNumber="changeOrderNumber"
- />
- </el-dialog>
- <el-dialog
- class="orderDialog"
- top="50px"
- :title="'订单号:' + orderNumber"
- :visible.sync="isPayment"
- width="720px"
- :before-close="closePayment"
- >
- <Payment
- :data="goods_Data"
- :orderNumber="orderNumber"
- :judgePayResult="judgePayResult"
- />
- </el-dialog>
- </div>
- </template>
- <script>
- import EditTitle from "../common/EditTitle.vue";
- import Empty from "../common/Empty.vue";
- import Goodstype from "../common/Goodstype.vue";
- import Cookies from "js-cookie";
- import { getLearnWebContent } from "@/api/ajax";
- import Confirmorder from "../common/Confirmorder.vue";
- import Payment from "../common/Payment.vue";
- import { jumpPath } from "@/utils/jumpPath";
- import Hanzi from "../common/Hanzi.vue";
- import Sentence from "../common/Sentence.vue";
- export default {
- name: "MyCollect",
- //import引入的组件需要注入到对象中才能使用
- components: {
- EditTitle,
- Empty,
- Goodstype,
- Confirmorder,
- Payment,
- Hanzi,
- Sentence,
- },
- props: {},
- data() {
- //这里存放数据
- return {
- navType: "6",
- isEmpty: false,
- activeIndex: "all",
- list: [],
- goods_name: "", // 商品名称,模糊查询,空表示查询所有
- goods_id_list: [], // 商品 ID 列表,空表示查询所有商品
- goods_type_list: [101], // 商品类型列表,具体参看数据字典 6.9,商品类型。空表示查询所有类型
- total: 0,
- pageSize: 20,
- pageNum: 1,
- currPageNum: 0,
- loading: false,
- isShowCheckBox: false,
- selecedGoodsList: [],
- check_img: require("../../assets/Personalcenter/check.png"),
- checked_img: require("../../assets/Personalcenter/checked.png"),
- listCount: 0,
- delCount: 0,
- isPayment: false,
- isConfirmorder: false,
- orderNumber: "",
- goods_Data: null,
- };
- },
- //计算属性 类似于data概念
- computed: {},
- //监控data中数据变化
- watch: {},
- //方法集合
- methods: {
- jump(item) {
- jumpPath(item);
- },
- //完成
- changeIsDel(isShowCheckBox) {
- this.isShowCheckBox = isShowCheckBox;
- this.selecedGoodsList = [];
- this.delCount = 0;
- this.currPageNum = 0;
- this.list.map((item) => {
- item.checked = false;
- return item;
- });
- },
- //取消
- changeIsCancle(isShowCheckBox) {
- this.selecedGoodsList = [];
- this.delCount = 0;
- this.currPageNum = 0;
- this.list.map((item) => {
- item.checked = false;
- return item;
- });
- },
- changecurrentPage(val) {
- this.pageNum = val;
- this.getMyCollectionList();
- },
- getMyCollectionList() {
- let _this = this;
- _this.loading = true;
- _this.delCount = 0;
- if (_this.currPageNum != _this.pageNum) {
- _this.isShowCheckBox = false;
- }
- let MethodName = "page_query-PageQueryMyCollectionList";
- let data = {
- goods_id_list: [],
- goods_type_list: this.goods_type_list,
- goods_name: _this.goods_name,
- page_capacity: _this.pageSize,
- cur_page: _this.pageNum,
- };
- getLearnWebContent(MethodName, data)
- .then((res) => {
- _this.loading = false;
- _this.total = res.total_count;
- let collection_list = res.collection_list;
- if (collection_list.length > 0) {
- this.list = collection_list.map((item) => {
- let obj = this.handleGoodsType(item.goods_type);
- item.className = obj.className;
- item.goods_type_root_name = obj.rootName;
- if (item.goods_price) {
- let goods_price = this.handlePrice(item.goods_price);
- item.goods_price_str = goods_price.price_str;
- //item.goods_price = goods_price.price;
- }
- // if (item.discount_money) {
- // let dis_price = this.handlePrice(item.goods_price);
- // item.discount_money = dis_price.price;
- // }
- // if (item.receivables_money) {
- // let rec_price = this.handlePrice(item.receivables_money);
- // item.receivables_money = rec_price.rprice;
- // }
- item.checked = false;
- return item;
- });
- this.isEmpty = false;
- this.listCount = this.list.length;
- } else {
- this.isEmpty = true;
- this.list = [];
- this.listCount = 0;
- }
- console.log(this.list);
- })
- .catch((error) => {
- _this.loading = false;
- });
- },
- handlePrice(price) {
- let priceArr = price.toString().split(".");
- if (priceArr.length > 1 && priceArr[1]) {
- } else {
- price = priceArr[0] + ".00";
- }
- let price_str = this.handlePrice2(price);
- return { price: price, price_str: price_str };
- },
- handlePrice2(price) {
- price = price.toString();
- let arr = price.split(".");
- let str = `<span style="font-size:24px;">${arr[0]}</span>.<span style="font-size:16px;">${arr[1]}</span>`;
- return str;
- },
- handleGoodsType(type) {
- let className = "",
- rootName = "";
- if (type) {
- type = type.toString();
- if (type.indexOf("10") > -1) {
- className = "type10";
- rootName = "教材";
- }
- if (type.indexOf("20") > -1) {
- rootName = "教学课程";
- className = "type20";
- }
- if (type.indexOf("30") > -1) {
- className = "type30";
- rootName = "教培课程";
- }
- if (type.indexOf("40") > -1) {
- className = "type40";
- rootName = "教研资料";
- }
- }
- return { className: className, rootName: rootName };
- },
- handleSelect(val) {
- let _this = this;
- _this.activeIndex = val;
- _this.pageNum = 1;
- _this.goods_name = "";
- _this.selecedGoodsList = [];
- if (_this.activeIndex == "all") {
- _this.goods_type_list = [];
- } else if (_this.activeIndex == "book") {
- _this.goods_type_list = [101];
- } else if (_this.activeIndex == "teaching") {
- _this.goods_type_list = [201];
- } else if (_this.activeIndex == "video") {
- _this.goods_type_list = [302];
- } else if (_this.activeIndex == "live") {
- _this.goods_type_list = [301];
- } else if (_this.activeIndex == "jiaoyan") {
- _this.goods_type_list = [401];
- } else if (_this.activeIndex == "hanzi") {
- _this.goods_type_list = [501];
- } else if (_this.activeIndex == "sentence") {
- _this.goods_type_list = [502];
- }
- _this.getMyCollectionList();
- },
- //勾选我的收藏
- selecedGoods(item, index) {
- let _this = this;
- if (item.checked) {
- item.checked = false;
- this.delCount--;
- let selecedGoodsList = JSON.parse(
- JSON.stringify(_this.selecedGoodsList)
- );
- selecedGoodsList = selecedGoodsList.filter((ele) => ele != item.id);
- _this.selecedGoodsList = selecedGoodsList;
- } else {
- item.checked = true;
- this.delCount++;
- _this.selecedGoodsList.push(item.id);
- }
- },
- //删除我的收藏
- deleteMyCollection() {
- let _this = this;
- if (_this.selecedGoodsList.length < 1) {
- this.$message.warning("请先勾选");
- return;
- }
- return new Promise((resolve) => {
- _this.loading = true;
- let MethodName = "order-collection_manager-DeleteMyCollection";
- let data = {
- id_list: _this.selecedGoodsList,
- };
- getLearnWebContent(MethodName, data).then((res) => {
- _this.$message.success("删除成功!");
- _this.loading = false;
- setTimeout(() => {
- _this.currPageNum = _this.pageNum;
- _this.goods_name = "";
- _this.selecedGoodsList = [];
- _this.getMyCollectionList();
- }, 500);
- resolve();
- });
- });
- },
- //获取订单编号
- changeOrderNumber(
- id,
- back_discount_code,
- discount_money,
- receivables_money
- ) {
- this.isConfirmorder = false;
- this.orderNumber = id;
- this.isPayment = true;
- this.goods_Data.discount_code = back_discount_code;
- this.goods_Data.discount_money = discount_money;
- this.goods_Data.receivables_money = receivables_money;
- console.log(this.goods_Data);
- },
- //去购买
- reOrder(item) {
- this.isConfirmorder = true;
- this.goods_Data = item;
- console.log(this.goods_Data);
- },
- closeConfirmorder() {
- this.isConfirmorder = false;
- this.$refs.Confirmorder.clearData();
- },
- closePayment() {
- this.isPayment = false;
- this.$refs.Confirmorder.clearData();
- },
- judgePayResult(bool) {
- this.isPayment = false;
- this.isConfirmorder = false;
- if (bool) {
- this.$message.success("支付成功");
- } else {
- this.$message.warning("支付失败");
- }
- this.getMyCollectionList();
- },
- },
- //生命周期 - 创建完成(可以访问当前this实例)
- created() {},
- //生命周期 - 挂载完成(可以访问DOM元素)
- mounted() {
- this.getMyCollectionList();
- },
- //生命周期-创建之前
- beforeCreated() {},
- //生命周期-挂载之前
- beforeMount() {},
- //生命周期-更新之前
- beforUpdate() {},
- //生命周期-更新之后
- updated() {},
- //生命周期-销毁之前
- beforeDestory() {},
- //生命周期-销毁完成
- destoryed() {},
- //如果页面有keep-alive缓存功能,这个函数会触发
- activated() {},
- };
- </script>
- <style lang="scss" scoped>
- /* @import url(); 引入css类 */
- .OrderManage {
- .list {
- width: 100%;
- min-height: 400px;
- .main {
- width: 100%;
- box-sizing: border-box;
- padding: 16px 16px 16px 16px;
- background: #ffffff;
- box-shadow: inset 0px -1px 0px rgba(0, 0, 0, 0.15);
- .checkBox {
- display: flex;
- justify-content: center;
- align-items: center;
- height: 88px;
- margin-right: 16px;
- cursor: pointer;
- .check-img {
- width: 16px;
- height: 16px;
- }
- }
- &-top {
- width: 100%;
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 16px;
- &-left {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- cursor: pointer;
- .orderTime {
- font-weight: bold;
- font-size: 14px;
- line-height: 150%;
- text-align: right;
- color: #2c2c2c;
- margin-right: 16px;
- }
- .orderNo {
- font-weight: normal;
- font-size: 14px;
- line-height: 150%;
- color: #2c2c2c;
- }
- }
- .del-order {
- width: 16px;
- height: 16px;
- cursor: pointer;
- }
- }
- &-content {
- display: flex;
- justify-content: space-between;
- &-left {
- display: flex;
- justify-content: flex-start;
- .coverUrl {
- width: 88px;
- height: 88px;
- margin-right: 24px;
- border-radius: 4px;
- display: flex;
- justify-content: center;
- align-items: center;
- > img {
- max-height: 100%;
- max-width: 100%;
- }
- }
- .order-infor {
- width: 528px;
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- .name {
- font-weight: normal;
- font-size: 16px;
- line-height: 150%;
- color: #2c2c2c;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- .intro {
- font-weight: normal;
- font-size: 16px;
- line-height: 150%;
- color: #2c2c2c;
- opacity: 0.7;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- .author {
- font-weight: normal;
- font-size: 14px;
- line-height: 150%;
- color: #2c2c2c;
- opacity: 0.7;
- }
- .pinyin {
- font-weight: normal;
- font-size: 20px;
- line-height: 23px;
- color: #2c2c2c;
- }
- .en {
- font-style: normal;
- font-weight: 600;
- font-size: 20px;
- line-height: 25px;
- color: #2c2c2c;
- margin: 4px 0 12px;
- }
- .hanzi-btn {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- &-img {
- display: flex;
- justify-content: center;
- align-items: center;
- width: 24px;
- height: 24px;
- background: #ff5757;
- border-radius: 4px;
- margin-right: 8px;
- cursor: pointer;
- > img {
- width: 16px;
- height: 16px;
- }
- }
- .more-intp {
- font-weight: normal;
- font-size: 14px;
- line-height: 20px;
- color: #2c2c2c;
- opacity: 0.5;
- cursor: pointer;
- }
- }
- }
- .hanzi {
- display: flex;
- justify-content: center;
- align-items: center;
- width: 88px;
- height: 88px;
- background: #ffffff;
- border: 1px solid #e0e0e0;
- box-sizing: border-box;
- border-radius: 4px;
- font-weight: normal;
- font-size: 48px;
- line-height: 100%;
- display: flex;
- align-items: center;
- text-align: center;
- color: #2c2c2c;
- margin-right: 16px;
- }
- }
- &-right {
- display: flex;
- flex-direction: column;
- justify-content: space-around;
- .collectTime {
- font-weight: normal;
- font-size: 14px;
- line-height: 150%;
- text-align: right;
- color: #2c2c2c;
- opacity: 0.5;
- margin-bottom: 16px;
- }
- .order-btn {
- display: flex;
- justify-content: flex-end;
- align-items: center;
- height: 40px;
- width: 240px;
- .price {
- font-weight: normal;
- font-size: 24px;
- line-height: 40px;
- color: #2c2c2c;
- margin-right: 12px;
- }
- .goPay {
- width: 120px;
- height: 40px;
- background: #ff9900;
- border-radius: 4px;
- font-weight: normal;
- font-size: 16px;
- line-height: 40px;
- text-align: center;
- text-transform: uppercase;
- color: #ffffff;
- cursor: pointer;
- border: 0;
- outline: 0;
- &.hasPay {
- background: #e5e5e5;
- color: #919191;
- }
- }
- }
- &.hanzi-right {
- justify-content: center;
- align-items: flex-start;
- padding-right: 24px;
- .resource {
- font-style: normal;
- font-weight: normal;
- font-size: 14px;
- line-height: 20px;
- color: #2c2c2c;
- opacity: 0.5;
- margin-bottom: 8px;
- }
- .collectTime {
- font-weight: normal;
- font-size: 14px;
- line-height: 20px;
- color: #2c2c2c;
- opacity: 0.5;
- margin: 0;
- }
- }
- }
- }
- }
- }
- .paging {
- margin-left: 16px;
- margin-top: 20px;
- }
- }
- </style>
- <style lang="scss">
- .OrderManage {
- .el-menu.el-menu--horizontal {
- border: 0;
- padding: 0 32px;
- }
- .el-menu--horizontal > .el-menu-item {
- height: 44px;
- font-size: 16px;
- line-height: 44px;
- text-align: center;
- padding: 0;
- margin-right: 24px;
- }
- .el-menu--horizontal > .el-menu-item.is-active {
- border-bottom: 1px solid #ff9900;
- color: #ff9900;
- }
- .el-pagination.is-background .el-pager li:not(.disabled).active {
- background: #ff9900;
- color: #fff;
- }
- }
- </style>
|