<style>
.jz_LineHeadeBox{
	padding-top: 41.2vw;
	position: relative;
}
.jz_LineHeade{
	height: 310rpx;
	position: absolute;
	left: 0;
	right: 0;
	top:0;
	bottom: 0;
}
.jz_LineHeade.active0{
	background: url('https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Upload/Goods/638731577125637216.png') no-repeat;
	background-size: 100% auto;
}
.jz_LineHeade.active1{
	background: url('https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Upload/Goods/638731577133752446.png') no-repeat;
	background-size: 100% auto;
}
.jz_LineHeade.active2{
	background: url('https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Upload/Goods/638731577175977264.png') no-repeat;
	background-size: 100% auto;
}
	.jz_Line {}

	.jz_Content {
		/* margin: 20rpx 0rpx 30rpx 0rpx; */
	}

	.jz_List {
		display: flex;
		justify-content: space-between;
	}

	.jz_TuDiv {
		width: 220rpx;
		height: 280rpx;
		border-radius: 12px;
		overflow: hidden;
		position: relative;
	}

	.jz_TuDiv .jz_TuBigImg {
		width: 100%;
		height: 100%
	}

	.jz_TuDiv .none-image {
		width: 100%;
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #ECF1F4;
		color: grey;
		font-size: 28rpx;
		font-family: 'nav-font';
	}
	.jz_TuNewImg{
		width: 94rpx;
		height: 37rpx;
		position: absolute;
		left: -4px;
		top: 10px;
	}

	.jz_Right {
		width: 432rpx;
		margin-top: 5px;
		font-size: 14px;
		position: relative;
	}

	.jz_LineName {
		color: #111111;
		font-size: 30rpx;
		font-weight: 600;
		text-overflow: -o-ellipsis-lastline;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		line-clamp: 2;
		-webkit-box-orient: vertical;
		font-family: microsoft yahei ui light;
	}

	.jz_Canhoubu {
		color: #FF3166;
		margin-left: 10px;
	}

	.jz_redType {
		color: #FF3166;
	}

	.jz_TuDivBotm {
		position: absolute;
		width: 100%;
		height: 18px;
		text-align: center;
		bottom: 0;
		color: #fff;
		font-size: 12px;
		line-height: 18px;
		background-color: rgba(0, 0, 0, 0.3);
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.op_remark {
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}

	.jz_ListMain {
		padding-bottom: 10px;
		margin: 0 30rpx;
		border-bottom: 1px solid #f1f1f1;
		margin-bottom: 10px;

	}

	.jz_TuDivBotm img {
		width: 12px;
		height: 12px;
		margin-right: 5px;
	}

	.jz_calederImg {
		width: 16px;
		height: 16px;
		position: relative;
		top: 2px;
		margin-right: 5px;
	}

	.jz_Sort {
		width: 100%;
		margin: 20px 0;
	}

	.jz_SortItem {
		display: inline-block;
		width: 25%;
		text-align: center;
	}

	.Jz_tanchu {
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		background: #FFF;
		position: absolute;
		top: 100px;
		left: 0;
		z-index: 1999;
	}

	.Jz_tanchu_item {
		width: 94%;
		margin-left: 3%;
		height: 45px;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		border-bottom: 1px solid #f1f1f1;
	}

	.Jz_Mask {
		width: 100%;
		height: 100%;
		background: #000000;
		opacity: 0.3;
		position: absolute;
		left: 0;
		top: 130px;
		z-index: 999;
	}

	.jz_Recommend {
		color: #999999;
		font-size: 24rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		margin-top: 10px;
		line-height: 20px;
	}

	.jz_Content .search-box {
		height: 70rpx;
		background: #FFF;
		border-radius:18rpx;
		display: flex;
		align-items: center;
		padding: 19rpx 30rpx;
		margin: 0 30rpx;
		position: absolute;
		bottom: 29rpx;
		left: 0;
		right: 0;
	}

	.jz_Content .search-box .date {
		height: 50rpx;
		font-size: 28rpx;
		font-weight: 500;
		color: #111111;
		line-height: 50rpx;
		margin-right: 30rpx;
		display: flex;
		align-items: center;
	}

	.jz_Content .team-box {
		display: flex;
		align-items: stretch;
		justify-content: space-between;
		flex-wrap: wrap;
	}

	.jz_Content .team-box:after {
		content: "";
		flex: auto;
	}

	.jz_Content .team-box .team {
		width: calc(50% - 30rpx);
		background: #ECF1F4;
		border-radius: 10rpx;
		font-size: 26rpx;
		color: #999999;
		text-align: center;
		padding: 20rpx;
		margin-top: 30rpx;
		margin-right: 30rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.jz_Content .team-box .team.active {
		background: #111111;
		color: #FFFFFF;
	}

	.jz_Content .team-box .team .team-content {
		text-overflow: -o-ellipsis-lastline;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}

	.jz_Content .start-range-box {
		background: #ECF1F4;
		border-radius: 10rpx;
		margin-top: 30rpx;
		display: flex;
		align-items: center;
		padding: 20rpx;
	}

	.jz_Content .start-range-box .date-box {
		flex: 1;
		font-weight: 400;
	}

	.jz_Content .start-range-box .split-box {
		color: #bbb;
		font-size: 24rpx;
		margin: 0 20rpx
	}

	.jz_Content .start-range-box .date-box.right view {
		text-align: right;
	}

	.jz_Content .start-range-box .date-box .label {
		color: #bbb;
		font-size: 24rpx;
	}

	.jz_Content .start-range-box .date-box .chosen-date {
		color: #111;
		font-size: 28rpx;
		font-weight: 600;
	}

	.jz_Content .start-city {
		display: inline-block;
		position: relative;
	}

	.jz_Content .start-city text {
		position: relative;
		z-index: 2;
		font-size: 30rpx;
		line-height: 30rpx;
		font-weight: 500;
		color: #111;
	}

	.jz_Content .start-city::after {
		background-color: #DFBE6E;
		height: 6px;
		bottom: 2px;
		left: 0;
		right: 0;
		position: absolute;
		z-index: 1;
		display: block;
		content: ' ';
	}

	.jz_Content .price {
		margin-top: 10rpx;
		font-weight: 500;
		color: #111111;
		font-size: 20rpx;
		text-align: right;
	}

	.jz_Content .price .money {
		font-size: 36rpx;
		color: #FF3166;
		font-family: nav-font;
	}
</style>
<template>
	<div class="jz_Line">
		<view class="jz_Content" style="display: flex; flex-direction: column;height: 100vh;">
			<view class="jz_LineHeadeBox">
				<view class="jz_LineHeade" :class="{
					'active0':msg.teamType==0,
					'active1':msg.teamType==1,
					'active2':msg.teamType==2}">
					<headerLine></headerLine>
					<view class="search-box" style="margin-top: 24rpx;">
						<view class="date" @click="showBranch=true" v-if="branchVisible">
							<u-icon name="location" color="#B99846" size="24"></u-icon>
							<text style="margin-left: 20rpx;color: #B99846;">{{currentBrachName}}</text>
						</view>
						<view  v-if="branchVisible" style="width: 1px;height: 26rpx;margin-right: 10rpx; background: #E5E3E1;flex-shrink: 0;">
							<view style="opacity: 0;">
								1
							</view>	
						</view>
						<view style="width: 1px; flex: 1;">
							<u-search placeholder="关键字搜索" v-model="msg.searchKey" @search="getList(1)" input-align="left" :value="msg.searchKey"
							text-color="#111" bg-color="rgba(0,0,0,0)" :show-action="false"></u-search>
						</view>
					</view>
				</view>
			</view>
			<view style="height: 80rpx;width: 100%;">
				<u-dropdown ref="uDropdown" @open="open" @close="close" active-color="#000" inactive-color="#444">
					<u-dropdown-item v-model="msg.orderBy" :title="optionsTitle[0]" :options="orderBys" @change="changeOrderBy">
					</u-dropdown-item>
					<u-dropdown-item :title="optionsTitle[1]">
						<view class="slot-content" style="padding:0 30rpx 30rpx 0;padding-top:0;background-color: #FFF;">
							<view style="height: 50vh;display: flex;">
								<view style="background-color: #f1f1f1;margin-right: 30rpx;height:100%">
									<scroll-view scroll-y="true" style="height:100%">
										<view style="text-align: center; padding: 15px 0;" v-if='msg.teamType==0 || msg.teamType==1'>
											<u-tag mode="plain" border-color="#DFBE6E" color="#DFBE6E" text="出境游" size="mini"></u-tag>
										</view>
										<template v-for="x in lineList">
											<view :style="{'background':x.LineID==currentLineId.LineID?'#FFF':'unset'}" @click="changeLineTeamsHandler(x)"
											style="font-size: 15px;color:#111;padding:30rpx;text-align: center;" v-if="x.LineDirection==2 && (msg.teamType==0 || msg.teamType==1)" :key="x.LineID">{{x.LineShortName}}</view>
										</template>
										<view style="text-align: center; padding: 15px 0;"  v-if='msg.teamType==2'>
											<u-tag mode="plain" border-color="#DFBE6E" color="#DFBE6E" text="当地游" size="mini"></u-tag>
										</view>
										<template v-for="x in lineList">
											<view :style="{'background':x.LineID==currentLineId.LineID?'#FFF':'unset'}" @click="changeLineTeamsHandler(x)"
											style="font-size: 15px;color:#111;padding:30rpx;text-align: center;" v-if="x.LineDirection==3&&msg.teamType==2" :key="x.LineID">{{x.LineShortName}}</view>
										</template>
									</scroll-view>
								</view>
								<view style="flex:1;width:1px;height:100%">
									<scroll-view scroll-y="true" style="height:100%" v-if="currentLineId && currentLineId.PlaceList">
										<view style="text-align: right;">
											<checkbox-group @change="allTeamsChangeHandler">
												<label>
													<checkbox value="all" :checked="allTeams" style="transform: scale(0.7)" /><text style="font-size: 12px;">全部系列</text>
												</label>
											</checkbox-group>
										</view>
										<template v-for="(x,i) in currentLineId.PlaceList">
											<view style="padding-top:30rpx">
												<text style="font-size: 28rpx;color:#111;font-weight: 800;margin-right: 10rpx;">{{x.DestinationName}}</text>
											</view>
											<view class="team-box">
												<view v-for="(y,yi) in x.Teams" :key="yi" class="team" :class="{'active':msg.team.indexOf(y.TeamId)!=-1}"
												@click="setTeams(y.TeamId)">
													<view class="team-content">{{y.TeamName}}</view>
												</view>
											</view>
										</template>
									</scroll-view>
								</view>
							</view>
							<view style="box-shadow: 0px -10px 30px 0px rgba(36, 36, 36, 0.06);margin-top:40rpx;display: flex;padding-left: 30rpx;">
								<view style="flex:1;margin-right: 30rpx;">
									<u-button :custom-style="btnStyle" @click="clearTeams">清除</u-button>
								</view>
								<view style="flex:1;">
									<u-button :custom-style="btnStyle2" @click="changeTeams">完成</u-button>
								</view>
							</view>
						</view>
					</u-dropdown-item>
					<u-dropdown-item :title="optionsTitle[2]">
						<view class="slot-content" style="padding: 30rpx;padding-top:0;background-color: #FFF;">
							<scroll-view scroll-y="true" style="max-height: 50vh;">
								<view style="padding-top:30rpx">
									<text style="font-size: 28rpx;color:#111;font-weight: 800;margin-right: 10rpx;">行程天数</text>
								</view>
								<view class="team-box">
									<view v-for="x in days" class="team" style="width:calc(25% - 30rpx);" :class="{'active':msg.days.indexOf(x.day)!=-1}"
									@click="setDays(x.day)">{{x.name}}</view>
								</view>
								<view style="padding-top:30rpx">
									<text style="font-size: 28rpx;color:#111;font-weight: 800;margin-right: 10rpx;">出发日期</text>
								</view>
								<view class="start-range-box" @click="showTimePopup=true">
									<view class="date-box">
										<view class="label">最早出发日期</view>
										<view class="date" style="font-weight: 400;" v-if="msg.startDate==''">选择日期</view>
										<view class="date" v-else>{{msg.startDate}}</view>
									</view>
									<view class="split-box">-至-</view>
									<view class="date-box right">
										<view class="label">最晚出发日期</view>
										<view class="date" style="font-weight: 400;" v-if="msg.endDate==''">选择日期</view>
										<view class="date" v-else>{{msg.endDate}}</view>
									</view>
								</view>
							</scroll-view>
			
							<view style="box-shadow: 0px -10px 30px 0px rgba(36, 36, 36, 0.06);margin-top:40rpx;display: flex;">
								<view style="flex:1;margin-right: 30rpx;">
									<u-button :custom-style="btnStyle" @click="clearDayAndDate">清除</u-button>
								</view>
								<view style="flex:1;">
									<u-button :custom-style="btnStyle2" @click="changeDayAndDate">完成</u-button>
								</view>
							</view>
						</view>
					</u-dropdown-item>
					<u-dropdown-item v-model="msg.startCityId" :title="optionsTitle[3]" :options="startCitys" @change="changeStartCity">
					</u-dropdown-item>
				</u-dropdown>
			</view>
			<view style="height: 1px; flex: 1;width: 100%;">
				<view v-if="screenshow==true" class="Jz_Mask" @click="screenshow=false"></view>
				<u-empty v-if="dataList.length==0 && !loading" text="暂无数据" mode="data"></u-empty>
				<template v-else>
					<view style="height: 100%;overflow: hidden;">
						<scroll-view :scroll-y="true" :enable-back-to-top="true" :enable-flex="true" @scrolltolower="lower" :style="{ height: '100%' }">
							<view class="jz_ListMain" v-for="(item,index) in dataList" :key="index" @click="goJzDetail(item)">
								<view class="jz_List">
									<view class="jz_TuDiv">
										<img class="jz_TuBigImg" mode="aspectFill" :src="getImgs(item.imgCover)" alt="" v-if="item.imgCover && item.imgCover.length>0 && getImgs(item.imgCover)!=''" />
										<view class="none-image" v-else>暂无图片</view>
										<img v-if="item.isNewArrival&&item.isNewArrival==1" class="jz_TuNewImg" src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Upload/Goods/638733097518452353.png" />
									</view>
									<view class="jz_Right">
										<view class="jz_LineName">{{item.title}}</view>
										<view class="jz_Recommend" v-if="item.productRecommend && item.productRecommend!='null'">
											{{item.productRecommend}}
										</view>
										<view style="margin:10px 0;display: flex;align-items: center;">
											<view class="start-city" style="margin-right: 20rpx;" v-if="item.startCityName">
												<text>{{item.startCityName}}出发</text>
											</view>
											<view style="margin-right: 20rpx;" v-if="item.companyUnions && item.companyUnions.length>1">
												<u-tag border-color="#DFBE6E" color="#FFF" bg-color="#DFBE6E" text="多个出发城市" size="mini"></u-tag>
											</view>
											<view>
												<u-tag mode="plain" border-color="#DFBE6E" color="#DFBE6E" :text="`${item.dayNum}天`" size="mini"></u-tag>
											</view>
										</view>
										<view class="price" style="display:flex;justify-content: space-between;align-items: center;">
											<view style="font-size:24rpx;color:#999999;">
												最近团期：{{item.startDate}}
											</view>

										</view>
										<view class="price" style="text-align: unset;">
											<text>￥</text>
											<text class="money">
												<!-- #ifdef MP-DI -->
													{{parseFloat(item.b2CPrice).toFixed(2)}}
												<!-- #endif -->
												<!-- #ifdef MP-AG -->
													{{parseFloat(item.b2BPrice).toFixed(2)}}
												<!-- #endif -->
											</text>
										</view>
									</view>
								</view>
							</view>
						</scroll-view>
					</view>
				</template>
			</view>
			
		</view>
		<auth v-if="showAuth&&is_show_auth==1" @changeuserinfo="reloadUserinfo" @gbAuth="gbAuth"></auth>
		<u-picker mode="time" v-model="isShowDate" @confirm='getStratDate' :params="params"></u-picker>
		<u-popup v-model="showTimePopup" mode="bottom" border-radius="20" length="90%" :safe-area-inset-bottom="true">
			<canlendar @finish="chosenDateResult"></canlendar>
		</u-popup>
		<u-picker mode="selector" v-model="showBranch" :default-selector="[0]" :range="branchList" @confirm='changeBranch'
		 range-key="BName"></u-picker>
	</div>
</template>
<script>
	import canlendar from "./components/time/index.vue"
	import auth from "@/components/auth/index.vue";
	import headerLine from "@/components/header/header";//"./components/headerLine";
	export default {
		components: {
			canlendar,
			auth,
			headerLine
		},
		data() {
			return {
				allTeams: false,
				loading: true,
				pageTitle: '线路',
				showTimePopup: false,
				msg: {
					pageIndex: 1,
					pageSize: 15,
					orderBy: "",
					team: [],
					days: ['<100'],
					startDate: '',
					endDate: '',
					startCityId: -1,
					companyId: -1,
					searchKey: '', //搜索数据
					priceOrderByField: 2,
					PlaceIds: '',
					lineId: 0,
					teamType: "", //团队类型 1-小包团
					pName:""
				},
				time: '',
				currentLineId: null,
				params: {
					year: true,
					month: true,
					day: true,
					hour: false,
					minute: false,
					second: false
				},
				btnStyle: {
					borderRadius: '16rpx',
					color: '#111',
					fontSize: '30rpx',
					width: '100%',
					border: "1px solid #111",
					background: "#FFF"
				},
				btnStyle2: {
					borderRadius: '16rpx',
					color: '#fff',
					fontSize: '30rpx',
					width: '100%',
					background: "#111"
				},
				dataList: [], //数据
				isShowDate: false,
				orderBys: [],
				lineList: [],
				days: [{
						name: "不限",
						day: '<100'
					},
					{
						name: "2日以下",
						day: '<=2'
					},
					{
						name: "3日",
						day: '=3'
					},
					{
						name: "4日",
						day: '=4'
					},
					{
						name: "5日",
						day: '=5'
					},
					{
						name: "6日",
						day: '=6'
					},
					{
						name: "7日",
						day: '=7'
					},
					{
						name: "8日以上",
						day: '>=8'
					}

				],
				loadText: {
					loadmore: "轻轻上拉，加载更多",
					loading: "努力加载中",
					nomore: "没有更多了",
				},
				startCitys: [],
				screenshow: false,
				status: "加载中",
				page_count: 0,
				branchList: [],
				currentBrachName: "",
				showBranch: false,
				branchVisible:false,
				optionsTitle: [
					"推荐排序",
					"线路玩法",
					"天数日期",
					"出发城市"
				],
				CityId: 0,
				showAuth: false,
				is_show_auth: 0, //是否显示授权弹窗
				b2bUser: {}, //同行信息
				mallUserInfo: {},
			};
		},
		created() {
			uni.setNavigationBarTitle({
				title: "精品旅游线路"
			})
			// #ifdef MP-DI
			this.branchVisible=false
			// #endif
		},
		onLoad(option) {
			console.log("option", option);
			if (option && option.LineTeamIds) {
				let NewArr = [];
				NewArr = option.LineTeamIds.split(",");
				if (NewArr.length > 0) {
					NewArr.forEach(x => {
						this.msg.team.push(parseInt(x));
					})
				}
			} else if (option && option.lineId) {
				this.msg.lineId = option.lineId;
			}
			if (option && option.PlaceIds) {
				this.msg.PlaceIds = option.PlaceIds;
			}
			//  && option.teamType == "1"
			if (option && option.teamType) {
				this.msg.teamType = option.teamType;
			}
			if(option && option.pName){
				this.msg.pName = option.pName
			}
			let basedata = uni.getStorageSync("basedata");
			//判断后台是否开启自动授权
			if (basedata && basedata.mall && basedata.mall.setting && basedata.mall.setting && basedata.mall.setting.is_show_auth ==
				1) {
				this.is_show_auth = 1;
			}
			this.b2bUser = uni.getStorageSync("b2b_user");
			this.mallUserInfo = uni.getStorageSync("mall_UserInfo");
			if (!this.mallUserInfo) {
				this.mallUserInfo = {
					nickName: "未登录",
					avatarUrl: "",
				};
				this.showAuth = true;
			} else if (!this.b2bUser && this.is_show_auth == 1) {
				this.U = {
					nickName: "未登录",
					avatarUrl: "",
				};
				this.showAuth = true;
			}
			this.getLineQuery();
		},
		methods: {
			reloadUserinfo() {
				this.b2bUser = uni.getStorageSync("b2b_user");
				this.mallUserInfo = uni.getStorageSync("mall_UserInfo");
			},
			//关闭登录窗口
			gbAuth() {
				this.showAuth = false;
			},
			allTeamsChangeHandler(e) {
				this.allTeams = e.detail.value.length > 0
				if (this.allTeams && this.msg.team.length > 0) {
					this.msg.team = [];
				}
				this.$forceUpdate();
			},
			//线路切换
			changeLineTeamsHandler(item) {
				this.allTeams = false;
				this.currentLineId = item;
				this.msg.lineId = item.LineID;
				this.msg.PlaceIds = "";
				this.msg.team = [];
				this.allTeams = true
			},
			//获取查询条件
			getLineQuery() {
				let customerInfo = uni.getStorageSync("b2b_user")
				this.apipost(
					"b2b_get_GetMiniAppTravelQuery", {},
					res => {
						if (res.resultCode == 1) {
							this.orderBys = res.data.OrderByList;
							this.branchList = res.data.SiteList;
							this.startCitys = res.data.CityList;
							this.lineList = res.data.LineList;
							// #ifdef MP-AG
							this.msg.companyId = this.branchList[0].BId;
							// #endif
							
							this.currentBrachName = this.branchList[0].BName;
							this.CityId = this.branchList[0].CityId;
							this.currentLineId = this.lineList[0]
							if (this.msg.lineId != 0) {
								let temp = this.lineList.find(x => x.LineID == this.msg.lineId)
								if (temp) {
									this.currentLineId = temp
									this.optionsTitle[1] = temp.LineShortName
								} else {
									this.currentLineId = this.lineList[0]
								}
							} else {
								this.currentLineId = this.lineList[0]
							}
							if (customerInfo && customerInfo.salesBaseInfo) {
								let tempCompany = this.branchList.find(x => x.BId == customerInfo.salesBaseInfo.rB_Branch_id)
								if (tempCompany && tempCompany.BId) {
									// #ifdef MP-AG
									this.msg.companyId = tempCompany.BId
									// #endif
									
									this.currentBrachName = tempCompany.BName
								}
							}
						}
						this.research();
					},
					null
				);
			},
			changeBranch(val) {
				this.msg.companyId = this.branchList[val].BId
				this.currentBrachName = this.branchList[val].BName
				this.CityId = this.branchList[val].CityId;
				this.research();
			},
			setDays(day) {
				if (day == '<100') {
					this.msg.days = ['<100']
				} else {
					if (this.msg.days.indexOf('<100') != -1) {
						this.msg.days.splice(this.msg.days.indexOf('<100'), 1)
					}
					let temp = this.msg.days.indexOf(day)
					if (temp == -1) {
						this.msg.days.push(day)
					} else {
						this.msg.days.splice(temp, 1)
					}
				}
			},
			clearDayAndDate() {
				this.msg.days = ['<100']
				this.optionsTitle[2] = '天数日期'
				this.msg.startDate = ''
				this.msg.endDate = ''
				this.$forceUpdate()
				this.$refs.uDropdown.close();
				this.research();
			},
			changeDayAndDate() {
				let temp = ''
				if (this.msg.days.indexOf("<100") == -1) {
					this.msg.days.forEach(x => {
						this.days.forEach(y => {
							if (y.day == x) {
								temp += y.name + ","
							}
						})
					})
				}
				if (this.msg.startDate != '') {
					temp += "最早:" + this.msg.startDate + ","
				}
				if (this.msg.endDate != '') {
					temp += "最早:" + this.msg.endDate + ","
				}
				this.optionsTitle[2] = temp == '' ? '天数日期' : temp
				this.$forceUpdate()
				this.$refs.uDropdown.close();
				this.research();
			},
			chosenDateResult(obj) {
				this.msg.startDate = obj.start;
				this.msg.endDate = obj.end;
				this.showTimePopup = false
			},
			clearTeams() {
				this.msg.team = []
				this.optionsTitle[1] = '线路玩法'
				this.currentLineId = null
				this.msg.lineId = 0;
				this.msg.PlaceIds = "";
				this.allTeams = false
				this.$forceUpdate()
				this.$refs.uDropdown.close();
				this.research();
			},
			changeTeams() {
				if (this.msg.team.length == 0) {
					this.optionsTitle[1] = '线路玩法'
					if (this.allTeams && this.currentLineId) {
						this.optionsTitle[1] = this.currentLineId.LineShortName
						this.msg.lineId = this.currentLineId.LineID
					}
				} else {
					let temp = ''
					this.lineList.forEach(x => {
						x.PlaceList.forEach(y => {
							y.Teams.forEach(z => {
								if (this.msg.team.indexOf(z.TeamId) != -1) {
									temp += z.TeamName + ","
								}
							})
						})
					})
					this.optionsTitle[1] = temp
				}
				if (this.optionsTitle[1] == '') {
					this.optionsTitle[1] = '线路玩法'
				}
				this.$forceUpdate()
				this.$refs.uDropdown.close();
				this.research();
			},
			setTeams(teamId) {
				this.msg.PlaceIds = "";
				let id = teamId
				let temp = this.msg.team.indexOf(id)
				if (temp == -1) {
					this.msg.team.push(id)
				} else {
					this.msg.team.splice(temp, 1)
				}
				if (this.allTeams && this.msg.team.length > 0) {
					this.allTeams = false
					this.msg.lineId = 0
				}
				this.$forceUpdate();
			},
			changeOrderBy(index) {
				let temp = this.orderBys.find(x => {
					if (x.value == index) {
						return x
					} else {
						return false
					}
				})
				this.optionsTitle[0] = temp.label
				this.msg.orderBy = temp.value
				this.$forceUpdate()
				this.research();
			},
			changeStartCity(index) {
				if (index == -1) {
					this.optionsTitle[3] = "出发城市"
					this.msg.startCity = -1
				} else {
					let temp = this.startCitys.find(x => {
						if (x.value == index) {
							return x
						} else {
							return false
						}
					})
					this.optionsTitle[3] = temp.label + "出发"
					this.msg.startCity = temp.value
				}
				this.$forceUpdate()
				this.research();
			},
			open(index) {
				this.$refs.uDropdown.highlight();
				console.log(this.$refs.uDropdown.active,'-----')
			},
			close(index) {
				this.$refs.uDropdown.highlight(index);
				console.log(this.$refs.uDropdown.highlight(index),'-----33')
			},
			research() {
				this.msg.pageIndex = 1;
				this.dataList = [];
				this.getList();
			},
			//获取数据
			getList(type) {
				if (type == 1) {
					this.dataList = [];
					this.msg.pageIndex = 1;
				}
				if (this.msg.lineId != 0 && this.msg.team.length > 0) {
					this.msg.lineId = 0
				}
				uni.showLoading({
					title: '加载中',
					icon: 'none'
				})
				this.apipost(
					"b2b_get_GetLXYTravelPageList",
					this.msg,
					res => {
						if (res.resultCode == 1) {
							let format = this.getFormatUnionStartCityHandler(res.data.pageData)
							this.dataList = this.dataList.concat(format);
							this.page_count = res.data.pageCount;
						}
						this.loading = false
						uni.hideLoading();
					},
					err => {
						this.loading = false
					}
				);
			},
			getFormatUnionStartCityHandler(data) {
				data.forEach(x => {
					if (x.unionList && x.unionList.length > 0) {
						let companyUnions = x.unionList.filter(y => y.unionBranchId == this.msg.companyId)
						if (companyUnions && companyUnions.length > 0) {
							if (companyUnions[0].unionCityId > 0) {
								x.startCityId = companyUnions[0].unionCityId
								x.startCityName = companyUnions[0].startCityName
							} else {
								let tempCity = this.branchList.find(y => y.BId == this.msg.companyId)
								if (tempCity && tempCity.CityId) {
									x.startCityId = tempCity.CityId
									x.startCityName = tempCity.BName.replace('站', '')
								}
							}
							x.companyUnions = companyUnions
						}
					}
				})
				return data
			},
			//获取日期
			getStratDate(val) {
				console.log(val, 'val');
			},
			lower(e) {
				if (this.msg.pageIndex < this.page_count) {
					this.msg.pageIndex++;
					this.status = "loading";
					this.getList();
				} else {
					this.status = "nomore";
				}
			},
			//跳转至详情
			goJzDetail(item) {
				uni.navigateTo({
					url: "/pages/jiuzhai/jz_LineDetail?tcid=" + item.tcid + '&configId=' + item.configId + '&cityId=' + (item.startCityId ?
						item.startCityId : this.CityId) + '&lineId=' + this.msg.lineId
				});
			},
			//获取第一张图
			getImgs(imgObj) {
				let imgArr = JSON.parse(imgObj);
				if (imgArr && imgArr.length > 0) {
					return imgArr[0].Url
				}
			}
		},
	};
</script>
