<template>
  <div class="home_wrapper">
    <!--  头部开始  -->
    <div class="header">
<!--      @click="onClickLeft"-->
      <div class="header_left" v-if="navDis == 'none'" @click="loginType='',navDis = 'block',loginDis = 'none'">
        <img src="../../../static/images/agriculturalTrusteeship/return.png">
      </div>
      <div class="header_left" v-if="navDis == 'block'" @click="loginType='',$router.push({ path: '/agriculturalTrusteeship/index' })">
        <img src="../../../static/images/agriculturalTrusteeship/return.png">
      </div>
      <div class="tit">
        <p>大托管服务中心</p>
        <p>{{loginType=='mj'?'会员登录':loginType=='fwzz'?'社会化服务组织':loginType=='bxjg'?'保险机构':loginType=='dkjg'?'金融机构':loginType=='ndjg'?'农担机构':'登录注册'}}</p>
      </div>
    </div>
    <!--  头部结束  -->

    <!--  登陆选择开始  -->
    <div class="main" :style="{'display': navDis}">
      <div class="nav">
        <div class="nav_content" style="padding: 12.5px 0;" @click="loginType = 'mj',navDis = 'none',loginDis = 'block'" >
          <div>
            <p class="nav_name_01">会员登录</p>
<!--            <p class="nav_text">登录后支持下单操作</p>-->
          </div>
          <i class="go"></i>
        </div>
      </div>

      <div class="nav">
        <div class="nav_content" style="padding: 12.5px 0;" @click="loginType = 'fwzz',navDis = 'none',loginDis = 'block'" >
          <div>
            <p class="nav_name_02">社会化服务组织登录</p>
<!--            <p class="nav_text">登录发布社会化服务及相关产品</p>-->
          </div>
          <i class="go"></i>
        </div>
      </div>

      <div class="nav">
        <div class="nav_content" style="padding: 12.5px 0 30px;" @click="financialType = '2' ,loginType = 'bxjg',navDis = 'none',loginDis = 'block'">
          <div>
            <p class="nav_name_03">保险机构登录</p>
<!--            <p class="nav_text">登录可发布保险产品</p>-->
          </div>
          <i class="go"></i>
        </div>
        <div class="nav_content" style="padding: 30px 0 ;border-top: 1px solid #D5D8DE;border-bottom: 1px solid #D5D8DE;" @click="financialType = '1' ,loginType = 'dkjg',navDis = 'none',loginDis = 'block'">
          <div>
            <p class="nav_name_04">金融机构登录</p>
<!--            <p class="nav_text">登录可发布贷款产品</p>-->
          </div>
          <i class="go"></i>
        </div>
        <div class="nav_content" style="padding: 30px 0 12.5px;" @click="financialType = '3' ,loginType = 'ndjg',navDis = 'none',loginDis = 'block'">
          <div>
            <p class="nav_name_05">农担机构登录</p>
<!--            <p class="nav_text">登录可发布农担产品</p>-->
          </div>
          <i class="go"></i>
        </div>
      </div>
    </div>
    <!--  登陆选择结束  -->

    <!--  登录开始  -->
    <div class="login_main" :style="{'display': loginDis , 'position': position,'top':top,'transform':transform,'left':left}">
      <van-tabs v-model="active" animated color="#1E67FF" background="transparent" title-active-color="#1E67FF" @change="tabsChange">
        <van-tab name="login" title="登录">
          <van-field v-model="username" center :border="false" placeholder="请输入账号" >
            <template #left-icon>
              <img src="../../../static/images/agriculturalTrusteeship/login/register_01.png" alt="">
            </template>
          </van-field>
          <van-field v-model="password" type="password" center :border="false" placeholder="请输入密码">
            <template #left-icon>
              <img src="../../../static/images/agriculturalTrusteeship/login/register_02.png" alt="">
            </template>
          </van-field>
          <div v-if="loginType == 'mj'">
            <van-field
              v-model="formData.code"
              center
              clearable
              label="验证码"
              placeholder="图形验证码"
            >
              <template #button>
                <img style="width: 100px" :src="codeUrl" @click="getCode" />
              </template>
            </van-field>
            <van-checkbox style="float: left;margin-top:10px;" v-model="formData.rememberMe" shape="square">{{showMessage ? "记住手机号" : "记住密码"}}</van-checkbox>
            <p style="float: right;margin-top:10px;color:#1D6FE9 ">忘记密码</p>
            <div class="clear"></div>
          </div>
<!--          $router.push({name:'agriculturalTrusteeshipShopList'})-->
          <p class="submit_btn" v-if="loginType == 'mj'" @click="handleLogin">登录</p>
          <p class="submit_btn" v-else @click="goLogin">登录</p>
        </van-tab>
        <van-tab name="register" title="注册" v-if="loginType != 'mj'">
        <!--保险机构注册-->
          <van-form @submit="goRegister" ref="formData" show-error :show-error-message="false">

            <template v-if="loginType == 'bxjg' || loginType == 'dkjg' || loginType == 'ndjg'">
              <van-field v-model="serviceForm.financialName" required :rules="[{ required: true }]" center :border="false" placeholder="请输入机构名称" >
                <template #left-icon>
                  <img src="../../../static/images/agriculturalTrusteeship/login/register_01.png" alt="">
                </template>
              </van-field>
              <van-field v-model="serviceForm.linker" required :rules="[{ required: true }]" center :border="false" placeholder="请输入联系人">
                <template #left-icon>
                  <img src="../../../static/images/agriculturalTrusteeship/login/register_04.png" alt="">
                </template>
              </van-field>
              <van-field v-model="serviceForm.phone" required :rules="[{ required: true }]" center :border="false" placeholder="请输入电话">
                <template #left-icon>
                  <img src="../../../static/images/agriculturalTrusteeship/login/register_07.png" alt="">
                </template>
              </van-field>
              <van-field v-model="serviceForm.address" required :rules="[{ required: true }]" center :border="false" placeholder="请输入地址" >
                <template #left-icon>
                  <img src="../../../static/images/agriculturalTrusteeship/login/register_02.png" alt="">
                </template>
              </van-field>

              <van-field v-model="serviceForm.username" required :rules="[{ required: true }]" center :border="false" placeholder="请输入登录账号" >
                <template #left-icon>
                  <img src="../../../static/images/agriculturalTrusteeship/login/register_06.png" alt="">
                </template>
              </van-field>
              <van-field v-model="serviceForm.password" required :rules="[{ required: true }]" center :border="false" placeholder="请输入登录密码" >
                <template #left-icon>
                  <img src="../../../static/images/agriculturalTrusteeship/login/register_08.png" alt="">
                </template>
              </van-field>
              <van-field v-model="serviceForm.passwordReal" required :rules="[{ required: true }]" center :border="false" placeholder="请再次输入密码">
                <template #left-icon>
                  <img src="../../../static/images/agriculturalTrusteeship/login/register_08.png" alt="">
                </template>
              </van-field>

              <van-field v-model="serviceForm.fax" center :border="false" placeholder="请输入传真">
                <template #left-icon>
                  <img src="../../../static/images/agriculturalTrusteeship/login/register_05.png" alt="">
                </template>
              </van-field>
              <van-field v-model="serviceForm.description" center :border="false" placeholder="请输入简要描述">
                <template #left-icon>
                  <img src="../../../static/images/agriculturalTrusteeship/login/register_03.png" alt="">
                </template>
              </van-field>
              <div style="height: 20PX"></div>
              <van-uploader v-model="mainImgUploader" :after-read="afterReadEvidenceForm" :before-delete="deleteFileEvidenceForm" />
<!--              <MapGisTag ref="clickLoading" :showBtn="true" :message="serviceForm.theGeom" v-on:formSubmit="MapTag"></MapGisTag>-->

            </template>

            <template v-if="loginType == 'fwzz'">
              <van-field v-model="entityForm.entityName" required :rules="[{ required: true }]" center :border="false" placeholder="请输入主体名称" >
                <template #left-icon>
                  <img src="../../../static/images/agriculturalTrusteeship/login/register_01.png" alt="">
                </template>
              </van-field>

              <van-field
                readonly
                clickable
                required
                :rules="[{ required: true }]"
                v-model="statisticsTypeId"
                center
                @click="showStatisticsTypeId = true"
                :border="false"
                right-icon="arrow-down"
                placeholder="请选择主体类别">
                <template #left-icon>
                  <img src="../../../static/images/agriculturalTrusteeship/login/register_02.png" alt="">
                </template>
              </van-field>
              <van-popup v-model="showStatisticsTypeId" position="bottom" get-container="body">
                <van-picker
                  show-toolbar
                  :columns="statisticsTypeIdOptions"
                  @confirm="onConfirmStatisticsTypeId"
                  @cancel="showStatisticsTypeId = false"
                />
              </van-popup>

              <van-field
                readonly
                clickable
                required
                :rules="[{ required: true }]"
                v-model="industryClassificationType"
                center
                @click="showIndustryClassificationType = true"
                :border="false"
                right-icon="arrow-down"
                placeholder="请选择生产种类"
              >
                <template #left-icon>
                  <img src="../../../static/images/agriculturalTrusteeship/login/register_03.png" alt="">
                </template>
              </van-field>
              <van-popup v-model="showIndustryClassificationType" position="bottom" get-container="body">
                <van-picker
                  show-toolbar
                  :columns="industryClassificationTypeOptions"
                  @confirm="onConfirmIndustryClassificationType"
                  @cancel="showIndustryClassificationType = false"
                />
              </van-popup>

              <van-field
                readonly
                clickable
                required
                :rules="[{ required: true }]"
                v-model="modelSocietyType"
                center
                @click="showModelSocietyType = true"
                :border="false"
                right-icon="arrow-down"
                placeholder="请选择示范类型"
              >
                <template #left-icon>
                  <img src="../../../static/images/agriculturalTrusteeship/login/register_04.png" alt="">
                </template>
              </van-field>
              <van-popup v-model="showModelSocietyType" position="bottom" get-container="body">
                <van-picker
                  show-toolbar
                  :columns="modelSocietyTypeOptions"
                  @confirm="onConfirmModelSocietyType"
                  @cancel="showModelSocietyType = false"
                />
              </van-popup>

              <van-field
                readonly
                clickable
                required
                :rules="[{ required: true }]"
                v-model="deptName"
                placeholder="请选择主体属地"
                @click="showDeptId = true"
                right-icon="arrow-down"
                :border="false"
                label-width="auto"
              >
                <template #left-icon>
                  <img src="../../../static/images/agriculturalTrusteeship/login/register_02.png" alt="">
                </template>
              </van-field>
              <van-popup v-model="showDeptId" position="bottom" get-container="body">
                <van-cascader
                  v-model="villageValue"
                  title="请选择主体属地"
                  :options="deptOptions"
                  @close="showDeptId = false"
                  @change="onConfirmDept"
                  active-color="#1989fa"
                  :field-names="hcAreaInfoFieldName"
                />
              </van-popup>

              <van-field v-model="entityForm.entityAddress" required :rules="[{ required: true }]" center :border="false" placeholder="请输入主体地址" >
                <template #left-icon>
                  <img src="../../../static/images/agriculturalTrusteeship/login/register_02.png" alt="">
                </template>
              </van-field>

              <van-field
                readonly
                clickable
                required
                :rules="[{ required: true }]"
                v-model="entityForm.registerTime"
                center
                @click="showRegisterTime = true"
                :border="false"
                right-icon="arrow-down"
                placeholder="请选择成立时间"
              >
                <template #left-icon>
                  <img src="../../../static/images/agriculturalTrusteeship/login/register_05.png" alt="">
                </template>
              </van-field>
              <van-popup v-model="showRegisterTime" position="bottom" get-container="body">
                <van-datetime-picker
                  v-model="currentDate"
                  type="date"
                  title="选择年月日"
                  show-toolbar
                  @confirm="onConfirmRegisterTime"
                  @cancel="showRegisterTime = false"
                />
              </van-popup>

              <van-field v-model="entityForm.principalName" required :rules="[{ required: true }]" center :border="false" placeholder="请输入负责人姓名">
                <template #left-icon>
                  <img src="../../../static/images/agriculturalTrusteeship/login/register_06.png" alt="">
                </template>
              </van-field>

              <van-field v-model="entityForm.tal" required :rules="[{ required: true }]" center :border="false" placeholder="请输入联系方式">
                <template #left-icon>
                  <img src="../../../static/images/agriculturalTrusteeship/login/register_07.png" alt="">
                </template>
              </van-field>

              <van-field v-model="entityForm.userName" required :rules="[{ required: true }]" center :border="false" placeholder="请输入账号">
                <template #left-icon>
                  <img src="../../../static/images/agriculturalTrusteeship/login/register_06.png" alt="">
                </template>
              </van-field>

              <van-field v-model="entityForm.password" required :rules="[{ required: true }]" center :border="false" placeholder="请输入密码">
                <template #left-icon>
                  <img src="../../../static/images/agriculturalTrusteeship/login/register_08.png" alt="">
                </template>
              </van-field>

              <van-field v-model="entityForm.passwordReal" required :rules="[{ required: true }]" center :border="false" placeholder="请确认密码">
                <template #left-icon>
                  <img src="../../../static/images/agriculturalTrusteeship/login/register_08.png" alt="">
                </template>
              </van-field>

              <div style="height: 20PX"></div>
              <van-uploader v-model="mainImgUploader2" :after-read="afterReadEvidenceEntityForm" :before-delete="deleteFileEvidenceEntityForm" />


<!--              <MapGisTag ref="clickLoading1" :showBtn="true" :message="entityForm.theGeom" v-on:formSubmit="MapTag1"></MapGisTag>-->
            </template>
            <p class="submit_btn" @click="$refs.formData.submit()">提交审核</p>
          </van-form>
        </van-tab>
      </van-tabs>
    </div>
    <!--  登录结束  -->

  </div>
</template>
<script>
  import Cookies from "js-cookie";
  import {getCodeImg, getRegisterSmsCode, registerCheck, registerOn} from "@/api/login";
  import {decrypt, encrypt} from "@/utils/jsencrypt";
  import {serviceLogin, entityLogin, commonUpload , serviceRegister , entityRegister , treeselect} from "@/api/agriculturalTrusteeship";
  // import MapGisTag from "@/components/Map/MapGisTagDTG";
  export default {
    name: "agriculturalTrusteeshipLogin",
    // components: {
    //   MapGisTag
    // },
    data() {
      return {
        active:0,
        value1:'',
        position:'absolute',
        top: '50%',
        transform:'translateY(-50%)',
        left:'4%',
        registerShow:false,
        showMessage:false,
        smsCodeValue:"",
        showKeyboard:false,
        username: "", //账号
        password: "", //密码
        formData: {
          username: "", //账号
          password: "", //密码
          financialType:'2'
        },
        formData2: {
          userName: "", //账号
          password: "", //密码
        },
        loading: false,
        codeUrl: "", //验证码
        isSmsLogin: false, //是否手机验证码
        computeTime: 0,
        navDis:'block',
        loginDis:'none',
        loginType:'',
        serviceForm:{
          mainImg:''
        },//保险公司注册表单
        entityForm:{},//服务组织注册表单
        mainImgArr:[],
        mainImgArrEntity:[],
        mainImgUploader:[],
        mainImgUploader2:[],
        financialType:'',
        statisticsTypeIdOptions : [],
        showStatisticsTypeId : false,
        statisticsTypeId:'',
        industryClassificationType:'',
        showIndustryClassificationType: false,
        industryClassificationTypeOptions: [],
        modelSocietyType:'',
        showModelSocietyType: false,
        modelSocietyTypeOptions: [],
        showRegisterTime :false,
        currentDate:new Date(),
        deptOptions:[],
        deptName:'',
        showDeptId:false,
        villageValue : '',
        hcAreaInfoFieldName: {
          text: "label",
          value: "value",
          children: "children",
        },
      };
    },
    created() {
      this.getDicts("financial_type").then(response => {
        this.financialTypeOptions = response.data;
      });
      this.getDicts("newBusinessEntity_statistics_project").then(response => {
        for (var i = 0; i < response.data.length; i++) {
          this.statisticsTypeIdOptions.push({text: response.data[i].dictLabel, value: response.data[i].dictValue});
        }
      });
      this.getDicts("Industrial_classification_type").then(response => {
        for (var i = 0; i < response.data.length; i++) {
          this.industryClassificationTypeOptions.push({text: response.data[i].dictLabel, value: response.data[i].dictValue});
        }
      });
      this.getDicts("model_society_type").then(response => {
        for (var i = 0; i < response.data.length; i++) {
          this.modelSocietyTypeOptions.push({text: response.data[i].dictLabel, value: response.data[i].dictValue});
        }
      });

      treeselect().then(res=>{
        if (res.code == 200) {
          this.deptOptions = res.data;
        }
      })

      this.getCode();
      this.getCookie();

    },
    methods: {
      // //获取自己返回值
      // /** 查找地图中定位点 */
      // MapTag: function (data) {
      //   this.serviceForm.theGeom = data;
      // },
      // //每个查看修改，新增  方法下引用下面方法
      // mapClickLoading(){
      //   setTimeout(() => {
      //     this.$refs.clickLoading.pointPaceCountryDarw();
      //   }, 500);
      // },
      // //获取自己返回值
      // /** 查找地图中定位点 */
      // MapTag1: function (data) {
      //   this.entityForm.theGeom = data;
      // },
      // //每个查看修改，新增  方法下引用下面方法
      // mapClickLoading1(){
      //   setTimeout(() => {
      //     this.$refs.clickLoading1.pointPaceCountryDarw();
      //   }, 500);
      // },
      goLogin(){
        console.log(this.formData)
        if (this.loginType == 'bxjg' || this.loginType == 'dkjg' || this.loginType == 'ndjg' ){
          Cookies.set("username", encrypt(this.formData.username), { expires: 30 });
          Cookies.set("password", encrypt(this.formData.password), { expires: 30 });

          this.formData.username = encrypt(this.username);
          this.formData.password = encrypt(this.password);
          this.formData.financialType = this.financialType;
          serviceLogin(this.formData).then(response => {
            Cookies.set("ACCESS-SESSION-ID", response.data.id);
            Cookies.set("ServiceInformation", response.data);
            this.$router.push({ path: "/agriculturalTrusteeship/shopList" }).catch(() => {});
          });
        }
        if (this.loginType == 'fwzz' ){
          Cookies.set("username", encrypt(this.formData2.userName), { expires: 30 });
          Cookies.set("password", encrypt(this.formData2.password), { expires: 30 });

          this.formData2.userName = encrypt(this.username);
          this.formData2.password = encrypt(this.password);
          entityLogin(this.formData2).then(response => {
            Cookies.set("ACCESS-SESSION-ID", response.data.id);
            Cookies.set("ServiceInformation", response.data);
            this.$router.push({ path: "/agriculturalTrusteeship/socializationIndex" }).catch(() => {});
          });
        }
      },
      tabsChange(name){
        this.serviceForm = {};
        this.entityForm = {};
        this.statisticsTypeId = '';
        this.industryClassificationType = '';
        this.modelSocietyType = '';
        this.deptName = '';
        this.mainImgArr = [];
        this.mainImgArrEntity = [];
        this.mainImgUploader = [];
        this.mainImgUploader2 = [];
        if ( name == 'register' ){
          this.position = 'relative';
          this.top = '40px';
          this.transform = 'none';
          this.left = '0';
          // if (this.loginType == 'bxjg' || this.loginType == 'dkjg' || this.loginType == 'ndjg'){
          //   this.mapClickLoading()
          // }else if(this.loginType == 'fwzz'){
          //   this.mapClickLoading1()
          // }
        }else if( name == 'login'){
          this.position = 'absolute';
          this.top = '50%';
          this.transform = 'translateY(-50%)';
          this.left = '4%';
        }
      },
      showPopup(){
        this.showKeyboard = !this.showKeyboard
      },
      showMessagePop(){
        this.showMessage = !this.showMessage
      },
      getCode() {
        getCodeImg().then((res) => {
          this.formData.uuid = res.uuid;
          this.codeUrl = "data:image/gif;base64," + res.img;
        });
      },
      getCookie() {
        const username = Cookies.get("username");
        const password = Cookies.get("password");
        const rememberMe = Cookies.get("rememberMe");
        this.formData = {
          username: username === undefined ? this.formData.username : username,
          password:
            password === undefined ? this.formData.password : decrypt(password),
          rememberMe: rememberMe === undefined ? false : Boolean(rememberMe),
        };
      },
      getSmsCode() {
        if (this.formData.code == "") {
          this.$dialog.alert({
            message: '图片验证码不能为空',
          });
          return false;
        }
        if (!this.computeTime) {
          let myreg = /^[1][3,4,5,7,8,9][0-9]{9}$/;
          if (!myreg.test(this.formData.mobile)) {
            this.$dialog.alert({
              message: '手机号格式不正确',
            });
            return false;
          }
          /* getSmsCode(this.formData.mobile).then((res) => {
             if (res.code === 200) {
                this.$dialog.alert({
                 message: '验证码已发送',
               });
               this.showKeyboard = !this.showKeyboard;
               this.loginForm.uuid = res.uuid;
               this.computeTime = 60;
               this.timer = setInterval(() => {
                 this.computeTime--;
                 if (this.computeTime <= 0) {
                   clearInterval(this.timer);
                 }
               }, 1000);
             }
           });*/
        }
      },
      handleLogin(values) {
        this.formData.username = this.username;
        this.formData.password = this.password;
        if (this.isSmsLogin) {
          //短信登录
          let myreg = /^[1][3,4,5,7,8,9][0-9]{9}$/;
          if (!myreg.test(this.formData.mobile)) {
            this.$dialog.alert({
              message: '手机号格式不正确',
            });
            return false;
          } else if (this.formData.smsCode == "") {
            this.$dialog.alert({
              message: '短信验证码不能为空',
            });
            return false;
          }
          this.loading = true;
          this.$store
            .dispatch("SmsLogin", this.formData)
            .then(() => {
              this.$router.push({ path: "/onlineHomeIndex" }).catch(() => {});
            })
            .catch((error) => {
              this.loading = false;
            });
        } else {
          if (this.formData.rememberMe) {
            Cookies.set("username", this.formData.username, { expires: 30 });
            Cookies.set("password", encrypt(this.formData.password), { expires: 30 });
            Cookies.set("rememberMe", this.formData.rememberMe, { expires: 30 });
          } else {
            Cookies.remove("username");
            Cookies.remove("password");
            Cookies.remove("rememberMe");
          }
          //账号密码登录
          if (this.formData.username == "") {
            this.$dialog.alert({
              message: '账号不能为空',
            });
            return false;
          } else if (this.formData.password == "") {
            this.$dialog.alert({
              message: '密码不能为空',
            });
            return false;
          } else if (this.formData.code == "") {
            this.$dialog.alert({
              message: '图片验证码不能为空',
            });
            return false;
          }
          this.$store
            .dispatch("Login", this.formData)
            .then(() => {
              this.$router.push({ path: "/agriculturalTrusteeship/buyerIndex" }).catch(() => {});
            })
            .catch((error) => {
              console.log(error)
              this.loading = false;
              this.getCode();
            });
        }
      },
      getRegisterSmsCode(){
        if (!this.computeTime) {
          let myreg = /^[1][3,4,5,7,8,9][0-9]{9}$/;
          if (!myreg.test(this.formData.mobile)) {
            this.$dialog.alert({
              message: '手机号格式不正确',
            });
            return false;
          }else if (this.formData.code == "") {
            this.$dialog.alert({
              message: '图片验证码不能为空',
            });
            return false;
          }
          if (this.active==2) {
            let formObj = {
              code :this.formData.code,
              mobile:this.formData.mobile,
              uuid:this.formData.uuid
            }
            getRegisterSmsCode(formObj).then((res) => {
              console.log(res)
              console.log(res.code == 200)
              if(res.code == 200) {
                this.$dialog.alert({
                  message: '验证码已发送',
                });
                this.formData.uuid = res.uuid;
                this.computeTime = 60;
                this.timer = setInterval(() => {
                  this.computeTime--;
                  if (this.computeTime <= 0) {
                    clearInterval(this.timer);
                  }
                }, 1000);
              }
            }).catch((res)=>{
              if(res=='Error: 验证码已失效'){
                this.getCode()
              }
            });
          }
        }
      },
      registerSubmit(){

        //注册
        if (this.formData.memberName == "") {
          this.$dialog.alert({
            message: '姓名不能为空',
          });
          return false;
        } else if (this.formData.idcard == "") {
          this.$dialog.alert({
            message: '身份证号不能为空',
          });
          return false;
        } else if (this.formData.mobile == "") {
          this.$dialog.alert({
            message: '手机号码不能为空',
          });
          return false;
        }else if (this.formData.smsCode == "") {
          this.$dialog.alert({
            message: '短信验证码不能为空',
          });
          return false;
        }
        //registerCheck,registerOn
        console.log(this.formData)
        registerCheck(this.formData).then((res)=>{
          if(res.code == 200){
            registerOn(this.formData).then((res)=>{
              if(res.code == 200){
                //
                this.$dialog.alert({
                  message: '您的初始密码：'+res.password,
                }).then(() => {
                  this.$router.push({ path: "/onlineHome/workbench" }).catch(() => {});
                });
              }
            })
          }
        })

      },
      afterReadEvidenceForm(file){
        let params1 = new FormData();
        Cookies.set("ACCESS-SESSION-ID", '0');
        params1.append("file", file.file);
        commonUpload(params1).then((r1) => {
          // this.tEnforceSamplingGoodsList[index].attachement.push(r1.fileName);
          console.log(r1)
          Cookies.remove("ACCESS-SESSION-ID");
          this.mainImgArr.push(r1.fileName)
        })
      },
      deleteFileEvidenceForm(file,detail) {
        this.mainImgArr.splice(detail.index,1);
        this.mainImgUploader.splice(detail.index,1);
      },
      afterReadEvidenceEntityForm(file){
        let params1 = new FormData();
        Cookies.set("ACCESS-SESSION-ID", '0');
        params1.append("file", file.file);
        commonUpload(params1).then((r1) => {
          // this.tEnforceSamplingGoodsList[index].attachement.push(r1.fileName);
          console.log(r1)
          Cookies.remove("ACCESS-SESSION-ID");
          this.mainImgArrEntity.push(r1.fileName)
        })
      },
      deleteFileEvidenceEntityForm(file,detail) {
        this.mainImgArrEntity.splice(detail.index,1);
        this.mainImgUploader2.splice(detail.index,1);
      },
      goRegister(){
        if (this.loginType == 'bxjg' || this.loginType == 'dkjg' || this.loginType == 'ndjg'){
          this.serviceForm.mainImg = this.mainImgArr.join(',');
          this.serviceForm.username = encrypt(this.serviceForm.username);
          this.serviceForm.password = encrypt(this.serviceForm.password);
          this.serviceForm.financialType = this.financialType;
          serviceRegister(this.serviceForm).then(res=>{
            this.$notify({ type: 'success', message: '注册成功' });
            this.active = 0;
          })
        }else if(this.loginType == 'fwzz'){
          this.entityForm.mainImg = this.mainImgArrEntity.join(',');
          this.entityForm.userName = encrypt(this.entityForm.userName);
          this.entityForm.password = encrypt(this.entityForm.password);
          entityRegister(this.entityForm).then(res=>{
            this.$notify({ type: 'success', message: '注册成功' });
            this.active = 0;
          })
        }
        // else if(this.loginType == 'mj'){
        //   this.registerSubmit();
        // }
      },
      onConfirmStatisticsTypeId(data){
        this.entityForm.statisticsTypeId = data.value;
        this.statisticsTypeId = data.text;
        this.showStatisticsTypeId = false;
      },
      onConfirmIndustryClassificationType(data){
        this.entityForm.industryClassificationType = data.value;
        this.industryClassificationType = data.text;
        this.showIndustryClassificationType = false;
      },
      onConfirmModelSocietyType(data){
        this.entityForm.modelSocietyType = data.value;
        this.modelSocietyType = data.text;
        this.showModelSocietyType = false;
      },
      onConfirmRegisterTime(data){
        this.currentDate = data ;
        this.entityForm.registerTime = this.format(data,'yyyy-MM-dd')
        this.showRegisterTime = false;
      },
      //选择案件属地
      onConfirmDept({ selectedOptions }){
        this.entityForm.serviceDeptId = selectedOptions[selectedOptions.length-1].value;
        this.entityForm.serviceDeptName = selectedOptions[selectedOptions.length-1].label;
        this.deptName = selectedOptions[selectedOptions.length-1].label;
        // this.showDeptId = false
      },

      //methods结束处
    },
  }
</script>
<style scoped lang="scss">
.home_wrapper{
  background: url("../../../static/images/agriculturalTrusteeship/login/login_bg.png") no-repeat;
  background-size: 100%;
  height: 100vh;
  overflow-y: scroll;
}
/*头部*/
.header{
  display: flex;
  align-items: start;
  justify-content: space-between;
  padding: 2vh 4% 2vh;
  position: relative;
  .header_left{
    display: flex;
    align-items: center;
    background-color: rgba(0,0,0,0.5);
    width: 30PX;
    height: 30PX;
    justify-content: center;
    border-radius: 100%;
    z-index: 999;
  }
  .tit{
    font-size: .7rem;
    color: #334281;
    text-align: center;
    position: absolute;
    //left: 50%;
    //transform: translateX(-50%);
    width: 92%;
    line-height: 1;
    p{
      &:nth-child(1){
        margin-bottom: 15PX;
      }
    }
  }
}

/*导航*/
  .main{
    position: absolute;
    top: 20vh;
    width: 100%;
  }
  .nav{
    background-color: rgba(255,255,255,0.95);
    width: 92%;
    margin: 0 auto;
    padding: 25PX;
    border-radius: 15PX;
    margin-top: 15PX;
    box-shadow: 0px 5PX 10PX rgba(0,0,0,0.16);
    .nav_content{
      display: flex;
      justify-content: space-between;
      align-items: center;
      p{
        &:nth-child(1){
          font-size: .5rem;
          color: #334281;
          padding-left: 25PX;
        }
        &:nth-child(2){
          color: #626C88;
          margin-top: 10PX;
        }
      }
      .nav_name_01{
        background: url("../../../static/images/agriculturalTrusteeship/login/login_icon_01.png") no-repeat left center;
      }
      .nav_name_02{
        background: url("../../../static/images/agriculturalTrusteeship/login/login_icon_02.png") no-repeat left center;
      }
      .nav_name_03{
        background: url("../../../static/images/agriculturalTrusteeship/login/login_icon_03.png") no-repeat left center;
      }
      .nav_name_04{
        background: url("../../../static/images/agriculturalTrusteeship/login/login_icon_04.png") no-repeat left center;
      }
      .nav_name_05{
        background: url("../../../static/images/agriculturalTrusteeship/login/login_icon_05.png") no-repeat left center;
      }
    }
    .go{
      width: 20PX;
      height: 20PX;
      display: block;
      background: url("../../../static/images/agriculturalTrusteeship/login/login_icon_06.png") no-repeat left center;
    }
  }
  .login_main{
    background-color: rgba(255,255,255,0.95);
    width: 92%;
    margin: 0 auto;
    padding: 25PX;
    padding-top: 15PX;
    border-radius: 15PX;
    box-shadow: 0px 5PX 10PX rgba(0,0,0,0.16);
    /deep/ .van-field__left-icon{
      display: flex;
      align-items: center;
    }
    /deep/ .van-cell{
      background: transparent;
      padding: 5PX 2PX;
      margin-top: 25PX;
      border-bottom: 1px solid #1E67FF;
    }
    .submit_btn{
      width: 50%;
      padding: 8PX 0;
      margin: 25PX auto 0;
      background-image: linear-gradient(to right , #6E93F3 , #7E89E9 , #54C6E4);
      text-align: center;
      font-size: .35rem;
      color: #ffffff;
      border-radius: 50PX;
    }
  }
  /deep/ .van-cell--required::before{
    left: 20PX;
    color: rgb(30, 103, 255);
  }
  /deep/ .van-cell__value{
    padding-left: 10PX;
  }
</style>
