Browse Source

一对多调整

gcz 11 months ago
parent
commit
fafce9adb1
1 changed files with 47 additions and 37 deletions
  1. 47 37
      pages/bookticket.vue

+ 47 - 37
pages/bookticket.vue

@@ -47,13 +47,15 @@
 			<view class="block-wrap visitors">
 				<view class="block-title u-flex">
 					<view class="name">观影人信息</view>
+					<text v-if="needIdcardNumber">需要{{needIdcardNumber}}张身份证</text>
 					<!-- <text>用于入园身份验证</text> -->
 				</view>
 				<view class="people-list u-flex u-flex-wrap">
 					<view class="people btn" v-if="visitors.length>0" v-for="(visitor,index) in visitors" :key="index">
 						{{visitor.name}}
 					</view>
-					<view class="btn u-flex u-row-center" @click="visitorShow = true">
+					<view class="btn u-flex u-row-center"
+						@click="visitorShow = true">
 						<u-icon name="plus-circle" color="#2D2D2D" size="32rpx"></u-icon>
 						<text class="text">新增/更换</text>
 					</view>
@@ -158,7 +160,8 @@
 </template>
 
 <script>
-	import {
+	import { locale } from "moment/moment";
+import {
 		systemInfo
 	} from "@/mixin.js";
 	// #ifdef H5
@@ -228,6 +231,15 @@
 					return total;
 				}, 0);
 			},
+			needIdcardNumber(){
+				if(this.pageContent.oneMany===1&&this.pageContent.personnelNum!==0){
+					return this.pageContent.personnelNum
+				}else if(this.pageContent.oneMany===1&&this.pageContent.personnelNum===0){
+					return null
+				}else if(this.pageContent.oneMany===2){
+					return 1
+				}
+			}
 		},
 		onShow() {
 			this.getSettlement();
@@ -274,15 +286,23 @@
 					this.visitorList = res.data.list;
 					// this.visitors = this.visitorList.filter(obj => obj.memberId==userId);
 					this.visitors = this.visitorList.filter(obj => that.selectedVisitor.includes(obj.idcard));
-					// console.log('this.visitorList',this.visitorList);
-					// console.log('this.selectedVisitor',this.selectedVisitor);
-					// console.log('this.visitors',this.visitors);
+					console.log('this.visitorList',this.visitorList);
+					console.log('this.selectedVisitor',this.selectedVisitor);
+					console.log('this.visitors',this.visitors);
 				}).catch(err => {
 					console.log('getMemberAll', err);
 				})
 			},
 			confirmVisitor() {
 				let that = this;
+				
+				if(this.needIdcardNumber&&this.needIdcardNumber!==this.selectedVisitor.length){
+					uni.showToast({
+						title:`身份证数量应该为${this.needIdcardNumber}张`,
+						icon:'none'
+					})
+					return false
+				}
 				// console.log('selectedVisitor',this.selectedVisitor);
 				this.visitorShow = false;
 				this.visitors = this.visitorList.filter(obj => that.selectedVisitor.includes(obj.idcard)).map(item => {
@@ -356,16 +376,19 @@
 				    }
 					this.retailId = retailId;
 				console.log('submitorder retailId',this.retailId);
-				// if(this.scene&&this.scene!='undefined'){
-				// 	await this.$u.api.uncompress({scene:this.scene}).then(res=>{
-				// 		// data.performId = res.data.performId;
-				// 		this.label = res.data.label;
-				// 		this.retailId =  res.data.retailId;
-				// 		console.log('uncompress',res.data);
-				// 	}).catch(err=>{
-				// 		console.log('uncompress',err);
-				// 	})
-				// }
+				if(this.pageContent.oneMany === 2 && this.pageContent.personnelNum!==0){//一证多票,补齐观影人信息
+					let dontNeedCardsNumber = this.pageContent.personnelNum - this.visitors.length;
+					if(dontNeedCardsNumber>0){//
+						for (let i = 0;i<dontNeedCardsNumber;i++) {
+							console.log('dontNeedCardsNumber',dontNeedCardsNumber);
+							this.visitors.push({
+								name: this.visitors[0].name,
+								idcard: this.visitors[0].idcard,
+								mobile: this.visitors[0].mobile,
+							});
+						}
+					}
+				}
 				let params = {
 					performId: this.pageContent.performId,
 					goodsList: [{
@@ -386,6 +409,7 @@
 					retailId:this.retailId
 				}
 				console.log('submitorder params',params);
+				// return
 				// #ifdef MP
 				params['source'] = 1
 				// #endif 
@@ -401,26 +425,6 @@
 					this.orderId = res.data.orderId;
 					// this.templateEven()
 					this.gotoPay();
-					// 删除分销信息
-					// this.setTemplate();
-					// uni.removeStorage({
-					// 	key:'retailId',
-					// 	success: (e) => {
-					// 		console.log('removeStorage retailId success',e);
-					// 	},
-					// 	fail: (e) => {
-					// 		console.log('removeStorage retailId fail',e);
-					// 	}
-					// });
-					// uni.removeStorage({
-					// 	key:'scene',
-					// 	success: (e) => {
-					// 		console.log('removeStorage scene success',e);
-					// 	},
-					// 	fail: (e) => {
-					// 		console.log('removeStorage scene fail',e);
-					// 	}
-					// });
 
 				}).catch(err => {
 					this.cansubmit = true;
@@ -476,6 +480,13 @@
 			},
 			// 设置小程序订阅消息
 			setTemplate() {
+				if(this.needIdcardNumber&&this.needIdcardNumber!==this.visitors.length){
+					uni.showToast({
+						title:'观影人信息不正确',
+						icon:'none'
+					})
+					return false
+				}
 				let that = this;
 				// console.log('templateIdList', this.templateIdList);
 				// #ifdef MP
@@ -657,8 +668,7 @@
 					})
 				})
 				// #endif
-			}
-
+			},
 		}
 	}
 </script>