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.

344 lines
8.1 KiB

2 years ago
<template>
<view class="wrap">
<view class="list">
2 years ago
<view class="list-item" v-for="(item,index) in orders" :key="index">
<view class="list-item-top" @click="toorder(item.id)">
2 years ago
<view class="status">
2 years ago
<text class="statusName">{{item.status_name}}</text>
2 years ago
</view>
2 years ago
<view>订单编号{{item.serial}}</view>
<view>{{item.bed.building.name}}-{{item.bed.room.name}}-{{item.bed.name}}</view>
2 years ago
</view>
2 years ago
<view class="list-item-body" @click="toorder(item.id)">
2 years ago
<view class="">
<view>
2 years ago
<text>{{item.project.name}}</text>
{{item.product.name}}
2 years ago
</view>
2 years ago
<view>{{item.patient.name}}</view>
2 years ago
</view>
<view class="">
2 years ago
<view>预约{{item.from_date}}</view>
<view>X{{item.days}}</view>
2 years ago
</view>
<view>
2 years ago
<view>合计¥{{item.total}}</view>
<view>已扣¥{{item.paid_total}}</view>
<view>余额¥{{item.customer.balance}}</view>
2 years ago
</view>
<view>
<view>
2 years ago
<text v-for="(mod,i) of item.factorsJson">{{mod.factor_item_name}}</text>
2 years ago
</view>
</view>
</view>
<view class="list-item-foot">
2 years ago
<view class="cancel" v-if="item.status==0" :data-id="item.id" @click="toCancel"></view>
<view class="" @click="toPay" :data-id="item.id" v-if="item.status==20"></view>
<view class="judge" v-if="!item.scored_at&&item.status==100" :data-id="item.id" @click="toJuge"></view>
2 years ago
</view>
</view>
</view>
<tabbar :current-page="3"></tabbar>
</view>
</template>
<script>
2 years ago
import tabbar from "../../components/tabbar/tabbar.vue";
import util from "../../utils/util.js";
2 years ago
export default {
components: {
tabbar
},
2 years ago
2 years ago
data() {
return {
2 years ago
currentPage: 1,
orders: [],
loading: true
2 years ago
}
2 years ago
},
onLoad: function(e) {},
onShow: function() {
this.loadPage(1);
},
onReady: function() {},
onHide: function() {},
onUnload: function() {},
onPullDownRefresh: function() {
this.loadPage(1);
2 years ago
},
2 years ago
onReachBottom: function() {
this.loadPage(this.currentPage + 1);
2 years ago
},
2 years ago
2 years ago
methods: {
getErrorMessage: function(err, fallback) {
fallback = fallback || '支付失败,请稍后重试';
if (!err) return fallback;
if (typeof err === 'string') return err;
if (err.errormsg) return err.errormsg;
if (err.errorMsg) return err.errorMsg;
if (err.message) return err.message;
if (err.data && err.data.errormsg) return err.data.errormsg;
if (err.data && err.data.message) return err.data.message;
try {
return JSON.stringify(err);
} catch (e) {
return fallback;
}
},
2 years ago
toorder(id) {
uni.navigateTo({
url: "/packages/packagesOrder/pages/orderInfo/index?id=" + id
})
},
loadPage: function(o) {
var that = this;
util.request({
bindThis: that,
api: 'customer/get-orders',
customLoading: false,
data: {
page: o,
page_size: 10
},
utilSuccess: function(n) {
var i = n.data;
console.log(i);
uni.stopPullDownRefresh();
if ((that.orders.length < 10 && o > 1) || (0 == i.length && o > 1)) {
uni.showToast({
title: '已加载到最后一页',
icon: 'none'
});
} else {
var s;
var l;
var u = that.orders;
var c = Math.floor(new Date().getTime() / 1000);
var d = i;
try {
for (var g of d) {
g.statusStr = util.orderStatusDic[g.status];
g.ThumbUrl = util.isNull(g.ThumbUrl) ? '/resources/nonepro.jpg' : '';
var f = g.from_date.replace(/-/g, '/').replace(/T/g, ' ');
g.isPreParamedic = Math.floor(new Date(f).getTime() / 1000) > c;
g.factorsJson = JSON.parse(g.factors.replace(/\\/g, ''));
// 定义两个日期
const date1 = that.$moment(g.from_date);
const date2 = that.$moment(g.to_date);
// 计算差异
const duration = that.$moment.duration(date2.diff(date1));
console.log(duration)
g.days = duration.days() + 1;
}
} catch (e) {
} finally {
}
if (1 == o) {
u = i;
} else {
(l = u).push.apply(l, e(i));
}
that.currentPage = o;
that.orders = u;
that.loading = false;
}
},
utilFail: function(e) {
uni.stopPullDownRefresh();
if (1 == o) {
that.currentPage = o;
that.orders = [];
}
util.alert(e);
}
});
},
2 years ago
2 years ago
toPay: function(e) {
var that = this;
2 years ago
var t = e.currentTarget.dataset.id;
util.request({
api: 'customer/get-order/' + t,
utilSuccess: function(e) {
var o = (e.total - e.balance - e.paid_total).toFixed(2);
util.payOrder(
o,
t,
function(e) {
that.loadPage(1);
2 years ago
},
function(e) {
util.alert(that.getErrorMessage(e, '支付失败,请稍后重试'));
2 years ago
}
);
},
utilFail: function(e) {
util.alert(e);
}
});
},
toJuge: function(e) {
var t = e.currentTarget.dataset.id;
uni.navigateTo({
url: "/packages/packagesOrder/pages/judge/index?id=" + t
});
},
toCancel: function(e) {
var that = this;
var o = e.currentTarget.dataset.id;
uni.showModal({
title: '提示',
content: '取消订单',
confirmText: '确认',
confirmColor: '#000',
cancelColor: '#eee',
success: function(e) {
e.confirm ?
util.request({
bindThis: this,
customLoading: true,
api: 'customer/cancel-order/' + o,
data: {
id: o
},
method: 'POST',
utilSuccess: function(e) {
that.loadPage(1);
},
utilFail: function(e) {
util.alert(e);
}
}) :
e.cancel;
}
});
},
2 years ago
}
}
</script>
<style lang="scss">
.wrap {
background-color: #E7F5F4;
width: 100vw;
2 years ago
padding-bottom: 200rpx;
2 years ago
.list {
padding: 30rpx;
2 years ago
font-size: 24rpx;
2 years ago
&-item {
background: #FFFFFF;
box-shadow: 2rpx 0rpx 20rpx 0rpx #ddd;
border-radius: 4rpx 4rpx 4rpx 4rpx;
margin-bottom: 30rpx;
position: relative;
&-top {
color: #838180;
background: #FAFAFA;
display: flex;
justify-content: space-between;
padding: 0 20rpx;
2 years ago
height: 70rpx;
line-height: 70rpx;
2 years ago
position: relative;
2 years ago
.status {
&::before {
color: #fff;
content: '';
position: absolute;
top: 0;
left: 0;
width: 0;
height: 0;
border-top: 35rpx solid orangered;
border-right: 35rpx solid transparent;
border-left: 35rpx solid orangered;
border-bottom: 35rpx solid transparent;
}
text {
transform: rotate(313deg);
display: block;
color: #fff;
font-size: 16rpx;
position: relative;
left: -23rpx;
top: -12rpx;
2 years ago
}
}
}
&-body {
padding: 30rpx;
border-bottom: 1px solid #eceded;
padding-bottom: 20rpx;
>view {
display: flex;
justify-content: space-between;
color: #838180;
margin-bottom: 10rpx;
&:first-child {
2 years ago
font-size: 26rpx;
2 years ago
}
text {
color: #f96f40;
margin-right: 20rpx;
}
}
}
&-foot {
padding: 30rpx;
display: flex;
justify-content: flex-end;
view {
border-radius: 25rpx 25rpx 25rpx 25rpx;
// padding: 10rpx 20rpx;
background: linear-gradient(to right, #0EE2BA 0%, #67F7DC 100%);
color: #fff;
width: 140rpx;
text-align: center;
height: 54rpx;
line-height: 54rpx;
margin-left: 20rpx;
}
.cancel {
background: #fff;
color: #838180;
border: 2rpx solid #838180;
}
2 years ago
.judge {
background: rgba(247, 114, 63, 1);
color: #fff;
border: 2rpx solid #rgba(247, 114, 63, 1);
}
2 years ago
}
}
}
}
2 years ago
</style>