<template>
	<NavBar />
	<view class="container">
		<view class="title">
			<PageTitle :title="$t('menu.partner')" />
		</view>
		<view>
			<uni-forms ref="identityForm" :modelValue="identityFormData" :rules="identityFormRules">
				<uni-forms-item name="voucher_name">
					<text class="uni-subtitle">{{ $t('form.fullName.label') }}</text>
					<uni-easyinput trim="all" primaryColor="#29BBE4" v-model="identityFormData.voucher_name"></uni-easyinput>
				</uni-forms-item>
				<view class="voucherTypeWrapper">
					<view :class="['voucherType', selectedVoucherType === 'SFZ' ? 'active' : '']" @click="selectVoucherType('SFZ')">
						<image src="/static/IDCard.png" mode="aspectFit" class="voucherIcon"></image>
						<text class="label">身份证</text>
					</view>
					<view :class="['voucherType', selectedVoucherType === 'HZ' ? 'active' : '']" @click="selectVoucherType('HZ')">
						<image src="/static/passport.png" mode="aspectFit" class="voucherIcon"></image>
						<text class="label">护照</text>
					</view>
				</view>
				<view class="voucherImgTitle">属性设置</view>
				<uni-forms-item name="name">
					<text class="uni-subtitle">推广链接自定义名称</text>
					<uni-easyinput trim="all" primaryColor="#29BBE4" v-model="identityFormData.name"></uni-easyinput>
				</uni-forms-item>
				<uni-forms-item name="share_type">
					<text class="uni-subtitle">账户类型选择（多选）</text>
					<uni-data-checkbox
						v-model="share_type"
						:localdata="shareMtTypeOptions"
						@change="handlePresetChange"
						selectedColor="#29BBE4"
						class="datePreset"
					></uni-data-checkbox>
				</uni-forms-item>

				<view class="normWrapper">
					<view class="normTitle">证件照片上传规范：</view>
					<view class="normContent">
						<view class="normColumn">
							<view class="normItem">
								<view class="point"></view>
								照片清晰
							</view>
							<view class="normItem">
								<view class="point"></view>
								照片高质
							</view>
						</view>
						<view class="normColumn">
							<view class="normItem">
								<view class="point"></view>
								细节清晰可见
							</view>
							<view class="normItem">
								<view class="point"></view>
								文件的四个角均可见
							</view>
						</view>
					</view>
				</view>
			</uni-forms>
		</view>
	</view>
</template>

<script>
import { getShareMtTypeList, saveShareRecord } from '@/services/partner/promotionLink.ts';
export default {
	data() {
		return {
			btnLoading: false,
			identityFormData: {},
			identityFormRules: {
				voucher_name: {
					rules: [
						{
							required: true,
							errorMessage: this.$t('form.fullName.required')
						}
					]
				}
			},
			shareMtTypeOptions: []
		};
	},
	methods: {
		async getShareMtTypes() {
			const res = await getShareMtTypeList();
			if (res && res.code === 0) {
				this.shareMtTypeOptions = res.data.map((item) => ({
					text: item.name,
					value: item.id
				}));
			}
		}
	},
	created() {
		this.getShareMtTypes();
	}
};
</script>

<style></style>
