You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

583 lines
16 KiB

<template>
<view>
<view class="wrap safe-area-inset-bottom" v-if="token">
<view class="u-tabs-box">
<u-tabs-swiper :height="76" :font-size="24" active-color="#c20d12" bg-color="transparent"
inactive-color="#999" ref="tabs" :list="tabs" :current="swiperCurrent" @change="change"
:is-scroll="true" :offset="[5, 5]" swiperWidth="750"></u-tabs-swiper>
</view>
<swiper class="swiper-box" :current="swiperCurrent" @animationfinish="animationfinish" >
<swiper-item class="swiper-item" v-for="(swiper, swiperIndex) in tabs" :key="swiperIndex">
<block v-if="swiper.type === 'refund'">
<view class="refund-sub-tabs">
<view v-for="(st, idx) in refundSubTabs" :key="'rs-' + idx"
:class="['refund-sub-tab', { active: refundSubTab === idx }]"
@click="changeRefundSubTab(idx)">
{{ st.name }}
</view>
</view>
<scroll-view scroll-y style="height: calc(100% - 72rpx); width: 100%" @scrolltolower="reachBottom">
<view>
<view class="order" v-for="row in list[swiperIndex]" :key="row.id">
<block v-if="row.order && row.order.id">
<view class="title">
<view class="title__name">
<u-tag size="mini" type="primary" mode="dark" shape="circleLeft"
:text="row.order.type === 1 ? '陪诊' : '陪护'"></u-tag>
<text style="padding-left: 10rpx;">{{ row.order.accompany_product ? row.order.accompany_product.name : '' }}</text>
</view>
<view class="title__status">{{ refundStatusText(row.status) }}</view>
</view>
<view class="price">
<view class="price-icon">
<image style="width:90rpx" mode="widthFix"
:src="row.order.accompany_product ? (row.order.accompany_product.cover ? row.order.accompany_product.cover.url : vuex_default_icon) : vuex_default_icon"></image>
</view>
<view class="price-text">
<view class="price-text__num">¥{{ row.order.price ? row.order.price : 0 }}</view>
<view class="price-text__no">订单号 {{ row.order.no }}</view>
<view class="price-text__no" v-if="row.apply_reason">退单理由:{{ row.apply_reason }}</view>
</view>
</view>
<view class="info" @click.stop.native="goOrderDetail(row.order)">
<view class="info__item flex100">
<text>被服务人</text>
<text>{{ row.order.user_archive ? row.order.user_archive.name : '' }}</text>
</view>
<view class="info__item flex100">
<text>{{ (row.order.type == 1 ? '就诊' : '服务') + '时间' }}</text>
<text>{{ row.order.time ? $moment(row.order.time).format('YYYY年MM月DD日 HH:mm') : '' }}</text>
</view>
<view class="info__item flex100" v-if="row.order.type==2">
<text>详细地址</text>
<text>{{ row.order.city || ' ' }}</text>
</view>
<view class="info__item flex100" v-if="row.order.type==1">
<text>就诊医院</text>
<text>{{ row.order.hospital ? row.order.hospital.name : '' }}</text>
</view>
</view>
<view class="bottom">
<view class="row1" style="justify-content: flex-end;">
<u-button ripple shape="circle" :custom-style="payBtnStyle"
:throttle-time="2000" @click="goOrderDetail(row.order)">查看订单</u-button>
</view>
</view>
</block>
</view>
<u-empty v-if="list[swiperIndex].length === 0 && loadStatus[swiperIndex] !== 'loading'" margin-top="120" text="暂无退款订单" mode="list"></u-empty>
<u-loadmore :status="loadStatus[swiperIndex]" bgColor="#f2f2f2"></u-loadmore>
</view>
</scroll-view>
</block>
<scroll-view v-else scroll-y style="height: 100%; width: 100%" @scrolltolower="reachBottom">
<view>
<view class="order" v-for="i in list[swiperIndex]" :key="i.id">
<view class="title">
<view class="title__name">
<u-tag size="mini" type="primary" mode="dark" shape="circleLeft"
:text="i.type === 1 ? '陪诊' : '陪护'"></u-tag>
<text style="padding-left: 10rpx;">{{i.accompany_product?i.accompany_product.name:''}}</text>
</view>
<view class="title__status">{{ orderListStatusLabel(i) }}</view>
</view>
<view class="price">
<view class="price-icon">
<image style="width:90rpx" mode="widthFix" :src="i.accompany_product?(i.accompany_product.cover?i.accompany_product.cover.url:vuex_default_icon):vuex_default_icon"></image>
</view>
<view class="price-text">
<view class="price-text__num">
¥{{ i.price ? i.price : 0 }}</view>
<view class="price-text__no">订单号 {{ i.no }}</view>
</view>
</view>
<view class="info" @click.stop.native="goOrderDetail(i)">
<view class="info__item flex100">
<text>{{i.type == 1 ? '被服务人' : '被服务人'}}</text>
<text>{{ i.user_archive ? i.user_archive.name : i.user_archive_id }}</text>
</view>
<view class="info__item flex100">
<text>{{(i.type == 1 ? '就诊' : '服务') + '时间'}}</text>
<text>{{ i.time ? $moment(i.time).format('YYYY年MM月DD日 HH:mm') : '' }}</text>
</view>
<view class="info__item flex100" v-if="i.type==2">
<text>详细地址</text>
<text>{{ i.city || " " }}</text>
</view>
<view class="info__item flex100" v-if="i.type==1">
<text>就诊医院</text>
<text>{{ i.hospital ? i.hospital.name : '' }}</text>
</view>
<view class="info__item flex100">
<text>下单时间: </text>
<text>{{ i.created_at ? $moment(i.created_at).format('YYYY年MM月DD日 HH:mm') : '' }}</text>
</view>
</view>
<view class="bottom">
<view class="row1" style="justify-content: flex-end;">
<u-button v-if="i.pay_status === 0" ripple shape="circle" :custom-style="editBtnStyle"
:throttle-time="2000" @click="$u.route({
url: '/package_sub/pages/AddOrder/editOrder',
params: {
order_id: i.id,
type: i.type,
site_id: i.hospital ? i.hospital.site_id : ''
}
})">修改信息</u-button>
<u-button style="margin-left:20rpx" ripple shape="circle" :custom-style="payBtnStyle"
:throttle-time="2000" @click="goOrderDetail(i)">{{ i.pay_status === 0 ? '立即支付' : '查看订单' }}</u-button>
</view>
</view>
</view>
<u-loadmore :status="loadStatus[swiperIndex]" bgColor="#f2f2f2"></u-loadmore>
</view>
</scroll-view>
</swiper-item>
</swiper>
</view>
<view v-if="!token">
<u-empty :margin-top="360" text="未登录" mode="order">
<u-button shape="circle" slot="bottom" type="primary" ripple @click="$u.route({
url: '/pages/login/login',
type: 'redirect'
})"></u-button>
</u-empty>
</view>
<Tabbar />
<floatPhone></floatPhone>
</view>
</template>
<script>
import Tabbar from "@/component/Tabbar/Tabbar.vue";
import { hasPendingRefund, refundOrderStatusText } from "@/common/refundApply.js";
export default {
components: {
Tabbar,
},
data() {
return {
editBtnStyle:{
"background-image": "linear-gradient(-90deg, #ddd 0%, #ccc 94%, #ccc 100%)",
"font-weight": "500",
"font-size": "28rpx",
color: "#fff",
width: "185rpx",
height: "60rpx",
"line-height": "60rpx",
},
payBtnStyle: {
"background-image": "linear-gradient(-90deg, #e26165 0%, #c10d12 94%, #c10d12 100%)",
"font-weight": "500",
"font-size": "28rpx",
color: "#fff",
width: "185rpx",
height: "60rpx",
"line-height": "60rpx",
},
tabs: [{
name: "全部",
value: "",
count: 0,
},
{
name: "待支付",
value: 0,
count: 0,
},
{
name: "已支付",
value: 1,
count: 0,
},
{
name: "服务中",
value: 2,
count: 0,
},
{
name: "已完成",
value: 3,
count: 0,
},
{
name: "退款订单",
value: "refund",
type: "refund",
count: 0,
},
],
refundSubTabs: [
{ status: 0, name: '退款审核中' },
{ status: 1, name: '已退款' },
{ status: 2, name: '已驳回' },
],
refundSubTab: 0,
swiperCurrent: 0,
tabsHeight: 0,
dx: 0,
scrollTop: [],
loadStatus: [],
refresherStatus: [],
select: {
page: 1,
pay_status: "",
page_size: 10,
},
refundSelect: {
page: 1,
page_size: 10,
refund_status: 0,
},
list: [],
};
},
onShow() {
if (this.token) {
this.getOrder(true);
}
},
created() {
for (let i = 0; i < this.tabs.length; i++) {
this.refresherStatus.push(false);
this.list.push([]);
this.loadStatus.push("loadmore");
}
},
computed: {
statusFormat() {
return function(status) {
return this.vuex_order_status.find(i => i.value === status)?.name
}
},
token() {
return this.vuex_token || uni.getStorageSync('lifeData')?.vuex_token
},
isRefundTab() {
const tab = this.tabs[this.swiperCurrent]
return !!(tab && tab.type === 'refund')
}
},
methods: {
refundStatusText(status) {
return refundOrderStatusText(status)
},
orderListStatusLabel(i) {
if (hasPendingRefund(i)) return '退款审核中'
if (i.refund_display_status === 'rejected') return '已驳回'
if (Number(i.pay_status) === 2 || i.refund_display_status === 'refunded') return '已退款'
return this.statusFormat(i.pay_status)
},
goOrderDetail(i) {
this.$u.route({
url: '/package_sub/pages/AddOrder/AddOrder',
params: {
order_id: i.id,
type: i.type,
site_id: i.hospital ? i.hospital.site_id : ''
}
})
},
reachBottom() {
this.getOrder()
},
change(index) {
this.swiperCurrent = index;
},
transition({
detail: {
dx
}
}) {
this.$refs.tabs.setDx(dx);
},
animationfinish({
detail: {
current
}
}) {
this.$refs.tabs.setFinishCurrent(current);
this.swiperCurrent = current;
const tab = this.tabs[this.swiperCurrent]
if (tab && tab.type === 'refund') {
const sub = this.refundSubTabs[this.refundSubTab]
this.refundSelect.refund_status = sub ? sub.status : 0
} else {
this.select.pay_status = tab ? tab.value : ''
}
this.getOrder(true)
},
changeRefundSubTab(idx) {
if (this.refundSubTab === idx) return
this.refundSubTab = idx
const sub = this.refundSubTabs[idx]
this.refundSelect.refund_status = sub ? sub.status : 0
this.getOrder(true)
},
async getOrder(isRefresh = false) {
if (this.isRefundTab) {
return this.getRefundOrders(isRefresh)
}
if (isRefresh) {
this.select.page = 1;
this.loadStatus[this.swiperCurrent] = 'loadmore'
}
if (this.loadStatus[this.swiperCurrent] === 'nomore') return
try {
this.loadStatus[this.swiperCurrent] = 'loading'
const res = await this.$u.api.accompanyOrders(this.select);
this.tabs[0].count = res.pay_status_count_0+res.pay_status_count_1+res.pay_status_count_2+res.pay_status_count_3;
this.tabs[1].count = res.pay_status_count_0;
this.tabs[2].count = res.pay_status_count_1;
this.tabs[3].count = res.pay_status_count_2;
this.tabs[4].count = res.pay_status_count_3;
if (isRefresh) {
this.list[this.swiperCurrent].length = 0;
}
this.list[this.swiperCurrent].push(...res.order.data)
if (this.list[this.swiperCurrent].length >= res.order.total) {
this.loadStatus[this.swiperCurrent] = 'nomore'
} else {
this.select.page++;
this.loadStatus[this.swiperCurrent] = 'loadmore'
}
} catch (err) {
console.error(err);
this.loadStatus[this.swiperCurrent] = 'loadmore'
}
},
async getRefundOrders(isRefresh = false) {
const idx = this.swiperCurrent
if (isRefresh) {
this.refundSelect.page = 1
this.loadStatus[idx] = 'loadmore'
}
if (this.loadStatus[idx] === 'nomore') return
try {
this.loadStatus[idx] = 'loading'
const sub = this.refundSubTabs[this.refundSubTab]
const res = await this.$u.api.accompanyRefundOrders({
page: this.refundSelect.page,
page_size: this.refundSelect.page_size,
refund_status: sub ? sub.status : 0,
})
if (isRefresh) {
this.list[idx].length = 0
}
const rows = res && res.data ? res.data : []
this.list[idx].push(...rows)
const total = res && res.total != null ? res.total : rows.length
if (this.list[idx].length >= total) {
this.loadStatus[idx] = 'nomore'
} else {
this.refundSelect.page++
this.loadStatus[idx] = 'loadmore'
}
} catch (err) {
console.error(err)
this.loadStatus[idx] = 'loadmore'
}
},
},
};
</script>
<style>
page {
height: 100%;
background-color: #eee;
}
</style>
<style lang="scss" scoped>
::v-deep .u-load-more-wrap {
padding: 20rpx 0;
}
::v-deep .u-load-more-wrap {
background-color: #eee !important;
.u-line-1 {
background-color: #eee !important;
}
}
.refund-sub-tabs {
display: flex;
align-items: center;
padding: 16rpx 25rpx 8rpx;
background: #eee;
}
.refund-sub-tab {
font-size: 24rpx;
color: #999;
padding: 12rpx 24rpx;
margin-right: 16rpx;
border-radius: 999rpx;
background: #fff;
&.active {
color: #c20d12;
background: rgba(194, 13, 18, 0.08);
}
}
.d-flex {
display: flex;
}
.ai-center {
align-items: center;
}
.jc-center {
justify-content: center;
}
.wrap {
display: flex;
flex-direction: column;
height: calc(100vh - var(--window-top) - calc(60px + 6px));
width: 100%;
}
.swiper-box {
flex: 1;
}
.swiper-item {
height: 100%;
}
.order {
margin: 0 25rpx;
border-radius: 10rpx;
filter: drop-shadow(0 0 10rpx rgba(211, 211, 214, 0.3));
background-color: #ffffff;
margin-top: 24rpx;
.title {
display: flex;
align-items: center;
padding: 37rpx 39rpx 32rpx 45rpx;
position: relative;
&__name {
font-size: 26rpx;
color: #333333;
font-weight: bold;
::v-deep .u-tag {
font-size: 26rpx;
}
}
&__status {
font-size: 26rpx;
color: #c20d12;
font-weight: 500;
margin-left: auto;
}
&::after {
content: "";
height: 2rpx;
background: #999999;
opacity: 0.302;
position: absolute;
bottom: 0;
left: 39rpx;
right: 39rpx;
}
}
.price {
display: flex;
align-items: center;
padding: 28rpx 0 0 44rpx;
&-icon {
display: flex;
justify-content: center;
align-items: center;
width: 90rpx;
height: 84rpx;
border-radius: 10rpx;
}
&-text {
padding-left: 28rpx;
&__num {
font-size: 30rpx;
color: #000000;
font-weight: bold;
}
&__no {
font-size: 24rpx;
color: #999999;
font-weight: 500;
padding-top: 14rpx;
}
}
}
.info {
display: flex;
flex-wrap: wrap;
padding: 35rpx 45rpx 0;
&__item {
flex-basis: 50%;
color: #333;
font-size: 26rpx;
font-weight: 500;
display: flex;
margin-bottom: 32rpx;
&>text {
display: block;
}
&>text:nth-child(1) {
color: #999;
padding-right: 20rpx;
flex: 0;
word-break: keep-all;
}
&>text:nth-child(2) {}
}
.flex100 {
flex-basis: 100%;
}
}
.bottom {
padding: 6rpx 28rpx 35rpx 43rpx;
.row1 {
display: flex;
align-items: center;
justify-content: space-between;
.time {
font-size: 24rpx;
color: #999999;
font-weight: 500;
}
}
}
}
</style>