push them all
This commit is contained in:
@@ -44,8 +44,8 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<view v-for="(record,index) in displayRecordList" :key="`${record.recordType}-${record.id || record.confirmationNo || index}`">
|
||||
<view class="hz-record-list">
|
||||
<view class="hz-record-item" v-for="(record,index) in displayRecordList" :key="(record.recordType || 'record') + '-' + (record.id || record.confirmationNo || index)">
|
||||
<view @click="openRecordDetail(record)" :class="getRecordCardClass(record)" class="hz-card-booking hz-record-card hz-pd-30 hz-font-bold hz-font-sm">
|
||||
<view class="hz-flex-row hz-booking-type-row">
|
||||
<view class="hz-booking-type-wrap">
|
||||
@@ -72,6 +72,9 @@
|
||||
<view class="hz-w-55">
|
||||
<view class="hz-font-md">{{$t("common.checkOutDate")}}: {{ record.checkoutDate }}</view>
|
||||
</view>
|
||||
<!-- <view class="hz-flex-row hz-sharer-wrap" v-if="canShowSharer(record)">
|
||||
<view v-if="hasSharer(record)" class="hz-btn-sharer hz-font-min hz-sharer-tag">{{$t("bookingRecord.sharer").toUpperCase()}}</view>
|
||||
</view> -->
|
||||
<view class="hz-flex-row hz-sharer-wrap" v-if="canShowSharer(record)">
|
||||
<view v-if="hasSharer(record)" class="hz-btn-sharer hz-font-min hz-sharer-tag">{{$t("bookingRecord.sharer").toUpperCase()}}</view>
|
||||
</view>
|
||||
@@ -204,11 +207,17 @@
|
||||
this.pullDownRefresh();
|
||||
},
|
||||
methods: {
|
||||
normalizeBookingList(res){
|
||||
if(Array.isArray(res)) return res;
|
||||
if(res && Array.isArray(res.data)) return res.data;
|
||||
if(res && res.data && Array.isArray(res.data.records)) return res.data.records;
|
||||
if(res && Array.isArray(res.records)) return res.records;
|
||||
return null;
|
||||
},
|
||||
updateHotelBookingList(res){
|
||||
if(Array.isArray(res) && res.length > 0){
|
||||
this.bookingList = res;
|
||||
}else{
|
||||
this.bookingList = [];
|
||||
const list = this.normalizeBookingList(res);
|
||||
if(list){
|
||||
this.bookingList = list;
|
||||
}
|
||||
},
|
||||
updateLimoBookingList(res) {
|
||||
@@ -246,39 +255,62 @@
|
||||
// 數據方法
|
||||
async getDataByPage(){
|
||||
if(this.userData.canViewBooking==false) return;
|
||||
const previousTask = this.currentTask;
|
||||
const previousRequest = this.currentTask;
|
||||
const requestId = ++this.getDataByPageRequestId;
|
||||
if(previousTask){
|
||||
try{
|
||||
previousTask.abort();
|
||||
}catch(err){
|
||||
}
|
||||
}
|
||||
|
||||
// 一次页面加载会同时发起 Hotel 和 Limo 请求,统一保存并取消它们。
|
||||
const requestTasks = [];
|
||||
let finishRequest;
|
||||
const requestFinished = new Promise(resolve => {
|
||||
finishRequest = resolve;
|
||||
});
|
||||
const requestController = {
|
||||
requestId,
|
||||
finished: requestFinished,
|
||||
isAborted: false,
|
||||
addTask: task => {
|
||||
if(!task || typeof task.abort !== 'function') return;
|
||||
if(requestController.isAborted || requestId !== this.getDataByPageRequestId){
|
||||
try{
|
||||
task.abort();
|
||||
}catch(err){
|
||||
}
|
||||
return;
|
||||
}
|
||||
requestTasks.push(task);
|
||||
},
|
||||
abort: () => {
|
||||
requestTasks.forEach(task => {
|
||||
if(task && typeof task.abort === 'function'){
|
||||
try{
|
||||
task.abort();
|
||||
}catch(err){
|
||||
}
|
||||
if(requestController.isAborted) return;
|
||||
requestController.isAborted = true;
|
||||
requestTasks.splice(0).forEach(task => {
|
||||
try{
|
||||
task.abort();
|
||||
}catch(err){
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
const requestConfig = {
|
||||
getTask: task => {
|
||||
if(requestId === this.getDataByPageRequestId){
|
||||
requestTasks.push(task);
|
||||
}else if(task && typeof task.abort === 'function'){
|
||||
task.abort();
|
||||
}
|
||||
}
|
||||
},
|
||||
finish: () => finishRequest()
|
||||
};
|
||||
this.currentTask = requestController;
|
||||
|
||||
if(previousRequest && typeof previousRequest.abort === 'function'){
|
||||
previousRequest.abort();
|
||||
// 等旧请求的 abort 回调先完成,避免 App 端取消动作影响紧接着的新请求。
|
||||
if(previousRequest.finished){
|
||||
await Promise.race([
|
||||
previousRequest.finished,
|
||||
new Promise(resolve => setTimeout(resolve, 50))
|
||||
]);
|
||||
}else{
|
||||
await new Promise(resolve => setTimeout(resolve, 0));
|
||||
}
|
||||
}
|
||||
if(requestId !== this.getDataByPageRequestId){
|
||||
requestController.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
const requestConfig = {
|
||||
getTask: task => requestController.addTask(task)
|
||||
};
|
||||
let params = {};
|
||||
uni.showLoading({
|
||||
title: this.$t("common.loading")
|
||||
@@ -314,6 +346,7 @@
|
||||
uni.$u.toast(e.errMsg,5000);
|
||||
await this.writeLog(this.userData.userId,"save_booking","","[APP][bookingDetail.vue][getDataByPage][Catch Exception]"+e.errMsg,"[RequestData]" +JSON.stringify(params),"",1,false);
|
||||
}finally{
|
||||
requestController.finish();
|
||||
if(requestId === this.getDataByPageRequestId){
|
||||
if(this.currentTask === requestController){
|
||||
this.currentTask = null;
|
||||
@@ -382,10 +415,14 @@
|
||||
return bookingType+': Limo';
|
||||
},
|
||||
getRecordStatusText(record){
|
||||
if(this.isHotelRecord(record)){
|
||||
return this.getStatusText(record);
|
||||
}else{
|
||||
return record.status.replace("_"," ");
|
||||
try{
|
||||
if(this.isHotelRecord(record)){
|
||||
return this.getStatusText(record);
|
||||
}
|
||||
if(record.status == null) return '';
|
||||
return String(record.status).replace("_"," ");
|
||||
}catch(e){
|
||||
return '';
|
||||
}
|
||||
},
|
||||
getRecordStatusClass(record){
|
||||
@@ -478,8 +515,8 @@
|
||||
userId: this.userData.userId
|
||||
};
|
||||
const [resHotel, resLimo] = await Promise.all([
|
||||
getBookings(bookingParams, requestConfig),
|
||||
getLimoBookings(bookingParams, requestConfig)
|
||||
getBookings(bookingParams, requestConfig).catch(() => null),
|
||||
getLimoBookings(bookingParams, requestConfig).catch(() => null)
|
||||
]);
|
||||
if(requestId !== this.getDataByPageRequestId) return;
|
||||
this.updateHotelBookingList(resHotel);
|
||||
@@ -924,4 +961,36 @@
|
||||
.hz-book-btn-wrap--single {
|
||||
width: 95%;
|
||||
}
|
||||
.hz-page {
|
||||
overflow-x: hidden;
|
||||
}
|
||||
.hz-record-list,
|
||||
.hz-record-item,
|
||||
.hz-record-card {
|
||||
box-sizing: border-box;
|
||||
max-width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
.hz-record-card {
|
||||
align-items: stretch;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
}
|
||||
.hz-record-card ::v-deep .hz-flex-row,
|
||||
.hz-record-card ::v-deep .hz-w-50,
|
||||
.hz-record-card ::v-deep .hz-w-55,
|
||||
.hz-record-card ::v-deep .hz-w-100,
|
||||
.hz-record-card ::v-deep .hz-booking-type-wrap,
|
||||
.hz-record-card ::v-deep .hz-font-md {
|
||||
box-sizing: border-box;
|
||||
max-width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
.hz-record-card ::v-deep .hz-w-55 {
|
||||
flex: 1;
|
||||
width: auto;
|
||||
}
|
||||
.hz-record-card ::v-deep .hz-font-md {
|
||||
word-break: break-word;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user