wangfukang 1 month ago
parent
commit
06175e3687
  1. 50
      package2/shop/afterService.vue

50
package2/shop/afterService.vue

@ -62,11 +62,11 @@
查看订单 查看订单
</view> </view>
</view> </view>
<view class="btn" :class="{'btn-disabled': submitLoading}" @tap="returnAmountAllow(item,0)" style="background: rgba(0, 35, 28, 1);color: rgba(166, 255, 234, 1);"> <view class="btn" :class="{'btn-disabled': isSubmittingRefund(item)}" @tap="returnAmountAllow(item,0)" style="background: rgba(0, 35, 28, 1);color: rgba(166, 255, 234, 1);">
{{submitLoading ? '处理中' : '不同意'}} {{isSubmittingRefund(item) ? '处理中' : '不同意'}}
</view> </view>
<view class="btn" :class="{'btn-disabled': submitLoading}" @tap="returnAmountAllow(item,1)" style="margin-left: 10px;"> <view class="btn" :class="{'btn-disabled': isSubmittingRefund(item)}" @tap="returnAmountAllow(item,1)" style="margin-left: 10px;">
{{submitLoading ? '处理中' : '同意'}} {{isSubmittingRefund(item) ? '处理中' : '同意'}}
</view> </view>
</view> </view>
</view> </view>
@ -213,6 +213,7 @@
returnData:[], returnData:[],
returnCount:0, returnCount:0,
submitLoading:false, submitLoading:false,
submitRefundId:'',
contactItem:{} contactItem:{}
} }
}, },
@ -315,6 +316,26 @@
} }
return String(pictures).split(',').map(item => item.trim()).filter(item => item !== ''); return String(pictures).split(',').map(item => item.trim()).filter(item => item !== '');
}, },
isSubmittingRefund(item) {
return this.submitLoading && item && this.submitRefundId === item.id;
},
getRequestErrorMessage(error) {
if (typeof error === 'string' && error !== '') {
return error;
}
if (error && error.message) {
return error.message;
}
if (error && error.errMsg) {
return error.errMsg;
}
return '操作失败,请稍后再试';
},
resetSubmitState() {
this.submitLoading = false;
this.submitRefundId = '';
uni.hideLoading();
},
previewRefundImage(pictures, index) { previewRefundImage(pictures, index) {
const urls = this.getPictureList(pictures); const urls = this.getPictureList(pictures);
if (urls.length === 0) return; if (urls.length === 0) return;
@ -346,6 +367,7 @@
success: (res) => { success: (res) => {
if (res.confirm) { if (res.confirm) {
this.submitLoading = true; this.submitLoading = true;
this.submitRefundId = item.id;
uni.showLoading({ uni.showLoading({
title: '处理中', title: '处理中',
mask: true mask: true
@ -359,13 +381,17 @@
requestList.push(this.processReturn(item, status)); requestList.push(this.processReturn(item, status));
} }
Promise.all(requestList).then((messageList) => { Promise.all(requestList).then((messageList) => {
this.tui.toast(messageList[0] || '操作成功'); const successMessage = messageList[0] || '操作成功';
return this.getReturnCount(); return this.getReturnCount().then(() => {
this.resetSubmitState();
this.tui.toast(successMessage, 2000, true);
}).catch(() => {
this.resetSubmitState();
this.tui.toast(successMessage, 2000, true);
});
}).catch((message) => { }).catch((message) => {
this.tui.toast(message || '操作失败'); this.resetSubmitState();
}).then(() => { this.tui.toast(this.getRequestErrorMessage(message), 2000);
this.submitLoading = false;
uni.hideLoading();
}); });
} }
} }
@ -402,10 +428,10 @@
if (res.code == 200) { if (res.code == 200) {
return res.message; return res.message;
} else { } else {
return Promise.reject(res.message); return Promise.reject(res && res.message ? res.message : '操作失败,请稍后再试');
} }
}).catch((res) => { }).catch((res) => {
return Promise.reject(res && res.message ? res.message : res); return Promise.reject(this.getRequestErrorMessage(res));
}); });
}, },
back() { back() {

Loading…
Cancel
Save