order.vue
7.7 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<template>
<view class="order_container">
<!-- 订单头部 -->
<u-sticky>
<!-- 自定义头部 -->
<u-navbar
:title="orderType === 'mall' ? '商城订单' : '门店订单'"
leftIcon="list"
bgColor="#24262B"
:placeholder="true"
leftIconColor="#fff"
:titleStyle="{color: '#fff'}"
@leftClick="show = !show"
/>
<!-- 头部导航栏 -->
<view class="order_header">
<u-tabs
:list="orderType === 'mall' ? mallNavlist : bookingNavlist"
lineColor="#FFA100"
:activeStyle="{ color: '#fff' }"
:inactiveStyle="{ color: '#BBB' }"
@click="toggleOrder"
/>
<!-- 下拉选项 -->
<u-transition :show="show" :duration="300">
<view class="selectOrder">
<view class="select_item" :class="{active: orderType === 'mall'}" @click="orderType = 'mall'">
<text>商城订单</text>
</view>
<view class="select_item" :class="{active: orderType === 'booking'}" @click="orderType = 'booking'">
<text>球场订单</text>
</view>
<view class="select_item" v-for="(item, index) in employeeList" :key="index">
<u-icon :name="item.iconNane" size="20"></u-icon>
<text class="m-l-10">{{ item.title }}</text>
</view>
</view>
</u-transition>
</view>
</u-sticky>
<!-- 下拉选择订单类型列表 -->
<view class="px-30 my-30">
<uni-data-select
v-model="stateVlue"
placeholder="请选择订单的状态"
:localdata="stateList"
@change="getList"
/>
</view>
<!-- 订单列表 -->
<view v-if="stateList.length > 0" class="px-30 m-top20">
<BookingOrderCard
v-for="(item, index) in showList"
:key="index"
:orderList="item"
:number="index + 1"
:stateValue="formatState(item.state)"
@showRefund="(value) => showRefund = value"
>
<!-- 退款 -->
<template #refund>
<view class="m-top30 px-30" v-show="item.refundReason">
<text class="col-6 f-26 l-h-32">退款原因</text>
<view class="m-top30">
<u--textarea v-model="item.refundReason" disabled placeholder="请输入内容" ></u--textarea>
</view>
</view>
</template>
<!-- 评价 -->
<template #comment>
<view class="m-top30 px-30" v-show="item.commentContent">
<text class="col-6 f-26 l-h-32">评论内容</text>
<view class="m-top30">
<u--textarea v-model="item.commentContent" disabled placeholder="请输入内容" ></u--textarea>
</view>
</view>
</template>
</BookingOrderCard>
<view v-show="!showList.length > 0" >
<u-empty text="暂无订单" />
</view>
</view>
<!-- 遮罩层 -->
<u-overlay :show="show" zIndex="98" opacity="0" @click="show = false"></u-overlay>
<!-- 选择退款比例 -->
<u-modal
:show="showRefund"
:title="title" showCancelButton
@cancel="showRefund = false"
@close="showRefund = false"
@confirm="sendRefund"
>
<view class="slot-content">
<u-radio-group
v-model="radiovalue"
placement="row"
>
<u-radio
:customStyle="{marginBottom: '8px', marginRight: '10px'}"
v-for="(item, index) in radiolist"
:key="index"
:value="item.value"
:label="item.name"
:name="item.value"
>
</u-radio>
</u-radio-group>
</view>
</u-modal>
</view>
</template>
<script>
import BookingOrderCard from '@/components/order/bookingOrderCard.vue'
import { getOrderList, getAftersalesOrder, getCommentOrder, getOrderState, getRefundState, getCommentState, businessLookRefund } from '@/api/order.js'
import loadMore from '../../mixins/loadMore'
import { mapGetters } from 'vuex'
export default {
components: { BookingOrderCard },
mixins: [loadMore],
data() {
return {
show: false, // 是否显示遮罩层
title: '确定允许退款吗,请选择退款比例',
showRefund: false,
total: 0, //订单数量
name: '实时订单', //订单状态名
orderType: 'booking', // 订单类型 商家订单或者球场订单
stateVlue: null, //当前选择状态码
stateList: [], // 显示订单列表
orderState: [], // 订单类型数据
refundState: [], // 退货订单类型数据
commentState: [], // 评价订单类型数据
// 基本案列数据
radiolist: [{name: '退全款', value: 1}, {name: '退款50%', value: 2}],
// u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
radiovalue: 1,
// 商城导航列表
mallNavlist: [
{ name: '自提', badge: { value: 2 } },
{ name: '待配送', badge: { value: 2 } },
{ name: '退款', badge: { value: 2 } },
{ name: '已完成', badge: { isDot: true } },
],
// 球场导航列表
bookingNavlist: [
{ name: '实时订单', badge: { value: 0 } },
{ name: '退款售后', badge: { value: 0 } },
{ name: '订单评价', badge: { value: 0 } }
],
// 订单列表
showList: [], // 显示订单列表
// 商家订单功能列表
mallList: [
{title: '扫一扫', iconNane: 'scan'}
],
// 员工订单功能列表
employeeList: [
{title: '扫一扫', iconNane: 'scan'},
{title: '张三', iconNane: 'account'},
{title: '18172289999', iconNane: 'phone'},
{title: '退出登录', iconNane: 'share-square'}
]
}
},
computed: {
...mapGetters(['userInfo']),
formatState(){
return (stateNum) => {
let stateValue = ''
this.stateList.forEach(item => {
if(Number(item.value) === stateNum) {
stateValue = item.text
}
})
return stateValue
}
}
},
// async onLoad() {
// // 获取三种订单状态
// const [ orderState, refundState, commentState ] = await Promise.all([
// getOrderState(),
// getRefundState(),
// getCommentState()
// ])
// this.orderState = orderState
// this.refundState = refundState
// this.commentState = commentState
// this.stateList = this.getStatus(this.orderState)
// },
// 获取订单列表
// mounted() {
// this.getList()
// },
methods: {
// 选择订单类型
selectMode(){},
// 切换订单获取相应列表
toggleOrder(item){
this.name = item.name
this.getList()
},
// 显示列表
getList(){
let query = { ...this.query, businessId: this.userInfo.businessId, state: this.stateVlue }
if(this.name === '实时订单') {
this.getNewList(query)
this.stateList = this.getStatus(this.orderState)
} else if(this.name === '退款售后') {
this.getRefundList(query)
this.stateList = this.getStatus(this.refundState)
} else {
this.getCommentList(query)
this.stateList = this.getStatus(this.commentState)
}
uni.stopPullDownRefresh()
},
// 获取订单状态
getStatus(arr){
return arr.map(item => {
return {
value: item.dictValue,
text: item.dictLabel
}
})
},
// 获取实时订单列表
async getNewList(query) {
const { rows, total } = await getOrderList(query)
this.showList = rows
this.total = total
this.bookingNavlist[0].badge.value = total
},
// 获取退款订单列表
async getRefundList(query){
const { rows, total } = await getAftersalesOrder(query)
this.showList = rows
this.total = total
this.bookingNavlist[1].badge.value = total
},
// 获取订单评论列表
async getCommentList(query){
const { rows, total } = await getCommentOrder(query)
this.showList = rows
this.total = total
this.bookingNavlist[2].badge.value = total
},
// 发起退款
async sendRefund(){
await businessLookRefund(this.radiovalue)
uni.$u.toast('退款成功')
this.showRefund = false
}
}
}
</script>
<style lang="scss" scoped>
@import '@/static/css/order.scss'
</style>