<template>
	<view class="maintenance-detail">
		<!-- 自定义导航栏开始 -->
		<uni-nav-bar :status-bar="true" :border="false" :background-color="'transparent'" :fixed="true"
			@click-left="handleClickLeft">
			<block v-slot:left>
				<view class="back-wrap u-f u-f-fdr u-f-aic u-f-jcfs">
					<image style="width: 16rpx;height:30rpx;" src="../.././static/common/left_gray_arrow.png"></image>
				</view>
			</block>
		</uni-nav-bar>
		<!-- 自定义导航栏结束 -->

		<view class="content">
			<view class="top-fixed" :style="{ height: paddingTop }">
				<!-- swiper图 -->
				<!-- <image v-if="JSON.stringify(tugouDetailInfo) !== '{}'" style="width: 100%;height: 100%;"
					:mode="'widthFix'" :src="tugouDetailInfo.goodsImageList[current]">
				</image> -->
			</view>

			<view class="swiper-wrap">
				<swiper class="swiper" :current="current" @change="changeswiper">
					<swiper-item v-for="(item, index) in tugouDetailInfo.goodsImageList" :key="index">
						<view class="swiper-item">
							<image style="width: 100%;height: 100%;" :src="item" :mode="'aspectFill'"></image>
						</view>
					</swiper-item>
				</swiper>
				<view class="swiper-num fw400 fs28">
					{{current+1}}/{{tugouDetailInfo.goodsImageList ? tugouDetailInfo.goodsImageList.length : 0}}
				</view>
			</view>

			<view class="content-detail">
				<view class="shop-desc">
					<view class="common-card mg-bot-20">
						<view class="u-f u-f-jcsb u-f-aic mg-bot-16">
							<view class="main-color">
								<text class="fs24">￥</text>
								<text class="fs32 mg-right-10">{{tugouDetailInfo.groupBuyingPrice}}</text>
								<text class="fs24 light-gray delete-line">￥{{tugouDetailInfo.originalPrice}}</text>
							</view>
							<button open-type="share" class="u-f u-f-fdc u-f-jcc shareBtn">
								<image class="share-icon" :mode="'widthFix'" src="../.././static/common/share.png">
								</image>
								<text class="main-color fs22 fw400">分享</text>
							</button>
						</view>
						<view class="fw700 fs32 light-black two-line-ellipsis mg-bot-16">
							{{tugouDetailInfo.goodsName ? tugouDetailInfo.goodsName : '-'}}
						</view>
						<view class="u-f u-f-jcfs u-f-aic">
							<view class="join-group-person u-f u-f-jcfs u-f-aic">
								<text
									class="main-title-btn fs18 fw400 mg-right-10">{{tugouDetailInfo.clusteringNum}}人可成团</text>
								<view class="mark border-radius-9">本场还剩 {{tugouDetailInfo.remainingTime}}</view>
							</view>
						</view>
						<view class="join-group-progress u-f u-f-aic mg-top-10">
							<view class="progress-wrap">
								<progress :percent="groupProductProgress" stroke-width="5" activeColor="#FF4502"
									border-radius="3" />
							</view>
							<view class='join-group-person fs24 fw400'>已团{{tugouDetailInfo.groupNumbered}}人</view>
						</view>
					</view>

					<view class="common-card mg-bot-20">
						<view class="u-f u-f-jcfs u-f-aifs">
							<view class="fw400 light-gray fs28 mg-right-14 vertical-text" style="flex: 28rpx;">适用门店
							</view>
							<view class="right u-f u-f-jcfs">
								<view class="mg-right-12">
									<image style="width: 134rpx;height: 134rpx;" class="border-radius-9"
										:mode="'scaleToFill'" :src="tugouDetailInfo.storeImage"></image>
								</view>
								<view>
									<view class="u-f u-f-jcsb u-f-aic mg-bot-10" @click="goToShopDetail">
										<view class="fs28 fw400 light-black one-line-ellipsis" style="flex: 1;">
											{{tugouDetailInfo.storeName}}
										</view>
										<view class="u-f u-f-jcfs u-f-aic">
											<text
												class="fs24 fw400 light-gray mg-right-18">{{tugouDetailInfo.storeNum}}家门店</text>
											<image src="../.././static/common/big_gray_right_arrow.png"
												:mode="'widthFix'" style="width: 13rpx;height: 26rpx"></image>
										</view>
									</view>
									<view class="mg-bot-10">
										<text class="fs28 light-gray fw400">{{tugouDetailInfo.distance}}km</text>
									</view>
									<view class="u-f u-f-jcsb u-f-aic" @click="openCity(tugouDetailInfo)">
										<view style="flex: 3" class="one-line-ellipsis"><text
												class="fs28 fw400 light-gray">{{tugouDetailInfo.detailedAddress}}</text>
										</view>
										<view style="flex: 1" class="u-f u-f-jcfe u-f-aic">
											<image style="width: 56rpx;height: 56rpx;" :mode="'widthFix'"
												src="../.././static/common/send.png"></image>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>

					<view class="common-card mg-bot-20">
						<view class="u-f u-f-jcsb u-f-aic" @click="handleShowChoiseSize">
							<view>选择规格</view>
							<view class="u-f u-f-jcsb u-f-aic">
								<text class="fs26 light-gray mg-right-10">{{goodsSpecification}}、x{{goodsNum}}</text>
								<image style="width: 8rpx;height: 16rpx;" src="../.././static/common/sg_right_arrow.png"
									:mode="'widthFix'"></image>
							</view>
						</view>
					</view>

					<view class="user-evlution mg-top-20">
						<view class="ue-title u-f u-f-jcsb u-f-aic" @click="jumpToEvaluationList">
							<common-title :msg="'用户评价'"></common-title>
							<view class="jump-location">
								<image src="../.././static/common/sg_right_arrow.png" style="width: 100%;height: 100%">
								</image>
							</view>
						</view>
						<view v-if="reviewsList.length > 0">
							<view class="ue-user u-f u-f-jcfs u-f-aic mg-top-16">
								<image class="avatar mg-right-10" style="border-radius: 50%;"
									:src="reviewsList[0].avatarUrl"></image>
								<view class="user-desc">
									<view class="fs26 fw400 light-black mg-bot-8">{{reviewsList[0].nickName}}</view>
									<view class="evaluate-wrap u-f u-f-jcfs">
										<view class="fs24 fw400 light-gray mg-right-10">{{reviewsList[0].createTime}}
										</view>
										<view class="evaluate u-f">
											<view class="star-icon" v-for="i in reviewsList[0].score" :key="i"></view>
											<view class="star-num fs24">{{reviewsList[0].score}}分</view>
										</view>
									</view>
								</view>
							</view>
							<view class="ue-content mg-top-24">
								<view class="light-black ellipsis mg-bot-10 fs24 fw400"
									v-if="reviewsList[0].commentContent">
									{{reviewsList[0].commentContent}}
								</view>
								<view class="image-list u-f u-f-jcfs"
									v-if="reviewsList[0].commentImageList && Object.prototype.toString.call(reviewsList[0].commentImageList) !== '[object Null]'">
									<view class="image-item mg-right-12"
										v-for="(innerItm,innerIdx) in reviewsList[0].commentImageList" :key="innerIdx">
										<image class="image-item" :mode="'widthFix'" :src="innerItm"></image>
									</view>
								</view>
							</view>
						</view>
						<view v-else class="fs24 light-gray mg-top-30" style="text-align: center;">暂无评论</view>
					</view>

					<view class="common-card mg-bot-20">
						<view class="good-detail">
							<view class="big-title u-f u-f-aic u-f-jcc mg-bot-20">
								<view class="left mg-right-16"></view>
								<view class="fw700 fs32 main-color mg-right-16">商品详情</view>
								<view class="right"></view>
							</view>
						</view>
					</view>

					<view class="common-card mg-bot-50 ">
						<view class="good-detail">
							<rich-text :nodes="tugouDetailInfo.serviceIntroduction"></rich-text>
							<!-- <image src="../.././static/common/exclamation_ point.png" class="gantanhao"></image> -->
							<text class="light-gray fs24 fw400">“平台只为用户和商家提供服务，开发票请找服务商家”</text>
						</view>
					</view>

				</view>
			</view>

			<view class="fix-bot">
				<view class="u-f u-f-jcsb u-f-aic" style="padding: 0 24rpx;">
					<view class="u-f u-f-jcc u-f-aic" style="flex: 1">
						<view class="u-f u-f-fdc u-f-jcfe mg-right-48" @click="addCollection"
							style="align-items: center;">
							<image v-show="tugouDetailInfo.isCollect" class="already-collect mg-bot-10"
								src="../.././static/common/star.png"></image>
							<image v-show="!tugouDetailInfo.isCollect" class="collect mg-bot-10"
								src="../.././static/common/collect.png"></image>
							<text class="light-black fs24 fw400">收藏</text>
						</view>
						<view class="u-f u-f-fdc u-f-jcc" @click="showCusServeicePopup" style="align-items: center;">
							<text class="serve-person mg-bot-10"></text>
							<text class="light-black fs24 fw400">客服</text>
						</view>
					</view>
					<view class="u-f u-f-jcc u-f-aic" style="flex: 3" @click="handleShowChoiseSize">
						<text class="main-btn" style="width: 70%;text-align: center;">立即成团</text>
					</view>
				</view>
			</view>
		</view>

		<uni-popup :position="'bottom'" class="updatePopup" :show="show" @hidePopup="handleHidePopup">
			<view class="share-modal">
				<image class="gray-close fw70" @click="handleHidePopup" src="../../static/common/gray_close.png"
					mode=""></image>
				<!-- <view class="gray-close fw70" @click="handleHidePopup"></view> -->
				<view class="u-f u-f-aic u-f-jcc one-line-ellipsis mg-bot-32">
					<slot name="share-modal-title">分享出去，让更多人看到</slot>
				</view>

				<view class="content-wrap u-f u-f-fdc u-f-aic">
					<image :src="path" mode="widthFix"></image>

					<l-painter ref="painter" isCanvasToTempFilePath @success="path = $event" hidden
						css="width: 429rpx;height: 562rpx;border: 10rpx solid #FF5502;border-radius:12rpx;padding:20rpx;background:#fff">
						<!-- 基础用法 -->
						<l-painter-image :src="tugouDetailInfo.goodsImageList&&tugouDetailInfo.goodsImageList[0]"
							css="width: 373rpx; height: 363rpx;margin-bottom:10rpx;object-fit: contain;" />
						<l-painter-text :text="tugouDetailInfo.goodsName"
							css="font-size: 28rpx;color: #333333;line-clamp:2" />
						<l-painter-view css="display:flex;">
							<l-painter-text :text="'￥' + tugouDetailInfo.groupBuyingPrice"
								css="font-size: 28rpx;color: #FF4502;margin-right:20rpx" />
							<l-painter-text :text="'￥' + tugouDetailInfo.goodsOriginalPrice"
								css="font-size: 24rpx;color: #999999; text-decoration: line-through;vertical-align: bottom;" />
							<l-painter-image :src="QRCode"
								css="width: 70rpx; height: 70rpx;object-fit: contain;margin-left:100rpx" />
						</l-painter-view>
					</l-painter>

					<view class="share u-f u-f-jcsb u-f-aic mg-bot-46">
						<view class="u-f u-f-fdc u-f-aic" @click="handleShareWxFriend">
							<view class="wx mg-bot-8">
								<image src="../../static/common/weixin.png" style="width: 100%;height: 100%;" mode="">
								</image>
							</view>
							<text class="fs24 light-gray">微信好友</text>
						</view>
						<view class="u-f u-f-fdc u-f-aic" @click="handleShareWxPengyouquan">
							<view class="wx-pengyouquan mg-bot-8">
								<image src="../../static/common/pengyouquan.png" style="width: 100%;height: 100%;"
									mode="">
								</image>
							</view>
							<text class="fs24 light-gray">朋友圈</text>
						</view>
					</view>

					<view class="u-f u-f-aic u-f-jcc" style="width: 100%;">
						<view class="line-gradient-btn" style="flex: 1;padding: 22rpx 0;" @click="savePic">保存图片</view>
					</view>
				</view>
			</view>
		</uni-popup>

		<uni-popup :position="'bottom'" class="updatePopup" :show="showChoiseSize" @hidePopup="handleHideChoiseSize">
			<view class="share-modal">
				<view class="gray-close fw70" @click="handleHideChoiseSize">
					<image style="width: 100%;height: 100%;" src="../.././static/common/gray_close.png"></image>
				</view>
				<view>
					<view class="u-f u-f-aic">
						<image class="border-radius-9" style="width: 146rpx;height: 146rpx;" :mode="'scaleToFill'"
							:src="curImage">
						</image>

						<view class="u-f u-f-fdc u-f-aifs" style="flex: calc(100% - 146rpx)">
							<view class="light-black fs28 ellipsis" style="text-align: left;">
								{{tugouDetailInfo.goodsName}}
							</view>
							<view class="u-f u-f-jcfs u-f-aic">
								<view class="light-black mg-right-18 main-color fw600">
									<text class="fs38">￥</text>
									<text class="fs44">{{specificationListList[active].groupBuyingPrice}}</text>
								</view>
								<view class="light-gray fs24">
									<text
										class="delete-line">￥{{specificationListList&&specificationListList[active].originalPrice}}</text>
								</view>
							</view>
						</view>
					</view>

					<view class="mg-bot-40">
						<view class="fw700 light-black fs28 mg-bot-24" style="text-align: left;">规格</view>
						<view class="tab-list u-f u-f-jcfs" v-if="specificationListList.length > 0">
							<view :class="['tab-item mg-right-20', active === index ? 'active' : '']"
								v-for="(item, index) in specificationListList" :key="item.specificationsId"
								@click="handleTabChooseSize(index, item)">
								{{item.specificationsName}}
							</view>
						</view>
					</view>

					<view class="u-f u-f-jcsb u-f-aic mg-bot-56">
						<text>数量</text>
						<view>
							<uni-number :min="1" :disabled="true" v-model="goodsNum"></uni-number>
						</view>
					</view>

					<view class="u-f u-f-aic u-f-jcc" style="width: 100%;">
						<view class="line-gradient-btn" style="flex: 1;padding: 22rpx 0;" @click="beginBuy">立即购买</view>
					</view>

				</view>
			</view>
		</uni-popup>

		<!-- 客服 -->
		<uni-popup :position="'middle'" :show="showBotPopup" @hidePopup="hideCusServeicePopup">
			<view class="sys-mes-nofity">
				<view class="top u-f u-f-aic u-f-jcc">联系客服</view>
				<view class="mg-top-28">客服电话：{{customerService.cusServicePhone}}</view>
				<view class="bot u-f u-f-jcc u-f-aic" @click="callOut(customerService.cusServicePhone)">
					<text class="confirm">拨打电话</text>
				</view>
			</view>
		</uni-popup>

	</view>
</template>

<script>
	import commonTitle from "../.././components/common-title/common-title.vue"
	import uniNumber from "../.././components/uni-number-box/uni-number-box.vue"
	import uniPopup from "../.././components/uni-popup/uni-popup.vue"

	import {
		getCusNavBarInfo
	} from "../.././common/customizeNavBarInfo.js"
	export default {
		components: {
			commonTitle,
			uniNumber,
			uniPopup
		},
		data() {
			return {
				groupId: 0,
				current: 0,
				goodsId: 0,
				tugouDetailInfo: {},
				number: 1,
				active: 0,
				activeSize: 'huoche',
				sizeList: [{
						name: '货车',
						id: 'huoche'
					},
					{
						name: '轿车',
						id: 'jiaoche'
					}
				],
				paddingTop: 0,
				show: false,
				showChoiseSize: false,
				reviewPageNum: 1,
				reviewPageSize: 10,
				reviewsList: [],
				goodsNum: 1,
				goodsSpecificationId: 0,
				goodsSpecification: '',
				specificationListList: [],
				billInfo: {},
				showBotPopup: false,
				customerService: {},
				timer: null,
				isChangeShop: false,
				QRCode: '',
				path: ''
			}
		},
		computed: {
			curImage() {
				return JSON.stringify(this.tugouDetailInfo.goodsImageList) !== 'null' && this.tugouDetailInfo
					.goodsImageList[this.current] ? this.tugouDetailInfo.goodsImageList[this.current] : ''
			},
			groupProductProgress() {
				return this.tugouDetailInfo.groupNumbered / this.tugouDetailInfo.clusteringNum * 100
			}
		},
		mounted() {
			let {
				customizeNavBarHeight
			} = getCusNavBarInfo()
			this.paddingTop = customizeNavBarHeight + 'px'
		},
		onLoad(options) {
			this.groupId = options.groupId
			this.getSpecificationsListByGroupId() // 商品规格
			this.getCustomerService() // 获取客服信息
			this.getTuGouDetail() // 团购商品详情
		},
		onHide() {
			console.log("LMG", "onHide")
			//clearInterval(this.timer)
		},

		onUnload() {
			console.log("LMG", "onUnload")
			clearInterval(this.timer)
		},
		onShow() {
			let detail = uni.getStorageSync('detail');
			if (detail && this.isChangeShop) {
				let object = JSON.parse(detail);
				this.tugouDetailInfo.storeImage = object.storeLogo
				this.tugouDetailInfo.storeName = object.storeName
				this.tugouDetailInfo.distance = object.distance
				this.tugouDetailInfo.score = object.score
				this.tugouDetailInfo.storeId = object.storeId
				this.tugouDetailInfo.detailedAddress = object.detailedAddress
				this.tugouDetailInfo.commentNum = object.commentNum
				this.tugouDetailInfo.totalSales = object.totalSales
			}
			this.getCustomerService() // 获取客服信息
		},
		onShareAppMessage(res) {
			// id=1854410148847865857&storeId=1854405699001700354
			return {
				title: '[￥' + this.tugouDetailInfo.groupBuyingPrice + ']' + this.tugouDetailInfo.goodsName, // 分享出去的标题
				path: '/pagesC/tugou-detail/tugou-detail?groupId=' + this.groupId // 分享出去的页面路径
			}
		},
		onShareTimeline() {
			return {
				title: '蚂蚁车生活', // 分享出去的标题
			}
		}, // 像这样不配置也行,都有默认值
		methods: {
			async getTuGouDetail() {
				let data = {
					"groupId": this.groupId,
					"lat": this.User.curcity.lat,
					"lon": this.User.curcity.lng
				}

				let res = await this.$http.post('/api/client/groupBuying/details', data, {
					token: true,
					checkToken: true
				})
				let tugouDetailInfo = res.data.data
				this.tugouDetailInfo = tugouDetailInfo || {}
				if (tugouDetailInfo.serviceIntroduction) {
					tugouDetailInfo.serviceIntroduction = tugouDetailInfo.serviceIntroduction.replace(/\<img/gi,
						'<img style="max-width:100% !important;height:auto !important" ')
				}
				this.tugouDetailInfo.serviceIntroduction = tugouDetailInfo.serviceIntroduction
				this.getReviewsList()
				this.startCountdown()


			},
			async getReviewsList() {
				let data = {
					"pageNum": this.reviewPageNum,
					"pageSize": this.reviewPageSize,
					"goodsId": this.tugouDetailInfo.goodsId,
					"storeId": this.tugouDetailInfo.storeId
				}

				let res = await this.$http.post('/api/client/store/reviewsList', data)
				let reviewsList = res.data.data.rows
				this.reviewsList = reviewsList || []
			},
			async getSpecificationsListByGroupId() {
				let data = {
					"groupId": this.groupId,
					"sortType": 1 //  1升序 2降序
				}

				let res = await this.$http.post('/api/client/groupBuying/getSpecificationsListByGroupId', data)
				let specificationListList = res.data.data

				this.specificationListList = specificationListList || []
				this.goodsSpecificationId = this.specificationListList.length > 0 ? this.specificationListList[
					this.active].specificationsId : 0
				this.goodsSpecification = this.specificationListList.length > 0 ? this.specificationListList[
					this.active].specificationsName : ''

				console.log("this.goodsSpecificationId", this.goodsSpecificationId)
			},
			async createGroupBuyingOrder() {
				let data = {
					"groupId": this.groupId,
					"storeId": this.tugouDetailInfo.storeId,
					"specificationsId": this.goodsSpecificationId,
					"goodsNum": this.goodsNum
				}

				uni.showLoading()
				let res = await this.$http.post('/api/client/groupBuying/groupBuyingOrder', data)
				let billInfo = res.data.data
				this.billInfo = billInfo
				uni.hideLoading()
				// 确认订单
				if (res.data.code === 200) {
					uni.navigateTo({
						url: '/pagesC/tugou-buy/tugou-buy?data=' + encodeURIComponent(JSON.stringify(billInfo))
					})
				}

			},
			async getCustomerService() {
				let res = await this.$http.get('/api/client/userInfo/customerService')
				let customerService = res.data.data
				this.customerService = customerService
				console.log("customerService", customerService)
			},
			handleTabChooseSize(index, item) {
				this.active = index;
				this.specificationsId = item.specificationsId
				this.goodsSpecification = item.specificationsName
			},
			handleShowChoiseSize() {
				this.showChoiseSize = true;
			},
			handleHideChoiseSize() {
				this.showChoiseSize = false;
			},
			handleClickLeft() {
				// 获取当前页面栈
				const pages = getCurrentPages();

				// 判断是否有上一页
				if (pages.length > 1) {
					uni.navigateBack({
						delta: 1
					})
				} else {
					uni.switchTab({
						url: '/pages/index/index'
					})
				}
			},
			addCollection() {
				this.$http.post('/api/client/collectionRecord/addCollection', {
					targetId: this.tugouDetailInfo.goodsId,
					storeId: this.tugouDetailInfo.storeId,
					type: 2
				}).then(res => {
					this.tugouDetailInfo.isCollect = !this.tugouDetailInfo.isCollect
					if (this.tugouDetailInfo.isCollect) {
						uni.showToast({
							icon: 'none',
							title: '收藏成功'
						})
					} else {
						uni.showToast({
							icon: 'none',
							title: '取消收藏成功'
						})
					}
				})
			},
			callOut(data) {
				console.log("呼叫");
				uni.makePhoneCall({
					phoneNumber: data, //要拨打的手机号
					success: (res) => {
						// console.log("调用成功")
					},
					fail: (res) => {
						// console.log('调用失败!')
					}
				})
			},
			goToDetail(item) {
				let {
					id,
					userId,
					nickName,
					avatarUrl,
					score,
					commentContent,
					commentImageList,
					createTime
				} = item
				let str = 'id=' + id + '&userId=' + userId + '&nickName=' + nickName + '&avatarUrl=' + avatarUrl +
					'&score=' + score + '&commentContent=' + commentContent + '&commentImageList=' + JSON.stringify(
						commentImageList) + '&createTime=' + createTime
				// uni.navigateTo({
				// 	url: '/pages/evaluation-detail/evaluation-detail?' + str
				// })
			},
			showCusServeicePopup() {
				this.showBotPopup = true
				console.log("showCusServeicePopup", this.showBotPopup)
			},
			hideCusServeicePopup() {
				this.showBotPopup = false
			},
			goToShopDetail() {
				this.isChangeShop = true
				this.User.navigate({
					url: "/pagesC/choice-shop/choice-shop?goodsId=" + this.tugouDetailInfo.goodsId +
						'&storeType2Id=' + 0
				}, "navigateTo", true)
				/* this.User.navigate({
					url: "/pagesC/shop-detail/shop-detail?id=" + this.tugouDetailInfo.storeId
				}, "navigateTo", true); */
			},
			openCity(data) {
				uni.openLocation({
					// 
					latitude: Number(data.lat),
					longitude: Number(data.lon),
					name: '地点',
					address: data.detailedAddress,
					success: function(res) {
						console.log('打开系统位置地图成功')
					},
					fail: function(error) {
						console.log(error)
					}
				})
			},
			beginBuy() {
				if (this.tugouDetailInfo.isPlaceOrder) {
					uni.showToast({
						title: '您已下单过该商品，请勿重复下单',
						icon: 'none'
					})
					return
				}
				this.createGroupBuyingOrder()
				this.handleHideChoiseSize()
			},
			changeswiper(e) {
				this.current = e.detail.current
			},
			jumpToEvaluationList() {
				this.User.navigate({
					url: '/pages/evaluation-list/evaluation-list?storeId=' + this.tugouDetailInfo.storeId
				})
			},

			// 更新所有商品的倒计时
			startCountdown() {

				this.timer = setInterval(() => {
					console.log(this.tugouDetailInfo.remainingTime);
					// 解析剩余时间
					let timeParts = this.tugouDetailInfo.remainingTime.split(':');
					console.log(timeParts);
					let hours = parseInt(timeParts[0], 10);
					let minutes = parseInt(timeParts[1], 10);
					let seconds = parseInt(timeParts[2], 10);

					// 如果时间还未结束
					if (hours > 0 || minutes > 0 || seconds > 0) {
						// 每秒减少1秒
						seconds -= 1;

						// 如果秒数变为负数，调整分钟和小时
						if (seconds < 0) {
							seconds = 59;
							minutes -= 1;
						}
						if (minutes < 0) {
							minutes = 59;
							hours -= 1;
						}

						// 更新倒计时
						this.tugouDetailInfo.remainingTime = this.formatTime(hours, minutes, seconds);
					}
				}, 1000);
			},

			// 格式化时间：将小时、分钟、秒格式化为 "时:分:秒"
			formatTime(hours, minutes, seconds) {
				return `${this.padZero(hours)}:${this.padZero(minutes)}:${this.padZero(seconds)}`;
			},
			// 格式化数字，确保两位数显示
			padZero(num) {
				return num < 10 ? '0' + num : num;
			},
			handleHidePopup() {
				this.show = false;
			},
			showBottomPopup() {
				this.show = true;
			},
			sharePic() { //分享图片给好友按钮的点击事件函数
				let that = this
				this.base64ToFilePath(this.userInfo.jumpAddFriendQr, (filePath) => {
					console.log(filePath);
					wx.showShareImageMenu({ //分享给朋友
						path: filePath,
						success: (res) => {
							console.log("分享成功：", res);
						},
						fail: (err) => {
							console.log("分享取消：", err);
						},
					})
				})
			},
			base64ToFilePath(base64data, fun) { //封装的base64转换成临时文件路径的函数
				const base64 = base64data; //base64格式图片
				const time = new Date().getTime();
				const imgPath = wx.env.USER_DATA_PATH + "/addFriends" + time + "share_qrcode" +
					".png"; //去掉data:image/png;base64,如果图片字符串不含要清空的前缀,可以不执行下行代码.
				const imageData = base64.replace(/^data:image\/\w+;base64,/, "");
				const file = wx.getFileSystemManager();
				file.writeFileSync(imgPath, imageData, "base64");
				fun(imgPath);
			},
			handleShareWxFriend() {
				let that = this
				this.base64ToFilePath(this.path, (filePath) => {
					console.log(filePath);
					wx.showShareImageMenu({ //分享给朋友
						path: filePath,
						success: (res) => {
							console.log("分享成功：", res);
						},
						fail: (err) => {
							console.log("分享取消：", err);
						},
					})
				})
				console.log(this.path);
				// uni.downloadFile({
				//   url: this.path,
				//   success: (res) => {
				//    console.log(res);
				//     uni.showShareImageMenu({
				//       path: res.tempFilePath
				//     })
				//   }
				// })


			},
			handleShareWxPengyouquan() {
				this.savePic('pengyouquan')

			},
		}
	}
</script>

<style>
	page {
		background-color: #F9F9F9;
	}
</style>

<style lang="scss" scoped>
	.maintenance-detail {
		.back-wrap {
			width: 100%;
			height: 100%;

			.white-back-icon {
				width: 30rpx;
				height: 30rpx;
			}
		}

		.content {
			position: relative;

			.top-fixed {
				position: fixed;
				top: 0;
				left: 0;
				width: 100%;
				z-index: 3;
				overflow: hidden;
			}

			.swiper {
				height: 750rpx;

				.swiper-item {
					position: relative;
					display: block;
					width: 100%;
					height: 750rpx;

					.shop-car {
						padding-top: 10rpx;
						position: absolute;
						right: 28rpx;
						width: 62rpx;
						height: 62rpx;
						// background: url(../.././static/maintenance/shop_car.png) no-repeat bottom center;
						background-size: 100%;
						z-index: 1000;
					}

					.swiper-num {
						color: #ffffff;
						padding: 10rpx 24rpx;
						position: absolute;
						bottom: 58rpx;
						right: 24rpx;
						background-color: rgba(0, 0, 0, 0.25);
						border-radius: 28rpx 28rpx 28rpx 28rpx;
						z-index: 2;
					}
				}
			}

			.content-detail {
				position: relative;
				margin-top: -50rpx;
				padding: 26rpx 24rpx 24rpx 34rpx;
				background-color: #F9F9F9;
				border-radius: 40rpx 40rpx 0 0;

				.common-card {
					padding: 20rpx;
					border-radius: 18rpx;
					background-color: #ffffff;

					view {
						view {
							.share-icon {
								width: 30rpx;
								height: 30rpx;
							}
						}
					}

					.youhuiquan {
						padding: 18rpx 20rpx;
						background: #FFF4F0;
						border-radius: 9rpx 9rpx 9rpx 9rpx;

						.main-color-right-arrow {
							width: 18rpx;
							height: 18rpx;
							// background: url(../.././static/maintenance/hight_right_arrow.png) no-repeat center center;
							background-size: 50%;
						}
					}

					.ue-user {
						.avatar {
							width: 78rpx;
							height: 78rpx;
						}

						.user-desc {
							.evaluate-wrap {
								.evaluate {
									.star-icon {
										width: 32rpx;
										height: 32rpx;
										// background: url(../.././static/star.png) no-repeat center center;
										background-size: 100%;
									}

									.star-num {
										color: #F2CB51;
									}
								}
							}
						}
					}

					.ue-content {
						.image-list {
							.image-item {
								width: calc(25% - 12rpx);

								&:last-child {
									margin-right: 0;
								}
							}
						}
					}

					.good-detail {
						.big-title {
							.left {
								width: 165rpx;
								height: 4rpx;
								background: url(../.././static/common/l_recom.png) no-repeat center center;
								background-size: 100%;
							}

							.right {
								width: 165rpx;
								height: 4rpx;
								background: url(../.././static/common/r_recom.png) no-repeat center center;
								background-size: 100%;
							}
						}

						.gantanhao {
							width: 20rpx;
							height: 20rpx;
						}
					}
				}
			}
		}

		.fix-bot {
			width: 100%;
			position: fixed;
			bottom: 0;
			left: 0;
			padding: 10rpx 0;
			background-color: #ffffff;
		}
	}

	.small-gray-right-arrow {
		width: 16rpx;
		height: 16rpx;
	}

	.collect {
		width: 40rpx;
		height: 40rpx;
		// background: url(../.././static/common/collect.png) no-repeat center center;
		background-size: 100%;
	}

	.already-collect {
		width: 40rpx;
		height: 40rpx;
	}

	.serve-person {
		width: 40rpx;
		height: 40rpx;
		background: url(../.././static/common/say.png) no-repeat center center;
		background-size: 100%;
	}

	.default-line-btn {
		color: #333333;
		font-size: 28rpx;
		border-radius: 40rpx;
		padding: 22rpx 46rpx;
		text-align: center;
		background-color: transparent;
		border: 1rpx solid #707070;
	}

	.main-btn {
		color: #ffffff;
		font-size: 28rpx;
		background: linear-gradient(90deg, #FF4502 0%, #FF8903 100%);
		border-radius: 41rpx 41rpx 41rpx 41rpx;
		padding: 22rpx 100rpx;
	}

	.mark {
		font-size: 28rpx;
		padding: 8rpx 50rpx 8rpx 36rpx;
		width: 326rpx;
		color: #ffffff;
		background: linear-gradient(90deg, #FF4502 0%, rgba(255, 137, 3, 0) 100%);
	}

	.join-group-person {
		.main-title-btn {
			padding: 6rpx 12rpx;
			background: #FFF6F3;
			border-radius: 9rpx 4rpx 9rpx 2rpx;
			border: 1rpx solid #FFD0BF;
			color: #FF4502;
		}
	}

	.join-group-progress {
		margin-bottom: 10rpx;

		.progress-wrap {
			flex: 2;
			margin-right: 10rpx;
		}

		.join-group-person {
			color: #FF4502;
		}
	}

	.share-modal {
		position: relative;
		padding: 44rpx;

		.gray-close {
			position: absolute;
			right: 28rpx;
			top: 28rpx;
			width: 42rpx;
			height: 42rpx;
			// background: url(../.././static/common/gray-close.png) no-repeat center center;
			background-size: 100%;
		}

		.content-wrap {
			width: 100%;

			.inner {
				width: 420rpx;
				padding: 12rpx;
				border-radius: 10rpx;
				background-color: #ffffff;
				border: 10rpx solid #FF4502;
			}

			.share {
				width: 420rpx;

				view {
					.wx {
						width: 58rpx;
						height: 58rpx;
						// background: url(../.././static/common/wx.png) no-repeat center center;
						background-size: 100%;
					}

					.wx-pengyouquan {
						width: 58rpx;
						height: 58rpx;
						// background: url(../.././static/common/wx__pengyouquan.png) no-repeat center center;
						background-size: 100%;
					}
				}
			}
		}
	}

	.product-card {
		flex: 1;
		border-radius: 18rpx;
		background-color: #ffffff;

		.pc-image {
			width: 100%;
			height: 340rpx;
		}

		.pc-desc {
			color: #333333;
			height: 74rpx;
		}

		.pc-price {
			margin-top: 10rpx;
			color: #FF4502;
		}
	}

	.tab-list {
		.tab-item {
			padding: 12rpx 30rpx;
			font-size: 22rpx;
			border-radius: 28rpx;
			background-color: transparent;
			border: 1rpx solid transparent;
			background-color: #F9F9F9;
			color: #333333;

			&.active {
				color: #FF4502;
				background-color: #FFEFE9;
				border-color: #FF4502;
			}
		}
	}

	.sys-mes-nofity {
		padding: 0 90rpx;
		padding-bottom: 50rpx;
		position: relative;
		width: 100%;
		background: linear-gradient(180deg, #FFE3D9 0%, #FFFFFF 100%);
		border-radius: 14rpx;

		.top {
			border-radius: 14rpx;
			height: 148rpx;
		}

		.bot {
			margin-top: 72rpx;

			.confirm {
				padding: 10rpx 60rpx;
				border-radius: 30rpx;
				color: #ffffff;
				background-color: #FF4502;
			}
		}
	}

	.updatePopup :deep(.uni-popup-bottom) {
		border-radius: 40rpx 40rpx 0 0;
	}

	.shareBtn {
		margin: unset;
		padding: unset;
		background: #ffffff;
	}

	.shareBtn:after {
		border: unset;
	}

	.share-icon {
		width: 30rpx;
		height: 30rpx;
		background-size: 100%;
	}
</style>