dingdong-mall/pages/my/my-order.vue

321 lines
12 KiB
Vue
Raw Normal View History

2022-04-23 23:13:29 +08:00
<template>
<view>
<!-- 顶部操作条 -->
<cu-custom :bgColor="'bg-main-color'" :isBack="true">
<block slot="backText">返回</block>
<block slot="content">我的订单</block>
2023-03-18 23:58:52 +08:00
</cu-custom>
<view class="padding-tb bg-white solid-bottom">
<view class="flex justify-between align-center margin-top-xs padding-left">
<input class="line-input radius-input margin-right-sm" v-model="formData.orderKeywords"
placeholder="请输入订单号或标题或关键词"></input>
<view class="text-xl text-bold">
<text class="cuIcon-search margin-right-sm" @click="searchOrderPage"></text>
</view>
</view>
</view>
2022-04-23 23:13:29 +08:00
<!-- tab -->
<view class="sticky-bar" :style="[{top: stickyTop + 'px'}]">
<scroll-view scroll-x class="bg-white nav text-center" :scroll-with-animation="true"
:scroll-left="scrollLeft">
<view class="cu-item" :class="index==tabCur?'text-main-color cur':''"
v-for="(item,index) in tabHeaderList" :key="index" @tap="tabSelect" :data-id="index">
{{item.name}}
</view>
</scroll-view>
</view>
<!-- tab content -->
<view class="margin-lr-sm margin-bottom-xl">
<view class="margin-top-sm padding-bottom-sm bg-white" v-for="(shopOrder, index) in myOrders">
<view class="cu-bar solid-bottom">
<view class="action bar-first-action">
<text class="cuIcon-shopfill text-main-color"></text>
2022-06-08 13:59:47 +08:00
{{shopOrder.workerName}}
2022-04-23 23:13:29 +08:00
<view>
<view class="cuIcon-right"></view>
</view>
</view>
2022-10-15 01:43:07 +08:00
<view class='cu-tag line-main-color radius margin-right-sm' v-if="shopOrder.payType == 0">在线支付单</view>
<view class='cu-tag line-main-color radius margin-right-sm' v-else-if="shopOrder.payType == 1">上门到付单</view>
2022-04-23 23:13:29 +08:00
</view>
<view class="padding-lr">
2022-06-20 18:07:35 +08:00
<view class="margin-top-sm" @click="showServDetail(shopOrder)">
2022-06-13 16:14:21 +08:00
<product-picked :product="shopOrder" :pickedList="shopOrder.standardList"></product-picked>
2022-04-23 23:13:29 +08:00
</view>
<view class="flex justify-end align-end padding-bottom-xs" @click="showServDetail(shopOrder)">
2022-06-08 13:59:47 +08:00
<view class="margin-right-sm"><text>总价</text><text class="text-price text-red">{{shopOrder.totalMoney}}</text>
2022-04-23 23:13:29 +08:00
</view>
2022-06-08 13:59:47 +08:00
<view class="margin-right-sm"><text>优惠</text><text class="text-price text-red">{{shopOrder.discountMoney}}</text>
</view>
<view class="margin-right-sm" v-if="shopOrder.payStatus == 1 && shopOrder.changeMoney"><text>已付款</text><text class="text-price text-red">{{shopOrder.payMoney}}</text>
</view>
<view class="text-lg" v-if="shopOrder.payStatus == 1 && shopOrder.changeMoney"><text>需付款</text><text
class="text-price text-red text-lg text-bold">{{shopOrder.changeMoney}}</text></view>
<view class="text-lg" v-else-if="shopOrder.payStatus == 1"><text>实付款</text><text
class="text-price text-red text-lg text-bold">{{shopOrder.payMoney}}</text></view>
<view class="text-lg" v-else-if="shopOrder.payStatus == 0"><text>需付款</text><text
class="text-price text-red text-lg text-bold">{{Math.round((shopOrder.payMoney + shopOrder.changeMoney) * 100) / 100}}</text></view>
</view>
<view class="padding-bottom-sm flex justify-end align-end text-red text-lg" v-if="shopOrder.payStatus == 1 && shopOrder.changeMoney">您有报价/加价申请待付款中......</view>
2022-06-08 18:04:55 +08:00
<view v-if="orderType === 0" class="padding-tb-sm">
<view class="flex justify-end">
2022-10-15 01:43:07 +08:00
<button v-if="[0,1].indexOf(shopOrder.orderStatus) >= 0" class="cu-btn bg-gray margin-right-sm shadow-blur" @click="showModalByRef('confirmModal', shopOrder)">取消订单</button>
<button v-if="shopOrder.payStatus != 1 || shopOrder.changeMoney" class="cu-btn bg-main-color shadow-blur margin-right-sm" @click="wxpay(shopOrder)">付款</button>
<button class="cu-btn bg-main-color shadow-blur" @click="showServDetail(shopOrder)">查看</button>
</view>
2022-04-23 23:13:29 +08:00
</view>
2022-06-22 22:37:32 +08:00
<view v-if="orderType === 0 && shopOrder.orderStatus === 4"
2022-04-23 23:13:29 +08:00
class="padding-tb-sm solid-top">
<view>师傅已提交完成请验收</view>
2022-06-21 21:42:29 +08:00
<!-- <view>服务保障权益期</view> -->
2022-04-23 23:13:29 +08:00
<view class="flex justify-between align-end">
2022-06-21 21:42:29 +08:00
<!-- <view>{{shopOrder.finishOrder.finishWaitUntil}}</view> -->
2022-04-23 23:13:29 +08:00
<view>
2022-06-21 21:42:29 +08:00
<button class="cu-btn sm bg-yellow margin-right-sm"
2022-06-22 22:37:32 +08:00
@click="updateFinisheStatus(shopOrder, 5, false)">确认完单</button>
2022-09-26 02:31:29 +08:00
<button class="cu-btn sm bg-yellow margin-right-sm" @click="showModalByRef('applyAfterService', shopOrder, {afterServiceType: 2, toUpdateStatus: true})">拒绝完单</button>
2022-04-23 23:13:29 +08:00
</view>
</view>
</view>
<view
v-if="orderType === 0"
2022-04-23 23:13:29 +08:00
class="padding-tb-sm solid-top">
<view>约定服务时间</view>
<view class="flex justify-between align-end">
2022-10-27 00:45:08 +08:00
<view v-if="shopOrder.expectTimeEndFront">{{shopOrder.expectTimeStartFront + '~' + shopOrder.expectTimeEndFront}}</view>
<view v-else>{{shopOrder.expectTimeStartFront}}</view>
2022-04-23 23:13:29 +08:00
<view>
<button v-if="shopOrder.agreedServTime.customerAgreeStatus === 1"
class="cu-btn sm bg-yellow margin-right-sm"
@click="updateAgreeStatus(2, index)">同意</button>
<button v-if="shopOrder.agreedServTime.customerAgreeStatus === 1"
class="cu-btn sm bg-yellow margin-right-sm"
@click="updateAgreeStatus(-1, index)">不同意</button>
<button v-if="shopOrder.agreedServTime.customerAgreeStatus === 2"
class="cu-btn sm bg-yellow margin-right-sm" disabled type="">已同意</button>
<button v-if="shopOrder.agreedServTime.customerAgreeStatus === -1"
class="cu-btn sm bg-yellow margin-right-sm" disabled type="">已否决</button>
</view>
</view>
</view>
2022-06-06 22:09:43 +08:00
<view v-else-if="orderType === 0 && shopOrder.subProcessStatus === 1"
2022-04-23 23:13:29 +08:00
class="padding-tb-sm solid-top text-orange">
路途遥远服务内容稍难时间紧迫您可以试试追加赏金重金之下必有勇夫噢
</view>
</view>
</view>
2022-05-26 20:24:33 +08:00
</view>
2022-06-17 16:44:35 +08:00
<load-status-bar ref="loadStatusBar" @loadMore="loadOrderPage"></load-status-bar>
2022-09-26 02:31:29 +08:00
<confirm-modal ref="confirmModal" :content="'是否确定取消订单?'" @confirm="cancelOrder" @cancel="blurCurOrder"></confirm-modal>
<apply-after-service ref="applyAfterService" :data="curOrder" @confirmFeedback="reloadOrderPage" @cancel="blurCurOrder"></apply-after-service>
2022-04-23 23:13:29 +08:00
</view>
</template>
<script>
2022-06-08 13:59:47 +08:00
import productPicked from '@/pages/my/components/product-picked.vue';
2022-09-26 02:31:29 +08:00
import loadStatusBar from '@/components/custom-bar/load-status-bar.vue';
import applyAfterService from '@/pages/my/components/modal/apply-after-service.vue';
2022-04-23 23:13:29 +08:00
export default {
components: {
2022-05-26 20:24:33 +08:00
productPicked,
2022-09-26 02:31:29 +08:00
loadStatusBar,
applyAfterService
2022-04-23 23:13:29 +08:00
},
data() {
2022-06-22 22:37:32 +08:00
return {
curUserInfo: {},
2022-04-23 23:13:29 +08:00
scrollLeft: 0,
tabCur: 0,
tabHeaderList: [],
orderType: '',
2022-05-26 20:24:33 +08:00
myOrders: [],
pageParams: [],
2022-06-08 18:04:55 +08:00
stickyTop: this.CustomBar,
curOrder: null
2022-04-23 23:13:29 +08:00
}
},
onLoad(options) {
if (Boolean(options) && Boolean(options.tabInfo)) {
let tabInfo = JSON.parse(decodeURIComponent(options.tabInfo));
if (tabInfo.tabCur != null || tabInfo.tabCur != undefined) {
this.tabCur = tabInfo.tabCur;
}
if (tabInfo.tabCur != null || tabInfo.tabCur != undefined) {
this.orderType = tabInfo.orderType;
}
if (Array.isArray(tabInfo.tabHeaderList) && tabInfo.tabHeaderList.length > 0) {
2022-05-26 20:24:33 +08:00
this.tabHeaderList = tabInfo.tabHeaderList;
2022-06-08 13:59:47 +08:00
this.loadData();
2022-05-26 20:24:33 +08:00
}
2022-04-23 23:13:29 +08:00
}
},
methods: {
2022-06-08 13:59:47 +08:00
loadData() {
2022-06-22 22:37:32 +08:00
this.curUserInfo = this.$request.getCurUserInfo();
2022-05-26 20:24:33 +08:00
for(let i = 0; i < this.tabHeaderList.length; i++) {
this.pageParams.push({
2022-07-09 18:41:14 +08:00
pageNum: this.$globalData.initPageNum
2022-05-26 20:24:33 +08:00
});
}
2022-04-23 23:13:29 +08:00
// 真实对接口的时候使用
// this.myOrders = await this.$api.data(this.orderType, mainProcess);
2022-05-26 20:24:33 +08:00
// this.myOrders = await this.$api.data(mainProcess);
2022-06-08 13:59:47 +08:00
this.loadOrderPage();
2022-05-26 20:24:33 +08:00
},
2023-03-18 23:58:52 +08:00
searchOrderPage(keyWords) {
this.reloadOrderPage({
keyWords: keyWords
})
},
2022-06-02 17:39:14 +08:00
reloadOrderPage(params = {}) {
this.pageParams = [];
for(let i = 0; i < this.tabHeaderList.length; i++) {
this.pageParams.push({
2022-07-09 18:41:14 +08:00
pageNum: this.$globalData.initPageNum
2022-06-02 17:39:14 +08:00
});
}
this.myOrders = [];
this.$refs.loadStatusBar.showLoadMore();
this.loadOrderPage(params);
},
2022-06-08 13:59:47 +08:00
async loadOrderPage(params = {}) {
2022-05-26 20:24:33 +08:00
params.pageNum = this.pageParams[this.tabCur].pageNum;
2022-06-02 17:39:14 +08:00
params.pageSize = this.$globalData.initPageSize;
2022-05-26 20:24:33 +08:00
this.$refs.loadStatusBar.showLoading();
try {
2022-06-22 22:37:32 +08:00
params.customerId = this.curUserInfo.customerId;
2022-06-08 13:59:47 +08:00
params.orderType = this.orderType;
let orderStatus = this.tabHeaderList[this.tabCur].type;
if (typeof orderStatus == 'string' && orderStatus.indexOf(",") > 0) {
params.orderStatuses = orderStatus;
} else {
params.orderStatus = orderStatus;
}
2022-06-08 13:59:47 +08:00
if (this.tabCur === 0) {
params.payStatusList = "0,4";
2022-07-07 15:36:21 +08:00
params.exceptOrderStatus = 6;
2022-06-08 13:59:47 +08:00
}
2022-09-26 02:31:29 +08:00
let res = null;
if (this.tabCur === 3) {
res = await this.$request.getAfterList({
customerId: params.customerId
});
2022-09-26 02:31:29 +08:00
} else {
res = await this.$request.qryOrderPage(params);
}
2022-05-26 20:24:33 +08:00
let rowsLength = res.rows.length;
if (rowsLength > 0) {
this.myOrders = this.myOrders.concat(res.rows);
this.pageParams[this.tabCur].pageNum++;
if (rowsLength === this.pageSize) {
this.$refs.loadStatusBar.showLoadMore();
}
}
this.$refs.loadStatusBar.showLoadOver();
} catch (e) {
console.error(e)
this.$refs.loadStatusBar.showLoadErr();
}
2022-04-23 23:13:29 +08:00
},
tabSelect(e) {
this.tabCur = e.currentTarget.dataset.id;
2022-06-08 13:59:47 +08:00
this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60;
this.reloadOrderPage();
2022-04-23 23:13:29 +08:00
},
updateAgreeStatus(status, index) {
this.myOrders[index].agreedServTime.customerAgreeStatus = status;
},
2022-06-21 21:42:29 +08:00
async updateFinisheStatus(order, status, ifRollback) {
let res = await this.$request.updateOrder({
id: order.orderMasterId,
orderStatus: status
});
if (res && res.code === 0) {
this.reloadOrderPage();
if (ifRollback) {
uni.showToast({
title: '订单已回滚至服务中状态,请联系师傅',
icon: 'none',
duration: 3000
2022-06-21 21:42:29 +08:00
})
}
2022-09-26 02:31:29 +08:00
}
return res;
2022-04-23 23:13:29 +08:00
},
2022-06-18 02:03:35 +08:00
showServDetail(order) {
2022-04-23 23:13:29 +08:00
uni.navigateTo({
2022-06-18 02:03:35 +08:00
url: '/pages/my/serv-detail?order=' + encodeURIComponent(JSON.stringify(order))
2022-04-23 23:13:29 +08:00
})
2022-06-06 22:09:43 +08:00
},
2022-09-26 02:31:29 +08:00
showModalByRef(refName, curOrder, params) {
this.$refs[refName].showModal(curOrder, params);
2022-06-08 18:04:55 +08:00
this.curOrder = curOrder;
2022-06-06 22:09:43 +08:00
},
2022-06-08 18:04:55 +08:00
blurCurOrder() {
this.curOrder = null;
},
async cancelOrder() {
let res = await this.$request.cancelMasterOrder({
orderMasterId: this.curOrder.orderMasterId
2022-06-08 18:04:55 +08:00
});
if (res && res.code === 0) {
this.reloadOrderPage();
2022-06-08 18:04:55 +08:00
uni.showToast({
title: '取消成功',
icon: 'success',
duration: 2000
})
} else {
uni.showToast({
title: '取消失败',
icon: 'error'
2022-06-08 18:04:55 +08:00
})
}
},
async wxpay(curOrder) {
try {
// 获取微信支付所需参数
let wxPayParams = {
code: this.$request.getCurUserInfo().openId,
orderMasterCode: curOrder.orderMasterCode
}
let wxPayParamRes = await this.$request.getWxPayParams(wxPayParams);
// 拉起微信支付窗口,支付成功跳转到支付成功页面
let payInfo = JSON.parse(wxPayParamRes.data.expend.pay_info);
let wxPayRes = await wx.requestPayment(payInfo);
if (wxPayRes.errMsg === "requestPayment:ok") {
uni.navigateTo({
url: '/pages/order/pay-result?payResult=0'
})
} else {
throw 'err';
}
} catch(e) {
// 支付失败弹出提示并跳转到我的订单待支付页
uni.navigateTo({
url: '/pages/order/pay-result?payResult=1'
})
}
2022-04-23 23:13:29 +08:00
}
}
}
</script>
<style scoped>
.bar-first-action {
margin-left: unset !important;
padding-left: 40rpx;
font-size: 30rpx !important;
}
.cu-btn.sm {
padding: 0 20rpx;
font-size: 23rpx;
height: 48rpx;
}
</style>