gcz 9 ماه پیش
والد
کامیت
1fa087c1c0
1فایلهای تغییر یافته به همراه31 افزوده شده و 7 حذف شده
  1. 31 7
      pages/ticketlist.vue

+ 31 - 7
pages/ticketlist.vue

@@ -153,13 +153,13 @@
 						没有座位信息
 					</view>
 					<view class="date-list u-flex u-flex-wrap">
-						<view class="date-item" :class="{active:positionIndex==index,'stock-over':date.saleSeatNum<1}" @click="positionClick(index)" v-for="(date,index) in positionArr" :key="index">
+						<view class="date-item" :class="{active:positionIndex==index,'stock-over':date.stockNum<1&&date.stockNum!==-1}" @click="positionClick(index,date)" v-for="(date,index) in positionArr" :key="index">
 							<view class="name">{{ date.seatTypeName }} <br />¥ {{date.salePrice}}</view>
-							<view class="sold-out" v-if="date.saleSeatNum<1">售罄</view>
+							<view class="sold-out" v-if="date.stockNum<1&&date.stockNum!==-1">售罄</view>
 						</view>
 					</view>
 				</view>
-				<view class="book-btn full-btn" v-if="positionArr.length>=1&&sessionList.length>=1" @click="book()">确定</view>
+				<view class="book-btn full-btn" v-if="positionArr.length>=1&&sessionList.length>=1&&(positionIndex||positionIndex===0)" @click="book()">确定</view>
 				<view class="full-btn gray" v-else>确定</view>
 			</view>
 			<!-- ticket end -->
@@ -312,7 +312,7 @@
 				ticketTypeIndex:0,
 				positionData:{},//座位信息接口
 				positionArr:[],
-				positionIndex:0,
+				positionIndex:null,
 				scene:null,
 				retailId:null,//分销码
 				label:null,//scene解析出来的
@@ -563,7 +563,7 @@
 			sessionClick(index,data){
 				// console.log('sessionClick index',index);
 				console.log('sessionClick data',data);
-				if(this.sessionIndex==index||date.stock<1){
+				if(this.sessionIndex==index){
 					// console.log('不变');
 					return
 				}
@@ -625,6 +625,9 @@
 					this.ticketTypeList = res.data.goodsList||[];
 					this.goodsSnapshot = this.ticketTypeList[this.ticketTypeIndex]?.goodsSnapshot;
 					this.positionArr =  this.ticketTypeList[this.ticketTypeIndex]?.regionList||[];
+					let sellableProductIndex = this.findFirstSellableProductIndex();
+					this.positionIndex = sellableProductIndex;
+					// console.log('this.positionIndex',this.positionIndex);
 					uni.hideLoading();
 				}).catch(err=>{
 					uni.hideLoading();
@@ -639,16 +642,37 @@
 				this.ticketTypeIndex = index;
 				this.goodsSnapshot = this.ticketTypeList[this.ticketTypeIndex]?.goodsSnapshot;
 				this.positionArr =  this.ticketTypeList[this.ticketTypeIndex]?.regionList||[];
-				this.positionIndex = 0;
+				let sellableProductIndex = this.findFirstSellableProductIndex();
+				this.positionIndex = sellableProductIndex;
 				// this.getPositionData()
 			},
-			positionClick(index){
+			positionClick(index,date){
 				if(this.positionIndex==index){
 					// console.log('不变');
 					return
+				}else if(date.stockNum<1&&date.stockNum!==-1){
+					uni.showToast({
+						title:'已售罄',
+						icon:'none'
+					})
+					return
 				}
 				this.positionIndex = index;
 			},
+			findFirstSellableProductIndex(){
+				// 检查数组是否为空
+				if (!Array.isArray(this.positionArr) || this.positionArr.length === 0) {
+					return null; 
+				}
+			
+				// 遍历数组,找到第一个可售的产品
+				for (let i = 0; i < this.positionArr.length; i++) {
+					if (this.positionArr[i].stockNum > 0 || this.positionArr[i].stockNum === -1) {
+						return i; // 返回第一个可售产品的索引
+					}
+				}
+				return null; 
+			},
 			book(item){
 				// console.log('book',item);
 				// console.log('performInfo',this.performInfo);