<template>
	<view class="container">
		<!-- 自定义头部导航栏 -->
		<ZdyNavbar @right-click="edit" isRightButton rightButtonText="编辑" :title="data.navbar.title"
			:bgColor="data.navbar.bgColor" :isBack="true" />
			<view class="footer-box" v-if="data.typeList.length>1" >
				<view class="btn" :style="{'margin-bottom':$store.state.safeBottomAz+'px'}" v-for="(item, index) in data.typeList" :key="index" :class="{ active: data.type == getType(index) }"
					@click="setType(index)">
					{{ item }}
				</view>
			</view>
		<view style="display: flex;align-items: center;background: #fff;border-radius: 6px;margin: 10px;padding: 4px;color: #767676;">
			<image src="/static/image/other/notice.png" style="width: 16px;height: 16px;margin-right: 10rpx;margin-left: 10rpx;"></image>
			此功能不具备真实性，仅供娱乐
		</view>
		<image :src="data.code" mode="widthFix" style="width:calc( 100vw - 24px);margin:0 12px;" @click="previewImage">
		</image>
		<view class="button-container">
			<button class="btn-save-image" @click="saveImage">保存图片</button>
		</view>
		<view style="width: 0px;height: 0;overflow: hidden;" v-if="data.shuaxing">
			<l-painter isCanvasToTempFilePath @success="successImage" @progress="progress" css="width:351px;height:250px;"
				v-if="data.type == 0 && data.bgImg1">
				<l-painter-view
					:css="`width:351px;height:250px;position: relative;`">
					<l-painter-image :src="data.bgImg1" css="width:351px;height:250px;position:absolute;left:0;top:0;object-fit:fill;" />
					<!-- 标题 -->
					<l-painter-view :css="`position: absolute;left:${data.graduate.type == 0 ? 46 : 85}px;top:67px;`">
						<l-painter-image :src="data.graduate.title"
							:css="`width: ${data.graduate.type == 0 ? 144 : 64}px;height: 18px;`" />
					</l-painter-view>
					<!-- 头像 -->
					<l-painter-view :css="`position: absolute;left:65px;bottom:55px;`">
						<l-painter-image :src="data.graduate.avatar" :css="`width: 39px;height: 55px;`" />
					</l-painter-view>
					<!-- 注册号码 -->
					<l-painter-view :css="`position: absolute;left:112px;bottom:59px;`">
						<l-painter-text :css="data.textCss" :text="'注册号码：' + data.graduate.code" />
					</l-painter-view>
					<!-- 姓名，性别 -->
					<l-painter-view :css="`position: absolute;left:209px;top:67px;`">
						<l-painter-text :css="data.textCssRight" :text="'学生' + data.graduate.name + '，性别' + data.graduate.sex" />
					</l-painter-view>
					<!-- 注册号码 -->
					<l-painter-view :css="`position: absolute;left:209px;top:77px;`">
						<l-painter-text :css="data.textCssRight" :text="'生于' + data.graduate.birth" />
					</l-painter-view>
					<!-- 注册号码 -->
					<l-painter-view :css="`position: absolute;left:209px;top:87px;`">
						<l-painter-text :css="data.textCssRight"
							:text="'于' + data.graduate.satrt + '至' + data.graduate.end + '在本校'" />
					</l-painter-view>
					<!-- 注册号码 -->
					<l-painter-view :css="`position: absolute;left:209px;top:97px;`">
						<l-painter-text :css="data.textCssRight" :text="data.graduate.college" />
					</l-painter-view>
					<!-- 注册号码 -->
					<l-painter-view :css="`position: absolute;left:209px;top:107px;`">
						<l-painter-text :css="data.textCssRight" :text="data.graduate.major" />
					</l-painter-view>
					<!-- 注册号码 -->
					<l-painter-view :css="`position: absolute;left:209px;top:117px;`">
						<l-painter-text :css="data.textCssRight" :text="'四年制本科学习，'" />
					</l-painter-view>
					<!-- 注册号码 -->
					<l-painter-view :css="`position: absolute;left:209px;top:127px;`">
						<l-painter-text :css="data.textCssRight" :text="'修完培养方案规定的内容，'" />
					</l-painter-view>
					<!-- 注册号码 -->
					<l-painter-view :css="`position: absolute;left:209px;top:137px;`">
						<l-painter-text :css="data.textCssRight" :text="'成绩合格，准予毕业。'" />
					</l-painter-view>
					<!-- 注册号码 -->
					<l-painter-view :css="`position: absolute;left:256px;bottom:68px;width:50px;text-align: center;`">
						<l-painter-text :css="data.textCssRight + 'text-align: center;'"
							:text="data.graduate.type == 0 ? '五道口职业技术学院' : '清华大学'" />
					</l-painter-view>
					<!-- 注册号码 -->
					<l-painter-view :css="`position: absolute;left:256px;bottom:59px;width:50px;text-align: center;`">
						<l-painter-text :css="data.textCssRight + 'text-align: center;'" :text="data.graduate.time" />
					</l-painter-view>
					<!-- 公章 -->
					<l-painter-view :css="`position: absolute;right:41px;bottom:62px;`">
						<l-painter-image :src="data.graduate.icon" :css="`width: 54px;height: 54px;`" />
					</l-painter-view>
					<l-painter-view v-if="$isVip()" :css="`position: absolute;left:117px;bottom:127px;`">
						<l-painter-image src="/static/image/other/card/shuiyin2.png" css="width: 97px;height: 28px;" />
					</l-painter-view>
				</l-painter-view>
			</l-painter>
			<l-painter isCanvasToTempFilePath @success="successImage" @progress="progress" css="width:351px;height:262px;"
				v-else-if="data.type == 1 && data.bgImg2">
				<l-painter-view
					:css="`width:351px;height:262px;position: relative;`">
					<l-painter-image :src="data.bgImg2" css="width:351px;height:262px;position:absolute;left:0;top:0;object-fit:fill;" />
					<l-painter-view :css="`position: absolute;right:126px;bottom:113px;`">
						<l-painter-text :css="data.textCss2 + 'text-align: right;color:#838383;'" :text="data.graduate.name" />
					</l-painter-view>
					<l-painter-view v-if="$isVip()" :css="`position: absolute;left:117px;bottom:127px;`">
						<l-painter-image src="/static/image/other/card/shuiyin2.png" css="width: 97px;height: 28px;" />
					</l-painter-view>
				</l-painter-view>
			</l-painter>
			<l-painter isCanvasToTempFilePath @success="successImage" @progress="progress" css="width:350px;height:552px;"
				v-else-if="data.type == 2">
				<l-painter-view
					:css="`width:350px;height:552px;position: relative;`">
					<l-painter-image src="/static/image/other/certificate/couple/bgImage.png"
						css="width:350px;height:552px;position:absolute;left:0;top:0;object-fit:fill;" />
					<!-- 持证人：绝对定位，避免鸿蒙 flex 错位 -->
					<l-painter-text :css="data.textCssCouple + `position:absolute;left:39px;top:123px;`"
						:text="data.graduate.name" />
					<l-painter-image src="/static/image/other/certificate/couple/love.png"
						:css="`position:absolute;left:${coupleHolder.iconLeft}px;top:125px;width:10px;height:9px;`" />
					<l-painter-text :css="data.textCssCouple + `position:absolute;left:${coupleHolder.name2Left}px;top:123px;`"
						:text="data.graduate.name2" />
					<l-painter-view :css="`position: absolute;left:39px;top:175px;`">
						<l-painter-text :css="data.textCssCouple" :text="data.graduate.time" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:39px;top:224px;width:180px;`">
						<l-painter-text :css="data.textCssCouple + 'width:180px;'" :text="data.graduate.dec" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:33px;bottom:45px;`">
						<l-painter-text :css="data.textCssCouple" :text="'发证时间: ' + data.graduate.time" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:33px;bottom:27px;`">
						<l-painter-text :css="data.textCssCouple"
							:text="`发证单位: ${$isVip() ? '装样大师恋爱委员会' : '幸福恋爱委员会'}`" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:156px;top:93px;`">
						<l-painter-image :src="data.graduate.image" css="width: 160px;height: 110px;" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:227px;top:181px;`">
						<l-painter-image :src="`/static/image/other/certificate/couple/${$isVip() ? 'icon1' : 'icon2'}.png`"
							css="width: 104px;height: 92px;" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:251px;bottom:21px;`">
						<l-painter-qrcode text="http://u8t.cn/QJ?sc=DpK" image="/static/image/other/certificate/couple/image.png"
							css="width: 44px; height: 44px" />
					</l-painter-view>
					<l-painter-view v-if="$isVip()" :css="`position: absolute;left:117px;bottom:127px;`">
						<l-painter-image src="/static/image/other/card/shuiyin2.png" css="width: 97px;height: 28px;" />
					</l-painter-view>
				</l-painter-view>
			</l-painter>
			<l-painter isCanvasToTempFilePath @success="successImage" @progress="progress" css="width:350px;height:552px;"
				v-else-if="data.type == 3">
				<l-painter-view
					:css="`width:350px;height:552px;position: relative;`">
					<l-painter-image src="/static/image/other/certificate/couple/bgImage2.png"
						css="width:350px;height:552px;position:absolute;left:0;top:0;object-fit:fill;" />
					<!-- 持证人 -->
					<l-painter-text :css="data.textCssCouple + `position:absolute;left:39px;top:123px;`"
						:text="data.graduate.name" />
					<l-painter-image src="/static/image/other/certificate/couple/noLove.png"
						:css="`position:absolute;left:${coupleHolder.iconLeft}px;top:125px;width:10px;height:9px;`" />
					<l-painter-text :css="data.textCssCouple + `position:absolute;left:${coupleHolder.name2Left}px;top:123px;`"
						:text="data.graduate.name2" />
					<l-painter-view :css="`position: absolute;left:39px;top:175px;`">
						<l-painter-text :css="data.textCssCouple" :text="data.graduate.time" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:39px;top:224px;width:180px;`">
						<l-painter-text :css="data.textCssCouple + 'width:180px;'" :text="data.graduate.dec" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:33px;bottom:45px;`">
						<l-painter-text :css="data.textCssCouple" :text="'发证时间: ' + data.graduate.time" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:33px;bottom:27px;`">
						<l-painter-text :css="data.textCssCouple"
							:text="`发证单位: ${$isVip() ? '装样大师分手委员会' : '分手快乐委员会'}`" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:156px;top:93px;`">
						<l-painter-image :src="data.graduate.image" css="width: 160px;height: 110px;" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:156px;top:93px;`">
						<l-painter-image src="/static/image/other/certificate/couple/imageDask.png"
							css="width: 160px;height: 110px;" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:227px;top:181px;`">
						<l-painter-image :src="`/static/image/other/certificate/couple/${$isVip() ? 'icon1' : 'icon2'}2.png`"
							css="width: 104px;height: 92px;" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:251px;bottom:21px;`">
						<l-painter-qrcode text="http://u8t.cn/QJ?sc=DpK" image="/static/image/other/certificate/couple/image.png"
							css="width: 44px; height: 44px" />
					</l-painter-view>
					<l-painter-view v-if="$isVip()" :css="`position: absolute;left:117px;bottom:127px;`">
						<l-painter-image src="/static/image/other/card/shuiyin2.png" css="width: 97px;height: 28px;" />
					</l-painter-view>
				</l-painter-view>
			</l-painter>
			<l-painter isCanvasToTempFilePath @success="successImage" @progress="progress" css="width:351px;height:248px;"
				v-else-if="data.type == 4">
				<l-painter-view
					:css="`width:351px;height:248px;background-image: url('/static/image/other/certificate/certificate/bgImg.png');position: relative;`">
					<l-painter-view :css="`position: absolute;left:55px;top:85px;display: flex;align-items: center;`">
						<l-painter-text :css="data.textCss4 +'width:50px;text-align:center;'+data.textFont" :text="data.graduate.name" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:108px;top:85px;display: flex;align-items: center;`">
						<l-painter-text :css="data.textCss4 +data.textFont" :text="data.graduate.title1" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:60px;top:110px;display: flex;align-items: center;`">
						<l-painter-text :css="data.textCss4 +data.textFont" :text="data.graduate.title2" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:60px;bottom:36px;display: flex;align-items: center;`">
						<l-painter-text :css="data.textCss4 +data.textFont" :text="data.graduate.title3" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:0px;top:133px;display: flex;align-items: center;`">
						<l-painter-text :css="data.textCss4 +'width:351px;text-align:center;font-size:36px;color:#E63C00;'+data.textFont"
							:text="data.graduate.dec" />
					</l-painter-view>
					<l-painter-view v-if="$isVip()" :css="`position: absolute;left:117px;bottom:127px;`">
						<l-painter-image src="/static/image/other/card/shuiyin2.png" css="width: 97px;height: 28px;" />
					</l-painter-view>
				</l-painter-view>
			</l-painter>
			<l-painter isCanvasToTempFilePath @success="successImage" @progress="progress" css="width:351px;height:248px;"
				v-else-if="data.type == 5">
				<l-painter-view
					:css="`width:351px;height:248px;background-image: url('/static/image/other/certificate/certificate/bgImg2.png');position: relative;`">
					<l-painter-view :css="`position: absolute;left:60px;top:95px;display: flex;align-items: center;`">
						<l-painter-text :css="data.textCss5 +data.textFont" :text="data.graduate.name" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:60px;top:113px;display: flex;align-items: center;`">
						<l-painter-text :css="data.textCss5 +data.textFont" :text="data.graduate.title1" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:0px;bottom:58px;display: flex;align-items: center;`">
						<l-painter-text :css="data.textCss5 +'width:351px;text-align:center;'+data.textFont" :text="data.graduate.title2" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:0px;top:126px;display: flex;align-items: center;`">
						<l-painter-text :css="data.textCss5 +'width:351px;text-align:center;font-size:36px;color:#F85400;'+data.textFont"
							:text="data.graduate.dec" />
					</l-painter-view>
					<l-painter-view v-if="$isVip()" :css="`position: absolute;left:117px;bottom:127px;`">
						<l-painter-image src="/static/image/other/card/shuiyin2.png" css="width: 97px;height: 28px;" />
					</l-painter-view>
				</l-painter-view>
			</l-painter>
			<l-painter isCanvasToTempFilePath @success="successImage" @progress="progress" css="width:351px;height:248px;"
				v-else-if="data.type == 6">
				<l-painter-view
					:css="`width:351px;height:248px;position: relative;`">
					<l-painter-image src="/static/image/other/certificate/god/bgImg.png"
						css="width:351px;height:248px;position:absolute;left:0;top:0;object-fit:fill;" />
					<l-painter-view :css="`position: absolute;left:74px;top:181px;`">
						<l-painter-text :css="data.textCss6 +'width:60px;text-align:center;'" :text="data.graduate.name" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:74px;top:204px;`">
						<l-painter-text :css="data.textCss6 +'width:60px;text-align:center;'" :text="data.graduate.age" />
					</l-painter-view>
					<!-- 兹证明：手动换行，鸿蒙下 width 自动折行不生效 -->
					<l-painter-view :css="`position: absolute;left:161px;top:44px;width:166px;`">
						<l-painter-text :css="data.textCssGodBody" :text="goddessCertText" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:211px;top:171px;`">
						<l-painter-text :css="data.textCss6 " :text="data.graduate.time1" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:211px;top:190px;`">
						<l-painter-text :css="data.textCss6 " :text="data.graduate.time2" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:211px;top:208px;`">
						<l-painter-text :css="data.textCss6 " :text="'装样大师颜值委员会'" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:60px;top:84px;`">
						<l-painter-image :src="data.graduate.avatar" css="width: 70px;height: 88px;" />
					</l-painter-view>
					<l-painter-view v-if="$isVip()" :css="`position: absolute;left:117px;bottom:127px;`">
						<l-painter-image src="/static/image/other/card/shuiyin2.png" css="width: 97px;height: 28px;" />
					</l-painter-view>
				</l-painter-view>
			</l-painter>
			<l-painter isCanvasToTempFilePath @success="successImage" @progress="progress" css="width:351px;height:248px;"
				v-else-if="data.type == 7">
				<l-painter-view
					:css="`width:351px;height:248px;position: relative;`">
					<l-painter-image src="/static/image/other/certificate/god/bgImg2.png"
						css="width:351px;height:248px;position:absolute;left:0;top:0;object-fit:fill;" />
					<l-painter-view :css="`position: absolute;left:74px;top:181px;`">
						<l-painter-text :css="data.textCss6 +'width:60px;text-align:center;'" :text="data.graduate.name" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:74px;top:204px;`">
						<l-painter-text :css="data.textCss6 +'width:60px;text-align:center;'" :text="data.graduate.age" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:161px;top:44px;width:166px;`">
						<l-painter-text :css="data.textCssGodBody" :text="godCertText" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:211px;top:171px;`">
						<l-painter-text :css="data.textCss6 " :text="data.graduate.time1" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:211px;top:190px;`">
						<l-painter-text :css="data.textCss6 " :text="data.graduate.time2" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:211px;top:208px;`">
						<l-painter-text :css="data.textCss6 " :text="'装样大师颜值委员会'" />
					</l-painter-view>
					<l-painter-view :css="`position: absolute;left:60px;top:84px;`">
						<l-painter-image :src="data.graduate.avatar" css="width: 70px;height: 88px;" />
					</l-painter-view>
					<l-painter-view v-if="$isVip()" :css="`position: absolute;left:117px;bottom:127px;`">
						<l-painter-image src="/static/image/other/card/shuiyin2.png" css="width: 97px;height: 28px;" />
					</l-painter-view>
				</l-painter-view>
			</l-painter>
		</view>
		<!-- 编辑弹窗 -->
		<view v-if="showEditPopup" class="popup-overlay">
			<view class="popup-content">
				<view class="popup-header">
					<text class="popup-title">编辑证书</text>
					<text class="popup-close" @click="closeEditPopup">×</text>
				</view>
				<view class="popup-body">
					<!-- 毕业证书样式1 -->
					<template v-if="data.type == 0">
						<view class="form-row">
							<text class="form-label">学校：</text>
							<uni-data-select v-model="editForm.type" @change="typeChange" :localdata="data.range"></uni-data-select>
						</view>
						<view class="form-row">
							<text class="form-label">姓名：</text>
							<input class="form-input" v-model="editForm.name" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">性别：</text>
							<input class="form-input" v-model="editForm.sex" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">出生日期：</text>
							<input class="form-input" v-model="editForm.birth" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">入学时间：</text>
							<input class="form-input" v-model="editForm.satrt" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">毕业时间：</text>
							<input class="form-input" v-model="editForm.end" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">学院：</text>
							<input class="form-input" v-model="editForm.college" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">专业：</text>
							<input class="form-input" v-model="editForm.major" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">证书编号：</text>
							<input class="form-input" v-model="editForm.code" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">发证时间：</text>
							<input class="form-input" v-model="editForm.time" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">照片：</text>
							<view class="upload-container">
								<image v-if="editForm.avatar" :src="editForm.avatar" class="upload-image" @click="chooseImage(39,55)" />
								<view v-else class="upload-btn" @click="chooseImage(39,55)">
									<text class="upload-text">点击上传照片</text>
								</view>
							</view>
						</view>
					</template>

					<!-- 毕业证书样式2 -->
					<template v-else-if="data.type == 1">
						<view class="form-row">
							<text class="form-label">姓名：</text>
							<input class="form-input" v-model="editForm.name" type="text" />
						</view>
					</template>

					<!-- 情侣证 -->
					<template v-else-if="data.type == 2">
						<view class="form-row">
							<text class="form-label">姓名1：</text>
							<input class="form-input" v-model="editForm.name" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">姓名2：</text>
							<input class="form-input" v-model="editForm.name2" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">时间：</text>
							<input class="form-input" v-model="editForm.time" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">描述：</text>
							<input class="form-input" v-model="editForm.dec" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">照片：</text>
							<view class="upload-container">
								<image v-if="editForm.image" :src="editForm.image" class="upload-image" @click="chooseImage(160,110)" />
								<view v-else class="upload-btn" @click="chooseImage(160,110)">
									<text class="upload-text">点击上传照片</text>
								</view>
							</view>
						</view>
					</template>

					<!-- 分手证 -->
					<template v-else-if="data.type == 3">
						<view class="form-row">
							<text class="form-label">姓名1：</text>
							<input class="form-input" v-model="editForm.name" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">姓名2：</text>
							<input class="form-input" v-model="editForm.name2" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">时间：</text>
							<input class="form-input" v-model="editForm.time" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">描述：</text>
							<input class="form-input" v-model="editForm.dec" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">照片：</text>
							<view class="upload-container">
								<image v-if="editForm.image" :src="editForm.image" class="upload-image" @click="chooseImage(160,110)" />
								<view v-else class="upload-btn" @click="chooseImage(160,110)">
									<text class="upload-text">点击上传照片</text>
								</view>
							</view>
						</view>
					</template>

					<!-- 奖状样式1 -->
					<template v-else-if="data.type == 4">
						<view class="form-row">
							<text class="form-label">姓名：</text>
							<input class="form-input" v-model="editForm.name" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">标题1：</text>
							<input class="form-input" v-model="editForm.title1" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">标题2：</text>
							<input class="form-input" v-model="editForm.title2" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">标题3：</text>
							<input class="form-input" v-model="editForm.title3" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">描述：</text>
							<input class="form-input" v-model="editForm.dec" type="text" />
						</view>
					</template>

					<!-- 奖状样式2 -->
					<template v-else-if="data.type == 5">
						<view class="form-row">
							<text class="form-label">姓名：</text>
							<input class="form-input" v-model="editForm.name" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">标题1：</text>
							<input class="form-input" v-model="editForm.title1" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">标题2：</text>
							<input class="form-input" v-model="editForm.title2" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">描述：</text>
							<input class="form-input" v-model="editForm.dec" type="text" />
						</view>
					</template>

					<!-- 女神证 -->
					<template v-else-if="data.type == 6">
						<view class="form-row">
							<text class="form-label">姓名：</text>
							<input class="form-input" v-model="editForm.name" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">年龄：</text>
							<input class="form-input" v-model="editForm.age" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">照片：</text>
							<view class="upload-container">
								<image v-if="editForm.avatar" :src="editForm.avatar" class="upload-image" @click="chooseImage(70,88)" />
								<view v-else class="upload-btn" @click="chooseImage(70,88)">
									<text class="upload-text">点击上传照片</text>
								</view>
							</view>
						</view>
						<view class="form-row">
							<text class="form-label">时间1：</text>
							<input class="form-input" v-model="editForm.time1" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">时间2：</text>
							<input class="form-input" v-model="editForm.time2" type="text" />
						</view>
					</template>

					<!-- 男神证 -->
					<template v-else-if="data.type == 7">
						<view class="form-row">
							<text class="form-label">姓名：</text>
							<input class="form-input" v-model="editForm.name" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">年龄：</text>
							<input class="form-input" v-model="editForm.age" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">照片：</text>
							<view class="upload-container">
								<image v-if="editForm.avatar" :src="editForm.avatar" class="upload-image" @click="chooseImage(70,88)" />
								<view v-else class="upload-btn" @click="chooseImage(70,88)">
									<text class="upload-text">点击上传照片</text>
								</view>
							</view>
						</view>
						<view class="form-row">
							<text class="form-label">时间1：</text>
							<input class="form-input" v-model="editForm.time1" type="text" />
						</view>
						<view class="form-row">
							<text class="form-label">时间2：</text>
							<input class="form-input" v-model="editForm.time2" type="text" />
						</view>
					</template>
				</view>
				<view class="popup-footer">
					<button class="btn-cancel" @click="closeEditPopup">取消</button>
					<button class="btn-save" @click="saveEditForm">保存</button>
				</view>
			</view>
		</view>
		<!-- 水印 -->
		<view v-if="$isVip()">
			<liu-drag-button :canDocking="false"
				@clickBtn="$goRechargePage('watermark', 'uni_alipay_other_certificate')">
				<image src='/static/lottie/watermark.gif' mode="widthFix" style="width:94px;height:74px;" ></image>
			</liu-drag-button>
		</view>
	</view>
</template>

<script setup>
	// 自定义头部
	import ZdyNavbar from "@/components/nav-bar/nav-bar.vue"
	import { imgLocal  } from '@/utils/common.js';

	import {
		ref,
		reactive,
		computed,
		watch,
		nextTick,
		getCurrentInstance
	} from "vue";
	import {
		onLoad,
		onShow,
		onUnload,
		onReady,
		onPullDownRefresh,
		onReachBottom
	} from "@dcloudio/uni-app";
	const {
		appContext,
		proxy
	} = getCurrentInstance();
	const data = reactive({
		styleType:0,
		type: 0,
		bgImg1:'',
		bgImg2:'',
		graduate: {
			type: 0,
			avatar: '',
			title: '/static/image/other/certificate/graduate/title1.png',
			icon: '/static/image/other/certificate/graduate/icon1.png',
			bgImg: '',
			code: "v1ToV631231311",
			name: '某某',
			sex: '男',
			birth: '2000年1月1日',
			satrt: '2019年9月',
			end: '2023年6月',
			college: '计算机科学与技术学院',
			major: '计算机科学与技术专业',
			time: '2023年6月30日'
		},
		range: [{
			"value": 0,
			"text": "五道口职业技术学院"
		}, {
			"value": 1,
			"text": "清华大学"
		}],
		shuaxing: false,
		navbar: {
			title: "证书",
			bgColor: '#EDEDED',
		},
		width: 800,
		height: 600,
		code: '',
		textCss: 'word-spacing: 50px;letter-spacing: 20px;word-spacing: 20px;font-family: "SimSun", "宋体", sans-serif;width:100px;color:#3D3D3D;font-size:4px; mix-blend-mode: overlay;',
		textCssRight: 'word-spacing: 50px;letter-spacing: 20px;word-spacing: 20px;font-family: "SimSun", "宋体", sans-serif;width:100px;color:#3D3D3D;font-size:5px; mix-blend-mode: overlay;',
		textCss2: 'word-spacing: 50px;letter-spacing: 20px;word-spacing: 20px;font-family:  "宋体", sans-serif;width:100px;color:#3D3D3D;font-size:5.2px; mix-blend-mode: overlay;',
		textCss3: 'word-spacing: 50px;letter-spacing: 20px;word-spacing: 20px;font-family:  "宋体", sans-serif;color:#3D3D3D;font-size:12px; mix-blend-mode: overlay;',
		// 情侣/分手证文字（去掉 letter-spacing，避免鸿蒙字距异常）
		textCssCouple: 'font-family: "宋体", sans-serif;color:#3D3D3D;font-size:12px;',
		textCss4: 'font-weight: bold;font-family:  "宋体", sans-serif;color:#3D3D3D;font-size:13px; mix-blend-mode: overlay;',
		textCss5: 'font-weight: bold;font-family:  "宋体", sans-serif;color:#3D3D3D;font-size:13px; mix-blend-mode: overlay;',
		textCss6: 'font-weight: bold;font-family: "宋体", sans-serif;color:#3D3D3D;font-size:10px; mix-blend-mode: overlay;',
		textCssGodBody: 'font-weight:bold;font-family:"宋体",sans-serif;color:#3D3D3D;font-size:11px;width:166px;line-height:1.45em;',
		textCss7: 'font-weight: bold;font-family:  "宋体", sans-serif;color:#3D3D3D;font-size:13px; mix-blend-mode: overlay;',
		textFont:'font-family:"certificate";',
		textCssLeft: 'text-align: left;',
		textCssCenter: 'text-align: center;',
		typeList: [
			'样式一',//毕业证书
			'样式二',//毕业证书
			'情侣证',
			'分手证',
			'样式一',//奖状样式
			'样式二',//奖状样式
			'样式一',//女神证
			'样式二',//男神证
		]
	})

	/** 持证人：按姓名字数算爱心/第二姓名位置（font-size 12 ≈ 每字 12px） */
	const coupleHolder = computed(() => {
		const nameLen = String(data.graduate?.name || '').length
		const charW = 12
		const startLeft = 39
		const gap = 5
		const iconW = 10
		const iconLeft = startLeft + nameLen * charW + gap
		const name2Left = iconLeft + iconW + gap
		return { iconLeft, name2Left }
	})

	/** 按字数插入换行（鸿蒙 canvas 窄宽不自动折行） */
	function wrapTextByChars(text, charsPerLine = 15) {
		const s = String(text || '')
		const lines = []
		for (let i = 0; i < s.length; i += charsPerLine) {
			lines.push(s.slice(i, i + charsPerLine))
		}
		return lines.join('\n')
	}

	const goddessCertText = computed(() => {
		const name = data.graduate?.name || ''
		const text = ` 兹证明 ${name} 同志，肤白貌美，聪颖过人，身材窈窕，婉约温柔，沉鱼落雁，闭月羞花，迷倒一群高富帅，人称“女神”，通过外貌协会权威认证，特发此证。`
		return wrapTextByChars(text, 15)
	})

	const godCertText = computed(() => {
		const name = data.graduate?.name || ''
		const text = ` 兹证明 ${name}同志，肤若凝脂，气宇轩昂，聪慧果敢，身形挺拔，温润如玉，才貌双全，迷倒万千少女心，人称“男神”，经颜值与气质协会权威认证，特发此证。`
		return wrapTextByChars(text, 15)
	})

	// 弹窗相关
	const showEditPopup = ref(false);
	const editForm = ref({});
	onLoad(async(option) => {
		uni.showLoading({
			title: "生成中"
		})
		try {
			data.bgImg1 = await imgLocal.getLocalImage('other/certificate/graduate/graduate1.png')
		} catch (e) {
			console.error('毕业证书背景1加载失败', e)
			data.bgImg1 = ''
		}
		try {
			data.bgImg2 = await imgLocal.getLocalImage('other/certificate/graduate/graduate2.png')
		} catch (e) {
			console.error('毕业证书背景2加载失败', e)
			data.bgImg2 = ''
		}
		data.styleType=option.styleType||0
		if(data.styleType==0){
			data.navbar.title='毕业证书'
			data.typeList=[
				'样式一',//毕业证书
				'样式二',//毕业证书
			]
			setType(0)
		}else if(data.styleType==1){
			data.navbar.title='情侣证'
			data.typeList=['情侣证',]
			data.type=2
			setType(0)
		}else if(data.styleType==2){
			data.navbar.title='分手证'
			data.typeList=['分手证',]
			data.type=3
			setType(0)
		}else if(data.styleType==3){
			data.navbar.title='奖状'
			data.typeList=[
				'样式一',//奖状样式
				'样式二',//奖状样式
			]
			data.type=4
			setType(0)
		}else{
			data.navbar.title='颜值证'
			data.type=6
			data.typeList=[
				'样式一',//女神证
				'样式二',//男神证
			]
			setType(0)
		}
		data.shuaxing = true
		if (data.styleType == 0 && !data.bgImg1 && !data.bgImg2) {
			uni.hideLoading()
			uni.showToast({ title: '背景图加载失败', icon: 'none' })
		}
		// 进入毕业证书页面埋点
		proxy.$apiUserEvent('all', {
			type: 'event',
			key: 'certificate',
			prefix: '.uni.other.',
			value: data.navbar.title
		})
		// let graduateData = uni.getStorageSync("graduateData")
		// if (graduateData) {
		// 	data.graduate = graduateData
		// }
		uni.$on("editFormPhoto", (info) => {
			data.code = ""
			if(data.type==2||data.type==3){
				editForm.value.image = info;
			}else{
				editForm.value.avatar = info;
			}
			// editForm.value.avatar = info;
			// data.graduate.avatar = info;
		})
		const config = uni.getStorageSync('config')
		console.log("---config---", config);
		const font = config.config['client.uniapp.font']

		console.log("字体地址信息", font.certificate);
		// Font loading logic
		const fontUrl = font.certificate;
		const fontName = 'certificate';

		const loadFont = (path) => {
			uni.loadFontFace({
				family: fontName,
				source: `url("${path}")`,
				success() {
					console.log('字体加载成功');
				},
				fail(err) {
					console.error('字体加载失败', err);
				}
			});
		};

		// #ifdef H5
		// H5 环境直接从 URL 加载字体
		loadFont(fontUrl);
		// #endif

		// #ifndef H5
		// 非 H5 环境使用下载和保存逻辑
		const savedFontPath = uni.getStorageSync('	');
		if (savedFontPath) {
			loadFont(savedFontPath);
		} else {
			uni.downloadFile({
				url: fontUrl,
				success: (res) => {
					if (res.statusCode === 200) {
						uni.saveFile({
							tempFilePath: res.tempFilePath,
							success: (saveRes) => {
								const savedPath = saveRes.savedFilePath;
								uni.setStorageSync('certificate_font_path', savedPath);
								console.log("字体保存路径", savedPath);
								loadFont(savedPath);
							},
							fail: (err) => {
								console.error('保存文件失败', err);
								// Fallback: 尝试加载临时路径
								loadFont(res.tempFilePath);
							}
						});
					}
				},
				fail: (err) => {
					console.error('下载字体失败', err);
				}
			});
		}
		// #endif
	})
	onUnload(() => {
		uni.$off('editFormPhoto')
	})
	onReady(() => {

	})
	onShow(() => {})
	onPullDownRefresh(() => {
		setTimeout(() => {
			uni.stopPullDownRefresh();
		}, 1000);
	})
	onReachBottom(() => {

	})

	function setType(index) {
		if(data.styleType==0){
			
		}else if(data.styleType==1){
			index+=2
		}else if(data.styleType==2){
			index+=3
		}else if(data.styleType==3){
			index+=4
		}else{
			index+=6
		}
		uni.showLoading({
			title: "生成中"
		})
		data.type = index
		if (index == 0 || index == 1) {
			let graduateData = uni.getStorageSync("graduateData") || {
				type: 0,
				avatar: '',
				title: '/static/image/other/certificate/graduate/title1.png',
				icon: '/static/image/other/certificate/graduate/icon1.png',
				bgImg: '',
				code: "v1ToV631231311",
				name: '某某',
				sex: '男',
				birth: '2000年1月1日',
				satrt: '2019年9月',
				end: '2023年6月',
				college: '计算机科学与技术学院',
				major: '计算机科学与技术专业',
				time: '2023年6月30日'
			}
			data.graduate = graduateData
		} else if (index == 2) {
			let graduateData = uni.getStorageSync("graduateData2") || {
				name: '熊大',
				name2: "光头强",
				time: "2026年5月20日",
				image: "/static/image/other/certificate/couple/image.png",
				dec: '手牵手不走散 你是我心中的 No.1'
			}
			data.graduate = graduateData
		} else if (index == 3) {
			let graduateData = uni.getStorageSync("graduateData3") || {
				name: '熊大',
				name2: "光头强",
				time: "2026年5月20日",
				image: "/static/image/other/certificate/couple/image.png",
				dec: '谢谢你的出现，让遗憾的是，我们终究没能走到最后。'
			}
			data.graduate = graduateData
		} else if (index == 4) {
			let graduateData = uni.getStorageSync("graduateData4") || {
				name: '熊大',
				title1: '宝宝',
				title2: '恭喜你在本年度被评为：',
				title3: '特发此证 以资鼓励',
				dec: '拉屎大王'
			}
			data.graduate = graduateData
		} else if (index == 5) {
			let graduateData = uni.getStorageSync("graduateData5") || {
				name: '熊大',
				title1: '恭喜你在本年度被评为：',
				title2: '特发此证 以资鼓励',
				dec: '干饭大王'
			}
			data.graduate = graduateData
		} else if (index == 6) {
			let graduateData = uni.getStorageSync("graduateData6") || {
				name: '朱碧石',
				age: '男',
				avatar: '/static/image/other/certificate/god/image1.png',
				time1: '长期有效',
				time2: '2026年4月14日'
			}
			data.graduate = graduateData
		} else if (index == 7) {
			let graduateData = uni.getStorageSync("graduateData7") || {
				name: '良子',
				age: '男',
				avatar: '/static/image/other/certificate/god/image2.png',
				time1: '长期有效',
				time2: '2026年4月14日'
			}
			data.graduate = graduateData
		}
	}

	function typeChange(e) {
		console.log(e);
		if (e) {
			editForm.value.title = '/static/image/other/certificate/graduate/title2.png';
			editForm.value.icon = '/static/image/other/certificate/graduate/icon2.png';
		} else {
			editForm.value.title = '/static/image/other/certificate/graduate/title1.png';
			editForm.value.icon = '/static/image/other/certificate/graduate/icon1.png';
		}
	}
	const getType = (index) => {
		switch (Number(data.styleType)) {
			case 0:
				return index
			case 1:
				return index + 2
			case 2:
				return index + 3
			case 3:
				return index + 4
			default:
				return index + 6
		}
	}
	function successImage(e) {
		data.code = e
		uni.hideLoading()
	}

	function progress(e) {
		// console.log(e)

	}
	// 打开编辑弹窗
	function edit() {
		console.log(data.graduate)
		// 复制当前表单数据到编辑表单
		editForm.value = JSON.parse(JSON.stringify(data.graduate));
		// 显示弹窗
		showEditPopup.value = true;
	}

	// 关闭编辑弹窗
	function closeEditPopup() {
		showEditPopup.value = false;
	}

	// 保存编辑表单
	function saveEditForm() {
		uni.showLoading({
			title: "生成中"
		})
		data.shuaxing = false
		// 将编辑后的数据复制回原始表单
		data.graduate = editForm.value
		setTimeout(() => {
			data.shuaxing = true
		}, 100)
		uni.setStorageSync(["graduateData", "graduateData", "graduateData2", "graduateData3", "graduateData4",
			"graduateData5", "graduateData6", "graduateData7"
		][data.type], data.graduate)
		// 关闭弹窗
		showEditPopup.value = false;
	}

	// 选择图片
	function chooseImage(width,height) {
		uni.chooseImage({
			count: 1,
			sizeType: ['original', 'compressed'],
			sourceType: ['album', 'camera'],
			success: (res) => {
				uni.navigateTo({
					url: '/pages/other/qf-image/qf-image?src=' + res.tempFilePaths[0]+'&width='+width+'&height='+height
				})
			},
			fail: (err) => {
				console.log('选择图片失败', err);
			}
		});
	}


	/**
	 * 将本地图片路径通过 Canvas 转换为 File 对象
	 * @param {string} localPath - 本地图片路径（如从 uni.chooseImage 获取的 tempFilePath）
	 * @param {Object} options - 可选参数
	 * @param {string} options.format - 输出格式 'image/png' 或 'image/jpeg'，默认 'image/png'
	 * @param {number} options.quality - 图片质量（仅 jpeg 有效），0~1，默认 0.92
	 * @param {number} options.maxWidth - 最大宽度（等比缩放），不填则使用原图尺寸
	 * @param {number} options.maxHeight - 最大高度（等比缩放），不填则使用原图尺寸
	 * @returns {Promise<File>} 返回一个 Promise，resolve 为 File 对象
	 */
	function convertLocalImageToFile(localPath) {
		return new Promise((resolve, reject) => {
			// #ifdef APP-PLUS&&!APP-HARMONY
			// 1. 读取本地图片为 Base64（避免 Image 对象直接加载本地路径的兼容问题）
			plus.io.resolveLocalFileSystemURL(localPath, (entry) => {
				entry.file((file) => {
					const reader = new plus.io.FileReader();
					reader.onload = (e) => {
						const base64Data = e.target.result; // 格式如 data:image/jpeg;base64,/9j/...
						resolve(e.target.result)
					};
					reader.onerror = (err) => reject(err);
					reader.readAsDataURL(file); // 读取为 DataURL
				}, reject);
			}, reject);
			// #endif
			// #ifndef APP-PLUS
			reject(new Error('plus.io not supported'))
			// #endif
		});
	}
	// 预览图片
	function previewImage() {
		if (data.code) {
			uni.previewImage({
				urls: [data.code],
				current: 0
			});
		}
	}

	// 保存图片
	function saveImage() {
		if (data.code) {
			console.log(data.code)
			uni.showLoading({
				title: '保存中...'
			});
			try {
				// 检查是否为base64格式
				if (data.code.startsWith('data:image')) {
					// 处理base64格式图片
					console.log('开始处理base64图片');
					uni.base64ToTempFile({
						base64: data.code.split(',')[1], // 去除base64前缀
						success: (res) => {
							console.log('base64转换成功', res);
							if (res.tempFilePath) {
								uni.saveImageToPhotosAlbum({
									filePath: res.tempFilePath,
									success: () => {
										console.log('保存图片成功');
										uni.hideLoading();
										uni.showToast({
											title: '保存成功',
											icon: 'success'
										});
									},
									fail: (err) => {
										console.log('保存图片失败', err);
										uni.hideLoading();
										uni.showToast({
											title: '保存失败',
											icon: 'none'
										});
									}
								});
							} else {
								console.log('base64转换失败，无临时文件路径');
								uni.hideLoading();
								uni.showToast({
									title: '转换失败',
									icon: 'none'
								});
							}
						},
						fail: (err) => {
							console.log('base64转换失败', err);
							uni.hideLoading();
							uni.showToast({
								title: '转换失败',
								icon: 'none'
							});
						}
					});
				} else if (data.code.startsWith('_') || data.code.includes('temp') || data.code.includes('cache') || data
					.code.includes('_doc') || data.code.includes('_tmp')) {
					// 处理本地临时文件
					console.log('开始处理本地临时文件');
					uni.saveImageToPhotosAlbum({
						filePath: data.code,
						success: () => {
							console.log('保存本地文件成功');
							uni.hideLoading();
							uni.showToast({
								title: '保存成功',
								icon: 'success'
							});
						},
						fail: (err) => {
							console.log('保存本地文件失败', err);
							uni.hideLoading();
							uni.showToast({
								title: '保存失败',
								icon: 'none'
							});
						}
					});
				} else {
					// 处理网络图片
					console.log('开始处理网络图片');
					uni.downloadFile({
						url: data.code,
						success: (res) => {
							console.log('下载图片成功', res);
							if (res.statusCode === 200 && res.tempFilePath) {
								uni.saveImageToPhotosAlbum({
									filePath: res.tempFilePath,
									success: () => {
										console.log('保存图片成功');
										uni.hideLoading();
										uni.showToast({
											title: '保存成功',
											icon: 'success'
										});
									},
									fail: (err) => {
										console.log('保存图片失败', err);
										uni.hideLoading();
										uni.showToast({
											title: '保存失败',
											icon: 'none'
										});
									}
								});
							} else {
								console.log('下载图片失败，状态码:', res.statusCode);
								uni.hideLoading();
								uni.showToast({
									title: '下载失败',
									icon: 'none'
								});
							}
						},
						fail: (err) => {
							console.log('下载图片失败', err);
							uni.hideLoading();
							uni.showToast({
								title: '下载失败',
								icon: 'none'
							});
						}
					});
				}
			} catch (error) {
				console.log('保存图片异常', error);
				uni.hideLoading();
				uni.showToast({
					title: '保存失败',
					icon: 'none'
				});
			}
		} else {
			uni.showToast({
				title: '暂无图片可保存',
				icon: 'none'
			});
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #ededed;
	}

	.box {
		width: 750rpx;
		height: 500rpx;
		// background-image: url('/static/image/other/certificate/graduate/graduate1.png');
		background-repeat: no-repeat;
		background-size: 100% 100%;
		position: relative;

		.title {
			position: absolute;
			width: 288rpx;
			height: 36rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			left: 92rpx;
			top: 134rpx;

			image {
				height: 36rpx;
			}
		}

		.icon {
			position: absolute;
			width: 108rpx;
			height: 108rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			right: 82rpx;
			bottom: 124rpx;

			image {
				height: 108rpx;
			}
		}
	}

	@font-face {
		font-family: "card";
		src: url("/static/font/card.ttf");
	}

	* {
		box-sizing: content-box;
	}

	.aadadad {
		text-align: center;
	}

	.heiti {
		font-family: "SimHei", "Microsoft YaHei", sans-serif;
	}

	/* 弹窗样式 */
	.popup-overlay {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background-color: rgba(0, 0, 0, 0.5);
		display: flex;
		justify-content: center;
		align-items: center;
		z-index: 9999;
	}

	.popup-content {
		background-color: #fff;
		border-radius: 10px;
		width: 90%;
		max-width: 500px;
		max-height: 80vh;
		overflow-y: auto;
	}

	.popup-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 20rpx;
		border-bottom: 1rpx solid #eee;
	}

	.popup-title {
		font-size: 32rpx;
		font-weight: bold;
		color: #333;
	}

	.popup-close {
		font-size: 48rpx;
		color: #999;
		cursor: pointer;
	}

	.popup-body {
		padding: 20rpx;
	}

	.form-section {
		margin-bottom: 30rpx;
		padding: 20rpx;
		background-color: #f5f5f5;
		border-radius: 8rpx;
	}

	.section-title {
		font-size: 28rpx;
		font-weight: bold;
		color: #333;
		margin-bottom: 20rpx;
		display: block;
	}

	.form-row {
		display: flex;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.form-label {
		width: 200rpx;
		font-size: 26rpx;
		color: #333;
	}

	.form-input {
		flex: 1;
		padding: 15rpx;
		border: 1rpx solid #ddd;
		border-radius: 4rpx;
		font-size: 26rpx;
	}

	.form-separator {
		margin: 0 10rpx;
		font-size: 26rpx;
		color: #333;
	}

	.form-total {
		margin-top: 10rpx;
		padding-top: 10rpx;
		border-top: 1rpx dashed #ddd;
	}

	.form-total-input {
		background-color: #f9f9f9;
		color: #ff6b35;
		font-weight: bold;
	}

	/* 上传图片样式 */
	.upload-container {
		flex: 1;
		position: relative;
	}

	.upload-btn {
		width: 120rpx;
		height: 160rpx;
		border-radius: 8rpx;
		border: 1rpx dashed #ddd;
		display: flex;
		justify-content: center;
		align-items: center;
		background-color: #f5f5f5;
	}

	.upload-text {
		font-size: 22rpx;
		color: #999;
		text-align: center;
	}

	.upload-image {
		width: 98rpx;
		height: 115rpx;
		border-radius: 1rpx;
		object-fit: cover;
		border: 1px dashed #ddd;
	}

	.popup-footer {
		display: flex;
		justify-content: space-between;
		padding: 20rpx;
		border-top: 1rpx solid #eee;
	}

	.btn-cancel,
	.btn-save {
		width: calc(48% - 40rpx);
		padding: 20rpx;
		border-radius: 4rpx;
		font-size: 28rpx;
	}

	.btn-cancel {
		background-color: #f5f5f5;
		color: #333;
		// border: 1rpx solid #ddd;
	}

	.btn-save {
		background-color: #187AFF;
		color: #fff;
		border: none;

	}

	/* 保存图片按钮 */
	.button-container {
		display: flex;
		justify-content: center;
		padding: 30rpx 0;
	}

	.btn-save-image {
		background: linear-gradient(90deg, #187AFF 0%, #3295FC 100%);
		color: #fff;
		border: none;
		padding: 18rpx 60rpx;
		border-radius: 50rpx;
		font-size: 26rpx;
		font-weight: bold;
		box-shadow: 0 3rpx 10rpx rgba(7, 66, 193, 0.3);
		transition: all 0.3s ease;
		text-align: center;
		min-width: 160rpx;
	}

	.btn-save-image:hover {
		transform: translateY(-2rpx);
		box-shadow: 0 4rpx 12rpx rgba(7, 72, 193, 0.4);
	}

	.btn-save-image:active {
		transform: translateY(0);
		box-shadow: 0 2rpx 6rpx rgba(7, 140, 193, 0.3);
	}

	.footer-box {
		position: fixed;
		left: 0;
		bottom: 16px;
		width: 100vw;
		display: flex;
		justify-content: center;
		padding-bottom: constant(safe-area-inset-bottom); // 兼容 IOS<11.2
		padding-bottom: env(safe-area-inset-bottom); // 兼容 IOS>11.2
		.btn {
			font-size: 18px;
			color: #767676;
			
			width: 180rpx;
			height: 80rpx;
			line-height: 80rpx;
			background: #FFFFFF;
			border-radius: 8px 8px 8px 8px;
			background: #FFFFFF;
			text-align: center;
			margin: 0 24rpx;
			color: #767676;
			border: 2px solid #FFFFFF;
		}
		.active {
			color: #1777FF;
			border: 2px solid #1777FF;
		}
	}
</style>