<template>
|
<div class="orderPage">
|
<div class="header">
|
<van-nav-bar
|
title="我的订单"
|
left-text=""
|
right-text=""
|
@click-left="onClickLeft"
|
left-arrow
|
/>
|
</div>
|
<!-- 列表 -->
|
<div class="recordBox">
|
<van-tabs
|
v-model="tabActive"
|
color="#1989fa"
|
title-active-color="#1989fa"
|
@change="changeMenu"
|
>
|
<van-tab title="全部">
|
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
|
<van-list
|
v-model="loading"
|
:finished="finished"
|
finished-text="没有更多了"
|
@load="onLoad"
|
>
|
<template slot="finished" name="finished">
|
<div v-if="orderList.length == 0">
|
<van-empty description="暂无数据" />
|
</div>
|
<div v-else>
|
没有更多了
|
</div>
|
</template>
|
<div class="orderListBox">
|
<div
|
class="orderList"
|
v-for="(item, index) in orderList"
|
:key="index"
|
>
|
<div class="spline"></div>
|
<div class="orderTitle">
|
<span class="orderNum">订单号: {{ item.orderNumber }}</span>
|
<span class="orderState wait" v-if="item.state == 'WaitPay'"
|
>待支付</span
|
>
|
<span
|
class="orderState successTxt"
|
v-if="item.state == 'Success'"
|
>已完成</span
|
>
|
<span class="orderState" v-if="item.state == 'Cancel'"
|
>已取消</span
|
>
|
</div>
|
<div class="orderContent">
|
<div
|
class="contentItem"
|
v-for="(citem, cindex) in item.saleMethodLinks"
|
:key="cindex"
|
@click="toDetail(citem)"
|
>
|
<div class="imgBox">
|
<img
|
class="bookImg"
|
:src="
|
tool.getPublicImage(
|
citem.orderSaleMethod.product.icon,
|
'840'
|
)
|
"
|
alt=""
|
/>
|
</div>
|
<div class="txtBox">
|
<div class="title">
|
{{ citem.orderSaleMethod.product.name }}
|
<span
|
v-if="citem.orderSaleMethod.name != '默认销售方式'"
|
>
|
{{
|
citem.orderSaleMethod.name.replace(
|
/-销售方式/g,
|
""
|
)
|
}}
|
</span>
|
</div>
|
<div class="price" v-if="citem.payPrice != 0">
|
¥
|
{{ tool.toDecimal2(citem.payPrice) }}
|
</div>
|
<div v-else class="successTxt">
|
免费
|
</div>
|
</div>
|
</div>
|
</div>
|
<div class="orderFunBox">
|
<div class="countInfoBox">
|
<span style="float: left;font-size: 12px;color: #999;"
|
>创建时间:{{
|
item.createDate.replace("T", " ").split(".")[0]
|
}}</span
|
>
|
<span v-if="item.payPrice != 0"
|
>合计:
|
<span class="priceTxt"
|
>¥ {{ tool.toDecimal2(item.payPrice) }}</span
|
></span
|
>
|
<span v-else class="successTxt">
|
免费
|
</span>
|
</div>
|
<div class="orderBtnBox">
|
<span
|
class="orderBtn"
|
@click="deletOrder(item)"
|
v-if="item.state == 'WaitPay'"
|
>取消订单</span
|
>
|
<span
|
class="orderBtn pay"
|
@click="toPay(item)"
|
v-if="item.state == 'WaitPay'"
|
>去支付</span
|
>
|
<!-- <span
|
class="orderBtn invoice"
|
v-if="
|
item.state == 'Success' &&
|
item.payPrice > 0 &&
|
!item.invoiceInfo &&
|
!item.exceedingTheSpecifiedTime
|
"
|
@click="toInvoice(item)"
|
>申请发票</span
|
> -->
|
</div>
|
</div>
|
</div>
|
</div>
|
</van-list>
|
</van-pull-refresh>
|
</van-tab>
|
<van-tab title="待支付">
|
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
|
<van-list
|
v-model="loading"
|
:finished="finished"
|
finished-text="没有更多了"
|
@load="onLoad"
|
>
|
<template slot="finished" name="finished">
|
<div v-if="orderList.length == 0">
|
<van-empty description="暂无数据" />
|
</div>
|
<div v-else>
|
没有更多了
|
</div>
|
</template>
|
<div class="orderListBox">
|
<div
|
class="orderList"
|
v-for="(item, index) in orderList"
|
:key="index"
|
>
|
<div class="spline"></div>
|
<div class="orderTitle">
|
<span class="orderNum">订单号: {{ item.orderNumber }}</span>
|
<span class="orderState wait" v-if="item.state == 'WaitPay'"
|
>待支付</span
|
>
|
</div>
|
<div class="orderContent">
|
<div
|
class="contentItem"
|
v-for="(citem, cindex) in item.saleMethodLinks"
|
:key="cindex"
|
@click="toDetail(citem)"
|
>
|
<div class="imgBox">
|
<img
|
class="bookImg"
|
:src="
|
tool.getPublicImage(
|
citem.orderSaleMethod.product.icon,
|
'840'
|
)
|
"
|
alt=""
|
/>
|
</div>
|
<div class="txtBox">
|
<div class="title">
|
{{ citem.orderSaleMethod.product.name }}
|
</div>
|
<div class="price" v-if="citem.payPrice != 0">
|
¥
|
{{ tool.toDecimal2(citem.payPrice) }}
|
</div>
|
<div v-else class="successTxt">免费</div>
|
</div>
|
</div>
|
</div>
|
<div class="orderFunBox">
|
<div class="countInfoBox">
|
<span style="float: left;font-size: 12px;color: #999;"
|
>创建时间:{{
|
item.createDate.replace("T", " ").split(".")[0]
|
}}</span
|
>
|
<span v-if="item.payPrice != 0"
|
>合计:
|
<span class="priceTxt"
|
>¥ {{ tool.toDecimal2(item.payPrice) }}</span
|
></span
|
>
|
<span v-else class="successTxt">
|
免费
|
</span>
|
</div>
|
<div class="orderBtnBox">
|
<span
|
class="orderBtn"
|
@click="deletOrder(item)"
|
v-if="item.state == 'WaitPay'"
|
>取消订单</span
|
>
|
<span
|
@click="toPay(item)"
|
class="orderBtn pay"
|
v-if="item.state == 'WaitPay'"
|
>去支付</span
|
>
|
</div>
|
</div>
|
</div>
|
</div>
|
</van-list>
|
</van-pull-refresh>
|
</van-tab>
|
<van-tab title="已完成">
|
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
|
<van-list
|
v-model="loading"
|
:finished="finished"
|
finished-text="没有更多了"
|
@load="onLoad"
|
>
|
<template slot="finished" name="finished">
|
<div v-if="orderList.length == 0">
|
<van-empty description="暂无数据" />
|
</div>
|
<div v-else>
|
没有更多了
|
</div>
|
</template>
|
<div class="orderListBox">
|
<div
|
class="orderList"
|
v-for="(item, index) in orderList"
|
:key="index"
|
>
|
<div class="spline"></div>
|
<div class="orderTitle">
|
<span class="orderNum">订单号: {{ item.orderNumber }}</span>
|
<span
|
class="orderState successTxt"
|
v-if="item.state == 'Success'"
|
>已完成</span
|
>
|
</div>
|
<div class="orderContent">
|
<div
|
class="contentItem"
|
v-for="(citem, cindex) in item.saleMethodLinks"
|
:key="cindex"
|
@click="toDetail(citem)"
|
>
|
<div class="imgBox">
|
<img
|
class="bookImg"
|
:src="
|
tool.getPublicImage(
|
citem.orderSaleMethod.product.icon,
|
'840'
|
)
|
"
|
alt=""
|
/>
|
</div>
|
<div class="txtBox">
|
<div class="title">
|
{{ citem.orderSaleMethod.product.name }}
|
</div>
|
<div class="price" v-if="citem.payPrice != 0">
|
¥
|
{{ tool.toDecimal2(citem.payPrice) }}
|
</div>
|
<div v-else class="successTxt">
|
免费
|
</div>
|
</div>
|
</div>
|
</div>
|
<div class="orderFunBox">
|
<div class="countInfoBox">
|
<span style="float: left;font-size: 12px;color: #999;"
|
>创建时间:{{
|
item.createDate.replace("T", " ").split(".")[0]
|
}}</span
|
>
|
<span v-if="item.payPrice != 0"
|
>合计:
|
<span class="priceTxt"
|
>¥ {{ tool.toDecimal2(item.payPrice) }}</span
|
></span
|
>
|
<span v-else class="successTxt">
|
免费
|
</span>
|
</div>
|
<!-- <div class="orderBtnBox">
|
<span
|
class="orderBtn invoice"
|
v-if="
|
item.state == 'Success' &&
|
item.payPrice > 0 &&
|
!item.invoiceInfo &&
|
!item.exceedingTheSpecifiedTime
|
"
|
@click="toInvoice(item)"
|
>申请发票</span
|
>
|
</div> -->
|
</div>
|
</div>
|
</div>
|
</van-list>
|
</van-pull-refresh>
|
</van-tab>
|
<van-tab title="已取消">
|
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
|
<van-list
|
v-model="loading"
|
:finished="finished"
|
finished-text="没有更多了"
|
@load="onLoad"
|
>
|
<template slot="finished" name="finished">
|
<div v-if="orderList.length == 0">
|
<van-empty description="暂无数据" />
|
</div>
|
<div v-else>
|
没有更多了
|
</div>
|
</template>
|
<div class="orderListBox">
|
<div
|
class="orderList"
|
v-for="(item, index) in orderList"
|
:key="index"
|
>
|
<div class="spline"></div>
|
<div class="orderTitle">
|
<span class="orderNum">订单号: {{ item.orderNumber }}</span>
|
<span class="orderState" v-if="item.state == 'Cancel'"
|
>已取消</span
|
>
|
</div>
|
<div class="orderContent">
|
<div
|
class="contentItem"
|
v-for="(citem, cindex) in item.saleMethodLinks"
|
:key="cindex"
|
@click="toDetail(citem)"
|
>
|
<div class="imgBox">
|
<img
|
class="bookImg"
|
:src="
|
tool.getPublicImage(
|
citem.orderSaleMethod.product.icon,
|
'840'
|
)
|
"
|
alt=""
|
/>
|
</div>
|
<div class="txtBox">
|
<div class="title">
|
{{ citem.orderSaleMethod.product.name }}
|
</div>
|
<div class="price" v-if="citem.payPrice != 0">
|
¥
|
{{ tool.toDecimal2(citem.payPrice) }}
|
</div>
|
<div v-else class="successTxt">
|
免费
|
</div>
|
</div>
|
</div>
|
</div>
|
<div class="orderFunBox">
|
<div class="countInfoBox">
|
<span style="float: left;font-size: 12px;color: #999;"
|
>创建时间:{{
|
item.createDate.replace("T", " ").split(".")[0]
|
}}</span
|
>
|
<span
|
>合计:
|
<span class="priceTxt"
|
>¥ {{ tool.toDecimal2(item.payPrice) }}</span
|
></span
|
>
|
</div>
|
</div>
|
</div>
|
</div>
|
</van-list>
|
</van-pull-refresh>
|
</van-tab>
|
</van-tabs>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import { mapState } from "vuex";
|
import { setOrderList } from "@/assets/js/toolClass";
|
|
import Vue from "vue";
|
import {
|
Tab,
|
Tabs,
|
List,
|
PullRefresh,
|
NavBar,
|
Dialog,
|
Toast,
|
Empty
|
} from "vant";
|
Vue.use(Tab);
|
Vue.use(Tabs);
|
Vue.use(List);
|
Vue.use(PullRefresh);
|
Vue.use(Dialog);
|
Vue.use(Toast);
|
Vue.use(NavBar);
|
Vue.use(Empty);
|
export default {
|
data() {
|
return {
|
arrow: true,
|
headTitle: "我的订单",
|
//分页
|
loading: true,
|
finished: false,
|
refreshing: false,
|
// tabActive
|
tabActive: 0,
|
// 订单列表
|
orderList: [],
|
//分页
|
paginationData: {
|
page: 1,
|
limit: 6,
|
totalCount: 0,
|
totalPage: 0
|
},
|
//筛选条件请求参数
|
querySearch: []
|
};
|
},
|
computed: {
|
...mapState(["userInfo"])
|
},
|
created() {
|
this.getOrderList();
|
},
|
beforeRouteLeave(to, from, next) {
|
if (to.name != "bookDetail") {
|
this.$store.commit("delKeepAlive", from.name);
|
}
|
next();
|
},
|
methods: {
|
//获取订单列表
|
getOrderList() {
|
this.loading = true;
|
let data = {
|
Size: 9999,
|
Start: 0,
|
sort: {
|
type: "Desc",
|
field: "CreateDate"
|
},
|
searchList: this.querySearch,
|
filterList: this.queryFilter
|
};
|
this.MG.store.getUserOrderList(data).then(response => {
|
// console.log(response)
|
// 判断是否已加载完数据'
|
let list = [];
|
response.datas.forEach(element => {
|
if (
|
element.saleMethodLinks[0].orderSaleMethod.product.cmsTypeRefCode ==
|
"tourism_digitalTextbooks"
|
) {
|
list.push(element);
|
}
|
});
|
this.finished = true;
|
this.orderList = setOrderList(list);
|
this.loading = false;
|
this.refreshing = false;
|
});
|
},
|
//切换菜单
|
changeMenu() {
|
if (this.tabActive == 0) {
|
this.queryFilter = [];
|
} else if (this.tabActive == 1) {
|
this.queryFilter = [{ field: "State", value: "WaitPay" }];
|
} else if (this.tabActive == 2) {
|
this.queryFilter = [{ field: "State", value: "Success" }];
|
} else if (this.tabActive == 3) {
|
this.queryFilter = [{ field: "State", value: "Cancel" }];
|
}
|
this.orderList = [];
|
// 恢复数据加载完毕的状态
|
this.finished = false;
|
this.getOrderList();
|
},
|
// 上拉加载
|
onLoad() {
|
this.getOrderList();
|
},
|
// 下拉刷新
|
onRefresh() {
|
this.paginationData.page = 1;
|
this.getOrderList();
|
this.finished = true;
|
},
|
// 申请发票
|
toInvoice(item) {
|
this.$router.push({
|
path: "/applyInvoice",
|
query: {
|
invoiceOrderNum: item.orderNumber,
|
invoiceOrderPrice: item.payPrice,
|
invoiceOrderInfo: JSON.stringify(item)
|
}
|
});
|
},
|
toPay(item) {
|
this.$router.push({
|
path: "/pay",
|
query: {
|
orderNum: item.orderNumber
|
}
|
});
|
},
|
deletOrder(item) {
|
Dialog.confirm({
|
title: "温馨提示",
|
message: "确定取消该订单吗?"
|
})
|
.then(() => {
|
this.MG.store
|
.cancelOrder({ orderNum: item.orderNumber })
|
.then(res => {
|
if (res) {
|
Toast.success("订单已取消");
|
item.state = "Cancel";
|
} else {
|
Toast.fail("订单取消失败");
|
}
|
});
|
})
|
.catch(() => {});
|
},
|
toDetail(item) {
|
let query = {
|
path: "*",
|
queryType: "*",
|
productId: item.orderSaleMethod.product.id,
|
storeInfo: this.config.digitalTextBooksGoodsStore
|
};
|
this.MG.store.getProductDetail(query).then(res => {
|
this.$router.push({
|
path: "/bookDetail",
|
query: {
|
id: res.datas.id
|
}
|
});
|
});
|
},
|
onClickLeft() {
|
var that = this;
|
that.$router.go(-1);
|
}
|
}
|
};
|
</script>
|
|
<style scoped>
|
.recordBox {
|
max-height: calc(100vh - 75px);
|
overflow: auto;
|
}
|
.orderTitle {
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
color: #999;
|
padding: 20px 15px;
|
border-bottom: 1px solid #dddddd;
|
}
|
.orderContent {
|
padding: 15px;
|
}
|
.contentItem {
|
display: flex;
|
margin-top: 12px;
|
}
|
.txtBox {
|
display: flex;
|
flex: 1;
|
flex-direction: column;
|
justify-content: space-between;
|
margin-left: 15px;
|
}
|
.imgBox {
|
width: 105px;
|
height: 140px;
|
margin: 0 auto;
|
overflow: hidden;
|
border-radius: 5px;
|
box-shadow: 0 3px 6px 1px #00000029;
|
}
|
.imgBox img {
|
width: auto;
|
height: auto;
|
max-width: 100%;
|
max-height: 100%;
|
display: inline-block;
|
}
|
.txtBox .title {
|
font-size: 16px;
|
color: #333333;
|
font-weight: bold;
|
}
|
.txtBox .price {
|
font-size: 18px;
|
color: #f24b3b;
|
}
|
.orderFunBox {
|
padding: 15px;
|
border-top: 1px solid #ddd;
|
}
|
.orderBtnBox {
|
text-align: right;
|
}
|
.countInfoBox {
|
text-align: right;
|
}
|
.orderBtn {
|
margin-top: 30px;
|
display: inline-block;
|
padding: 10px 20px;
|
color: #333333;
|
background: #fff;
|
border: 1px solid #ddd;
|
border-radius: 10px;
|
margin-left: 20px;
|
}
|
.orderState.discuss {
|
color: #2e70ff;
|
}
|
.orderState.wait {
|
color: #f04343;
|
}
|
.invoice {
|
color: #fff;
|
background: #2e70ff;
|
}
|
.pay {
|
color: #fff;
|
background: #f04343;
|
}
|
.priceTxt {
|
color: #f04343;
|
}
|
</style>
|