refund-order.vue
5.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<template>
<div class="order-wrapper return-goods" v-show="orderList.length > 0">
<ul v-infinite-scroll="getRefundData()" infinite-scroll-disabled="busy" infinite-scroll-distance="10">
<li class="order-item" v-for="(index, order) in orderList">
<div class="order-detail">
<div class="order-code">
<div class="code-time">
<p>订单号:{{order.order_code}}</p>
<p>申请时间:{{order.order_create_time}}</p>
</div>
<p>{{order.status_name}}</p>
</div>
<div class="order-goods">
<div class="goods-info" v-for="product in order.goods">
<div class="img-box">
<img :src="product.goods_image | resize 49 65">
<label v-if="product.goods_type === 'gift'">赠品</label>
<label class="price-gift" v-if="product.goods_type === 'price_gift'">加价购</label>
</div>
<div class="goods-detail">
<p class="name">{{product.product_name}}</p>
<p class="size">
<span>颜色: {{product.color_name}}</span>
<span>尺码: {{product.size_name}}</span>
</p>
</div>
<div class="goods-price">
<p>¥{{product.sales_price}}</p>
<p>×1</p>
</div>
<a v-if="order.refund_type === 1" href="/me/return/refund/detail/{{order.id}}"></a>
<a v-if="order.refund_type === 2" href="/me/return/exchange/detail/{{order.id}}"></a>
</div>
</div>
<div class="order-option" v-show="order.canCancel == 'Y'">
<div class="goods-total"></div>
<div class="options">
<button class="normal" @click="cancelApply(order.id, order.refund_type)">取消申请</button>
</div>
</div>
</div>
</li>
</ul>
</div>
<div class="order-empty {{emptybox}}">
<p>您暂时还没有订单</p>
<p>Your do not have an order <br>for the time being</p>
<a href="/product/new">随便逛逛</a>
</div>
</template>
<script>
'use strict';
const $ = require('jquery');
const tip = require('common/tip');
const Modal = require('common/modal');
const yoho = require('yoho');
module.exports = {
data() {
return {
page: 0,
limit: 10,
pageTotal: 1,
orderList: [],
busy: false,
emptybox: 'hide'
};
},
created() {
this.reload();
document.addEventListener('visibilitychange', () => {
if (!document.hidden && yoho.store.get('refundOrder')) {
this.reload();
}
});
},
methods: {
reload() {
this.page= 0;
this.pageTotal = 1;
this.orderList= [];
this.busy= false;
this.emptybox= 'hide';
this.getRefundData();
yoho.store.remove('refundOrder');
},
getRefundData() {
this.busy = true;
if (this.page >= this.pageTotal) {
return;
}
$.ajax({
url: '/me/return/getOrderList',
data: {
page: ++this.page,
limit: this.limit
}
}).then(result => {
if (result.data && result.data.list.length > 0) {
this.$set('orderList', this.orderList.concat(result.data.list));
this.pageTotal = result.data.total_page;
this.busy = false;
}
if (this.orderList.length === 0) {
this.emptybox = '';
}
}).fail(() => {
tip('网络错误');
});
},
cancelApply(id, type) {
let _this = this;
Modal.confirm('', '确认取消吗?', function() {
this.hide();
// type refundType 1为退货,2为换货
$.ajax({
url: '/me/return/' + (Number(type) === 2 ? 'exchange' : 'refund') + '/cancel-apply',
type: 'post',
data: {
id: id
}
}).then(result => {
if (result.code === 200) {
tip('取消成功');
setTimeout(() => {
_this.reload();
}, 1000);
} else {
tip(result.message);
}
}).fail(() => {
tip('操作失敗');
});
});
}
}
};
</script>
<style>
html,
body {
height: 100%;
}
@import "../../scss/me/_order.css";
</style>