123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731 |
- <template>
- <div class="my-order">
- <div class="my-order__header">
- <el-tabs :value="activeName" @tab-click="tabChange">
- <el-tab-pane
- v-for="(tab, tabIndex) in list"
- :key="tabIndex"
- :label="tab.count ? `${tab.label}(${tab.count})` : `${tab.label}`"
- :name="tab.name"
- ></el-tab-pane>
- </el-tabs>
- </div>
- <div class="my-order__body">
- <div class="list" v-if="orderList.length == 0">
- <div class="no-data">您暂无相关订单哦~</div>
- </div>
- <div class="list" v-else>
- <template v-if="activeName == '2' && orderList.length">
- <el-button
- type="primary"
- class="invoice"
- @click="go('/person-center/my-invoice')"
- >发票申请</el-button
- >
- </template>
- <div class="order-item" v-for="(item, index) in orderList" :key="index">
- <div class="order-item__header">
- <div class="state">
- 订单号:
- <div class="note">{{ item.orderSn }}</div>
- </div>
- <div class="time">
- {{ $tools.timestampToTime(item.createTime) }}
- </div>
- </div>
- <div class="order-item__body clearfix">
- <template v-if="activeName != '4'">
- <div class="order-item__body__goodslist">
- <div
- class="goods-item clearfix"
- v-for="(items, itemIndex) in item.orderGoodsList"
- :key="itemIndex"
- >
- <div class="img">
- <img
- :src="$tools.splitImgHost(items.coverUrl, true)"
- alt=""
- />
- </div>
- <div class="text">
- <div class="title">{{ items.goodsName }}</div>
- <div class="desc">
- 应付金额:
- <span class="note">¥{{ items.goodsRealPrice }}</span>
- </div>
- </div>
- <div
- class="btn btn--nobg"
- @click="refund(item.orderSn, items.goodsId)"
- v-if="
- items.refundStatus === 0 &&
- (item.orderFrom === 2 || item.orderFrom === 3) &&
- (item.orderStatus === 1 ||
- item.orderStatus === 2 ||
- item.orderStatus === 3) &&
- (items.goodsType == '1' || items.goodsType == '2')
- "
- >
- 申请退款
- </div>
- <div class="state" v-if="items.refundStatus == 2">已退款</div>
- </div>
- </div>
- <div class="price-wrap">
- <div class="btns">
- <div class="price-text">实付金额</div>
- <div class="price-number">¥{{ item.payPrice }}</div>
- </div>
- </div>
- <div
- class="btns-wrap"
- v-if="
- (item.orderStatus === 0 &&
- (item.orderFrom === 2 || item.orderFrom === 3)) ||
- ((item.orderStatus === -1 || item.orderStatus === -2) &&
- (item.orderFrom === 2 || item.orderFrom === 3))
- "
- >
- <div class="btns">
- <el-button
- type="primary"
- class="btn"
- v-if="
- item.orderStatus === 0 &&
- (item.orderFrom === 2 || item.orderFrom === 3)
- "
- @click="pay(item)"
- >
- 立即支付
- </el-button>
- <div
- class="btn btn--nobg"
- v-if="
- item.orderStatus === 0 &&
- (item.orderFrom === 2 || item.orderFrom === 3)
- "
- @click="cancelOrder(item)"
- >
- 取消订单
- </div>
- <div
- class="btn btn--nobg"
- v-if="
- (item.orderStatus === -1 || item.orderStatus === -2) &&
- (item.orderFrom === 2 || item.orderFrom === 3)
- "
- @click="delOrder(item)"
- >
- 删除订单
- </div>
- <!-- <div class="btn btn--warm">开始学习</div> -->
- </div>
- </div>
- </template>
- <template v-else>
- <div class="order-item__body__goodslist">
- <div class="goods-item clearfix">
- <div class="img">
- <img
- :src="$tools.splitImgHost(item.coverUrl, true)"
- alt=""
- />
- </div>
- <div class="text">
- <div class="title">{{ item.goodsName }}</div>
- <div class="desc">
- <!-- 应付金额:
- <span class="note">¥99.99</span> -->
- </div>
- </div>
- </div>
- </div>
- <div class="refund-wrap">
- <div class="btns">
- <div class="price-text">已退款</div>
- <div class="price-number">¥{{ item.refundFee }}</div>
- </div>
- </div>
- </template>
- </div>
- </div>
- <div class="pagination">
- <el-pagination
- @current-change="currentChange"
- background
- layout="prev, pager, next"
- :total="total"
- :pager-count="5"
- :page-size="formData.pageSize"
- >
- </el-pagination>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import { mapMutations } from "vuex";
- export default {
- name: "MyOrder",
- data() {
- return {
- orderList: [],
- activeName: "1",
- formData: {
- status: "0,1",
- pageNum: 1,
- pageSize: 10,
- },
- total: 0,
- loading: null,
- list: [
- {
- label: "待支付",
- count: 0,
- name: "1",
- },
- {
- label: "已支付",
- count: 0,
- name: "2",
- },
- {
- label: "已取消",
- count: 0,
- name: "3",
- },
- {
- label: "已退款",
- count: 0,
- name: "4",
- },
- ],
- };
- },
- mounted() {
- if (this.$route.query.state) {
- this.activeName = this.$route.query.state;
- }
- this.getOrderNum();
- this.getOrderList();
- },
- methods: {
- ...mapMutations(["setCheckGoodsList"]),
- getOrderNum() {
- this.$request
- .getorderlists({
- status: "0,1",
- pageNum: 1,
- pageSize: 1,
- orderStatus: "0",
- })
- .then((res) => {
- this.list[0].count = res.total;
- });
- this.$request
- .getorderlists({
- status: "0,1",
- pageNum: 1,
- pageSize: 1,
- orderStatus: "1,2,3,4",
- })
- .then((res) => {
- this.list[1].count = res.total;
- });
- this.$request
- .getorderlists({
- status: "0,1",
- pageNum: 1,
- pageSize: 1,
- orderStatus: "-1,-2",
- })
- .then((res) => {
- this.list[2].count = res.total;
- });
- this.$request
- .orderRefundList({
- pageNum: 1,
- pageSize: 1,
- })
- .then((res) => {
- this.list[3].count = res.total;
- })
- .catch(this.hideLoading);
- },
- currentChange(e) {
- this.formData.pageNum = e;
- if (this.activeName == "4") {
- //退款订单
- this.formData.status = "";
- this.orderRefundList();
- } else {
- //其他订单
- this.formData.status = "0,1";
- this.getOrderList();
- }
- },
- tabChange(e) {
- if (this.activeName == e.name) {
- return;
- }
- this.formData.pageNum = 1;
- this.activeName = e.name;
- if (this.activeName == "4") {
- //退款订单
- this.formData.status = "";
- this.formData.pageNum = 1;
- this.orderRefundList();
- } else {
- //其他订单
- this.formData.status = "0,1";
- this.getOrderList();
- }
- },
- pay(item) {
- this.setCheckGoodsList([]);
- this.$router.push({
- path: "/payment",
- name: "支付",
- params: {
- total: item.payPrice,
- orderSn: item.orderSn,
- },
- });
- },
- refund(orderSn, goodsId) {
- this.$confirm("确定要退款吗?", "提示", {
- confirmButtonText: "确认",
- cancelButtonText: "取消",
- closeOnClickModal: false,
- closeOnPressEscape: false,
- distinguishCancelAndClose: false,
- showClose: false,
- })
- .then((_) => {
- this.showLoading();
- this.$request
- .refundSmallOrder({ orderSn: orderSn, goodsId: goodsId })
- .then((res) => {
- this.hideLoading();
- this.$message({
- type: "success",
- message: "退款成功",
- });
- this.getOrderNum();
- this.getOrderList();
- })
- .catch((err) => {
- this.hideLoading();
- this.$message({
- type: "warning",
- message: "不可以退款哦",
- });
- });
- })
- .catch((err) => {});
- },
- delOrder(item) {
- this.$confirm("确定要删除该订单吗?", "提示", {
- confirmButtonText: "确认",
- cancelButtonText: "取消",
- closeOnClickModal: false,
- closeOnPressEscape: false,
- distinguishCancelAndClose: false,
- showClose: false,
- })
- .then((_) => {
- this.showLoading();
- this.$request
- .eddOrder({ orderId: item.orderId, status: -1 })
- .then((res) => {
- this.$message({
- type: "success",
- message: "订单删除成功",
- });
- this.hideLoading();
- this.getOrderNum();
- this.getOrderList();
- })
- .catch((err) => {
- this.hideLoading();
- this.$message({
- type: "warning",
- message: err.msg,
- });
- });
- })
- .catch((err) => {
- this.hideLoading();
- });
- },
- orderRefundList() {
- this.showLoading();
- this.formData.orderStatus = "";
- this.$request
- .orderRefundList(this.formData)
- .then((res) => {
- this.hideLoading();
- this.orderList = res.rows;
- this.total = res.total;
- })
- .catch(this.hideLoading);
- },
- /**
- * 取消订单
- */
- cancelOrder(item) {
- this.$confirm("确定要取消该订单吗?", "提示", {
- confirmButtonText: "确认",
- cancelButtonText: "取消",
- closeOnClickModal: false,
- closeOnPressEscape: false,
- distinguishCancelAndClose: false,
- showClose: false,
- })
- .then((_) => {
- this.showLoading();
- this.$request
- .eddOrder({ orderId: item.orderId, orderStatus: -1 })
- .then((res) => {
- this.hideLoading();
- this.getOrderNum();
- this.$message({
- type: "success",
- message: "订单取消成功",
- });
- this.getOrderList();
- })
- .catch((err) => {
- this.hideLoading();
- this.$message({
- type: "warning",
- message: err.msg,
- });
- });
- })
- .catch((_) => {});
- },
- showLoading(obj) {
- this.loading = this.$loading({
- lock: true,
- text: (obj && obj.text) || "loading",
- spinner: "el-icon-loading",
- background: "rgba(0, 0, 0, 0)",
- target: document.querySelector(".my-order__body"),
- });
- },
- hideLoading() {
- this.loading.close();
- },
- //获取订单
- getOrderList() {
- this.showLoading();
- if (this.activeName == "1") {
- this.formData.orderStatus = "0";
- }
- if (this.activeName == "2") {
- this.formData.orderStatus = "1,2,3,4";
- }
- if (this.activeName == "3") {
- this.formData.orderStatus = "-1,-2";
- }
- this.$request
- .getorderlists(this.formData)
- .then((res) => {
- this.orderList = res.rows;
- this.total = res.total;
- this.hideLoading();
- })
- .catch(this.hideLoading);
- },
- },
- };
- </script>
- <!-- Add "scoped" attribute to limit CSS to this component only -->
- <style scoped lang="scss">
- .my-order {
- &__header {
- /deep/ .el-tabs__header {
- margin-bottom: 0;
- }
- /deep/ .el-tabs__item {
- padding: 0 30px !important;
- }
- }
- &__body {
- .invoice {
- margin-top: 10px;
- }
- .list {
- .order-item {
- margin-top: 24px;
- background: #fafbfc;
- border: 1px solid #eeeeee;
- box-shadow: 0px 0px 7px 1px rgba(0, 0, 0, 0.04);
- border-radius: 8px;
- overflow: hidden;
- &__header {
- height: 40px;
- border-bottom: 1px solid #eee;
- padding: 0 18px;
- .state {
- margin-top: 8px;
- float: left;
- font-size: 14px;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #666666;
- .note {
- vertical-align: middle;
- display: inline-block;
- font-size: 14px;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #3f8dfd;
- line-height: 24px;
- }
- }
- .time {
- float: right;
- line-height: 40px;
- text-align: right;
- font-size: 12px;
- font-family: Microsoft YaHei;
- font-weight: 400;
- color: #666666;
- }
- }
- &__body {
- display: flex;
- &__goodslist {
- flex: 1;
- .goods-item {
- margin-bottom: 20px;
- border-top: 1px solid #eee;
- border-bottom: 1px solid #eee;
- &:nth-last-of-type(1) {
- margin: 0;
- border-bottom: 0;
- }
- &:nth-of-type(1) {
- border-top: 0;
- }
- .img {
- float: left;
- width: 160px;
- height: 90px;
- display: table-cell;
- img {
- max-width: 100%;
- max-height: 100%;
- display: inline-block;
- vertical-align: middle;
- }
- }
- .text {
- float: left;
- margin-left: 12px;
- .title {
- margin-top: 10px;
- font-size: 16px;
- font-family: Microsoft YaHei;
- font-weight: bold;
- color: #333333;
- }
- .desc {
- margin-top: 30px;
- font-size: 14px;
- .note {
- color: #ff3b30;
- }
- }
- }
- .state {
- font-size: 14px;
- margin: 30px 0 0 0;
- float: right;
- width: 122px;
- height: 32px;
- line-height: 32px;
- text-align: center;
- }
- .btn {
- float: right;
- cursor: pointer;
- margin: 30px 0 0 0;
- width: 122px;
- height: 32px;
- font-size: 14px;
- background: #3f8dfd;
- border-radius: 16px;
- text-align: center;
- line-height: 32px;
- color: #fff;
- &--warm {
- background: #ff3b30;
- }
- &--nobg {
- background: none;
- color: #333;
- }
- }
- }
- }
- .refund-wrap {
- width: 320px;
- display: table;
- border-left: 1px solid #eee;
- .btns {
- display: table-cell;
- vertical-align: middle;
- text-align: center;
- .price-text {
- margin: 2px 0;
- width: 100%;
- height: 32px;
- font-size: 14px;
- display: inline-block;
- text-align: center;
- line-height: 32px;
- color: #333333;
- }
- .price-number {
- margin: 2px 0;
- width: 100%;
- height: 32px;
- font-weight: bold;
- display: inline-block;
- text-align: center;
- line-height: 32px;
- font-size: 16px;
- color: #333333;
- }
- }
- }
- .price-wrap {
- display: table;
- width: 160px;
- border-left: 1px solid #eee;
- .btns {
- display: table-cell;
- vertical-align: middle;
- text-align: center;
- .price-text {
- margin: 2px 0;
- width: 150px;
- height: 32px;
- font-size: 14px;
- display: inline-block;
- text-align: center;
- line-height: 32px;
- color: #333333;
- }
- .price-number {
- font-weight: bold;
- margin: 2px 0;
- width: 150px;
- height: 32px;
- font-size: 14px;
- display: inline-block;
- text-align: center;
- line-height: 32px;
- color: #ff3b30;
- }
- }
- }
- .btns-wrap {
- display: table;
- width: 160px;
- border-left: 1px solid #eee;
- .btns {
- display: table-cell;
- vertical-align: middle;
- text-align: center;
- .btn {
- cursor: pointer;
- margin: 2px 0;
- width: 122px;
- height: 32px;
- font-size: 14px;
- padding: 0;
- border-radius: 16px;
- display: inline-block;
- text-align: center;
- line-height: 32px;
- color: #fff;
- &--warm {
- background: #ff3b30;
- }
- &--nobg {
- background: none;
- color: #333;
- }
- }
- }
- }
- }
- }
- }
- .no-data {
- text-align: center;
- padding: 50px 0;
- color: #666;
- font-size: 16px;
- }
- .pagination {
- padding: 30px 0;
- text-align: center;
- }
- }
- }
- </style>
|