<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.Name"
        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 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="bottom-border">
      <view class="label-text"
        >投运时间<span style="color: #e54d42">*</span></view
      >
      <input
        type="text"
        @click="disabled ? '' : (showOpenTime = true,TimeType=1)"
        v-model="model.OperationTime"
        :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">
				<view style="padding: 10px 0;width: 1px;flex:1">
          <template v-if="CategoryName">
            {{CategoryName}}
          </template>
          <text v-else style="color:#CECECE;">
            请选择楼宇等级
          </text>
        </view>
				<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 >
							<view v-for="(x,y) in goodsType" :key="y" class="u-action-sheet-item u-border-bottom" 
							@click="clickItem(x)" 
							:style="{color:x.ID == model.CategoryId?'#2979ff':'#111',}">
								{{x.ClassName}}
							</view>
						</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.Areas"
          :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.BuildingNum"
        :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.FloorNum"
        :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.ElevatorNum"
        :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.FloorHeight"
        :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
      >
      <input
        type="text"
        v-model="model.PropertyComp"
        :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.SaleOrSelf"
        :disabled="disabled"
        style="padding: 10px 0"
        placeholder="请填写销售自持比例"
        placeholder-style="color:#CECECE;"
      />
    </view>
    <view class="bottom-border">
      <view class="label-text">是否统一运营</view>
      <radio-group @change="radioChange" style="display: flex;padding: 10px 0;">
				<label class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in OperateList" 
        :key="item.value"
        style="display: flex;margin-right: 10px;">
					<view>
						<radio class="radio" :value="item.value" :checked="item.value === model.IsAllOperate" 
            color="#017EDF"/>
					</view>
					<view>{{item.name}}</view>
				</label>
			</radio-group>
    </view>
    <view class="bottom-border">
      <view class="label-text"
        >建设时间<span style="color: #e54d42">*</span></view
      >
      <input
        type="text"
        @click="disabled ? '' : (showOpenTime = true,TimeType=2)"
        v-model="model.ConstructionTime"
        :disabled="true"
        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="number"
          v-model="model.PropertyFee"
          :disabled="disabled"
          style="padding: 10px 0;flex: 1;margin-right: 10px"
          placeholder="请填写物业费"
          placeholder-style="color:#CECECE;"
        />
        <span>元/m²</span>
      </view>
				
		</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="number"
          v-model="model.RentFee"
          :disabled="disabled"
          style="padding: 10px 0;flex: 1;margin-right: 10px;"
          placeholder="请填写月租金"
          placeholder-style="color:#CECECE;"
        />
        <span>元/m²</span>
      </view>
				
		</view>
    <view class="bottom-border">
			<view class="label-text">产业方向</view>
			<textarea
			  style="height: 60px;padding: 10px 0;"
			  v-model="model.IndustryDirection"
			  placeholder="请填写产业方向"
			  :disabled="disabled"
			  maxlength="500"
			  placeholder-style="color:#CECECE;"
			/>
		</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>
			<textarea
			  style="height: 60px;padding: 10px 0;"
			  v-model="model.Other"
			  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="number"
				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" :style="{background:mainColor,boxShadow:`0rpx 4rpx 40rpx 0rpx ${mainColor}94`}" v-if="!disabled">
        <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>
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:"",//	楼宇主键Id	
        Name:"",//	楼宇名称	
        Address:"",//	楼宇位置	
        LatAndLon:"",//	经纬度	
        OperationTime:"",//	投运时间	
        CategoryId:"",//	楼宇等级	
        Areas:"",//	面积	
        BuildingNum:"",//	楼栋数	
        FloorNum:"",//	楼层数	
        ElevatorNum:"",//	电梯数	
        FloorHeight:"",//	层高	
        Developers:"",//	开发商	
        PropertyComp:"",//	物业公司	
        SaleOrSelf:"",//	销售自持比例	
        IsAllOperate: 1,//	是否统一运营(1-是，0-否)	
        ConstructionTime:"",//	建设时间	
        PropertyFee:"",//	物业费(元/㎡)	
        RentFee:"",//	月租金(元/㎡)	
        IndustryDirection:"",//	产业方向	
        BrandDemand:"",//	目标企业招引需求	
        Other:"",//	其他需求	
        ContactName:"",//	联系人	
        ContactPhone:"",//	联系电话	
        BannerList:[],//	楼宇图片	
        CompanyId:"",//	认证id
      },
      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",
      },
      TimeType: 1,
      OperateList:[
        {value: 1,name:'是'},
        {value: 0,name:'否'},
      ],
      showTypeStatus: false,
    };
  },
  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
    ) {
      //判断是否填写过了
      this.model = this.datas.buildingApplyForModel
      this.CategoryName = this.model.CategoryName;
      this.model.CompanyId = this.datas.CompanyId;
      let data = this.datas.buildingApplyForModel;
      // this.model = this.datas.CarrierModel

      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.CategoryId > 0) {
        // this.disabled2 = true;
        
      }
    } else {
      this.model.CompanyId = this.datas.CompanyId
    }
  },
  methods: {
    clickItem(x) {//类型选择
      this.model.CategoryId = x.ID
      this.CategoryName = x.ClassName
      this.showTypeStatus = false
    },
    radioChange(evt) {
      for (let i = 0; i < this.OperateList; i++) {
          if (this.OperateList[i].value === evt.detail.value) {
              this.model.IsAllOperate = i;
              break;
          }
      }
    },
    GetProjectTypeEnumList() {
      this.request2({
						url: "/api/AppletTrade/GetBrandClassList",
						data: {
							BrandCategory: 2
						},
					},
					(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) {
      if(this.TimeType==1) this.model.OperationTime = r.year + "-" + r.month + "-" + r.day;
      else this.model.ConstructionTime = 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.Name == ""||!this.model.Name) {
        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.BannerList.length == 0||!this.model.BannerList) {
        uni.showToast({ title: "请上传品牌介绍图", icon: "none" });
        return;
      }
      if (this.model.OperationTime == ""||!this.model.OperationTime) {
        uni.showToast({ title: "请选择投运时间", icon: "none" });
        return;
      }
      if (this.model.CategoryId==""||!this.model.CategoryId) {
        uni.showToast({ title: "请选择楼宇等级", icon: "none" });
        return;
      }
      if (this.model.Areas == "" || this.model.Areas === 0) {
        uni.showToast({ title: "请输入面积", icon: "none" });
        return;
      }
      if (this.model.PropertyComp == ""||!this.model.PropertyComp) {
        uni.showToast({ title: "请填写物业公司", icon: "none" });
        return;
      }
      if (this.model.ConstructionTime == ""||!this.model.ConstructionTime) {
        uni.showToast({ title: "请选择建设时间", icon: "none" });
        return;
      }
      console.log(this.model, "保存");
      uni.showLoading({
        title: "提交中...",
      });
      this.model.CarrierMetroList = this.MetroList;
      let parms = {
        url: "/api/AppletTrade/SetBuildingApplyFor",
        data: this.model,
      };
      if (this.datas.CompanyStatus && this.datas.CompanyStatus == 1) {
        parms = {
          url: "/api/AppletTrade/SetBuildingServicesUpdate",
          data: this.model,
        };
      }
      this.request2(parms, (res) => {
        //认证 - 保存载体信息
        if (res.resultCode == 1) {
          uni.hideLoading();
          uni.showToast({ title: res.message, icon: "none" });
          // setTimeout(() => {
          //   uni.navigateBack();
          // }, 1500);
		  this.$emit('finish')
        }
      });
    },
    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>
