<template>
  <view class="container">
    <navbar :config="config" backColor="#666666" @onlyLink='onlyLink'></navbar>
    <form @submit="nextStep">
      <!--企业信息-->
      <view v-if="step==0">
        <view class="u-flex u-bg-abc5b5 step-pd">
          <view>
            <text class="iconfont font68">&#xe696;</text>
          </view>
          <view class="u-ml45 u-00321E">
            <view class="u-font28 u-bold">第一步：企业信息</view>
            <view class="u-font22">共两步</view>
          </view>
        </view>
        <view class="bg-fff">
          <view class="u-plr30 pt14">
            <view>
              <text class="vertical-bar">|</text>
              <text class="u-ml10 u-font30 u-060606">企业信息</text>
            </view>
            <view>
              <view class="uni-form-item u-flex ">
                <view class="title u-font28 u-1A1A1A">
                  <required-tag></required-tag>
                  企业名称
                </view>
                <input class="uni-input u-font26" disabled maxlength="16" name="company_name"
                  :value="dataform.company_name" placeholder="请输入企业名称" />
              </view>
              <view class="uni-form-item u-flex ">
                <view class="title u-font28 u-1A1A1A">统一信用代码</view>
                <input class="uni-input u-font26" disabled maxlength='18' name="credit_code"
                  :value="dataform.credit_code" placeholder="请输入统一信用代码" />
              </view>
              <view class="uni-form-item u-flex ">
                <view class="title u-font28 u-1A1A1A">经营范围</view>
                <input class="uni-input u-font26" disabled maxlength='25' name="business_scope"
                  :value="dataform.business_scope" placeholder="请输入经营范围" />
              </view>
              <!-- <picker class="pickerList" mode="multiSelector" :range="newProvinceDataList"
								range-key="label" :value="multiIndex" @change="enterprisePickerChange"
								@columnchange="enterprisePickerColumnchange">
								<view class="uni-form-item u-flex ">
									<view class="title u-font28 u-1A1A1A">所属地区</view>
									<view v-if="dataform.province != '' " class="uni-input u-font26">
										{{dataform.province}}
									</view>
									<view v-if="dataform.province == '' " class="uni-input u-999">请选择省市区</view>
								</view>
							</picker> -->
              <view class="uni-form-item u-flex" @click="openAreaSelect(1)">
                <view class="title u-font28 u-1A1A1A">
                  <required-tag></required-tag>所属地区
                </view>
                <view v-if="dataform.province != '' " class="uni-input u-font26">
                  {{dataform.province}}
                </view>
                <view v-if="dataform.province == '' " class="uni-input u-999">请选择省市区</view>
              </view>
              <view class="uni-form-item u-flex ">
                <view class="title u-font28 u-1A1A1A">详细地址</view>
                <input class="uni-input u-font26" disabled maxlength='25' name="company_address"
                  :value="dataform.company_address" placeholder="详细地址" />
              </view>
            </view>
          </view>
        </view>
        <!--法人信息-->
        <view class="bg-fff u-mt10">
          <view class="u-plr30 pt14">
            <view>
              <text class="vertical-bar">|</text>
              <text class="u-ml10 u-font30 u-060606">法人信息</text>
            </view>
            <view>
              <view class="uni-form-item u-flex ">
                <view class="title u-font28 u-1A1A1A">
                  <required-tag></required-tag>法人姓名
                </view>
                <input class="uni-input u-font26" disabled maxlength='5' name="legal_representative"
                  :value="dataform.legal_representative" placeholder="请输入法人姓名" />
              </view>
              <view class="uni-form-item u-flex-center-sb ">
                <view class="title u-font28 u-1A1A1A">证件类型</view>
                <view>
                  <label class="radio" @click="radio(0)">
                    <radio value="0" style="transform:scale(0.7)" disabled :checked="dataform.id_type==0" />
                    身份证
                  </label>
                  <label class="radio u-ml20" @click="radio(1)">
                    <radio value="1" style="transform:scale(0.7)" disabled :checked="dataform.id_type==1" />
                    护照
                  </label>
                </view>
              </view>
              <view class="uni-form-item u-flex ">
                <view class="title u-font28 u-1A1A1A">证件号码</view>
                <input class="uni-input u-font26" disabled maxlength="18" name="id_number" :value="dataform.id_number"
                  placeholder="请输入证件号码" />
              </view>
              <view class="uni-form-item u-flex ">
                <view class="title u-font28 u-1A1A1A">
                  <required-tag></required-tag>法人手机号
                </view>
                <input class="uni-input u-font26" disabled type="number" name="lr_mobile" maxlength="11"
                  :value="dataform.lr_mobile" placeholder="请输入法人手机号" />
              </view>
              <view class="uni-form-item u-flex ">
                <view class="title u-font28 u-1A1A1A">法人邮箱</view>
                <input class="uni-input u-font26" disabled maxlength='20' name="lr_email" :value="dataform.lr_email"
                  placeholder="请输入法人邮箱" />
              </view>
            </view>
          </view>
        </view>

        <!--上传图片-->
        <view class="bg-fff u-mt10">
          <view class="u-plr30">
            <view class="pt30">
              <text class="vertical-bar">|</text>
              <text class="u-ml10 u-font30 u-060606">上传附件</text>
            </view>
            <view class="u-mt20">
              <view class="">
                <text>营业执照</text>
                <!-- <text class="u-ml10">查看示例图</text> -->
              </view>
              <view class="u-mt25">
                <uploadImg imgCount="2" uploadImgCount="2" :imgArr="business_license_images" :type="upimgtype" url=""
                  @result="resultUrlthree"></uploadImg>
              </view>
            </view>
            <view class="u-mt20">
              <view class="">
                <text>法人申请身份证</text>
                <!-- <text class="u-ml10 u-6087F2">查看示例图(需传身份证正反两面)</text> -->
              </view>
              <view class="u-mt25">
                <uploadImg imgCount="2" uploadImgCount="2" :imgArr="identty_images" :type="upimgtype" url=""
                  @result="resultUrlone"></uploadImg>
              </view>
            </view>
            <view class="btn" v-if="dataform.audit_status !=0">
              <button class="u-btn" v-if="step==0" form-type="submit">填写店铺信息</button>
            </view>
          </view>
        </view>
      </view>
    </form>
    <form @submit="formSubmit">
      <!-- v-if="step==1" -->
      <view v-if="step==1">
        <view class="u-flex u-bg-abc5b5 step-pd" v-if="false">
          <view>
            <text class="iconfont font68">&#xe63b;</text>
          </view>
          <view class="u-ml45 u-00321E">
            <view class="u-font28 u-bold">第二步：店铺信息</view>
            <view class="u-font22">共两步</view>
          </view>
        </view>

        <!--门店信息-->
        <view class="bg-fff">
          <view class="u-plr30">
            <view class="pt30">
              <text class="vertical-bar">|</text>
              <text class="u-ml10 u-font30 u-060606">店铺信息</text>
            </view>
            <view>
              <view class="uni-form-item u-flex ">
                <view class="title u-font28 u-1A1A1A">
                  <required-tag></required-tag>店铺名称
                </view>
                <input class="uni-input u-font26" maxlength='16' name="shop_name" :value="dataform.shop_name"
                  placeholder="请输入店铺名称" />
              </view>
              <!-- <picker class="pickerList" mode="multiSelector" :range="newProvinceDataList"
								range-key="label" :value="multiIndex" @change="pickerChange"
								@columnchange="pickerColumnchange">
								<view class="uni-form-item u-flex ">
									<view class="title u-font28 u-1A1A1A">所属地区</view>
									<view class="uni-input u-font26" v-if="dataform.province_name != '' ">
										{{dataform.province_name}}{{dataform.city_name}}{{dataform.area_name}}
									</view>
									<view v-if="dataform.province_name == '' " class="uni-input u-999">请选择省市区</view>
								</view>
							</picker> -->
              <view class="uni-form-item u-flex" @click="openAreaSelect(2)">
                <view class="title u-font28 u-1A1A1A">
                  <required-tag></required-tag>所属地区
                </view>
                <view class="uni-input u-font26" v-if="dataform.province_name != '' ">
                  {{dataform.province_name}}{{dataform.city_name}}{{dataform.area_name}}
                </view>
                <view v-if="dataform.province_name == '' " class="uni-input u-999">请选择省市区</view>
              </view>
              <!-- <view class="uni-form-item u-flex " @click="streetChange">
								<view class="title u-font28 u-1A1A1A">所属街道</view>
								<view v-if="dataform.street_name " class="uni-input u-font26">{{dataform.street_name}}
								</view>
								<view v-else class="uni-input u-999">请选择街道</view>
							</view>
							<view class="uni-form-item u-flex " @click="communityChange">
								<view class="title u-font28 u-1A1A1A">所属社区</view>
								<view v-if="dataform.community_code" class="uni-input u-font26">
									{{dataform.community_name}}
								</view>
								<view v-else class="uni-input u-999">请选择社区</view>
							</view> -->


              <view class="uni-form-item u-flex ">
                <view class="title u-font28 u-1A1A1A">详细地址</view>
                <input class="uni-input u-font26" maxlength='20' name="address" :value="dataform.address" type="button"
                  placeholder="详细地址" />
              </view>
              <view class="uni-form-item u-flex-center-sb " @click="goMap">
                <view class="title u-font28 u-1A1A1A">店铺地图选址</view>
                <view class="iconfont" v-if="showSelected==false">&#xe6db;</view>
                <view v-if="showSelected==true">已选</view>
              </view>
              <view class="uni-form-item u-flex ">
                <view class="title u-font28 u-1A1A1A">
                  <required-tag></required-tag>客服电话
                </view>
                <input class="uni-input u-font26" maxlength="11" name="customer_service_phone"
                  :value="dataform.customer_service_phone" placeholder="请输入客服电话" />
              </view>
              <view class="uni-form-item u-flex ">
                <view class="title u-font28 u-1A1A1A">营业时间</view>
                <input class="uni-input u-font26" maxlength="26" name="business_hours" disabled @click="goWeeks()"
                  :value="dataform.business_hours" placeholder="选择营业时间" />
              </view>
              <view class="uni-form-item u-flex ">
                <view class="title u-font28 u-1A1A1A">营业时间段</view>
                <picker mode="time" :value="beginTime" @change="beginTimeChange">
                  <input class="uni-input u-font26" name="beginTime" disabled :value="beginTime" placeholder="开始时间"
                    style="width: 180rpx;" />
                </picker>
                <picker mode="time" :value="endTime" @change="endTimeChange" class="u-ml20">
                  <input class="uni-input u-font26" name="endTime" disabled :value="endTime" placeholder="结束时间"
                    style="width: 180rpx;" />
                </picker>
              </view>


              <view class="uni-form-item u-flex ">
                <view class="title u-font28 u-1A1A1A">商业主体名称</view>
                <input class="uni-input u-font26" maxlength='20' name="main_name" :value="dataform.main_name"
                  placeholder="请输入商业主体名称" />
              </view>
              <view class="uni-form-item u-flex ">
                <view class="title u-font28 u-1A1A1A">运营人姓名</view>
                <input class="uni-input u-font26" maxlength='5' name="loser" :value="dataform.loser"
                  placeholder="请输入运营人姓名" />
              </view>
              <view class="uni-form-item u-flex ">
                <view class="title u-font28 u-1A1A1A">运营人手机号</view>
                <input class="uni-input u-font26" type="number" maxlength='11' name="mobile" :value="dataform.mobile"
                  placeholder="请输入运营人手机号" />
              </view>

              <template v-if="settleMode == 1">
                <view class="uni-form-item u-flex ">
                  <view class="title u-font28 u-1A1A1A" style="width: 300rpx;">门店打赏比例</view>
                  <input class="uni-input u-font26" max="100" name="reward_ratio" :value="dataform.reward_ratio"
                    placeholder="请输入门店打赏比例" />（%）
                </view>

                <view class="uni-form-textarea">
                  <view>优惠介绍</view>
                  <textarea class="textarea" maxlength='400' name="special_offers" :value="dataform.special_offers"
                    placeholder="请输入优惠介绍"></textarea>
                </view>
              </template>

              <view class="uni-form-textarea">
                <view>店铺介绍</view>
                <textarea class="textarea" maxlength='400' name="remark" :value="dataform.remark"
                  placeholder="请输入店铺介绍"></textarea>
              </view>
              <view class="uni-form-textarea">
                <view>场地说明</view>
                <textarea class="textarea" maxlength='200' name="place_remark" :value="dataform.place_remark"
                  placeholder="请输入场地说明"></textarea>
              </view>
            </view>
          </view>
        </view>

        <!--上传图片-->
        <view class="bg-fff u-mt10">
          <view class="u-plr30">
            <view class="pt30">
              <text class="vertical-bar">|</text>
              <text class="u-ml10 u-font30 u-060606">申请材料</text>
            </view>
            <view class="u-mt20">
              <view class="">
                <text>
                  <required-tag></required-tag>店铺logo
                </text>
                <!-- <text class="u-ml10">查看示例图</text> -->
              </view>
              <view class="u-mt25">
                <uploadImg imgCount="1" :imgArr="logo" :type="upimgtype" url="" @result="resultUrlLogo">
                </uploadImg>
              </view>
            </view>
            <view class="u-mt20">
              <view class="">
                <text>店铺图片</text>
                <!-- <text class="u-ml10">查看示例图</text> -->
              </view>
              <view class="u-mt25">
                <uploadImg imgCount="2" :imgArr="store_images" :type="upimgtype" url="" @result="resultUrltwo"
                  uploadImgCount="2"></uploadImg>
              </view>
            </view>
            <view class="u-flex-center u-mt25">
              <view class="check u-mr10" @click="aggrementCheck">
                <text class="iconfont iconbox u-font32 u-FF0000 " v-if="checkAggrement">&#xe646;</text>
                <view class="radios" v-else></view>
              </view>
              <text class="u-006BC9 u-font24" @click="linkAgreement">勾选注册协议及隐私声明</text>
            </view>
            <view class="btn" v-if="dataform.audit_status !=0">
              <button class="u-btn" form-type="submit" v-if="step==1">立即提交</button>
            </view>
          </view>
        </view>
      </view>
    </form>

    <u-popup mode="bottom" v-model="weekShow" ref="weeksOpen">
      <view class="u-bg-fff u-p30">
        <view class="week" :class="{ checkedYes: checkedArrey.indexOf(item) != -1 }" v-for="(item,index) in weeks"
          :key="index" @click="appointment(item)">
          <view>{{item}}</view>
        </view>
        <view>
          <button class="weeks-btn" @click="gbClose()">确定</button>
        </view>
      </view>
    </u-popup>
    <!-- 地区 -->
    <u-select v-model="areaShow" mode="mutil-column-auto" :list="newProvinceDataList" @confirm="areaConfirm">
    </u-select>
    <!-- 街道弹窗 -->
    <u-select v-model="streetShow" mode="single-column" :list="streetList" @confirm="streetConfirm"></u-select>
    <!-- 社区弹窗 -->
    <u-select v-model="communityShow" mode="single-column" :list="communityList" @confirm="communityConfirm">
    </u-select>
  </view>
</template>

<script>
  import uploadImg from "../../../components/uploadImg/imgUpload.vue"
  import uniPopup from "../../../components/uni-popup/uni-popup.vue"
  import {
    cos
  } from "mathjs"
  export default {
    components: {
      uploadImg,
      uniPopup
    },
    data() {
      return {
        config: {
          back: true, //false是tolbar页面 是则不写
          title: '店铺管理',
          color: '#1A1A1A',
          //背景颜色;参数一透明度（0-1）;参数二背景颜色（array则为线性渐变，string为单色背景）
          backgroundColor: [1, "#fff"],
          statusBarFontColor: '#1A1A1A',
          onlyMy: true
        },
        upimgtype: 'other',
        step: 1, //0 显示企业，1显示店铺
        certificateType: null,
        oldpProvinceDataList: [],
        newProvinceDataList: [
          // [],
          // [],
          // []
        ],
        multiIndex: [0, 0, 0],
        dataform: {
          company_name: '', //企业名称
          credit_code: '', //统一信用代码
          business_scope: '', //经营范围
          province: '', //企业省市区
          company_address: '', //企业地址
          legal_representative: '', //法人姓名
          id_type: null, //法人代证件类型（0身份证、1护照）
          id_number: '', //法代证件号码
          lr_mobile: '', //法人手机号
          lr_email: '', //法代邮箱
          mobile: "", //手机
          identity_code: "", //身份证号
          shop_name: "", //店铺名
          main_name: '', //主体名称
          loser: '', //运营人姓名
          province_name: "", //省的名称
          province_code: "", //省编号
          city_code: "", //市编号
          city_name: "", //市名称
          area_name: "", //区名称
          area_code: "", //区编号
          address: "", //详细地址
          map_punctuation: '', //店铺地图选址
          business_hours: "", //营业时间
          time_quantum: '', //时间段
          customer_service_phone: '', //客服电话
          remark: "", //店铺介绍
          place_remark: '', //场地说明
          noticeItems: "", //注意事项
          tx_longitude: "", //微信经度
          tx_latitude: "", //微信纬度
          logo: "", //店铺logo
          store_images: "", //门店图片
          business_license_images: "", //商家经营执照
          identty_images: "", //身份证下反面
        },
        showSelected: false,
        checkAggrement: true,
        audit_status: "1", //审核状态（0待审核，1审核通过，2审核不通过）
        checkedArrey: [],
        weeks: ['周一', '周二', '周三', '周四', '周五', '周六', '周日', ],
        beginTime: "",
        endTime: "",
        logo: [], //店铺logo
        store_images: [], //门店图片
        business_license_images: [], //商家经营执照
        identty_images: [], //身份证下反面
        streetList: [],
        communityList: [],
        areaShow: false,
        streetShow: false,
        communityShow: false,
        areaShowType: 1, //弹窗类型  1 企业信息地区   2商家地区
        weekShow: false,
        settleMode: 0, // 入驻方式 0 线上 1 联盟
      }
    },
    //写这监听滑动事件，是为了点击填写店铺信息资料时，回到顶部
    onPageScroll(e) {
      if (e.scrollTop > 300) {
        this.floorstatus = true
      } else {
        this.floorstatus = false
      }
    },
    onLoad(options) {

      let that = this;
      if (options.type) {
        //1 审核不通过
        if (options.type == 1) {
          this.getUserInfo()
        }
      }
      if (options.settleMode) {
        this.settleMode = options.settleMode
      }
      //获取省市区
      this.$http.get('/cnarea/tree-lbs', {}).then(async res => {
        let provincesList = res.tree.children;
        // for (let i = 0; i < provincesList.length; i++) {
        // 	this.newProvinceDataList[0].push(provincesList[i]);
        // 	for (let c = 0; c < provincesList[i].children.length; c++) {
        // 		this.newProvinceDataList[1].push(provincesList[i].children[c]);
        // 		if (provincesList[i].children[c].children) {
        // 			for (let a = 0; a < provincesList[i].children[c].children.length; a++) {
        // 				this.newProvinceDataList[2].push(provincesList[i].children[c].children[a]);
        // 			}
        // 		} else {
        // 			this.newProvinceDataList[2] = [];
        // 		}
        // 	}
        // }
        this.newProvinceDataList = provincesList
        that.oldpProvinceDataList = provincesList;
      })
    },

    methods: {
      // 协议勾选
      aggrementCheck() {
        this.checkAggrement = !this.checkAggrement
      },
      linkAgreement() {
        uni.navigateTo({
          url: '/pages/user/agreement?type=2'
        })
      },
      openAreaSelect(num) {
        this.areaShow = true;
        this.areaShowType = num;
      },
      // 获取地区
      areaConfirm(e) {
        if (e.length > 0) {
          if (this.areaShowType == 1) {
            this.dataform.province = e[0].label + e[1].label + e[2].label
          } else {
            this.dataform.province_name = e[0].label;
            this.dataform.province_code = e[0].value;
            this.dataform.city_name = e[1].label;
            this.dataform.city_code = e[1].value;
            this.dataform.area_name = e[2].label;
            this.dataform.area_code = e[2].value;
            this.getAreaList(this.dataform.area_code, 'street');
            this.dataform.street_name = "";
            this.dataform.street_code = "";
            this.dataform.community_name = "";
            this.dataform.community_code = ""
          }
        }
      },
      // 获取街道列表
      getAreaList(parentCode, type) {
        this.$http.get(`/cnarea/lbs-children/${parentCode}`, {}).then(res => {
          if (res && res.code == 200) {
            if (type == 'street') {
              this.streetList = res.list;
              // this.getAreaList(this.streetList[this.streetListIndex].value,'community');
            } else {
              this.communityList = res.list;
            }
          }
        });
      },
      // 选择街道
      streetConfirm(e) {
        if (e.length > 0) {
          this.dataform.street_name = e[0].label;
          this.dataform.street_code = e[0].value;
          this.getAreaList(this.dataform.street_code, 'community')
        } else {
          this.dataform.street_name = null;
          this.dataform.street_code = null;
          this.communityList = [];
        }
        this.dataform.community_name = "";
        this.dataform.community_code = ""
      },
      // 选择社区
      communityConfirm(e) {
        if (e.length > 0) {
          this.dataform.community_name = e[0].label;
          this.dataform.community_code = e[0].value
        } else {
          this.dataform.community_name = null;
          this.dataform.community_code = null;
        }
      },
      onlyLink(e) {
        if (e == 1) {
          if (this.step == 1) {
            this.step = 0
          } else if (this.step == 0) {
            uni.navigateBack({
              delta: 1
            })
          }
        }
      },
      getUserInfo() {
        //获取店铺信息
        this.$http.get('/yxt/shop/my-shop', {
          union_business: true
        }).then(res => {
          if (res && res.code == 200 && res.data) {
            this.dataform = res.data
            //将字符串转成图片数组
            if (res.data.logo) {
              this.logo = res.data.logo.split(',')
            }
            if (res.data.business_license_images) {
              this.business_license_images = res.data.business_license_images.split(',')
            }
            if (res.data.identty_images) {
              this.identty_images = res.data.identty_images.split(',')
            }
            if (res.data.store_images) {
              this.store_images = res.data.store_images.split(',')
            }
            //拆分时间
            if (res.data.time_quantum) {
              this.beginTime = res.data.time_quantum.split('-')[0]
              this.endTime = res.data.time_quantum.split('-')[1]
            }
            if (res.data.tx_longitude) {
              this.showSelected = true
            }
          }
        })
      },
      //上传身份证
      resultUrlone(e) {
        this.identty_images = e
      },
      //上传店铺logo
      resultUrlLogo(e) {
        this.logo = e
      },
      //上传门店
      resultUrltwo(e) {
        this.store_images = e
      },
      //上传营业执照
      resultUrlthree(e) {
        this.business_license_images = e
      },
      //证件类型
      radio(e) {
        this.dataform.id_type = e
      },
      //步骤e
      nextStep(e) {
        let target = e.detail.value;
        if (!target.company_name) {
          this.$mUtil.toast('请输入企业名称')
          return false
        }
        // if (!target.credit_code) {
        //   this.$mUtil.toast('请输入统一信用代码')
        //   return false
        // }
        // if (!target.business_scope) {
        //   this.$mUtil.toast('请输入经营范围')
        //   return false
        // }
        if (!this.dataform.province) {
          this.$mUtil.toast('请选择省市区')
          return false
        }
        // if (!target.company_address) {
        //   this.$mUtil.toast('请输入企业地址')
        //   return false
        // }
        if (!target.legal_representative) {
          this.$mUtil.toast('请输入法人姓名')
          return false
        }
        // if (this.dataform.id_type == null) {
        //   this.$mUtil.toast('请选择法人证件类型')
        //   return false
        // }
        // if (!target.id_number) {
        //   this.$mUtil.toast('请输入法人证件号码')
        //   return false
        // }
        if (!target.lr_mobile) {
          this.$mUtil.toast('请输入法人手机号')
          return false
        }
        if (!(target.lr_mobile.match(this.$mConfig.telRegex))) {
          this.$mUtil.toast('请输入正确手机号')
          return false
        }
        // if (!target.lr_email) {
        //   this.$mUtil.toast('请输入法人邮箱')
        //   return false
        // }
        if (target.lr_email && !target.lr_email.match(this.$mConfig.mailVerify)) {
          this.$mUtil.toast('请输入正确邮箱')
          return false
        }
        // if (this.business_license_images == '') {
        //   this.$mUtil.toast('请上传营业执照')
        //   return false
        // }
        // if (this.identty_images == '') {
        //   this.$mUtil.toast('请上传法人身份证(正反面)')
        //   return false
        // }
        // if (this.identty_images.length < 2) {
        //   this.$mUtil.toast('请上传法人身份证(正反面)')
        //   return false
        // }
        //将图片转换字符串
        this.dataform.company_name = target.company_name
        this.dataform.credit_code = target.credit_code
        this.dataform.business_scope = target.business_scope
        this.dataform.company_address = target.company_address
        this.dataform.legal_representative = target.legal_representative
        this.dataform.id_number = target.id_number
        this.dataform.lr_mobile = target.lr_mobile
        this.dataform.lr_email = target.lr_email
        this.dataform.business_license_images = this.business_license_images.join(',')
        this.dataform.identty_images = this.identty_images.join(',')
        if (uni.pageScrollTo) {
          uni.pageScrollTo({
            scrollTop: 0
          })
        } else {
          uni.showModal({
            title: '提示',
            content: '当前微信版本过低，无法使用该功能，请升级到最新微信版本后重试。'
          })
        }
        this.step = 1
      },
      //跳转到地图
      goMap() {
        uni.chooseLocation({
          success: (res) => {
            if (res.address) {
              this.dataform.map_punctuation = res.address;
              this.dataform.tx_latitude = res.latitude
              this.dataform.tx_longitude = res.longitude
              this.showSelected = true
            } else {
              this.showSelected = false
            }
          },
        })
      },
      //点击选择营业时间
      goWeeks() {
        // this.$refs.weeksOpen.open()
        this.weekShow = true;
      },
      //点击关闭
      gbClose() {
        this.$refs.weeksOpen.close()
        this.dataform.business_hours = this.checkedArrey.join(',')
      },
      appointment(value) {
        if (this.checkedArrey.indexOf(value) != -1) {
          this.checkedArrey.splice(this.checkedArrey.indexOf(value), 1);
        } else {
          this.checkedArrey.push(value);
        }
      },
      beginTimeChange(e) {
        this.beginTime = e.target.value
      },
      endTimeChange(e) {
        this.endTime = e.target.value
      },
      //提交申请
      formSubmit(e) {
        let target = e.detail.value;
        if (!target.shop_name) {
          this.$mUtil.toast('请输入店铺名称')
          return false
        }
        if (!this.dataform.province_name) {
          this.$mUtil.toast('请选择省市区')
          return false
        }
        // if(!this.dataform.street_name){
        // 	this.$mUtil.toast('请选择所属街道')
        // 	return false
        // }
        // if(!this.dataform.community_name){
        // 	this.$mUtil.toast('请选择所属社区')
        // 	return false
        // }
        // if (!target.address) {
        //   this.$mUtil.toast('请输入店铺详细地址')
        //   return false
        // }
        // if(!this.dataform.map_punctuation){
        // 	this.$mUtil.toast('请选择店铺地图选址')
        // 	return false
        // }
        if (!target.customer_service_phone) {
          this.$mUtil.toast('请输入客服电话')
          return false
        }
        // if (!this.dataform.business_hours) {
        //   this.$mUtil.toast('请选择营业时间')
        //   return false
        // }
        // if (this.beginTime == '') {
        //   this.$mUtil.toast('请选择开始时间段')
        //   return false
        // }
        // if (this.endTime == '') {
        //   this.$mUtil.toast('请选择结束时间段')
        //   return false
        // }
        // if (!target.main_name) {
        //   this.$mUtil.toast('请输入商业主体名称')
        //   return false
        // }
        // if (!target.loser) {
        //   this.$mUtil.toast('请输入运营人姓名')
        //   return false
        // }
        // if (!target.mobile) {
        //   this.$mUtil.toast('请输入运营人电话')
        //   return false
        // }
        // if (!(target.mobile.match(this.$mConfig.telRegex))) {
        //   this.$mUtil.toast('运营人手机号格式错误')
        //   return false
        // }
        if (this.settleMode == 1) {
          if (target.reward_ratio) {
            if (this.$u.test.chinese(target.reward_ratio)) {
              return this.$mUtil.toast('请输入数字类型')
            } else if (!this.$u.test.range(target.reward_ratio, [1, 100])) {
              return this.$mUtil.toast('门店打赏比例请输入0-100的值')
            } else if (!this.$u.test.amount(target.reward_ratio)) {
              return this.$mUtil.toast('门店打赏比例最多保留两位小数')
            }
          }
        }
        // if (!target.remark) {
        //   this.$mUtil.toast('请输入店铺介绍')
        //   return false
        // }
        // if (!target.place_remark) {
        //   this.$mUtil.toast('请输入场地说明')
        //   return false
        // }
        if (this.logo == '') {
          this.$mUtil.toast('请上传店铺logo')
          return false
        }
        // if (this.store_images == '') {
        //   this.$mUtil.toast('请上传店铺图片')
        //   return false
        // }
        if (!this.checkAggrement) {
          this.$mUtil.toast('请先同意协议')
          return false
        }
        this.dataform.shop_name = target.shop_name
        this.dataform.address = target.address
        this.dataform.mobile = target.mobile
        this.dataform.main_name = target.main_name
        this.dataform.loser = target.loser
        this.dataform.customer_service_phone = target.customer_service_phone
        this.dataform.place_remark = target.place_remark
        this.dataform.remark = target.remark
        //将图片数组转成字符串
        this.dataform.logo = this.logo.join(',')
        this.dataform.store_images = this.store_images.join(',')
        //拼接时间段
        this.dataform.time_quantum = this.beginTime + '-' + this.endTime
        // 商家入驻类型
        if (this.settleMode == 1) {
          this.dataform.union_business = true
          this.dataform.reward_ratio = target.reward_ratio || 0
          this.dataform.special_offers = target.special_offers
        }
        console.log('this.dataform', this.dataform)
        let url = '/shop/update/record/apply'
        if (this.dataform.audit_status == 2) {
          url = '/yxt/shopapply/apply'
        }
        this.$http.post(url, this.dataform).then(
          async res => {
            if (res && res.code == 200) {
              uni.showToast({
                title: "提交成功",
                icon: "none",
                duration: 3000
              })
              setTimeout(() => {
                if (this.dataform.audit_status == 2) {
                  uni.redirectTo({
                    url: '/pages/workbench/shop/audit'
                  });
                } else {
                  uni.navigateBack()
                }
              }, 1000)
            } else {
              this.$mUtil.toast(res.msg)
            }
          })
      },
      //企业选择————企业省市区确认事件
      // enterprisePickerChange(e) {
      // 	this.multiIndex = e.detail.value;
      // 	if (this.newProvinceDataList[2][this.multiIndex[2]] != undefined) {
      // 		this.dataform.province = this.newProvinceDataList[0][this.multiIndex[0]].label + this
      // 			.newProvinceDataList[1][this.multiIndex[1]].label + this.newProvinceDataList[2][this.multiIndex[2]]
      // 			.label
      // 	} else {
      // 		this.dataform.province = this.newProvinceDataList[0][this.multiIndex[0]].label + this
      // 			.newProvinceDataList[1][this.multiIndex[1]].label
      // 	}
      // },
      enterprisePickerColumnchange(e) {
        // 第几列滑动
        // console.log(e.detail.column);
        // 第几列滑动的下标
        // console.log(e.detail.value)
        // 第一列滑动
        if (e.detail.column === 0) {
          this.multiIndex[0] = e.detail.value
          this.newProvinceDataList[1] = this.oldpProvinceDataList[this.multiIndex[0]].children.map((item,
            index) => {
            return item
          })
          //当三级存在
          if (this.oldpProvinceDataList[this.multiIndex[0]].children[0].children) {
            if (this.oldpProvinceDataList[this.multiIndex[0]].children[this.multiIndex[1]]) {
              this.newProvinceDataList[2] = this.oldpProvinceDataList[this.multiIndex[0]].children[this
                  .multiIndex[1]].children
                .map((item, index) => {
                  return item
                })
            }
          } else {
            this.newProvinceDataList[2] = []
          }
          // 第一列滑动  第二列 和第三列 都变为第一个
          this.multiIndex.splice(1, 1, 0)
          this.multiIndex.splice(2, 1, 0)
        }
        // 第二列滑动
        if (e.detail.column === 1) {
          this.multiIndex[1] = e.detail.value
          if (this.oldpProvinceDataList[this.multiIndex[0]].children[0].children) {
            this.newProvinceDataList[2] = this.oldpProvinceDataList[this.multiIndex[0]].children[this
                .multiIndex[1]].children
              .map(
                (item, index) => {
                  return item
                })
          } else {
            this.newProvinceDataList[2] = []
          }
          // 第二列 滑动 第三列 变成第一个
          this.multiIndex.splice(2, 1, 0)
        }
        // 第三列滑动
        if (e.detail.column === 2) {
          this.multiIndex[2] = e.detail.value
          // console.log('第三列滑动')
          // console.log(this.multiIndex)
        }
      },
      //商家选择————省市区确认事件
      pickerChange(e) {
        this.multiIndex = e.detail.value;
        if (this.newProvinceDataList[2][this.multiIndex[2]] != undefined) {
          this.dataform.province_name = this.newProvinceDataList[0][this.multiIndex[0]].label
          this.dataform.province_code = this.newProvinceDataList[0][this.multiIndex[0]].value
          this.dataform.city_name = this.newProvinceDataList[1][this.multiIndex[1]].label
          this.dataform.city_code = this.newProvinceDataList[1][this.multiIndex[1]].value
          this.dataform.area_name = this.newProvinceDataList[2][this.multiIndex[2]].label
          this.dataform.area_code = this.newProvinceDataList[2][this.multiIndex[2]].value
          // this.dataform.tx_latitude = this.newProvinceDataList[2][this.multiIndex[2]].latitude
          // this.dataform.tx_longitude = this.newProvinceDataList[2][this.multiIndex[2]].longitude
          this.getAreaList(this.dataform.area_code, 'street')
        } else {
          this.dataform.province_name = this.newProvinceDataList[0][this.multiIndex[0]].label
          this.dataform.province_code = this.newProvinceDataList[0][this.multiIndex[0]].value
          this.dataform.city_name = this.newProvinceDataList[1][this.multiIndex[1]].label
          this.dataform.city_code = this.newProvinceDataList[1][this.multiIndex[1]].value
          // this.dataform.tx_latitude = this.newProvinceDataList[1][this.multiIndex[1]].latitude
          // this.dataform.tx_longitude = this.newProvinceDataList[1][this.multiIndex[1]].longitude
          this.streetList = [];
          this.communityList = [];
        }
      },
      streetChange(e) {
        if (this.streetList && this.streetList.length <= 0) {
          uni.showToast({
            icon: "none",
            title: '请选择所属地区',
            duration: 2000
          });
          return
        }
        this.streetShow = true
      },
      communityChange() {
        if (this.communityList && this.communityList.length <= 0) {
          uni.showToast({
            icon: "none",
            title: '请选择所属街道',
            duration: 2000
          });
          return
        }
        this.communityShow = true
      },
      pickerColumnchange(e) {
        // 第几列滑动
        // console.log(e.detail.column);
        // 第几列滑动的下标
        // console.log(e.detail.value)
        // 第一列滑动
        if (e.detail.column === 0) {
          this.multiIndex[0] = e.detail.value
          this.newProvinceDataList[1] = this.oldpProvinceDataList[this.multiIndex[0]].children.map((item,
            index) => {
            return item
          })
          //当三级存在
          if (this.oldpProvinceDataList[this.multiIndex[0]].children[0].children) {
            if (this.oldpProvinceDataList[this.multiIndex[0]].children[this.multiIndex[1]]) {
              this.newProvinceDataList[2] = this.oldpProvinceDataList[this.multiIndex[0]].children[this
                  .multiIndex[1]].children
                .map((item, index) => {
                  return item
                })
            }
          } else {
            this.newProvinceDataList[2] = []
          }
          // 第一列滑动  第二列 和第三列 都变为第一个
          this.multiIndex.splice(1, 1, 0)
          this.multiIndex.splice(2, 1, 0)
        }
        // 第二列滑动
        if (e.detail.column === 1) {
          this.multiIndex[1] = e.detail.value
          if (this.oldpProvinceDataList[this.multiIndex[0]].children[0].children) {
            this.newProvinceDataList[2] = this.oldpProvinceDataList[this.multiIndex[0]].children[this
                .multiIndex[1]].children
              .map(
                (item, index) => {
                  return item
                })
          } else {
            this.newProvinceDataList[2] = []
          }
          // 第二列 滑动 第三列 变成第一个
          this.multiIndex.splice(2, 1, 0)
        }
        // 第三列滑动
        if (e.detail.column === 2) {
          this.multiIndex[2] = e.detail.value
          // console.log('第三列滑动')
          // console.log(this.multiIndex)
        }
      }
    }
  }
</script>

<style lang="scss">
  page {
    background-color: #F5F5F5;
  }

  .step-pd {
    padding: 40rpx 30rpx;
  }

  .font68 {
    color: #FFFFFF;
    font-size: 68rpx;
  }

  .u-6087F2 {
    color: #6087F2;
  }

  .vertical-bar {
    width: 6rpx;
    height: 30rpx;
    background: #FA6138;
    border-radius: 2rpx;
    color: #0B844A;
  }

  .pt14 {
    padding-top: 14rpx;
  }

  .pt30 {
    padding-top: 30rpx;
  }

  .audit {
    width: 100%;
    padding: 42rpx 0rpx;
    margin-bottom: 30rpx;
  }

  .radio {}

  .auditImg {
    width: 214rpx;
    height: 160rpx;
  }

  .bg-F5FFF9 {
    background-color: #F5FFF9;
  }

  .bg-fff {
    background-color: #FFFFFF;
    padding-bottom: 40rpx;
  }

  .uni-form-item {
    height: 104rpx;
    line-height: 104rpx;
    // margin-top: 34rpx;
    border-bottom: 1rpx solid #d9d9d9;
  }

  .title {
    width: 250rpx;
  }

  .uni-input {
    width: 100%;
    // height: 70rpx;
    height: 104rpx;
    padding-left: 20rpx;
    text-align: right;
    // border: 1rpx solid #d9d9d9;
    // border-radius: 8rpx;
    // padding-left: 20rpx;
  }

  .u-position-re {
    position: relative;

    .iconfont {
      position: absolute;
      top: 0rpx;
      left: 20rpx;
    }

    .uni-input {
      width: 366rpx;
      padding-left: 60rpx;
    }
  }

  .uni-form-textarea {
    margin-top: 35rpx;

    .textarea {
      width: 100%;
      height: 282rpx;
      background-color: #F7F7F7;
      border-radius: 8rpx;
      padding-top: 14rpx;
      margin-top: 24rpx;
      box-sizing: border-box;
      padding-left: 22rpx;
    }
  }

  .btn {
    margin-top: 100rpx;
    margin-bottom: 40rpx;
    display: flex;
    justify-content: center;
  }

  .week {
    text-align: center;
    padding-bottom: 20rpx;
  }

  .checkedYes {
    color: #FF0000;
  }

  .weeks-btn {
    background: #FA6138;
    color: #FFFFFF;
  }

  .check {
    position: relative;
    width: 32rpx;
    height: 32rpx;

    .radios {
      width: 30rpx;
      height: 30rpx;
      display: block;
      border: 1px solid #ccc;
      border-radius: 50%;
      position: absolute;
      left: 0;
      top: 0;
      z-index: 1;
    }

    .iconbox {
      position: relative;
      z-index: 2;
    }

  }

  .u-bg-abc5b5 {
    background-color: rgba(55, 117, 246, 0.5);
  }
</style>
