<template>
	<view class="container">
		<view v-if="isNeedAppoint">
			<view class="address-box">
				<view class="address-item" @tap="selectAddress" v-if="checkedAddress.id > 0">
					<image class="map-icon" mode="aspectFit" src="/static/images/address/dingwei.png"></image>
					<view class="m">
						<text class="address">{{ checkedAddress.addressDetail }}</text>
						<view class="address-bottom">
							<text class="user-name">{{ checkedAddress.name }}</text>
							<text>{{ checkedAddress.tel }}</text>
						</view>
					</view>
					<view class="r">
						<van-icon name="arrow" />
					</view>
				</view>
				<view class="address-item address-empty" @tap="selectAddress" v-else>
					<view class="m">还没有收货地址，去添加</view>
					<view class="r">
						<van-icon name="arrow" />
					</view>
				</view>
			</view>

			<view style="text-align: right; height: 48rpx; line-height: 48rpx; font-size: 22rpx ;color: #d77958;"
				class="jz-color">*请确保服务地址正确，确保服务者顺利上门！</view>
		</view>

		<!-- 商品详情 -->
		<view class="goods-items">
			<view class="item" v-for="(item, index) in checkedGoodsList" :key="index">
				<!-- <view class="name">{{item.goodsName}}</view> -->

				<view style="display: flex">
					<view class="img">
						<image :src="item.picUrl" mode="aspectFill"></image>
					</view>
					<view class="info">
						<view class="name">{{ item.goodsName }}</view>
						<view class="m" style="margin-top: 10rpx">规格:{{ item.specifications[0] }}</view>
						<view class="m" v-if="item.goodsType == 4">服务次数:{{ item.product.serviceTimes }}</view>
						<view class="m" v-else-if="">购买份数:{{ item.number }}</view>
						<view class="b">单价:￥{{ item.price }}</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 加购 -->
		<view class="plus-order" v-if="increaseSumPrice > 0">
			<view class="plus-title">加购</view>
			<view class="plus-name">
				{{ checkedGoodsList[0].product.specifications }}
				<text>x</text>
				<!-- <text class="plus-num">{{checkedGoodsList[0].unitPrice}}*{{checkedGoodsList[0].unitIncreaseNumber}}</text> -->
				<text class="plus-num">{{ checkedGoodsList[0].unitIncreaseNumber }}</text>
			</view>
			<view class="plus-amount">{{ increaseSumPrice }}</view>
		</view>

		<view class="appoint-server" v-if="showLastServiceBtn&&addressId&&addressId!='undefined'&&addressId!='null'"
			@tap="chooseLastOrder">
			<view class="server-tip">优先匹配上一单的服务者</view>

			<image mode="aspectFit" src="https://mall.zhaijieshi.cc/file/wx-huawang/dian2.png" class="radio-img"
				v-if="isPreOrder"></image>

			<image mode="aspectFit" src="https://jzmall.lifejingzhi.com/file/jzmall-dy/icon-unselect-popup.png" v-else
				class="radio-img"></image>
		</view>
		<!-- 预约时间 -->
		<view class="appoint-time-block" v-if="goodsType != 6 && goodsType != 4 && (isNeedAppoint || couponId == 24)">
			<view class="appoint-time-operate" @tap="showAppoint">
				<view class="operate-left" v-if="!isFinishAppoint||!isOneAppoint" style="margin: 20rpx 0rpx;">预约上门时段
				</view>
				<view class="operate-left" v-if="isFinishAppoint&&isOneAppoint">
					<text>{{ oneTimeAppoint }}</text>
					<view class="" style="margin-top: 20rpx;">
						距离今日<text
							style="color: #D77958; display: inline-block;margin-right:4rpx;margin-left: 4rpx;">{{daysDifference}}</text>天
					</view>
				</view>

				<view class="operate-right">
					<text class="not-select" v-if="!isFinishAppoint" style="color: #D77958;">请选择</text>
					<text v-if="isFinishAppoint" style="color: #D77958;">更改</text>
					<van-icon name="arrow" color="##D77958" />
				</view>
			</view>
			<view class="appoint-time-show" v-if="isFinishAppoint">

				<view class="multi-times" v-if="!isOneAppoint">
					<view class="multi-times-item">
						<text>服务频率</text>
						<text>{{ activeTab == 3? '两周一次' : activeTab == 5 ? '一月一次' : '两月一次' }}</text>
					</view>
					<view class="multi-times-item">
						<text>服务时间</text>
						<text>{{ selectedDateList[0].weekStr + ' ' + selectedDateList[0].time }}</text>
					</view>
					<view class="multi-times-item">
						<text>首次服务时间</text>
						<text>{{ firstAppointList[firstDateIndex].date }}</text>
					</view>
				</view>
			</view>
		</view>

		<view class="coupon-box">
			<!-- 优惠 -->
			<view class="discount-title">
				<image mode="aspectFit" src="/static/images/new/icon-minus.png"></image>
				<text>优惠</text>
			</view>
			<view class="coupon-item" @tap="selectCoupon">
				<view class="l" v-if="couponId == 0">
					<text class="name">没有可用的优惠券</text>
					<text class="txt">0张</text>
				</view>
				<view class="l" v-else-if="couponId == -1">
					<text class="name">优惠券</text>
					<text class="txt">{{ availableCouponLength }}张</text>
				</view>
				<view class="l" v-else>
					<text class="name">优惠券</text>
					<text class="txt">{{ couponName }}</text>
				</view>
				<view class="r">
					<van-icon name="arrow" color="#85868A" />
				</view>
			</view>

			<view class="discount-line">
				<view class="l">
					<text class="name">已选择</text>
					<text class="txt">-￥{{ couponPrice }}</text>
				</view>
			</view>
		</view>


		<!-- 多次预约结果 -->
		<view class="appoint-result" v-if="appointFailTip">
			根据您的预约需求,有
			<text class="orange-font">{{ noSerTimes }}</text>
			个日期暂时无法提供预约服务,为您保留
			<text class="orange-font">{{ noSerTimes }}</text>
			个保洁次卡,下单成功后在"
			<text class="orange-font">我的订单-查看服务</text>
			"里预约服务
		</view>
		<view class="order-box">
			<view class="order-item no-border">
				<view class="l">
					<text class="name">备注</text>
				</view>
				<view class="r">
					<input class="txt message-item" :disabled="remarkDisable" @input="bindMessageInput"
						placeholder="如需要，请输入备注信息" :value="message" />
				</view>
			</view>
		</view>


		<view class="order-box code-module" v-if="isRecommend">
			<view class="order-item no-border">
				<view class="l">
					<text class="name">推荐码</text>
				</view>
				<view class="r">
					<input class="txt message-item" :disabled="remarkDisable" @input="bindCodeInput" type="number"
						maxlength="9" placeholder="请输入" :value="recCode" />
				</view>
			</view>
			<view class="codeTips" :class="{'no-match': isNoMatch}" v-if="codeShow" :disabled="remarkDisable">
				{{recommendTips}}
			</view>
		</view>

		<view class="coupon-price">
			优惠券：
			<text>￥{{ couponPrice }}</text>
		</view>
		<view class="actual-price">
			需支付：
			<text>￥{{ actualPrice }}</text>
		</view>

		<view class="go-pay-wrapper">
			<van-button block round @tap="submitOrder" color="#d77958" v-if="!isNeedAppoint">去支付</van-button>
			<van-button block round @tap="submitOrdera" color="#d77958" v-else>支付并预约</van-button>
		</view>

		<!-- custom-style="height: 80%" -->
		<van-popup :show="choosePopup" round position="bottom" @click-overlay="onClose">
			<view :class="'popup-wrapper  ' + (popupType == 1 ? 'popup-wrapper-special' : '')">
				<!-- 标题 -->
				<view class="popup-title popup-title-special popup-title-new">
					<view>{{ popupType == 1 ? '请选择服务开始时间' : popupType == 2 ? '请选择服务频次' : '请选择首次服务日期' }}</view>
					<view v-if="selectTimeValue >= 17" class="fee-tips">您选的时间段可能会加收夜间服务费，具体以与商家的沟通为准</view>
				</view>

				<block v-if="popupType == 1">
					<view :class="'popup-content ' + (popupType == 1 ? 'popup-content-special' : '')">
						<view class="time-select-top" style="display: flex;">
							<scroll-view class="scroll-view_H" scroll-x="true" scroll-left="0">
								<view class="time-select-left-item" @tap="dateCheck" :data-index="index"
									:data-week="item.week" :data-date="item.date" :data-isbook="item.isBook"
									v-for="(item, index) in dateList" :key="index" style="display: inline-block;">
									<view class="date-line-wrapper">
										<view :class="[
						'date-msg',
						   dateIndex == index ? 'current-date' : '',
						   item.dateMsg != '' ? 'avail-date' : ''
						 ]">
											{{item.weekOfDay}}
										</view>
										<view :class="[
						'date-msg1',
						   dateIndex == index ? 'current-date' : '',
						   item.dateMsg != '' ? 'avail-date' : ''
						 ]"> {{ item.bookdate | formatDate }}</view>
										<view :class="[
						    dateIndex == index ? 'current-line' : '',
							 item.dateMsg != '' ? 'current-line0' : ''
						  ]"></view>

									</view>
								</view>
							</scroll-view>
						</view>

						<view class="time-select-middle">
							<view class="noon-select">
								<view :class="'noon-item' + (noonType == '1' ? 'active-noon' : '')" data-noon="1"
									@tap="noonTab">上午</view>
								<view class="divider"></view>
								<view :class="'noon-item' + (noonType == '2' ? 'active-noon' : '')" data-noon="2"
									@tap="noonTab">下午</view>
							</view>

							<view class="time-item-wrapper">
								<view @tap="timeCheck" :data-stock="item.stock" :data-index="index"
									:data-msg="item.timeMsg" :data-toastmsg="item.toastMsg" :class="[
													'time-msg',
													   timeIndex == index ? 'current-time' : '',
													   item.toastMsg != null ? 'avail-time' : ''
													 ]" v-for="(item, index) in timeList" :key="index">
									<view :class="timeIndex === index ? 'current-time' : ''">{{ item.begin }}</view>



								</view>
							</view>
							<view class="appointment-tips">
								<view> <span></span>
									<text>可预约</text>
								</view>
								<view> <span class="selected"></span>
									<text>已选择</text>
								</view>
								<view> <span class="no-appointment"></span>
									<text>不可约</text>
								</view>
							</view>

							<view class="time-select-bottom" v-if="date!==''&week!==''&time!==''">
								<span>当前选择：</span>
								{{date}}
								（{{week}}）{{time}}
							</view>
						</view>
					</view>
				</block>
				<!-- 选择频次 -->
				<!--  -->
				<block v-if="popupType == 2">
					<van-tabs title-style="color:red;" v-if="choosePopup" :active="activeTab" color="#d77958"
						@change="onTabChange">
						<van-tab title="两周1次" name="3"></van-tab>
						<van-tab title="一月1次" name="5"></van-tab>
						<van-tab title="两月1次" name="6"></van-tab>
					</van-tabs>
					<view class="popup-content select-week-times">
						<view class=" week-select-left">
							<view class="time-select-left-item" @tap="weekCheck" :data-index="index"
								:data-weekday="item.week" v-for="(item, index) in weekArrList" :key="index">
								<view :class="'week-str ' + (weekIndex == index ? 'current-date' : '')">{{ item.week }}
								</view>
							</view>
						</view>
						<view class="time-select-right time-select-middle">
							<view class="time-select-right-a">
								<view class="time-select-right-item" @tap="timeSelect" :data-index="index"
									:data-time="item.time" v-for="(item, index) in timeList" :key="index">
									<view :class="
                                        selectTimeIndex==index
                                            ? 'current-time'
                                            : ''
                                    ">
										{{ item.time }}
									</view>
								</view>
							</view>
							<view class="appointment-tips appointment-tips1">
								<view> <span></span>
									<text>可预约</text>
								</view>
								<view> <span class="selected"></span>
									<text>已选择</text>
								</view>
								<view> <span class="no-appointment"></span>
									<text>不可约</text>
								</view>
							</view>
							<view class="time-select-bottom1" v-if="selectweek!==''&weekday!==''&selecttime!==''">
								周期卡服务频次，可按照您的习惯选择特定频率上门，后续可修改。
							</view>
							<view class="time-select-bottom" v-if="selectweek!==''&weekday!==''&selecttime!==''">
								<span>当前选择：</span>
								{{selectweek}}
								<span class="select-week-date"></span>
								{{weekday}}（{{selecttime}}）
							</view>
						</view>
					</view>
				</block>

				<!-- 选择首次预约时间 -->
				<block v-if="popupType == 3">
					<view class="popup-content">
						<view class="first-appoint-date-list">
							<view class="first-appoint-date-item" @tap="firstDateCheck" :data-index="index"
								:data-firstdate="item.date" :data-firstweek="item.week"
								v-for="(item, index) in firstAppointList" :key="index">
								<view :class="firstDateIndex == index ? 'current-date' : ''">
									{{ item.date + ' ' + item.week }}
								</view>
							</view>
							<view class="time-select-bottom2" v-if="firstdate!==''&firstweek!==''&selecttime!==''">
								<span>当前选择：</span>
								{{firstdate}}（{{firstweek}}）{{selecttime}}
							</view>
						</view>
					</view>
				</block>
			</view>

			<!-- 确认按钮 -->
			<view :class="'popup-btn-wrapper ' + (popupType == 1 ? 'popup-btn-special' : '')">
				<van-button color="#d77958" block round @tap.native="confirmTime">确定</van-button>
			</view>
		</van-popup>

		<!-- 支付失败弹框 -->

		<van-overlay :show="payFailShow">
			<view class="overlay-wrapper">
				<view class="fail-wrapper">
					<image src="https://mall.zhaijieshi.cc/file/wx-huawang/bj3.png" class="bgimg"></image>
					<image src="https://mall.zhaijieshi.cc/file/wx-huawang/cc.png" class="ccimg"></image>
					<view class="fail-top">
						<view class="fail-text">支付失败</view>
						<view class="sub-color">支付遇到问题，请尝试重新支付</view>
					</view>
					<view class="fail-bottom">
						<view class="cancel-btn" @tap="cancelPay">取消</view>
						<view class="repay-btn" @tap="rePay">重新支付</view>
					</view>
				</view>
			</view>
		</van-overlay>

		<!-- 不可预约提示弹框 -->
		<van-overlay :show="showOverLay" z-index=99999 @tap="onClickHide">
			<view class="overlay-wrapper">
				<view class="fail-wrapper" style="height: 900rpx;">
					<image src="https://mall.zhaijieshi.cc/file/wx-huawang/bj3.png" class="bgimg"></image>
					<image src="https://mall.zhaijieshi.cc/file/wx-huawang/cc.png" class="ccimg"></image>
					<view class="fail-top">
						<view class="fail-text">暂不可约</view>
						<view class="sub-color">服务可约时间遇到困难</view>
					</view>
					<view class="er-code">
						<view class="image">
							<image src="https://mall.zhaijieshi.cc/file/wx-huawang/er-code.png"
								:show-menu-by-longpress="true" @tap="previewImage"></image>
						</view>

						<view class="addwx ">
							长按识别添加
						</view>
						<view class="addwx">
							您的专属花王管家
							<image src="https://mall.zhaijieshi.cc/file/wx-huawang/tipcontent.png" class="tipcontent">
							</image>
						</view>
					</view>
					<view class="fail-bottom">
						<view class="btn" @tap="onClickHide">
							我知道了
						</view>
					</view>
				</view>
			</view>
		</van-overlay>
	</view>
</template>
<script module="formatFuc" lang="wxs" src="@/utils/formatFuc.wxs"></script>
<script>
	var util = require('../../utils/util.js');
	var user = require('../../utils/user.js');
	var api = require('../../config/api.js');
	var check = require('../../utils/check.js');
	var app = getApp();
	export default {
		filters: {
			formatDate: function(value, format) {
				// 这里可以根据format来格式化日期
				if (value) {
					return value.substring(0, 10).split('-').slice(1).join('-');
				}
			}
		},
		data() {
			return {
				traceId: '',

				//视频号的traceid
				requireOrder: 0,

				//视频号 是否需要推单，1:需要，0:不需要
				increaseSumPrice: 0,

				isRecommend: false,
				isNoMatch: true,
				codeShow: false,
				recCode: '',
				recommendTips: '',
				memberDiscount: '',
				isMember: false,
				orderId: '',
				payFailShow: false,
				choosePopup: false,
				noSerTimes: '',
				popupType: 1,

				//1单次预约 2 选择服务频次 3选择首次预约时间
				// timeList: check.getTimeList(1),
				timeList: [],

				// dateList: util.getDateList(new Date(new Date().getTime() + 60 * 60 * 1000 * 24 * 0), 1, 21),
				dateList: [],

				// firstAppointList:util.getDateList(new Date(new Date().getTime()+60*60*1000*24),7),
				firstAppointList: [],

				timeIndex: '',

				//选中的时间段
				dateIndex: 0,

				//单次预约选中的日期
				firstDateIndex: 0,

				//首次预约时间
				activeTab: 5,

				//频次
				weekIndex: 0,

				//选中的周几
				weekArrList: [{
						id: 1,
						week: '周一',
						num: 0
					},
					{
						id: 2,
						week: '周二',
						num: 0
					},
					{
						id: 3,
						week: '周三',
						num: 0
					},
					{
						id: 4,
						week: '周四',
						num: 0
					},
					{
						id: 5,
						week: '周五',
						num: 0
					},
					{
						id: 6,
						week: '周六',
						num: 0
					},
					{
						id: 0,
						week: '周日',
						num: 0
					}
				],

				selectedWeekList: [],
				selectedDateList: [],
				selectTimeIndex: 'null',

				//选中的时间段
				oneTimeAppoint: '2021-04-22 周一 13:00-14:00',

				isNeedAppoint: false,

				//是否需要预约
				isFinishAppoint: false,

				//已选择预约
				isOneAppoint: true,

				//单次卡
				appointFailTip: false,

				//预约失败提示
				bookStartDate: '',

				//可预约时间段
				bookEndDate: '',

				multiIndex: [0, 0, 0, 0, 0, 0],
				multiArray: [],
				array: [],
				year: '',
				month: '',
				day: '',
				startHour: '',
				endHour: '',
				orderData: '',

				//此时间为预计上门时间
				checkedGoodsList: [],

				checkedAddress: {
					id: 0,
					addressDetail: '',
					name: '',
					tel: ''
				},

				availableCouponLength: 0,

				// 可用的优惠券数量
				goodsTotalPrice: 0,

				//商品总价
				freightPrice: 0,

				//快递费
				couponPrice: 0,

				//优惠券的价格
				grouponPrice: 0,

				//团购优惠价格
				orderTotalPrice: 0,

				//订单总价
				actualPrice: 0,

				//实际需要支付的总价
				cartId: 0,

				addressId: 0,
				addressMsg: '',
				couponId: 0,
				userCouponId: 0,
				message: '',
				grouponLinkId: 0,

				//参与的团购
				grouponRulesId: 0,

				//团购规则ID
				nurseId: 0,

				//安心包认证id
				petinfo: null,

				//宠物保险内容
				shareId: 0,

				userInfo: {},
				remarkDisable: false,
				fraId: '',

				//加盟商id
				rId: '',

				//阿姨推荐码
				channelId: 112,

				//渠道id
				goodsType: 1,

				//商品类型 如果是6 可以不填写预约时间,
				serviceDuration: '',

				noonType: 1,
				selectTimeValue: '',
				Varieties: '',
				Warehouse: '',
				unitIncreaseNumber: '',
				weekStr: '',
				time: '',
				date: '',
				week: '',
				daysDifference: '',
				appType: 0,
				couponName: '',
				selectweek: '两周1次',
				weekday: '周一',
				selecttime: '',
				showLastServiceBtn: false,
				isPreOrder: false,
				firstweek: '',
				firstdate: '',
				toastMsg: "",
				showOverLay: false
			};
		},
		onReady: function() {
			// 页面渲染完成
		},
		onShow: function() {
			// 页面显示
			user.checkLogin()
				.then((res) => {
					app.globalData.hasLogin = true;
					console.info('session 未过期');
				})
				.catch(() => {
					console.info('session 过期');
					app.globalData.hasLogin = false;
					uni.navigateTo({
						url: '/pages/auth/login/login'
					});
				});
			uni.showLoading({
				title: '加载中...'
			});
			try {
				var cartId = uni.getStorageSync('cartId');
				if (cartId === '') {
					cartId = 0;
				}
				var addressId = uni.getStorageSync('addressId');
				if (addressId === '') {
					addressId = 0;
				} else if (typeof addressId === 'number') {} else if ((typeof addressId === 'string' && addressId
						.indexOf("{") !== -1) || addressId.length > 20) {
					addressId = JSON.parse(addressId).id;
				}
				var couponId = uni.getStorageSync('couponId');
				if (couponId === '') {
					couponId = 0;
				}
				var userCouponId = uni.getStorageSync('userCouponId');
				if (userCouponId === '') {
					userCouponId = 0;
				}
				var grouponRulesId = uni.getStorageSync('grouponRulesId');
				if (grouponRulesId === '') {
					grouponRulesId = 0;
				}
				var grouponLinkId = uni.getStorageSync('grouponLinkId');
				if (grouponLinkId === '') {
					grouponLinkId = 0;
				}

				//客户点选的预约动作
				var appType = uni.getStorageSync('appType');
				console.info(appType);
				this.setData({
					cartId: cartId,
					addressId: addressId,
					couponId: couponId,
					userCouponId: userCouponId,
					grouponRulesId: grouponRulesId,
					grouponLinkId: grouponLinkId,
					appType: appType
				});
				this.getCheckoutInfo(appType);
			} catch (e) {
				console.log('CatchClause', e);
				// Do something when catch error
				console.log(e);
			}
		},
		onHide: function() {
			// 页面隐藏
		},
		onUnload: function() {
			// 页面关闭
			//清空宠物保险的缓存数据
			console.info('checkout onload');
			//wx.setStorageSync('petinfo'+this.data.cartId, null);
		},
		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad: function(options) {
			this.setData({
				userInfo: app.globalData.userInfo
			});
			let that = this;
			if (options.nurseId) {
				this.setData({
					nurseId: options.nurseId
				});
			}
			var rId = uni.getStorageSync('rId');
			if (rId) {
				this.setData({
					rId: rId,
					recCode: rId
				});
			}
			var fraId = uni.getStorageSync('fraId');
			if (fraId) {
				this.setData({
					fraId: fraId
				});
			}
			var channelId = uni.getStorageSync('channelId');
			if (channelId) {
				this.setData({
					channelId: parseInt(channelId)
				});
			}
			if (typeof options.shareId != 'undefined' && options.shareId > 0) {
				that.setData({
					shareId: options.shareId
				});
			}

			//视频号，校验 wx.checkBeforeAddOrder
			uni.checkBeforeAddOrder({
				success(res) {
					console.log('checkBeforeAddOrder-success:', res);
					if (res.data.errcode == 0) {
						that.setData({
							traceId: res.data.traceId,
							requireOrder: res.data.requireOrder
						});
					}
				},
				fail(res) {
					console.log('checkBeforeAddOrder-fail:', res);
				}
			});
			var date = new Date();
			var year = date.getFullYear();
			var month = date.getMonth() + 1;
			var day = date.getDate();
			var hour = date.getHours();
			var surplusMonth = that.surplusMonth(year);
			console.log(surplusMonth);
			var surplusDay = this.surplusDay(year, month, day);
			console.log(surplusDay);
			var surplusHour = this.surplusHour(year, month, day, hour);
			console.log(surplusHour);

			//初始化picker
			that.setData({
				multiArray: [
					[year + '年', year + 1 + '年', year + 2 + '年'], surplusMonth, surplusDay, surplusHour[0],
					['~'], surplusHour[1]
				],
				year: year,
				month: month,
				day: day,
				startHour: surplusHour[0][0],
				endHour: surplusHour[1][0]
			});
		},
		methods: {
			//获取checkou信息
			getCheckoutInfo: function(appType) {
				let that = this;
				util.request(api.CartCheckout, {
					cartId: that.cartId,
					addressId: that.addressId,
					couponId: that.couponId,
					userCouponId: that.userCouponId,
					grouponRulesId: that.grouponRulesId,
					shareId: that.shareId,
					createOrderType: that.appType
				}).then(function(res) {
					console.log("1aaa", res);
					if (res.errno === 0) {
						that.setData({
							isRecommend: res.data.checkedGoodsList[0].goods.attribute != 1,
							isMember: res.data.isMember,
							memberDiscount: res.data.memberDiscount,
							checkedGoodsList: res.data.checkedGoodsList,
							checkedAddress: res.data.checkedAddress,
							availableCouponLength: res.data.availableCouponLength,
							actualPrice: res.data.actualPrice,
							couponPrice: res.data.couponPrice,
							grouponPrice: res.data.grouponPrice,
							freightPrice: res.data.freightPrice,
							goodsTotalPrice: res.data.goodsTotalPrice,
							orderTotalPrice: res.data.orderTotalPrice,
							addressId: res.data.addressId,
							addressMsg: res.data.addressMsg,
							couponId: res.data.couponId,
							userCouponId: res.data.userCouponId,
							grouponRulesId: res.data.grouponRulesId,
							isNeedAppoint: appType == '1' ? true : false,
							//0需要预约 服务类商品，1保险 2中介 3买约分离次卡res.data.checkedGoodsList[0].goods.type === 0 ||
							isOneAppoint: res.data.checkedGoodsList[0].product.serviceTimes == 1 ?
								true : false,
							//1为单次，其余为多次
							popupType: res.data.checkedGoodsList[0].product.serviceTimes == 1 ? 1 : 2,
							bookStartDate: res.data.bookStartDate,
							bookEndDate: res.data.bookEndDate,
							goodsType: res.data.goodsType,
							increaseSumPrice: res.data.increaseSumPrice,
							serviceDuration: res.data.serviceDuration,
							couponName: res.data.couponName,
							showLastServiceBtn: res.data.showLastServiceBtn
						});
						let serviceDuration = res.data.checkedGoodsList[0].product.serviceDuration;
						if (that.popupType == 2) {
							let timeList = [];
							if (res.data.timeRange != null && res.data.timeRange.length > 0) {
								res.data.timeRange.forEach((time, index) => {
									timeList.push({
										id: index + 1,
										time: time
									});
								});
							} else {
								timeList = check.getTimeList(serviceDuration);
							}
							that.setData({
								timeList: timeList
							});
							console.log("timeList", that.timeList);
						}
						if (res.data.addressId == null && res.data.addressMsg != null) {
							uni.showToast({
								title: res.data.addressMsg,
								icon: 'none',
								duration: 2000
							});
						}
						// that.LimitCanAppointmentDate();
					}

					uni.hideLoading();
				});
			},

			LimitCanAppointmentDate() {
				//特殊商品 如果需要限制可预约的时间范围 在次方法中实现
				if (this.checkedGoodsList[0].goodsId == 1190332) {
					let dates = [];
					this.dateList.forEach((item) => {
						if (item.date < '2022-04-01') {
							dates.push(item);
						}
					});
					this.setData({
						dateList: dates
					});
				}
				//控制可预约时间范围
				let that = this;
				if (that.bookStartDate) {
					let dates = [];
					let dateIndex = -1;
					that.dateList.forEach((item, index) => {
						if (item.date < that.bookStartDate || item.date > that.bookEndDate) {
							item.isBook = false;
							item.mark = '不可约';
						} else {
							//设置第一个可预约的时间index
							if (dateIndex < 0) {
								dateIndex = index;
							}
						}
						dates.push(item);
					});
					that.setData({
						dateList: dates,
						dateIndex: dateIndex
					});
				}
				console.info(that.dateList);
				console.info(that.dateIndex);

				//设置默认起始可预约 index:dateIndex  近7天如果有周六 周日 不允许预约
				//存在一种情况 如果今天是周四，如果起始index=2 则周日允许预约 虽然页面显示为”约满"
				// if(this.data.dateList[3].id==0) {
				//   console.info(" dateIndex:4")
				//   this.setData({
				//     dateIndex:4
				//   })
				// }else{
				//   if(this.data.dateList[2].id==0) {

				//   console.info(" dateIndex:3")
				//     this.setData({
				//       dateIndex:3
				//     })
				//   }
				// }
			},

			selectAddress() {
				uni.navigateTo({
					url: '/pages/ucenter/address/address'
				});
			},

			selectCoupon() {
				uni.navigateTo({
					url: '/pages/ucenter/couponSelect/couponSelect'
				});
			},

			bindMessageInput: function(e) {
				this.setData({
					message: e.detail.value
				});
			},

			bindCodeInput: function(e) {
				this.setData({
					recCode: e.detail.value
				});
				if (e.detail.value.length == 5) {
					// 校验服务者真实性
					this.recCodeCheck();
					//  this.setData({
					//   codeShow:true
					//  })
				} else {
					this.setData({
						codeShow: false
					});
				}
			},

			recCodeCheck() {
				uni.showLoading({
					title: '加载中'
				});
				util.request(
						api.checkRecommend, {
							recCode: this.recCode
						},
						'GET'
					)
					.then((res) => {
						uni.hideLoading();
						if (res.errno == 0) {
							if (res.data) {
								this.setData({
									codeShow: true,
									isNoMatch: false,
									recommendTips: '推荐人：' + res.data
								});
							} else {
								this.setData({
									codeShow: true,
									isNoMatch: true,
									recommendTips: '未匹配到推荐者，请您和推荐人核对'
								});
							}
						} else {
							this.setData({
								codeShow: false
							});
							uni.showToast({
								title: res.errmsg,
								icon: 'none',
								duration: 2000
							});
						}
					})
					.catch(function(err) {
						uni.hideLoading();
						this.setData({
							codeShow: false
						});
						uni.showToast({
							title: err.errMsg,
							icon: 'none'
						});
					});
			},

			submitOrder: function() {
				console.log("submitOrder");
				let that = this;
				// if (that.addressId <= 0) {
				// 	console.log("无地址");
				// 	//所选地址无服务门店，或选择其他地址
				// 	let errmsg = that.addressMsg == '' ? '请选择收货地址' : that.addressMsg;
				// 	//util.showErrorToast(errmsg);
				// 	uni.showModal({
				// 		title: '提示',
				// 		content: errmsg,
				// 		showCancel: false,
				// 		   confirmColor: '#D77958',
				// 	});
				// 	return;
				// }
				// 检查是否已经预约
				if (that.goodsType != 6 && that.goodsType != 4 && that.isNeedAppoint && !that.isFinishAppoint) {
					// util.showErrorToast('请先预约服务时间');
					uni.showToast({
						title: '请先预约服务时间',
						icon: 'none',
						duration: 2000
					});
					return;
				}
				// uni.showLoading({
				// 	title: '检测中'
				// });
				that.submitInfo();
			},
			submitOrdera: function() {
				console.log("submitOrder");
				let that = this;
				if (that.addressId <= 0) {
					console.log("无地址");
					//所选地址无服务门店，或选择其他地址
					let errmsg = that.addressMsg == '' ? '请选择收货地址' : that.addressMsg;
					//util.showErrorToast(errmsg);
					uni.showModal({
						title: '提示',
						content: errmsg,
						showCancel: false,
						confirmColor: '#D77958',
					});
					return;
				}
				// 检查是否已经预约
				if (that.goodsType != 6 && that.goodsType != 4 && that.isNeedAppoint && !that.isFinishAppoint) {
					// util.showErrorToast('请先预约服务时间');
					uni.showToast({
						title: '请先预约服务时间',
						icon: 'none',
						duration: 2000
					});
					return;
				}
				// uni.showLoading({
				// 	title: '检测中'
				// });
				that.submitInfo();
			},



			submitInfo() {
				//  如果是多次卡先预估，单次卡不用预估
				console.log("submitInfo");
				if (!this.isOneAppoint) {
					console.log("submitInfo1");
					let weeks = [];
					this.selectedDateList.forEach((item) => {
						let obj = {
							dayOfWeek: this.weekArrList[item.week].id,
							startTime: item.time.split('-')[0],
							endTime: item.time.split('-')[1]
						};
						weeks.push(obj);
					});
					let tempStartDate = null;
					if (this.firstAppointList.length != 0 && this.firstAppointList.length >= this.firstDateIndex) {
						tempStartDate = this.firstAppointList[this.firstDateIndex].date;
					}
					let params = {
						weeks: weeks,
						type: this.activeTab,
						startDate: tempStartDate,
						//this.data.firstAppointList[this.data.firstDateIndex].date,
						lng: this.checkedAddress.lng,
						lat: this.checkedAddress.lat,
						shopId: this.checkedAddress.shopId,
						goodId: this.checkedGoodsList[0].goodsId,
						isPreOrder: this.isPreOrder
					};
					console.log(params);
					this.orderPay(params);
				} else {
					console.log("submitInfo2");
					let weeks = [];
					if (this.isNeedAppoint && this.goodsType != 6 && this.goodsType != 4) {
						weeks = [{
							dayOfWeek: new Date(this.dateList[this.dateIndex].bookdate).getDay(),
							startTime: this.timeList[this.timeIndex].begin,
							endTime: this.timeList[this.timeIndex].end
						}];
					}
					let params = {
						weeks: weeks,
						type: 0,

						//startDate: this.isNeedAppoint ? this.dateList[this.dateIndex].bookdate : null,
						startDate: this.dateList != '' && this.dateList.length > 0 ? this.dateList[this.dateIndex]
							.bookdate : null,
						lng: this.checkedAddress.lng,
						lat: this.checkedAddress.lat,
						shopId: this.checkedAddress.shopId,
						goodId: this.checkedGoodsList[0].goodsId,
						isPreOrder: this.isPreOrder
					};
					console.log(params);
					this.orderPay(params);
				}
			},

			orderPay(orderData) {
				let that = this;

				var orderInfo = {
					cartId: this.cartId,
					addressId: this.addressId,
					couponId: this.couponId,
					userCouponId: this.userCouponId,
					message: this.message,
					orderDate: this.orderData,
					grouponRulesId: this.grouponRulesId,
					grouponLinkId: this.grouponLinkId,
					nurseId: this.nurseId,
					petinfo: this.petinfo,
					shareId: this.shareId,
					recCode: this.recCode ? this.recCode : this.rId,
					//服务者推荐id(如果填写推荐码 以填写为准)
					fraId: this.fraId,
					//加盟商id
					channelId: this.channelId,
					//渠道码
					//预约参数信息
					orderDate: orderData,
					requireOrder: this.requireOrder,
					traceId: this.traceId, //视频号
					createOrderType: this.appType,

				};

				if (this.codeShow && !this.isNoMatch) {
					orderInfo.recCode = this.recCode;
				}
				console.log(orderInfo);
				util.request(api.OrderSubmit, orderInfo, 'POST').then((res) => {
					//视频号，校验 wx.checkBeforeAddOrder
					uni.checkBeforeAddOrder({
						success(res) {
							console.log('checkBeforeAddOrder-success:', res);
							if (res.data.errcode == 0) {
								that.setData({
									traceId: res.data.traceId,
									requireOrder: res.data.requireOrder
								});
							}
						},
						fail(res) {
							console.log('checkBeforeAddOrder-fail:', res);
						}
					});
					if (res.errno === 0) {
						console.log(res.data.isNeedPay);
						if (res.data.isNeedPay == false) {
							console.log('跳过支付');
							util.redirect('/pages/ucenter/order/order');
							return;
						}
						// 下单成功，重置couponId
						uni.setStorageSync('couponId', 0);
						const orderId = res.data.orderId;
						this.setData({
							orderId: orderId
						});
						const grouponLinkId = res.data.grouponLinkId;
						util.request(
							api.OrderPrepay, {
								orderId: orderId
							},
							'POST'
						).then((res) => {
							if (res.errno === 0) {
								const payParam = res.data;
								console.log('支付过程开始');
								if (this.requireOrder == 1) {
									//视频号支付
									uni.requestOrderPayment({
										timeStamp: payParam.timeStamp,
										nonceStr: payParam.nonceStr,
										package: payParam.packageValue,
										signType: payParam.signType,
										paySign: payParam.paySign,
										success: (res) => {
											console.log('支付过程成功');
											if (grouponLinkId) {
												setTimeout(() => {
													uni.redirectTo({
														url: '/pages/groupon/grouponDetail/grouponDetail?id=' +
															grouponLinkId
													});
												}, 1000);
											} else {
												uni.redirectTo({
													url: '/pages/checkout/payResult/payResult?status=1&orderId=' +
														orderId + '&actualPrice=' +
														this.actualPrice
												});
											}
										},
										fail: (res) => {
											console.log('支付过程失败');

											// wx.redirectTo({
											//   url: '/pages/checkout/payResult/payResult?status=0&orderId=' + orderId
											// });
											// 弹出支付失败
											this.setData({
												payFailShow: true,
												remarkDisable: true
											});
										},
										complete: function(res) {
											console.log('支付过程结束');
										}
									});
								} else {
									uni.requestPayment({
										timeStamp: payParam.timeStamp,
										nonceStr: payParam.nonceStr,
										package: payParam.packageValue,
										signType: payParam.signType,
										paySign: payParam.paySign,
										success: (res) => {
											console.log('支付过程成功');
											if (grouponLinkId) {
												setTimeout(() => {
													uni.redirectTo({
														url: '/pages/groupon/grouponDetail/grouponDetail?id=' +
															grouponLinkId
													});
												}, 1000);
											} else {
												uni.redirectTo({
													url: '/pages/checkout/payResult/payResult?status=1&orderId=' +
														orderId + '&actualPrice=' +
														this.actualPrice
												});
											}
										},
										fail: (res) => {
											console.log('支付过程失败');
											// 弹出支付失败
											this.setData({
												payFailShow: true,
												remarkDisable: true
											});
										},
										complete: function(res) {
											console.log('支付过程结束');
										}
									});
								}
							} else {
								// 弹出支付失败
								this.setData({
									payFailShow: true,
									remarkDisable: true
								});
								// wx.redirectTo({
								//   url: '/pages/checkout/payResult/payResult?status=0&orderId=' + orderId
								// });
							}
						});
					} else {
						uni.showToast({
							title: res.errmsg,
							icon: 'none'
						});

						// util.showErrorToast(res.errmsg);
					}
				});
			},

			surplusMonth: function(year) {
				var date = new Date();
				var year2 = date.getFullYear();
				var month = date.getMonth() + 1;
				var day = date.getDate();
				var hour = date.getHours();
				var minute = date.getMinutes();
				var second = date.getSeconds();
				var monthDatas = [];
				if (year == year2) {
					var surplusMonth = 12 - month;
					monthDatas.push(month + '月');
					for (var i = month; i < 12; i++) {
						monthDatas.push(i + 1 + '月');
					}
				} else {
					for (var i = 0; i < 12; i++) {
						monthDatas.push(i + 1 + '月');
					}
				}
				return monthDatas;
			},

			//天数计算
			surplusDay: function(year, month, day) {
				var days = 31;
				var dayDatas = [];
				var date = new Date();
				var year2 = date.getFullYear();
				var month2 = date.getMonth() + 1;
				switch (parseInt(month)) {
					case 1:
					case 3:
					case 5:
					case 7:
					case 8:
					case 10:
					case 12:
						days = 31;
						break;
						//对于2月份需要判断是否为闰年
					case 2:
						if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
							days = 29;
							break;
						} else {
							days = 28;
							break;
						}
					case 4:
					case 6:
					case 9:
					case 11:
						days = 30;
						break;
				}
				if (year == year2 && month == month2) {
					// dayDatas.push(day + "日")
					for (var i = day; i < days; i++) {
						dayDatas.push(i + 1 + '日');
					}
				} else {
					console.log(month + '月' + days + '天');
					for (var i = 0; i < days; i++) {
						dayDatas.push(i + 1 + '日');
					}
				}
				return dayDatas;
			},

			//时间计算
			surplusHour: function(year, month, day, hour) {
				var date = new Date();
				var year2 = date.getFullYear();
				var month2 = date.getMonth() + 1;
				var day2 = date.getDate();
				var hourEnd = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21];
				var hours = [
					['09时', '10时', '11时', '12时', '13时', '14时', '15时', '16时', '17时', '18时', '19时', '20时'],
					['10时', '11时', '12时', '13时', '14时', '15时', '16时', '17时', '18时', '19时', '20时', '21时']
				];
				return hours;
			},

			varietiesChange: function(e) {
				var Varieties = this.array[parseInt(e.detail.value)];
				console.log(Varieties);
				this.setData({
					Varieties: Varieties
				});
			},

			warehouseChange: function(e) {
				var Warehouse = this.array[parseInt(e.detail.value)];
				console.log(Warehouse);
				this.setData({
					Warehouse: Warehouse
				});
			},

			//某一列的值改变时触发
			bindMultiPickerColumnChange: function(e) {
				var date = new Date();
				var year1 = date.getFullYear();
				var month1 = date.getMonth() + 1;
				var day1 = date.getDate();
				var hour1 = date.getHours();
				console.log('当前月份' + this.month + '修改的列为', e.detail.column, '，值为', e.detail.value);
				var data = {
					multiArray: this.multiArray,
					multiIndex: this.multiIndex,
					year: this.year,
					month: this.month,
					day: this.day,
					startHour: this.startHour,
					endHour: this.startHour
				};
				data.multiIndex[e.detail.column] = e.detail.value;
				switch (e.detail.column) {
					case 0:
						var yearStr = data.multiArray[e.detail.column][e.detail.value];
						var year = yearStr.substring(0, yearStr.length - 1);
						data.year = parseInt(year);
						var surplusMonth = this.surplusMonth(year);
						data.multiArray[1] = surplusMonth;
						if (data.year == year1) {
							data.month = month1;
						} else {
							data.month = 1;
						}
						if (data.year == year1 && month1 == data.month) {
							data.day = day1;
						} else {
							data.day = 1;
						}
						var surplusDay = this.surplusDay(data.year, data.month, data.day);
						data.multiArray[2] = surplusDay;
						var surplusHour;
						if (data.year == year1 && month1 == data.month && data.day == day1) {
							surplusHour = this.surplusHour(data.year, data.month, data.day, hour1);
						} else {
							surplusHour = this.surplusHour(data.year, data.month, data.day, 1);
						}
						console.log(surplusHour);
						data.multiArray[3] = surplusHour[0];
						data.multiArray[5] = surplusHour[1];
						data.startHour = surplusHour[0];
						data.endHour = surplusHour[1];
						data.multiIndex[1] = 0;
						data.multiIndex[2] = 0;
						data.multiIndex[3] = 0;
						data.multiIndex[5] = 0;
						break;
					case 1:
						console.log('选择月份' + data.multiArray[e.detail.column][e.detail.value]);
						var monthStr = data.multiArray[e.detail.column][e.detail.value];
						var month = monthStr.substring(0, monthStr.length - 1);
						data.month = month;
						data.day = 1;
						if (data.year == year1 && month1 == data.month) {
							data.day = day1;
						} else {
							data.day = 1;
						}
						var surplusDay = this.surplusDay(data.year, data.month, data.day);
						data.multiArray[2] = surplusDay;
						var surplusHour;
						if (data.year == year1 && month1 == data.month && data.day == day1) {
							surplusHour = this.surplusHour(data.year, data.month, data.day, hour1);
						} else {
							surplusHour = this.surplusHour(data.year, data.month, data.day, 1);
						}
						data.multiArray[3] = surplusHour[0];
						data.multiArray[5] = surplusHour[1];
						data.startHour = surplusHour[0];
						data.endHour = surplusHour[1];
						data.multiIndex[2] = 0;
						data.multiIndex[3] = 0;
						data.multiIndex[5] = 0;
						break;
					case 2:
						console.log('选择日' + data.multiArray[e.detail.column][e.detail.value]);
						var dayStr = data.multiArray[e.detail.column][e.detail.value];
						var day = dayStr.substring(0, dayStr.length - 1);
						data.day = day;
						var surplusHour;
						if (data.year == year1 && month1 == data.month && data.day == day1) {
							surplusHour = this.surplusHour(data.year, data.month, data.day, hour1);
						} else {
							surplusHour = this.surplusHour(data.year, data.month, data.day, 1);
						}
						data.multiArray[3] = surplusHour[0];
						data.multiArray[5] = surplusHour[1];
						data.startHour = surplusHour[0];
						data.endHour = surplusHour[1];
						data.multiIndex[3] = 0;
						data.multiIndex[5] = 0;
						break;
					case 3:
						console.log('起始时间' + data.multiArray[e.detail.column][e.detail.value]);
						var hourStr = data.multiArray[e.detail.column][e.detail.value];
						var hour = hourStr.substring(0, hourStr.length - 1);
						data.startHour = hour;
						console.log('起始时间' + hour + ' day1:' + day1);
						/*var endhours2 = [];
          var end = ['09时', '11时', '12时', '13时', '14时', '15时', '16时', '17时', '18时', '19时', '20时', '20时'];
            for (var i = e.detail.value; i < end.length; i++) {
               endhours2.push(end[i]);
            }
          data.multiArray[5] = endhours2; */
						if (e.detail.value > data.multiIndex[5]) {
							data.multiIndex[5] = e.detail.value;
						}
						break;
					case 5:
						var hourStr = data.multiArray[e.detail.column][e.detail.value];
						var hour = hourStr.substring(0, hourStr.length - 1);
						data.endHour = hour;
						if (e.detail.value < data.multiIndex[3]) {
							data.multiIndex[3] = e.detail.value;
						}
						//console.log('index:'+data.multiIndex[3]+'value:'+e.detail.value+'结束时间' + data.multiArray[e.detail.column][e.detail.value]);
						break;
				}
				this.setData(data);
			},

			//value 改变时触发 change 事件
			bindMultiPickerChange: function(e) {
				console.info(e);
				console.info(this.multiArray);
				console.info(this);
				console.info(this.multiIndex);
				var dateStr =
					this.multiArray[0][this.multiIndex[0]] +
					this.multiArray[1][this.multiIndex[1]] +
					this.multiArray[2][this.multiIndex[2]] +
					this.multiArray[3][this.multiIndex[3]] +
					this.multiArray[4][this.multiIndex[4]] +
					this.multiArray[5][this.multiIndex[5]];
				console.log('picker发送选择改变，携带值为', dateStr);
				this.setData({
					orderData: dateStr
				});
			},

			onClose() {
				this.setData({
					choosePopup: false,
					remarkDisable: false
				});
			},

			dateCheck(e) {
				let index = e.currentTarget.dataset.index;
				let date = e.currentTarget.dataset.date;
				let week = e.currentTarget.dataset.week;
				let isbook = e.currentTarget.dataset.isbook;

				this.setData({
					dateIndex: index,

				});
				let period = this.dateList[this.dateIndex].period;
				let current = this.noonType == 1 ? '上午' : '下午';
				let list = period.filter((item) => {
					return item.ofTime == current;
				});
				let bookdate = this.dateList[this.dateIndex].bookdate
				let weekOfDay = this.dateList[this.dateIndex].weekOfDay
				console.info('dateCheck:' + weekOfDay);
				this.setData({
					timeList: list,
					date: bookdate,
					week: weekOfDay
				});
				let isNoTime = list.every((item) => {
					return item.timeMsg && item.timeMsg != null;
				});
				if (isNoTime) {
					this.setData({
						timeIndex: -1,
						selectTimeValue: ''
					});
				}
			},

			noonTab(e) {
				let noon = e.currentTarget.dataset.noon;
				this.setData({
					timeIndex: -1,
					noonType: noon,
					selectTimeValue: ''
				});
				let period = this.dateList[this.dateIndex].period;
				let current = this.noonType == 1 ? '上午' : '下午';
				let list = period.filter((item) => {
					return item.ofTime == current;
				});
				this.setData({
					timeList: list
				});
			},

			timeCheck(e) {
				let index = e.currentTarget.dataset.index;
				let toastMsg = e.currentTarget.dataset.toastmsg;
				if (toastMsg == null || toastMsg == '') {
					let time = this.timeList[index].begin.split(':')[0];
					let bookTime = this.timeList[index].begin + '-' + this.timeList[index].end
					this.setData({
						timeIndex: index,
						selectTimeValue: Number(time),
						time: bookTime
					});
				} else {
					this.setData({
						toastMsg: toastMsg,
						showOverLay: true
					})
				}


			},

			weekCheck(e) {
				let index = e.currentTarget.dataset.index;
				let weekday = e.currentTarget.dataset.weekday;
				console.log("weekday", weekday);
				this.setData({
					weekIndex: index,
					weekday: weekday
					// selectTimeIndex:'null'
				});
			},

			timeSelect(e) {
				let index = e.currentTarget.dataset.index;
				let time = e.currentTarget.dataset.time;
				console.log("this.selecttime", time);
				if (this.activeTab) {
					let weekList = this.weekArrList;
					weekList.forEach((item) => {
						item.num = 0;
					});
					this.setData({
						weekArrList: weekList,
						selectTimeIndex: index,
						selecttime: time
					});
					console.log("this.selectTimeIndex", this.selectTimeIndex);
					let itemData = 'weekArrList[' + this.weekIndex + '].num';
					let selectedDateList = [];
					let dateItem = {
						week: this.weekIndex,
						time: time,
						weekStr: this.weekArrList[this.weekIndex].week
					};
					selectedDateList.push(dateItem);
					this.setData({
						// selectTimeIndex: index,
						[itemData]: 1,
						selectedWeekList: [this.weekIndex],
						selectedDateList: selectedDateList
					});
					// console.log(this);
				}
			},

			firstDateCheck(e) {
				let index = e.currentTarget.dataset.index;
				let firstdate = e.currentTarget.dataset.firstdate;
				let firstweek = e.currentTarget.dataset.firstweek;
				console.log("firstweek", firstweek + firstdate);
				this.setData({
					firstDateIndex: index,
					firstdate: firstdate,
					firstweek: firstweek
				});
			},

			onTabChange(e) {
				let weekList = this.weekArrList;
				weekList.forEach((item) => {
					item.num = 0;
				});
				console.log("e.detail.name", e.detail.name);
				if (e.detail.name == '3') {
					this.setData({
						selectweek: '两周1次'
					})
				} else if (e.detail.name == '5') {
					this.setData({
						selectweek: '一月1次'
					})
				} else {
					this.setData({
						selectweek: '两月1次'
					})
				}
				console.log("selectweek", this.selectweek);
				this.setData({
					weekArrList: weekList,
					activeTab: e.detail.name,
					selectTimeIndex: 'null',
					selectedWeekList: [],
					selectedDateList: []
				});
			},

			showAppoint() {
				if (this.addressId == 0) {
					util.showErrorToast('请选择服务地址');
					return;
				}
				this.setData({
					activeTab: "3",
					choosePopup: true,
					remarkDisable: true,
					popupType: this.popupType == 3 ? 2 : this.popupType,
					isFinishAppoint: false
				});
				if (this.popupType == '1') {
					this.getDayTime();
				}
				let that = this
			},

			confirmTime() {
				console.log(this);
				if (this.popupType == 1) {
					if (this.timeIndex === '' || this.timeIndex < 0) {
						uni.showToast({
							title: '请选择服务时间',
							icon: 'none',
							duration: 2000
						});
						return false;
					}
					let date = this.dateList[this.dateIndex].bookdate;
					let week = this.dateList[this.dateIndex].weekOfDay;
					let time = this.timeList[this.timeIndex].begin + '-' + this.timeList[this.timeIndex].end;
					console.log(week, time);
					const date1 = new Date();
					// 获取今天日期的毫秒数
					const date2 = new Date(date);
					// 计算两个日期的毫秒数差
					const timeDifference = date2.getTime() - date1.getTime();
					// 将毫秒数转换为天数（1天 = 24小时 * 60分钟 * 60秒 * 1000毫秒）
					const daysDifference = Math.ceil(timeDifference / (1000 * 60 * 60 * 24));
					// console.log(`两个日期相差 ${daysDifference} 天`);
					this.setData({
						oneTimeAppoint: date + ' ' + week + ' ' + time,
						choosePopup: false,
						remarkDisable: false,
						isFinishAppoint: true,
						daysDifference: daysDifference
					});


				} else if (this.popupType == 2) {
					//这个0是瞎填的，只是为了不走这个if判断，后期可以删除
					if (this.activeTab === 0) {
						if (this.selectedDateList.length < 1) {
							uni.showToast({
								title: '请选择服务时间',
								icon: 'none',
								duration: 2000
							});
						} else if (this.selectedDateList.length == 1) {
							uni.showToast({
								title: '请选择第二次服务时间',
								icon: 'none',
								duration: 2000
							});
						} else {
							// 选择频次
							let futureDateList = util.getDateList(new Date(new Date().getTime() + 3600000 * 24), 1);
							let minIndex = Math.min.apply(null, this.selectedWeekList);
							console.log(minIndex);
							console.log(this.weekArrList[minIndex].id);
							let beginDate = futureDateList.filter((item) => {
								return new Date(item.date).getDay() == this.weekArrList[minIndex].id;
							});
							console.log(beginDate);
							let inter = 7;
							let firstAppointList = util.getDateList(new Date(new Date(beginDate[0].date).getTime()),
								inter);
							this.setData({
								popupType: 3,
								firstAppointList: firstAppointList
							});
						}
					} else {
						if (this.selectedDateList.length == 0) {
							uni.showToast({
								title: '请选择服务时间',
								icon: 'none',
								duration: 2000
							});
						} else {
							//  选择频次
							let futureDateList = util.getDateList(new Date(new Date().getTime() + 3600000 * 24), 1);
							let minIndex = Math.min.apply(null, this.selectedWeekList);
							console.log(minIndex);
							let beginDate = futureDateList.filter((item) => {
								return new Date(item.date).getDay() == this.weekArrList[minIndex].id;
							});

							let inter = (this.activeTab == 3 ? 14 : this.activeTab == 5 ? util.getNextMonthDays(1) : util
								.getNextMonthDays(1) + util.getNextMonthDays(2));
							let firstAppointList = util.getDateList(new Date(new Date(beginDate[0].date).getTime()),
								inter);
							this.setData({
								popupType: 3,
								firstAppointList: firstAppointList
							});
						}
					}
				} else if (this.popupType == 3) {
					let firstTime = this.firstAppointList[this.firstDateIndex].date;
					console.log(firstTime);
					console.log(this.selectedDateList);

					this.setData({
						choosePopup: false,
						remarkDisable: false,
						isFinishAppoint: true,
						popupType: 2

					});

				}
			},

			orderAppoint() {
				//   如果是多次卡先预估，单次卡不用预估
				let weeks = [];
				this.selectedDateList.forEach((item) => {
					let obj = {
						dayOfWeek: this.weekArrList[item.week].id,
						startTime: item.time.split('-')[0],
						endTime: item.time.split('-')[1]
					};
					weeks.push(obj);
				});
				let params = {
					weeks: weeks,
					type: this.activeTab,
					startDate: this.firstAppointList[this.firstDateIndex].date,
					lng: this.checkedAddress.lng,
					lat: this.checkedAddress.lat,
					shopId: this.checkedAddress.shopId,
					goodId: this.checkedGoodsList[0].goodsId
				};
				uni.showLoading({
					title: '加载中'
				});
				util.request(api.OrderAppoint, params, 'POST')
					.then((res) => {
						uni.hideLoading();
						if (res.errno == 0) {
							// this.orderPay(params);
							this.setData({
								choosePopup: false,
								remarkDisable: false,
								isFinishAppoint: true,
								popupType: 2
							});
						} else {
							uni.showToast({
								title: res.errmsg,
								icon: 'none',
								duration: 2000
							});
						}
					})
					.catch(function(err) {
						console.log(err);
						uni.hideLoading();
						uni.showToast({
							title: err.errMsg,
							icon: 'none'
						});
					});
			},

			cancelPay() {
				this.setData({
					payFailShow: false,
					remarkDisable: false
				});
				uni.navigateBack({
					delta: 1
				});
			},

			rePay() {
				uni.showLoading({
					title: '支付中'
				});
				this.setData({
					payFailShow: false,
					remarkDisable: false
				});
				util.request(
						api.OrderPrepay, {
							orderId: this.orderId
						},
						'POST'
					)
					.then((res) => {
						if (res.errno === 0) {
							const payParam = res.data;
							console.log('支付过程开始');
							uni.requestPayment({
								timeStamp: payParam.timeStamp,
								nonceStr: payParam.nonceStr,
								package: payParam.packageValue,
								signType: payParam.signType,
								paySign: payParam.paySign,
								success: (res) => {
									console.log('支付过程成功');
									uni.redirectTo({
										url: '/pages/checkout/payResult/payResult?status=1&orderId=' +
											this.orderId + '&actualPrice=' + this.actualPrice
									});
								},
								fail: (res) => {
									console.log('支付过程失败');
									util.showErrorToast('支付失败');
								},
								complete: (res) => {
									uni.hideLoading();
									console.log('支付过程结束');
								}
							});
						} else {
							uni.hideLoading();
						}
					})
					.catch((res) => {
						uni.hideLoading();
					});
			},

			goBuyMember() {
				uni.navigateTo({
					url: '/pages/member/buyMember/buyMember'
				});
			},


			getDayTime() {
				let params = {
					days: 30,
					productId: this.checkedGoodsList[0].productId,
					serviceDuration: this.serviceDuration,
					isPreOrder: this.isPreOrder,
					addressId: this.checkedAddress.id
				};

				let addressId = params.addressId;
				if (!addressId || addressId === 'null' || addressId === 'undefined') {
					delete params.addressId
				}


				uni.showLoading({
					title: '加载中'
				});
				util.request(api.everyDayTime, params, 'GET')
					.then((res) => {
						uni.hideLoading();
						if (res.errno == 0) {
							this.setData({
								dateList: res.data,
								dateIndex: 0,
								timeIndex: -1,
								noonType: 1
							});
							let period = res.data[0].period;
							let list = period.filter((item) => {
								return item.ofTime == '上午';
							});
							this.setData({
								timeList: list
							});
						} else {
							uni.showToast({
								title: res.errmsg,
								icon: 'none',
								duration: 2000
							});
							this.setData({
								timeList: [],
								timeIndex: ''
							});
						}
					})
					.catch(function(err) {
						console.log(err);
						uni.hideLoading();
						uni.showToast({
							title: err.errMsg,
							icon: 'none',
							duration: 1000
						});
						this.setData({
							timeList: [],
							timeIndex: ''
						});
					});
			},
			//优先选择上一单服务者
			chooseLastOrder() {
				this.setData({
					isPreOrder: !this.isPreOrder
				})
				console.log("isProOrder", this.isPreOrder);
			},
			onClickHide() {
				this.setData({
					showOverLay: false
				})
			},
			previewImage(e) {
				uni.previewImage({
					// 需要预览的图片链接列表
					urls: [],
					// 为当前显示图片的链接/索引值
					current: 'https://mall.zhaijieshi.cc/file/wx-huawang/er-code.png',
					// 图片指示器样式	
					indicator: 'default',
					// 是否可循环预览
					loop: false,
					// 长按图片显示操作菜单，如不填默认为保存相册
					// longPressActions:{
					// 	itemList:[this.l('发送给朋友'),this.l]
					// },
					success: res => {
						console.log('res', res);
					},
					fail: err => {
						console.log('err', err);
					}
				})
			}
		}
	};
</script>
<style>
	page {
		height: 100%;
		background: #f4f4f4;
	}

	.container {
		padding: 50rpx 28rpx 180rpx;
	}

	.address-box {
		width: 100%;
		border-radius: 20rpx;
	}

	.address-item {
		display: flex;
		background: #fff;
		padding: 36rpx 16rpx 32rpx;
		border-radius: 20rpx;
	}

	.address-item.address-empty {
		line-height: 75rpx;
		text-align: center;
	}

	.address-item .map-icon {
		width: 28rpx;
		height: 28rpx;
		margin: 0 18rpx 0 0;
	}

	.address-box .l {
		width: 125rpx;
		height: 100%;
	}

	.address-box .l .name {
		margin-left: 6.25rpx;
		margin-top: -7.25rpx;
		display: block;
		width: 125rpx;
		height: 43rpx;
		line-height: 43rpx;
		font-size: 30rpx;
		color: #333;
		margin-bottom: 5rpx;
	}

	.address-box .l .default {
		margin-left: 6.25rpx;
		display: block;
		width: 62rpx;
		height: 33rpx;
		border-radius: 5rpx;
		border: 1px solid #b4282d;
		font-size: 20.5rpx;
		text-align: center;
		line-height: 29rpx;
		color: #b4282d;
	}

	.address-box .m {
		flex: 1;
	}

	.address-box .mobile {
		display: block;
		height: 29rpx;
		line-height: 29rpx;
		margin-bottom: 6.25rpx;
		font-size: 26rpx;
	}

	.address-box .address {
		display: block;
		/* height: 30rpx; */
		line-height: 30rpx;
		font-size: 26rpx;
		margin: 0 0 18rpx 0;
	}

	.address-bottom {
		color: #85868a;
		line-height: 24rpx;
		height: 24rpx;
		font-size: 22rpx;
	}

	.address-bottom .user-name {
		margin: 0 32rpx 0 0;
	}

	.address-box .r {
		width: 77rpx;
		height: 77rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.address-box .r image {
		width: 52.078rpx;
		height: 52.078rpx;
	}

	.coupon-box {
		width: 100%;
		height: 210rpx;
		background: #fff;
		border-radius: 20rpx;
		margin-top: 20rpx;
	}

	.coupon-box .coupon-item {
		margin: 0 10rpx;
		height: 70rpx;
		overflow: hidden;
		background: #fff;
		display: flex;
		padding: 0 20rpx 0 10rpx;
		align-items: center;
		justify-content: space-between;
		border-bottom: 2rpx solid #e4e4e4;
		color: #999;
	}

	.coupon-box .l {
		flex: 1;
		height: 70rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		color: #999;
	}

	.coupon-box .l .name {
		font-size: 24rpx;
	}

	.coupon-box .l .txt {
		font-size: 24rpx;
	}

	.coupon-box .r {
		width: 30rpx;
		height: 40rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.coupon-box .r image {
		width: 52.078rpx;
		height: 52.078rpx;
	}

	.message-box {
		margin-top: 20rpx;
		width: 100%;
		height: auto;
		overflow: hidden;
		background: #fff;
	}

	.message-box .message-item {
		height: 86.078rpx;
		overflow: hidden;
		background: #fff;
		display: flex;
		margin-left: 31.25rpx;
		padding-right: 31.25rpx;
	}

	.message-box .message-app {
		height: 74.078rpx;
		overflow: hidden;
		background: #fff;
		display: flex;
		margin-left: 31.25rpx;
		padding-right: 31.25rpx;
		padding-top: 18rpx;
		border-radius: 20rpx;
	}

	.order-box {
		margin-top: 20rpx;
		width: 100%;
		height: auto;
		overflow: hidden;
		background: #fff;
		border-radius: 20rpx !important;
	}

	.order-box .order-item {
		height: 94rpx !important;
		color: #999;
		overflow: hidden;
		background: #fff;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 20rpx;
		border-bottom: 1px solid #d9d9d9;
	}

	.order-box .order-item.tip-item {
		padding-bottom: 26rpx;
		height: auto;
		display: flex;
		flex-direction: column;
	}

	.order-box .order-item .l {
		width: 100rpx;
		height: 70rpx;
		line-height: 70rpx;
		align-items: center;
	}

	.order-box .order-item .l .name {
		font-size: 24rpx;
	}

	.order-box .order-item .r {
		line-height: 70rpx;
		flex: 1;
		height: 70rpx;
		line-height: 70rpx;
		align-items: center;
		text-align: right;
	}

	.order-box .order-item.no-border {
		border-bottom: none;
	}

	.goods-items {
		background: #fff;
		border-radius: 20rpx;
		padding: 20rpx 12rpx;
	}

	.goods-items .item {
		height: 210rpx;
		align-items: center;
	}

	.goods-items .item .name {
		font-size: 28rpx;
		line-height: 32rpx;
		color: #2a2a2a;
	}

	.goods-items .item.no-border {
		border-bottom: none;
	}

	.goods-items .item:last-child {
		border-bottom: none;
	}

	.goods-items .img {
		height: 178rpx;
		width: 178rpx;
		margin-right: 26rpx;
		border-radius: 10rpx;
	}

	.goods-items .img image {
		height: 178rpx;
		width: 178rpx;
		border-radius: 10rpx;
	}

	.goods-items .info {
		flex: 1;
		height: 210rpx;
		padding: 14rpx 0 0;
	}

	.goods-items .t {
		height: 33rpx;
		line-height: 33rpx;
		margin-bottom: 10rpx;
		overflow: hidden;
		font-size: 30rpx;
		color: #333;
	}

	.goods-items .t .name {
		display: block;
		float: left;
	}

	.goods-items .t .number {
		display: block;
		float: right;
		text-align: right;
	}

	.goods-items .m {
		height: 28rpx;
		overflow: hidden;
		line-height: 28rpx;
		margin-bottom: 16rpx;
		font-size: 24rpx;
		color: #85868a;
		margin-top: 5rpx;
	}

	.goods-items .b {
		height: 28rpx;
		line-height: 28rpx;
		font-size: 24rpx;
		color: #85868a;
	}

	.order-total {
		position: fixed;
		left: 0;
		bottom: 0;
		height: 100rpx;
		width: 100%;
		display: flex;
	}

	.order-total .l {
		flex: 1;
		height: 100rpx;
		line-height: 100rpx;
		color: #b4282d;
		background: #fff;
		font-size: 33rpx;
		padding-left: 31.25rpx;
		border-top: 1rpx solid rgba(0, 0, 0, 0.2);
		border-bottom: 1rpx solid rgba(0, 0, 0, 0.2);
	}

	.order-total .r {
		width: 233rpx;
		height: 100rpx;
		background: #b4282d;
		border: 1px solid #b4282d;
		line-height: 100rpx;
		text-align: center;
		color: #fff;
		font-size: 30rpx;
	}

	.actual-price {
		color: #2a2a2a;
		font-size: 32rpx;
		text-align: right;
		margin: 14rpx 0 0;
	}

	.actual-price text {
		color: #df1717;
	}

	.coupon-price {
		color: #FF4545;
		font-size: 25rpx;
		text-align: right;
		margin: 52rpx 0 20rpx 0;
	}

	.go-pay-wrapper {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		height: 130rpx;
		padding: 20rpx 24rpx;
		z-index: 100;
	}

	view.go-pay-wrapper button>view {
		color: #fff;
	}

	.appoint-time-block {
		margin-top: 20rpx;
		background: #fff;
		border-radius: 20rpx;
	}

	.appoint-time-block view.appoint-time-operate {
		background: #FFFFFF;
		border-radius: 20rpx;
		border: 2rpx solid #D77958;
		padding: 20rpx 34rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-size: 24rpx;
	}

	view.operate-left {
		color: #999999;
	}

	view.operate-right {
		display: flex;
		align-items: center;
	}

	view.operate-right {
		color: #d77958;
	}

	view.operate-right .not-select {
		color: #333;
	}

	.appoint-time-show {
		border-top: 2rpx solid #e4e4e4;
		padding: 0 24rpx;
		font-size: 24rpx;
	}

	view.one-time {
		height: 70rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	view.one-time text {
		color: #999;
		font-size: 26rpx;
	}

	.multi-times {
		padding: 30rpx 0;
	}

	.multi-times-item {
		height: 54rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.multi-times-item text {
		font-weight: bold;
		font-size: 24rpx;
	}

	view.appoint-result {
		margin-top: 18rpx;
		border: 2rpx solid #d77958;
		border-radius: 20rpx;
		line-height: 46rpx;
		font-size: 26rpx;
		padding: 10rpx;
	}

	.orange-font {
		color: #fa6400;
		font-weight: bold;
		font-size: 26rpx;
	}

	.order-item .message-item {
		color: #2a2a2a;
		font-size: 24rpx;
		font-weight: normal;
		height: 70rpx;
	}


	/* 支付失败弹框 */
	.overlay-wrapper {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
	}

	.fail-wrapper {
		width: 652rpx;
		height: 580rpx;
		border-radius: 22rpx;
		background-color: #fff;
		background-size: 100% 40%;
		position: relative;
		font-size: 24rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	.fail-wrapper .bgimg {
		width: 100%;
		height: 260rpx;
		display: block;
	}

	.fail-wrapper .ccimg {
		position: absolute;
		top: 50rpx;
		left: 248rpx;
		width: 161rpx;
		height: 161rpx;
	}

	.fail-top {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.er-code {
		width: 240rpx;
		height: 280rpx;
		margin: 20rpx auto;
	}

	.er-code .image {
		width: 220rpx;
		height: 220rpx;
		margin: auto;
	}

	.er-code .image image {
		width: 100%;
		height: 100%;
	}

	.er-code .addwx {
		width: 240rpx;
		color: #c2c2c2;
		margin: 14rpx auto;
		height: 30rpx;
		line-height: 30rpx;
		font-size: 28rpx;
		text-align: center;
	}

	.er-code .addwx .tipcontent {
		width: 96rpx;
		height: 32rpx;
		position: absolute;
		top: 700rpx;
	}

	.fail-text {
		font-size: 34rpx;
		font-weight: bold;
		margin: 4rpx 0 40rpx;
		height: 34rpx;
	}

	.fail-bottom {
		height: 132rpx;
		display: flex;
		justify-content: space-around;
		align-items: center;
	}

	.cancel-btn {
		width: 250rpx;
		height: 72rpx;
		line-height: 72rpx;
		border: 2rpx solid #85868a;
		color: #282728;
		border-radius: 72rpx;
		text-align: center;
	}

	.repay-btn {
		width: 250rpx;
		height: 72rpx;
		line-height: 72rpx;
		/* background: #d77958; */
		color: #d77958;
		border-radius: 72rpx;
		text-align: center;
		border: 1rpx solid #d77958;
	}

	.fail-bottom .btn {
		border: #C2C2C2 2rpx solid;
		border-radius: 48rpx;
		color: #C2C2C2;
		width: 240rpx;
		height: 80rpx;
		text-align: center;
		font-size: 28rpx;
		line-height: 80rpx;
	}

	.discount-title {
		height: 70rpx;
		background: #feebd7;
		padding: 0 10rpx;
		display: flex;
		align-items: center;
		border-radius: 20rpx 20rpx 0rpx 0rpx;
	}

	.discount-title image {
		width: 24rpx;
		height: 26rpx;
		margin: 0 8rpx 0 0;
	}

	.discount-title text {
		font-size: 28rpx;
		font-weight: bold;
		color: #323232;
	}

	.discount-line {
		padding: 0 50rpx 0 20rpx;
	}

	.discount-line .txt {
		color: #df1717;
		font-size: 24rpx;
	}

	.member-benefit,
	.buy-member {
		margin: 20rpx 0 0;
		height: 70rpx;
		background: #fff;
		border-radius: 10rpx;
		padding: 0 20rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.member-benefit .member-tip {
		text-align: right;
	}

	.member-tag {
		width: 142rpx;
		padding: 0 10rpx;
		height: 44rpx;
		line-height: 44rpx;
		text-align: center;
		background: #2e3235;
		border-radius: 5rpx;
	}

	.member-tag text {
		font-size: 24rpx;
		color: #2a2a2a;
		background: linear-gradient(177deg, #f1e3c8 0%, #e6c162 100%);
		-webkit-background-clip: text;
		-webkit-text-fill-color: transparent;
	}

	.member-tip {
		flex: 1;
		margin: 0 0 0 26rpx;
		color: #df1717;
		font-size: 24rpx;
	}

	.stock-text {
		font-size: 20rpx;
		font-weight: normal;
		color: #888;
	}

	.zero-stock {
		color: #ccc;
	}

	.order-box.code-module {
		border-radius: 10rpx;
		padding: 8rpx 0;
	}

	.codeTips {
		height: 52rpx;
		line-height: 40rpx;
		padding-bottom: 20rpx;
		color: #d77958;
		font-size: 26rpx;
		text-align: right;
		padding: 0 20rpx;
	}

	.codeTips.no-match {
		color: #fa6400;
	}

	.plus-order {
		margin-top: 20rpx;
		width: 694rpx;
		border-radius: 10rpx;
		height: 100rpx;
		display: flex;
		padding: 0 20rpx;
		background: #fff;
		align-items: center;
	}

	.plus-order .plus-title {
		color: #999;
	}

	.plus-order .plus-name {
		flex: 1;
		margin: 0 20rpx;
		font-size: 30rpx;
		color: #333;
	}

	.plus-name .plus-num {
		color: #d77958;
		font-size: 30rpx;
		font-weight: bold;
	}

	.plus-amount {
		color: #d77958;
		font-size: 32rpx;
		font-weight: bold;
	}


	.popup-title-new view {
		color: #333;
		font-size: 32rpx;
	}

	.popup-title-new view.fee-tips {
		color: #ff5735;
		font-size: 22rpx;
	}

	.time-select-right-item text {
		color: #888;
	}

	.time-select-right .time-item-wrapper {
		height: 836rpx;
		overflow-y: scroll;
	}

	.time-line {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 100%;
	}

	.time-select-right-item text.extra-tips {
		color: #ff5735;
		font-size: 22rpx;
	}

	.van-tab--active.van-tab>view.van-ellipsis {
		color: #d77958;
	}

	.van-tab>view.van-ellipsis {
		font-size: 36rpx;
		color: #ABABAB;
		font-family: AlibabaPuHuiTi_2_85_Bold;
	}

	.appoint-server {
		border-radius: 18rpx;
		background-color: #fff;
		height: 80rpx;
		line-height: 80rpx;
		padding: 0 24rpx;
		color: #999;
		display: flex;
		margin-top: 28rpx;
		justify-content: space-between;
		align-items: center;
	}

	.appoint-server .server-tip {
		color: #999;
		font-size: 26rpx;
		flex: 1;
		text-align: left;
	}

	.appoint-server .radio-img {
		width: 26rpx;
		height: 26rpx;
	}

	/* 时间弹窗相关 */
	.week-select-left {
		display: flex;
		justify-content: space-around;
		text-align: center;
	}

	.popup-wrapper view {
		color: #888;
		font-size: 30rpx;
	}

	.popup-content {
		flex: 1;
	}


	.appointment-tips {
		display: flex;
		justify-content: space-between;
		width: 178px;
		/* margin: 170px auto 10px; */
		position: absolute;
		bottom: 62rpx;
		left: calc(50% - 89px);
	}

	.appointment-tips1 {
		position: absolute;
		bottom: 120rpx;
	}

	.appointment-tips view span {
		width: 20rpx;
		height: 20rpx;
		border-radius: 20rpx;
		background-color: #feebd7;
		display: inline-block;
		margin-right: 10rpx;
	}

	.appointment-tips view .selected {
		background-color: #d77958;
	}

	.appointment-tips view .no-appointment {
		background-color: #ccc;
	}

	.appointment-tips view text {
		color: #d77958;
		font-size: 24rpx;
	}

	.time-select-bottom {
		width: 100vw;
		background-color: #feebd7;
		height: 54rpx;
		font-size: 22rpx !important;
		color: #d77958 !important;
		line-height: 54rpx;
		padding-left: 30rpx;
		position: absolute;
		bottom: 0;
		letter-spacing: 2rpx;
	}

	.time-select-bottom1 {
		width: 100vw;
		background-color: #feebd7;
		height: 54rpx;
		font-size: 22rpx !important;
		color: #d77958 !important;
		line-height: 54rpx;
		padding-left: 30rpx;
		position: absolute;
		bottom: 55rpx;
	}

	.time-select-bottom2 {
		width: 100vw;
		background-color: #feebd7;
		height: 54rpx;
		font-size: 22rpx !important;
		color: #d77958 !important;
		line-height: 54rpx;
		padding-left: 30rpx;

		letter-spacing: 2rpx;
	}

	.time-select-left {
		padding: 0 8rpx 0 20rpx;
		width: 370rpx;
	}

	.time-select-right {
		flex: 1;
		display: flex;
		justify-content: space-between;
	}

	.scroll-view_H {
		white-space: nowrap;
		/* 确保子元素在同一行内显示 */
		overflow-x: scroll;
		/* 允许横向滚动 */
	}

	.time-select-left-item {
		height: 100rpx;
		display: flex;
		flex-direction: column;
		padding: 4rpx 0;
		width: 20vw;
		justify-content: center;
		align-items: center;
	}

	.date-line-wrapper {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.time-select-left-item .date-msg {
		height: 36rpx;
		line-height: 36rpx;
		color: #292929;
		font-size: 36rpx;
		font-weight: bold;
	}

	.time-select-left-item .date-msg1 {
		/* height: 36rpx;
		line-height: 36rpx; */
		color: #292929;
		font-size: 22rpx;
		margin-top: 10rpx;
		margin-bottom: 4rpx;
	}

	.time-select-left-item .date-msg.avail-date {
		color: #999 !important;
		font-weight: bold;
	}

	.time-select-left-item .date-msg1.avail-date {
		color: #999 !important;
		font-weight: bold;
	}

	.popup-wrapper .popup-content .current-date {
		color: #d77958;
		/* font-weight: bold; */
	}

	view.popup-btn-wrapper {
		margin: 10rpx auto;
		/* padding: 24rpx; */
		background-color: #d77958;
		text-align: center;
		width: 682rpx;
		border-radius: 16rpx;
	}

	view.popup-btn-wrapper view {
		color: #fff;
	}

	.time-select-middle {
		background-color: #FCFCFC;
		padding: 10rpx 0rpx;
		height: 800rpx;
		position: relative;
	}

	.noon-select {
		width: 100%;
		display: flex;
		justify-content: center;
		margin: 30rpx auto;
	}

	.noon-select .divider {
		height: 40rpx;
		width: 2rpx;
		background-color: #e5e5e5;
	}

	.noon-select .noon-item {
		text-align: center;
		color: #979797;
		font-size: 36rpx;
		width: 49%;
	}

	.noon-itemactive-noon {
		text-align: center;
		color: #d77958 !important;
		font-size: 36rpx !important;
		width: 49%;
	}

	.popup-title-new.popup-title {
		display: flex;
		flex-direction: column;
		font-size: 20px;
		font-weight: bold;
		text-align: left;
		padding: 30rpx;

	}

	.popup-title-new view {
		color: #000;
		font-size: 40rpx;
		font-weight: bold;
	}

	.popup-title-new view.fee-tips {
		color: #d77958;
		font-size: 22rpx;
	}


	.current-line {
		width: 38rpx;
		height: 6rpx;
		background: #d77958;
		border-radius: 8rpx;
		margin: auto;
		opacity: 1;
	}

	.current-line0 {
		width: 38rpx;
		height: 6rpx;
		background: #d77958;
		border-radius: 3rpx;
		margin: auto;
		opacity: 0 !important;
	}

	.current-time {
		color: #fff !important;
		font-family: AlibabaPuHuiTi_2_65_Medium;
		line-height: 70rpx;
		height: 70rpx;
		background-color: #d77958;
		border-radius: 8px;
		font-size: 36rpx;
	}


	.time-item-wrapper {
		display: flex;
		width: 90vw;
		justify-content: flex-start;
		flex-wrap: wrap;
		text-align: center;
		gap: 20px;
		margin: 10px auto;
	}


	.time-item-wrapper .time-msg {
		width: 20%;
		line-height: 70rpx;
		height: 70rpx;
		background-color: #feebd7;
		border-radius: 8px;
		font-size: 36rpx;
		font-weight: bold;
	}

	.time-item-wrapper .avail-time {
		width: 20%;
		line-height: 70rpx;
		height: 70rpx;
		background-color: #CCCCCC !important;
		border-radius: 8px;
		font-size: 36rpx;
		font-weight: bold;
	}

	.first-appoint-date-item {
		height: 108rpx;
		display: flex;
		align-items: center;
		padding: 0 0 0 240rpx;
		font-family: AlibabaPuHuiTi_2_85_Bold;
	}

	.first-appoint-date-item view {
		font-family: AlibabaPuHuiTi_2_85_Bold;
	}

	.first-time-selected {
		margin: 0 0 0 60rpx;
	}

	.week-str {
		font-family: AlibabaPuHuiTi_2_85_Bold;
		font-size: 36rpx !important;
		color: #C2C2C2;
	}

	.time-select-right-item {
		width: 45vw;
		background-color: #feebd7;
		text-align: center;
		margin-bottom: 28rpx;
		font-family: AlibabaPuHuiTi_2_65_Medium;
		line-height: 70rpx;
		height: 70rpx;
		border-radius: 8px;
	}

	.time-select-right-a {
		padding: 10rpx 24rpx;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		align-content: flex-start;
	}

	.first-appoint-date-list {
		background-color: #fafafa;
	}

	.select-week-date {
		display: inline-block;
		width: 2px;
		height: 10px;
		background-color: #d77958;
		position: relative;
		top: 1px;
		margin: 0 5px;
	}
</style>