NurseStationPersonAppletUl/pages/Orderdetails/Orderdetails.vue

156 lines
4.1 KiB
Vue
Raw Normal View History

2023-04-24 15:53:03 +08:00
<template>
<view class="app">
2023-04-25 16:25:50 +08:00
<view class="time" style="" v-if="list.trainingOrderStatus=='WAIT_PAY'">
2023-04-24 15:53:03 +08:00
剩余付款时间
<u-count-down :timestamp="timestamp"></u-count-down>
</view>
<view class="trainingOrderStatus"
v-if="list.trainingOrderStatus=='REFUNDED'||list.trainingOrderStatus=='CANCEL'">
订单已关闭
</view>
<view class="content">
<view class="details">
<view class="detailslist">
<image :src="baseurl+list.trainingItemCoverUrl" mode=""></image>
<view class="model">
<span>{{list.trainingItemTitle}}</span>
</view>
</view>
<view class="payinfo">
<text class="pay">实付款</text>
2023-04-27 10:24:28 +08:00
<text class="price">{{list.trainingOrderAmount?list.trainingOrderAmount:0}}</text>
2023-04-24 15:53:03 +08:00
</view>
</view>
</view>
<view class="info">
<span>护理人员<text>{{list.nursePersonName}}</text></span>
<!-- <span>联系电话<text>{{list.phone}}</text></span> -->
<span>订单编号<text>{{list.trainingOrderNo}}</text></span>
<!-- <span>下单时间<text>{{list.orderTime}}</text></span> -->
</view>
2023-04-25 16:25:50 +08:00
<view class="buy" @tap='tobuy' v-if="list.trainingOrderStatus == 'WAIT_PAY'">
2023-04-24 15:53:03 +08:00
<view class="pay">
2023-04-25 16:25:50 +08:00
确认支付
2023-04-24 15:53:03 +08:00
</view>
</view>
<u-toast ref="uToast" />
</view>
</template>
<script>
2023-04-25 16:25:50 +08:00
import {
trainingItemOrder,
appletTrainingOrderPay
} from '@/api/learning/index.js'
2023-04-27 09:40:13 +08:00
import {
2023-04-27 10:24:28 +08:00
handCloseOrder,
getWaitPayTrainingOrderDetails
2023-04-27 09:40:13 +08:00
} from '@/api/Orderdetails/index.js'
2023-04-24 15:53:03 +08:00
import baseurl from '@/api/baseurl.js'
export default {
data() {
return {
baseurl: undefined,
2023-04-27 09:40:13 +08:00
trainingOrderNo: undefined,
2023-04-27 09:09:43 +08:00
list: undefined,
2023-04-24 15:53:03 +08:00
timestamp: 0,
2023-04-27 09:40:13 +08:00
timecount: 0,
Timer: null,
2023-04-24 15:53:03 +08:00
};
},
2023-04-27 09:09:43 +08:00
onUnload() {
clearInterval(this.Timer); //清除该函数
},
watch: {
2023-04-27 09:40:13 +08:00
timecount() {
if (this.timecount <= 0) {
handCloseOrder().then(res => {
clearInterval(this.Timer); //清除该函数
2023-04-27 11:03:22 +08:00
this.list.trainingOrderStatus = 'CANCEL'
2023-04-27 09:40:13 +08:00
})
}
2023-04-27 09:09:43 +08:00
}
},
2023-04-24 15:53:03 +08:00
onLoad(options) {
this.baseurl = baseurl
2023-04-27 10:24:28 +08:00
this.trainingOrderNo = options.trainingOrderNo
this.info();
2023-04-25 16:25:50 +08:00
},
methods: {
2023-04-27 09:40:13 +08:00
info() {
2023-04-27 10:24:28 +08:00
getWaitPayTrainingOrderDetails(this.trainingOrderNo).then(res => {
this.list = res.data
var ordertimes = this.list.trainingOrderTime.replaceAll(/\-/gi, "/")
2023-04-27 15:19:00 +08:00
var time = new Date(ordertimes).getTime() / 1000 + (60 * 60 * 2)
2023-04-27 10:24:28 +08:00
var times = new Date().getTime() / 1000
2023-04-27 16:31:45 +08:00
// this.timestamp = time - times
this.timestamp = 40
this.timecount = 40
2023-04-27 15:19:00 +08:00
if (this.timestamp > 0) {
this.timecount = this.timestamp
2023-04-27 16:09:54 +08:00
this.Timer = setInterval(() => {
this.timecount--;
}, 1000)
2023-04-27 15:19:00 +08:00
}
2023-04-27 10:24:28 +08:00
})
2023-04-27 09:40:13 +08:00
},
2023-04-25 16:25:50 +08:00
//购买
tobuy() {
var that = this
2023-04-27 10:24:28 +08:00
if (this.list.trainingOrderAmount > 0) {
2023-04-27 09:17:34 +08:00
let objs = {
"openid": uni.getStorageSync('openid'),
"nurseStationPersonId": this.list.nurseStationPersonId,
"orderNo": this.list.trainingOrderNo,
"payType": "WECHAT_PAY",
"orderChannel": "WECHAT_APPLET",
"buySource": "TRAINING",
2023-04-27 10:24:28 +08:00
"paymentPrice": this.list.trainingOrderAmount,
2023-04-27 09:17:34 +08:00
}
appletTrainingOrderPay(objs).then(response => {
if (response.code == 200) {
uni.requestPayment({
timeStamp: response.data.timeStamp,
nonceStr: response.data.nonceStr,
package: response.data.prepayId,
signType: response.data.signType,
paySign: response.data.paySign,
success: function(res) {
2023-04-27 11:09:52 +08:00
uni.setStorageSync("Refresh", '1')
2023-04-27 09:17:34 +08:00
that.$refs.uToast.show({
title: '支付成功',
type: 'success',
duration: 1500,
})
2023-04-27 11:06:09 +08:00
setTimeout(e => {
uni.navigateBack({
delta: 1
})
}, 1500)
2023-04-27 09:17:34 +08:00
},
fail: function(err) {
that.$refs.uToast.show({
title: '取消支付',
2023-04-25 16:25:50 +08:00
type: 'error',
2023-04-27 09:17:34 +08:00
duration: 1500,
2023-04-25 16:25:50 +08:00
})
}
2023-04-27 09:17:34 +08:00
});
} else {
this.$refs.uToast.show({
title: response.msg,
type: 'error',
duration: 2000
2023-04-25 16:25:50 +08:00
})
}
2023-04-27 09:17:34 +08:00
})
}
2023-04-25 16:25:50 +08:00
},
2023-04-24 15:53:03 +08:00
}
}
</script>
<style lang="scss">
2023-04-25 15:06:35 +08:00
@import "./Orderdetails.scss";
2023-04-24 15:53:03 +08:00
</style>