<style scoped lang="scss">
.carrierInformationfrom {
  width: 100%;
  .slot-btn {
    width: 220rpx;
    height: 220rpx;
    background: #f5f5f5;
    border-radius: 17rpx;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .slot-btn .image {
    width: 54rpx;
    height: auto;
  }
  #myVideo {
    width: 150px;
    height: 200px;
  }
  .bottom-border {
    border-bottom: 3rpx #dadce6 solid;
    margin-top: 10px;
    .bottom-border_r {
      height: 42px;
      display: flex;
      align-items: center;
    }
    .con6 {
      display: flex;
      flex-wrap: wrap;

      .goodsTypeImg {
        width: 278rpx;
        height: 144rpx;
        background-color: #232323;
        opacity: 0.6;
        border-radius: 18rpx;
        margin-bottom: 30rpx;
      }
    }
  }
  .butBox2 {
    margin: 10rpx auto;
    width: 300rpx;
    height: 80rpx;
    background-color: #f70027;
    box-shadow: 0rpx 4rpx 40rpx 0rpx rgba(249, 54, 85, 0.58);
    border-radius: 20rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 28rpx;
    font-weight: bold;
    color: #ffffff;

    .next {
      width: 100%;
      height: auto;
    }
  }
  .u-action-sheet-item {
				display: flex;
				line-height: 1;
				justify-content: center;
				align-items: center;
				font-size: 14px;
				padding: 34rpx 0;
				
			}
			 .pubox{
				width: 100%;
				
			}
			 .pubox-top{
				width: 100%;
				height: 45px;
				display: flex;
				align-items: center;
				justify-content: space-between;
				font-size: 14px;
				color: #111;
			}
			.u-gab {
				height: 12rpx;
				background-color: rgb(234, 234, 236);
			}
			.u-actionsheet-cancel {
				color: $u-main-color;
			}
}
</style>

<template>
  <view class="carrierInformationfrom">
    <view class="bottom-border">
      <view class="label-text"
        >载体名称 <span style="color: #e54d42">*</span></view
      >
      <input
        type="text"
        v-model="model.CarrierName"
        style="padding: 10px 0"
        placeholder="请填写载体名称"
        :disabled="disabled || disabled2 ? true : false"
        placeholder-style="color:#CECECE;"
      />
    </view>

    <view class="bottom-border">
      <view class="label-text"
        >开发商<span style="color: #e54d42">*</span></view
      >
      <input
        type="text"
        v-model="model.Developers"
        :disabled="disabled"
        style="padding: 10px 0"
        placeholder="请填写开发商"
        placeholder-style="color:#CECECE;"
      />
    </view>
    <view class="bottom-border">
      <view class="label-text"
        >载体地址<span style="color: #e54d42">*</span></view
      >
      <view
        class="bottom-border_r"
        style="padding: 10px 0; height: 42px; display: flex"
        @click="disabled ? '' : getAddress()"
      >
        <u-icon name="location" :color="mainColor" size="30"></u-icon>
        <text
          style="
            width: 1px;
            flex: 1;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
            margin-right: 5px;
          "
          v-if="model.Address"
          >{{ model.Address }}</text
        >
        <text
          style="width: 1px; flex: 1; color: #cecece"
          v-if="!model.Address"
          >请选择地址</text
        >
        <u-icon name="arrow" color="#A5A4AC" size="30"></u-icon>
      </view>
    </view>
    

    <view class="label-text" style="margin-top: 20px; margin-bottom: 30rpx">
      <view>Logo<span style="color: #e54d42">*</span></view>
    </view>
    <view @click="disabled ? '' : uploadcard()">
      <view slot="addBtn" class="slot-btn" v-if="model.Logo == ''">
        <image
          class="image"
          src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/ybminiappimg.png"
          mode="widthFix"
        ></image>
      </view>
      <view
        class="slot-btn"
        v-if="model.Logo != ''"
        @click="disabled ? previewImage([model.Logo], 1) : ''"
      >
        <image
          style="width: 220rpx; height: 220rpx"
          :src="model.Logo"
          mode="aspectFill"
        ></image>
      </view>
    </view>
    <view class="label-text" style="margin-top: 20px; margin-bottom: 30rpx">
      <view style="display: flex">
        <view>介绍图<span style="color: #e54d42">*</span></view>
        <text style="color: #999; font-weight: 400"
          >（最多9张,第一张为封面图）</text
        >
      </view>
    </view>
    <view>
      <u-upload
        :action="action"
        :max-count="9"
        :max-size="2 * 1024 * 1024"
        :deletable="!disabled"
        :file-list="fileList"
        @on-remove="onRemove1"
        :custom-btn="true"
        @on-success="uploadSuccessHandler"
      >
        <view slot="addBtn" class="slot-btn" v-if="disabled == false">
          <image
            class="image"
            src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/ybminiappimg.png"
            mode="widthFix"
          ></image>
        </view>
      </u-upload>
    </view>
    <view class="label-text" style="margin-top: 20px; margin-bottom: 30rpx">
      <text>载体视频</text>
    </view>
    <view style="margin-bottom: 30rpx">
      <view
        style="
          width: 150px;
          height: 200px;
          position: relative;
          margin-right: 20px;
        "
        v-if="model.VideoUrl"
      >
        <video
          id="myVideo"
          :src="model.VideoUrl"
          style="width: 150px; height: 200px"
          :controls="controls"
          :show-center-play-btn="true"
          :show-fullscreen-btn="true"
        ></video>
        <view
          style="
            width: 50rpx;
            height: 50rpx;
            position: absolute;
            right: 10rpx;
            top: 10rpx;
            border-radius: 25rpx;
            background: #f30329;
            display: flex;
            align-items: center;
            justify-content: center;
          "
          @tap.stop="!model.VideoUrl"
          v-if="!disabled"
        >
          <u-icon
            class="u-icon"
            name="cross"
            size="30"
            color="#ffffff"
          ></u-icon>
        </view>
      </view>
      <view v-if="!model.VideoUrl">
        <view slot="addBtn" class="slot-btn" @click="disabled ? '' : upvideo()">
          <image
            class="image"
            src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/ybminiappvideo.png"
            mode="widthFix"
          ></image>
        </view>
      </view>
    </view>
    <view class="bottom-border">
      <view class="label-text"
        >开业时间<span style="color: #e54d42">*</span></view
      >
      <input
        type="text"
        @click="disabled ? '' : (showOpenTime = true)"
        v-model="model.OpenTime"
        :disabled="true"
        style="padding: 10px 0"
        placeholder="请选择开业时间"
        placeholder-style="color:#CECECE;"
      />
      <u-picker
        mode="time"
        v-model="showOpenTime"
        :params="params"
        @confirm="confirmOpenTime"
      ></u-picker>
    </view>
    <view class="bottom-border">
      <view class="label-text"
        >载体类型<span style="color: #e54d42">*</span></view
      >
      <view class="bottom-border_r" style="padding: 10px 0;height: 42px;display: flex;" 
      @click="disabled ||disabled2?'':(showTypeStatus= true,showType=1)">
				<input type="text" v-model="BrandClassName" :disabled="true" style="padding: 10px 0;width: 1px;flex:1" placeholder="请选择分类"  placeholder-style="color:#CECECE;">
				<u-icon name="arrow" color="#A5A4AC" size="30" ></u-icon>
			</view>
      <u-popup v-model="showTypeStatus" mode="bottom" >
				<view class="pubox" >
					<scroll-view scroll-y="true" style="max-height: calc(100vh * 0.7 - 65px) ;">
						<view >
              <template v-if="showType==1">
                <view v-for="(x,y) in BrandClassList" :key="y" class="u-action-sheet-item u-border-bottom" 
                @click="clickItem(x)" :style="{color:x.ID == model.CategoryId?'#2979ff':'#111',}">
                  {{x.ClassName}}
                </view>
              </template>
              <template v-if="showType==2">
                <view v-for="(x,y) in GetYBConfig.zichanList" :key="y" class="u-action-sheet-item u-border-bottom" 
                @click="clickItem(x)" :style="{color:x.Name == model.Ascription?'#2979ff':'#111',}">
                  {{x.Name}}
                </view>
              </template>
						</view>
					</scroll-view>
					<view class="u-gab" ></view>
					<view  class="u-actionsheet-cancel u-action-sheet-item" hover-class="u-hover-class"
					 :hover-stay-time="150" @click="showTypeStatus=false">取消</view>
				</view>
			</u-popup>
    </view>
    <view class="bottom-border">
      <view class="label-text"
        >经营面积<span style="color: #e54d42">*</span></view
      >
      <view
        class="bottom-border_r"
        style="padding: 10px 0; height: 42px; display: flex"
      >
        <input
          type="number"
          v-model="model.BuiltUpArea"
          style="width: 1px; flex: 1;margin-right: 10px;"
          placeholder="请填写经营面积"
          :disabled="disabled"
          placeholder-style="color:#CECECE;"
        />
        <text>m²</text>
      </view>
    </view>
    <view class="bottom-border">
      <view class="label-text"
        >可租赁面积<span style="color: #e54d42">*</span></view
      >
      <view
        class="bottom-border_r"
        style="padding: 10px 0; height: 42px; display: flex"
      >
        <input
          type="number"
          v-model="model.AreaRequirement"
          style="width: 1px; flex: 1;margin-right: 10px;"
          placeholder="请填写可租赁面积"
          :disabled="disabled"
          placeholder-style="color:#CECECE;"
        />
        <text>m²</text>
      </view>
    </view>
    <view class="bottom-border">
      <view class="label-text"
        >商业体量<span style="color: #e54d42">*</span></view
      >
      <view
        class="bottom-border_r"
        style="padding: 10px 0; height: 42px; display: flex"
      >
        <input
          type="number"
          v-model="model.CarrierSize"
          :disabled="disabled"
          style="padding: 10px 0; width: 1px; flex: 1; margin-right: 10px"
          placeholder="请输入商业体量"
          placeholder-style="color:#CECECE;"
        />
        <span>万m²</span>
      </view>
    </view>

    <view class="bottom-border">
      <view class="label-text">商业层数</view>
      <input
        type="text"
        v-model="model.LayersNum"
        :disabled="disabled"
        style="padding: 10px 0"
        placeholder="请填写商业层数"
        placeholder-style="color:#CECECE;"
      />
    </view>
    <view class="bottom-border">
      <view class="label-text">车位数量 </view>
      <input
        type="number"
        v-model="model.CarNum"
        :disabled="disabled"
        style="padding: 10px 0"
        placeholder="请填写车辆数量"
        placeholder-style="color:#CECECE;"
      />
    </view>
    <view class="bottom-border">
      <view class="label-text">业态规划</view>
      <input
        type="text"
        v-model="model.CarrierPlan"
        :disabled="disabled"
        style="padding: 10px 0"
        placeholder="请填写业态规划"
        placeholder-style="color:#CECECE;"
      />
    </view>
    <view class="bottom-border">
      <view class="label-text">发展及定位</view>
      <input
        type="text"
        v-model="model.Location"
        :disabled="disabled"
        style="padding: 10px 0"
        placeholder="请填写发展及定位"
        placeholder-style="color:#CECECE;"
      />
    </view>
    <view class="bottom-border">
      <view class="label-text">资产权属</view>
      <view class="bottom-border_r" style="padding: 10px 0;height: 42px;display: flex;" 
			@click="disabled || disabled2?'':(showTypeStatus= true,showType=2)">
				<view v-if="model.Ascription" style="padding: 10px 0;flex:1;display: flex;overflow: hidden;text-overflow: ellipsis;">
					{{model.Ascription}}
				</view>
        <text v-else style="padding: 10px 0;flex:1;color:#CECECE;">请选择资产权属</text>
				<u-icon name="arrow" color="#A5A4AC" size="30" ></u-icon>
			</view>
    </view>
    <view class="bottom-border">
      <view class="label-text">人流量参数</view>
      <input
        type="text"
        v-model="model.VisitorsFlowrate"
        :disabled="disabled"
        style="padding: 10px 0"
        placeholder="请填写人流量参数"
        placeholder-style="color:#CECECE;"
      />
    </view>
    <view class="bottom-border">
      <view class="label-text">水电气及配套</view>
      <input
        type="text"
        v-model="model.SupportingFacilities"
        :disabled="disabled"
        style="padding: 10px 0"
        placeholder="请填写水电气及配套"
        placeholder-style="color:#CECECE;"
      />
    </view>
    <view class="bottom-border">
      <view class="label-text">管理公司及管理费</view>
      <view
        class="bottom-border_r"
        style="padding: 10px 0; height: 42px; display: flex"
      >
        <input
          type="text"
          v-model="model.ManagementCompany"
          :disabled="disabled"
          style="padding: 10px 0;flex: 1;margin-right: 10px"
          placeholder="请填写人管理公司及管理费"
          placeholder-style="color:#CECECE;"
        />
        
      </view>
    </view>
    <view class="bottom-border">
      <view class="label-text">目标招商业态及品牌需求</view>
      <textarea
			  style="height: 60px;padding: 10px 0;"
			  v-model="model.BrandDemand"
			  placeholder="请填写人目标招商业态及品牌需求"
			  :disabled="disabled"
			  maxlength="500"
			  placeholder-style="color:#CECECE;"
			/>
    </view>
    <view class="bottom-border">
      <view class="label-text">联系人</view>
      <input
        type="text"
        v-model="model.ContactName"
        :disabled="disabled"
        style="padding: 10px 0"
        placeholder="请填写联系人"
        placeholder-style="color:#CECECE;"
      />
    </view>
    <view class="bottom-border">
      <view class="label-text">联系电话</view>
      <input
        type="text"
        v-model="model.ContactPhone"
        :disabled="disabled"
        style="padding: 10px 0"
        placeholder="请填写联系电话"
        placeholder-style="color:#CECECE;"
      />
    </view>
    <view style="margin-top: 30px">
      <view class="butBox2" @click="carrierSubmit" v-if="!disabled" :style="{background:mainColor,boxShadow:`0rpx 4rpx 40rpx 0rpx ${mainColor}94`}">
        <text v-if="datas.CompanyStatus && datas.CompanyStatus == 1"
          >确定修改</text
        >
        <text v-else>完成</text>
      </view>
      <view class="butBox2" @click="goback" :style="{background:mainColor,boxShadow:`0rpx 4rpx 40rpx 0rpx ${mainColor}94`}" v-else>
        <text>返回</text>
      </view>
    </view>
  </view>
</template>

<script>
import {formatDate} from '../../../appointment/components/zzx-calendar/generateDates.js';
export default {
  props: {
    datas: {
      type: Object,
    },
  },
  data() {
    return {
      mainColor: "",
      controls: true,
      action: this.host2 + "/api/File/UploadTencent",
      fileList: [],
      HonorFileList: [],
      params: {
        year: true,
        month: true,
        day: true,
        hour: false,
        minute: false,
        second: false,
      },
      model: {
        ID: 0,
        CompanyId: 0, //认证Id
        // ExistCarrierId: 0, //绑定id
        CarrierName: "", //	载体名称
        Logo: "",
        BannerList: [], //载体介绍图
        VideoUrl: "", //载体视频
        Address: "", //载体地址
        LatAndLon: "", //载体地址经纬度
        Developers: "", //开发商
        OpenTime: "", //开业时间
        // ProjectType: 0, //项目类型
        CarrierSize: null, //商业体量
        LayersNum: "", //商业层数
        CarNum: null, //车位数量
        CarrierPlan: "", //业态规划
        // CarrierTarget: "", //招引目标
        Location: "", //定位
        // Crowd: "", //目标人群
        // CarrierMetroList: [], //地铁信息
        // FirstShopNumList: [
          //载体类型、数量
          // {
          //   Id: 0,
          //   Name: "",
          //   Num: 0,
          // },
        // ],
        // HonorList: [], //载体荣誉
        // Discount: "", //招引优惠政策
        // StartingInfo: "", //首发政策
        // FirstShow: "", //首秀政策
        // FirstExhibition: "", //首展政策
        // ShopNum: 0, //店铺数量
        BuiltUpArea: null, //经营面积
        AreaRequirement: null, //可租赁面积
        // YeJi: 0, //去年业绩
        Ascription: "",//资产权属
        VisitorsFlowrate: "",//人流量参数
        SupportingFacilities: "",//水电气及配套
        ManagementCompany: "",//管理公司及管理费
        BrandDemand: "",//目标招商业态及品牌需求
        CategoryId: "",//载体类型
        ContactName: "",//联系人
        ContactPhone: "",//联系电话
      },
      showOpenTime: false,
      goodsType: [], //载体类型
      goodsTypeImg: {
        1: "https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/goodstype-baihuo.png",
        2: "https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/goodstype-shappingmall.png",
        3: "https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/goodstype-center.png",
        4: "https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/goodstype-other.png",
      },
      MetroList: [],
      disabled: false,
      disabled2: false,
      glCarrierName: "",
      CategoryName: "", //类别
      shenList: [], //
      showTypeStatus4: false,
      isdisabled: false, //是否是详情过来的
      blockStyle: {
        width: "36rpx",
        height: "36rpx",
        background: "#FFFFFF",
        border: "4rpx solid",
        "border-image": "linear-gradient(0deg, #F70027, #FB899B) 4 4",
        "box-shadow": "0rpx 0rpx 10rpx 0rpx rgba(232, 76, 100, 0.74)",
        "border-radius": "10rpx",
      },
      BrandClassList: [],
      showTypeStatus: false,
      BrandClassName: '',
      GetYBConfig: null,
      showType: 1,
    };
  },
  onLoad(options) {
    let MallBaseId = uni.getStorageSync("mall_UserInfo").MallBaseId
      ? uni.getStorageSync("mall_UserInfo").MallBaseId
      : 1;
    this.action =
      this.host2 + "/api/File/UploadTencent?MallBaseId=" + MallBaseId;
    
  },
  created() {
    this.mainColor = this.$uiConfig.mainColor;
    this.GetAuthenticationCategoryEnumList(); //首店类别
    this.GetProjectTypeEnumList(); //载体性质
    

    if (
      this.datas.CompanyStatus != undefined &&
      this.datas.IsComplete != undefined
    ) {
      //判断是否填写过了
      let data = this.datas.CarrierModel
      this.model = this.datas.CarrierModel
      if(this.model.OpenTime) this.model.OpenTime = formatDate(new Date(this.model.OpenTime),'yyyy-MM-dd')
      this.model.CompanyId = this.datas.CompanyId;
      this.BrandClassName = data.CategoryName

      if (this.model.BannerList && this.model.BannerList.length > 0) {
        this.model.BannerList.forEach((x) => {
          let obj = {
            url: x,
          };
          this.fileList.push(obj);
        });
      } else {
        this.model.BannerList = [];
        this.fileList = [];
      }
      // if (this.model.HonorList && this.model.HonorList.length > 0) {
      //   this.model.HonorList.forEach((x) => {
      //     let obj = {
      //       url: x,
      //     };
      //     this.HonorFileList.push(obj);
      //   });
      // } else {
      //   this.model.HonorList = [];
      //   this.HonorFileList = [];
      // }
      if (!this.model.Logo) {
        this.model.Logo = "";
      }
      if (this.datas.CompanyStatus == 0 && this.datas.IsComplete == 1) {
        //审核中
        this.disabled = true;
      }
      if (this.datas.CompanyStatus == 1) {
        // this.disabled2 = true;
      }
      if (this.model.ExistCarrierId > 0) {
        // this.disabled2 = true;
      }
    } else {
      this.model.CompanyId = this.datas.CompanyId;
    }
  },
  methods: {
    clickItem(x) {//类型选择
        if(this.showType==1) {
          this.BrandClassName = x.ClassName;
				  this.model.CategoryId = x.ID;
        }else{
				  this.model.Ascription = x.Name;
        }
				
				this.showTypeStatus=false
			},
    GetProjectTypeEnumList() {
      this.request2({
						url: "/api/AppletTrade/GetBrandClassList",
						data: {
							BrandCategory: 1
						},
					},
					(res) => {
						if (res.resultCode == 1) {
							this.BrandClassList =  res.data
						}
					}
      );
      this.request2({
						url: "/api/AppletTrade/GetYBConfig",
						data: {},
					},
					(res) => {
						if (res.resultCode == 1) {
							this.GetYBConfig =  res.data
						}
					}
				);
      // let parms = {
      //   url: "/api/AppletTrade/GetProjectTypeEnumList",
      // };
      // this.request2(parms, (res) => {
      //   if (res.resultCode == 1) {
      //     this.goodsType = res.data;
      //   }
      // });
    },
    onRemove1(index) {
      this.model.BannerList.splice(index, 1);
    },
    uploadSuccessHandler(data, index, lists) {
      let r = JSON.parse(data);
      this.model.BannerList.push(r.data);
    },
    onRemoveHonor(index) {
      this.model.HonorList.splice(index, 1);
    },
    uploadSuccessHandlerHonor(data, index, lists) {
      let r = JSON.parse(data);
      this.model.HonorList.push(r.data);
    },
    uploadcard() {
      uni.chooseImage({
        count: 1, //默认9
        sizeType: ["original", "compressed"], //可以指定是原图还是压缩图，默认二者都有
        sourceType: ["album", "camera"], //从相册选择
        success: async (res) => {
          var tempFilePaths = res.tempFilePaths;
          uni.showLoading({
            title: "正在上传中...",
          });
          for (let temp of tempFilePaths) {
            // 图片上传服务器
            await uni.uploadFile({
              url: this.action,
              filePath: temp,
              name: "file",
              formData: {
                user: "test",
              },

              success: (res) => {
                let data = JSON.parse(res.data);
                // 上传完成后处理
                this.model.Logo = data.data;
                uni.hideLoading();
              },
            });
          }
        },
      });
    },
    enlarge(file) {
      // 全屏
      this.videoContext = uni.createVideoContext("myVideo");
      this.videoContext.requestFullScreen({
        direction: 0,
      });
    },
    videoControl(e) {
      if (e.detail.fullScreen == false) {
        this.videoContext.stop();
        this.controls = false;
      } else {
        this.videoContext.play();
        this.controls = true;
      }
    },
    upvideo() {
      let that = this;
      uni.chooseVideo({
        count: 1,
        sourceType: ["camera", "album"],
        success: function (res) {
          console.log(res);
          that.upFile(res.tempFilePath, 1);
          uni.showLoading({
            title: "上传中...",
          });
        },
        fail(err) {
          console.log(err);
        },
      });
    },
    upFile(filePath, type) {
      let that = this;
      uni.uploadFile({
        url: that.action,
        filePath: filePath,
        name: "file",
        formData: {
          user: "tesdt",
        },
        success: (uploadFileRes) => {
          uni.hideLoading();
          if (uploadFileRes.statusCode == 200) {
            let data = JSON.parse(uploadFileRes.data);
            that.model.VideoUrl = data.data;
          }
        },
        fail: function (res) {
          wx.showToast({
            title: "上传失败!",
            icon: "none",
            duration: 1000,
          });
        },
      });
    },
    previewImage(imgs, i) {
      uni.previewImage({
        urls: imgs,
        current: i,
        longPressActions: {
          itemList: ["发送给朋友", "保存图片", "收藏"],
          success: function (data) {},
          fail: function (err) {
            console.log(err.errMsg);
          },
        },
      });
    },
    //打开地图
    getAddress() {
      let that = this;
      uni.chooseLocation({
        success: function (res) {
          console.log(res);
          that.model.Address = res.name;
          that.model.LatAndLon = res.latitude + "," + res.longitude;
        },
        fail: function (err) {
          that.fetchAgainLocation();
        },
      });
    },
    //重新提示用户打开设置对地图授权
    fetchAgainLocation() {
      let that = this;
      wx.getSetting({
        success: (res) => {
          var statu = res.authSetting;
          if (!statu["scope.userLocation"]) {
            wx.showModal({
              title: "是否授权当前位置",
              content:
                "需要获取您的地理位置，请确认授权，否则地图功能将无法使用",
              success: (tip) => {
                if (tip.confirm) {
                  console.log(tip);
                  wx.openSetting({
                    success: (data) => {
                      console.log(data);
                      if (data.authSetting["scope.userLocation"] === true) {
                        wx.showToast({
                          title: "授权成功",
                          icon: "success",
                          duration: 1000,
                        });
                        if (that.latitude != "" && that.longitude != "") {
                          that.getAddress();
                        } else {
                          that.getAddress();
                        }
                      } else {
                        wx.showToast({
                          title: "授权失败",
                          duration: 1000,
                        });
                      }
                    },
                    fail: (err) => {
                      console.log(err);
                    },
                    complete: () => {},
                  });
                }
              },
            });
          }
        },
        fail: () => {},
        complete: () => {},
      });
    },
    confirmOpenTime(r) {
      this.model.OpenTime = r.year + "-" + r.month + "-" + r.day;
    },
    addMetroList() {
      let obj = {
        MetroNum: "",
        MetroName: "",
        Distance: "",
      };
      this.MetroList.push(obj);
    },

    //删除地铁信息
    delCarrier(index) {
      this.MetroList.splice(index, 1);
    },
    gobrandsearch() {
      //跳转到品牌搜索页面
      uni.navigateTo({
        url: "/pages/kotra/brandSearch?type=2",
      });
    },
    carrierSubmit() {
      if (this.model.CarrierName == ""||!this.model.CarrierName) {
        uni.showToast({ title: "请输入载体名", icon: "none" });
        return;
      }
      if (this.model.Developers == ""||!this.model.Developers) {
        uni.showToast({ title: "请输入开发商", icon: "none" });
        return;
      }
      if (this.model.Address == ""||!this.model.Address) {
        uni.showToast({ title: "请输入载体地址", icon: "none" });
        return;
      }
      if (this.model.Logo == ""||!this.model.Logo) {
        uni.showToast({ title: "请上传Logo", icon: "none" });
        return;
      }
      if (this.model.BannerList.length == 0||!this.model.BannerList) {
        uni.showToast({ title: "请上传品牌介绍图", icon: "none" });
        return;
      }

      // if (this.model.CarNum == "") {
      //   this.model.CarNum = 0;
      // }
      if (this.model.OpenTime == ""||!this.model.OpenTime) {
        uni.showToast({ title: "请输入开业时间", icon: "none" });
        return;
      }
      if (this.model.CategoryId == ""||!this.model.CategoryId) {
        uni.showToast({ title: "请选择载体类型", icon: "none" });
        return;
      }
      if (this.model.BuiltUpArea == "" || this.model.BuiltUpArea === 0|| !this.model.BuiltUpArea) {
        uni.showToast({ title: "请输入经营面积", icon: "none" });
        return;
      }
      if (
        this.model.AreaRequirement == "" ||
        this.model.AreaRequirement === 0 ||
        !this.model.AreaRequirement
      ) {
        uni.showToast({ title: "请输入可租赁面积", icon: "none" });
        return;
      }
      if (this.model.CarrierSize == ""||!this.model.CarrierSize) {
        uni.showToast({ title: "请输入商业体量", icon: "none" });
        return;
      }
      console.log(this.model, "保存");
      uni.showLoading({
        title: "提交中...",
      });
      this.model.CarrierMetroList = this.MetroList;
      let parms = {
        url: "/api/AppletTrade/SetCarrierEnterpriseApplyFor",
        data: this.model,
      };
      if (this.datas.CompanyStatus && this.datas.CompanyStatus == 1) {
        parms = {
          url: "/api/AppletTrade/SetBuildingCarrierUpdate",
          data: this.model,
        };
      }
      this.request2(parms, (res) => {
        //认证 - 保存载体信息
        if (res.resultCode == 1) {
          uni.hideLoading();
          uni.showToast({ title: res.message, icon: "none" });
		  this.$emit('finish')
          // setTimeout(() => {
          //   uni.navigateBack();
          // }, 1500);
        }
      });
    },
    goback() {
      uni.navigateBack();
    },
    GetAuthenticationCategoryEnumList() {
      this.request2(
        {
          url: "/api/AppletTrade/GetAuthenticationCategoryEnumList",
          data: { Name: "", Id: "" },
        },
        (res) => {
          if (res.resultCode == 1) {
            this.shenList = res.data;

            if (this.model.FirstShopNumList&&this.model.FirstShopNumList.length === 0) {
              this.shenList.map((item) => {
                let obj = {
                  Id: item.Id,
                  Name: item.Name,
                  Num: 0,
                };
                this.model.FirstShopNumList.push(obj);
              });
            }
            // else if (this.model.FirstShopNumList.length > 0) {
            //   this.shenList.map((item) => {
            //     let obj = {
            //       Id: item.Id,
            //       Name: item.Name,
            //       Num: 0,
            //     };
            //     this.mdel.FirstShopNumList.push(obj);
            //   });
            // }

            if (this.isdisabled == true) {
              this.shenList.map((x) => {
                if (x.Id == this.model.Category) {
                  this.CategoryName = x.Name;
                  return;
                }
              });
            }
          }
        }
      );
    },
    clickFirstShop(e, currentIndex) {
      let index = parseInt(e.detail.value);
      //   //类别
      this.model.FirstShopNumList[currentIndex].Id = this.shenList[index].Id;
      this.model.FirstShopNumList[currentIndex].Name =
        this.shenList[index].Name;
    },
    addFirstShop() {
      this.model.FirstShopNumList.push({ Id: 0, Name: "", Num: 0 });
    },
    delFirstShop(index) {
      this.model.FirstShopNumList.splice(index, 1);
    },
  },
};
</script>
