<template>
	<view class="template-edit tn-safe-area-inset-bottom" style="background: #f7f7f7;min-height: 100vh;">
		<!-- 顶部自定义导航 -->
		<tn-nav-bar fixed customBack>
			<view slot="back" class='tn-custom-nav-bar__back' @click="goBack">
				<text class='icon tn-icon-left'></text>
			</view>
			
			<view slot="default"  style="display: flex;">
				<view style="flex:1;margin-left:25px">
					<text :style="{fontSize:(wxFontSize)+'px'}">发布需求</text>
				</view>
				<view>
					<button v-if="!canSave" :disabled="!canSave"  plain="true" style="margin-right: 4px;border-radius: 8px;height:32px;line-height: 32px;font-size:15px;margin-top:4px;color:#0003;border-color:#0003;" @click="saveForm(1)"  :style="{fontSize:(wxFontSize-3)+'px'}">暂存</button>
					<button v-if="canSave" plain="true" :disabled="!canSave" style="margin-right: 4px;border-radius: 8px;height:32px;line-height: 32px;font-size:15px;margin-top:4px;color:#1d60b1;border-color:#1d60b1;" @click="saveForm(1)" :style="{fontSize:(wxFontSize-3)+'px'}">暂存</button>
				</view>
			</view>
		</tn-nav-bar>

		<view class="tn-safe-area-inset-bottom" :style="{paddingTop: vuex_custom_bar_height + 'px'}">

			<view style="display: flex;padding: 16px 80px;">
				<view style="position: relative;">
					<image style="width: 48px;height: 48px;margin-right: 8px;" src="../static/tu/step1.png"></image>
					<view style="position: absolute;width: max-content;margin-left: -8px;" :style="{color:stepIndex==1?'#333':'#777'}">填写需求</view>
				</view>
				<view style="flex:1;height: 0px;border: 1px dashed #005DA6;align-self: center;" :style="{borderColor:stepIndex>1?'#005DA6':'#333'}"></view>
				<view style="position: relative;">
				<image v-if="stepIndex==1" style="width: 48px;height: 48px;margin-left: 8px;" src="../static/tu/step2.png"></image>
				<image v-if="stepIndex==2" style="width: 48px;height: 48px;margin-left: 8px;" src="../static/tu/step22.png"></image>
				<view style="position: absolute;width: max-content;margin-left: -25%;" :style="{color:stepIndex==1?'#777':'#333'}">填写联系方式</view>
				</view>
			</view>
			
			<!-- <tn-steps style="pointer-events:none;" :list="stepList" :current="stepIndex" mode="dotIcon" :fontSize="(wxFontSize-3)+'px'"></tn-steps>
			 -->
			<view v-show="stepIndex==1">
				<view style="margin-top: 24px;background: #e187301a;border-radius: 5px 5px 5px 5px;margin-left: 16px;margin-right: 16px;padding: 8px 0 7px 10px;">
					<image src="../static/tu/tip.png" style="width: 20px;height: 20px;vertical-align: bottom;"></image>
					<text style="color:#E18730">以下三种方式可任选其一，若有可都输入</text>
				</view>
				
			<!-- <view class="tn-flex tn-flex-row-between tn-flex-col-center tn-padding-top tn-margin">
				<view class="tn-flex justify-content-item">
					<view class="tn-text-lg tn-padding-right-xs tn-text-bold" style="font-size: 16px;" :style="{fontSize:(wxFontSize-1)+'px'}">以下三种方式可任选其一，若有可都输入</view>
				</view>
			</view> -->
			<view style="padding: 16px;color:#333;font-weight: bold;padding-bottom: 8px;"  :style="{fontSize:(wxFontSize-1)+'px'}">
				 需求
			</view>
			<view class="tn-margin tn-padding" style="border-radius: 10rpx;background: #fff;margin-top: 0;">
				<textarea maxlength="500" v-model="content" placeholder="请描述您的需求..." :style="{fontSize:(wxFontSize-3)+'px',width:'100%'}"  :placeholder-style="styleString"></textarea>
			</view>


			<view style="padding: 16px;color:#333;padding-top: 8px;padding-bottom: 8px;font-weight: bold;"  :style="{fontSize:(wxFontSize-1)+'px'}">
				 上传图片
			</view>
			<view class="tn-margin-left">
				<uni-file-picker
					v-model="imgList" :limit="6" @delete="deleteFile"  :auto-upload="false" @select="select" @success="success">
				</uni-file-picker>
				<view style="margin-top: 8px;">
					<image src="../static/tu/help.png" style="width: 16px;height: 16px;margin-right:4px;vertical-align: bottom;"></image>
					<text style="color: #aaa;font-size: 12px;" :style="{fontSize:(wxFontSize-5)+'px'}">一次只能上传<text style="color: #E18730;display: inline;">六张图片</text></text>
				</view>
			</view>
			<view style="padding: 16px;color:#333;font-weight: bold;padding-top: 24px;padding-bottom: 8px;"  :style="{fontSize:(wxFontSize-1)+'px'}">
				 上传文件
			</view>
			<!-- <view class="tn-flex tn-flex-row-between tn-flex-col-center tn-padding-top-xl tn-margin" style="margin-bottom: 0;">
				<view class="tn-flex justify-content-item">
					<view class=" tn-text-center"
						style="border-radius: 100rpx;margin-right: 8rpx;width: 45rpx;height: 45rpx;line-height: 45rpx;">
						<text class="tn-icon-link" style="font-size: 20px;" :style="{fontSize:(wxFontSize+3)+'px'}"></text>
					</view>
					<view class="tn-padding-right-xs tn-text-bold" style="font-size: 16px;" :style="{fontSize:(wxFontSize-1)+'px'}">上传文件</view>
				</view>
				 
			</view> -->
			
			<view style="background: #fff;margin-left: 16px;margin-right: 16px;padding: 12px;border-radius: 6px;">
				<uni-file-picker
					v-model="fileList" :limit="3" mode="grid" @delete="deleteFile"  file-mediatype="all" file-extname="pdf,docx,doc,xls,xlsx" :auto-upload="false" @select="select" @success="success">
				<!-- <button size="default">上传文件</button> -->
				<view style="text-align: left;">
					<button size="mini" style="color:#fff;background-color:#005DA6;border: none;" plain="true" :style="{fontSize:(wxFontSize-5)+'px'}">
						<image src="../static/tu/up.png" style="width: 20px;height: 20px;vertical-align: middle;margin-right: 4px;"></image>
						上传文件</button>
				</view>
				<!-- <tn-button shadow shape="round" fontColor="tn-color-white" size="lg" backgroundColor="tn-bg-blue" :fontSize="24" height="auto" padding="20rpx 36rpx">上传文件</tn-button>
				 -->
				</uni-file-picker>
				<view style="margin-top: 4px;">
					<text style="color: #999;font-size: 12px;" :style="{fontSize:(wxFontSize-5)+'px'}">一次只能上传<text style="color: #E18730;">三个</text>文件，支持格式<text style="color: #E18730;"> pdf .doc .xls</text>，不超过<text style="color: #E18730;">5MB</text>。</text>
				</view>
				
			
			</view>
			
			<view style="padding: 16px;padding-top:0">
				<view style="padding: 16px 0;color:#333;font-weight: bold;padding-bottom: 6px;"  :style="{fontSize:(wxFontSize-1)+'px'}">
					 需求有效期
				</view>
				 
				<uni-data-select
				    v-model="selectValue"
				    :localdata="selectList"
				    @change="changeSelect"
					placement="top"
					placeholder="请选择"
					:fontSize="(wxFontSize-3)+'px'"
				  ></uni-data-select>
			</view>
			

			<!-- 悬浮按钮-->
			<view class="tn-flex tn-footerfixed">
				<view class="tn-flex-1 justify-content-item tn-margin-sm tn-text-center">
					<button type="default" plain="true" style="border-radius: 8px 8px 8px 8px;background: #005DA6;color: #f7f7f7;border: none;" :disabled="!canNext"
						@click="nextStep()" :style="{fontSize:(wxFontSize-2)+'px'}">
						 下一步 
					</button>
				</view>
			</view>
</view>
<view v-show="stepIndex==2">
	
	<view style="padding:16px">
		<uni-forms :modelValue="formData" label-width="0">
			<view style="margin:16px 0" :style="{fontSize:(wxFontSize-3)+'px'}">
				<text style="color: red;line-height: 30px;vertical-align: middle;margin-right: 4px;" >*</text><text>公司名称:</text>
			<w-select
			     style="width: 100%;" 
			     v-model='searchValue' 
			     :list='items'
			     valueName='name' 
			     keyName="regNumber"
			     @change='selectChange'
				 :filterable="true"
				 :fontSize="(wxFontSize-3)+'px'"
			   >
			   </w-select>
			</view>
			<!-- <uni-forms-item label="公司名称" name="name">
				<uni-easyinput type="text" v-model="userInfo.company" placeholder="请输入所在公司名称" />
			</uni-forms-item> -->
			<text style="color: red;line-height: 30px;vertical-align: middle;margin-right: 4px;" :style="{fontSize:(wxFontSize-3)+'px'}">*</text><text :style="{fontSize:(wxFontSize-3)+'px'}">您的职务:</text>
			<uni-forms-item label="" name="realName" label-width="0">
				 <uni-easyinput type="text" v-model="formInfo.jobTitle" :inputSize="wxFontSize-3" :placeholder-style="styleString" :clearable="false" placeholder="请输入您的职务" />
			</uni-forms-item>
			<text style="color: red;line-height: 30px;vertical-align: middle;margin-right: 4px;" :style="{fontSize:(wxFontSize-3)+'px'}">*</text><text :style="{fontSize:(wxFontSize-3)+'px'}">联系人姓名:</text>
			<uni-forms-item label="联系人姓名" name="contactMethod">
				 <uni-easyinput type="text" v-model="formInfo.contactPerson" :inputSize="wxFontSize-3" :placeholder-style="styleString" :clearable="false" placeholder="请输入联系人姓名" />
			</uni-forms-item>
			<text style="color: red;line-height: 30px;vertical-align: middle;margin-right: 4px;" :style="{fontSize:(wxFontSize-3)+'px'}">*</text><text :style="{fontSize:(wxFontSize-3)+'px'}">联系方式:</text>
			<uni-forms-item label="联系方式" name="phone">
				 <uni-easyinput type="text"  v-model="formInfo.contactMethod" :inputSize="wxFontSize-3" :placeholder-style="styleString" :clearable="false" placeholder="请输入联系手机/微信/邮箱" />
			</uni-forms-item>
			 
			<uni-forms-item label="11" name="check">
				<tn-checkbox v-model="formInfo.agree" activeColor="#45c05d" :size="wxFontSize+17" name="选项1">
					<text :style="{fontSize:(wxFontSize-4)+'px',color:formInfo.agree?'#45c05d':'#666666'}">同意平台核查所填信息的真实性</text>
				</tn-checkbox>
				<!-- <text :style="{fontSize:(wxFontSize-4)+'px',color:'#888',paddingTop:'8px',display:'block'}">系统将短信通知您审核结果。如需关闭通知功能，请前往“我的”页面自行关闭</text> -->
			</uni-forms-item>
		</uni-forms>
	</view>
	
	<view class="tn-flex tn-footerfixed">
		<view class="tn-flex-1 justify-content-item tn-margin-sm tn-text-center">
			<button type="default" plain="true" style="border-radius: 8px;"
				@click="preStep()" :disabled="!canSave" :style="{fontSize:(wxFontSize-2)+'px'}">
				 上一步 
			</button>
		</view>
		<view class="tn-flex-1 justify-content-item tn-margin-sm tn-text-center">
			<button v-if="canSave&&canNext" type="primary" style="background-color:#1d60b1;border-radius: 8px" @click="saveForm()" :style="{fontSize:(wxFontSize-2)+'px'}">提交审核</button>
			<button v-if="!canSave||!canNext" type="primary" :disabled="!canSave||!canNext" style="background-color:#0003;border-radius: 8px" @click="saveForm()" :style="{fontSize:(wxFontSize-2)+'px'}">提交审核</button>
		</view>
	</view>
</view>
		</view>
		
		

		<view class='tn-tabbar-height'></view>

	</view>
</template>

<script>
	import template_page_mixin from '@/libs/mixin/template_page_mixin.js';
	import request from '../utils/request';
	export default {
		name: 'TemplateEdit',
		mixins: [template_page_mixin],
		data() {
			return {
				wxFontSize:17,
				canSave: true,
				selectValue: '',
				//非常紧急/两周/一月/长期
				selectList: [{
						value: '一周',
						text: '一周'
					},
					{
						value: '两周',
						text: '两周'
					},
					{
						value: '一月',
						text: '一月'
					}
				],
				content:'',
				formInfo:{
					jobTitle:'',
					agree:false,
					contactPerson:JSON.parse(uni.getStorageSync('userInfo')).contactNickName,
					contactMethod:JSON.parse(uni.getStorageSync('userInfo')).contactMethod||JSON.parse(uni.getStorageSync('userInfo')).userName
				},
				imgList:[],
				fileDetailList:[],
				stepIndex:1,
				stepList: [{
						name: '填写需求',
						icon: 'circle',
						selectIcon: 'circle-fill'
					},
					{
						name: '填写联系方式',
						icon: 'trusty',
						selectIcon: 'trusty-fill'
					}
				],
				formData: {
					apiType: 'this,ali',
					token: 'dffc1e06e636cff0fdf7d877b6ae6a2e',
					image: null
				},
				fileList: [],
				showUploadList: true,
				customBtn: false,
				autoUpload: true,
				showProgress: false,
				deleteable: true,
				customStyle: false,
				maxCount: 9,
				disabled: false,
				searchValue: '',
				items: [],
				org:{
					name:'',
					regNumber:''
				},
				editItem:{},
				styleString:'font-size:'+14+'px',
				canNext:true
			}
		},
		watch: {
			searchValue(val, oldval) {
				console.error(val,this.org.name);
				if(val!==this.org.name){
					this.current = null;
				}
				if(this.stepIndex==2){
					this.search(val)
				}
				
			}
		},
		onLoad(props) {
			const appBaseInfo = wx.getAppBaseInfo();
			this.wxFontSize = uni.getStorageSync('fontSize')||appBaseInfo.fontSizeSetting||17;
			this.styleString='font-size:'+(this.wxFontSize-3)+'px';
			if(props.sid){
				this.isEdit = true;
				this.editItem = JSON.parse(uni.getStorageSync(props.sid)||'{}');
				this.content = this.editItem.content;
				this.fileDetailList = this.editItem.fileDetailList;
				
				for(let i=0;i<this.fileDetailList.length;i++){
					this.fileDetailList[i].path = this.fileDetailList[i].ftpUrl
					if(this.isImage(this.fileDetailList[i].fileName)){
						this.imgList.push({
							name: this.fileDetailList[i].fileName,
							url: this.fileDetailList[i].ftpUrl,
							path: this.fileDetailList[i].path
						})
					}else{
						this.fileList.push({
							name: this.fileDetailList[i].fileName,
							url: this.fileDetailList[i].ftpUrl,
							path: this.fileDetailList[i].path
						})
					}
				}
				
				this.org.name = this.editItem.company;
				this.formInfo.jobTitle = this.editItem.jobTitle;
				this.formInfo.contactPerson = this.editItem.contactPerson;
				this.formInfo.contactMethod = this.editItem.contactMethod;
			}
			this.getCompany();
		},
		methods: {
			 isImage(fileName) {
				const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'ico']
				const extension = fileName.split('.').pop().toLowerCase();
				return imageExtensions.includes(extension);
			 },
			 getCompany(){
			 	let that = this;
			 		request.post('/slbUserCompanyRel/show/my', {
			 			userNo: uni.getStorageSync('userNo')
			 		}).then(res => {
			 			if (res.success) {
			 				let list = res.list || [];
			 				for(let i=0;i<list.length;i++){
			 					list[i].name = list[i].company;
			 					list[i].regNumber= list[i].company;
								if(!that.isEdit&&list[i].isDefault=='1'){
									that.searchValue = list[i].name
									that.current = list[i].name;
									that.org = list[i];
									if(list[i].jobTitle){
										that.formInfo.jobTitle = list[i].jobTitle
										
									}
									if(list[i].contactPerson){
										that.formInfo.contactPerson = list[i].contactPerson
									}
									if(list[i].contactMethod){
										that.formInfo.contactMethod = list[i].contactMethod;
									}
									
									that.getAddress(list[i].name);
								}
								if(that.isEdit&&list[i].name==that.editItem.company){
									that.searchValue = list[i].name
									that.current = list[i].name;
									that.formInfo.jobTitle = list[i].jobTitle;
									that.formInfo.contactPerson = list[i].contactPerson;
									that.formInfo.contactMethod = list[i].contactMethod;
									that.org = list[i];
									
									that.getAddress(list[i].name);
								}
			 					 
			 				}
			 				that.items = list;
			 			}else{
							if(res._redirect){
								uni.showToast({
									title: '操作过期，请重试',
									duration: 2000,
									icon:'none'
								});
								that.goBack();
							}
						}
			 		})
			},
			preStep(){
				this.stepIndex = 1;
			},
			nextStep(){
				console.warn(this.searchValue);
				if(this.content==''&&this.fileDetailList.length===0){
					 uni.showToast({
						title:'请输入您的需求或上传图片/文件',
						icon:'none'
					 })
					 this.stepIndex = 1;
					 
					 return false;
				}
				 
				this.stepIndex = 2;
			},
			
			changeSelect(e) {
			        this.selectValue = e;
			},
			saveForm(status){
				if(!this.canSave){
					return false;
				}
				let that = this;
				let params = {
					
				};
				
				if(status!=1&&!this.org.name){
					uni.showToast({
						title: '请输入公司名称',
						duration: 2000,
						icon:'none'
					});
					return false;
				}
				
				
				
				if(status!=1&&this.formInfo.jobTitle.length<1){
					uni.showToast({
						title: '请输入您的职称',
						duration: 2000,
						icon:'none'
					});
					return false;
				}
				if(status!=1&&this.formInfo.contactPerson.length<1){
					uni.showToast({
						title: '请输入联系人姓名',
						duration: 2000,
						icon:'none'
					});
					return false;
				}
				if(status!=1&&this.formInfo.contactMethod.length<1){
					uni.showToast({
						title: '请输入联系方式',
						duration: 2000,
						icon:'none'
					});
					return false;
				}
				
				if(status!=1&&!this.formInfo.agree){
					uni.showToast({
						title: '请勾选同意平台核查所填信息的真实性',
						duration: 2000,
						icon:'none'
					});
					return false;
				}
				
				if(!that.canNext){
					uni.showToast({
						title: '照片/文件正在上传中，请耐心等待',
						duration: 2000,
						icon:'none'
					});
					return false;
				}
				
				uni.showToast({
					title: '提交中...',
					icon:'none'
				});
				
				that.canSave = false;
				
				params.slbResourceDemand = {
					type:'3',
					company:this.org.name,
 					jobTitle:this.formInfo.jobTitle,
					contactPerson:this.formInfo.contactPerson,
					contactMethod:this.formInfo.contactMethod,
					content:that.content,
					userNo:uni.getStorageSync('userNo'),
					validDate:this.selectValue,
					status: status==1?status:4,
					showFlag:'是',
					id: that.isEdit?that.editItem.id:undefined,
					bisNo: that.isEdit?that.editItem.bisNo:undefined,
					version: that.isEdit?that.editItem.version:undefined,
					createTime: that.isEdit?that.editItem.createTime:undefined
				};
				
				params.slbResourceDemand.companyEntity = {};
				params.slbResourceDemand.companyEntity.company = params.slbResourceDemand.company;
				params.slbResourceDemand.companyEntity.jobTitle = params.slbResourceDemand.jobTitle;
				params.slbResourceDemand.companyEntity.creditCode = this.org.creditCode;
				params.slbResourceDemand.companyEntity.address = this.org.base;
				params.slbResourceDemand.companyEntity.regStatus = this.org.regStatus;
				
				params.slbResourceDemand.companyEntity.contactPerson = params.slbResourceDemand.contactPerson;
				params.slbResourceDemand.companyEntity.contactMethod = params.slbResourceDemand.contactMethod;
				
				params.slbResourceDemand.slbUserExt = {
						contactPerson:params.slbResourceDemand.contactPerson,
						contactMethod:params.slbResourceDemand.contactMethod,
						userNo:uni.getStorageSync('userNo'),
				};
				
				params.slbResourceDemand = JSON.stringify(params.slbResourceDemand);
				
				
				// params.slbResourceDemand.companyEntity.contactNickName = params.slbResourceDemand.contactNickName;
				// params.slbUserExt = JSON.stringify({
				// 	jobTitle:this.formInfo.jobTitle,
				// 	contactPerson:this.formInfo.contactPerson,
				// 	contactMethod:this.formInfo.contactMethod,
				// 	userNo:uni.getStorageSync('userNo'),
				// });
				
				params.fileDetailList = JSON.stringify(this.fileDetailList);
				request.post(that.isEdit?'/slbResourceDemand/update':'/slbResourceDemand/add', params).then(res => {
				    
					if(res.success){
						uni.showToast({
							title:status==1?'信息已暂存，请在我的需求中查看暂存信息':'发布已提交，请在我的需求中查看进度',
							icon:'none',
							success:()=>{
								setTimeout(()=>{
									
									uni.redirectTo({
									 url: "/pages/mine/need?tab="+(status==1?2:0)
									});
									 
								},1500)
								
							}
						})
					}else{
						uni.showToast({
							title:res.msg,
							icon:'none'
						})
						that.canSave = true;
					}
					console.warn(res);
				})
			},
			// 跳转
			tn(e) {
				uni.navigateTo({
					url: e,
				});
			},
			// 手动上传文件
			upload() {
				console.warn(121212);
			},
			// 手动清空列表
			clear() {
				this.$refs.imageUpload.clear()
			},
			// 图片拖拽重新排序
			onSortList(list) {
				console.log(list);
			},
			select(e) {
				console.log('选择文件：', e)
				let tempFiles = e.tempFiles;
				for (let i in tempFiles) {
					this.upfile(tempFiles[i])
				}
			},
			deleteFile(e, index) {
				if(!this.canNext){
					uni.showToast({
						title: '照片/文件正在上传中，请耐心等待',
						icon:'none'
					});
					return false;
				}
				for(let i=0;i<this.fileDetailList.length;i++){
					if(e.tempFile.path===this.fileDetailList[i].path){
						this.fileDetailList.splice(i, 1);
					}
				}
			},
			upfile(file) {
				let that = this;
				console.warn(file);
				this.canNext = false;
				uni.showToast({
					title: '照片/文件正在上传中，请耐心等待',
					icon:'none'
				});
				uni.uploadFile({
					url: 'https://slb-mstg.lx-device.com/oss/upload/userFeedback', //仅为示例，非真实的接口地址
					filePath: file.url,
					name: 'file',
					success: (uploadFileRes) => {
						that.canNext = true;
						uni.hideToast();
						console.warn(JSON.parse(uploadFileRes.data));
						if(JSON.parse(uploadFileRes.data).success){
							let resultMap = JSON.parse(uploadFileRes.data).resultMap;
							that.fileDetailList.push({
								name: file.name,
								fileName: file.name, // 原始文件名
								ftpUrl: resultMap.uploadUrl, // 文件访问url
								path: file.path
							})
						}else{
							uni.showToast({
								title: JSON.parse(uploadFileRes.data).msg+'，请删除后重试',
								icon:'none'
							});
						}
					},
					fail:(err)=>{
						 uni.showToast({
						 	title: '上传失败，请删除后重试',
						 	icon:'none'
						 });
					}
				});
			},
			// 上传成功
			success(e) {
				console.log('上传成功')
			},
			 
			selectChange(e){
				console.error(e);
				this.searchValue = e.name
				this.current = e.regNumber;
				if(e.jobTitle){
					this.formInfo.jobTitle = e.jobTitle;
				}
				this.org = e;
				this.getAddress(e.name);
			},
			getAddress(name){
				let that = this;
				request.post('/member/getEnterPriseInfo', {
					keyWord:  name
				}).then(res => {
					if(res&&res.success&&res.resultMap.data){
					  if( res.resultMap.data.creditCode){
					  	 that.org.creditCode = res.resultMap.data.creditCode
					  }
					  if( res.resultMap.data.regStatus){
					  	 that.org.regStatus = res.resultMap.data.regStatus
					  }
					  if( res.resultMap.data.regLocation){
						 that.org.base = res.resultMap.data.regLocation
					  }
					}
				})
			},
			search: function(val) {
				let that = this;
				
				if (val && val.length > 3) {
					request.post('/member/searchCompys', {
						keyWord:  val
					}).then(res => {
						if(res&&res.success){
							let list = res.resultMap.data || [];
							that.items = list;
						}else{
							if(res._redirect){
								uni.showToast({
									title: '操作过期，请重试',
									duration: 2000,
									icon:'none'
								});
								that.goBack();
							}
						} 
					})
				}else{
					that.items = [];
					that.org = {}; 
				}
			},
			goBack() {
				const pages = getCurrentPages()
				// 有可返回的页面则直接返回，uni.navigateBack 默认返回失败之后会自动刷新页面 ，无法继续返回
				if (pages.length > 1) {
					uni.navigateBack()
					return;
				}else{
					uni.reLaunch({
						url: '/pages/index/index'
					})
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.template-edit {}

	/* 胶囊*/
	.tn-custom-nav-bar__back {
		width: 60%;
		height: 100%;
		position: relative;
		display: flex;
		justify-content: space-evenly;
		align-items: center;
		box-sizing: border-box;
		// background-color: rgba(0, 0, 0, 0.15);
		border-radius: 1000rpx;
		border: 1rpx solid rgba(255, 255, 255, 0.5);
		// color: #FFFFFF;
		font-size: 18px;

		.icon {
			display: block;
			flex: 1;
			margin: auto;
			text-align: center;
		}

		&:before {
			content: " ";
			width: 1rpx;
			height: 110%;
			position: absolute;
			top: 22.5%;
			left: 0;
			right: 0;
			margin: auto;
			transform: scale(0.5);
			transform-origin: 0 0;
			pointer-events: none;
			box-sizing: border-box;
			opacity: 0.7;
			background-color: #FFFFFF;
		}
	}

	/* 底部悬浮按钮 start*/
	.tn-tabbar-height {
		min-height: 100rpx;
		height: calc(120rpx + env(safe-area-inset-bottom) / 2);
	}

	.tn-footerfixed {
		position: fixed;
		width: 100%;
		bottom: calc(env(safe-area-inset-bottom));
		z-index: 1024;
		box-shadow: 0 1rpx 6rpx rgba(0, 0, 0, 0);
		background: #f7f7f7;
	}

	/* 底部悬浮按钮 end*/

	/* 标签内容 start*/
	.tn-tag-content {
		&__item {
			display: inline-block;
			line-height: 45rpx;
			padding: 10rpx 30rpx;
			margin: 20rpx 20rpx 5rpx 0rpx;

			&--prefix {
				padding-right: 10rpx;
			}
		}
	}
	
	/deep/ .uni-forms-item__label {
		display: none;
	}
	/deep/ .uni-stat__select .uni-select__input-placeholder {
		font-size: 14px;
	}

	/* 标签内容 end*/
</style>