<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>
		</tn-nav-bar>

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

			 
			<!-- <tn-steps style="pointer-events:none;" :list="selectValue=='个人'?stepList:stepList2" :current="stepIndex" mode="dotIcon" :fontSize="(wxFontSize-3)+'px'"></tn-steps> -->
			<view v-show="stepIndex==1">

				<view style="padding: 16px;padding-bottom: 0;font-weight: 600;">
					<view style="line-height: 30px;" :style="{fontSize:(wxFontSize-1)+'px'}">
						发布主体：
						<uni-data-checkbox :multiple="false" v-model="selectValue" selectedColor="#01BEFF"
							:localdata="[{text: '个人',value: '个人'},{text: '公司',value: '公司'}]" :fontSize="(wxFontSize-3)+'px'"/>
					</view>
					<!-- <uni-data-select v-model="selectValue" :localdata="selectList" @change="changeSelect"
						:clear="false"></uni-data-select> -->
				</view>
				
				<view v-if="selectValue=='个人'" style="padding: 16px">
					<uni-forms :modelValue="formData" label-width="0">

						<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" disabled :inputSize="wxFontSize-3" :placeholder-style="styleString" v-model="formInfo.contactNickName" placeholder="请输入您的昵称" />
						</uni-forms-item>
						<text style="line-height: 30px;vertical-align: middle;" :style="{fontSize:(wxFontSize-3)+'px'}">真实姓名:</text>
						<uni-forms-item label="真实姓名" name="contactMethod">
							<uni-easyinput type="text" disabled="true" :inputSize="wxFontSize-3" :placeholder-style="styleString" v-model="formInfo.userRealName" 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" disabled :inputSize="wxFontSize-3" :placeholder-style="styleString" v-model="formInfo.contactMethod" placeholder="请输入联系手机/微信/邮箱" />
						</uni-forms-item>

					</uni-forms>
					<text style="font-size: 13px;color:#999;" :style="{fontSize:(wxFontSize-4)+'px'}">如要更改个人信息,请在<text style="color: #E18730;">“我的”=>个人信息</text>页面更改</text>
				</view>

				<view v-if="selectValue=='公司'" style="padding: 16px">
					<uni-forms :modelValue="formData" label-width="0">
						<view style="margin-bottom:16px">
							<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>
							<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" :clearable="false" :inputSize="wxFontSize-3" :placeholder-style="styleString" v-model="formInfo.jobTitle" 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" :clearable="false" :inputSize="wxFontSize-3" :placeholder-style="styleString" v-model="formInfo.contactPerson" 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" :clearable="false" :inputSize="wxFontSize-3" :placeholder-style="styleString" v-model="formInfo.contactMethod" placeholder="请输入联系手机/微信/邮箱" />
						</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 8px 8px 8px;background: #005DA6;color: #f7f7f7;border: none;"
							@click="nextStep()" :style="{fontSize:(wxFontSize-2)+'px'}">
							 下一步 
						</button>
					</view>
				</view>
			</view>
			<view v-show="stepIndex!=1">

				<!-- <view style="padding: 16px;padding-bottom: 0;" v-if="(selectValue=='公司'&&stepIndex==2)||(selectValue=='个人'&&stepIndex==2)">
					
					<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-data-select v-model="selectValue2" :localdata="selectList2" @change="changeSelect2"
						:clear="false" :fontSize="(wxFontSize-3)+'px'"></uni-data-select>
				</view> -->

				<view v-if="selectValue2=='产品'" >
					<view style="padding: 16px" v-if="(selectValue=='公司'&&stepIndex==2)||(selectValue=='个人'&&stepIndex==2)">
						
						<!-- <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-data-select v-model="selectValue4" :localdata="selectList4" @change="changeSelect4"
							placeholder="产品种类" :clear="false" style="margin-bottom:16px" :fontSize="(wxFontSize-3)+'px'"></uni-data-select>
						 -->
						<view>
						    <text style="line-height: 30px;" :style="{fontSize:(wxFontSize-3)+'px'}">设备名称:</text>
						    <uni-easyinput type="text" :clearable="false" :inputSize="wxFontSize-3" :placeholder-style="styleString" required disabled v-model="deviceName" placeholder="请输入设备名称" />
						</view>
						
						<view style="margin-top: 16px;">
						  <text  style="line-height: 30px;" :style="{fontSize:(wxFontSize-3)+'px'}">设备编号:</text>
						   <uni-easyinput type="text" :clearable="false" :inputSize="wxFontSize-3" :placeholder-style="styleString" required disabled v-model="deviceId" placeholder="请输入设备编号" />
						</view>
						
						<view style="margin-top: 16px;">
						   <text style="line-height: 30px;" :style="{fontSize:(wxFontSize-3)+'px'}">设备型号:</text>
						   <uni-easyinput type="text" :clearable="false" :inputSize="wxFontSize-3" :placeholder-style="styleString" required disabled v-model="deviceModel" placeholder="请输入设备型号" />
						</view>
						
						<view style="margin-top: 16px;">
							<text style="line-height: 30px;" :style="{fontSize:(wxFontSize-3)+'px'}">设备状态:</text>
							<uni-data-select v-model="selectValue4" :localdata="selectList4" @change="changeSelect4"
								placeholder="设备状态" :clear="false" style="margin-bottom:16px" disabled :fontSize="(wxFontSize-3)+'px'"></uni-data-select>
						</view>
						
						<view style="margin-top: 16px;margin-bottom: 20px;">
							<text style="line-height: 30px;" :style="{fontSize:(wxFontSize-3)+'px'}">发布设备是否属于特种设备？</text>
							<uni-data-checkbox :multiple="false" v-model="isMedical" selectedColor="#01BEFF"
								:localdata="[{text: '是',value: '1'},{text: '否',value: '0'}]" disabled :fontSize="(wxFontSize-3)+'px'"/>
							<!-- <text v-if="isMedical==1" style="font-size: 13px;color:#999;color: #E18730;" :style="{fontSize:(wxFontSize-5)+'px'}">如若产品是医疗器械，请在上传附件步骤上传产品注册证，企业经营许可证等相关信息。</text> -->
						</view>
						
						<view style="margin-top: 16px;">
						    <text style="line-height: 30px;" :style="{fontSize:(wxFontSize-3)+'px'}">制造厂家:</text>
						    <uni-easyinput type="text" :clearable="false" :inputSize="wxFontSize-3" disabled :placeholder-style="styleString" required v-model="manufacturer" placeholder="请输入制造厂家" />
						</view>
						
						<view style="margin-top: 16px;">
							<text style="line-height: 30px;" :style="{fontSize:(wxFontSize-3)+'px'}">设备类别:</text>
							<uni-data-select v-model="deviceCategory" :localdata="[{value: '关键设备',text: '关键设备'},{value: '非关键设备',text: '非关键设备'}]" @change="changeSelect5"
								placeholder="设备类别" :clear="false" style="margin-bottom:16px" disabled :fontSize="(wxFontSize-3)+'px'"></uni-data-select>
						</view>
						
						
						
						<view style="margin-top: 16px;">
						    <text style="line-height: 30px;" :style="{fontSize:(wxFontSize-3)+'px'}">设备设计能力:</text>
						    <uni-easyinput type="text" :clearable="false" :inputSize="wxFontSize-3" disabled :placeholder-style="styleString" required v-model="designCapacity" placeholder="请输入设备设计能力" />
						</view>
						
						<view style="margin-top: 16px;">
						    <text style="line-height: 30px;" :style="{fontSize:(wxFontSize-3)+'px'}">主体材质:</text>
						    <uni-easyinput type="text" :clearable="false" :inputSize="wxFontSize-3" disabled :placeholder-style="styleString" required v-model="mainMaterial" placeholder="请输入主体材质" />
						</view>
						
						
						
						<view style="margin-top: 16px;">
							<text style="line-height: 30px;" :style="{fontSize:(wxFontSize-3)+'px'}">计量单位:</text>
							<uni-data-select v-model="measurementUnit" :localdata="[{value: '个',text: '个'},{value: '台',text: '台'},{value: '其他',text: '其他'}]" @change="changeSelect6"
								placeholder=" " :clear="false" style="margin-bottom:16px" disabled :fontSize="(wxFontSize-3)+'px'"></uni-data-select>
						</view>

						 <view style="margin-top: 16px;">
							<text style="line-height: 30px;" :style="{fontSize:(wxFontSize-3)+'px'}">启用日期:</text>
							 
							<uni-datetime-picker
											type="date"
											:value="startDate"
											 disabled
											@change="bindDateChange"
										/>
						 </view>
 
						<view style="margin-top: 16px;">
							<text style="line-height: 30px;" :style="{fontSize:(wxFontSize-3)+'px'}">安装(存放）地点:</text>
							<uni-easyinput maxlength="100" :inputSize="wxFontSize-4" :placeholder-style="styleString" disabled type="textarea" v-model="installationLocation" placeholder=" " />
						</view>
						
						
						
						<view style="margin-top: 16px;">
						    <text style="line-height: 30px;" :style="{fontSize:(wxFontSize-3)+'px'}">资产原值(元):</text>
						    <uni-easyinput type="number" :clearable="false" :inputSize="wxFontSize-3" disabled :placeholder-style="styleString" required v-model="originalValue" placeholder=" " />
						</view>
						
						<view style="margin-top: 16px;">
						    <text style="line-height: 30px;" :style="{fontSize:(wxFontSize-3)+'px'}">月折旧(元):</text>
						    <uni-easyinput type="number" :clearable="false" :inputSize="wxFontSize-3" disabled :placeholder-style="styleString" required v-model="monthlyDepreciation" placeholder=" " />
						</view>
						
						<view style="margin-top: 16px;">
						    <text style="line-height: 30px;" :style="{fontSize:(wxFontSize-3)+'px'}">设备净值(元):</text>
						    <uni-easyinput type="number" :clearable="false" :inputSize="wxFontSize-3" disabled :placeholder-style="styleString" required v-model="netValue" placeholder=" " />
						</view>
						
						<view style="margin-top: 16px;">
						    <text style="line-height: 30px;" :style="{fontSize:(wxFontSize-3)+'px'}">净残值(元):</text>
						    <uni-easyinput type="number" :clearable="false" :inputSize="wxFontSize-3" disabled :placeholder-style="styleString" required v-model="residualValue" placeholder=" " />
						</view>
						
						
						
						<view style="margin-top: 16px;">
						<text style="line-height: 30px;vertical-align: middle;" :style="{fontSize:(wxFontSize-4)+'px'}">备注:</text>
							<uni-easyinput maxlength="500" :inputSize="wxFontSize-4" disabled :placeholder-style="styleString" type="textarea" v-model="remark" placeholder=" " />
						</view>
						
						
						<view class="tn-flex tn-flex-row-between tn-flex-col-center  tn-margin" style="margin-bottom: 0;margin-left:0" v-if="imgList&&imgList.length>0">
							<view style="padding: 16px 0;padding-bottom:8px; color:#333;font-weight: 600;"  :style="{fontSize:(wxFontSize-1)+'px'}">
								 图片
							</view> 
							 
						</view>
						<block v-if="imgList&&imgList.length>0">
										<view v-if="[1,2,4].indexOf(imgList.length) != -1" class="tn-padding-top-xs">
											<image v-for="(image_item,image_index) in imgList" :key="image_index"
												class="blogger__main-image" :class="{
						  'blogger__main-image--1 tn-margin-bottom-sm': imgList.length === 1,
						  'blogger__main-image--2 tn-margin-right-sm tn-margin-bottom-sm': imgList.length === 2 || imgList.length === 4
						}" :src="image_item.url" mode="aspectFill" @click="showImg(imgList,image_index)"></image>
										</view>
										<view v-else class="tn-padding-top-xs" @click="tn('')">
											<tn-grid hoverClass="none" :col="3">
												<block v-for="(image_item,image_index) in imgList" :key="image_index">
													<!-- #ifndef MP-WEIXIN -->
													<tn-grid-item style="width: 30%;margin: 10rpx;">
														<image class="blogger__main-image blogger__main-image--3"
															:src="image_item.url" mode="aspectFill" @click="showImg(imgList,image_index)"></image>
													</tn-grid-item>
													<!-- #endif-->
													<!-- #ifdef MP-WEIXIN -->
													<tn-grid-item style="width: 30%;margin: 10rpx;">
														<image class="blogger__main-image blogger__main-image--3"
															:src="image_item.url" mode="aspectFill" @click="showImg(imgList,image_index)"></image>
													</tn-grid-item>
													<!-- #endif-->
												</block>
											</tn-grid>
										</view>
									</block>
						
						<view class="tn-flex tn-flex-row-between tn-flex-col-center  tn-margin" style="margin-bottom: 0;margin-left:0" v-if="fileList&&fileList.length>0">
							<view style="padding: 16px 0;padding-bottom:8px; color:#333;font-weight: 600;"  :style="{fontSize:(wxFontSize-1)+'px'}">
								 文件
							</view> 
							 
						</view>
									
									<view v-for="(file,fIndex) in fileDetailList" :style="{marginTop:imgList&&imgList.length==0&&fIndex==0?'8px':'0'}" style="background-color:#005da60d ;margin-bottom: 4px;padding: 4px 8px;border-radius: 4px;" :key="file.id" v-if="!isImage(file.fileName)"  @click="clickLink(file.ftpUrl,file.fileName)">
										<view>
											<image src="../static/tu/link.png" style="width: 18px;height: 18px;vertical-align: bottom;"></image>
											<view style="display: inline;margin-left:8px;color:#005DA6;" :style="{fontSize:(wxFontSize-3)+'px'}">
												{{file.fileName}}</view>
										</view>
									</view>
 
 
						<!-- <view v-for="item,itemIndex in extList">
							<view style="margin-bottom: 12px;">
							 
							</view>
							 

						</view> -->


					</view>

				</view>
				<view v-if="selectValue2=='服务'&&stepIndex==2">
					<view style="padding: 16px">
						<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-data-select v-model="selectValue3" :localdata="selectList3" @change="changeSelect3"
							:clear="false" :fontSize="(wxFontSize-3)+'px'"></uni-data-select>
					</view>
				</view>
				
				<view v-if="selectValue2=='服务'&&stepIndex==2">
					<view style="padding: 0 16px 16px 16px">
					   <text style="line-height: 30px;vertical-align: middle;" :style="{fontSize:(wxFontSize-3)+'px'}">服务品牌:</text>
					   <uni-easyinput type="text" :clearable="false" :inputSize="wxFontSize-3" :placeholder-style="styleString" v-model="brand" placeholder="请输入服务品牌" />
					</view>
				</view>
					
				<view>
 
					 <view v-if="selectValue2=='服务'&&stepIndex==2" style="padding: 16px;padding-bottom: 0;margin-bottom: -16px;">
					    <text style="color: red;line-height: 30px;vertical-align: middle;margin-right: 4px;">*</text><text>服务介绍:</text>
					 </view>
					<view v-if="selectValue2=='服务'&&stepIndex==2" class="tn-margin tn-padding"
						style="border-radius: 10rpx;background: #fff;">
						
						<textarea maxlength="500" v-model="content" placeholder="请输入服务介绍"
							placeholder-style="color:#AAAAAA" :style="{fontSize:(wxFontSize-3)+'px',width:'100%'}" :placeholder-style="styleString"></textarea>
					</view>

					<view class="tn-flex tn-flex-row-between tn-flex-col-center  tn-margin" style="margin-bottom: 0;" v-if="stepIndex==3">
						<view style="padding: 16px 0;padding-bottom:8px; color:#333;font-weight: 600;"  :style="{fontSize:(wxFontSize-1)+'px'}">
							 上传图片（选填）
						</view> 
						 
					</view>

					<view class="tn-margin-left"  v-show="stepIndex==3">
						<uni-file-picker v-model="imgList" :limit="6" :auto-upload="false" @select="select"
							@success="success" @delete="deleteFile">


						</uni-file-picker>
						<view style="margin-top: 8px;">
							<text style="color: #999;font-size: 12px;" :style="{fontSize:(wxFontSize-5)+'px'}">一次只能上传<text style="color: #E18730;display: inline;">六张图片</text></text>
						</view>
						 

					</view>

					<view class="tn-flex tn-flex-row-between tn-flex-col-center tn-margin" style="margin-top:0;margin-bottom: 0;" v-if="stepIndex==3">
						 
						<view style="padding: 16px 0;padding-top:24px;padding-bottom:8px;color:#333;font-weight: 600;"  :style="{fontSize:(wxFontSize-1)+'px'}">
							 上传相关文件（选填）
						</view> 
						 
					</view>

					<view class="tn-margin-left" style="background: #fff;margin-left: 16px;margin-right: 16px;padding: 12px;border-radius: 6px;" v-show="stepIndex==3">
						<uni-file-picker v-model="fileList" :limit="3" mode="grid" file-mediatype="all"
							file-extname="pdf,docx,doc,xls,xlsx" :auto-upload="false" @select="select" @success="success" @delete="deleteFile">
							<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 style="text-align: left;">
								<button size="mini" style="color:#1d60b1;border-color:#1d60b1;display: inline-block;" plain="true"  :style="{fontSize:(wxFontSize-5)+'px'}">上传文件</button>
							</view>
							
						
						</uni-file-picker>
						<view style="margin-top: 4px;">
							<text style="color: #999;font-size: 12px;" :style="{fontSize:(wxFontSize-5)+'px'}">一次只能上传三个文件，支持格式 pdf .doc .xls，不超过5MB。</text>
						</view> -->
						 
						 
						<view style="margin-top:6px" v-if="selectValue2=='产品'">
							<text style="color: #999;font-size: 12px;color:#E18730;" :style="{fontSize:(wxFontSize-5)+'px'}">如若产品属于特种设备，请上传相关资质证明。</text>
						</view>
						 

					</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,
				styleString:'font-size:'+14+'px',
				showTips:false,
				canSave:true,
				isMedical: '1',
				
				deviceName: '',
				deviceId: '',
				deviceModel: '',
				deviceCategory: '关键设备',
				
				content: '',
				selectValue: '个人',
				selectList: [{
						value: '个人',
						text: '个人'
					},
					{
						value: '公司',
						text: '公司'
					}
				],
				selectValue2: '产品',
				selectList2: [{
						value: '产品',
						text: '产品'
					},
					{
						value: '服务',
						text: '服务'
					}
				],
				selectValue3: '维修维保',
				brand: '',
				// 维修维保/改造升级/验证/搬迁/厂房建设/其他
				selectList3: [{
						value: '维修维保',
						text: '维修维保'
					},
					{
						value: '改造升级',
						text: '改造升级'
					},
					{
						value: '验证',
						text: '验证'
					},
					{
						value: '搬迁',
						text: '搬迁'
					},
					{
						value: '厂房建设',
						text: '厂房建设'
					},
					{
						value: '其他',
						text: '其他'
					}
				],
				selectValue4: '在用',
				selectList4: [{ 
						value: '在用',
						text: '在用'
					},
					{
						value: '停用',
						text: '停用'
					},
					{
						value: '闲置中',
						text: '闲置中'
					},
					{
						value: '其他',
						text: '其他'
					}
				],
				extList: [],
				// 机械五金/仪器仪表/耗材/其他
				formInfo: {
					jobTitle: '',
					userRealName:'',
					// contactPerson:JSON.parse(uni.getStorageSync('userInfo')).contactNickName?JSON.parse(uni.getStorageSync('userInfo')).contactNickName:'用户'+JSON.parse(uni.getStorageInfoSync('userInfo')).userName.splice(-4),
					agree: false,
					contactNickName: '',
					contactMethod: ''
				},
				imgList: [],
				fileDetailList: [],
				stepIndex: 2,
				stepList: [{
						name: '填写个人信息',
						icon: 'circle',
						selectIcon: 'circle-fill'
					},
					{
						name: '填写供应信息',
						icon: 'trusty',
						selectIcon: 'trusty-fill'
					},
					{
						name: '上传附件',
						icon: 'folder',
						selectIcon: 'folder-fill'
					}
				],
				stepList2 : [{
						name: '填写公司信息',
						icon: 'circle',
						selectIcon: 'circle-fill'
					},
					{
						name: '填写供应信息',
						icon: 'trusty',
						selectIcon: 'trusty-fill'
					},
					{
						name: '上传附件',
						icon: 'folder',
						selectIcon: 'folder-fill'
					}
				],
				action: 'https://www.hualigs.cn/api/upload',
				// action: '',
				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: {},
				isEdit:false,
				editItem:{},
				canNext:true,
				
				startDate:null,
				designCapacity: null,
				mainMaterial: null,
				manufacturer: null,
				measurementUnit: null,
 				installationLocation: null,
				
				originalValue: null,
				monthlyDepreciation:null,
				netValue: null,
				residualValue: null,
				remark: null,
				sid:'',
			}
		},
		watch: {
			searchValue(val, oldval) {
				console.error(val, this.org.name);
				if (val !== this.org.name) {
					this.current = null;
				}
				if(this.selectValue!='个人'){
					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.sid = props.sid;
				this.selectValue = this.editItem.subject=='1'?'公司':'个人';
				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
						})
					}
				}
				console.error(this.imgList);
				console.error(this.fileList);
				this.extList = this.editItem.shareExt;
				 
				this.selectValue4 = this.extList[0].deviceStatus;
				this.isMedical = this.extList[0].isSpecialEquipment;
				
				this.deviceName = this.extList[0].deviceName;
				this.deviceId = this.extList[0].deviceId;
				this.deviceModel = this.extList[0].deviceModel;
				this.deviceCategory = this.extList[0].deviceCategory;
				this.deviceName = this.extList[0].deviceName;
				this.deviceName = this.extList[0].deviceName;
				
				
				this.startDate= this.extList[0].startDate;
				this.designCapacity= this.extList[0].designCapacity;
				this.mainMaterial= this.extList[0].mainMaterial;
				this.manufacturer= this.extList[0].manufacturer;
				this.measurementUnit= this.extList[0].measurementUnit;
				this.installationLocation= this.extList[0].installationLocation;
				
				this.originalValue= this.extList[0].originalValue;
				this.monthlyDepreciation= this.extList[0].monthlyDepreciation;
				this.netValue= this.extList[0].netValue;
				this.residualValue= this.extList[0].residualValue;
				
				this.remark= this.extList[0].remark;
				
				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.formInfo.contactNickName = this.formInfo.contactNickName;
			}
			// this.getCompany();
		},
		beforeDestroy() {
			if(this.sid){
				uni.removeStorageSync(this.sid)
			}
		},
		methods: {
			 bindDateChange: function(e) {
				this.startDate = e
			},
			isImage(fileName) {
							const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'ico']
							const extension = fileName.split('.').pop().toLowerCase();
							return imageExtensions.includes(extension);
			},
			showSet(){
				uni.navigateTo({
				  url: '/minePages/set',
				});
			},
			preStep(){
				this.stepIndex = this.stepIndex-1;
			},
			nextStep() {
				//todo 检查
				 let that = this;
				 if(this.stepIndex==1&&this.extList.length==0){
					 this.extList.push({
					 	prodDesc: "",
					 	prodName: "",
					 	prodSpec: "",
					 })
				 }
				 if(that.selectValue=='公司'){
					 console.error(this.org);
					 //判断必填项
					 // 公司
					 if(!this.org.name){
					 	uni.showToast({
					 		title: '请输入公司名称',
					 		duration: 2000,
					 		icon:'none'
					 	});
					 	return false;
					 }
					 
					 if(!this.formInfo.jobTitle||this.formInfo.jobTitle.length<1){
					 	uni.showToast({
					 		title: '请输入您的职称',
					 		duration: 2000,
					 		icon:'none'
					 	});
					 	return false;
					 }
					 if(!this.formInfo.contactPerson||this.formInfo.contactPerson.length<1){
					 	uni.showToast({
					 		title: '请输入联系人姓名',
					 		duration: 2000,
					 		icon:'none'
					 	});
					 	return false;
					 }
					 if(!this.formInfo.contactMethod||this.formInfo.contactMethod.length<1){
					 	uni.showToast({
					 		title: '请输入联系手机/微信/邮箱',
					 		duration: 2000,
					 		icon:'none'
					 	});
					 	return false;
					 }
				 }
					if(this.stepIndex==2&&that.selectValue2=='产品'){
						if(this.deviceName.length<1){
							uni.showToast({
								title: '请输入设备名称',
								duration: 2000,
								icon:'none'
							});
							return false;
						}
						if(this.deviceId.length<1){
							uni.showToast({
								title: '请输入设备编号',
								duration: 2000,
								icon:'none'
							});
							return false;
						}
						if(this.deviceModel.length<1){
							uni.showToast({
								title: '请输入设备型号',
								duration: 2000,
								icon:'none'
							});
							return false;
						}
						 
						// for(let i=0;i<this.extList.length;i++){
						// 	if(!this.extList[i].prodName||!this.extList[i].prodSpec){
						// 		uni.showToast({
						// 			title: !this.extList[i].prodName?'请输入产品'+(i+1)+'的产品名称':'请输入产品'+(i+1)+'的产品型号',
						// 			duration: 2000,
						// 			icon:'none'
						// 		});
						// 		return false;
						// 	}
						// }
						
					}
					if(this.stepIndex==2&&that.selectValue2=='服务'){
							 if(!this.selectValue3){
								uni.showToast({
									title: '请选择服务类型',
									duration: 2000,
									icon:'none'
								});
								return false;
							 }
							if(!this.content){
								uni.showToast({
									title: '请输入服务介绍',
									duration: 2000,
									icon:'none'
								});
								return false;
							}
						 
					}
				 
				this.stepIndex = this.stepIndex+1;
			},
			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.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);
								}
								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;
							console.warn(that.items);
						}else{
							if(res._redirect){
								uni.showToast({
									title: '操作过期，请重试',
									duration: 2000,
									icon:'none'
								});
								that.goBack();
							}
						}
					})
			},
			goBack() {
				const pages = getCurrentPages()
				if(this.sid){
					uni.removeStorageSync(this.sid)
				}
				// 有可返回的页面则直接返回，uni.navigateBack 默认返回失败之后会自动刷新页面 ，无法继续返回
				if (pages.length > 1) {
					uni.navigateBack()
					return;
				}else{
					uni.reLaunch({
						url: '/pages/index/index'
					})
				}
			},
			changeSelect(e) {
				this.selectValue = e;
			},
			changeSelect2(e) {
				this.selectValue2 = e;
			},
			changeSelect3(e) {
				this.selectValue3 = e;
			},
			changeSelect4(e) {
				this.selectValue4 = e;
			},
			changeSelect5(e) {
				this.deviceCategory = e;
			},
			changeSelect6(e) {
				this.measurementUnit = e;
			},
			newItem(){
				this.extList.push({
					prodDesc: "",
					prodName: "",
					prodSpec: "",
				})
			},
			delItem(index){
				this.extList.splice(index,1);
			},
			saveForm(status) {
				if(!this.canSave){
					return false;
				}
				let that = this;
				
				if(status!=1&&that.selectValue2=='服务'){
					
					if(!this.content){
						uni.showToast({
							title: '请输入服务介绍',
							duration: 2000,
							icon:'none'
						});
						return false;
					}
				}
				
				// if(status!=1&&that.selectValue2=='产品'){
					 
				// 	for(let i=0;i<this.extList.length;i++){
				// 		if(!this.extList[i].prodName||!this.extList[i].prodSpec){
				// 			uni.showToast({
				// 				title: !this.extList[i].prodName?'请输入产品'+(i+1)+'的产品名称':'请输入产品'+(i+1)+'的产品型号',
				// 				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;
				}

				let params = {

				};
				let postData = {
						type: that.selectValue2=='服务'?'2':'1',
						// secType: that.selectValue3,
						company: that.selectValue=='公司'?this.org.name:'',
						subject: that.selectValue=='公司'?'1':'2',
						jobTitle: this.formInfo.jobTitle,
						contactPerson: that.selectValue=='公司'?this.formInfo.contactPerson:(this.formInfo.userRealName||this.formInfo.contactNickName),
						contactMethod: this.formInfo.contactMethod,
						contactNickName: this.formInfo.contactNickName,
						// content: that.content,
						userNo: uni.getStorageSync('userNo'),
						status: status==1?status:3,
						showFlag: '是',
						// brand: that.brand,
						id: that.isEdit?that.editItem.id:undefined,
						bisNo: that.isEdit?that.editItem.bisNo:undefined,
						version: that.isEdit?that.editItem.version:undefined
				}
				if(that.selectValue=='公司'){
					postData.companyEntity = {};
					postData.companyEntity.company = postData.company;
					postData.companyEntity.jobTitle = postData.jobTitle;
					postData.companyEntity.creditCode = this.org.creditCode;
					postData.companyEntity.address = this.org.base;
					postData.companyEntity.regStatus = this.org.regStatus;
					
					postData.companyEntity.contactPerson = postData.contactPerson;
					postData.companyEntity.contactMethod = postData.contactMethod;
					postData.companyEntity.contactNickName = postData.contactNickName;
					
					// postData.companyEntity.address = this.org.creditCode;
					// postData.companyEntity.company = postData.company;
					
					postData.slbUserExt = {};
					postData.slbUserExt.userContactMethod = postData.contactMethod;
					postData.slbUserExt.contactPerson = postData.contactPerson;
					postData.slbUserExt.contactMethod = postData.contactMethod;
					postData.slbUserExt.contactNickName = postData.contactNickName;
					postData.slbUserExt.userRealName = this.formInfo.userRealName;
					
				}else{
					postData.slbUserExt = {};
					postData.slbUserExt.userContactMethod = postData.contactMethod;
					postData.slbUserExt.contactPerson = postData.contactPerson;
					postData.slbUserExt.contactMethod = postData.contactMethod;
					postData.slbUserExt.contactNickName = postData.contactNickName;
					postData.slbUserExt.userRealName = this.formInfo.userRealName;
				}
				if(postData.type=='1'){
					// postData.secType = that.selectValue4;
					// postData.isSpecialEquipment = that.isMedical;
					// postData.content = '';
					postData.shareExt = [{
						isSpecialEquipment: that.isMedical,
						deviceName: that.deviceName,
						deviceId: that.deviceId,
						deviceModel: that.deviceModel,
						deviceCategory: that.deviceCategory,
						deviceStatus: that.selectValue4,
						
						designCapacity: that.designCapacity,
						mainMaterial: that.mainMaterial,
						manufacturer: that.manufacturer,
						measurementUnit: that.measurementUnit,
						startDate: that.startDate,
						installationLocation: that.installationLocation,
						
						originalValue: that.originalValue,
						monthlyDepreciation: that.monthlyDepreciation,
						netValue: that.monthlyDepreciation,
						residualValue: that.residualValue,
						remark: that.remark,
					}];
				}

				params.slbResourceShare = JSON.stringify(postData);
				 

				params.fileDetailList = JSON.stringify(this.fileDetailList);
				uni.showToast({
					title: '提交中...',
					icon:'none'
				});
				that.canSave = false;
				request.post(that.isEdit?'/slbResourceShare/update':'/slbResourceShare/add', params).then(res => {
					
					if (res.success) {
						uni.showToast({
							title: status==1?'信息已暂存，请在我的供应中查看暂存信息':'发布已提交，请在我的供应中查看进度',
							icon: 'none',
							success: () => {
								setTimeout(() => {
									
									uni.redirectTo({
										url: "/pages/mine/share?tab="+(status==1?2:1)
									});
									 
								}, 2500)
							}
						})
						
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
						that.canSave = true;
					}
					console.warn(res);
				})
			},
			// 跳转
			tn(e) {
				uni.navigateTo({
					url: e,
				});
			},
			showImg(items, index) {
				let urls = [];
				for (let i = 0; i < items.length; i++) {
					urls.push(items[i].url);
				}
				// wx.chooseMessageFile({
				//   count: 3, //默认100
				//   type:'file',
				//   extension:['.pdf','.doc'],
				// 	success: function (res) {
				// 		console.error(JSON.stringify(res));
				// 	}
				// });
				// 预览图片
				uni.previewImage({
					urls: urls,
					current: index,
			
				});
			},
			clickLink(url,fileName) {
				// uni.navigateTo({
				// 	url:'/pages/webview/web-view?url='+encodeURIComponent('https://slb-m.lx-device.com/webview?title='+fileName+'&url='+ url),
				// })
				uni.downloadFile({
				  url: url,
				  filePath: wx.env.USER_DATA_PATH + "/" + fileName,
				  success: function (res) {
				    const filePath = res.filePath
				    uni.openDocument({
				      filePath: filePath,
					  showMenu: true,
				      success: function (res) {
				        console.log('打开文档成功')
				      },
					  fail: function(){
						  uni.showToast({
						  	title: '打开失败，请重试',
						  	icon:'none'
						  });
					  }
				    })
				  }
				})
				// uni.navigateTo({
				// 	url:'/pages/webview/web-view?url='+url,
				// })
			},
			// 手动上传文件
			upload() {
				console.warn(121212);
			},
			// 手动清空列表
			clear() {
				this.$refs.imageUpload.clear()
			},
			select(e) {
				console.log('选择文件：', e)
				let tempFiles = e.tempFiles;
				for (let i in tempFiles) {
					this.upfile(tempFiles[i])
				}
			},
			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('上传成功')
			},
			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);
					}
				}
				console.error(this.fileDetailList);
			},
			selectChange(e) {
				this.searchValue = e.name
				this.current = e.regNumber;
				if(e.jobTitle){
					this.formInfo.jobTitle = e.jobTitle;
					this.formInfo.contactPerson = this[i].contactPerson;
					this.formInfo.contactMethod = this[i].contactMethod;
				}
				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.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 = {};
				}
			},
		}
	}
</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: 10;
		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-list-item__container {
		align-items: center;
	}
	/deep/.uni-card--shadow {
		margin:0 !important;
	}
	
	/* 文章内容 start*/
	.blogger {
		&__item {
			padding: 30rpx;
		}
	
		&__author {
			&__btn {
				margin-right: -12rpx;
				opacity: 0.5;
			}
		}
	
		&__desc {
			line-height: 30rpx;
	
			&__label {
	
				color: #1D2541;
				background-color: #F3F2F7;
				border-radius: 10rpx;
				font-size: 22rpx;
	
				padding: 5rpx 15rpx;
				margin: 5rpx 18rpx 0 0;
	
				&--prefix {
					font-size: 24rpx;
					color: #1D2541;
					padding-right: 10rpx;
				}
			}
	
			&__content {
				line-height: 50rpx;
			}
		}
	
		&__content {
			margin-top: 18rpx;
			padding-right: 18rpx;
	
			&__data {
				line-height: 46rpx;
				text-align: justify;
				overflow: hidden;
				transition: all 0.25s ease-in-out;
	
			}
	
			&__status {
				margin-top: 10rpx;
				font-size: 26rpx;
				color: #82B2FF;
			}
		}
	
		&__main-image {
			border: 1rpx solid #F8F7F8;
			border-radius: 16rpx;
	
			&--1 {
				max-width: 80%;
				max-height: 300rpx;
			}
	
			&--2 {
				max-width: 260rpx;
				max-height: 260rpx;
			}
	
			&--3 {
				height: 212rpx;
				width: 100%;
			}
		}
	
		 
	}
	
	/* 文章内容 end*/

	/deep/ .uni-date-editor--x__disabled{
		opacity: 1;

	}


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