<template>
	<view class="template-edit tn-safe-area-inset-bottom">
		<!-- 顶部自定义导航 -->
		<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>发布供应</text>
				</view>
				<view v-if="(selectValue=='个人'&&stepIndex==3)||(selectValue=='公司'&&stepIndex==3)">
					<button plain="true" style="margin-right: 4px;border-radius: 24px;height:32px;line-height: 32px;font-size:15px;margin-top:4px;color:#1d60b1;border-color:#1d60b1;" @click="saveForm(1)">暂存</button>
					<!-- <text style="margin-right: 4px;padding: 6px 15px;background-color:#00000026;border-radius: 30px;color: #3D7EFF;" @click="saveForm(1)">暂存</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"></tn-steps>
			<view v-if="stepIndex==1">

				<view style="padding: 16px">
					<view style="line-height: 30px;">
						发布主体：
						<uni-data-checkbox :multiple="false" v-model="selectValue" selectedColor="#01BEFF"
							:localdata="[{text: '个人',value: '个人'},{text: '公司',value: '公司'}]" />
					</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 v-if="formInfo.contactNickName">用户昵称:</text>
						<uni-forms-item label="用户昵称" name="realName" label-width="0">
							<uni-easyinput type="text" disabled v-model="formInfo.contactNickName" placeholder="请输入您的昵称" />
						</uni-forms-item>
						<text v-if="formInfo.userRealName">真实姓名:</text>
						<uni-forms-item label="真实姓名" name="contactMethod" v-if="formInfo.userRealName">
							<uni-easyinput type="text" disabled="" v-model="formInfo.userRealName" placeholder="请输入真实姓名" />
						</uni-forms-item>
						<text v-if="formInfo.contactMethod">联系方式:</text>
						<uni-forms-item label="联系方式" name="phone">
							<uni-easyinput type="text" disabled v-model="formInfo.contactMethod" placeholder="请输入联系手机/微信/邮箱" />
						</uni-forms-item>

					</uni-forms>
				</view>

				<view v-if="selectValue=='公司'" style="padding: 16px">
					<uni-forms :modelValue="formData" label-width="0">
						<view style="margin-bottom:16px">
							<text v-if="searchValue">公司名称:</text>
							<w-select style="width: 100%;" v-model='searchValue' :list='items' valueName='name'
								keyName="regNumber" @change='selectChange' :filterable="true">
							</w-select>
						</view>
						<!-- <uni-forms-item label="公司名称" name="name">
					<uni-easyinput type="text" v-model="userInfo.company" placeholder="请输入所在公司名称" />
				</uni-forms-item> -->
						<text v-if="formInfo.jobTitle">您的职称:</text>
						<uni-forms-item label="" name="realName" label-width="0">
							<uni-easyinput type="text" :clearable="false" v-model="formInfo.jobTitle" placeholder="请输入您的职称" />
						</uni-forms-item>
						<text v-if="formInfo.contactPerson">联系姓名:</text>
						<uni-forms-item label="联系人姓名" name="contactMethod">
							<uni-easyinput type="text" :clearable="false" v-model="formInfo.contactPerson" placeholder="请输入联系人姓名" />
						</uni-forms-item>
						<text v-if="formInfo.contactMethod">联系方式:</text>
						<uni-forms-item label="联系方式" name="phone">
							<uni-easyinput type="text" :clearable="false" v-model="formInfo.contactMethod" placeholder="请输入联系手机/微信/邮箱" />
						</uni-forms-item>

						<uni-forms-item label="11" required>
							<uni-data-checkbox v-model="formInfo.agree"
								localdata="[{text: '同意平台核查所填信息的真实性',value: '是'}]" />
						</uni-forms-item>
					</uni-forms>
				</view>





				<!-- <view class="tn-flex tn-flex-row-between tn-flex-col-center tn-padding-top-xl tn-margin">
        <view class="tn-flex justify-content-item">
          <view class="tn-bg-black tn-color-white tn-text-center" style="border-radius: 100rpx;margin-right: 8rpx;width: 45rpx;height: 45rpx;line-height: 45rpx;">
            <text class="tn-icon-tag" style="font-size: 30rpx;"></text>
          </view>
          <view class="tn-text-lg tn-padding-right-xs tn-text-bold">话题标签</view>
        </view>
        <view class="justify-content-item tn-text-df tn-color-grey">
          <text class="tn-padding-xs">选择</text>
          <text class="tn-icon-right"></text>
        </view>
      </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: 24px;"
							@click="preStep()">
							 上一步 
						</button>
						 
					</view> -->
					<view class="tn-flex-1 justify-content-item tn-margin-sm tn-text-center">
						<button type="default" plain="true" style="border-radius: 24px;"
							@click="nextStep()">
							 下一步 
						</button>
					</view>
				</view>
			</view>
			<view v-if="stepIndex!=1">

				<view style="padding: 16px" v-if="(selectValue=='公司'&&stepIndex==2)||(selectValue=='个人'&&stepIndex==2)">
					
					<text>发布种类:</text>
					<uni-data-select v-model="selectValue2" :localdata="selectList2" @change="changeSelect2"
						:clear="false"></uni-data-select>
				</view>

				<view v-if="selectValue2=='产品'" >
					<view style="padding: 16px" v-if="(selectValue=='公司'&&stepIndex==2)||(selectValue=='个人'&&stepIndex==2)">
						<text v-if="selectValue4">产品种类:</text>
						<uni-data-select v-model="selectValue4" :localdata="selectList4" @change="changeSelect4"
							placeholder="产品种类" :clear="false" style="margin-bottom:16px"></uni-data-select>
						
						
						<view style="margin-top: 16px;">
						   <text>品牌:</text>
						   <uni-easyinput type="text"  required v-model="brand" placeholder="请输入产品品牌" />
						</view>
						<view style="margin-top: 16px;line-height: 30px;margin-bottom: 16px;">
							发布的产品是否属于医疗器械？
							<uni-data-checkbox :multiple="false" v-model="isMedical" selectedColor="#01BEFF"
								:localdata="[{text: '是',value: '1'},{text: '否',value: '0'}]" />
						</view>

						<view v-for="item,itemIndex in extList">
							
							<uni-card >
											<template v-slot:title>
												<uni-list>
													<uni-list-item style="align-items: center;">
															<template v-slot:header>
																 产品信息{{itemIndex+1}}
															</template>
															<template v-slot:footer>
																<button type="default" style="color:#1d60b1;border-color:#1d60b1;" plain="true" size="mini" v-if="(extList.length>1&&extList.length<6&&itemIndex==extList.length-1)||extList.length==1" @click="newItem">+新增产品</button>
																<button type="warn" plain="true" size="mini" v-if="extList.length>1&&itemIndex!==extList.length-1" @click="delItem(itemIndex)">-删除产品</button>
																<!-- <tn-button fontColor="tn-color-white" shape="round" backgroundColor="#3668FC" v-if="extList.length==1" @click="newItem">+新增产品</tn-button>
																 <tn-button fontColor="tn-color-white" shape="round" backgroundColor="#3668FC" v-if="extList.length>1&&extList.length<6&&itemIndex==extList.length-1" @click="newItem">+新增产品</tn-button>
																 <tn-button fontColor="tn-color-white" shape="round" backgroundColor="#FF000C" v-if="extList.length>1&&itemIndex!==extList.length-1" @click="delItem(itemIndex)">-删除产品</tn-button> -->
															</template>
														</uni-list-item>
												</uni-list>
												
											</template>
										<uni-forms :modelValue="formData" label-width="0">
											 
											<uni-forms-item label="" name="prodName" label-width="0">
												<uni-easyinput maxlength="50" type="text" :clearable="false" v-model="item.prodName"
													placeholder="*请输入产品名称" />
											</uni-forms-item>
											<uni-forms-item label="" name="contactMethod">
												<uni-easyinput maxlength="100" type="text" :clearable="false" v-model="item.prodSpec"
													placeholder="*请输入产品型号" />
											</uni-forms-item>
											<uni-forms-item label="" name="phone">
												<uni-easyinput maxlength="500" type="textarea" v-model="item.prodDesc" placeholder="请输入产品介绍" />
											</uni-forms-item>
										
										
										</uni-forms>
										<template v-slot:actions v-if="itemIndex==extList.length-1" >
											<view style="margin: 12px;margin-top: -12px;">
												<text style="color:#999">为保证排版整洁，最多一次上传六个产品哦</text>
											</view>
										</template>
							</uni-card>
							<!-- <view>
								
								<uni-forms :modelValue="formData" label-width="0">
									<view style="display: flex;justify-content: space-between;">
										<view><text class="tn-icon-p" style="font-size: 30rpx;"></text>产品{{itemIndex+1}}</view>
										  
										<view><tn-button v-if="extList.length==1" @click="newItem">+新增产品</tn-button>
										<tn-button v-if="extList.length>1&&extList.length<6&&itemIndex==extList.length-1" @click="newItem">+新增产品</tn-button>
										<tn-button v-if="extList.length>1&&itemIndex!==extList.length-1" @click="delItem(itemIndex)">-删除产品</tn-button></view>
										
									</view>
									<uni-forms-item label="" name="prodName" label-width="0">
										<uni-easyinput type="text" required v-model="item.prodName"
											placeholder="*请输入产品名称" />
									</uni-forms-item>
									<uni-forms-item label="" name="contactMethod">
										<uni-easyinput type="text" required v-model="item.prodSpec"
											placeholder="*请输入产品型号" />
									</uni-forms-item>
									<uni-forms-item label="" name="phone">
										<uni-easyinput type="text" v-model="item.prodDesc" placeholder="请输入产品介绍" />
									</uni-forms-item>


								</uni-forms>
							</view> -->

						</view>


					</view>

				</view>
				<view v-if="selectValue2=='服务'&&stepIndex==2">
					<view style="padding: 16px">
						<text>服务类型:</text>
						<uni-data-select v-model="selectValue3" :localdata="selectList3" @change="changeSelect3"
							:clear="false"></uni-data-select>
					</view>
				</view>
				
				<view v-if="selectValue2=='服务'&&stepIndex==2">
					<view style="padding: 16px">
					   <text>品牌:</text>
					   <uni-easyinput type="text"  required v-model="brand" placeholder="请输入服务品牌" />
					</view>
				</view>
					
				<view>


					<!-- <view class="tn-margin tn-bg-gray--light" style="border-radius: 10rpx;padding: 20rpx 30rpx;">
					 	<input placeholder="写下一句简短的标题" name="input" placeholder-style="color:#AAAAAA" ></input>
					 </view> -->
					 <view v-if="selectValue2=='服务'&&stepIndex==2" style="padding: 16px;padding-bottom: 0;margin-bottom: -30rpx;">
					    <text>服务介绍:</text>
					 </view>
					<view v-if="selectValue2=='服务'&&stepIndex==2" class="tn-margin tn-bg-gray--light tn-padding"
						style="border-radius: 10rpx;">
						
						<textarea maxlength="500" v-model="content" placeholder="请输入服务介绍"
							placeholder-style="color:#AAAAAA"></textarea>
					</view>

					<view class="tn-flex tn-flex-row-between tn-flex-col-center   tn-margin"  v-if="stepIndex==3">
						<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-image" style="font-size: 30rpx;"></text>
							</view>
							<view class="tn-text-lg tn-padding-right-xs tn-text-bold">上传其他图片（选填）</view>
						</view>
						<!-- <view class="justify-content-item tn-text-df tn-color-grey" @tap="clear">
					 					<text class="tn-padding-xs">清空上传</text>
					 					<text class="tn-icon-delete"></text>
					 				</view> -->
					</view>






					<view class="tn-margin-left tn-padding-top-xs"  v-if="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;">一次只能上传六张图片</text>
						</view>
						
						<!-- <tn-image-upload-drag ref="imageUpload" :action="action" :width="236" :height="236" :formData="formData"
					 					:fileList="fileList" :disabled="disabled" :autoUpload="autoUpload" :maxCount="maxCount"
					 					:showUploadList="showUploadList" :showProgress="showProgress" :deleteable="deleteable"
					 					:customBtn="customBtn" @sort-list="onSortList" /> -->

					</view>

					<view class="tn-flex tn-flex-row-between tn-flex-col-center tn-margin tn-padding-top-xs"  v-if="stepIndex==3">
						<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: 30rpx;"></text>
							</view>
							<view class="tn-text-lg tn-padding-right-xs tn-text-bold">上传相关文件（选填）</view>
						</view>
						<!-- <view class="justify-content-item tn-text-df tn-color-grey" @tap="clear">
					 					<text class="tn-padding-xs">清空上传</text>
					 					<text class="tn-icon-delete"></text>
					 				</view> -->
					</view>

					<view class="tn-margin-left tn-padding-top-xs"  v-if="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:#1d60b1;border-color:#1d60b1;display: inline-block;" plain="true">上传文件</button>
							</view>
							
						
						</uni-file-picker>
						<view style="margin-top: 8px;">
							<text style="color: #999;font-size: 12px;">一次只能上传三个文件，支持格式 pdf .doc .xls，不超过5MB。</text>
						</view>
						 
						 
						<view style="margin-top:20px" v-if="selectValue2=='产品'">
							<text style="color: #999;font-size: 12px;">如若产品属于医疗器械，请上传相关资质证明。</text>
						</view>
						<!-- <tn-image-upload-drag ref="imageUpload" :action="action" :width="236" :height="236" :formData="formData"
					 					:fileList="fileList2" :disabled="disabled" :autoUpload="autoUpload" :maxCount="maxCount"
					 					:showUploadList="showUploadList" :showProgress="showProgress" :deleteable="deleteable"
					 					:customBtn="customBtn" @sort-list="onSortList" /> -->

					</view>
				</view>

				<view label="11" name="check" style="padding:16px"  v-if="stepIndex==3">
					<uni-data-checkbox :multiple="true" v-model="formInfo.agree" selectedColor="#01BEFF"
						:localdata="[{text: '同意平台核查所填信息的真实性',value: '是'}]" />
				</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: 24px;"
							@click="preStep()">
							 上一步 
						</button>
					</view>
					<view class="tn-flex-1 justify-content-item tn-margin-sm tn-text-center">
						<button type="default" plain="true" style="border-radius: 24px;"
							@click="nextStep()">
							 下一步 
						</button>
						<!-- <tn-button backgroundColor="#3668FC" padding="40rpx 0" width="60%" shadow fontBold
							@click="nextStep()">
							<text class="tn-color-white">下一步</text>
						</tn-button> -->
					</view>
				</view>

				<view class="tn-flex tn-footerfixed"  v-if="(stepIndex==3)">
					<view class="tn-flex-1 justify-content-item tn-margin-sm tn-text-center">
						<button type="default" plain="true" style="border-radius: 24px;"
							@click="preStep()">
							 上一步 
						</button>
						 
					</view>
					<view class="tn-flex-1 justify-content-item tn-margin-sm tn-text-center">
						<button type="primary" style="background-color:#1d60b1;border-radius: 23px" @click="saveForm()">提交审核</button>
						<!-- <tn-button backgroundColor="#3668FC" padding="40rpx 0" width="60%" shadow fontBold
							@click="saveForm()">
							<text class="tn-color-white">提交审核</text>
						</tn-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 {
				canSave:true,
				isMedical: '1',
				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: [{
					prodDesc: "",
					prodName: "",
					prodSpec: "",
				}],
				// 机械五金/仪器仪表/耗材/其他
				formInfo: {
					jobTitle: '',
					userRealName:JSON.parse(uni.getStorageSync('userInfo')).userRealName,
					// contactPerson:JSON.parse(uni.getStorageSync('userInfo')).contactNickName?JSON.parse(uni.getStorageSync('userInfo')).contactNickName:'用户'+JSON.parse(uni.getStorageInfoSync('userInfo')).userName.splice(-4),
					agree: ['是'],
					contactNickName: JSON.parse(uni.getStorageSync('userInfo')).contactNickName||'用户'+JSON.parse(uni.getStorageSync('userInfo')).userName.slice(-4),
					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'
					},
					{
						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: {},
			}
		},
		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() {
			this.getCompany();
		},
		methods: {
			preStep(){
				this.stepIndex = this.stepIndex-1;
			},
			nextStep() {
				//todo 检查
				 let that = this;
					if(this.stepIndex==2&&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(this.stepIndex==2&&that.selectValue2=='服务'){
						 
							if(!this.content){
								uni.showToast({
									title: '服务介绍必填',
									duration: 2000,
									icon:'none'
								});
								return false;
							}
						 
					}
				 
				this.stepIndex = this.stepIndex+1;
				
				console.error(this.stepIndex);
			},
			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(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.items = list;
							console.warn(that.items);
						}  
					})
				
				 
				 
			},
			changeSelect(e) {
				this.selectValue = e;
			},
			changeSelect2(e) {
				this.selectValue2 = e;
			},
			changeSelect3(e) {
				this.selectValue3 = e;
			},
			changeSelect4(e) {
				this.selectValue4 = 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(this.formInfo.agree.length<1){
					uni.showToast({
						title: '请勾选同意平台核查所填信息的真实性',
						duration: 2000,
						icon:'none'
					});
					return false;
				}
				if(that.selectValue2=='服务'){
					if(!this.content&&this.fileDetailList.length<1){
						uni.showToast({
							title: '请输入服务介绍或上传图片/文件',
							duration: 2000,
							icon:'none'
						});
						return false;
					}
				}
				
				if(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;
						}
					}
				}
				
				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: this.formInfo.contactPerson,
						contactMethod: this.formInfo.contactMethod,
						contactNickName: this.formInfo.contactNickName,
						content: that.content,
						userNo: uni.getStorageSync('userNo'),
						status: status==1?status:undefined,
						brand: that.brand,
				}
				if(that.selectValue=='公司'){
					postData.companyEntity = {};
					postData.companyEntity.company = postData.company;
					postData.companyEntity.jobTitle = postData.jobTitle;
					postData.companyEntity.creditCode = this.org.creditCode;
					
					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.isMedical = that.isMedical;
					postData.content = '';
					postData.shareExt = that.extList;
				}

				params.slbResourceShare = JSON.stringify(postData);
				 

				params.fileDetailList = JSON.stringify(this.fileDetailList);
				uni.showToast({
					title: '提交中...',
					icon:'none'
				});
				that.canSave = false;
				request.post('/slbResourceShare/add', params).then(res => {
					that.canSave = true;
					if (res.success) {
						uni.showToast({
							title: status==1?'暂存成功':'发布已提交，请在我的供应中查看进度',
							icon: 'none',
							success: () => {
								setTimeout(() => {
									uni.redirectTo({
										url: "/pages/mine/share?tab="+(1)
									});
								}, 2500)
							}
						})
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
					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])
				}
			},
			upfile(file) {
				let that = this;
				console.warn(file);
				uni.uploadFile({
					url: 'http://slb-m.dev.ml1993.com/oss/upload/userFeedback', //仅为示例，非真实的接口地址
					filePath: file.url,
					name: 'file',
					success: (uploadFileRes) => {
						console.warn(JSON.parse(uploadFileRes.data));
						let resultMap = JSON.parse(uploadFileRes.data).resultMap;
						that.fileDetailList.push({
							name: file.name,
							fileName: file.name, // 原始文件名
							ftpUrl: resultMap.uploadUrl, // 文件访问url
							path: file.path
						})
					}
				});
			},
			// 上传成功
			success(e) {
				console.log('上传成功')
			},
			deleteFile(e, index) {
				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;
			},
			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 {
							uni.showToast({
								title: res.msg,
								icon: 'none'
							})
						}
					})

				} else {
					that.items = [];

				}
			},
		}
	}
</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: #fff;
	}

	/* 底部悬浮按钮 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;
	}



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