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.

284 lines
6.9 KiB

<template>
<view class="content">
<yu-toast :duration="2000" ref='toasts' verticalAlign="center" :message="toastMessage"></yu-toast>
<!-- 订单信息 -->
<view class="popup-content">
<view class='popup-title'>预约信息</view>
<view class='popup-form'>
<uni-forms :modelValue="orderForm" :label-width="80" label-align='right'>
<uni-forms-item name="type" label="预约时段">
<view class='line36'>{{orderForm.dates}}</view>
</uni-forms-item>
<uni-forms-item name="type" label="预约状态">
<view class='line36'>{{orderForm.status_name}}</view>
</uni-forms-item>
<uni-forms-item name="type_name" label="入场类型">
<view class='line36'>{{orderForm.type_name}}</view>
</uni-forms-item>
<uni-forms-item v-if="orderForm.type==1" label="单位名称" name="unit">
<view class='line36'>{{orderForm.unit}}</view>
</uni-forms-item>
<uni-forms-item label="联系人" name="name">
<view class='line36'>{{orderForm.name}}</view>
</uni-forms-item>
<uni-forms-item label="手机号" name="mobile">
<view class='line36'>{{orderForm.mobile}}</view>
</uni-forms-item>
<uni-forms-item required label="人数" name="total" v-if='orderForm.type==1'>
<uni-easyinput v-if='orderForm.status==1' type="number" v-model="orderForm.total" placeholder="请输入人数" />
<view v-else class='line36'>{{orderForm.total}}</view>
</uni-forms-item>
</uni-forms>
</view>
<view class='popup-btn' v-if='orderForm.status==1'>
<button type="primary" @click="cancelOrder" plain="true">取消</button>
<button type="primary" v-if='orderForm.type==1' @click="confirmOrder" plain="true">确认</button>
<button type="primary" v-if='orderForm.type==2' @click="cancelAll" plain="true">确认</button>
</view>
<view v-else class='popup-btn'>
<button style='width:80%' type="primary" @click="cancelOrder" plain="true"></button>
</view>
</view>
</view>
</template>
<script>
import yuToast from '@/components/yu-toast/yu-toast.vue';
export default {
components: {
yuToast
},
data() {
return {
hosts:'https://gbyuyue.szgmbwg.org.cn',
// hosts: 'https://gb-test.ali251.langye.net',
toastMessage:'',
code: "",
isCancelAll:0,
orderForm: {
},
typeList: [{
value: 2,
text: '个人'
}, {
value: 1,
text: '团队'
}]
}
},
onShow() {
let that = this
},
onLoad(options){
this.code = options.code?options.code:''
this.getOrder()
},
methods: {
openToast(message){
this.toastMessage = message
this.$refs.toasts.show()
},
// 核销
getOrder() {
var that = this
var url = this.hosts + '/api/mobile/other/code-show'
uni.request({
url: url,
method: "GET",
data: {
code: that.code
},
success(res) {
if (res.statusCode == 200) {
if (res.data.errcode) {
that.openToast(res.data.errmsg)
setTimeout(function(){
uni.redirectTo({
url:'/pages/index/index'
})
},1500)
} else {
console.log(res)
if(Object.keys(res.data).length==0){
that.openToast('未查询到信息')
setTimeout(function(){
uni.redirectTo({
url:'/pages/index/index'
})
},1500)
return
}
let resdata = res.data
that.orderForm.dates = resdata.order.date+' ' + resdata.order.time
that.orderForm.type = resdata.order.type
that.orderForm.type_name = resdata.order.type==1?'团队':'个人'
that.orderForm.mobile = resdata.order.mobile
if(resdata.order.type==2){
that.orderForm.name = resdata.order_detail.name?resdata.order_detail.name:""
that.orderForm.status_name = resdata.order_detail.status_name
that.orderForm.status = resdata.order_detail.status
}else{
that.orderForm.name = resdata.order.leader?resdata.order.leader:""
that.orderForm.unit = resdata.order.unit?resdata.order.unit:""
that.orderForm.status_name = resdata.order.status_name
that.orderForm.status = resdata.order.status
}
that.orderForm.total = resdata.order.total
that.$forceUpdate();
}
} else {
that.openToast('请求失败')
}
},
fail() {
}
})
},
cancelOrder(e) {
uni.redirectTo({
url:'/pages/index/index'
})
},
cancelAll(){
let that = this
if(this.orderForm.total==1){
this.isCancelAll = 0
this.usecode()
return
}
uni.showModal({
title:'提示',
content:`该订单下共有${this.orderForm.total}位参观人员,是否全部核销?`,
cancelText:'核销一人',
confirmText:'核销所有',
success:res=>{
if(res.confirm){
that.isCancelAll = 1
that.usecode()
console.log("all")
}
if(res.cancel){
that.isCancelAll = 0
that.usecode()
console.log('single')
}
}
})
},
confirmOrder() {
this.usecode()
},
usecode() {
var url = this.hosts + '/api/mobile/other/code-use'
let that = this;
that.isfocus = false
uni.request({
url: url,
method: "GET",
data: {
code: that.code,
total:that.orderForm.total,
all_order:that.isCancelAll
},
success(res) {
if (res.statusCode == 200) {
if (res.data.errcode) {
that.openToast(res.data.errmsg)
} else {
that.openToast('核销成功')
setTimeout(function(){
uni.redirectTo({
url:'/pages/index/index'
})
},1500)
}
} else {
that.openToast(res.data.errmsg)
setTimeout(function(){
uni.redirectTo({
url:'/pages/index/index'
})
},1500)
}
},
fail() {
}
})
}
}
}
</script>
<style scoped>
.content {}
/deep/ .yu-toast-container{
z-index:99999999
}
/deep/ .uni-forms-item{
margin-bottom:20rpx!important
}
.btn input {
border: 1px solid #ddd;
height: 40px;
padding: 15px 10px;
margin: 10px;
margin-top: 30px;
font-size: 26px;
}
.admin {
text-align: center;
}
.admin button {
margin: 10px;
margin-top: 20px;
padding: 10px;
font-size: 24px;
}
.popup-content {}
.popup-title {
text-align: center;
font-size: 20px;
padding: 10px;
}
.popup-form {
margin: 20px;
overflow-y: scroll;
margin-top: 0;
}
/deep/ .uni-data-checklist {
margin-top: 5px !important;
}
.popup-btn {
text-align: center;
position: fixed;
bottom: 10px;
width: 100%;
}
.popup-btn button {
width: 40%;
display: inline-block;
margin: 0 10px;
}
.line36 {
line-height: 36px;
}
</style>