Browse Source

fix orderList

course
刘嘉炜 3 years ago
parent
commit
b18cdc1706
  1. 301
      src/pages/order_list/order_list.vue

301
src/pages/order_list/order_list.vue

@ -1,20 +1,21 @@
<template>
<view class="order-list">
<view class="ol-header">
<view class="oh-cur-store" v-if="orderType == 3 || orderType == 4 || orderType == 1|| orderType == 10">
<view class="oh-cur-store" v-if="isStoreInfo">
<text>当前门店</text>
<picker mode="selector" :range="storeList" range-key="name" @change="storeChange">
<view class="ocs-store">
<view :class="curSelectedStore!=null?'active':''">{{curSelectedStore == null?'全部':(curSelectedStore.name || '-')}}</view>
<view :class="curSelectedStore != null ? 'active' : ''">{{ curSelectedStore == null ? '全部' : (curSelectedStore.name || '-')}}</view>
<image mode="aspectFit" src="/static/images/icon/arrow_b2.png"></image>
</view>
</picker>
</view>
<!-- 约玩tab -->
<view class="ol-select-type" v-if="orderType == 10">
<view
v-for="(oitem,oi) in selectOrderType"
:key="oi"
:class="oitem.type == selectedOrderType ?'als-active':''"
:class="oitem.type == selectedOrderType ? 'als-active' : ''"
@click="tabTypeChange(oitem)"
>{{oitem.name || '-'}}</view>
</view>
@ -23,15 +24,15 @@
<view class="oc-period" @click="showPeriodModal">
<text>
{{
!!periodInfo.start&&!!periodInfo.end ?
`${periodInfo.start.replace(/\-/g,'.')} - ${periodInfo.end.replace(/\-/g,'.')}`:
!!periodInfo.start && !!periodInfo.end ?
`${ periodInfo.start.replace(/\-/g,'.') } - ${ periodInfo.end.replace(/\-/g,'.') }`:
'请选择时间'
}}
</text>
<view></view>
</view>
<view class="oc-bot">
<view>成功交易{{orderInfo.success_count || 0}}退款{{orderInfo.refund_count || 0}}</view>
<view>成功交易{{ orderInfo.success_count || 0 }}退款{{ orderInfo.refund_count || 0 }}</view>
<view class="ob-btns">
<image mode="aspectFit" @click="toSearch" src="/static/images/icon/search.png"></image>
<image @click="showClassify" mode="aspectFit" src="/static/images/icon/filter.png"></image>
@ -58,7 +59,7 @@
<view
v-for="e in classifyArr"
:key="e.id"
:class="['ot-item',e.id.toString() === curTabID.toString()?'active':'']"
:class="['ot-item', e.id.toString() === curTabID.toString() ? 'active' : '' ]"
@click="tabChange(e.id)"
>{{e.name}}</view>
</view>
@ -100,26 +101,12 @@
import timing_order from '../../components/timing_order/timing_order.vue'
import organize_order from '../../components/organize_order/organize_order.vue'
import util from '../../utils/util';
import { servers } from '../../js/server';
import { API } from '../../js/api';
import { mapState } from 'vuex';
// tab
const resClassify = [ {id:'', name:'全部'}, {id:1, name:'待使用'}, {id:2, name:'已使用'}, {id:3, name:'已失效'}, {id:4, name:'已退款'}, ];
// tab
const memClassify = [
{id:'', name:'全部'}, {id:1, name:'使用中'}, {id:0, name:'已失效'},
]
// tab
const intClassify = [ {id:'', name:'全部'}, {id:1, name:'待发货'}, {id:2, name:'已发货'}, {id:3, name:'已完成'}, ]
// tab ///退 [/0/1/4]
const timClassify = [ {id:'', name:'全部'}, {id:0, name:'计费中'}, {id:1, name:'已完成'}, {id:4, name:'已退款'}, ]
// tab ///退 [/0/1/4]
const orgClassify = [ {id:'', name:'全部'}, {id:1, name:'已付款'}, {id:2, name:'已完成'}, {id:4, name:'已退款'}, ]
export default {
components: {
// 'reservation-order': order.reservation,
@ -130,27 +117,19 @@
'organize-order': organize_order,
},
computed:{
isStoreInfo(){
let { orderType } = this;
return orderType == 3 || orderType == 4 || orderType == 1|| orderType == 10
},
//
classifyArr(){
let { orderType } = this;
if(orderType == 3)return resClassify;
if(orderType == 4)return memClassify;
if(orderType == 5)return intClassify;
if(orderType == 1)return timClassify;
if(orderType == 10)return orgClassify;
return [];
return getClassifyList(+orderType);
},
//
titleName(){
let { orderType, appointOrderType } = this;
if(orderType == 3){
if(appointOrderType == 0)return '订场订单';
if(appointOrderType == 1)return '次卡订单';
return '预约订单';
}
if(orderType == 4)return '会员卡订单';
if(orderType == 5)return '积分商城订单';
if(orderType == 1)return '计时订单';
if(orderType == 10)return '约玩订单';
return '订单'
return getTitleName({ orderType: +orderType, appointOrderType, });
},
...mapState(['brandInfo']),
},
@ -167,7 +146,8 @@
start: '',
end: ''
},
orderType: 3, // 3->,4->,5->,1 , 10->
orderType: 0, // 3->,4->,5->,1 , 10->
storeList: [ //
{ id: '', name: '全部' }
@ -189,25 +169,17 @@
type:"Sub"
}
],
selectedOrderType: "Main",//
selectedOrderType: "Main", //
// 20210706 // , ->
appointOrderType: ''
}
},
onReachBottom(){
let { curTabID, periodInfo, orderType, curSelectedStore, page, appointOrderType } = this;
let _curSelectedStore = curSelectedStore || {};
let { page } = this;
this.getOrderList({
begin: periodInfo.start,
end: periodInfo.end,
status: curTabID,
stadium_id: _curSelectedStore.id || '',
page: ++page,
orderType: orderType,
order_type: appointOrderType,
})
},
onLoad(options){
let _type = options.order_type || '';
@ -215,68 +187,40 @@
//
if(options.order_type == 3&&options.type!=undefined)this.appointOrderType = options.type;
this.$nextTick(_=>{ uni.setNavigationBarTitle({ title: this.titleName }) });
this.periodInfo = this.getDefaultTimeLimit(_type);
this.getStoreList();
this.$nextTick(this.refreshList);
this.$nextTick(_=> uni.setNavigationBarTitle({ title: this.titleName }));
},
methods: {
//
// 3->,4->,5->,1->
getDefaultTimeLimit(type){
let _date = new Date();
let _sevenTimeStemp = 7*24*60*60*1000;
let _beforeSeven = _date.getTime() - _sevenTimeStemp;
let _afterSeven = _date.getTime() + _sevenTimeStemp;
let _obj = { start: '', end: '' };
if(type == 3 )_obj['start']=util.formatDate({}),_obj['end'] = util.formatDate({date: _afterSeven});
if(type == 4 || type == 1)_obj['start']=util.formatDate({date: _beforeSeven}),_obj['end'] = util.formatDate({});
console.log(_obj)
return _obj;
},
//
refreshList(){
let { curTabID, periodInfo, orderType, curSelectedStore, page, appointOrderType } = this;
let _curSelectedStore = curSelectedStore || {};
this.orderList = [];
this.page = 1;
this.getOrderList({
begin: periodInfo.start,
end: periodInfo.end,
status: curTabID,
stadium_id: _curSelectedStore.id,
orderType: orderType,
order_type: appointOrderType,
})
},
tabChange: util.debounce(function(ID){
if(this.curTabID === ID)return;
this.curTabID = ID;
this.hideClassify();
this.$nextTick(this.refreshList);
},300,300),
//type
tabTypeChange: util.debounce(function(item){
this.selectedOrderType = item.type
this.$nextTick(this.refreshList);
},300,true),
showClassify(){
this.isShowClassify = true;
},
hideClassify(){
this.isShowClassify = false;
},
// ----->
//
storeChange(e){
let { value } = e.detail;
let { storeList } = this;
this.curSelectedStore = storeList[value];
this.$nextTick(this.refreshList);
},
//
getStoreList(){
let { brandInfo } = this;
@ -292,16 +236,44 @@
this.storeList = [ ...this.storeList, ..._list ];
})
},
// ----->
//
// 3->,4->,5->,1->
getDefaultTimeLimit(type){
let _date = new Date();
let _sevenTimeStemp = 7*24*60*60*1000;
let _beforeSeven = _date.getTime() - _sevenTimeStemp;
let _afterSeven = _date.getTime() + _sevenTimeStemp;
let _obj = { start: '', end: '' };
if(type == 3 ){
_obj['start']=util.formatDate({});
_obj['end'] = util.formatDate({date: _afterSeven});
}
if(type == 4 || type == 1){
_obj['start']=util.formatDate({date: _beforeSeven});
_obj['end'] = util.formatDate({});
}
return _obj;
},
//type
tabTypeChange: util.debounce(function(item){
this.selectedOrderType = item.type
this.$nextTick(this.refreshList);
},300,true),
toSearch(){
let { orderType } = this;
util.routeTo(`/pages/order_search/order_search?type=${orderType}`,'nT');
},
showClassify(){
this.isShowClassify = true;
},
hideClassify(){
this.isShowClassify = false;
},
//
startTimeChange(res){
let { value } = res.detail;
this.tempTimer.start = value;
@ -310,7 +282,6 @@
let { value } = res.detail;
this.tempTimer.end = value;
},
confirmPeriod(){
let { start, end } = this.tempTimer;
@ -329,70 +300,128 @@
hidePeriodModal(){
this.isShowPeriod = false;
},
getApiUrl(type = this.orderType){
if(type == 3)return API.reservationOrder;
if(type == 4)return API.membershipOrder;
if(type == 5)return API.integralOrder;
if(type == 1)return API.timeOrder;
if(type == 10)return API.organizeOrderList;
// ----->
//
refreshList(){
this.orderList = [];
this.page = 1;
this.getOrderList({ })
},
//
getOrderList({
begin='',
end='',
//
// - 1 使 / 2 使 / 3 / 4 退
// - 1 '使' / 0 ''
// - 1 / 2 / 3 / 4
status='',
stadium_id='',
page=1,
page_size=15,
orderType = this.orderType,
order_type='', //:0,1; :/[1/2]
}){
let { brandInfo } = this;
let { orderType } = this;
util.showLoad();
let postData = {
begin,
end,
status,
brand_id: brandInfo.brand.id,
stadium_id,
page,
page_size,
order_type,
orderType
}
if(this.orderType == "10"){ //, 0430.0507()
postData['type'] = this.selectedOrderType;
postData['filter_start_time'] = begin;
postData['filter_end_time'] = end;
postData['pay_status'] = status;
}
servers.get({
url: this.getApiUrl(orderType),
data: postData,
data: { ...this.getQueryForList(), page, page_size },
failMsg: '加载失败!'
})
.then(res=>{
util.hideLoad();
let { list, ...orderInfo } = res;
this.orderInfo = orderInfo
let _list = list || [];
this.orderInfo = orderInfo || {};
if(page == 1)return this.orderList = _list;
if(_list.length<=0)return util.showNone('没有更多!');
this.page = page;
this.orderList = [ ...this.orderList, ..._list ];
})
.catch(util.hideLoad)
.catch(util.hideLoad);
},
//
getApiUrl(type = this.orderType){
if(type == 3)return API.reservationOrder;
if(type == 4)return API.membershipOrder;
if(type == 5)return API.integralOrder;
if(type == 1)return API.timeOrder;
if(type == 10)return API.organizeOrderList;
},
//
getQueryForList(){
// status(curTabID)
// - 1 使 / 2 使 / 3 / 4 退
// - 1 '使' / 0 ''
// - 1 / 2 / 3 / 4
let { brandInfo, curTabID, periodInfo, orderType, curSelectedStore, appointOrderType, selectedOrderType } = this;
let _curSelectedStore = curSelectedStore || {};
let _obj = {
begin: periodInfo.start || '',
end: periodInfo.end || '',
status: curTabID || '',
brand_id: brandInfo.brand.id,
stadium_id: _curSelectedStore.id || ''
};
// :0,1; :/[1/2]
if(orderType == 3)_obj['order_type'] = appointOrderType;
// , 0430.0507()
if(orderType == "10"){
postData['type'] = selectedOrderType;
postData['filter_start_time'] = periodInfo.start;
postData['filter_end_time'] = periodInfo.end;
postData['pay_status'] = curTabID;
};
return _obj
},
},
}
//
function getTitleName({
orderType,
appointOrderType,
}){
switch(orderType){
case 3:
if(appointOrderType == 0)return '订场订单';
if(appointOrderType == 1)return '次卡订单';
return '预约订单';
case 4:
return '会员卡订单';
case 5:
return '积分商城订单';
case 1:
return '计时订单';
case 10:
return '约玩订单';
default:
return '订单'
}
}
//
function getClassifyList(orderType){
switch(orderType){
case 3: // tab
return [ {id:'', name:'全部'}, {id:1, name:'待使用'}, {id:2, name:'已使用'}, {id:3, name:'已失效'}, {id:4, name:'已退款'}, ];
case 4: // tab
return [ {id:'', name:'全部'}, {id:1, name:'使用中'}, {id:0, name:'已失效'},];
case 5: // tab
return [ {id:'', name:'全部'}, {id:1, name:'待发货'}, {id:2, name:'已发货'}, {id:3, name:'已完成'}, ];
case 1: // tab ///退 [/0/1/4]
return [ {id:'', name:'全部'}, {id:0, name:'计费中'}, {id:1, name:'已完成'}, {id:4, name:'已退款'}, ];
case 10: // tab ///退 [/0/1/4]
return [ {id:'', name:'全部'}, {id:1, name:'已付款'}, {id:2, name:'已完成'}, {id:4, name:'已退款'}, ];
default:
return []
}
}
</script>

Loading…
Cancel
Save