<template>
	<view>
		<page-meta :page-style="'overflow:'+(ifShowPageMeta?'hidden':'visible')"></page-meta>
		<!-- 顶部操作条 -->
		<cu-custom :bgColor="'bg-main-color'" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">{{order.orderType === 0 ? '服务订单详情' : '商品订单详情'}}</block>
		</cu-custom>
		<!-- 任务进度跟踪 -->
		<view class="bg-white margin-lr-sm padding-lr padding-bottom margin-top-sm">
			<uni-collapse  v-if="taskListArr.length">
				<uni-collapse-item :open="true">
					<template v-slot:title>
						<view class="cu-bar">
							<view class="action bar-first-action">
								<text class="cuIcon-titles text-main-color"></text> <text @click.stop="showTaskDetailMdl()">任务进度跟踪</text>
							</view>
						</view>
					</template>
					<view class="cu-timeline">
						<view class="cu-item text-main-color" key="cu-timeline">
							<!-- :class="index === 0 ? 'bg-main-color light' : 'bg-gray'" -->
							<view class="content shadow-blur bg-main-color light" >
								<view>
									<text>{{taskListArr[taskListArr.length-1].content}}</text>
								</view>
								<text>{{taskListArr[taskListArr.length-1].createTime}}</text>
							</view>
						</view>
					</view>
				</uni-collapse-item>
			</uni-collapse>
		</view>
		<!-- 服务单概况 -->
		<view class="bg-white margin-lr-sm margin-top-sm padding">
			<view class="flex align-center">
				<text class="text-xl margin-right">{{servDetail.goodsName}}</text>
				<view class='cu-tag bg-purple radius light margin-right-sm' v-if="servDetail.orderStatus === 5">已完成</view>
				<view class='cu-tag bg-purple radius light margin-right-sm' v-if="servDetail.orderStatus === 4">确认中</view>
				<view class='cu-tag bg-purple radius light margin-right-sm' v-if="servDetail.orderStatus === 3">{{order.orderType === 0 ? '服务中' : '发货中'}}</view>
				<view class='cu-tag bg-purple radius light margin-right-sm' v-if="servDetail.orderStatus === 2">{{order.orderType === 0 ? '待上门' : '待发货'}}</view>
				<view class='cu-tag bg-purple radius light margin-right-sm' v-if="servDetail.orderStatus === 1">{{order.orderType === 0 ? '未约/未排' : '拣货/发货'}}</view>
				<view class='cu-tag bg-grey radius light margin-right-sm' v-if="servDetail.orderStatus === 6">已取消</view>
			</view>
			<!-- <view class="margin-top-sm">
				<view v-for="(item, index) in servDetail.mainServOrder.orderTag" class='cu-tag radius margin-right-sm'>
					{{item}}</view>
			</view> -->
			<view class="margin-top-sm">
				<text class="cuIcon-location text-main-color margin-right-xs"></text>
				<text><text class="labels">服务地址：</text>{{servDetail.provinceName + servDetail.cityName + servDetail.countryName + servDetail.streetName + servDetail.address}}</text>
			</view>
			<view class="margin-top-sm">
				<text class="cuIcon-people text-main-color margin-right-xs"></text>
				<text class="margin-right-sm"><text class="labels">客户：</text>{{servDetail.customerName}}</text>
				<text v-if="servDetail.customerPhone">{{servDetail.customerPhone.substring(0, 3) + "****" + servDetail.customerPhone.substring(7)}}</text>
				<button class="cu-btn line-main-color sm" v-if="servDetail.orderStatus !== 1" @click="makeCustomerPhoneCall(servDetail)">拨打</button>
			</view>
			
			<view class="margin-top-sm" v-if="servDetail.goodsOrderMasterId">
				<text class="cuIcon-friendfamous text-main-color margin-right-xs"></text>
				<text class="margin-right-sm"><text class="labels">派单公司：</text>{{servDetail.masterCompanyName}}</text>
				<text class="margin-right-xs">{{servDetail.masterCompanyPhone}}</text>
				<button class="cu-btn line-main-color sm" @click="makePhoneCall(servDetail.masterCompanyPhone)">拨打</button>
			</view>
			<view class="margin-top-sm" v-else-if="servDetail.orderDetailId">
				<text class="cuIcon-friendfamous text-main-color margin-right-xs"></text>
				<text class="margin-right-sm"><text class="labels">派单公司：</text>{{servDetail.masterCompanyName}}</text>
				<text class="margin-right-xs">{{servDetail.masterWorkerPhone}}</text>
				<button class="cu-btn line-main-color sm" @click="makePhoneCall(servDetail.masterWorkerPhone)">拨打</button>
			</view>
			<!-- <view class="margin-top-sm" v-else-if="servDetail.masterCompanyName && servDetail.masterWorkerPhone">
				<text class="cuIcon-friendfamous text-main-color margin-right-xs"></text>
				<text class="margin-right-sm"><text class="labels">派单公司：</text>{{servDetail.masterCompanyName}}</text>
				<text class="margin-right-xs">{{servDetail.masterWorkerPhone}}</text>
				<button class="cu-btn line-main-color sm" @click="makePhoneCall(servDetail.masterWorkerPhone)">拨打</button>
			</view> -->
			<template v-if="order.orderType === 0">
				<view class="margin-top-sm">
					<text class="cuIcon-time text-main-color margin-right-xs"></text>
					<text v-if="servDetail.expectTimeEndFront"><text class="labels">预约时间：</text>{{servDetail.expectTimeStartFront + '~' + servDetail.expectTimeEndFront}}</text>
					<text v-else><text class="labels">预约时间：</text>{{servDetail.expectTimeStartFront}}</text>
				</view>
				<!-- <view class="margin-top-sm">
					<text class="cuIcon-time text-main-color margin-right-xs"></text>
					<text>排单时间：{{servDetail.mainServOrder.boodTime}}</text>
				</view> -->
				<view class="margin-top-sm" v-if="servDetail.orderDetailId != null && servDetail.orderStatus >= 3">
					<text class="cuIcon-time text-main-color margin-right-xs"></text>
					<text><text class="labels">上门时间：</text>{{servDetail.workBeginTime}}</text>
				</view>
			</template>
			<!-- <view class="margin-top-sm" v-if="servDetail.orderDetailId == null && servDetail.orderMode == '02'">
				<text class="cuIcon-moneybag text-main-color margin-right-xs"></text>
				<text>订单金额：</text>
				<text class="text-price">{{servDetail.totalMoney}}</text>
			</view> -->
			<!-- <view class="margin-top-sm" v-if="servDetail.customerRemark">
				<text class="cuIcon-message text-main-color margin-right-xs"></text>
				<text><text class="labels">备注：</text>{{servDetail.customerRemark}}</text>
			</view> -->
			<view class="margin-top-sm">
				<text class="cuIcon-moneybag text-main-color margin-right-xs"></text>
				<text class="labels">{{order.orderType === 0 ? '服务金额' : '货品金额'}}：</text>
				<text class="text-price" v-if="servDetail.orderDetailId != null">
					{{servDetail.payAddMoney}}
					<text v-if="servDetail.payType === 1 && servDetail.financialChangeRecords && servDetail.financialChangeRecords.length > 0">【订单加价，单独到账】</text>
					<text v-else-if="servDetail.payType === 0 && servDetail.financialChangeRecords && servDetail.financialChangeRecords.length > 0">【订单加价，合并到账】</text>
				</text>
				<text class="text-price" v-else>{{servDetail.serverMoney}}</text>
			</view>
			<!-- <view class="text-sm text-gray margin-left-lg" 
				v-if="servDetail.orderDetailId != null && servDetail.timeout == 1">
				<text>加减费用：<text class="text-price margin-top-xs">-3</text>
				[
				<text v-if="servDetail.orderStatus === 0">接单</text>
				<text v-else-if="servDetail.orderStatus === 1">预约</text>
				<text v-else-if="servDetail.orderStatus === 2">上门</text>
				<text v-else-if="servDetail.orderStatus === 3">完单</text>
				超时]
				</text>
			</view>
			<view class="text-sm text-gray margin-left-lg" v-if="servDetail.orderDetailId != null && servDetail.financialChangeRecords != null"
				v-for="(item, index) in servDetail.financialChangeRecords" :key="index">
				<text v-if="item.payStatus === 1">加减费用：<text class="text-price margin-top-xs">+{{item.changeMoney}}</text>[订单加价]</text>
			</view> -->
			
			
		</view>
		
		<!-- 下单备注 暂时注释, 客户说的不显示 -->
		<view v-if="servDetail.customerRemark || servDetail.orderImages" class="bg-white margin-lr-sm padding margin-top-sm">
			<view v-if="servDetail.orderImages">
				<view class="grid col-3 grid-square flex-sub">
					<view class="bg-img" v-for="imgUrl in servDetail.orderImages.split(',')" :key="imgUrl">
						<image :src="imgUrl" @tap="viewImage($event, [imgUrl])" :data-url="imgUrl" mode="aspectFill">
						</image>
					</view>
				</view>
			</view>
			<view>订单备注: {{servDetail.customerRemark}}</view>
		</view>
		
		
		<!-- 待服务列 -->
		<view class="bg-white margin-lr-sm padding-lr padding-bottom margin-top-sm">
			<view class="cu-bar solid-bottom">
				<view class="action bar-first-action">
					<text class="cuIcon-titles text-main-color"></text> 商品信息
				</view>
			</view>
			<view class="margin-top-sm">
				<product-picked :product="servDetail" :pickedList="servDetail.standardList" :columnTitleArr="servingColumnHeaders" :valFieldArr="servingValFields"></product-picked>
			</view>
		</view>
		
		<view class="bg-white margin-lr-sm padding-lr margin-top-sm padding" v-if="servDetail.serviceShop">
			<template v-if="servDetail.goodsOrderMasterId && servDetail.masterWorkerName && servDetail.masterWorkerPhone && (servDetail.originalWorkerId == curUserInfo.workerId)">
				<view class="cu-bar solid-bottom">
					<view class="action bar-first-action">
						<text class="cuIcon-titles text-main-color"></text> 服务记录
					</view>
					<view>
						<view class="cu-btn sm bg-main-color margin-right-sm shadow-blur" v-if="[0,1,2,3].indexOf(servDetail.orderStatus) >= 0" @click="cancelMasterOrder(servDetail)">撤单</view>
						<view class='cu-tag bg-purple radius light margin-right-sm' v-if="servDetail.orderStatus === 5">已完成</view>
						<view class='cu-tag bg-purple radius light margin-right-sm' v-if="servDetail.orderStatus === 4">待确认</view>
						<view class='cu-tag bg-purple radius light margin-right-sm' v-if="servDetail.orderStatus === 3">服务中</view>
						<view class='cu-tag bg-purple radius light margin-right-sm' v-if="servDetail.orderStatus === 2">待上门</view>
						<view class='cu-tag bg-purple radius light margin-right-sm' v-if="servDetail.orderStatus === 1">未约/未排</view>
						<view class='cu-tag bg-purple radius light margin-right-sm' v-if="servDetail.orderStatus === 0">待接单</view>
					</view>
				</view>
				<view class="float-clear"></view>
				<view class="margin-top-sm">师傅：{{servDetail.masterWorkerName}}</view>
				<view class="margin-top-sm margin-bottom-lg">
					<text class="margin-right-xs">联系方式：{{servDetail.masterWorkerPhone}}</text>
					<button class="cu-btn line-main-color sm" @click="makePhoneCall(servDetail.masterWorkerPhone)">拨打</button>
				</view>
			</template>
			<view class="text-black text-bold flex justify-between">
				<text>安装/服务/施工门店</text>
				<!-- <text @click="goChooseShop">更多></text> -->
			</view>
			<view class="flex-sub flex margin-top-sm" @click="openShopLocation(servDetail.serviceShop)">
				<view style="width: 150rpx;height: 150rpx;margin-right:10px;">
					<image style="width: 100%;height: 100%;" :src="servDetail.serviceShop.imageUrl" mode="aspectFill"></image>
				</view>
				<view class="flex-sub">
					<view class="text-bold" style="text-overflow: ellipsis;overflow: hidden;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 1;">
					客户已选: {{servDetail.serviceShop.shopName}}
					</view>
					<view class="padding-tb-xs" style="position: relative;">
						<view class="margin-lr-sm" style="display: inline-block;" v-if="servDetail.serviceShop.distance">
							<view class="cu-tag bg-red" style="padding: 0 2px;height: auto;">距离客户</view>
							<text class="text-gray" style="vertical-align: middle;">{{servDetail.serviceShop.distance}}</text>
						</view>
						<image src="/static/navigation.png" style="width: 50rpx;height: 50rpx;display: inline-block;position: absolute;top: 5px;right: -10px;"></image>
					</view>
					<view style="text-overflow: ellipsis;overflow: hidden;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 1;">{{servDetail.serviceShop.provinceName + servDetail.serviceShop.cityName + servDetail.serviceShop.countryName + servDetail.serviceShop.streetName + servDetail.serviceShop.address}}</view>
					<view class="flex justify-between align-center margin-bottom-xs padding-top">
						<view>
							<text class="text-bold text-lg margin-lr-xs">店长：{{servDetail.serviceShop.phone}}</text>
						</view>
						<button class="cu-btn line-main-color" @click.stop="makePhoneCall(servDetail.serviceShop.phone)">拨打</button>
					</view>
				</view>
			</view>
		</view>
		<view class="bg-white margin-lr-sm padding-lr margin-top-sm padding" v-else-if="servDetail.shop">
			<template v-if="servDetail.goodsOrderMasterId && (servDetail.originalWorkerId == curUserInfo.workerId)">
				<view class="cu-bar solid-bottom">
					<view class="action bar-first-action">
						<text class="cuIcon-titles text-main-color"></text> 服务记录
					</view>
					<view>
						<view class="cu-btn sm bg-main-color margin-right-sm shadow-blur" v-if="[0,1,2,3].indexOf(servDetail.orderStatus) >= 0" @click="cancelMasterOrder(servDetail)">撤单</view>
						<view class='cu-tag bg-purple radius light margin-right-sm' v-if="servDetail.orderStatus === 5">已完成</view>
						<view class='cu-tag bg-purple radius light margin-right-sm' v-if="servDetail.orderStatus === 4">待确认</view>
						<view class='cu-tag bg-purple radius light margin-right-sm' v-if="servDetail.orderStatus === 3">服务中</view>
						<view class='cu-tag bg-purple radius light margin-right-sm' v-if="servDetail.orderStatus === 2">待上门</view>
						<view class='cu-tag bg-purple radius light margin-right-sm' v-if="servDetail.orderStatus === 1">未约/未排</view>
						<view class='cu-tag bg-purple radius light margin-right-sm' v-if="servDetail.orderStatus === 0">待接单</view>
					</view>
				</view>
				<view class="float-clear"></view>
				<view class="margin-top-sm">师傅：{{servDetail.masterWorkerName}}</view>
				<view class="margin-top-sm margin-bottom-lg">
					<text class="margin-right-xs">联系方式：{{servDetail.masterWorkerPhone}}</text>
					<button class="cu-btn line-main-color sm" @click="makePhoneCall(servDetail.masterWorkerPhone)">拨打</button>
				</view>
			</template>
			<view class="text-black text-bold flex justify-between">
				<text>安装/服务/施工门店</text>
				<!-- <text @click="goChooseShop">更多></text> -->
			</view>
			<view class="flex-sub flex margin-top-sm" @click="openShopLocation(servDetail.shop)">
				<view style="width: 150rpx;height: 150rpx;margin-right:10px;">
					<image style="width: 100%;height: 100%;" :src="servDetail.shop.imageUrl" mode="aspectFill"></image>
				</view>
				<view class="flex-sub">
					<view class="text-bold" style="text-overflow: ellipsis;overflow: hidden;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 1;">
					客户已选: {{servDetail.shop.shopName}}
					</view>
					<view class="padding-tb-xs" style="position: relative;">
						<view class="margin-lr-sm" style="display: inline-block;" v-if="servDetail.shop.distance">
							<view class="cu-tag bg-red" style="padding: 0 2px;height: auto;">距离您</view>
							<text class="text-gray" style="vertical-align: middle;">{{servDetail.shop.distance}}</text>
						</view>
						<image src="/static/navigation.png" style="width: 50rpx;height: 50rpx;display: inline-block;position: absolute;top: 5px;right: -10px;"></image>
					</view>
					<view>{{servDetail.shop.provinceName + servDetail.shop.cityName + servDetail.shop.countryName + servDetail.shop.streetName + servDetail.shop.address}}</view>
					<view class="flex justify-between align-center margin-bottom-xs padding-top">
						<view>
							<text class="text-bold text-lg margin-lr-xs">店长：{{servDetail.shop.phone}}</text>
						</view>
						<button class="cu-btn line-main-color" @click.stop="makePhoneCall(servDetail.shop.phone)">拨打</button>
					</view>
				</view>
			</view>
		</view>
		
		
		
		<!-- 加价记录 子单详情展示 -->
		<view v-if="servDetail.orderDetailId != null && servDetail.financialChangeRecords && servDetail.financialChangeRecords.length > 0" class="bg-white margin-lr-sm padding-lr padding-bottom margin-top-sm">
			<view class="cu-bar solid-bottom">
				<view class="action bar-first-action">
					<text class="cuIcon-titles text-main-color"></text> 加价记录
				</view>
			</view>
			<view class="padding-tb-sm" v-for="addRecord in servDetail.financialChangeRecords" :key="addRecord.id">
				<view>
					<text>加价金额：</text>
					<text>{{addRecord.changeMoney + (addRecord.attachmentMoney || 0)}}</text>
				</view>
				<view v-if="addRecord.reason && addRecord.reason.indexOf('含') > -1">
					<text>{{addRecord.reason.split('含')[1]}}：</text>
					<text>{{addRecord.changeMoney}}</text>
				</view>
				<view>
					<text>加价备注：</text>
					<text v-if="addRecord.remark">{{addRecord.remark}}</text>
				</view>
				<view v-if="addRecord.urls">
					<view class="grid col-3 grid-square flex-sub margin-top-sm">
						<view class="bg-img" v-for="imgUrl in addRecord.urls.split(',')" :key="imgUrl">
							<image :src="imgUrl" @tap="viewImage($event, [imgUrl])" :data-url="imgUrl" mode="aspectFill">
							</image>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 完工图片 子单详情展示 -->
		<view v-if="servDetail.orderDetailId != null && servDetail.orderStatus > 3 && servDetail.finishImgList && servDetail.finishImgList.length" class="bg-white margin-lr-sm padding-lr padding-bottom margin-top-sm">
			<view class="cu-bar solid-bottom">
				<view class="action bar-first-action">
					<text class="cuIcon-titles text-main-color"></text> 完工图片
				</view>
			</view>
			<view class="grid col-3 grid-square flex-sub margin-top-sm">
				<view class="bg-img" v-for="(imgUrl, index) in servDetail.finishImgList" :key="index">
					<image :src="imgUrl" @tap="viewImage($event, [imgUrl])" :data-url="imgUrl" mode="aspectFill"></image>
				</view>
			</view>
			<view>
				<text>备注：{{servDetail.workerRemark}}</text>
			</view>
		</view>
		<view class="bg-white margin-lr-sm padding-lr padding-bottom margin-top-sm" v-if="servDetail.orderDetailId != null && servDetail.afterServiceRecordList && servDetail.afterServiceRecordList.length > 0">
			<view class="cu-bar solid-bottom">
				<view class="action bar-first-action">
					<text class="cuIcon-titles text-main-color"></text> 售后记录
				</view>
			</view>
			<view v-for="(afterServiceRecord, afterServiceRecordIndex) in servDetail.afterServiceRecordList"  :key="afterServiceRecordIndex">
				<afterServiceRecord 
					v-if="order.orderType === 0" 
					:after-service-record="afterServiceRecord" 
					:order="order"
					:showActionBtn="false"
				></afterServiceRecord>
				<afterServiceRecordGoods 
					v-else 
					:after-service-record="afterServiceRecord" 
					:order="order" 
					:showActionBtn="false"
					@getDeliveryFlow="(trackingNumber) => {showDeliveryFlow = true; showDeliveryFlowTrackingNumber = trackingNumber;}"
				></afterServiceRecordGoods>
				<!-- <view v-if="afterServiceRecord.createBy == 1" class="padding-tb-sm solid-top">
					<view class='cu-tag bg-main-color radius light'>售后发起中</view>
					<view v-if="afterServiceRecord.operType === 1">
						<view class="text-gray text-sm margin-bottom-xs">退单退款已提交至商家，其最大时限24小时内需完成操作！</view>
						<view class="flex justify-start align-end">
							<text>退款申请：</text>
							<uni-countdown :show-colon="false" :backgroundColor="'#eee'"
								:day="$dateUtil.countDownDiff($dateUtil.addHours(afterServiceRecord.createTime, 24)).day"
								:hour="$dateUtil.countDownDiff($dateUtil.addHours(afterServiceRecord.createTime, 24)).hour"
								:minute="$dateUtil.countDownDiff($dateUtil.addHours(afterServiceRecord.createTime, 24)).min"
								:second="$dateUtil.countDownDiff($dateUtil.addHours(afterServiceRecord.createTime, 24)).seconds">
							</uni-countdown>
						</view>
						<view>
							<text>退款金额：</text>
							<text>{{afterServiceRecord.refund}}</text>
						</view>
						<view v-if="order.orderType === 1">
							<text>售后类型：</text>
							<text v-if="afterServiceRecord.afterServiceType === 1">未收到货，我要退单退款！</text>
							<text v-else-if="afterServiceRecord.afterServiceType === 2">未收到货（发货在途），我要退款！</text>
							<text v-else-if="afterServiceRecord.afterServiceType === 3">已收到货，我要退款退货！</text>
						</view>
						<view>
							<text>退款原因：</text>
							<template v-if="order.orderType === 1">
								<text v-if="afterServiceRecord.customerReasonType === 1">不想要了</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 2">买错型号尺寸了</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 3">材质与商品描述不符</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 4">大小尺寸与商品描述不符</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 5">颜色、款式、型号与描述不符</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 6">出现质量问题</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 7">收到商品少件（少配件）</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 8">商家发错货</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 9">商品破损或污渍</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 10">未按承诺时间发货</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 11">未见快递/物流有信息</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 12">其它原因</text>
							</template>
							<template v-else>
								<text v-if="afterServiceRecord.customerReasonType === 1">上门/服务不守时</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 2">态度不友好，无法继续</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 3">服务效果差，未达到合格</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 4">技能水平问题，未妥善完成</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 5">要求加费用，费用不合理</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 6">订单拖太久了</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 7">超了些服务内容，师傅不接受</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 8">客户/我时间不方便了</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 9">客户/我已让别的师傅服务了</text>
							</template>
						</view>
						<view>
							<text>具体原因：</text>
							<text v-if="afterServiceRecord.customerReason">{{afterServiceRecord.customerReason}}</text>
						</view>
						<view class="grid col-3 grid-square flex-sub margin-top-sm">
							<view class="bg-img" v-for="(imgObj, imgIndex) in afterServiceRecord.imgsList"
								:key="imgIndex" v-if="imgObj.imgUploadBy === 1">
								<image :src="imgObj.imgUrl" @tap="viewImage($event, [imgObj.imgUrl])"
									:data-url="imgObj.imgUrl" mode="aspectFill"></image>
							</view>
						</view>
						<view>
							<text class="text-red" v-if="!item.isOnlyServ && item.payMoney < afterServiceRecord.refund">警报：退单金额大于该师傅接单金额，但客户发起的退款金额有效，您需介入处理，如让接单师傅系统上操作同意退款，系统最大按该单派单额退回客户，其余需人工处理！如属于师傅责任引起的退单，建议重做，重做后让客户撤消退单！</text>
						</view>
					</view>
					<view v-else-if="afterServiceRecord.operType === 2">
						<view class="text-gray text-sm margin-bottom-xs">售后已提交至商家，其最大时限24小时内需完成操作！</view>
						<view class="flex justify-start align-end">
							<text>待处理售后：</text>
							<uni-countdown :show-colon="false" :backgroundColor="'#eee'"
								:day="$dateUtil.countDownDiff($dateUtil.addHours(afterServiceRecord.createTime, 24)).day"
								:hour="$dateUtil.countDownDiff($dateUtil.addHours(afterServiceRecord.createTime, 24)).hour"
								:minute="$dateUtil.countDownDiff($dateUtil.addHours(afterServiceRecord.createTime, 24)).min"
								:second="$dateUtil.countDownDiff($dateUtil.addHours(afterServiceRecord.createTime, 24)).seconds">
							</uni-countdown>
						</view>
						<view v-if="order.orderType === 1">
							<text>售后类型：</text>
							<text v-if="afterServiceRecord.afterServiceType === 1">未收到货，我要退单退款！</text>
							<text v-else-if="afterServiceRecord.afterServiceType === 2">未收到货（发货在途），我要退款！</text>
							<text v-else-if="afterServiceRecord.afterServiceType === 3">已收到货，我要退款退货！</text>
						</view>
						<view>
							<text>退款原因：</text>
							<template v-if="order.orderType === 1">
								<text v-if="afterServiceRecord.customerReasonType === 1">不想要了</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 2">买错型号尺寸了</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 3">材质与商品描述不符</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 4">大小尺寸与商品描述不符</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 5">颜色、款式、型号与描述不符</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 6">出现质量问题</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 7">收到商品少件（少配件）</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 8">商家发错货</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 9">商品破损或污渍</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 10">未按承诺时间发货</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 11">未见快递/物流有信息</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 12">其它原因</text>
							</template>
							<template v-else>
								<text v-if="afterServiceRecord.customerReasonType === 1">上门/服务不守时</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 2">态度不友好，无法继续</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 3">服务效果差，未达到合格</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 4">技能水平问题，未妥善完成</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 5">要求加费用，费用不合理</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 6">订单拖太久了</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 7">超了些服务内容，师傅不接受</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 8">客户/我时间不方便了</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 9">客户/我已让别的师傅服务了</text>
							</template>
						</view>
						<view>
							<text>具体原因：</text>
							<text v-if="afterServiceRecord.customerReason">{{afterServiceRecord.customerReason}}</text>
						</view>
						<view class="grid col-3 grid-square flex-sub margin-top-sm">
							<view class="bg-img" v-for="(imgObj, imgIndex) in afterServiceRecord.imgsList"
								:key="imgIndex" v-if="imgObj.imgUploadBy === 1">
								<image :src="imgObj.imgUrl" @tap="viewImage($event, [imgObj.imgUrl])"
									:data-url="imgObj.imgUrl" mode="aspectFill"></image>
							</view>
						</view>
					</view>
				</view>
				<view v-if="afterServiceRecord.updateBy == 2" class="padding-tb-sm solid-top">
					<view class='cu-tag bg-main-color radius light'>师傅反馈</view>
					<view v-if="afterServiceRecord.operType === 1">
						<view class="margin-top-xs">
							<text>师傅反馈结果：</text>
							<text v-if="afterServiceRecord.workerFeedbackResult === 0">拒绝</text>
							<text v-else-if="afterServiceRecord.workerFeedbackResult === 1">同意</text>
							<text v-else-if="afterServiceRecord.workerFeedbackResult === 2">重新上门</text>
						</view>
						<view v-if="afterServiceRecord.workerFeedbackResult === 1">
							<text>同意退款金额：</text>
							<text>{{afterServiceRecord.agreedRefund ? afterServiceRecord.agreedRefund : afterServiceRecord.refund}}</text>
						</view>
						<view v-if="afterServiceRecord.workerFeedbackResult !== 2">
							<text>师傅反馈：</text>
							<text v-if="afterServiceRecord.workerFeedbackReasonType === 1">客户原因</text>
							<text v-else-if="afterServiceRecord.workerFeedbackReasonType === 2">师傅原因</text>
							<text v-else>其他</text>
							<text
								v-if="afterServiceRecord.workerFeedbackReason">{{"，" + afterServiceRecord.workerFeedbackReason}}</text>
						</view>
						<view class="grid col-3 grid-square flex-sub margin-top-sm">
							<view class="bg-img" v-for="(imgObj, imgIndex) in afterServiceRecord.imgsList"
								:key="imgIndex" v-if="imgObj.imgUploadBy === 2">
								<image :src="imgObj.imgUrl" @tap="viewImage($event, [imgObj.imgUrl])"
									:data-url="imgObj.imgUrl" mode="aspectFill"></image>
							</view>
						</view>
					</view>
					<view v-else-if="afterServiceRecord.operType === 2">
						<view class="margin-top-xs">
							<text>师傅反馈结果：</text>
							<text v-if="afterServiceRecord.workerFeedbackResult === 0">拒绝</text>
							<text v-else-if="afterServiceRecord.workerFeedbackResult === 1">同意</text>
							<text v-else-if="afterServiceRecord.workerFeedbackResult === 2">重新上门</text>
						</view>
						<view v-if="afterServiceRecord.workerFeedbackResult !== 2">
							<text>师傅反馈：</text>
							<text v-if="afterServiceRecord.workerFeedbackReasonType === 1">客户原因</text>
							<text v-else-if="afterServiceRecord.workerFeedbackReasonType === 2">师傅原因</text>
							<text v-else>其他</text>
							<text
								v-if="afterServiceRecord.workerFeedbackReason">{{"，" + afterServiceRecord.workerFeedbackReason}}</text>
						</view>
						<view class="grid col-3 grid-square flex-sub margin-top-sm">
							<view class="bg-img" v-for="(imgObj, imgIndex) in afterServiceRecord.imgsList"
								:key="imgIndex" v-if="imgObj.imgUploadBy === 2">
								<image :src="imgObj.imgUrl" @tap="viewImage($event, [imgObj.imgUrl])"
									:data-url="imgObj.imgUrl" mode="aspectFill"></image>
							</view>
						</view>
					</view>
				</view>
				<view v-if="afterServiceRecord.customerFinalCheck != null" class="padding-tb-sm solid-top">
					<view class='cu-tag bg-main-color radius light'>客户最终确认</view>
					<view class="margin-top-xs">{{afterServiceRecord.customerFinalCheck === 1 ? '同意' : '不同意'}}
					</view>
					<view v-if="afterServiceRecord.customerFinalCheck === 0">
						<view class="grid col-3 grid-square flex-sub margin-top-sm" v-if="afterServiceRecord.customerDisagreeImages">
							<view class="bg-img" v-for="imgUrl in afterServiceRecord.customerDisagreeImages.split(',')" :key="imgUrl">
								<image :src="imgUrl" @tap="viewImage($event, [imgUrl])" :data-url="imgUrl" mode="aspectFill"></image>
							</view>
						</view>
						<view class="margin-bottom-xs" v-if="afterServiceRecord.customerDisagreeReason">
							<text>不同意理由：{{afterServiceRecord.customerDisagreeReason}}</text>
						</view>
						<view class="text-red" v-if="afterServiceRecord.customerFinalCheck === 0">订单交由平台协商处理</view>
					</view>
					<view v-else-if="afterServiceRecord.customerFinalCheck === 1">
						<template v-if="afterServiceRecord.workerFeedbackResult !== 0">
							<view v-if="(afterServiceRecord.agreedRefund > 0 || afterServiceRecord.originalRefund > 0) && order.payStatus == 1">
								<view>
									<text>本单退款，系统已发起按客户支付的帐户原路退回</text>
									<text class="text-red">{{afterServiceRecord.agreedRefund || afterServiceRecord.originalRefund}}</text>
									<text>元，银行按工作日退款，节假日顺延到帐。遇客户问询，请其耐心等待，到账时会在客户端”客户最终确认“处有到账时间。</text>
								</view>
								<view>退款支付到账：{{afterServiceRecord.refundApplyTime}}</view>
							</view>
							<view v-else-if="order.payStatus == 0">
								<text>本单已退款{{afterServiceRecord.agreedRefund}}元，因未实际支付，实退为0元。未退部分继续完成订单及正常支付！</text>
							</view>
						</template>
						<view v-else>
							<text>本次售后已操作完毕，售后申请已结束！</text>
						</view>
					</view>
				</view> -->
			</view>
		</view>
		<!-- 完成记录 主单详情展示 -->
		<view v-if="servDetail.orderDetailId == null && (servDetail.originalWorkerId != curUserInfo.workerId)" class="bg-white margin-lr-sm padding-lr padding-bottom margin-top-sm" v-for="(item, index) in servDetail.orderStandardDetailList" :key="index">
			<view class="cu-bar solid-bottom">
				<view class="action bar-first-action">
					<text class="cuIcon-titles text-main-color"></text> {{order.orderType === 0 ? '服务记录' : '发货记录'}}
				</view>
				<view>
					<view class="cu-btn sm bg-main-color margin-right-sm shadow-blur" v-if="[0,1,2,3].indexOf(item.orderStatus) >= 0" @click="rejectDetailOrder(item)">撤单</view>
					<view class='cu-tag bg-purple radius light margin-right-sm' v-if="item.orderStatus === 5">已完成</view>
					<view class='cu-tag bg-purple radius light margin-right-sm' v-if="item.orderStatus === 4">待确认</view>
					<view class='cu-tag bg-purple radius light margin-right-sm' v-if="item.orderStatus === 3">{{servDetail.orderType === 0 ? '服务中' : '发货中'}}</view>
					<view class='cu-tag bg-purple radius light margin-right-sm' v-if="item.orderStatus === 2">{{servDetail.orderType === 0 ? '待上门' : '待发货'}}</view>
					<view class='cu-tag bg-purple radius light margin-right-sm' v-if="item.orderStatus === 1">{{servDetail.orderType === 0 ? '未约/未排' : '拣货/发货'}}</view>
					<view class='cu-tag bg-purple radius light margin-right-sm' v-if="item.orderStatus === 0">待接单</view>
				</view>
				<!-- <view class='cu-tag bg-purple radius light margin-right-sm' v-if="item.orderStatus > 3">{{item.workFinishTime}}</view> -->
			</view>
			<view class="margin-top-sm">
				<view class="float-left" v-for="(afterServiceRecord, afterServiceRecordIndex) in item.afterServiceRecordList" :key="afterServiceRecordIndex">
					<view v-if="afterServiceRecord.createBy && !afterServiceRecord.updateBy" class='cu-tag margin-right-xs radius line-red margin-top-xs'>售后发起中</view>
					<view v-if="afterServiceRecord.workerFeedbackResult == 1 && afterServiceRecord.customerFinalCheck == null" class='cu-tag margin-right-xs radius line-main-color margin-top-xs'>售后已同意</view>
					<view v-if="afterServiceRecord.workerFeedbackResult == 0 && afterServiceRecord.customerFinalCheck == null" class='cu-tag margin-right-xs radius line-red margin-top-xs'>售后已拒绝</view>
					<view v-if="afterServiceRecord.customerFinalCheck == 0" class='cu-tag margin-right-xs radius line-red margin-top-xs'>售后纠纷中</view>
					<view v-if="afterServiceRecord.customerFinalCheck == 1 || afterServiceRecord.customerFinalCheck == 2" class='cu-tag margin-right-xs radius line-main-color margin-top-xs'>售后已完成</view>
				</view>
				<template v-if="item.timeout == 1">
					<view class="float-left" v-if="order.orderType === 0">
						<view v-if="item.orderStatus === 0" class='cu-tag margin-right-xs radius line-red margin-top-xs'>超时未接单</view>
						<view v-else-if="order.orderStatus === 1 && order.isCall === '01'" class='cu-tag margin-right-xs radius line-red margin-top-xs'>超时未预约</view>
						<view v-else-if="order.orderStatus === 1 && order.isCall === '02'" class='cu-tag margin-right-xs radius line-red margin-top-xs'>超时未排单</view>
						<view v-else-if="order.orderStatus === 1 && order.orderDetailId != null" class='cu-tag margin-right-xs radius line-red margin-top-xs'>超时未预约</view>
						<view v-else-if="item.orderStatus === 2" class='cu-tag margin-right-xs radius line-red margin-top-xs'>{{order.orderType === 0 ? '超时未上门' : '超时未发货'}}</view>
						<view v-else-if="item.orderStatus === 3 && order.orderType === 0" class='cu-tag margin-right-xs radius line-red margin-top-xs'>超时未完单</view>
					</view>
					<view v-else class="float-left">
						<view v-if="order.orderStatus === 0" class='cu-tag margin-right-xs radius line-red margin-top-xs'>超时未接单</view>
						<view v-else-if="order.orderStatus === 1" class='cu-tag margin-right-xs radius line-red margin-top-xs'>超时未发货</view>
						<view v-else-if="order.orderStatus === 2" class='cu-tag margin-right-xs radius line-red margin-top-xs'>超时未发货</view>
					</view>
				</template>
				<view v-if="item.afterTimeout == 1" class='cu-tag margin-right-xs radius line-red margin-top-xs'>售后超时</view>
			</view>
			<view class="float-clear"></view>
			<view class="margin-top-sm">师傅：{{item.workerName}}</view>
			<view class="margin-top-sm">
				<text class="margin-right-xs">联系方式：{{item.workerPhone}}</text>
				<button class="cu-btn line-main-color sm" @click="makePhoneCall(item.workerPhone)">拨打</button>
			</view>
			<view class="margin-top-sm">
				服务金额：
				<text class="text-price">{{item.payMoney}}</text>
			</view>
			<view class="margin-top-sm" v-if="item.expectTimeEndFront">预约时间：{{item.expectTimeStartFront}}</view>
			<view class="margin-top-sm" v-else>预约时间：{{item.expectTimeStartFront}}</view>
			<view class="margin-top-sm" v-if="item.orderStatus >= 3">{{order.orderType === 1 ? '发货时间' : '上门时间'}}：{{item.workBeginTime}}</view>
			<view class="margin-top-sm" v-if="item.orderStatus >= 4">完成时间：{{item.workFinishTime}}</view>
			<view class="margin-top-sm">
				<product-picked :pickedList="item.orderStandardList" :columnTitleArr="servedColumnHeaders" :valFieldArr="servedValFields"></product-picked>
			</view>
			<view v-if="item.financialChangeRecord && item.financialChangeRecord.length > 0" class="bg-white">
				<view class="cu-bar solid-bottom">
					<view class="action bar-first-action">
						<text class="cuIcon-title text-main-color"></text> 加价记录
					</view>
				</view>
				<view class="padding-tb-sm" v-for="(changeRecord, changeRecordIndex) in item.financialChangeRecord" :key="changeRecordIndex">
					<view>
						<text>加价金额：</text>
						<text>{{changeRecord.changeMoney + (changeRecord.attachmentMoney || 0)}}</text>
					</view>
					<view v-if="changeRecord.reason && changeRecord.reason.indexOf('含') > -1">
						<text>{{changeRecord.reason.split('含')[1]}}：</text>
						<text>{{changeRecord.changeMoney}}</text>
					</view>
					<view>
						<text>加价备注：</text>
						<text v-if="changeRecord.remark">{{changeRecord.remark}}</text>
					</view>
					<view v-if="changeRecord.urls">
						<view class="grid col-3 grid-square flex-sub margin-top-sm">
							<view class="bg-img" v-for="imgUrl in changeRecord.urls.split(',')" :key="imgUrl">
								<image :src="imgUrl" @tap="viewImage($event, [imgUrl])" :data-url="imgUrl" mode="aspectFill">
								</image>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view v-if="servDetail.orderStatus > 3 && item.finishImgList && item.finishImgList.length" class="bg-white">
				<view class="cu-bar solid-bottom">
					<view class="action bar-first-action">
						<text class="cuIcon-title text-main-color"></text> 完工图片
					</view>
				</view>
				<view class="grid col-3 grid-square flex-sub margin-top-sm">
					<view class="bg-img" v-for="(imgUrl, index) in item.finishImgList" :key="index">
						<image :src="imgUrl" @tap="viewImage($event, [imgUrl])" :data-url="imgUrl" mode="aspectFill">
						</image>
					</view>
				</view>
				<view>
					<text>备注：{{item.remark}}</text>
				</view>
			</view>
			<view v-if="item.afterServiceRecordList && item.afterServiceRecordList.length" class="bg-white">
				<view class="cu-bar">
					<view class="action bar-first-action">
						<text class="cuIcon-title text-main-color"></text>
						{{item.afterServiceRecordList[0].operType === 1 ? '退款记录' : '售后记录'}}
					</view>
				</view>
				<view v-for="(afterServiceRecord, afterServiceRecordIndex) in item.afterServiceRecordList" :key="afterServiceRecordIndex">
					<afterServiceRecord v-if="order.orderType === 0" :after-service-record="afterServiceRecord" :order="item" :showActionBtn="false"></afterServiceRecord>
					<afterServiceRecordGoods 
						v-else 
						:after-service-record="afterServiceRecord" 
						:order="item" 
						:showActionBtn="false"
						@getDeliveryFlow="(trackingNumber) => {showDeliveryFlow = true; showDeliveryFlowTrackingNumber = trackingNumber;}"
					></afterServiceRecordGoods>
					<!-- <view v-if="afterServiceRecord.createBy == 1" class="padding-tb-sm solid-top">
						<view class='cu-tag bg-main-color radius light'>售后发起中</view>
						<view v-if="afterServiceRecord.operType === 1">
							<view class="text-gray text-sm margin-bottom-xs">退单退款已提交至商家，其最大时限24小时内需完成操作！</view>
							<view class="flex justify-start align-end">
								<text>退款申请：</text>
								<uni-countdown :show-colon="false" :backgroundColor="'#eee'"
									:day="$dateUtil.countDownDiff($dateUtil.addHours(afterServiceRecord.createTime, 24)).day"
									:hour="$dateUtil.countDownDiff($dateUtil.addHours(afterServiceRecord.createTime, 24)).hour"
									:minute="$dateUtil.countDownDiff($dateUtil.addHours(afterServiceRecord.createTime, 24)).min"
									:second="$dateUtil.countDownDiff($dateUtil.addHours(afterServiceRecord.createTime, 24)).seconds">
								</uni-countdown>
							</view>
							<view>
								<text>退款金额：</text>
								<text>{{afterServiceRecord.refund}}</text>
							</view>
							<view>
								<text>退款原因：</text>
								<text v-if="afterServiceRecord.customerReasonType === 1">上门/服务不守时</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 2">态度不友好，无法继续</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 3">服务效果差，未达到合格</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 4">技能水平问题，未妥善完成</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 5">要求加费用，费用不合理</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 6">订单拖太久了</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 7">超了些服务内容，师傅不接受</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 8">客户/我时间不方便了</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 9">客户/我已让别的师傅服务了</text>
							</view>
							<view>
								<text>具体原因：</text>
								<text v-if="afterServiceRecord.customerReason">{{afterServiceRecord.customerReason}}</text>
							</view>
							<view class="grid col-3 grid-square flex-sub margin-top-sm">
								<view class="bg-img" v-for="(imgObj, imgIndex) in afterServiceRecord.imgsList"
									:key="imgIndex" v-if="imgObj.imgUploadBy === 1">
									<image :src="imgObj.imgUrl" @tap="viewImage($event, [imgObj.imgUrl])"
										:data-url="imgObj.imgUrl" mode="aspectFill"></image>
								</view>
							</view>
							<view>
								<text class="text-red" v-if="!item.isOnlyServ && item.payMoney < afterServiceRecord.refund">警报：退单金额大于该师傅接单金额，但客户发起的退款金额有效，您需介入处理，如让接单师傅系统上操作同意退款，系统最大按该单派单额退回客户，其余需人工处理！如属于师傅责任引起的退单，建议重做，重做后让客户撤消退单！</text>
							</view>
						</view>
						<view v-else-if="afterServiceRecord.operType === 2">
							<view class="text-gray text-sm margin-bottom-xs">售后已提交至商家，其最大时限24小时内需完成操作！</view>
							<view class="flex justify-start align-end">
								<text>待处理售后：</text>
								<uni-countdown :show-colon="false" :backgroundColor="'#eee'"
									:day="$dateUtil.countDownDiff($dateUtil.addHours(afterServiceRecord.createTime, 24)).day"
									:hour="$dateUtil.countDownDiff($dateUtil.addHours(afterServiceRecord.createTime, 24)).hour"
									:minute="$dateUtil.countDownDiff($dateUtil.addHours(afterServiceRecord.createTime, 24)).min"
									:second="$dateUtil.countDownDiff($dateUtil.addHours(afterServiceRecord.createTime, 24)).seconds">
								</uni-countdown>
							</view>
							<view>
								<text>售后原因：</text>
								<text v-if="afterServiceRecord.customerReasonType === 1">上门/服务不守时</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 2">态度不友好，无法继续</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 3">服务效果差，未达到合格</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 4">技能水平问题，未妥善完成</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 5">要求加费用，费用不合理</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 6">订单拖太久了</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 7">超了些服务内容，师傅不接受</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 8">客户/我时间不方便了</text>
								<text v-else-if="afterServiceRecord.customerReasonType === 9">客户/我已让别的师傅服务了</text>
							</view>
							<view>
								<text>具体原因：</text>
								<text v-if="afterServiceRecord.customerReason">{{afterServiceRecord.customerReason}}</text>
							</view>
							<view class="grid col-3 grid-square flex-sub margin-top-sm">
								<view class="bg-img" v-for="(imgObj, imgIndex) in afterServiceRecord.imgsList"
									:key="imgIndex" v-if="imgObj.imgUploadBy === 1">
									<image :src="imgObj.imgUrl" @tap="viewImage($event, [imgObj.imgUrl])"
										:data-url="imgObj.imgUrl" mode="aspectFill"></image>
								</view>
							</view>
						</view>
					</view>
					<view v-if="afterServiceRecord.updateBy == 2" class="padding-tb-sm solid-top">
						<view class='cu-tag bg-main-color radius light'>师傅反馈</view>
						<view v-if="afterServiceRecord.operType === 1">
							<view class="margin-top-xs">
								<text>师傅反馈结果：</text>
								<text v-if="afterServiceRecord.workerFeedbackResult === 0">拒绝</text>
								<text v-else-if="afterServiceRecord.workerFeedbackResult === 1">同意</text>
								<text v-else-if="afterServiceRecord.workerFeedbackResult === 2">重新上门</text>
							</view>
							<view v-if="afterServiceRecord.workerFeedbackResult === 1">
								<text>同意退款金额：</text>
								<text>{{afterServiceRecord.agreedRefund ? afterServiceRecord.agreedRefund : afterServiceRecord.refund}}</text>
							</view>
							<view v-if="afterServiceRecord.workerFeedbackResult !== 2">
								<text>师傅反馈：</text>
								<text v-if="afterServiceRecord.workerFeedbackReasonType === 1">客户原因</text>
								<text v-else-if="afterServiceRecord.workerFeedbackReasonType === 2">师傅原因</text>
								<text v-else>其他</text>
								<text
									v-if="afterServiceRecord.workerFeedbackReason">{{"，" + afterServiceRecord.workerFeedbackReason}}</text>
							</view>
							<view class="grid col-3 grid-square flex-sub margin-top-sm">
								<view class="bg-img" v-for="(imgObj, imgIndex) in afterServiceRecord.imgsList"
									:key="imgIndex" v-if="imgObj.imgUploadBy === 2">
									<image :src="imgObj.imgUrl" @tap="viewImage($event, [imgObj.imgUrl])"
										:data-url="imgObj.imgUrl" mode="aspectFill"></image>
								</view>
							</view>
						</view>
						<view v-else-if="afterServiceRecord.operType === 2">
							<view class="margin-top-xs">
								<text>师傅反馈结果：</text>
								<text v-if="afterServiceRecord.workerFeedbackResult === 0">拒绝</text>
								<text v-else-if="afterServiceRecord.workerFeedbackResult === 1">同意</text>
								<text v-else-if="afterServiceRecord.workerFeedbackResult === 2">重新上门</text>
							</view>
							<view v-if="afterServiceRecord.workerFeedbackResult !== 2">
								<text>师傅反馈：</text>
								<text v-if="afterServiceRecord.workerFeedbackReasonType === 1">客户原因</text>
								<text v-else-if="afterServiceRecord.workerFeedbackReasonType === 2">师傅原因</text>
								<text v-else>其他</text>
								<text
									v-if="afterServiceRecord.workerFeedbackReason">{{"，" + afterServiceRecord.workerFeedbackReason}}</text>
							</view>
							<view class="grid col-3 grid-square flex-sub margin-top-sm">
								<view class="bg-img" v-for="(imgObj, imgIndex) in afterServiceRecord.imgsList"
									:key="imgIndex" v-if="imgObj.imgUploadBy === 2">
									<image :src="imgObj.imgUrl" @tap="viewImage($event, [imgObj.imgUrl])"
										:data-url="imgObj.imgUrl" mode="aspectFill"></image>
								</view>
							</view>
						</view>
					</view>
					<view v-if="afterServiceRecord.customerFinalCheck != null" class="padding-tb-sm solid-top">
						<view class='cu-tag bg-main-color radius light'>客户最终确认</view>
						<view class="margin-top-xs">{{afterServiceRecord.customerFinalCheck === 1 ? '同意' : '不同意'}}</view>
						<view v-if="afterServiceRecord.customerFinalCheck === 0">
							<view class="grid col-3 grid-square flex-sub margin-top-sm" v-if="afterServiceRecord.customerDisagreeImages">
								<view class="bg-img" v-for="imgUrl in afterServiceRecord.customerDisagreeImages.split(',')" :key="imgUrl">
									<image :src="imgUrl" @tap="viewImage($event, [imgUrl])" :data-url="imgUrl" mode="aspectFill"></image>
								</view>
							</view>
							<view class="margin-bottom-xs" v-if="afterServiceRecord.customerDisagreeReason">
								<text>不同意理由：{{afterServiceRecord.customerDisagreeReason}}</text>
							</view>
							<view class="text-red" v-if="afterServiceRecord.customerFinalCheck === 0">订单交由平台协商处理</view>
						</view>
						
						<view v-if="afterServiceRecord.customerFinalCheck === 1">
							<template v-if="afterServiceRecord.workerFeedbackResult !== 0">
								<view v-if="(afterServiceRecord.agreedRefund > 0 || afterServiceRecord.originalRefund > 0) && order.payStatus == 1">
									<view>
										<text>本单退款，系统已发起按客户支付的帐户原路退回</text>
										<text class="text-red">{{afterServiceRecord.agreedRefund || afterServiceRecord.originalRefund}}</text>
										<text>元，银行按工作日退款，节假日顺延到帐。遇客户问询，请其耐心等待，到账时会在客户端”客户最终确认“处有到账时间。</text>
									</view>
									<view>退款支付到账：{{afterServiceRecord.refundApplyTime}}</view>
								</view>
								<view v-else-if="order.payStatus == 0">
									<text>本单已退款{{afterServiceRecord.agreedRefund}}元，因未实际支付，实退为0元。未退部分继续完成订单及正常支付！</text>
								</view>
							</template>
							<view v-else>
								<text>本次售后已操作完毕，售后申请已结束！</text>
							</view>
						</view>
					</view> -->
				</view>
			</view>
		</view>
		
		<!-- 发货信息 -->
		<view class="bg-white margin-top-sm padding margin-lr-sm" v-if="servDetail.deliveryType">
			<view v-if="servDetail.deliveryType">
				发货方式：
				<text v-if="servDetail.deliveryType == 1">发快递/物流</text>
				<text v-if="servDetail.deliveryType == 2">送货上门</text>
				<text v-if="servDetail.deliveryType == 3">客户自提</text>
			</view>
			<view class="margin-top-xs" v-if="servDetail.deliveryImages">
				<view class="grid col-3 grid-square flex-sub">
					<view class="bg-img" v-for="imgUrl in servDetail.deliveryImages.split(',')" :key="imgUrl">
						<image :src="imgUrl" @tap="viewImage($event, [imgUrl])" :data-url="imgUrl" mode="aspectFill">
						</image>
					</view>
				</view>
			</view>
			<view class="margin-top-xs" v-if="servDetail.deliveryRemark"><text>发货备注：{{servDetail.deliveryRemark}}</text></view>
			<view class="margin-top-xs" v-if="servDetail.trackingNumber">
				<text>快递单号：{{servDetail.trackingNumber}}</text>
				<text class="text-main-color margin-left-sm" @click="getDeliveryFlow(servDetail.trackingNumber)">查询</text>
			</view>
		</view>
		
		<!-- 交货记录 -->
		<view class="bg-white margin-top-sm padding margin-lr-sm" v-if="servDetail.handoverRemark || servDetail.handoverImages">
			<view>交货记录</view>
			<view class="margin-top-xs" v-if="servDetail.handoverImages">
				<view class="grid col-3 grid-square flex-sub">
					<view class="bg-img" v-for="imgUrl in servDetail.handoverImages.split(',')" :key="imgUrl">
						<image :src="imgUrl" @tap="viewImage($event, [imgUrl])" :data-url="imgUrl" mode="aspectFill">
						</image>
					</view>
				</view>
			</view>
			<view class="margin-top-xs" v-if="servDetail.deliveryRemark"><text>交货备注：{{servDetail.handoverRemark}}</text></view>
		</view>
		
		<!-- 订单编码和时间 -->
		<view class="bg-white margin-top-sm padding margin-lr-sm">
			<view v-if="servDetail.orderDetailCode != null">订单编码：{{servDetail.orderDetailCode}}</view>
			<view v-else>订单编码：{{servDetail.orderMasterCode}}</view>
			<view class="margin-top-xs" v-if="servDetail.originalOrderMasterCode">原订单编码：{{servDetail.originalOrderMasterCode}}</view>
			<view class="margin-top-xs">订单时间：{{servDetail.createTime}}</view>
		</view>
		<view class="occupancy-bottom-bar"></view>
		<!-- 底部操作栏 -->
		<view class="cu-bar bg-white tabbar border fixed-bottom-bar" v-if="servDetail.orderDetailId != null && servDetail.orderStatus > 0 && servDetail.orderStatus != 6">
			<view class="action" data-popup="orderManage" @click="togglePopup">
				<view class="cuIcon-list"></view> 订单管理
			</view>
			<view v-if="servDetail.orderDetailId != null && servDetail.orderStatus === 2" class="bg-main-color submit" @click="workBegin">{{order.orderType === 0 ? (servDetail.goods.storeService ? '立即服务' : '立即上门') : '立即发货'}}</view>
		</view>
		<!-- <view class="cu-bar bg-white tabbar border fixed-bottom-bar" v-if="servDetail.orderDetailId != null && servDetail.orderStatus === 2">
			<view class="action" data-popup="orderManage" @click="togglePopup">
				<view class="cuIcon-list"></view> 订单管理
			</view>
			<view class="action" data-modal="sendUrgentMsgModal" @click="showModal">
				<view class="cuIcon-mail">
					<view class="cu-tag badge" v-if="servDetail.talkMsgNum > 0">{{servDetail.talkMsgNum}}</view>
				</view>
				发送急报
			</view>
			<view class="action" data-popup="orderManage">
			</view>
			<view class="action" data-modal="sendUrgentMsgModal">
			</view>
			<view v-if="servDetail.orderStatus === 2" class="bg-main-color submit" @click="workBegin">立即上门</view>
		</view> -->
		<uni-popup ref="orderManage" type="bottom" @change="changePopupState">
			<view class="bg-white text-center bottom-option-list-bar">
				<view v-for="(menu,index) in orderManageMenu" :key="index" class="padding solid-bottom" :data-action="menu.action" :data-modal="menu.modal" @click="clickOrderManageMenu">
					{{menu.name}}
				</view>
			</view>
			<!-- 底部占位 -->
			<view class="cu-bar bg-white fixed-bottom-bar"></view>
		</uni-popup>
		<!-- 模态框 -->
		<urgent-msg :show="sendUrgentMsgModal" @hideModal="hideModal"></urgent-msg>
		<!-- <apply-extra-charge v-if="applyExtraChargeModal" :show="applyExtraChargeModal" :data="servDetail" @close="applyExtraChargeClose"></apply-extra-charge> -->
		<apply-charge v-if="applyChargeModal" ref="applyChargeModal" :show="applyChargeModal" :data="servDetail" @close="applyChargeClose" @callAgain="callApplyChargeAgain"></apply-charge>
		
		<task-process-detail :show="taskProcessDetail" :arr="taskListArr" @close="taskDetailClose"></task-process-detail>
		
		<deliveryFlowDetail :show="showDeliveryFlow" :trackingNumber="showDeliveryFlowTrackingNumber" @close="showDeliveryFlow = false"></deliveryFlowDetail>
		
		<deliverGoods v-if="showDeliverGoods" :show="showDeliverGoods" :data="servDetail" @close="showDeliverGoods = false"  @confirmFeedback="showDeliverGoods = false;loadData()"></deliverGoods>
		
		<on-door-immediately v-if="showOnDoorNoticeModal" :show="showOnDoorNoticeModal" :data="servDetail" @close="showOnDoorNoticeModal = false" @confirmFeedback="showOnDoorNoticeModal = false;loadData()"></on-door-immediately>
	</view>
</template>

<script>
	import productPicked from '@/components/goods-card/product-picked.vue';
	import urgentMsg from '@/pages/order-manage/modal/urgent-msg.vue';
	// import applyExtraCharge from '@/pages/order-manage/modal/apply-extra-charge.vue';
	import applyCharge from '@/pages/order-manage/modal/apply-charge.vue';
	import taskProcessDetail from '@/pages/order-manage/modal/task_process_detail.vue'
	import deliveryFlowDetail from '@/pages/order-manage/modal/delivery_flow_detail.vue';
	import deliverGoods from '@/pages/order-manage/modal/deliver-goods.vue';
	import onDoorImmediately from '@/pages/order-manage/modal/on-door-immediately.vue';
	import afterServiceRecord from './components/afterServiceRecord.vue';
	import afterServiceRecordGoods from './components/afterServiceRecordGoods.vue';
	
	export default {
		components: {
			productPicked,
			urgentMsg,
			// applyExtraCharge,
			taskProcessDetail,
			applyCharge,
			deliveryFlowDetail,
			deliverGoods,
			onDoorImmediately,
			afterServiceRecord,
			afterServiceRecordGoods
		},
		data() {
			return {
				value: ['0'],
				order: {},
				servDetail: {},
				finishRecord4Show: [],
				servingColumnHeaders: ['购买型号', '购买量', '待服务'],
				servedColumnHeaders: ['购买型号', '购买量', '已服务'],
				servingValFields: ['standardName', 'standardNum', 'waitServerNum'],
				servedValFields: ['standardName', 'standardNum', 'serverNum'],
				ifShowPageMeta: false,
				orderManageMenu: [
				// {
				// 	name: '申请配件',
				// 	action: 'applyFittings'
				// }, 
				// {
				// 	name: '申请附加费',
				// 	action: 'applyExtraCharge',
				// 	modal: 'applyExtraChargeModal'
				// }, 
				{
					name: '申请费用',
					action: 'applyCharge',
					modal: 'applyChargeModal'
				}
				// {
				// 	name: '拍照回单',
				// 	action: ''
				// }, 
				// {
				// 	name: '指派/撤回订单',
				// 	action: ''
				// }, 
				// {
				// 	name: '申请退单',
				// 	action: 'applyCancelOrder'
				// },
				],
				sendUrgentMsgModal: false,
				overtimeRecords: null,
				applyExtraChargeModal: false,
				taskProcessDetail: false,
				taskListArr: [],
				applyChargeModal: false,
				showDeliveryFlow: false,
				showDeliverGoods: false,
				showOnDoorNoticeModal: false,
				curUserInfo: null,
				showDeliveryFlowTrackingNumber: ''
			}
		},
		onLoad(options) {
			this.bindEvent();
			if (options && options.order) {
				this.order = JSON.parse(decodeURIComponent(options.order));
			}
			console.log(this.order);	
			if(this.order.orderType === 1) {
				this.servingColumnHeaders = ['购买型号', '购买量', '待发货']
				this.servedColumnHeaders = ['购买型号', '购买量', '已发货']
			}
			this.curUserInfo = this.$request.getCurUserInfo();
			this.loadData();
		},
		onUnload() {
			this.offBindEvent();
		},
		methods: {
			openShopLocation(item) {
				// const gcj02Coord = wgs84ToGcj02(item.shop.longitude, item.shop.latitude)
				// const gcj02Coord = wgs84ToGcj02(102.80154676649306, 24.969456922743056)
				// const gcj02Coord = [102.82868680950929, 24.864792838337802]
				const gcj02Coord = [item.longitude, item.latitude]
				wx.openLocation({
				  latitude: gcj02Coord[1],
				  longitude: gcj02Coord[0],
				  scale: 18,
				  name: item.shopName,
				  address: `${item.provinceName}${item.cityName}${item.countryName}${item.streetName}${item.address}`
				})
			},
			// 显示任务详情进度框
			showTaskDetailMdl() {
				this.taskProcessDetail = true
			},
			taskDetailClose() {
				console.log('close  close');
				this.taskProcessDetail = false
			},
			bindEvent() {
				uni.$on(this.$globalFun.HIDE_MODAL, this.hideModal);
			},
			offBindEvent() {
				uni.$off(this.$globalFun.HIDE_MODAL);
			},
			async loadData() {
				let orderId = null;
				let funName = null;
				if (this.order.orderDetailId == null) {
					// 展示主单信息
					orderId = this.order.orderMasterId;
					funName = "getOrderMasterDetail";
				} else {
					// 展示子单信息
					orderId = this.order.orderDetailId;
					funName = "getOrderDetail";
				}
				let servDetailRes = await this.$request[funName]({
					id: orderId
				});
				servDetailRes.data.orderType = this.order.orderType;
				this.servDetail = servDetailRes.data;
				this.getProcessData()
			},
			async getProcessData() {
				const isDetail = this.order.orderDetailId == null
				const res = await this.$request.getOrderOperate({
					orderId: isDetail ? this.order.orderMasterId : this.order.orderDetailId,
					orderType: isDetail ? '01' : '02'
				})
				this.taskListArr = res.rows;
			},
			changePopupState(e) {
				this.ifShowPageMeta = e.show;
			},
			togglePopup(e) {
				if (this.ifShowPageMeta) {
					this.$refs[e.currentTarget.dataset.popup].close();
				} else {
					this.$refs[e.currentTarget.dataset.popup].open();
				}
			},
			clickOrderManageMenu(e) {
				this[e.currentTarget.dataset.action]();
			},
			applyFittings() {
				console.log("申请配件")
			},
			// applyExtraCharge() {
			// 	console.log("申请charge")
			// 	this.applyExtraChargeModal = true;
			// },
			// applyExtraChargeClose() {
			// 	this.applyExtraChargeModal = false;
			// },
			applyCharge() {
				this.applyChargeModal = true;
				console.log('resetPriceChangedInfo');	
				this.$nextTick(() => {
					this.$refs.applyChargeModal.initPriceData()
				})
			},
			async callApplyChargeAgain() {
				await this.loadData();
				this.$nextTick(() => {
					this.$refs.applyChargeModal.initPriceData()
				})
			},
			applyChargeClose() {
				this.applyChargeModal = false;
			},
			applyCancelOrder() {
				let params = {
					orderInfo: this.servDetail.mainServOrder
				}
				console.log(params)
				uni.navigateTo({
					url: '/pages/order-manage/cancel-order?params=' + encodeURIComponent(JSON.stringify(params))
				})
			},
			async workBegin() {
				if(this.order.orderType === 1) {
					this.showDeliverGoods = true
				} else {
					this.showOnDoorNoticeModal = true
					// let curDate = new Date();
					// let formatCurDate = curDate.getFullYear() + '-' + (curDate.getMonth() + 1) + '-' + curDate.getDate()
					// 	+ ' ' + curDate.getHours() + ':' + curDate.getMinutes() + ':' + curDate.getSeconds();
					// let params = {
					// 	id: this.servDetail.orderDetailId,
					// 	orderStatus: 3,
					// 	workBeginTime: formatCurDate
					// }
					// let res = await this.$request.updateDetailOrder(params);
					// if (res && res.code === 0) {
					// 	this.loadData(this.servDetail.orderDetailId);
					// 	uni.showToast({
					// 		icon: 'success'
					// 	})
					// }
				}
			},
			showModal(e) {
				this[e.currentTarget.dataset.modal] = true;
			},
			hideModal(e) {
				this[e.currentTarget.dataset.modal] = false;
			},
			viewImage(e, imgList) {
				uni.previewImage({
					urls: imgList,
					current: e.currentTarget.dataset.url
				});
			},
			async makeCustomerPhoneCall(order) {
				uni.makePhoneCall({
					phoneNumber: order.customerPhone
				})
				if (order.orderDetailId == null) {
					let res = await this.$request.callCustomer({
						id: order.orderMasterId,
						isCall: '02'
					});
				} else {
					this.$request.callDetailCustomer({
						id: order.orderDetailId,
						isCall: '02'
					});
				}
				this.loadData();
			},
			makePhoneCall(phoneNum) {
				uni.makePhoneCall({
					phoneNumber: phoneNum
				})
			},
			copyData(data) {
				uni.setClipboardData({
					data: data
				});
			},
			async rejectDetailOrder(order) {
				let res = await this.$request.rejectDetailOrder({
					id: order.orderDetailId
				});
				if (res && res.code === 0) {
					this.loadData();
					uni.showToast({
						icon: 'none',
						title: '操作成功',
						duration: 1000
					})
				} else {
					uni.showToast({
						icon: 'none',
						title: '操作失败'
					})
				}
			},
			async cancelMasterOrder(order) {
				let res = await this.$request.rejectMasterOrderWhenAccepted({
					id: order.orderMasterId
				});
				if (res && res.code === 0) {
					uni.showToast({
						icon: 'none',
						title: '撤单成功，请回商品订单管理处理或重派。',
						duration: 2000
					})
					setTimeout(() => {
						uni.navigateBack()
					}, 3000)
				} else {
					uni.showToast({
						icon: 'none',
						title: res.msg,
						duration: 2000
					})
				}
			},
			// 获取物流信息
			getDeliveryFlow(TrackingNumber) {
				this.showDeliveryFlow = true;
				this.showDeliveryFlowTrackingNumber = TrackingNumber;
			}
		}
	}
</script>

<style scoped>
	.bar-first-action {
		margin-left: unset !important;
		font-size: 30rpx !important;
	}
	
	.bottom-option-list-bar {
		z-index: 99;
		position: relative;
	}
</style>
