<template>
	<!-- 订单详情 -->
	<view class="page1" :style="popupPageStyle">
		<view class="pintuan-page" v-if="pintuan">
			<view class="title1">
				<view class="title-sreach1">
					<view class="back-btn1" @tap="back" :style="{'top': menuButtonInfo.top +'px'}">
						<uni-icons type="left" size="28"></uni-icons>
					</view>
				</view>
			</view>
			<view class="box11">
				<view class="ziqu-xuanfu1" v-if="orderDetail.deliveryType == 1">
					外卖配送
				</view>
				<view style="width: 100%;line-height: 70rpx;font-size: 28rpx;font-weight: 700;">
					{{orderDetail.shopName}}
				</view>
				<view v-if="orderDetail.payTime != null" style="height: 64rpx;line-height: 64rpx;display: flex;">
					<view style="flex: 1;color: #777;font-weight: 700;">
						支付时间
					</view>
					<view style="color: #000;font-weight: 700;">
						{{orderDetail.payTime | formatTime}}
					</view>
				</view>
				<view class="pintuan-goods-card"  v-for="(item1,index1) in orderDetail.goodsList" :key="index1"
						v-if="orderDetail.goodsList != null && orderDetail.goodsList.length > 0">
					<view class="goods-img1">
						<img :src="item1.productPicture" alt="">
					</view>
					<view class="goods-content1">
						<view class="goods-name1">
							{{item1.productName}}
						</view>
						<view class="goods-content-center1">
							<view>
								{{item1.specs | delNode}}
							</view>
						</view>
						<view class="goods-content-bottom1">
							<view style="flex: 1;">
								X{{item1.quantity}}
							</view>
							<view class="pintuan-left-price1">
								<view class="pintuan-price-tag">
									<text>拼团</text>
									<text style="color: red;">￥{{item1.price}}</text>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="box11">
				<view class="kaituan11">
					<view class="kaituan1-title1">
						差{{orderDetail.groupInfo.targetMembers - orderDetail.groupInfo.currentMembers}}人即可成团
						<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/21b403bd13414ce79ad73cf1c8e3de98.png"
							alt="" style="width: 240rpx;height: 22rpx;position: absolute;bottom: 0;right: 30rpx;" />
					</view>
					<view class="kaituan1-title11">
						快呼唤小伙伴参加吧！
					</view>
					<view class="kaituan-refresh-btn" @tap="refreah(orderDetail)">
						{{isRefreshing ? '刷新中' : '刷新'}}
					</view>
				</view>
				<view class="kaituan21">
					<view class="kaituan-member-list">
						<view class="kaituan221"
							v-for="(item1,index1) in orderDetail.groupInfo.currentMembers"
							:key="index1">
							<img class="kaituan-member-icon" src="/static/images/img/songshu.png" alt="" />
						</view>
						<view class="kaituan-empty-list">
							<view class="weipincheng1"
								v-for="(item1,index1) in (orderDetail.groupInfo.targetMembers - orderDetail.groupInfo.currentMembers)"
								:key="index1">
								+
							</view>
						</view>
					</view>
				</view>
				<view class="pintuan-actions">
					<view class="kaituan41 kaituan41-share">
						<button open-type="share" class="share-btn">
							分享至微信 <uni-icons type="weixin" size="15"></uni-icons>
						</button>
					</view>
					<view class="kaituan41 kaituan41-cancel" v-if="orderStatus(orderDetail)" @tap="returnPopupProp(orderDetail)">
						取消订单
					</view>
					<view class="kaituan41 kaituan41-buy" v-if="orderStatusBuy(orderDetail)" @tap="returnPopupPropBuy(orderDetail)">
						取消拼团转直接购买
					</view>
				</view>
				<view class="kaituan51">
					<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/c1f1b45c98fa4db1a1e5f98b3a0573c2.png"
						alt="" style="width: 520rpx;height: 150rpx;margin: 0 auto;display: block;" />
				</view>
			</view>
		</view>
		<view class="" v-else>
			<view class="order-detail-fixed-header" :class="{'order-detail-fixed-header-lower': popupPageStyle}">
				<view class="title">
					<view class="title-sreach">
						<view class="back-btn" @tap="back" :style="{'top': menuButtonInfo.top +'px'}">
							<uni-icons type="left" size="28"></uni-icons>
						</view>
					</view>
				</view>
				<view class="order-detail-header-content">
					<view class="box1 order-status-card" style="display: flex;min-height: 160rpx;">
						<view class="status-img">
							<img v-if="orderDetail.status == 0 || (orderDetail.status == 3 && orderDetail.deliveryType == 2)"
								src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/6cf6fff020614ebebb34f7c371e11331.png"
								alt="" />
							<img v-if="orderDetail.status == 2"
								src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/35ff6276eb3a4e58b8baa724ca44d5dc.png"
								alt="" />
							<img v-if="orderDetail.status == 5 || orderDetail.status == 8 || orderDetail.status == 12"
								src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/dbfa6dc934e2414c912c67430d5f802c.png"
								alt="" />
							<img v-if="orderDetail.status == 6"
								src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/03d7e8d5914e4b9ca04728113900d1fe.png"
								alt="" />
							<img v-if="orderDetail.status == 7 || orderDetail.status == 11"
								src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/35ff6276eb3a4e58b8baa724ca44d5dc.png"
								alt="" />
							<img v-if="(orderDetail.status == 3 && orderDetail.deliveryType == 1) || (orderDetail.status == 4 && orderDetail.deliveryType == 1)"
								src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/0ab87a35cbca473997c679a023337df6.png"
								alt="" />
							<!-- 
								待支付  https://jewel-shop.oss-cn-beijing.aliyuncs.com/6cf6fff020614ebebb34f7c371e11331.png
								订单取消  https://jewel-shop.oss-cn-beijing.aliyuncs.com/03d7e8d5914e4b9ca04728113900d1fe.png
								等待商家接单、等待配送员接单、等待商家同意  https://jewel-shop.oss-cn-beijing.aliyuncs.com/35ff6276eb3a4e58b8baa724ca44d5dc.png
								配送中、配送员已接单、配送员已到店、等待配送员接单  https://jewel-shop.oss-cn-beijing.aliyuncs.com/0ab87a35cbca473997c679a023337df6.png
								订单完成  https://jewel-shop.oss-cn-beijing.aliyuncs.com/dbfa6dc934e2414c912c67430d5f802c.png
							 -->
						</view>
						<view class="status-text">
							<view class="status-zhu">
								<text v-if="orderDetail.status == 0">待支付</text>
								<text v-if="orderDetail.status == 2">{{orderDetail.shopDelivery == 1 ? '等待商家配送接单' : '等待配送员接单'}}</text>
								<text v-if="orderDetail.status == 3 && orderDetail.deliveryType == 1 && !(orderDetail.deliveryInfo && orderDetail.deliveryInfo.transferDelivery == 1)">{{orderDetail.shopDelivery == 1 ? '商家配送已接单' : '配送员已接单'}}</text>
								<text v-if="orderDetail.status == 3 && orderDetail.deliveryType == 1 && orderDetail.deliveryInfo && orderDetail.deliveryInfo.transferDelivery == 1 && !orderDetail.deliveryInfo.transferArriveTime">等待商家送达中转点</text>
								<text v-if="orderDetail.status == 3 && orderDetail.deliveryType == 1 && orderDetail.deliveryInfo && orderDetail.deliveryInfo.transferDelivery == 1 && orderDetail.deliveryInfo.transferArriveTime">待配送员取货</text>
								<text v-if="orderDetail.status == 3 && orderDetail.deliveryType == 2">待消费</text>
								<text v-if="orderDetail.status == 4 && orderDetail.deliveryType == 1">{{orderDetail.deliveryInfo && orderDetail.deliveryInfo.transferDelivery == 1 ? '中转配送中' : '配送员已取货'}}</text>
								<text v-if="orderDetail.status == 5">订单已完成</text>
								<text v-if="orderDetail.status == 7">等待同意退款</text>
								<text v-if="orderDetail.status == 6">订单已取消</text>
								<text v-if="orderDetail.status == 8">订单已退款</text>
								<text v-if="orderDetail.status == 11">售后中</text>
								<text v-if="orderDetail.status == 12">订单已售后</text>
							</view>
							<view class="status-fu" v-if="orderDetail.status == 0">
								<view class="">
									剩余支付时间 <text style="color:red;font-weight: 700;">{{payCountdownText}}</text></view>
							</view>
							<view class="status-fu" v-else-if="orderDetail.deliveryInfo">
								<view class="">
									预计<text style="color:red;font-weight: 700;">{{orderDetail.deliveryInfo.mustFinishTime | formatHourMinute }}</text>送达</view>
								<!-- <view class="">超过15分钟未支付，订单自动取消</view>
								<view class="">您申请了取消订单，请等待商家同意</view>
								<view class="">商家已同意取消订单，订单金额将原路返回</view>
								<view class="">商家已拒绝取消订单，将会继续为您配送</view> -->
							</view>
							<view class="status-address" v-if="orderDetail.deliveryInfo">
								<text class="status-address-label">送至</text>
								<text class="status-address-text">{{orderDetail.deliveryInfo.receiverAddress}}</text>
							</view>
							<view class="status-btn" style="top: 0;" v-if="orderStatus(orderDetail)"
								@tap="returnPopupProp(orderDetail)">
								取消订单
							</view>
							<view class="status-btn" style="top: 0;" v-if="orderDetail.status == 5 && hasRefund == false"
								@tap="returnProducts(orderDetail)">
								申请售后
							</view>
							<view class="status-btn" style="top: 70rpx;" @tap="refreah(orderDetail)">
								{{isRefreshing ? '刷新中' : '刷新'}}
							</view>
							<!-- <view class="status-btn">
								去评价
							</view> -->
						</view>
					</view>
				</view>
			</view>
			<view class="content order-detail-content" :class="{'order-detail-content-address-long': isStatusAddressLong}">
				<view class="order-flow"  v-if="orderDetail.status != 6">
					<view class="flow-item active">
						<view class="flow-dot"></view>
						<view class="flow-name">{{orderDetail.status == 0 ? '待支付' : '已下单'}}</view>
					</view>
					<view class="flow-line" :class="{'active': orderDetail.status >= 3 || orderDetail.status == 5}"></view>
					<view class="flow-item" :class="{'active': orderDetail.status >= 3 || orderDetail.status == 5}">
						<view class="flow-dot"></view>
						<view class="flow-name">{{orderDetail.deliveryType == 1 ? '已接单' : '待消费'}}</view>
					</view>
					<view class="flow-line" :class="{'active': orderDetail.status >= 4 || orderDetail.status == 5}"></view>
					<view class="flow-item" :class="{'active': orderDetail.status >= 4 || orderDetail.status == 5}">
						<view class="flow-dot"></view>
						<view class="flow-name">{{orderDetail.deliveryType == 1 ? '配送中' : '核销中'}}</view>
					</view>
					<view class="flow-line" :class="{'active': isOrderFlowFinalActive}"></view>
					<view class="flow-item" :class="{'active': isOrderFlowFinalActive}">
						<view class="flow-dot"></view>
						<view class="flow-name">{{orderFlowFinalName}}</view>
					</view>
				</view>
				<view class="btn-box">
					<view class="btn" v-if="orderDetail.status == 0" @tap="openPayPopup">
						立即支付
					</view>
					<view class="btn"
						v-if="orderDetail.status == 3 && orderDetail.deliveryType == 2 && orderDetail.userRequireMake == null && orderDetail.otherOrder == null"
						@tap="openCode">
						核销取餐码
					</view>
					<view class="btn"
						v-if="orderDetail.status == 3 && orderDetail.deliveryType == 2 &&orderDetail.userRequireMake == null &&orderDetail.otherOrder == 2"
						@tap="openCode">
						核销二维码
					</view>
					<view class="btn"
						v-if="orderDetail.status == 3 && orderDetail.deliveryType == 2 && orderDetail.userRequireMake == null && orderDetail.otherOrder == null"
						@tap="makeMeal" style="background: rgba(0, 35, 28, 1);color:rgba(166, 255, 234, 1);">
						立即备餐
					</view>
					<view class="btn" style="width: 40%;" v-if="orderDetail.status == 2 && orderDetail.shopDelivery != 1" @tap="openAddFeePopup">
						增加配送佣金
					</view>
					<view class="btn" style="width: 40%;" v-if="orderDetail.status == 2 && orderDetail.shopDelivery != 1" @tap="goAssignWorker">
						改派配送员
					</view>
					<!-- <view class="btn">
						再来一单
					</view>
					<view class="btn">
						￥5 去支付
					</view>
					<view class="btn">
						增加配送佣金
					</view>
					<view class="btn">
						取消申请
					</view> -->
				</view>
				<view class="box1"
					v-if="orderDetail.mallRefundRecord != null && orderDetail.mallRefundRecord.length > 0">
					<view style="width: 100%;line-height: 70rpx;font-size: 30rpx;font-weight: 700;display: flex;align-items: center;">
						<text style="flex: 1;">退款/售后</text>
						<view class="refund-service-btn" @tap="callPlatformService">
							平台介入
						</view>
					</view>
					<view class="refund-card"
						v-for="(item2,index2) in orderDetail.mallRefundRecord" :key="index2">

						<view style="width: 100%;">
							<view style="height: 80rpx;line-height: 80rpx;display: flex;">
								<view style="flex: 1;color: #777;font-weight: 700;">
									申请时间
								</view>
								<view style="color: #000;font-weight:700;">
									{{item2.createTime | formatTime}}
								</view>
							</view>
							<view style="height: 80rpx;line-height: 80rpx;display: flex;">
								<view style="flex: 1;color: #777;font-weight: 700;">
									金额
								</view>
								<view style="color: #000;font-weight:700;">
									￥{{getDisplayRefundAmount(item2)}}
								</view>
							</view>
							<view class="refund-goods-card" v-for="(item3,index3) in item2.items" :key="index3"
								v-if="item2.items != null && item2.items.length > 0">
								<view class="refund-goods-img">
									<img :src="item3.productPicture" alt="">
								</view>
								<view class="refund-goods-content">
									<view class="refund-goods-name">{{item3.productName}}</view>
									<view class="refund-goods-spec">{{item3.specs | delNode}}</view>
									<view class="refund-goods-bottom">
										<text>X{{item3.quantity}}</text>
										<text>￥{{item3.price}}</text>
									</view>
									<view class="refund-goods-bottom" v-if="item3.packageFee != undefined && item3.packageFee > 0 && orderDetail.packageFee > 0">
										<text>餐盒费</text>
										<text>￥{{item3.packageFee}}</text>
									</view>
								</view>
							</view>
							<view class="refund-info-row">
								<view class="refund-info-label">
									原因
								</view>
								<view class="refund-info-value">
									{{item2.reason != null ? item2.reason : ''}}
								</view>
							</view>
							<view class="refund-info-row" v-if="item2.pictures != null && item2.pictures != ''">
								<view class="refund-info-label">
									图片
								</view>
								<view class="refund-info-value">
									<image class="refund-image" :src="item2.pictures" mode="aspectFill"></image>
								</view>
							</view>
							<view class="refund-info-row">
								<view class="refund-info-label">
									退款/售后类型
								</view>
								<view class="refund-info-value">
									{{item2.refundType == 1 ? '退商品 ' : item2.refundType == 2 ? '退配送费 ' : '全额退款 ' }}
									<text v-if="item2.refundTypeStatus != null">
										| {{item2.refundTypeStatus == 1 ? '商家退款' : item2.refundTypeStatus == 2 ? '配送员退款' : (item2.refundTypeStatus == 3 && item2.linkId.indexOf("W") == -1) ? '商家退款' : (item2.refundTypeStatus == 3 && item2.linkId.indexOf("W") != -1) ? '配送员退款' : '平台退款' }}
									</text>
								</view>
							</view>
							<view class="refund-info-row">
								<view class="refund-info-label">
									退款/售后状态
								</view>
								<view class="refund-info-value">
									{{item2.status == 0 ? '处理退款中' : item2.status == 1 ? '同意退款' : item2.status == 2 ? '拒绝退款' : item2.status == 3 ? '处理售后中' : item2.status == 4 ? '同意售后' : '拒绝售后' }}
								</view>
							</view>
							<view class="refund-info-row" v-if="(item2.status == 2 || item2.status == 5) && item2.rejectReason">
								<view class="refund-info-label">
									拒绝原因
								</view>
								<view class="refund-info-value">
									{{item2.rejectReason}}
								</view>
							</view>
							<view class="auto-refund-tip" v-if="isRefundPending(item2)">
								{{getAutoRefundTime(item2.createTime)}} 之前对方未处理系统会自动退款
							</view>
							<view class="refund-info-row" v-if="item2.successTime != null">
								<view class="refund-info-label">
									处理退款/售后时间
								</view>
								<view class="refund-info-value">
									{{item2.successTime | formatTime}}
								</view>
							</view>
						</view>
					</view>

				</view>

				<view class="box1">
					<view style="width: 100%;line-height: 70rpx;font-size: 28rpx;font-weight: 700;display: flex;"
						v-if="orderDetail.shopName != null">
						<text style="flex:1">{{orderDetail.shopName}}</text>
						<img @tap="makeCall(orderDetail.shopPhone)"
							src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/869a7af6a1c24bf3a0d523c4a18b55c6.png"
							alt="" style="width: 40rpx;height: 40rpx;margin-top: 14rpx;" />
					</view>

					<view v-for="(item1,index1) in orderDetail.goodsList" :key="index1"
						v-if="orderDetail.goodsList != null && orderDetail.goodsList.length > 0"
						style="display: flex;padding: 20rpx;background: rgba(247, 248, 248, 0.6);border-radius: 20rpx;">
						<view class="goods-img">
							<img :src="item1.productPicture" alt="">
						</view>
						<view class="goods-content">
							<view class="goods-name">
								{{item1.productName}}
							</view>
							<view class="goods-content-center">
								{{item1.specs | delNode}}
							</view>
							<view class="goods-content-bottom">
								<view style="width: 50%;">
									X{{item1.quantity}}
								</view>
								<view class="pintuan-left-price">
									￥{{item1.price}}
								</view>
							</view>
						</view>
					</view>
					<view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							v-if="orderDetail.packageFee != null && orderDetail.packageFee > 0">
							<view style="flex: 1;color: #777;font-weight: 700;">
								打包费
							</view>
							<view style="color: #000;font-weight:700;">
								￥{{orderDetail.packageFee == undefined ? '' : orderDetail.packageFee}}
							</view>
						</view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							v-if="orderDetail.freeAmount != null && orderDetail.freeAmount > 0 && refundAmountMode == 'user'">
							<view style="flex: 1;color: #ff6f2c;font-weight: 700;">
								锦鲤免单
							</view>
							<view style="color:  #ff6f2c;font-weight:700;">
								￥{{orderDetail.freeAmount == undefined ? '' : orderDetail.freeAmount}}
							</view>
						</view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							v-if="orderDetail.deliveryType == 1">
							<view style="flex: 1;color: #777;font-weight: 700;">
								配送费
							</view>
							<view style="color: #000;font-weight:700;">
								￥{{orderDetail.deliveryFee == undefined ? '' : orderDetail.deliveryFee}}
							</view>
						</view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							v-if="orderDetail.userCouponNum > 0 && refundAmountMode == 'user'">
							<view style="flex: 1;color: #777;font-weight: 700;">
								优惠券
							</view>
							<view style="color: #000;font-weight:700;">
								-￥{{orderDetail.userCouponNum == undefined ? '' : orderDetail.userCouponNum}}
							</view>
						</view>
					</view>
					<view v-if="orderDetail.status != 6 && refundAmountMode == 'user'"  
						style="display: flex;height: 80rpx;line-height: 100rpx;border-top: 1px solid #eee;font-size: 32rpx;font-weight: 700;">
						<view style="flex: 1;">
							{{orderDetail.status == 0 ? '待支付' : '实付'}}
						</view>
						<view class="">
							￥{{orderDetail.totalAmount == undefined ? '' : orderDetail.totalAmount}}
						</view>
					</view>
				</view>

				<view class="box1">
					<view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							v-if="orderDetail.otherOrder == 1">
							<view style="flex: 1;color: #777;font-weight: 700;">
								取件地址
							</view>
							<view style="color: #000;font-weight: 700;">
								{{orderDetail.shopAddress == undefined ? '' : orderDetail.shopAddress}}
							</view>
						</view>
						<view style="min-height: 80rpx;line-height: 40rpx;display: flex;align-items: flex-start;padding: 20rpx 0;box-sizing: border-box;"
							v-if="orderDetail.otherOrder == 1">
							<view style="width: 160rpx;flex-shrink: 0;color: #777;font-weight: 700;">
								收件地址
							</view>
							<view style="flex: 1;min-width: 0;color: #000;font-weight: 700;text-align: right;word-break: break-all;overflow-wrap: break-word;">
								{{orderDetail.receiverAddress == undefined ? '' : orderDetail.receiverAddress}}
							</view>
						</view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							v-if="orderDetail.otherOrder == 1">
							<view style="flex: 1;color: #777;font-weight: 700;">
								件数
							</view>
							<view style="color: #000;font-weight: 700;">
								{{orderDetail.deliveryInfo.allCount == undefined ? '' : orderDetail.deliveryInfo.allCount}}
							</view>
						</view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							v-if="orderDetail.otherOrder == 1">
							<view style="flex: 1;color: #777;font-weight: 700;">
								服务类型
							</view>
							<view style="color: #000;font-weight: 700;">
								快递/跑腿
							</view>
						</view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							v-if="orderDetail.numberCode != null">
							<view style="flex: 1;color: #777;font-weight: 700;">
								订单号
							</view>
							<view style="color: #000;font-weight: 700;">
								{{orderDetail.numberCode == undefined ? '' : orderDetail.numberCode}}
							</view>
						</view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;">
							<view style="flex: 1;color: #777;font-weight: 700;">
								创建时间
							</view>
							<view style="color: #000;font-weight: 700;">
								{{orderDetail.createTime | formatTime}}
							</view>
						</view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							v-if="orderDetail.payTime != null">
							<view style="flex: 1;color: #777;font-weight: 700;">
								支付时间
							</view>
							<view style="color: #000;font-weight: 700;">
								{{orderDetail.payTime | formatTime}}
							</view>
						</view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							v-if="orderDetail.groupInfo && orderDetail.groupInfo.successTime">
							<view style="flex: 1;color: #777;font-weight: 700;">
								成团时间
							</view>
							<view style="color: #000;font-weight: 700;">
								{{orderDetail.groupInfo.successTime | formatTime}}
							</view>
						</view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							v-if="orderDetail.deliveryType == 2">
							<view style="flex: 1;color: #777;font-weight: 700;">
								核销时间
							</view>
							<view style="color: #000;font-weight: 700;">
								{{orderDetail.shopMakeTime | formatTime}}
							</view>
						</view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							v-if="orderDetail.deliveryType == 1">
							<view style="flex: 1;color: #777;font-weight: 700;">
								{{orderDetail.shopDelivery == 1 ? '商家配送员' : '配送员'}}
							</view>
							<view style="color: #000;font-weight: 700;display: flex;"
								v-if="orderDetail.deliveryInfo && orderDetail.deliveryInfo.workerId != null && orderDetail.deliveryInfo.workerId != ''">
								{{orderDetail.deliveryInfo.workerName != null ? orderDetail.deliveryInfo.workerName : ''}}
								<img @tap="makeCall(orderDetail.deliveryInfo.workerPhone)"
									src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/869a7af6a1c24bf3a0d523c4a18b55c6.png"
									alt="" style="width: 40rpx;height: 40rpx;margin: 20rpx 0 0 20rpx;" />
							</view>
							<view style="color: #000;font-weight: 700;" v-else>
								未指定等待接单中
							</view>
						</view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							v-if="orderDetail.deliveryType == 1 && orderDetail.shopDelivery == 1">
							<view style="flex: 1;color: #777;font-weight: 700;">
								配送方式
							</view>
							<view style="color: #ff6f2c;font-weight: 700;">
								商家自配送
							</view>
						</view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							v-if="orderDetail.deliveryInfo && orderDetail.deliveryInfo.transferDelivery == 1">
							<view style="flex: 1;color: #777;font-weight: 700;">
								中转配送
							</view>
							<view style="color: #ff6f2c;font-weight: 700;">
								{{orderDetail.deliveryInfo.transferAddressName || orderDetail.transferAddressName}}
							</view>
						</view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							v-if="orderDetail.deliveryInfo && orderDetail.deliveryInfo.transferDelivery == 1">
							<view style="flex: 1;color: #777;font-weight: 700;">
								送达中转点
							</view>
							<view style="color: #000;font-weight: 700;">
								{{orderDetail.deliveryInfo.transferArriveTime ? formatTimeText(orderDetail.deliveryInfo.transferArriveTime) : '未送达'}}
							</view>
						</view>
						<view style="display: flex;padding: 10rpx 0;"
							v-if="orderDetail.deliveryInfo && orderDetail.deliveryInfo.transferArriveImage">
							<view style="flex: 1;color: #777;font-weight: 700;">中转图片</view>
							<image :src="orderDetail.deliveryInfo.transferArriveImage" mode="aspectFill" style="width: 160rpx;height: 160rpx;border-radius: 12rpx;" @tap="previewImage(orderDetail.deliveryInfo.transferArriveImage)"></image>
						</view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							v-if="orderDetail.deliveryInfo && orderDetail.deliveryType == 1 && orderDetail.deliveryInfo.workerId">
							<view style="flex: 1;color: #777;font-weight: 700;">
								{{orderDetail.shopDelivery == 1 ? '商家配送接单时间' : '配送员接单时间'}}
							</view>
							<view style="color: #000;font-weight: 700;">
								{{orderDetail.deliveryInfo.acceptTime | formatTime}}
							</view>
						</view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							v-if="orderDetail.deliveryType == 1 && orderDetail.otherOrder == null">
							<view style="flex: 1;color: #777;font-weight: 700;">
								商家出餐时间
							</view>
							<view style="color: #000;font-weight: 700;"
								v-if="orderDetail.deliveryInfo && orderDetail.deliveryInfo.workerId != null && orderDetail.deliveryInfo.workerId != ''">
								{{orderDetail.shopMakeTime ? orderDetail.shopMakeTime : ''  | formatTime}}
							</view>
						</view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							v-if="orderDetail.deliveryInfo && orderDetail.deliveryType == 1 && orderDetail.deliveryInfo.workerId != '' && orderDetail.otherOrder == null">
							<view style="flex: 1;color: #777;font-weight: 700;">
								{{orderDetail.shopDelivery == 1 ? '商家到店时间' : '配送员到店时间'}}
							</view>
							<view style="color: #000;font-weight: 700;" v-if="orderDetail.deliveryInfo != null">
								{{formatTimeText(orderDetail.deliveryInfo.arriveTime)}}
							</view>
						</view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							v-if="orderDetail.deliveryInfo && orderDetail.deliveryType == 1 && orderDetail.deliveryInfo.workerId != ''">
							<view style="flex: 1;color: #777;font-weight: 700;">
								{{orderDetail.shopDelivery == 1 ? '商家取货时间' : '配送员取货时间'}}
							</view>
							<view style="color: #000;font-weight: 700;">
								{{orderDetail.deliveryInfo.getTime ? orderDetail.deliveryInfo.getTime : ''  | formatTime}}
							</view>
						</view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							v-if="orderDetail.deliveryType == 1 && orderDetail.deliveryInfo.finishTime">
							<view style="flex: 1;color: #777;font-weight: 700;">
								送达时间
							</view>
							<view style="color: #000;font-weight: 700;" v-if="orderDetail.deliveryInfo">
								{{orderDetail.deliveryInfo.finishTime ? orderDetail.deliveryInfo.finishTime : '尽快送达'  | formatTime}}
							</view>
						</view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							v-if="orderDetail.deliveryType == 1 && orderDetail.deliveryInfo.finishTime == null && (orderDetail.deliveryInfo.status == 0 || orderDetail.deliveryInfo.status == 1 || orderDetail.deliveryInfo.status == 2)">
							<view style="flex: 1;color: #777;font-weight: 700;">
								预计送达时间
							</view>
							<view style="color: #000;font-weight: 700;" v-if="orderDetail.deliveryInfo">
								{{orderDetail.deliveryInfo.mustFinishTime ? orderDetail.deliveryInfo.mustFinishTime : '尽快送达'  | formatTime}}
							</view>
						</view>
						<view style="height: 80rpx;line-height: 80rpx;display: flex;"
							>
							<view style="flex: 1;color: #777;font-weight: 700;">
								我的评价
							</view>
							<view style="color: #000;font-weight: 700;" @tap="checkEvaluate">
								查看评价 >
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 评价弹出层 -->
		<uni-popup ref="evaluatePopup" background-color="#fff">
			<view class="evaluate-content" @tap.stop>
				<view class="evaluate-popup-header">
					<view>
						<view class="evaluate-popup-title">我的评价</view>
						<view class="evaluate-popup-subtitle">共 {{orderDetail.comments ? orderDetail.comments.length : 0}} 条评价</view>
					</view>
					<view class="evaluate-popup-close" @tap="$refs.evaluatePopup.close()">关闭</view>
				</view>
				<scroll-view scroll-y class="evaluate-scroll" @touchmove.stop>
					<view class="evaluate-list" v-for="(item,index) in orderDetail.comments" :key="index">
						<view class="eval-title">
							<view class="eval-icon">
								<img :src="item.createByIcon" alt="" />
							</view>
							<view class="eval-name">
								<view class="name1">
									{{item.createByName || '微信用户'}}
								</view>
								<view class="eval-time">
									{{formatTimeText(item.createTime)}}
								</view>
							</view>
							<view class="eval-target-tag" :class="{'worker': isWorkerEvaluate(item)}">
								{{getEvaluateTargetText(item)}}
							</view>
						</view>
						<view class="eval-content">
							<view class="eval-rate-row">
								<text>{{getEvaluateTargetText(item)}}</text>
								<view class="eval-rate">
									<uni-rate :value="Number(item.score || 0)" size="14" readonly />
								</view>
							</view>
							<view class="eval-text">
								{{item.remark || '暂无文字评价'}}
							</view>
							<view class="eval-img" v-if="item.picture">
								<img @tap.stop="previewImage(item.picture)" :src="item.picture" alt="">
							</view>
							<view class="reply-card" :class="{'expanded': isExpanded}"
								v-for="(item1,index1) in item.comments" :key="index1">
								<view class="reply-header">
									<view class="reply-content" :class="{ collapsed: !isExpanded, expanded: isExpanded }">
										<text>{{item1.createByName}} : {{ item1.remark }}</text>
									</view>
									<view class="reply-expand-btn" @tap.stop="toggleReply">
										<text v-if="!isExpanded">展开</text>
										<text v-else>收起</text>
									</view>
								</view>
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
		</uni-popup>
		<!-- 核销二维码弹出层 -->
		<uni-popup ref="imgPopup" background-color="#fff">
			<view class="img-popup-content" @tap="$refs.imgPopup.close()">
				<uqrcode :hide='true' ref="uqrcode" size="160" sizeUnit="rpx" canvas-id="qrcode"
					:value="orderDetail.id + '@@'+ orderDetail.shopId">
				</uqrcode>
				<img :src="newQRList" alt=""
					style="width: 330rpx;height: 330rpx;margin: 282rpx 0 0 136rpx;border: 20rpx solid rgba(222, 255, 248, 1);border-radius: 20rpx;">
			</view>
		</uni-popup>

		<uni-popup ref="returnPopup" type="bottom" background-color="#fff" @change="onCancelPopupChange">
			<view class="car-content cancel-popup">
				<view class="car-close" @tap="$refs.returnPopup.close()">
					<uni-icons type="close" size="24" color="#243f38"></uni-icons>
				</view>
				<view class="car-title" style="padding: 0 20rpx;">
					选择退款原因
				</view>
				<scroll-view scroll-y class="cancel-scroll" @touchmove.stop>
					<view class="guize-list">
						<view class="cancel-warning-card">
							<view class="cancel-warning-line">
								<uni-icons type="info" size="14" color="#ff5722"></uni-icons>
								<text
								v-if="(((payData.orderType == 2 || payData.orderType == 3) && payData.status == 2) || ((payData.orderType == 2 || payData.orderType == 3) && payData.status == 3)  || (payData.deliveryType == 1 && payData.status == 3) || payData.status == 4) && payData.otherOrder == null">
									请确认责任方，取消订单需要责任方同意！{{orderDetail.orderType == 3 ? '团员订单会一并退款！' : ''}}
								</text>
								<text v-else>请选择退款原因</text>
							</view>
							<view class="cancel-time-tips">
								<view class="cancel-warning-line" v-if="payData.shopMakeTime == null && payData.otherOrder == null">
									<uni-icons type="info" size="14" color="#ff5722"></uni-icons>
									<text>
										商家还未出餐
									</text>
								</view>
								<view class="cancel-warning-line" v-if="payData.shopMakeTime != null">
									<uni-icons type="info" size="14" color="#ff5722"></uni-icons>
									<text>
										商家已出餐
									</text>
								</view>
								<view class="cancel-warning-line" v-if="payData.otherOrder == null && payData.deliveryType == 1">
									<uni-icons type="info" size="14" color="#ff5722"></uni-icons>
									<text>
										配送员到店时间：{{arriveTime}}
									</text>
								</view>
								<view class="cancel-warning-line" v-if="payData.shopMakeTime != null && payData.otherOrder == null && payData.deliveryType == 1">
									<uni-icons type="info" size="14" color="#ff5722"></uni-icons>
									<text>
										本单商家备餐时长：{{shopTime}}
									</text>
								</view>
								<view class="cancel-warning-line" v-if="payData.shopMakeTime != null && payData.otherOrder == null && payData.deliveryType == 1">
									<uni-icons type="info" size="14" color="#ff5722"></uni-icons>
									<text>
										配送员配送时长：{{peisongTime}}
									</text>
								</view>
							</view>
						</view>
					</view>
				<view style="padding: 0 20rpx;">
					<view class="cancel-type-item" v-if="orderDetail.otherOrder != 1">
						<radio :checked="sellTime==2" name="sellTime" @click="checkSellTime(2)" />
						全额退款（商家退款）
					</view>
					<view class="cancel-type-item" v-if="payData.deliveryType ==1">
						<radio :checked="sellTime==3" name="sellTime" @click="checkSellTime(3)" />
						全额退款（配送员退款）
					</view>
					<view class="cancel-type-item" v-if="payData.deliveryType ==1 && orderDetail.otherOrder != 1">
						<radio :checked="sellTime==4" name="sellTime" @click="checkSellTime(4)" />
						全额退款（商家退商品+配送员退配送费）
					</view>
					<!-- <view class="cancel-type-item">
						<radio :checked="sellTime==5" name="sellTime" @click="checkSellTime(5)" />
						其他
					</view> -->
				</view>
				<view class="cancel-section">
					<view class="cancel-section-title">具体原因（可多选）</view>
					<view class="cancel-option-list">
						<view :class="selectedCancelReasonOptions.indexOf(item) !== -1 ? 'cancel-option checked' : 'cancel-option'"
							v-for="(item,index) in cancelReasonOptions" :key="index" @tap="toggleCancelReasonOption(item)">
							{{item}}
						</view>
					</view>
				</view>
				<view class="cancel-section">
					<view class="cancel-section-title">取消原因</view>
					<textarea class="cancel-textarea" placeholder="请选择或填写取消原因" maxlength="50"
						v-model="returnData.reason" @input="onReturnReasonInput"></textarea>
				</view>
				<view class="cancel-section">
					<view class="cancel-section-title">上传图片</view>
					<view class="cancel-upload-row">
						<view class="cancel-upload-img cancel-upload-btn" @tap="pictureAdd">
							<uni-icons type="camera" size="28" color="#777"></uni-icons>
						</view>
						<view v-if="returnData.pictures !=''" class="cancel-upload-preview">
							<img :src="returnData.pictures" alt="" class="cancel-upload-img">
						</view>
					</view>
				</view>
				
				</scroll-view>
				<view class="btn cancel-confirm-btn" @tap="returnOrder()">
					确认取消
				</view>
			</view>
		</uni-popup>

		<uni-popup ref="noResponsibilityCancelPopup" type="center" background-color="transparent">
			<view class="no-responsibility-cancel-popup">
				<view class="no-responsibility-cancel-title">确认取消订单吗</view>
				<view class="no-responsibility-cancel-desc">符合无责取消条件，订单金额将按平台退款处理</view>
				<view class="no-responsibility-cancel-desc" v-if="orderDetail.orderType == 3">团员订单会一并退款！</view>
				<view class="no-responsibility-cancel-actions">
					<view class="no-responsibility-cancel-btn no-responsibility-cancel-btn-muted"
						@tap="$refs.noResponsibilityCancelPopup.close()">
						再想想
					</view>
					<view class="no-responsibility-cancel-btn no-responsibility-cancel-btn-confirm"
						@tap="confirmNoResponsibilityCancel()">
						确认取消
					</view>
				</view>
			</view>
		</uni-popup>

		<!-- 待支付订单支付弹出层 -->
		<uni-popup ref="payPopup" background-color="#fff">
			<view class="pay-popup">
				<view class="pay-popup-content">
					<view class="box1">
						<view style="height: 70rpx;line-height: 70rpx;text-align: center;">
							微信支付
						</view>
						<view
							style="height: 90rpx;line-height: 90rpx;text-align: center;font-weight: 700;font-size: 30rpx;">
							￥<text style="font-size: 60rpx;">{{payAmountText}}</text>
						</view>
					</view>
					
					<view class="box1" style="display: flex;padding: 40rpx;">
						<view style="flex: 1;">
							<view style="height: 42rpx;line-height: 42rpx;display: flex;">
								<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/4c8e0cc311db4d38ab43e019673c4b8c.png"
									alt="" style="width: 42rpx;height: 42rpx;margin-right: 20rpx;" />
								<text style="font-size: 30rpx;font-weight: 700;">微信支付</text>
							</view>
							<view style="text-align: right;margin-left: 60rpx;color: #777;width: 146rpx;">
								使用微信支付
							</view>
						</view>
						<view style="width: 36rpx;padding-top: 20rpx;">
							<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/02bff7edc4e04caaa1868955ff684f1f.png"
								alt="" style="width: 36rpx;height: 36rpx;" />
						</view>
					</view>
					<view class="btn"
						style="background: linear-gradient(90deg, rgba(227, 255, 150, 1), rgba(166, 255, 234, 1));width: 90%;height: 100rpx;border-radius: 100rpx;text-align: center;font-size: 28rpx;font-weight: 700;line-height: 100rpx;margin: 40rpx auto;"
						@tap="wxPayment">
						确认付款
					</view>
				</view>
			</view>
		</uni-popup>

		<uni-popup ref="returnPopupBuy" background-color="#fff">
			<view class="group-buy-cancel-popup">
				<view class="group-buy-cancel-title">
					{{groupBuyCancelPopupType == 'cancel' ? '确定取消拼团订单吗？' : '确定要取消拼团吗'}}
				</view>
				<view class="group-buy-cancel-desc" v-if="groupBuyCancelPopupType != 'cancel'">
					取消后本单金额将退回，并转为直接购买
				</view>
				<view class="group-buy-cancel-actions">
					<view class="group-buy-cancel-btn group-buy-cancel-btn-muted" @tap="$refs.returnPopupBuy.close()">
						取消
					</view>
					<view class="group-buy-cancel-btn group-buy-cancel-btn-confirm" @tap="confirmGroupBuyCancelPopup()">
						确认
					</view>
				</view>
			</view>
		</uni-popup>

		<uni-popup ref="addFeePopup" type="center" background-color="transparent" @change="onCancelPopupChange">
			<view class="commission-popup">
				<view class="commission-popup-title">增加配送佣金</view>
				<view class="commission-popup-desc">最低 0.1 元，最高 200 元，最多输入 2 位小数</view>
				<view class="commission-popup-input">
					<text>￥</text>
					<input type="digit" :value="additionalFee" @input="onAdditionalFeeInput" />
				</view>
				<view class="commission-popup-actions">
					<view class="commission-popup-cancel" @tap="$refs.addFeePopup.close()">取消</view>
					<view class="commission-popup-confirm" @tap="submitAddFee">去支付</view>
				</view>
			</view>
		</uni-popup>

		<!-- 增加佣金支付弹出层 -->
		<uni-popup ref="addFeePayPopup" background-color="#fff" @change="onCancelPopupChange">
			<view class="pay-popup">
				<view class="pay-popup-content">
					<view class="box1">
						<view style="height: 70rpx;line-height: 70rpx;text-align: center;">
							增加配送佣金
						</view>
						<view
							style="height: 90rpx;line-height: 90rpx;text-align: center;font-weight: 700;font-size: 30rpx;">
							￥<text style="font-size: 60rpx;">{{additionalFee || '0.00'}}</text>
						</view>
					</view>
					<view class="btn"
						style="background: linear-gradient(90deg, rgba(227, 255, 150, 1), rgba(166, 255, 234, 1));width: 90%;height: 100rpx;border-radius: 100rpx;text-align: center;font-size: 28rpx;font-weight: 700;line-height: 100rpx;margin: 40rpx auto;"
						@tap="addFeeWxPayment">
						确认付款
					</view>
					<view class="box1" style="display: flex;padding: 40rpx;">
						<view style="flex: 1;">
							<view style="height: 42rpx;line-height: 42rpx;display: flex;">
								<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/4c8e0cc311db4d38ab43e019673c4b8c.png"
									alt="" style="width: 42rpx;height: 42rpx;margin-right: 20rpx;" />
								<text style="font-size: 30rpx;font-weight: 700;">微信支付</text>
							</view>
							<view style="text-align: right;margin-left: 60rpx;color: #777;width: 146rpx;">
								使用微信支付
							</view>
						</view>
						<view style="width: 36rpx;padding-top: 20rpx;">
							<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/02bff7edc4e04caaa1868955ff684f1f.png"
								alt="" style="width: 36rpx;height: 36rpx;" />
						</view>
					</view>

				</view>
			</view>
		</uni-popup>
		<common-loading />
	</view>
</template>

<script>
	import { buildGroupHomeSharePath } from '@/utils/sharePath.js'
	export default {
		data() {
			return {
				newQRList: '',
				pintuan: false,
				sellTime: '',
				menuButtonInfo: {},
				refundType: 3,
				refundTypeStatus: 1,
				returnData: {
					reason: '',
					pictures: ''
				},
				cancelReasonOptions: [ '不想要了','配送超时', '收到的商品少了', '骑手送错地址', '收到的商品错了', '商家出餐超时', '餐品损坏或撒了', '商品质量问题'],
				selectedCancelReasonOptions: [],
				popupPageStyle: '',
				shopTime: '',
				arriveTime:'',
				hasRefund: false,
				peisongTime: '',
				shopItem: {},
				orderId: '',
				payData: {},
				orderDetail: {
					userCouponNum: 0
				},
				codeImg: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/3a4e68eb14d7417cbb4f15fa85907c64.jpg',
				additionalFee: '',
				addFeeTradeNo: '',
				pendingAddFeeWorker: null,
				addFeeAutoPayOpened: false,
				addFeePollTimer: null,
				isRefreshing: false,
				groupBuyCancelPopupType: 'buy',
				assignWorkerModalVisible: false,
				assignWorkerSelectionKey: '',
				payCountdownText: '60:00',
				payCountdownSeconds: 0,
				payCountdownTimer: null,
				isExpanded: false,
				refundAmountMode: 'user'
			}
		},
		computed: {
			payAmountText() {
				let amount = Number(this.orderDetail.totalAmount || 0);
				return amount ? amount.toFixed(2) : '0.00';
			},
			isStatusAddressLong() {
				let address = this.orderDetail.deliveryInfo && this.orderDetail.deliveryInfo.receiverAddress
					? this.orderDetail.deliveryInfo.receiverAddress
					: '';
				return String(address).length > 20;
			},
			orderFlowFinalName() {
				const statusNameMap = {
					7: '待同意退款',
					8: '已退款',
					11: '售后中',
					12: '已售后'
				};
				return statusNameMap[Number(this.orderDetail.status)] || '已完成';
			},
			isOrderFlowFinalActive() {
				return [5, 7, 8, 11, 12].includes(Number(this.orderDetail.status));
			}
		},
		components: {

		},
		filters: {
			formatHourMinute(value) {
				if (!value) return '';

				const date = new Date(value);

				// 获取日 (getDate)，并补齐0
				const day = String(date.getDate()).padStart(2, '0');

				// 获取小时 (getHours)，并补齐0
				const hour = String(date.getHours()).padStart(2, '0');

				// 获取分钟 (getMinutes)，并补齐0
				const minute = String(date.getMinutes()).padStart(2, '0');

				// 拼接格式：日-日-时:分
				return `${hour}:${minute}`;
			},
			formatTime(value) {
				if (!value) return '';
				if (value == '尽快送达') return '尽快送达';
				let date = new Date(value);
				if (isNaN(date.getTime())) {
					const normalized = String(value).replace(/-/g, '/').replace('T', ' ').split('.')[0];
					date = new Date(normalized);
				}
				if (isNaN(date.getTime())) return '';

				// 获取年份
				const year = date.getFullYear();

				// 获取月份 (getMonth 返回 0-11，所以需要 +1)，并补齐0
				const month = String(date.getMonth() + 1).padStart(2, '0');

				// 获取日 (getDate)，并补齐0
				const day = String(date.getDate()).padStart(2, '0');

				// 获取小时 (getHours)，并补齐0
				const hour = String(date.getHours()).padStart(2, '0');

				// 获取分钟 (getMinutes)，并补齐0
				const minute = String(date.getMinutes()).padStart(2, '0');

				// 获取秒 (getSeconds)，并补齐0
				const second = String(date.getSeconds()).padStart(2, '0');

				// 拼接格式：年-月-日 时:分:秒
				return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
			},
			delNode(data) {
				// 1. 统一转为字符串
				let str;
				if (typeof data === 'object' && data !== null) {
					// 对象或数组 → JSON 字符串
					str = JSON.stringify(data);
				} else if (typeof data === 'string') {
					str = data;
				} else {
					// 其他类型（数字、布尔等）先转字符串
					str = String(data);
				}

				// 2. 删除所有大括号 { } 和双引号 "
				const result = str.replace(/[{}"]/g, '');
				return result;
			}
		},
		onLoad(option) {
			if (option.id) {
				this.orderId = option.id
			}
			if (option.refundAmountMode) {
				this.refundAmountMode = option.refundAmountMode
			}
			// 监听配送员选择事件（在onLoad中注册一次，确保事件不会丢失）
			uni.$on('updateDeliveryWorker', (worker) => {
				this.handleWorkerSelected(worker);
			});
		},
		onShow() {
			this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
			let pendingAddCommissionWorker = uni.getStorageSync('pendingAddCommissionWorker');
			if (pendingAddCommissionWorker) {
				uni.removeStorageSync('pendingAddCommissionWorker');
				this.prepareAddFeeForWorker(pendingAddCommissionWorker);
			}
			// 备用方案：检查缓存中是否有待处理的配送员选择
			let pendingWorker = uni.getStorageSync('pendingAssignWorker');
			if (pendingWorker) {
				uni.removeStorageSync('pendingAssignWorker');
				this.handleWorkerSelected(pendingWorker);
			}
			if (this.orderId) {
				this.getOrderDetail(this.orderId);
			}
		},
		onShareAppMessage(res) {
			let that = this
			let groupId = that.orderDetail.groupInfo.id;
			let targetMembers = that.orderDetail.groupInfo.targetMembers;
			let isFTF = that.orderDetail.orderType == 3 ? 1 : 0;
			let shopId = that.orderDetail.shopId || that.shopItem.id || '';

			return {
				title: '快来一起拼单吧！',
				path: buildGroupHomeSharePath({
					shopId: shopId,
					groupId: groupId,
					targetMembers: targetMembers,
					isFaceToFace: isFTF
				}),
				imageUrl: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/62c9aa038b2541ad9c400a76ddae7ef8.png'
			}
		},
		onPullDownRefresh() { 
		    this.getOrderDetail(this.orderId)
		},
		onHide() {
			this.stopPayCountdown();
		},
		onUnload() {
			uni.$off('updateDeliveryWorker');
			this.stopPayCountdown();
			this.stopAddFeePolling();
		},

		methods: {
			getDisplayRefundAmount(item) {
				if (!item) return 0;
				if (this.refundAmountMode == 'settlement') {
					return item.settlementAmount != null ? item.settlementAmount : item.refundAmount;
				}
				return item.refundAmount;
			},
			startPayCountdown() {
				this.stopPayCountdown();
				if (this.orderDetail.status != 0 || !this.orderDetail.createTime) {
					this.setPayCountdown(0);
					return;
				}
				this.setPayCountdown(this.getPayCountdownSeconds());
				this.payCountdownTimer = setInterval(() => {
					if (this.orderDetail.status != 0) {
						this.stopPayCountdown();
						return;
					}
					this.setPayCountdown(Math.max(this.payCountdownSeconds - 1, 0));
					if (this.payCountdownSeconds <= 0) {
						this.stopPayCountdown();
					}
				}, 1000);
			},
			stopPayCountdown() {
				if (this.payCountdownTimer) {
					clearInterval(this.payCountdownTimer);
					this.payCountdownTimer = null;
				}
			},
			getPayCountdownSeconds() {
				const createTime = this.parseOrderTime(this.orderDetail.createTime);
				if (!createTime) {
					return 0;
				}
				const expireTime = createTime.getTime() + 60 * 60 * 1000;
				const remainMs = expireTime - Date.now();
				return Math.max(Math.floor(remainMs / 1000), 0);
			},
			setPayCountdown(totalSeconds) {
				this.payCountdownSeconds = totalSeconds;
				const minutes = String(Math.floor(totalSeconds / 60)).padStart(2, '0');
				const seconds = String(totalSeconds % 60).padStart(2, '0');
				this.payCountdownText = `${minutes}:${seconds}`;
				this.$forceUpdate();
			},
			parseOrderTime(value) {
				if (!value) return null;
				if (value instanceof Date) return isNaN(value.getTime()) ? null : value;
				let date = new Date(value);
				if (!isNaN(date.getTime())) {
					return date;
				}
				const normalized = String(value).replace(/-/g, '/').replace('T', ' ').split('.')[0];
				date = new Date(normalized);
				return isNaN(date.getTime()) ? null : date;
			},
			formatTimeText(value) {
				if (!value) return '';
				if (value == '尽快送达') return '尽快送达';
				const date = this.parseOrderTime(value);
				if (!date) return '';
				const year = date.getFullYear();
				const month = String(date.getMonth() + 1).padStart(2, '0');
				const day = String(date.getDate()).padStart(2, '0');
				const hour = String(date.getHours()).padStart(2, '0');
				const minute = String(date.getMinutes()).padStart(2, '0');
				const second = String(date.getSeconds()).padStart(2, '0');
				return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
			},
			isWorkerEvaluate(item) {
				const shopId = item && item.shopId ? String(item.shopId) : '';
				return shopId.charAt(0).toUpperCase() == 'W';
			},
			getEvaluateTargetText(item) {
				return this.isWorkerEvaluate(item) ? '配送员评价' : '商家评价';
			},
			previewImage(url) {
				if (!url) return;
				uni.previewImage({
					current: url,
					urls: [url]
				});
			},
			isRefundPending(item) {
				return item && (item.status == 0 || item.status == 3);
			},
			getAutoRefundTime(value) {
				if (!value) return '';
				const date = new Date(value);
				if (isNaN(date.getTime())) return '';
				date.setHours(date.getHours() + 1);
				const year = date.getFullYear();
				const month = String(date.getMonth() + 1).padStart(2, '0');
				const day = String(date.getDate()).padStart(2, '0');
				const hour = String(date.getHours()).padStart(2, '0');
				const minute = String(date.getMinutes()).padStart(2, '0');
				const second = String(date.getSeconds()).padStart(2, '0');
				return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
			},
			openCode() {
				let that = this
				this.$refs.imgPopup.open()
				this.$refs.uqrcode.toTempFilePath({
					success: res => {
						
						that.newQRList = res.tempFilePath
					},
					fail: err => {}
				});
			},
			pictureAdd(id, huan) {
				let that = this
				uni.chooseMedia({
					count: 9,
					mediaType: ['image'],
					sourceType: ['album', 'camera'],
					success(res) {
						uni.showLoading({
							title: '加载中...',
							mask: true
						})
						for (let i = 0; i < res.tempFiles.length; i++) {
							that.upLoadFile(res.tempFiles[i].tempFilePath)
						}
					}
				})
			},
			async upLoadFile(path) {
				let that = this;
				let hiver_token = uni.getStorageSync("hiver_token")
				await uni.uploadFile({
					url: that.tui.interfaceUrl() + '/upload/file',
					filePath: path,
					name: 'file',
					header: {
						"content-type": "multipart/form-data",
						'accessToken': hiver_token
					},
					formData: {},
					success: (uploadFileRes) => {
						let pathData = JSON.parse(uploadFileRes.data)
						that.returnData.pictures = pathData.result
						that.$forceUpdate()
					},
					fail: (err) => {
						uni.hideLoading();
						uni.showToast({
							title: JSON.stringify(err),
							icon: 'none'
						})
					}
				});
				await setTimeout(res => {
					uni.hideLoading();
				}, 1000)
			},
			//立即备餐
			makeMeal() {
				let that = this;
				uni.showModal({
					title: '提示',
					content: "是否立刻通知商家备餐？",
					success: function(res) {
						if (res.confirm) {
							that.tui.request("/mall/order/userRequireMake", "POST", {
								orderId: that.orderDetail.id,
							}, false, true).then((res) => {
								if (res.code == 200) {
									that.tui.toast('通知成功！');
									that.getOrderDetail(that.orderId)
								} else {
									that.tui.toast(res.message);
									return;
								}
								uni.hideLoading();
							}).catch((res) => {});
						}
					}
				});
			},
			checkSellTime(type) {
				this.sellTime = type;
				if (this.sellTime == 2) {
					//this.returnData.refundAmount = this.orderDetail.totalAmount
					this.refundType = 3
					this.refundTypeStatus = 1
				} else if (this.sellTime == 3) {
					//this.returnData.refundAmount = this.orderDetail.totalAmount
					this.refundType = 3
					this.refundTypeStatus = 2
				} else {
					//this.returnData.refundAmount = this.orderDetail.totalAmount
					this.refundType = 3
					this.refundTypeStatus = 3
				}
			},
			onCancelPopupChange(e) {
				this.popupPageStyle = e.show ? 'height:100vh;overflow:hidden;' : '';
			},
			toggleCancelReasonOption(item) {
				let index = this.selectedCancelReasonOptions.indexOf(item);
				if (index === -1) {
					this.selectedCancelReasonOptions.push(item);
				} else {
					this.selectedCancelReasonOptions.splice(index, 1);
				}
				this.returnData.reason = this.limitReasonText(this.selectedCancelReasonOptions.join('、'));
			},
			limitReasonText(value) {
				return String(value || '').slice(0, 50);
			},
			onReturnReasonInput(e) {
				this.returnData.reason = this.limitReasonText(e.detail.value);
				return this.returnData.reason;
			},
			makeCall(phone) {
				if (!phone) {
					this.tui.toast("暂无联系电话");
					return;
				}
				uni.makePhoneCall({
					phoneNumber: phone
				});
			},
			callPlatformService() {
				let regionId = this.getCurrentRegionId();
				if (!regionId) {
					this.tui.toast("请选择校区");
					return;
				}
				let that = this;
				that.tui.request("/mall/admin/seckillGroup/customerPhone/get", "GET", {
					regionId: regionId
				}, false, true).then((res) => {
					if (res.code == 200) {
						that.makeCall(res.result);
					} else {
						that.tui.toast(res.message || "获取客服电话失败");
					}
				}).catch((res) => {
					that.tui.toast("获取客服电话失败");
				});
			},
			getCurrentRegionId() {
				let area = uni.getStorageSync('area');
				if (!area) return '';
				if (typeof area === 'object') {
					return area.id || '';
				}
				try {
					return JSON.parse(area).id || '';
				} catch (e) {
					return '';
				}
			},
			checkEvaluate() {
				if (this.orderDetail.comments != null && this.orderDetail.comments.length > 0) {
					this.$refs.evaluatePopup.open()
				} else {
					this.tui.toast("暂无评价");
				}
			},
			toggleReply() {
				this.isExpanded = !this.isExpanded;
			},
			orderStatus(item) {
				if (item.status == 0 || item.status == 10 || item.status == 2 || (item.status == 3 && item.deliveryType ==
						1) || (item.status == 3 && item.deliveryType == 2) || item.status == 4) {
					return true;
				}
				return false;
			},
			orderStatusBuy(item) {
				if (item.status == 10) {
					return true;
				}
				return false;
			},
			hasNoDeliveryWorker(item) {
				return !item || !item.deliveryInfo || !item.deliveryInfo.workerId || item.deliveryInfo.status === 0;
			},
			isGroupSuccess(item) {
				return item && item.groupInfo && (item.groupInfo.status == 1 || item.groupInfo.successTime);
			},
			isAfterGroupSuccessMinutes(item, minutes) {
				if (!item || !item.groupInfo || !item.groupInfo.successTime) {
					return false;
				}
				const successTime = this.parseOrderTime(item.groupInfo.successTime);
				if (!successTime) {
					return false;
				}
				return Date.now() - successTime.getTime() >= minutes * 60 * 1000;
			},
			isNoResponsibilityCancel(item) {
				if (!item) return false;

				const isNormalOrder = item.orderType == 1 && item.otherOrder == null;
				const isGroupDeliveryOrder = item.deliveryType == 1 && item.otherOrder == null && this.isGroupSuccess(item);
				const isSelfPickupNoMake = item.deliveryType == 2 && item.status == 3 && isNormalOrder &&
					(item.userRequireMake == null || item.userRequireMake == 0) && !item.shopMakeTime;
					
				if(item.otherOrder == 2 && (item.orderType != 1)){
					return false;
				}	

				if (isNormalOrder && item.deliveryType == 1 && this.hasNoDeliveryWorker(item)) {
					return true;
				}
				if (isSelfPickupNoMake) {
					return true;
				}
				if (isGroupDeliveryOrder && item.orderType == 3 && item.groupInfo.headOrderId == item.id &&
					this.hasNoDeliveryWorker(item)) {
					return true;
				}
				if (isGroupDeliveryOrder && item.orderType == 2 && this.isAfterGroupSuccessMinutes(item, 10) &&
					this.hasNoDeliveryWorker(item)) {
					return true;
				}
				if (item.otherOrder == 2 && item.status == 3 && !item.shopMakeTime) {
					return true;
				}
				if (item.otherOrder == 1 && this.hasNoDeliveryWorker(item)) {
					return true;
				}
				return false;
			},
			shouldCheckCancelOrderLatest(item) {
				return item && item.deliveryType == 1 && item.status == 2;
			},
			getOrderDetailForCancelCheck(id) {
				return this.tui.request("/mall/order/detail/" + id, "GET", {}, false, true, true).then((res) => {
					if (res.code == 200) {
						return res.result;
					}
					this.tui.toast(res.message || "订单状态校验失败");
					return null;
				}).catch(() => {
					this.tui.toast("订单状态校验失败");
					return null;
				});
			},
			async returnPopupProp(item) {
				let latestItem = item;
				this.payData = item;
				if (item.status == 0) {
					this.cancelUnpaidOrder(item);
					return;
				}
				if (this.shouldCheckCancelOrderLatest(item)) {
					let latestDetail = await this.getOrderDetailForCancelCheck(item.id);
					if (!latestDetail) {
						return;
					}
					let isNoResponsibility = this.isNoResponsibilityCancel(latestDetail);
					if (!isNoResponsibility && latestDetail.status != item.status) {
						this.getOrderDetail(latestDetail.id);
						uni.showModal({
							title: '提示',
							content: '订单状态已发生变化，请确认是否取消订单',
							confirmText: '继续退款',
							success: (res) => {
								if (res.confirm) {
									this.openResponsibilityCancelPopup(latestDetail);
								}
							}
						});
						return;
					}
					latestItem = latestDetail;
					this.payData = latestDetail;
				}
				if (this.isNoResponsibilityCancel(latestItem)) {
					this.$refs.noResponsibilityCancelPopup.open('center');
					return;
				}

				this.openResponsibilityCancelPopup(latestItem);
			},
			openResponsibilityCancelPopup(item) {
				this.payData = item;
				if (this.payData.otherOrder == 1) {
					this.refundType = 3
					this.refundTypeStatus = 2
					this.sellTime = 3
				}
				if(this.payData.deliveryInfo && this.payData.deliveryInfo.arriveTime){
					this.arriveTime = this.payData.deliveryInfo.arriveTime ? this.formatTimeText(this.payData.deliveryInfo.arriveTime) : '未到店'
				}
				if (this.payData.shopMakeTime != null && this.payData.deliveryInfo && this.payData.deliveryInfo.acceptTime) {
					const date1 = new Date(this.payData.deliveryInfo.acceptTime);
					const date2 = new Date(this.payData.shopMakeTime);

					// 2. 计算毫秒差值 (取绝对值，防止结果为负数)
					let diffMs = Math.abs(date2 - date1);

					// 3. 数学换算
					// 1秒 = 1000毫秒
					// 1分 = 60秒
					// 1时 = 60分
					const seconds = Math.floor((diffMs / 1000) % 60);
					const minutes = Math.floor((diffMs / (1000 * 60)) % 60);
					const hours = Math.floor(diffMs / (1000 * 60 * 60));

					// 4. 格式化输出 (可选：补零操作，例如 9秒 -> 09秒)
					const fmt = (num) => num.toString().padStart(2, '0');

					this.shopTime = `${fmt(hours)}时${fmt(minutes)}分${fmt(seconds)}秒`;

					const date3 = new Date();

					// 2. 计算毫秒差值 (取绝对值，防止结果为负数)
					let diffMs1 = Math.abs(date3 - date2);

					// 3. 数学换算
					// 1秒 = 1000毫秒
					// 1分 = 60秒
					// 1时 = 60分
					const seconds1 = Math.floor((diffMs1 / 1000) % 60);
					const minutes1 = Math.floor((diffMs1 / (1000 * 60)) % 60);
					const hours1 = Math.floor(diffMs1 / (1000 * 60 * 60));

					this.peisongTime = `${fmt(hours1)}时${fmt(minutes1)}分${fmt(seconds1)}秒`;
				}
				if (item.status == 10) {
					this.groupBuyCancelPopupType = 'cancel';
					this.$refs.returnPopupBuy.open('bottom');
				} else {
					this.$refs.returnPopup.open('bottom');
				}
				
			},
			cancelUnpaidOrder(item) {
				let that = this;
				that.tui.request("/mall/order/cancel", "POST", {
					refundType: 3,
					refundTypeStatus: 1,
					orderId: item.id,
					userId: uni.getStorageSync('id')
				}, false, true).then((res) => {
					uni.hideLoading();
					if (res.code == 200) {
						that.tui.toast("操作成功");
						that.getOrderDetail(item.id);
						that.$forceUpdate();
					} else {
						that.tui.toast(res.message, 2000);
					}
				}).catch((res) => {});
			},
			confirmNoResponsibilityCancel() {
				this.$refs.noResponsibilityCancelPopup.close();
				let item = this.payData;
				let that = this;
				that.tui.request("/mall/order/cancel", "POST", {
					status: 1,
					refundType: 3,
					refundTypeStatus: 4,
					orderId: item.id,
					userId: uni.getStorageSync('id')
				}, false, true).then((res) => {
					uni.hideLoading();
					if (res.code == 200) {
						that.tui.toast("操作成功");
						that.getOrderDetail(item.id);
						that.$forceUpdate();
					} else {
						that.tui.toast(res.message, 2000);
					}
				}).catch((res) => {});
			},
			returnPopupPropBuy(item) {
				this.payData = item;
				this.groupBuyCancelPopupType = 'buy';
				if (this.payData.shopMakeTime != null) {
					const date1 = new Date(this.payData.deliveryInfo.acceptTime);
					const date2 = new Date(this.payData.shopMakeTime);

					// 2. 计算毫秒差值 (取绝对值，防止结果为负数)
					let diffMs = Math.abs(date2 - date1);

					// 3. 数学换算
					// 1秒 = 1000毫秒
					// 1分 = 60秒
					// 1时 = 60分
					const seconds = Math.floor((diffMs / 1000) % 60);
					const minutes = Math.floor((diffMs / (1000 * 60)) % 60);
					const hours = Math.floor(diffMs / (1000 * 60 * 60));

					// 4. 格式化输出 (可选：补零操作，例如 9秒 -> 09秒)
					const fmt = (num) => num.toString().padStart(2, '0');

					this.shopTime = `${fmt(hours)}时${fmt(minutes)}分${fmt(seconds)}秒`;

					const date3 = new Date();

					// 2. 计算毫秒差值 (取绝对值，防止结果为负数)
					let diffMs1 = Math.abs(date3 - date2);

					// 3. 数学换算
					// 1秒 = 1000毫秒
					// 1分 = 60秒
					// 1时 = 60分
					const seconds1 = Math.floor((diffMs1 / 1000) % 60);
					const minutes1 = Math.floor((diffMs1 / (1000 * 60)) % 60);
					const hours1 = Math.floor(diffMs1 / (1000 * 60 * 60));

					this.peisongTime = `${fmt(hours1)}时${fmt(minutes1)}分${fmt(seconds1)}秒`;
				}
				this.$refs.returnPopupBuy.open('bottom');
			},
			returnOrder() {
				if(this.sellTime == ''){
					this.tui.toast("请选择退款责任方");
					return
				}
				this.$refs.returnPopup.close();
				let item = this.payData
				let that = this
				this.returnData.reason = this.limitReasonText(this.returnData.reason)
				that.tui.request("/mall/order/cancel", "POST", {
					refundType: this.refundType,
					refundTypeStatus: this.refundTypeStatus,
					orderId: item.id,
					userId: uni.getStorageSync('id'),
					reason: this.returnData.reason,
					pictures: this.returnData.pictures
				}, false, true).then((res) => {
					uni.hideLoading();
					if (res.code == 200) {
						that.tui.toast("操作成功");
						that.getOrderDetail(item.id)
						that.$forceUpdate();
					} else {
						that.tui.toast(res.message,2000);
					}
					
				}).catch((res) => {});
			},
			confirmGroupBuyCancelPopup() {
				if (this.groupBuyCancelPopupType == 'cancel') {
					this.returnGroupOrder();
					return;
				}
				this.returnOrderBuy();
			},
			returnGroupOrder() {
				this.$refs.returnPopupBuy.close();
				let item = this.payData;
				let that = this;
				that.tui.request("/mall/order/cancel", "POST", {
					refundType: 3,
					refundTypeStatus: 1,
					orderId: item.id,
					userId: uni.getStorageSync('id')
				}, false, true).then((res) => {
					uni.hideLoading();
					if (res.code == 200) {
						that.tui.toast("操作成功");
						that.getOrderDetail(item.id);
						that.$forceUpdate();
					} else {
						that.tui.toast(res.message, 2000);
					}
				}).catch((res) => {});
			},
			returnOrderBuy() {
				this.$refs.returnPopupBuy.close();
				let item = this.payData
				let that = this
				that.tui.request("/mall/order/cancel", "POST", {
					refundType: 3,
					refundTypeStatus: 4,
					orderId: item.id,
					userId: uni.getStorageSync('id')
				}, false, true).then((res) => {
					if (res.code == 200) {
						that.tui.request("/app/shop/getShopInfoById", "POST", {
							id: that.payData.shopId,
							regionId: JSON.parse(uni.getStorageSync('area')).id
						}, false, true).then((res1) => {
							try {
								if (res1.code == 200) {
									uni.hideLoading();
									
									// 1. 定义一个安全的 JSON 解析函数（防止遇到 undefined, null 或空字符串报错）
									const safeJsonParse = (str, fallback = null) => {
										if (!str || typeof str !== 'string') return fallback;
										try {
											return JSON.parse(str);
										} catch (e) {
											console.warn('JSON解析失败，原始数据:', str, '错误:', e.message);
											return fallback;
										}
									};
							
									let cartItems = [];
									for (let i = 0; i < that.payData.goodsList.length; i++) {
										let productPrice = that.payData.goodsList[i].price;
										
										for (let a = 0; a < res1.result.products.length; a++) {
											if (res1.result.products[a].id == that.payData.goodsList[i].productId) {
												let priceToUse = 0;
												let rawAttrPrice = res1.result.products[a].attributeListPrice;
												
												// 2. 安全解析 attributeListPrice（兼容未转义的双引号问题）
												let pObj = null;
												if (typeof rawAttrPrice === 'string') {
													pObj = safeJsonParse(rawAttrPrice); // 先尝试正常解析
													if (!pObj) {
														// 如果正常解析失败，说明可能是后端没转义内部的双引号，尝试修复
														try {
															// 简单修复：把最外层括号内部的双引号转义
															let fixedStr = rawAttrPrice.replace(/(\[{)(.*?)(\]})/g, (match, p1, p2, p3) => {
																return p1 + p2.replace(/"/g, '\\"') + p3;
															});
															pObj = JSON.parse(fixedStr);
														} catch (err) {
															console.warn('attributeListPrice 修复解析依然失败:', err.message);
														}
													}
												} else {
													pObj = rawAttrPrice; // 如果后端已经返回了对象，直接使用
												}
												
												// 3. 提取价格
												if (pObj) {
													if (Array.isArray(pObj) && pObj.length > 0) {
														priceToUse = parseFloat(pObj[0].specPrice);
													} else {
														for (let k in pObj) {
															priceToUse = parseFloat(pObj[k].specPrice);
															break;
														}
													}
												}
												productPrice = priceToUse;
											}
										}
										
										that.payData.goodsList[i].id = that.payData.goodsList[i].productId;
										let specStr = that.payData.goodsList[i].specs;
										let cartId = that.payData.goodsList[i].productId + '_' + specStr;
										
										// 4. 安全解析 specs
										let parsedSpecs = safeJsonParse(specStr, []); 
										
										cartItems.push({
											cartId: cartId,
											item: that.payData.goodsList[i],
											specs: parsedSpecs, // 使用安全解析后的值
											quantity: that.payData.goodsList[i].quantity,
											price: productPrice.toFixed(2)
										});
									}
									
									uni.navigateTo({
										url: '/package1/buyFood/buyFood?cart=' + encodeURIComponent(JSON.stringify(cartItems)) +
											'&shopItem=' + encodeURIComponent(JSON.stringify(res1.result.shop)) + 
											'&packageFee=' + that.payData.packageFee
									});
								} else {
									that.tui.toast(res.message, 2000);
									return;
								}
							} catch (e) {
								console.error('结算逻辑发生异常:', e.message);
							} finally {
								// 5. 无论成功失败，最后都隐藏 Loading（优化了原来在 if 里和外面重复调用的问题）
								uni.hideLoading();
							}
						}).catch((res1) => {});
					} else {
						that.tui.toast(res.message);
						return;
					}
					uni.hideLoading();
				}).catch((res) => {});
			},
			refreah(item) {
				if (this.isRefreshing) return;
				this.isRefreshing = true;
				uni.showLoading({
					title: '刷新中...',
					mask: true
				});
				this.getOrderDetail(item.id)
				this.$forceUpdate();
				setTimeout(() => {
					uni.hideLoading();
					this.isRefreshing = false;
				}, 1000);
			},
			returnProducts(item) {
				uni.redirectTo({
					url: '/package1/order/returnOrder?order=' + encodeURIComponent(JSON.stringify(item))
				});
			},
			getOrderDetail(id) {
				this.pintuan = false;
				let that = this
				that.tui.request("/mall/order/detail/" + id, "GET", {}, false, true).then((res) => {
					uni.stopPullDownRefresh()
					if (res.code == 200) {
						that.orderDetail = res.result;
						that.startPayCountdown();
						that.openPendingAddFeePayPopup();
						if (that.orderDetail.mallRefundRecord != null && that.orderDetail.mallRefundRecord.length >
							0) {
							for (let i = 0; i < that.orderDetail.mallRefundRecord.length; i++) {
								if (that.orderDetail.mallRefundRecord[i].status >= 3) {
									that.hasRefund = true
								}
							}
						}
						if (that.orderDetail.groupInfo) {
							//还没有拼团成功拼团状态 0:拼团中 1:拼团成功 2:拼团失败 3:面对面团(不公开)
							if (that.orderDetail.groupInfo.status != 1 && that.orderDetail.groupInfo.status != 2 && that.orderDetail.status == 10) {
								that.pintuan = true;
								that.tui.request("/app/shop/getShopInfoById", "POST", {
									id: that.orderDetail.shopId,
									regionId: JSON.parse(uni.getStorageSync('area')).id 
								}, false, true).then((res1) => {
									if (res1.code == 200) {
										that.shopItem = res1.result.shop
									} else {
										that.tui.toast(res1.message);
										return;
									}

								}).catch((res1) => {});
							}
						}
						that.orderDetail.userCouponNum = 0
						if (that.orderDetail.userCoupon.length > 0) {
							for (let i = 0; i < that.orderDetail.userCoupon.length; i++) {
								that.orderDetail.userCouponNum += Number(that.orderDetail.userCoupon[i]
									.discountAmount)
							}
						}
						that.$forceUpdate();
					} else {
						that.tui.toast(res.message)
						return
					}
				}).catch((res) => {})
				if (!this.isRefreshing) {
					uni.hideLoading();
				}
			},
			goAssignWorker() {
				let deliveryInfo = this.orderDetail.deliveryInfo || {};
				let shopAreaId = deliveryInfo.getAreaId || this.orderDetail.getAreaId || '';
				let putAreaId = deliveryInfo.putAreaId || this.orderDetail.putAreaId || '';
				let commissionAmount = deliveryInfo.deliveryFee != null
					? deliveryInfo.deliveryFee
					: '';
				let addressId = this.orderDetail.addressId || '';
				uni.navigateTo({
					url: `/package1/index/deliveryPersonList?shopAreaId=${shopAreaId}&putAreaId=${putAreaId}&commissionAmount=${commissionAmount}&addressId=${addressId}`
				});
			},
			prepareAddFeeForWorker(data) {
				if (!data || !data.worker) return;
				this.pendingAddFeeWorker = data.worker;
				this.additionalFee = this.formatAdditionalFee(data.additionalFee);
				this.addFeeAutoPayOpened = false;
				this.openPendingAddFeePayPopup();
			},
			openPendingAddFeePayPopup() {
				if (!this.pendingAddFeeWorker || this.addFeeAutoPayOpened || !this.orderDetail.id) return;
				this.additionalFee = this.formatAdditionalFee(this.additionalFee);
				if (!this.additionalFee) {
					this.pendingAddFeeWorker = null;
					return;
				}
				this.addFeeAutoPayOpened = true;
				setTimeout(() => {
					this.$refs.addFeePayPopup.open('bottom');
				}, 300);
			},
			handleWorkerSelected(worker) {
				if (!worker) return;
				uni.removeStorageSync('pendingAssignWorker');
				let workerKey = this.getWorkerSelectionKey(worker);
				if (this.assignWorkerModalVisible && workerKey == this.assignWorkerSelectionKey) {
					return;
				}
				this.assignWorkerModalVisible = true;
				this.assignWorkerSelectionKey = workerKey;
				let that = this;
				uni.showModal({
					title: '指派配送员',
					content: `是否选取配送员「${worker.workerName || '未知'}」？`,
					success: function(res) {
						if (res.confirm) {
							that.reassignWorker(worker);
						}
					},
					complete: function() {
						that.assignWorkerModalVisible = false;
					}
				});
			},
			getWorkerSelectionKey(worker) {
				return String(worker.workerId || worker.id || worker.mobile || worker.workerName || '');
			},
			reassignWorker(worker) {
				let that = this;
				let deliveryId = '';
				if (that.orderDetail.deliveryInfo && that.orderDetail.deliveryInfo.id) {
					deliveryId = that.orderDetail.deliveryInfo.id;
				}
				that.tui.request("/mall/delivery/reassignWorker", "POST", {
					deliveryId: deliveryId,
					newWorkerId: worker.workerId,
					newWorkerName: worker.workerName,
					newWorkerPhone: worker.mobile
				}, false, true).then((res) => {
					if (res.code == 200) {
						that.tui.toast("指派配送员成功");
						that.getOrderDetail(that.orderId);
						that.$forceUpdate();
					} else {
						that.tui.toast(res.message || '指派配送员失败');
					}
				}).catch((err) => {
					that.tui.toast('请求失败，请重试');
				});
			},
			openAddFeePopup() {
				this.additionalFee = '';
				this.$refs.addFeePopup.open('center');
			},
			openPayPopup() {
				if (!this.orderDetail.id || !this.orderDetail.totalAmount) {
					this.tui.toast('订单金额异常，无法支付');
					return;
				}
				this.$refs.payPopup.open('bottom');
			},
			wxPayment() {
				let that = this;
				if (!this.orderDetail.id || !this.orderDetail.totalAmount) return;
				let amountInCents = Math.round(Number(this.orderDetail.totalAmount) * 100);

				this.tui.request("/api/wechat/pay/unified-order", "POST", {
					openid: uni.getStorageSync('miniProgramOpenid') || 'test-openid',
					amount: amountInCents,
					description: '商城订单',
					outTradeNo: this.orderDetail.id
				}, false, false).then((res) => {
					if (res.code == 200) {
						uni.requestPayment({
							provider: 'wxpay',
							timeStamp: res.timeStamp,
							nonceStr: res.nonceStr,
							package: res.package,
							signType: res.signType,
							paySign: res.paySign,
							success: function(res2) {
								that.handlePaymentSuccess();
							},
							fail: function(err) {
								that.tui.toast("支付失败或取消");
							}
						});
					} else {
						if (res.code == 404 || res.code == 500 || res.code == 400 || !res.code) {
							let workerId = that.orderDetail.deliveryInfo && that.orderDetail.deliveryInfo.workerId ? that.orderDetail.deliveryInfo.workerId : '';
							that.tui.request(
								`/hiver/order/payMallOrderSuccess?orderId=${that.orderDetail.id}&workerId=${workerId}`,
								"POST", {}, false, false).then(res2 => {
								that.$refs.payPopup.close();
								uni.showToast({
									title: '支付成功(模拟)',
									icon: 'none'
								});
								setTimeout(() => {
									that.handlePaymentSuccess();
								}, 1500);
							}).catch(e => {
								uni.showToast({
									title: '请求失败',
									icon: 'none'
								})
							});
						} else {
							that.tui.toast(res.message);
						}
					}
				})
			},
			handlePaymentSuccess() {
				uni.redirectTo({
					url: '/package1/order/orderConfirm?id=' + this.orderDetail.id + '&amount=' + this.orderDetail.totalAmount
				});
			},
			formatMoneyInput(value) {
				value = String(value || '');
				value = value.replace(/[^\d.]/g, '');
				const dotIndex = value.indexOf('.');
				if (dotIndex !== -1) {
					value = value.slice(0, dotIndex + 1) + value.slice(dotIndex + 1).replace(/\./g, '');
					const parts = value.split('.');
					value = parts[0] + '.' + parts[1].slice(0, 2);
				}
				return value;
			},
			formatAdditionalFee(value) {
				let fee = parseFloat(this.formatMoneyInput(value));
				if (isNaN(fee) || fee < 0.1) {
					return '';
				}
				return (Math.floor(fee * 100) / 100).toFixed(2).replace(/\.?0+$/, '');
			},
			onAdditionalFeeInput(e) {
				const value = this.formatMoneyInput(e.detail.value);
				this.additionalFee = value;
				return value;
			},
			submitAddFee() {
				this.additionalFee = this.formatAdditionalFee(this.additionalFee);
				let fee = parseFloat(this.additionalFee);
				if (isNaN(fee) || fee < 0.1) {
					this.tui.toast('请输入有效的金额');
					return;
				}
				if (fee > 200) {
					this.tui.toast('增加配送佣金不得超过200元');
					return;
				}
				// 关闭输入弹窗，打开支付弹窗
				this.$refs.addFeePopup.close();
				setTimeout(() => {
					this.$refs.addFeePayPopup.open('bottom');
				}, 300);
			},
			addFeeWxPayment() {
				let that = this;
				this.additionalFee = this.formatAdditionalFee(this.additionalFee);
				let fee = parseFloat(this.additionalFee);
				if (!fee || fee < 0.1) return;
				if (fee > 200) {
					this.tui.toast('增加配送佣金不得超过200元');
					return;
				}
				let amountInCents = Math.round(fee * 100);

				this.tui.request("/api/wechat/pay/unified-order", "POST", {
					openid: uni.getStorageSync('miniProgramOpenid') || 'test-openid',
					amount: amountInCents,
					description: '增加配送佣金',
					outTradeNo: that.orderDetail.id
				}, false, false).then((res) => {
					if (res.code == 200) {
						that.addFeeTradeNo = res.wxOrderId || res.outTradeNo || '';
						uni.requestPayment({
							provider: 'wxpay',
							timeStamp: res.timeStamp,
							nonceStr: res.nonceStr,
							package: res.package,
							signType: res.signType,
							paySign: res.paySign,
							success: function(res2) {
								that.$refs.addFeePayPopup.close();
								if (that.addFeeTradeNo) {
									that.waitAddFeeRecordAndAssign();
								} else {
									that.finishAddFeeSuccess();
								}
							},
							fail: function(err) {
								that.$refs.addFeePayPopup.close();
								that.cancelPendingAddFeeAssign();
								that.tui.toast('支付失败取消');
							}
						});
					} else {
						// 模拟支付成功(用于测试环境)
						if (res.code == 404 || res.code == 500 || res.code == 400 || !res.code) {
							that.$refs.addFeePayPopup.close();
							uni.showToast({
								title: '支付成功(模拟)',
								icon: 'none'
							});
							setTimeout(() => {
								that.callAddFeeApi(true);
							}, 1500);
						} else {
							that.tui.toast(res.message);
						}
					}
				});
			},
			waitAddFeeRecordAndAssign() {
				this.stopAddFeePolling();
				uni.showLoading({
					title: '确认支付中...',
					mask: true
				});
				this.pollAddFeeRecord(0);
			},
			pollAddFeeRecord(times) {
				if (!this.addFeeTradeNo) {
					this.finishAddFeeSuccess();
					return;
				}
				if (times >= 30) {
					uni.hideLoading();
					this.cancelPendingAddFeeAssign();
					this.tui.toast('未确认到支付成功，请稍后刷新后重试');
					this.getOrderDetail(this.orderId);
					return;
				}
				this.tui.request("/api/wechat/pay/delivery-fee-record/exists", "GET", {
					wxOrderId: this.addFeeTradeNo
				}, false, false).then((res) => {
					if (res.code == 200 && (res.exists === true || res.exists == 'true')) {
						this.finishAddFeeSuccess();
					} else {
						this.addFeePollTimer = setTimeout(() => {
							this.pollAddFeeRecord(times + 1);
						}, 1000);
					}
				}).catch(() => {
					this.addFeePollTimer = setTimeout(() => {
						this.pollAddFeeRecord(times + 1);
					}, 1000);
				});
			},
			stopAddFeePolling() {
				if (this.addFeePollTimer) {
					clearTimeout(this.addFeePollTimer);
					this.addFeePollTimer = null;
				}
			},
			cancelPendingAddFeeAssign() {
				this.stopAddFeePolling();
				this.pendingAddFeeWorker = null;
				this.addFeeAutoPayOpened = false;
				this.addFeeTradeNo = '';
				this.additionalFee = '';
			},
			finishAddFeeSuccess() {
				this.stopAddFeePolling();
				uni.hideLoading();
				let worker = this.pendingAddFeeWorker;
				this.pendingAddFeeWorker = null;
				this.addFeeAutoPayOpened = false;
				this.addFeeTradeNo = '';
				this.additionalFee = '';
				if (worker) {
					this.reassignWorker(worker);
				} else {
					this.tui.toast("增加佣金成功");
					this.getOrderDetail(this.orderId);
					this.$forceUpdate();
				}
			},
			callAddFeeApi(assignAfterSuccess) {
				let that = this;
				let fee = parseFloat(this.additionalFee);
				let deliveryId = '';
				if (that.orderDetail.deliveryInfo && that.orderDetail.deliveryInfo.id) {
					deliveryId = that.orderDetail.deliveryInfo.id;
				}
				that.tui.request("/mall/delivery/addFee", "POST", {
					deliveryId: deliveryId,
					additionalFee: fee,
					orderId: that.orderDetail.id,
					olditionalFee: that.orderDetail.deliveryFee ? that.orderDetail.deliveryFee : 0
				}, false, true).then((res) => {
					if (res.code == 200) {
						that.tui.toast("增加佣金成功");
						if (assignAfterSuccess) {
							that.finishAddFeeSuccess();
						} else {
							that.getOrderDetail(that.orderId);
							that.$forceUpdate();
						}
					} else {
						that.tui.toast(res.message || '增加佣金失败');
					}
				}).catch((err) => {
					that.tui.toast('请求失败，请重试');
				});
			},
			back() {
				const pages = getCurrentPages()
				  if (pages.length > 1) {
				    uni.navigateBack({ delta: 1 })
				  } else {
				    uni.switchTab({ url: '/pages/index/index' })
				  }
			}
		}

	}
</script>

<style lang="scss">
	page {
		width: 100%;
		height: 100%;
		font-size: 24rpx;
		background: linear-gradient(180deg, #ecfff7 0%, #f7fbf6 38%, #f9faf7 100%);
		color: #00231C;
	}

	.page1 {
		width: 100%;
		min-height: 100%;
		font-size: 24rpx;
		position: relative;
		background:
			radial-gradient(circle at 12% 8%, rgba(166, 255, 234, 0.48) 0, rgba(166, 255, 234, 0) 260rpx),
			radial-gradient(circle at 92% 18%, rgba(255, 221, 176, 0.26) 0, rgba(255, 221, 176, 0) 300rpx);
	}

	.title {
		background:
			linear-gradient(135deg, rgba(166, 255, 234, 0.86) 0%, rgba(245, 255, 249, 0.94) 52%, rgba(255, 246, 225, 0.9) 100%);
		width: 100%;
		height: 360rpx;
		border-bottom-left-radius: 46rpx;
		border-bottom-right-radius: 46rpx;
		box-shadow: 0 18rpx 44rpx rgba(0, 35, 28, 0.06);
	}

	.order-detail-fixed-header {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		height: 380rpx;
		z-index: 999;
		background:
			radial-gradient(circle at 12% 8%, rgba(166, 255, 234, 0.48) 0, rgba(166, 255, 234, 0) 260rpx),
			radial-gradient(circle at 92% 18%, rgba(255, 221, 176, 0.26) 0, rgba(255, 221, 176, 0) 300rpx),
			linear-gradient(180deg, #ecfff7 0%, #f7fbf6 100%);
		overflow: visible;
	}

	.order-detail-fixed-header-lower {
		z-index: 1;
	}

	.order-detail-header-content {
		position: absolute;
		top: 170rpx;
		left: 0;
		width: 100%;
		z-index: 2;
	}

	.content {
		position: relative;
		width: 100%;
		padding-bottom: 60rpx;
	}

	.order-detail-content {
		padding-top: 390rpx;
		box-sizing: border-box;
		z-index: 1;
	}

	.order-detail-content-address-long {
		padding-top: 450rpx;
	}

	.title-sreach {
		width: 100%;
		display: flex;
		height: 260rpx;
		position: relative;
	}

	.back-btn {
		position: absolute;
		bottom: 0;
		left: 0;
		width: 64rpx;
		height: 64rpx;
		margin-left: 14rpx;
		border-radius: 50%;
		text-align: center;
		line-height: 64rpx;
	}

	.box1 {
		width: 95%;
		margin: 0 auto 22rpx;
		background: rgba(255, 255, 255, 0.94);
		border: 1px solid rgba(255, 255, 255, 0.86);
		border-radius: 32rpx;
		padding: 24rpx;
		box-shadow: 0 18rpx 42rpx rgba(0, 35, 28, 0.07);
		box-sizing: border-box;
		overflow: hidden;
	}

	.auto-refund-tip {
		margin: 8rpx 0 18rpx;
		padding: 18rpx 20rpx;
		border-radius: 18rpx;
		background: rgba(255, 244, 232, 0.9);
		border: 1rpx solid rgba(255, 180, 118, 0.48);
		color: #b4572d;
		font-size: 24rpx;
		font-weight: 700;
		line-height: 34rpx;
	}

	.refund-card {
		margin-top: 10px;
		padding: 20rpx;
		background: rgba(247, 248, 248, 0.6);
		border-radius: 20rpx;
	}

	.refund-service-btn {
		width: 136rpx;
		height: 54rpx;
		text-align: center;
		line-height: 54rpx;
		border-radius: 999rpx;
		background: rgba(255, 255, 255, 0.72);
		border: 1px solid rgba(0, 35, 28, 0.1);
		color: #60706c;
		font-size: 20rpx;
		font-weight: 800;
		box-shadow: 0 8rpx 18rpx rgba(0, 35, 28, 0.05);
	}

	.refund-goods-card {
		display: flex;
		padding: 18rpx;
		margin: 12rpx 0;
		background: rgba(255, 255, 255, 0.72);
		border-radius: 22rpx;
		border: 1rpx solid rgba(166, 255, 234, 0.28);
		box-sizing: border-box;
	}

	.refund-goods-img {
		width: 132rpx;
		height: 132rpx;
		flex-shrink: 0;
		border-radius: 20rpx;
		overflow: hidden;
		background: #f4f7f6;
	}

	.refund-goods-img img {
		width: 100%;
		height: 100%;
		border-radius: 20rpx;
		object-fit: cover;
	}

	.refund-goods-content {
		flex: 1;
		min-width: 0;
		padding-left: 18rpx;
	}

	.refund-goods-name {
		color: #243f38;
		font-size: 28rpx;
		font-weight: 900;
		line-height: 38rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.refund-goods-spec {
		margin-top: 8rpx;
		color: #7b8883;
		font-size: 22rpx;
		line-height: 32rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.refund-goods-bottom {
		display: flex;
		justify-content: space-between;
		margin-top: 14rpx;
		color: #243f38;
		font-size: 24rpx;
		font-weight: 800;
		line-height: 34rpx;
	}

	.refund-info-row {
		display: flex;
		align-items: flex-start;
		padding: 18rpx 0;
		border-bottom: 1rpx solid rgba(0, 35, 28, 0.045);
	}

	.refund-info-label {
		width: 160rpx;
		flex-shrink: 0;
		color: #87938f;
		font-weight: 700;
		line-height: 38rpx;
	}

	.refund-info-value {
		flex: 1;
		min-width: 0;
		color: #243f38;
		font-weight: 700;
		line-height: 38rpx;
		word-break: break-all;
		text-align: right;
	}

	.refund-image {
		width: 180rpx;
		height: 180rpx;
		border-radius: 20rpx;
		display: block;
		margin-left: auto;
	}

	.content > .box1:first-child {
		background:
			radial-gradient(circle at 94% 4%, rgba(255, 221, 176, 0.2) 0, rgba(255, 221, 176, 0) 170rpx),
			linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(244, 255, 251, 0.96) 100%);
		border-radius: 36rpx;
	}

	.order-status-card {
		background:
			radial-gradient(circle at 94% 4%, rgba(255, 221, 176, 0.2) 0, rgba(255, 221, 176, 0) 170rpx),
			linear-gradient(135deg, #ffffff 0%, #f4fffb 100%);
		border-radius: 36rpx;
		position: relative;
		z-index: 3;
	}

	.goods-img {
		width: 160rpx;
		height: 160rpx;
		position: relative;
		border-radius: 24rpx;
		overflow: hidden;
		box-shadow: 0 12rpx 24rpx rgba(0, 35, 28, 0.08);

		img {
			width: 100%;
			background-size: 100%;
			height: 100%;
			border-radius: 24rpx;
		}
	}

	.goods-content {
		flex: 1;
		padding-left: 20rpx;
	}

	.goods-name {
		font-size: 32rpx;
		font-weight: 900;
		color: #243f38;
	}

	.goods-content-center {
		display: flex;
		margin: 16rpx 0;
		color: #7b8883;
	}

	.goods-content-bottom {
		display: flex;
		line-height: 56rpx;
		color: #6b7773;
	}

	.pintuan-left-price {
		width: 50%;
		text-align: right;
		font-weight: 700;
		color: #00231C;
	}

	.status-img {
		width: 96rpx;
		height: 96rpx;
		border-radius: 50%;
		background: linear-gradient(135deg, rgba(166, 255, 234, 0.72), rgba(255, 247, 215, 0.78));
		box-shadow: 0 12rpx 26rpx rgba(0, 35, 28, 0.08);
		display: flex;
		align-items: center;
		justify-content: center;

		img {
			width: 72rpx;
			height: 72rpx;
			background-size: 100%;
		}
	}

	.status-text {
		flex: 1;
		min-width: 0;
		position: relative;
		padding-left: 20rpx;
		padding-right: 160rpx;
		box-sizing: border-box;
	}

	.status-zhu {
		font-size: 36rpx;
		font-weight: 900;
		color: #243f38;
	}

	.status-fu {
		height: 50rpx;
		line-height: 50rpx;
		color: #52625d;
	}

	.status-address {
		display: flex;
		align-items: flex-start;
		font-weight: 700;
		color: #243f38;
		line-height: 40rpx;
		word-break: break-all;
		max-height: 80rpx;
		overflow: hidden;
	}

	.status-address-label {
		flex-shrink: 0;
		margin-right: 8rpx;
	}

	.status-address-text {
		flex: 1;
		min-width: 0;
		word-break: break-all;
		overflow-wrap: break-word;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		overflow: hidden;
	}

	.status-btn {
		position: absolute;
		top: 20rpx;
		right: 0;
		background: rgba(255, 255, 255, 0.72);
		width: 136rpx;
		height: 54rpx;
		text-align: center;
		line-height: 54rpx;
		border-radius: 999rpx;
		color: #60706c;
		border: 1px solid rgba(0, 35, 28, 0.1);
		font-size: 20rpx;
		font-weight: 800;
		box-shadow: 0 8rpx 18rpx rgba(0, 35, 28, 0.05);
	}

	.order-flow {
		width: 95%;
		margin: -2rpx auto 12rpx;
		padding: 16rpx 20rpx;
		border-radius: 30rpx;
		background: rgba(255, 255, 255, 0.78);
		box-shadow: 0 14rpx 34rpx rgba(0, 35, 28, 0.05);
		display: flex;
		align-items: center;
		box-sizing: border-box;
	}

	.flow-item {
		width: 92rpx;
		text-align: center;
		color: #9aa6a2;
		font-size: 20rpx;
		font-weight: 800;
	}

	.flow-dot {
		width: 24rpx;
		height: 24rpx;
		margin: 0 auto 8rpx;
		border-radius: 50%;
		background: #dfe7e3;
		box-shadow: inset 0 0 0 4rpx #fff;
	}

	.flow-item.active {
		color: #125e50;
	}

	.flow-item.active .flow-dot {
		background: linear-gradient(135deg, #a6ffea, #ffdf75);
		box-shadow: 0 6rpx 14rpx rgba(0, 191, 160, 0.18);
	}

	.flow-line {
		flex: 1;
		height: 6rpx;
		border-radius: 999rpx;
		background: #e5ece9;
		margin: 0 4rpx 34rpx;
	}

	.flow-line.active {
		background: linear-gradient(90deg, #a6ffea, #ffdf75);
	}

	.btn-box {
		height: auto;
		display: flex;
		width: 95%;
		margin: 0 auto 20rpx;
		gap: 18rpx;
		flex-wrap: wrap;
	}

	.btn {
		flex: 1;
		min-width: 260rpx;
		height: 92rpx;
		line-height: 92rpx;
		background: linear-gradient(135deg, #fff7d7 0%, #a6ffea 100%);
		font-size: 30rpx;
		border-radius: 999rpx;
		text-align: center;
		margin: 0;
		font-weight: 900;
		box-shadow: 0 14rpx 28rpx rgba(0, 191, 160, 0.12);
	}

	.box1 > view[style*="rgba(247, 248, 248"] {
		background: linear-gradient(180deg, rgba(250, 255, 252, 0.96) 0%, rgba(255, 255, 255, 0.9) 100%) !important;
		border: 1px solid rgba(166, 255, 234, 0.34);
		box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
	}

	.box1 > view[style*="line-height: 70rpx"] {
		color: #243f38;
	}

	.box1 > view[style*="height: 80rpx"] {
		border-bottom: 1px solid rgba(0, 35, 28, 0.045);
	}

	.box1 > view[style*="height: 80rpx"]:last-child {
		border-bottom: 0;
	}

	.box1 view[style*="color: #777"] {
		color: #87938f !important;
	}

	.box1 view[style*="color: #000"] {
		color: #243f38 !important;
	}

	.box1 view[style*="border-top: 1px solid #eee"] {
		border-top: 1px solid rgba(0, 35, 28, 0.08) !important;
	}

	.box1 view[style*="font-size: 32rpx"][style*="font-weight: 700"] {
		color: #0d4d42;
	}

	.box1 image,
	.box1 img {
		object-fit: cover;
	}

	.evaluate-content,
	.car-content,
	.guize-list,
	.group-buy-cancel-popup,
	.pay-popup {
		border-radius: 36rpx 36rpx 0 0 !important;
		box-shadow: 0 -18rpx 44rpx rgba(0, 35, 28, 0.12);
	}

	.pay-popup {
		width: 100vw;
		min-height: 560rpx;
		padding: 30rpx 0 calc(28rpx + env(safe-area-inset-bottom));
		box-sizing: border-box;
		background: #fff;
	}

	.pay-popup-content {
		position: relative;
		width: 100%;
		height: auto;
		margin-top: 0;
		top: auto;
		padding-bottom: 1rpx;
		box-sizing: border-box;
	}

	.group-buy-cancel-popup {
		width: 100vw;
		padding: 46rpx 42rpx calc(42rpx + env(safe-area-inset-bottom));
		box-sizing: border-box;
		background: #fff;
	}

	.group-buy-cancel-title {
		color: #243f38;
		font-size: 36rpx;
		font-weight: 900;
		line-height: 52rpx;
		text-align: center;
	}

	.group-buy-cancel-desc {
		margin-top: 16rpx;
		color: #7b8883;
		font-size: 26rpx;
		font-weight: 700;
		line-height: 38rpx;
		text-align: center;
	}

	.group-buy-cancel-actions {
		display: flex;
		gap: 22rpx;
		margin-top: 52rpx;
	}

	.group-buy-cancel-btn {
		flex: 1;
		height: 88rpx;
		border-radius: 999rpx;
		font-size: 28rpx;
		font-weight: 900;
		line-height: 88rpx;
		text-align: center;
	}

	.group-buy-cancel-btn-muted {
		background: #f0f2f1;
		color: #7b8883;
	}

	.group-buy-cancel-btn-confirm {
		background: linear-gradient(90deg, rgba(227, 255, 150, 1), rgba(166, 255, 234, 1));
		color: #00231C;
		box-shadow: 0 14rpx 28rpx rgba(0, 191, 160, 0.12);
	}

	.cancel-popup {
		position: relative;
		max-height: 86vh;
		padding: 20rpx 20rpx calc(8rpx + env(safe-area-inset-bottom)) !important;
		overflow: visible;
		box-sizing: border-box;
		background: #fff;
	}

	.cancel-scroll {
		height: 62vh;
		overflow: hidden;
	}

	.cancel-type-item {
		min-height: 76rpx;
		line-height: 76rpx;
		color: #243f38;
		font-size: 28rpx;
		font-weight: 700;
	}

	.cancel-section {
		padding: 0 20rpx 24rpx;
	}

	.cancel-section-title {
		margin: 10rpx 0 18rpx;
		color: #243f38;
		font-size: 28rpx;
		font-weight: 900;
	}

	.cancel-option-list {
		display: flex;
		flex-wrap: wrap;
		gap: 16rpx;
	}

	.cancel-option {
		padding: 0 22rpx;
		height: 64rpx;
		line-height: 64rpx;
		border-radius: 999rpx;
		background: rgba(247, 248, 248, 0.78);
		border: 1rpx solid rgba(0, 35, 28, 0.06);
		color: #65736f;
		font-size: 24rpx;
		font-weight: 700;
	}

	.cancel-option.checked {
		background: linear-gradient(90deg, rgba(227, 255, 150, 1), rgba(166, 255, 234, 1));
		color: #00231C;
		border-color: rgba(166, 255, 234, 0.78);
	}

	.cancel-textarea {
		width: 100%;
		height: 180rpx;
		padding: 20rpx;
		box-sizing: border-box;
		border-radius: 24rpx;
		background: rgba(247, 248, 248, 0.8);
		color: #243f38;
		font-size: 26rpx;
		line-height: 38rpx;
	}

	.cancel-upload-row {
		display: flex;
		align-items: center;
		gap: 18rpx;
		flex-wrap: wrap;
	}

	.cancel-upload-img {
		width: 150rpx;
		height: 150rpx;
		border-radius: 20rpx;
		object-fit: cover;
	}

	.cancel-upload-btn {
		display: flex;
		align-items: center;
		justify-content: center;
		background: rgba(247, 248, 248, 0.8);
		border: 1rpx dashed rgba(0, 35, 28, 0.18);
	}

	.cancel-upload-preview {
		width: 150rpx;
		height: 150rpx;
		border-radius: 20rpx;
		overflow: hidden;
	}

	.cancel-warning-card {
		margin-top: 20rpx;
		padding: 18rpx 20rpx;
		border-radius: 18rpx;
		background: #fff5f5;
		color: #ff5722;
		font-size: 24rpx;
		line-height: 36rpx;
		box-sizing: border-box;
	}

	.cancel-time-tips {
		margin-top: 14rpx;
		display: flex;
		flex-direction: column;
		gap: 10rpx;
	}

	.cancel-warning-line {
		display: flex;
		align-items: flex-start;
		width: 100%;
		min-height: 36rpx;
		line-height: 36rpx;
		text-align: left;
		word-break: break-all;
	}

	.cancel-warning-line text {
		flex: 1;
		min-width: 0;
		padding-left: 10rpx;
		white-space: normal;
	}

	.cancel-confirm-btn {
		width: 95%;
		margin: 18rpx auto 0;
	}

	.evaluate-content {
		background: linear-gradient(180deg, #ffffff 0%, #f7fffb 100%);
		width: 100vw;
		max-height: 78vh;
		padding: 34rpx 28rpx calc(28rpx + env(safe-area-inset-bottom));
		box-sizing: border-box;
		overflow: hidden;
	}

	.evaluate-popup-header {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 8rpx 24rpx;
	}

	.evaluate-popup-title {
		color: #243f38;
		font-size: 34rpx;
		font-weight: 900;
		line-height: 48rpx;
	}

	.evaluate-popup-subtitle {
		margin-top: 6rpx;
		color: #7b8883;
		font-size: 24rpx;
		line-height: 34rpx;
	}

	.evaluate-popup-close {
		height: 56rpx;
		padding: 0 24rpx;
		border-radius: 999rpx;
		background: rgba(0, 35, 28, 0.06);
		color: #243f38;
		font-size: 24rpx;
		font-weight: 700;
		line-height: 56rpx;
	}

	.evaluate-scroll {
		max-height: 62vh;
		overflow: hidden;
	}

	.evaluate-list {
		padding: 20rpx;
		border-radius: 28rpx;
		background: rgba(247, 255, 251, 0.8);
	}

	.img-popup-content {
		width: 600rpx;
		height: 800rpx;
		background: url('https://jewel-shop.oss-cn-beijing.aliyuncs.com/73e684e3319c468d9252461ba3c9e95b.png') no-repeat;
		background-size: 100%;
	}

	.commission-popup {
		width: 620rpx;
		padding: 44rpx 36rpx 34rpx;
		box-sizing: border-box;
		border-radius: 32rpx;
		background: #fff;
		box-shadow: 0 28rpx 70rpx rgba(0, 35, 28, 0.18);
	}

	.no-responsibility-cancel-popup {
		width: 620rpx;
		padding: 46rpx 36rpx 34rpx;
		box-sizing: border-box;
		border-radius: 32rpx;
		background: #fff;
		box-shadow: 0 28rpx 70rpx rgba(0, 35, 28, 0.18);
	}

	.no-responsibility-cancel-title {
		color: #243f38;
		font-size: 36rpx;
		font-weight: 900;
		line-height: 52rpx;
		text-align: center;
	}

	.no-responsibility-cancel-desc {
		margin-top: 16rpx;
		color: #7b8883;
		font-size: 26rpx;
		font-weight: 700;
		line-height: 38rpx;
		text-align: center;
	}

	.no-responsibility-cancel-actions {
		display: flex;
		gap: 18rpx;
		margin-top: 42rpx;
	}

	.no-responsibility-cancel-btn {
		flex: 1;
		height: 82rpx;
		border-radius: 999rpx;
		font-size: 28rpx;
		font-weight: 900;
		line-height: 82rpx;
		text-align: center;
	}

	.no-responsibility-cancel-btn-muted {
		background: #f3f6f4;
		color: #87938f;
	}

	.no-responsibility-cancel-btn-confirm {
		background: linear-gradient(135deg, #fff7d7 0%, #a6ffea 100%);
		color: #243f38;
		box-shadow: 0 12rpx 26rpx rgba(0, 191, 160, 0.12);
	}

	.commission-popup-title {
		color: #243f38;
		font-size: 34rpx;
		font-weight: 900;
		text-align: center;
	}

	.commission-popup-desc {
		margin-top: 12rpx;
		color: #87938f;
		font-size: 24rpx;
		text-align: center;
	}

	.commission-popup-input {
		display: flex;
		align-items: center;
		height: 88rpx;
		margin-top: 34rpx;
		padding: 0 26rpx;
		border-radius: 24rpx;
		background: #f6faf8;
		border: 1rpx solid #e5efeb;

		text {
			margin-right: 12rpx;
			color: #ff7043;
			font-size: 34rpx;
			font-weight: 900;
		}

		input {
			flex: 1;
			height: 88rpx;
			min-height: 88rpx;
			font-size: 34rpx;
			font-weight: 800;
		}
	}

	.commission-popup-actions {
		display: flex;
		margin-top: 34rpx;
		gap: 18rpx;
	}

	.commission-popup-cancel,
	.commission-popup-confirm {
		flex: 1;
		height: 76rpx;
		border-radius: 999rpx;
		font-size: 28rpx;
		font-weight: 800;
		line-height: 76rpx;
		text-align: center;
	}

	.commission-popup-cancel {
		background: #f3f6f4;
		color: #87938f;
	}

	.commission-popup-confirm {
		background: linear-gradient(135deg, #fff7d7 0%, #a6ffea 100%);
		color: #243f38;
		box-shadow: 0 12rpx 26rpx rgba(0, 191, 160, 0.12);
	}

	.evaluate-content {
		width: 600rpx;
		height: 800rpx;
		background: #fff;
		border-radius: 20rpx;
		padding: 20rpx;
	}

	.pintuan-page {
		min-height: 100%;
		padding-bottom: 60rpx;
		box-sizing: border-box;
	}

	.title1 {
		background: url('https://jewel-shop.oss-cn-beijing.aliyuncs.com/69c894452e924bedbb5a24bf978f47c7.png') no-repeat;
		width: 100%;
		height: 600rpx;
		background-size: 100% auto;
	}

	.title-sreach1 {
		width: 100%;
		display: flex;
		height: 200rpx;
		position: relative;
	}

	.back-btn1 {
		position: absolute;
		left: 14rpx;
		width: 64rpx;
		height: 64rpx;
		border-radius: 50%;
		text-align: center;
		line-height: 64rpx;
	}

	.box11 {
		width: 95%;
		margin: -150rpx auto 22rpx;
		background: rgba(255, 255, 255, 0.96);
		border-radius: 32rpx;
		padding: 24rpx;
		position: relative;
		box-sizing: border-box;
		box-shadow: 0 18rpx 42rpx rgba(0, 35, 28, 0.07);
		overflow: hidden;
	}

	.pintuan-page > .box11 + .box11 {
		margin: 0 auto 22rpx;
	}

	.pintuan-goods-card {
		display: flex;
		padding: 20rpx;
		background: rgba(247, 248, 248, 0.6);
		border-radius: 20rpx;
		box-sizing: border-box;
	}

	.goods-img1 {
		width: 160rpx;
		height: 160rpx;
		position: relative;
		flex-shrink: 0;
		border-radius: 20rpx;
		overflow: hidden;

		img {
			width: 100%;
			background-size: 100%;
			height: 100%;
		}
	}

	.goods-content1 {
		flex: 1;
		min-width: 0;
		padding-left: 20rpx;
	}

	.goods-name1 {
		font-size: 32rpx;
		font-weight: 900;
		line-height: 44rpx;
	}

	.goods-content-center1 {
		display: flex;
		margin: 12rpx 0;
		color: #777;
		line-height: 36rpx;
		word-break: break-all;
	}

	.goods-content-bottom1 {
		display: flex;
		align-items: center;
		line-height: 56rpx;
		color: #777;
	}

	.pintuan-left-price1 {
		text-align: right;
		font-weight: 700;
		color: #000;
		display: flex;
		justify-content: flex-end;
		flex-shrink: 0;
	}

	.pintuan-price-tag {
		background: rgba(255, 57, 57, 0.2);
		padding: 0 12rpx;
		border-radius: 20rpx;
		margin-left: 20rpx;
		white-space: nowrap;
	}

	.ziqu-xuanfu1 {
		position: absolute;
		top: 0;
		right: 0;
		background: linear-gradient(90deg, rgba(227, 255, 150, 1), rgba(166, 255, 234, 1));
		border-top-right-radius: 32rpx;
		border-bottom-left-radius: 20rpx;
		font-weight: 700;
		font-size: 20rpx;
		height: 56rpx;
		width: 120rpx;
		text-align: center;
		line-height: 56rpx;
	}

	.weipincheng1 {
		width: 90rpx;
		height: 90rpx;
		background: #a6ffea;
		border-radius: 90rpx;
		text-align: center;
		font-size: 60rpx;
		font-weight: 700;
		color: #02fbdd;
		border: 1px solid #a6ffea;
		line-height: 80rpx;
		margin: 0 auto;
		box-sizing: border-box;
	}

	.kaituan11 {
		display: flex;
		align-items: center;
		flex-wrap: wrap;
		font-size: 44rpx;
		font-weight: 700;
		margin-top: 12rpx;
	}

	.kaituan1-title1 {
		position: relative;
		margin-left: 20rpx;
		line-height: 64rpx;
	}

	.kaituan1-title11 {
		font-size: 24rpx;
		background: rgba(224, 255, 222, 0.65);
		border: 1px solid rgba(166, 255, 234, 1);
		border-radius: 20rpx;
		height: 44rpx;
		line-height: 38rpx;
		width: 280rpx;
		text-align: center;
		margin: 10rpx 0 0 20rpx;
		box-sizing: border-box;
	}

	.kaituan-refresh-btn {
		height: 44rpx;
		line-height: 44rpx;
		padding: 0 22rpx;
		margin: 10rpx 0 0 16rpx;
		border-radius: 999rpx;
		background: rgba(255, 255, 255, 0.86);
		border: 1rpx solid rgba(166, 255, 234, 0.7);
		color: #0f806d;
		font-size: 22rpx;
		font-weight: 800;
		box-shadow: 0 8rpx 18rpx rgba(0, 35, 28, 0.06);
	}

	.kaituan21 {
		display: flex;
		align-items: center;
		justify-content: center;
		flex-wrap: nowrap;
		width: 90%;
		margin: 40rpx auto;
		overflow-x: auto;
		overflow-y: hidden;
		white-space: nowrap;
	}

	.kaituan-member-list {
		display: flex;
		align-items: center;
		justify-content: flex-start;
		flex-wrap: nowrap;
	}

	.kaituan-empty-list {
		display: flex;
		align-items: center;
		flex-wrap: nowrap;
	}

	.kaituan221 {
		flex: 0 0 90rpx;
		min-width: 90rpx;
		margin: 12rpx 18rpx;
	}

	.kaituan-member-icon {
		width: 90rpx;
		height: 90rpx;
		border-radius: 90rpx;
		margin: 0 auto;
		display: block;
	}

	.kaituan-member-list .weipincheng1 {
		flex: 0 0 90rpx;
		margin: 12rpx 18rpx;
	}

	.kaituan31 {
		min-height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		color: #777;
	}

	.pintuan-actions {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		margin: 18rpx auto 0;
		width: 95%;
	}

	.kaituan41 {
		width: 48%;
		min-height: 88rpx;
		background: #f4fbf8;
		border: 1px solid rgba(0, 35, 28, 0.08);
		border-radius: 28rpx;
		text-align: center;
		font-size: 26rpx;
		font-weight: 700;
		margin: 0 0 18rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		box-sizing: border-box;
		color: #243f38;
		box-shadow: 0 10rpx 22rpx rgba(0, 35, 28, 0.05);
		padding: 0 16rpx;
		line-height: 36rpx;
	}

	.kaituan41-share {
		width: 100%;
		background: linear-gradient(90deg, rgba(227, 255, 150, 1), rgba(166, 255, 234, 1));
		border: none;
		color: #00231C;
	}

	.kaituan41-cancel {
		background: #fff6f4;
		border-color: rgba(255, 116, 92, 0.28);
		color: #d75a43;
	}

	.kaituan41-buy {
		background: #f0fffa;
		border-color: rgba(78, 219, 187, 0.34);
		color: #0f806d;
	}

	.kaituan41-refresh {
		background: #f8fff0;
		border-color: rgba(190, 232, 93, 0.38);
		color: #5a7f13;
	}

	.kaituan51 {
		margin: 36rpx 0 20rpx;
	}

	.share-btn {
		width: 100%;
		height: 100%;
		margin: 0;
		padding: 0;
		background: transparent;
		border: none;
		color: inherit;
		font-size: inherit;
		font-weight: inherit;
		line-height: 88rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: inherit;
	}

	.evaluate-list {
		margin-top: 40rpx;
	}

	.evaluate-list:first-child {
		margin-top: 0;
	}

	.eval-title {
		width: 100%;
		min-height: 80rpx;
		display: flex;
		align-items: center;
	}

	.eval-icon {
		height: 80rpx;
		width: 80rpx;
		flex-shrink: 0;
		border-radius: 50%;
		overflow: hidden;

		img {
			width: 100%;
			height: 100%;
			background-size: 100%;
		}
	}

	.eval-name {
		margin-left: 20rpx;
		flex: 1;
		min-width: 0;
	}

	.name1 {
		font-size: 28rpx;
		line-height: 50rpx;
		font-weight: 700;
		color: #243f38;
	}

	.eval-time {
		color: #9aa6a2;
		font-size: 22rpx;
		line-height: 32rpx;
	}

	.eval-target-tag {
		flex-shrink: 0;
		height: 44rpx;
		padding: 0 18rpx;
		border-radius: 999rpx;
		background: #f0fffa;
		color: #0f806d;
		font-size: 22rpx;
		font-weight: 700;
		line-height: 44rpx;
	}

	.eval-target-tag.worker {
		background: #fff7e8;
		color: #d87800;
	}

	.eval-rate {
		display: flex;
		margin-left: 14rpx;
		padding-top: 4rpx;
	}

	.eval-content {
		margin: 22rpx 0 0 100rpx;
		font-size: 28rpx;
		color: #777;
		line-height: 48rpx;
	}

	.eval-rate-row {
		display: flex;
		align-items: center;
		min-height: 50rpx;
		color: #243f38;
		font-size: 24rpx;
		font-weight: 700;
		line-height: 50rpx;
	}

	.eval-text {
		margin-top: 10rpx;
		color: #4f5e59;
		font-size: 26rpx;
		line-height: 40rpx;
		word-break: break-all;
	}

	.eval-img {
		display: flex;
		width: 100%;
		overflow-x: scroll;
		margin-top: 20rpx;

		img {
			width: 132rpx;
			height: 132rpx;
			background-size: 100%;
			margin-right: 20rpx;
			border-radius: 18rpx;
			object-fit: cover;
		}
	}

	.reply-card {
		margin-top: 18rpx;
		padding: 18rpx 20rpx;
		border-radius: 18rpx;
		background: rgba(255, 255, 255, 0.78);
		border: 1rpx solid rgba(0, 35, 28, 0.06);
	}

	.reply-header {
		display: flex;
		align-items: flex-start;
	}

	.reply-content {
		flex: 1;
		min-width: 0;
		color: #65736f;
		font-size: 24rpx;
		line-height: 36rpx;
		word-break: break-all;
	}

	.reply-content.collapsed {
		display: -webkit-box;
		overflow: hidden;
		text-overflow: ellipsis;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}

	.reply-expand-btn {
		flex-shrink: 0;
		margin-left: 18rpx;
		color: #0f806d;
		font-size: 24rpx;
		font-weight: 700;
		line-height: 36rpx;
	}

	.car-close {
		width: 60rpx;
		height: 60rpx;
		position: absolute;
		top: 18rpx;
		right: 28rpx;
		z-index: 2;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 50%;
		background: rgba(0, 35, 28, 0.06);
	}

	.car-title {
		height: 96rpx;
		line-height: 60rpx;
		margin: 0 auto;
		font-size: 28rpx;
		font-weight: 700;
	}

	.share-btn::after {
		border: 0;
	}
</style>