diff --git a/common/config.js b/common/config.js index 0261395..b96365a 100644 --- a/common/config.js +++ b/common/config.js @@ -1,6 +1,6 @@ const mode = 'devLocal'; //devLocal:本地测试、devOnline:线上测试、production:生产环境 -let ROOTPATH = "https://yikangyang.ali251.langye.net"; //域名 -// let ROOTPATH = "https://yikangyang-test.ali251.langye.net"; //域名 +// let ROOTPATH = "https://yikangyang.ali251.langye.net"; //域名 +let ROOTPATH = "https://yikangyang-test.ali251.langye.net"; //域名 switch (mode) { case 'devLocal': diff --git a/common/http.api.js b/common/http.api.js index bf85f84..9c9b734 100644 --- a/common/http.api.js +++ b/common/http.api.js @@ -16,6 +16,7 @@ let apiApp = { accompanyProductOrder: '/api/mobile/hospital/accompany-order', accompanyPay: '/api/mobile/hospital/accompany-pay', orderRefund: '/api/mobile/user/accompany-order-refund', + accompanyRefundOrders: '/api/mobile/user/accompany-refund-orders', // 服务对象 userArchive: '/api/mobile/user-archive/index', userArchiveShow: '/api/mobile/user-archive/show', @@ -81,6 +82,7 @@ const install = (Vue, vm) => { const accompanyProductOrder = (params = {}) => vm.$u.post(apiApp.accompanyProductOrder, params) const accompanyPay = (params = {}) => vm.$u.post(apiApp.accompanyPay, params) const orderRefund = (params = {}) => vm.$u.get(apiApp.orderRefund, params) + const accompanyRefundOrders = (params = {}) => vm.$u.get(apiApp.accompanyRefundOrders, params) // 服务对象 const userArchive = (params = {}) => vm.$u.get(apiApp.userArchive, params) const userArchiveShow = (params = {}) => vm.$u.get(apiApp.userArchiveShow, params) @@ -136,7 +138,7 @@ const install = (Vue, vm) => { //用户订单 accompanyOrders,accompanyOrdersDetail, // 医院 陪护下单 - listHospital,detailHospital,accompanyProduct,accompanyProductDetail,accompanyProductOrder,accompanyPay,orderRefund, + listHospital,detailHospital,accompanyProduct,accompanyProductDetail,accompanyProductOrder,accompanyPay,orderRefund,accompanyRefundOrders, // 服务对象 userArchive,userArchiveShow,userArchiveSave,userArchiveDestroy, // other diff --git a/common/refundApply.js b/common/refundApply.js new file mode 100644 index 0000000..a01bc96 --- /dev/null +++ b/common/refundApply.js @@ -0,0 +1,49 @@ +/** + * 申请退单:弹窗收集必填理由 + * @returns {Promise} + */ +export function promptRefundReason() { + return new Promise((resolve) => { + uni.showModal({ + title: '申请退单', + content: '', + editable: true, + placeholderText: '请填写退单理由(必填)', + confirmText: '下一步', + cancelText: '取消', + success: (r) => { + if (!r.confirm) { + resolve(null) + return + } + const reason = String(r.content || '').trim() + if (!reason) { + uni.showToast({ title: '请填写退单理由', icon: 'none' }) + resolve(null) + return + } + resolve(reason) + }, + fail: () => resolve(null) + }) + }) +} + +export function hasPendingRefund(item) { + if (!item) return false + if (item.has_pending_refund === true || item.has_pending_refund === 1 || item.has_pending_refund === '1') { + return true + } + if (item.refund_display_status === 'pending') return true + const pending = item.pending_accompany_order_refund || item.pendingAccompanyOrderRefund + if (pending && pending.id) return true + return false +} + +export function refundOrderStatusText(refundStatus) { + const n = Number(refundStatus) + if (n === 0) return '退款审核中' + if (n === 1) return '已退款' + if (n === 2) return '已驳回' + return '—' +} diff --git a/package_sub/pages/AddOrder/AddOrder.vue b/package_sub/pages/AddOrder/AddOrder.vue index 28ec7a8..a39ea22 100644 --- a/package_sub/pages/AddOrder/AddOrder.vue +++ b/package_sub/pages/AddOrder/AddOrder.vue @@ -425,7 +425,8 @@ @click="pay" >立即{{ form.pay_status === 0 && !orderId ? '下单' : '支付' }} - 更多 + 退单 + {{ refundPendingTip }} ({ url: i.url @@ -1127,7 +1131,11 @@ export default { title: "支付成功", icon: "none", }); - await this.getDetail(); + setTimeout(() => { + uni.switchTab({ + url: "/pages/order/order", + }); + }, 800); } } catch (err) { uni.showToast({ @@ -1151,33 +1159,74 @@ export default { }) break; case 'chargeback': - fn = () => this.$u.api.orderRefund({ - id: this.orderId - }).then(_ => { - this.getDetail().then(_ => { - if (this.form.status) { - uni.showModal({ - title: "已成功提交退款申请", - content: "当前订单已分配护工,需等待客服处理", - showCancel: false - }) - } + fn = async () => { + const reason = await promptRefundReason() + if (!reason) return + const res = await this.$u.api.orderRefund({ + id: this.orderId, + reason }) - }) + if (res === false) return + this.$set(this.form, 'has_pending_refund', true) + this.$set(this.form, 'refund_display_status', 'pending') + await this.getDetail() + if (this.form.status) { + uni.showModal({ + title: "已成功提交退单申请", + content: "当前订单已分配护工,需等待客服处理", + showCancel: false + }) + } else { + uni.showModal({ + title: "已提交退单申请", + showCancel: false + }) + } + } break; } uni.showModal({ title: "操作", content: `是否确认${name}?`, - success: (status) => { + success: async (status) => { if (status.confirm) { - fn() - } else { + await fn() } }, fail: () => { }, }) + }, + async applyChargeback() { + const reason = await promptRefundReason() + if (!reason) return + uni.showModal({ + title: '确认退单', + content: '提交后将等待审核,通过后原路退款', + success: async (r) => { + if (!r.confirm) return + const res = await this.$u.api.orderRefund({ + id: this.orderId, + reason + }) + if (res === false) return + this.$set(this.form, 'has_pending_refund', true) + this.$set(this.form, 'refund_display_status', 'pending') + await this.getDetail() + if (this.form.status) { + uni.showModal({ + title: "已成功提交退单申请", + content: "当前订单已分配护工,需等待客服处理", + showCancel: false + }) + } else { + uni.showModal({ + title: "已提交退单申请", + showCancel: false + }) + } + } + }) } }, computed: { @@ -1262,6 +1311,24 @@ export default { tag: 'chargeback' }] } + }, + canApplyChargeback() { + if (!this.orderId) return false + if (Number(this.form.pay_status) !== 1) return false + if (Number(this.form.status) === 4) return false + if (Number(this.form.pay_status) === 2) return false + if (hasPendingRefund(this.form)) return false + if (this.form.refund_display_status === 'refunded') return false + return true + }, + refundPendingTip() { + if (!this.orderId || Number(this.form.pay_status) !== 1) return '' + if (hasPendingRefund(this.form) || this.form.refund_display_status === 'pending') { + return '退款审核中' + } + if (this.form.refund_display_status === 'rejected') return '退单已驳回' + if (Number(this.form.pay_status) === 2 || this.form.refund_display_status === 'refunded') return '已退款' + return '' } }, }; @@ -1795,6 +1862,10 @@ export default { font-size: 26rpx; color: #666; padding-right: 20rpx; + + &--disabled { + color: #c20d12; + } } } diff --git a/pages/order/order.vue b/pages/order/order.vue index c4c0643..f674415 100644 --- a/pages/order/order.vue +++ b/pages/order/order.vue @@ -4,13 +4,73 @@ - - + :is-scroll="true" :offset="[5, 5]" swiperWidth="750"> + - + + + + {{ st.name }} + + + + + + + + + + {{ row.order.accompany_product ? row.order.accompany_product.name : '' }} + + {{ refundStatusText(row.status) }} + + + + + + + ¥{{ row.order.price ? row.order.price : 0 }} + 订单号 {{ row.order.no }} + 退单理由:{{ row.apply_reason }} + + + + + 被服务人 + {{ row.order.user_archive ? row.order.user_archive.name : '' }} + + + {{ (row.order.type == 1 ? '就诊' : '服务') + '时间' }} + {{ row.order.time ? $moment(row.order.time).format('YYYY年MM月DD日 HH:mm') : '' }} + + + 详细地址 + {{ row.order.city || ' ' }} + + + 就诊医院 + {{ row.order.hospital ? row.order.hospital.name : '' }} + + + + + 查看订单 + + + + + + + + + + @@ -19,13 +79,12 @@ :text="i.type === 1 ? '陪诊' : '陪护'"> {{i.accompany_product?i.accompany_product.name:''}} - {{ statusFormat(i.pay_status) }} + {{ orderListStatusLabel(i) }} - + - @@ -35,14 +94,7 @@ - + {{i.type == 1 ? '被服务人' : '被服务人'}} {{ i.user_archive ? i.user_archive.name : i.user_archive_id }} @@ -58,34 +110,27 @@ 就诊医院 {{ i.hospital ? i.hospital.name : '' }} - - - 下单时间: - {{ i.created_at ? $moment(i.created_at).format('YYYY年MM月DD日 HH:mm') : '' }} + + + 下单时间: + {{ i.created_at ? $moment(i.created_at).format('YYYY年MM月DD日 HH:mm') : '' }} - 修改信息 {{ i.pay_status === 0 ? '立即支付' : '查看订单' }} + :throttle-time="2000" @click="goOrderDetail(i)">{{ i.pay_status === 0 ? '立即支付' : '查看订单' }} @@ -111,20 +156,21 @@ @@ -282,6 +408,27 @@ } } + .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; } @@ -364,7 +511,6 @@ width: 90rpx; height: 84rpx; border-radius: 10rpx; - // background-color: #f3e7d8; } &-text { @@ -433,4 +579,4 @@ } } } - \ No newline at end of file +