<template>
  <view class="gather">
    <!-- #ifdef MP || APP-PLUS -->

    <view class="conten-top">
      <view class="" style="position: absolute;left: 30rpx;" @click="logout"><i class="iconfont icon-xiangzuo"
          style="font-size: 40rpx;text-align: left;"></i></view>
      <view class="" style="font-size: 30rpx;">
        商家平台
      </view>
    </view>
    <view style="padding-top:var(--status-bar-height);padding-bottom: 30rpx; margin-bottom: 30rpx;"></view>
    <!-- #endif -->
    <block v-if="isShow&&userInfoData.mer_info.mer_name">
      <view class="" v-if="userInfoData.mer_info.setting_status==1">
        <view class="special_work com" v-if="userInfoData.mer_info.type_code === 'TypeSupplyChain'">
          <view class="special_work com" v-if="true">
            <view class="title">市级供应链</view>
            <view class="special_work-title" v-if='codenote.length>0'>
              <view class="special_work-titlea">
                <image src="@/static/images/de1.png" mode="aspectFit" v-if='codenote[0].status==0'>
                </image>
                <image src="@/static/images/de2.png" mode="aspectFit" v-if='codenote[0].status==1'>
                </image>
                <image src="@/static/images/de3.png" mode="aspectFit" v-if='codenote[0].status==2'>
                </image>
              </view>
              <view class="special_work-titlec" v-if='codenote[0].status==1'>交易申请状态:已通过</view>
              <view class="special_work-titled" v-if='codenote[0].status==2'>交易申请状态:已拒绝</view>
              <view class="special_work-titleb" v-if='codenote[0].status==0'>交易申请状态:待审核</view>
            </view>
            <view class="content">
              <view class="examine" @click="navigator(`/pages/nongKe/supply_chain/goods_list?merid=${mer_id}`)">
                <image class="icon_img" src="@/static/images/index21.png" mode="aspectFit"></image>
                <text class="text">在售管理</text>
              </view>
              <!-- <view class="examine"
								@click="navigator(`/pages/admin/order/index?mer_id=${mer_id}&product_type=98&type_id=${userInfoData.mer_info.type_id}`)">
								<image class="icon_img" src="@/static/images/index18.png" mode="aspectFit">
									<text class="text">财务管理</text>
							</view> -->
              <!-- <view class="examine"
                @click="navigator(`/pages/admin/financial_management/index?mer_id=${mer_id}&product_type=98&type_id=${userInfoData.mer_info.type_id}`)">
                <image class="icon_img" src="@/static/images/index18.png" mode="aspectFit">
                  <text class="text">财务管理</text>
              </view> -->
              <view class="examine"
                @click="navigator(`/pages/admin/order/index?mer_id=${mer_id}&product_type=98&type_id=${userInfoData.mer_info.type_id}`)">
                <image class="icon_img" src="@/static/images/index1.png" mode="aspectFit">
                  <text class="text">订单管理</text>
              </view>
              <view class="examine"
                @click="navigator(`/pages/nongKe/gather/select_warehouse?mer_id=${mer_id}&stype=1`)">
                <image class="icon_img" src="@/static/images/index9.png" mode="aspectFit">
                </image>
                <text class="text">入库管理</text>
              </view>
              <view class="examine" @click="buyserset">
                <image class="icon_img" src="@/static/images/index11.png" mode="aspectFit">
                  <text class="text">商户设置</text>
              </view>

              <view class="examine" @click="navigator(`/pages/product/list/index?mer_id=${mer_id}`)">
                <image class="icon_img" src="@/static/images/index7.png" mode="aspectFit">
                </image>
                <text class="text">商品管理</text>
              </view>
              <view class="examine" @click="navigator(`/pages/users/embody/embody?mer_id=${mer_id}`)">
                <image class="icon_img" src="@/static/images/index8.png" mode="aspectFit">
                </image>
                <text class="text">提现管理</text>
              </view>
              <view class="examine" @click="navigator(`/pages/admin/order_cancellation/index?mer_id=${mer_id}`)">
                <image class="icon_img" src="@/static/images/index2.png" mode="aspectFit">
                </image>
                <text class="text">订单核销</text>
              </view>
              <view class="examine" @click="paydecimal">
                <image class="icon_img" src="@/static/images/index20.png" mode="aspectFill">
                </image>
                <text class="text">押金缴纳</text>
              </view>

              <!-- <view class="examine" @click="navigator(`/pages/commissionedSales/index/index?mer_id=${mer_id}`)">
                <image class="icon_img" src="@/static/images/index13.png" mode="aspectFit">
                </image>
                <text class="text">委托销售</text>
              </view> -->
              <view class="examine" @click="navigator(`/pages/commissionedSales/receivedCommission/index?type_id=${userInfoData.mer_info.type_id}`)">
                <image class="icon_img" src="@/static/images/index13.png" mode="aspectFit">
                </image>
                <text class="text">委托销售</text>
              </view>
              <view class="examine" @click="navigator(`/pages/users/order_list/relase?mer_id=${mer_id}&status=-1`)">
                <image class="icon_img" src="@/static/images/index17.png" mode="aspectFit">
                </image>
                <text class="text">委托订单</text>
              </view>
              <!-- <view class="examine" @click="navigator(`/pages/nongKe/teach_video/teach_video`)">
							<image class="icon_img"
								src="https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/spjs.png"  mode="aspectFit">
							</image>
							<text class="text">视频教学</text>
						</view> -->
              <!-- <view class="examine" @click="navigator(`/pages/users/user_invoice_Finance/index?mer_id=${mer_id}`)">
						<image class="icon_img" src="@/static/images/cwgk.png"  mode="aspectFit">
						</image>
						<text class="text">财务公开</text>
					</view> -->
              <!-- <view class="examine" @click="navigator(`/pages/admin/order/index?mer_id=${mer_id}`)">
						<image class="icon_img" :src="`${prefix}ddgl.png`"  mode="aspectFit">
						</image>
						<text class="text">订单管理</text>
					</view> -->
            </view>
          </view>
        </view>

        <view class="business com"
          v-if="userInfoData.mer_info.type_code === 'TypeStore'||userInfoData.mer_info.type_code === 'TypeTownSupplyChain'">
          <view class="business com" v-if="true">
            <view class="special_work com">
              <view class="title">我的店铺</view>
              <view class="special_work-title" v-if='codenote.length>0'>
                <view class="special_work-titlea">
                  <image src="@/static/images/de1.png" mode="aspectFit" v-if='codenote[0].status==0'>
                  </image>
                  <image src="@/static/images/de2.png" mode="aspectFit" v-if='codenote[0].status==1'>
                  </image>
                  <image src="@/static/images/de3.png" mode="aspectFit" v-if='codenote[0].status==2'>
                  </image>
                </view>
                <view class="special_work-titlec" v-if='codenote[0].status==1'>交易申请状态:已通过</view>
                <view class="special_work-titled" v-if='codenote[0].status==2'>交易申请状态:已拒绝</view>
                <view class="special_work-titleb" v-if='codenote[0].status==0'>交易申请状态:待审核</view>
              </view>
              <view class="content ">
                <!-- <view class="examine"
                  @click="navigator(`/pages/users/supply_procurement/index?type_id=12&isDetail=1&product_type=98&cate_id=${userInfoData.mer_info.category_id}`)">

                  <image class="icon_img" src="@/static/images/index4.png" mode="aspectFit"></image>
                  <text class="text">供货采购</text>
                </view> -->
                <view class="examine"
                  @click="navigator(`/pages/nongKe/supply_chain/supplierA?tit=1&type_id=12&isDetail=1&product_type=98&cate_id=${userInfoData.mer_info.category_id}`)">  
                  <image class="icon_img" src="@/static/images/index4.png" mode="aspectFit"></image>
                  <text class="text">供货采购</text>
                </view>
                <view class="examine" @click="navigator('/pages/users/order_list/indexCopy?status=-1&product_type=98')">
                  <image class="icon_img" src="@/static/images/index5.png" mode="aspectFit"></image>
                  <text class="text">进货管理</text>
                </view>
                <view class="examine" @click="navigator(`/pages/admin/stockOut/index?mer_id=${mer_id}`)">
                  <image class="icon_img" src="@/static/images/index10.png" mode="aspectFit">
                  </image>
                  <text class="text">扫码出库</text>
                </view>
                <view class="examine"
                  @click="navigator(`/pages/nongKe/gather/select_warehouse?mer_id=${mer_id}&stype=2`)">
                  <image class="icon_img" src="@/static/images/index9.png" mode="aspectFit">
                  </image>
                  <text class="text">入库管理</text>
                </view>
                <view class="examine" @click="navigator(`/pages/users/embody/embody?mer_id=${mer_id}`)">
                  <image class="icon_img" src="@/static/images/index8.png" mode="aspectFit">
                  </image>
                  <text class="text">提现管理</text>
                </view>

                <view class="examine" @click="navigator(`/pages/chat/customer_list/index?type=1&mer_id=${mer_id}`,2)">
                  <image class="icon_img" src="@/static/images/index6.png" mode="aspectFit">
                  </image>
                  <text class="text">客服记录</text>
                </view>
                <view class="examine" @click="navigator(`/pages/admin/order_cancellation/index?mer_id=${mer_id}`)">
                  <image class="icon_img" src="@/static/images/index2.png" mode="aspectFit">
                  </image>
                  <text class="text">订单核销</text>
                </view>
                <view class="examine"
                  @click="navigator(`/pages/admin/order/index?mer_id=${mer_id}&type_id=${userInfoData.mer_info.type_id}`)">
                  <image class="icon_img" src="@/static/images/index1.png" mode="aspectFit">
                  </image>
                  <text class="text">订单管理</text>
                </view>
                <view class="examine" @click="navigator(`/pages/product/list/index?mer_id=${mer_id}`)">
                  <image class="icon_img" src="@/static/images/index7.png" mode="aspectFit">
                  </image>
                  <text class="text">商品管理</text>
                </view>
                <view class="examine" @click="buyserset">
                  <image class="icon_img" src="@/static/images/index11.png" mode="aspectFit">
                  </image>
                  <text class="text">商户设置</text>
                </view>
                <view class="examine" @click="paydecimal">
                  <image class="icon_img" src="@/static/images/index20.png" mode="aspectFill">
                  </image>
                  <text class="text">押金缴纳</text>
                </view>

                <view class="examine" @click="navigator(`/pages/users/trading_hall/index?mer_id=${mer_id}`)">
                  <image class="icon_img" src="@/static/images/index16.png" mode="aspectFit">
                  </image>
                  <text class="text">交易大厅</text>
                </view>
                <view class="examine" @click="navigator(`/pages/commissionedSales/initiateDelegation/index`)">
                  <image class="icon_img" src="@/static/images/index13.png" mode="aspectFit">
                  </image>
                  <text class="text">委托销售</text>
                </view>
                <!-- <view class="examine" @click="navigator(`/pages/users/order_list/relase?mer_id=${mer_id}&status=-1`)">
                  <image class="icon_img" src="@/static/images/index17.png" mode="aspectFit">
                  </image>
                  <text class="text">委托订单</text>
                </view> -->
                <view class="examine" @click="navigator(`/pages/releaseManagement/index?mer_id=${mer_id}`)">
                  <image class="icon_img" src="@/static/images/index15.png" mode="aspectFit">
                  </image>
                  <text class="text">发布管理</text>
                </view>
                <view v-if="userInfoData.mer_info.type_code === 'TypeTownSupplyChain'" class="examine" @click="navigator(`/pages/wholesale/wholesale/wholesale`)">
                  <image class="icon_img" src="@/static/images/index15.png" mode="aspectFit">
                  </image>
                  <text class="text">供应链批发</text>
                </view>
                <view v-if="userInfoData.mer_info.type_code === 'TypeTownSupplyChain'" class="examine" @click="navigator(`/pages/replace_replenishment/index`)">
                  <image class="icon_img" src="@/static/images/index15.png" mode="aspectFit">
                  </image>
                  <text class="text">代发补货</text>
                </view>

                <!-- <view class="examine" @click="navigator(`/pages/users/user_invoice_Finance/index?mer_id=${mer_id}`)">
							<image class="icon_img" src="@/static/images/cwgk.png"  mode="aspectFit">
							</image>
							<text class="text">财务公开</text>
						</view> -->


              </view>
            </view>

            <!-- <gatherBusiness :userInfoData="userInfoData" /> -->
          </view>
        </view>

        <view class="business com" v-if="userInfoData.mer_info.type_code === 'TypeCloudWarehouse'">
          <view class="business com" v-if="true">
            <view class="special_work com">
              <view class="title">里海云仓</view>
              <view class="special_work-title" v-if='codenote.length>0'>
                <view class="special_work-titlea">
                  <image src="@/static/images/de1.png" mode="aspectFit" v-if='codenote[0].status==0'>
                  </image>
                  <image src="@/static/images/de2.png" mode="aspectFit" v-if='codenote[0].status==1'>
                  </image>
                  <image src="@/static/images/de3.png" mode="aspectFit" v-if='codenote[0].status==2'>
                  </image>
                </view>
                <view class="special_work-titlec" v-if='codenote[0].status==1'>交易申请状态:已通过</view>
                <view class="special_work-titled" v-if='codenote[0].status==2'>交易申请状态:已拒绝</view>
                <view class="special_work-titleb" v-if='codenote[0].status==0'>交易申请状态:待审核</view>
              </view>
              <view class="content ">
                <view class="examine"
                  @click="navigator(`/pages/nongKe/supply_chain/supplier?type_id=12&isDetail=1&product_type=98&cate_id=${userInfoData.mer_info.category_id}`)">
                  <image class="icon_img" src="@/static/images/index4.png" mode="aspectFit"></image>
                  <text class="text">供货采购</text>
                </view>
                <view class="examine" @click="navigator('/pages/users/order_list/index?status=-1')">
                  <image class="icon_img" src="@/static/images/index5.png" mode="aspectFit"></image>
                  <text class="text">进货管理</text>
                </view>
                <view class="examine" @click="navigator(`/pages/admin/stockOut/index?mer_id=${mer_id}`)">
                  <image class="icon_img" src="@/static/images/index10.png" mode="aspectFit">
                  </image>
                  <text class="text">扫码出库</text>
                </view>
                <view class="examine"
                  @click="navigator(`/pages/nongKe/gather/select_warehouse?mer_id=${mer_id}&stype=2`)">
                  <image class="icon_img" src="@/static/images/index9.png" mode="aspectFit">
                  </image>
                  <text class="text">入库管理</text>
                </view>
                <view class="examine" @click="navigator(`/pages/users/embody/embody?mer_id=${mer_id}`)">
                  <image class="icon_img" src="@/static/images/index8.png" mode="aspectFit">
                  </image>
                  <text class="text">提现管理</text>
                </view>

                <view class="examine" @click="navigator(`/pages/chat/customer_list/index?type=1&mer_id=${mer_id}`,2)">
                  <image class="icon_img" src="@/static/images/index6.png" mode="aspectFit">
                  </image>
                  <text class="text">客服记录</text>
                </view>
                <view class="examine" @click="navigator(`/pages/admin/order_cancellation/index?mer_id=${mer_id}`)">
                  <image class="icon_img" src="@/static/images/index2.png" mode="aspectFit">
                  </image>
                  <text class="text">订单核销</text>
                </view>
                <view class="examine"
                  @click="navigator(`/pages/admin/order/index?mer_id=${mer_id}&type_id=${userInfoData.mer_info.type_id}`)">
                  <image class="icon_img" src="@/static/images/index1.png" mode="aspectFit">
                  </image>
                  <text class="text">订单管理</text>
                </view>
                <view class="examine" @click="navigator(`/pages/product/list/index?mer_id=${mer_id}`)">
                  <image class="icon_img" src="@/static/images/index7.png" mode="aspectFit">
                  </image>
                </view>
                <view class="examine" @click="buyserset">
                  <image class="icon_img" src="@/static/images/index11.png" mode="aspectFit">
                  </image>
                  <text class="text">商户设置</text>
                </view>


                <!-- <view class="examine" @click="navigator(`/pages/users/user_invoice_Finance/index?mer_id=${mer_id}`)">
							<image class="icon_img" src="@/static/images/cwgk.png"  mode="aspectFit">
							</image>
							<text class="text">财务公开</text>
						</view> -->

              </view>
            </view>
          </view>
        </view>

        <view class="business com"
          v-if="userInfoData.mer_info.type_code === 'TypeFeaturedCultural'|| userInfoData.mer_info.type_code === 'TypeFamousSpecialties'|| userInfoData.mer_info.type_code === 'TypeLocalCuisine' ">
          <view class="business com" v-if="true">
            <view class="special_work com">
              <view class="title">我的店铺</view>
              <view class="special_work-title" v-if='codenote.length>0'>
                <view class="special_work-titlea">
                  <image src="@/static/images/de1.png" mode="aspectFit" v-if='codenote[0].status==0'>
                  </image>
                  <image src="@/static/images/de2.png" mode="aspectFit" v-if='codenote[0].status==1'>
                  </image>
                  <image src="@/static/images/de3.png" mode="aspectFit" v-if='codenote[0].status==2'>
                  </image>
                </view>
                <view class="special_work-titlec" v-if='codenote[0].status==1'>交易申请状态:已通过</view>
                <view class="special_work-titled" v-if='codenote[0].status==2'>交易申请状态:已拒绝</view>
                <view class="special_work-titleb" v-if='codenote[0].status==0'>交易申请状态:待审核</view>
              </view>
              <view class="content ">

                <view class="examine" @click="navigator(`/pages/users/embody/embody?mer_id=${mer_id}`)">
                  <image class="icon_img" src="@/static/images/index8.png" mode="aspectFit">
                  </image>
                  <text class="text">提现管理</text>
                </view>

                <view class="examine" @click="navigator(`/pages/chat/customer_list/index?type=1&mer_id=${mer_id}`,2)">
                  <image class="icon_img" src="@/static/images/index6.png" mode="aspectFit">
                  </image>
                  <text class="text">客服记录</text>
                </view>
                <view class="examine" @click="navigator(`/pages/admin/order_cancellation/index?mer_id=${mer_id}`)">
                  <image class="icon_img" src="@/static/images/index2.png" mode="aspectFit">
                  </image>
                  <text class="text">订单核销</text>
                </view>
                <view class="examine"
                  @click="navigator(`/pages/admin/order/index?mer_id=${mer_id}&type_id=${userInfoData.mer_info.type_id}`)">
                  <image class="icon_img" src="@/static/images/index1.png" mode="aspectFit">
                  </image>
                  <text class="text">订单管理</text>
                </view>
                <view class="examine" @click="navigator(`/pages/product/list/index?mer_id=${mer_id}`)">
                  <image class="icon_img" src="@/static/images/index7.png" mode="aspectFit">
                  </image>
                  <text class="text">商品管理</text>
                </view>
                <view class="examine" @click="navigator(`/pages/product/basicSet?mer_id=${mer_id}`, '商户设置')">
                  <image class="icon_img" src="@/static/images/index11.png" mode="aspectFit">
                  </image>
                  <text class="text">商户设置</text>
                </view>
                <view class="examine" @click="paydecimal">
                  <image class="icon_img" src="@/static/images/index20.png" mode="aspectFill">
                  </image>
                  <text class="text">押金缴纳</text>
                </view>

              </view>
            </view>
          </view>
        </view>



      </view>

      <view class="" v-else>
        <view class="business com">
          <view class="special_work com">
            <view class="title">我的店铺</view>
            <view class="content ">
              <view class="examine" @click="buyserset">
                <image class="icon_img" src="@/static/images/index11.png" mode="aspectFit">
                </image>
                <text class="text">商户设置</text>
              </view>

            </view>
          </view>
        </view>

      </view>

    </block>
    <view class="" style="padding-top: 1px;" v-else>
      <emptyPage title="暂无信息"></emptyPage>
    </view>
    <view class="settlementAgreement" v-if="isFshow">
      <view class="setAgCount" style="width: 100%;height: 100% ;padding-top:120rpx ;">
        <!-- <i class="icon iconfont icon-cha" @click="recuo"></i> -->
        <view class="" style="width: 60rpx;height: 60rpx; position: absolute;right: 30rpx; top:60rpx" @click="recuo">
          <image src="@/static/images/close.png" mode="aspectFit" style="width: 60rpx;height: 60rpx;"></image>
        </view>
        <div class="title">{{detail.title}}</div>
        <view style="margin: 20rpx 0;">甲方公司:{{company?company:"暂无公司信息"}}</view>
        <view style="margin: 20rpx 0;">机构代码:{{organization_code?organization_code:"暂无公司信息"}}</view>
        <view class="contenta">
          <jyf-parser :html="detail.mer_settlement_agree" ref="article" :tag-style="tagStyle"></jyf-parser>

        </view>
        <view class="setAgCountbtn">
          <button class="setAgCountbtna" @click="refuse">
            拒绝
          </button>

          <button :class="num>0?'setAgCountbtnb':'setAgCountbtnc'" :disabled="num!=0" @click="agree">
            <text v-if="num>0">请仔细阅读协议{{num}}S</text>
            <text v-else>同意</text>

          </button>
        </view>
      </view>
    </view>

    <uni-popup ref="popup" type="bottom">

      <view class="userpage">
        <view class="userpage-icon" @click="close">
          <image src="@/static/images/close.png" mode=""></image>
        </view>

        <form report-submit='true' style="height: 100%;">
          <view class='merchantsSettled' :style="{'height':Fheight}">
            <view class="title">填写信息</view>
            <view class='list'>
              <view class="item">
                <view class="acea-row row-middle">
                  <text class="item-name">开户行名称:</text>
                  <input type="text" maxlength="30" placeholder="请输入开户行名称" v-model="merchantData.bank_username"
                    @input="validateBtn" placeholder-class='placeholder' />
                </view>
              </view>


              <view class="item">
                <view class="acea-row row-middle">
                  <text class="item-name">联系电话:</text>
                  <input type="text" placeholder="请输入手机号" v-model="merchantData.phone" @input="validateBtn"
                    placeholder-class='placeholder' />
                </view>
              </view>

              <view class="item">
                <view class="acea-row row-middle">
                  <text class="item-name">开户行:</text>
                  <input type="text" placeholder="请输入开户行" v-model="merchantData.bank_opening" @input="validateBtn"
                    placeholder-class='placeholder' />
                </view>
              </view>
              <view class="item">
                <view class="acea-row row-middle">
                  <text class="item-name">身份证正面:</text>
                </view>
                <view class="item-card">

                  <view class="item-carda" @click='uploadpic({type:1})' v-if='merchantData.cardno_front.length==0'>
                    <image src="@/static/images/SFZZ.png" mode="aspectFit"></image>
                  </view>
                  <view class="item-carda" @click='DelPic({type:1})' v-else>
                    <image :src="merchantData.cardno_front" mode="aspectFit"></image>
                  </view>
                  <view class="item-cardb" @click='uploadpic({type:2})' v-if='merchantData.cardno_back.length==0'>
                    <image src="@/static/images/SFFF.png" mode="aspectFit"></image>
                  </view>
                  <view class="item-cardb" @click='DelPic({type:2})' v-else>
                    <image :src="merchantData.cardno_back" mode="aspectFit"></image>
                  </view>
                </view>

              </view>
              <view class="item">
                <view class="acea-row row-middle">
                  <text class="item-name">银行卡反面:</text>
                </view>
                <view class="item-card">
                  <view class="item-carda" @click='uploadpic({type:3})' v-if='merchantData.bank_front.length==0'>
                    <image src="@/static/images/YHKZ.png" mode="aspectFit"></image>
                  </view>
                  <view class="item-carda" @click='DelPic({type:3})' v-else>
                    <image :src="merchantData.bank_front" mode="aspectFit"></image>
                  </view>
                  <view class="item-cardb" @click='uploadpic({type:4})' v-if='merchantData.bank_back.length==0'>
                    <image src="@/static/images/YHKF.png" mode="aspectFit"></image>
                  </view>

                  <view class="item-cardb" @click='DelPic({type:4})' v-else>
                    <image :src="merchantData.bank_back" mode="aspectFit"></image>
                  </view>
                </view>
              </view>


              <button class='submitBtn' :class="validate === true? 'on':''" @click="formSubmit">
                提交申请
              </button>
            </view>
          </view>
        </form>
      </view>
    </uni-popup>
  </view>
</template>

<script>
  import mTabbar from '@/components/m-tabbar/m-tabbar.vue'
  import emptyPage from '@/components/emptyPage.vue';
  import zbpSwiper from '@/components/zbpSwiper'
  import {

    mapGetters
  } from 'vuex'
  import {
    business,
    intention,
    intentionbus
  } from "@/api/product"
  import {
    merstreet,
    getUserInfo
  } from '@/api/user.js'
  import {
    getGeocoder,
    microSeachBarCode,
    microEadtProduct
  } from '@/api/store.js'
  import {
    Toast
  } from '@/libs/uniApi';
  import {
    getDiy,
    merchant,
    paymerchant
  } from '@/api/api.js'

  export default {
    components: {
      mTabbar,
      zbpSwiper,
      emptyPage
    },
    data() {
      return {
        company: '',
        organization_code: '',
        locationArr: ({}),
        emptyText: '暂无可用应用',
        jurisdiction: false, // 是否有权限
        mer_id: '',
        userInfoData: {
          mer_info: {
            type_id: 0
          }
        },
        prefix: 'https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/11/',
        isShow: false,
        bgColor: '',
        isFshow: false,
        street: '',
        detail: {},
        tagStyle: {
          img: 'width:100%;display:block;'
        },
        num: 15,
        where: {
          type: 2,
          page: 1,
          limit: 10
        },
        codenote: [],
        validate: false,
        merchantData: {
          bank_username: '',
          bank_opening: '',
          bank_front: '',
          bank_back: '',
          cardno_front: '',
          cardno_back: ''
        },
        Fheight: 0,

      };
    },
    computed: {
      ...mapGetters(['userInfo', 'isLogin'])
    },
    created() {},
    onLoad() {
      this.Fheight = uni.getSystemInfoSync().windowHeight + 'px';
      console.log(this.Fheight)
    },
    onShow() {
      if (this.isLogin) {
        this.emptyText = '暂无可用应用'
        this.jurisdiction = false
      } else {
        this.emptyText = '请登录'
        this.jurisdiction = true
      }
      this.getUserInfo()
      this.codelist()
      this.list()



    },



    methods: {
      //关闭弹窗
      close() {
        this.$refs.popup.close()
        this.num = 15
      },
      //获取交易信息
      codelist() {
        intention(this.where).then(res => {
          this.codenote = res.data.list
        })
      },


      //提交
      formSubmit: function(e) {
        let that = this;
        if (that.validateForm() && that.validate) {

          that.validate = false;

          intentionbus(that.merchantData).then(res => {
            if (res.status == 200) {
              this.$refs.popup.close()
              that.$util.Tips({
                title: '提交成功'
              });
              this.codelist()
              that.timer = setTimeout(() => {
                that.successful = true;
                that.validate = true;
              }, 1000)

            }
          }).catch(res => {
            that.validate = true;
            this.num = 15
            this.$refs.popup.close()
            that.$util.Tips({
              title: res
            });
          })


        }

      },
      //同意
      agree() {
        this.$refs.popup.open()
        this.isFshow = false

      },
      //拒绝
      refuse() {
        uni.switchTab({
          url: '/pages/index/index'
        })
      },
      //关闭弹窗
      recuo() {

        if (this.num > 0) {
          this.num = 15
          this.isFshow = false
        } else {
          this.num = 15
          this.isFshow = false
        }
      },
      logout() {
        uni.switchTab({
          url: '/pages/index/index'
        })
      },

      countDown() {
        let {
          num
        } = this;
        // if (num === 3) this.nums = true;
        num = num > 0 ? num - 1 : "0";
        setTimeout(() => {

          this.num = num;
          if (num == '0') {
            // this.launchApp()
            return
          }

          if (this.isFshow == false && this.num > 0) {
            this.num = 15
            return
          }
          this.countDown();
        }, 1000);


      },
      //验证
      validateBtn: function() {
        let that = this,
          value = that.merchantData;
        if (value.bank_username && value.bank_opening) {
          if (!that.isShowCode) {
            that.validate = true;
          } else {
            if (that.codeVal) {
              that.validate = true;
            } else {
              that.validate = false;
            }
          }
        } else {
          that.validate = false;
        }
      },

      validateForm: function() {
        let that = this,
          value = that.merchantData;

        if (!value.bank_username) return that.$util.Tips({
          title: '请输入银行账户姓名'
        });
        if (!value.bank_opening) return that.$util.Tips({
          title: '请输入开户行'
        });

        if (value.bank_front.length == 0) return that.$util.Tips({
          title: '请上传一张或者多张图片'
        });

        if (value.bank_back.length == 0) return that.$util.Tips({
          title: '请上传一张或者多张图片'
        });
        if (value.cardno_front.length == 0) return that.$util.Tips({
          title: '请上传一张或者多张图片'
        });
        if (value.cardno_back.length == 0) return that.$util.Tips({
          title: '请上传一张或者多张图片'
        });
        that.validate = true;
        return true;
      },
      /**
       * 上传文件
       *
       */
      uploadpic(data) {
        let that = this;
        if (data.type == 1) {
          that.$util.uploadImageOne('upload/image', function(res) {
            that.merchantData.cardno_front = res.data.path

          });
        } else if (data.type == 2) {
          that.$util.uploadImageOne('upload/image', function(res) {
            that.merchantData.cardno_back = res.data.path

          });
        } else if (data.type == 3) {
          that.$util.uploadImageOne('upload/image', function(res) {
            that.merchantData.bank_front = res.data.path

          });
        } else {
          that.$util.uploadImageOne('upload/image', function(res) {
            that.merchantData.bank_back = res.data.path

          });
        }

      },
      //删除图片
      DelPic(data) {
        let that = this;
        if (data.type == 1) {

          that.merchantData.cardno_front = ''


        } else if (data.type == 2) {

          that.merchantData.cardno_back = ''


        } else if (data.type == 3) {

          that.merchantData.bank_front = ''


        } else {

          that.merchantData.bank_back = ''


        }

      },


      //押金缴纳
      paydecimal() {
        if (this.userInfoData.mer_info.mer_settlement_agree_status == 0) {

          if (this.codenote.length == 0) {
            this.isFshow = true
            this.countDown()
          } else {
            if (this.codenote[0].status == 0) {
              uni.showModal({
                title: '申请正在审核中,请勿重复提交'
              })
            } else {
              this.isFshow = true
              this.countDown()
            }
          }

        } else {
          uni.navigateTo({
            url: '/pages/margin/margin' + `?mer_id=` + this.mer_id
          })
        }

      },

      //商户设置
      buyserset() {
        uni.navigateTo({
          url: `/pages/product/basicSet?mer_id=` + this.mer_id
        })
      },
      navigator(url, t) {
        console.log(this.codenote)
        if (this.userInfoData.mer_info.mer_settlement_agree_status == 0) {
          if (this.codenote.length == 0) {
            this.isFshow = true
            this.countDown()
          } else {
            if (this.codenote[0].status == 0) {
              uni.showModal({
                title: '申请正在审核中,请勿重复提交'
              })
            } else {
              this.isFshow = true
              this.countDown()
            }
          }
        } else {
          if (t == 2) {
            uni.switchTab({
              url: url
            })
          } else {
            uni.navigateTo({
              url: url
            })
          }

        }
      },
      getUserInfo: function() {
        let that = this;
        getUserInfo().then(res => {
          this.userInfoData = res.data;
          this.merchantData.phone = res.data.phone
          merstreet({
            street_code: res.data.mer_info.street_id
          }).then((res) => {
            if (res.code == 0) {
              // this.$util.Tips({
              // 	title: res.msg
              // });
              return false;
            }
            this.company = res.data.title
            this.organization_code = res.data.organization_code
          }).catch(res => {
            console.log(res)
          })
          if (res.data.service == null) {
            // console.log('123');
            this.isShow = false
          } else {
            this.isShow = true
            this.mer_id = res.data.service.mer_id
          }

          if (!res.data.mer_info) {
            that.$set(this, 'jurisdiction', false);
          }
          // console.log(that.userInfoData);
        });
      },

      //获取协议内容
      list() {
        business({
          type: 'mer_settlement_agree'
        }).then(res => {
          this.detail = res.data
        })
      },
    }
  };
</script>
<style lang="scss" scoped>
  .gather {
    padding-bottom: 164.91rpx;
    background: linear-gradient(180deg, #FFFFFF 0%, #F6F6F6 100%);
  }

  .conten-top {
    width: 100%;
    padding-top: var(--status-bar-height);
    padding-bottom: 30rpx;
    text-align: center;
    background-color: #fff;
    position: absolute;
    top: 0;
    position: fixed;
    z-index: 10;
  }

  .userpage {
    width: 100%;


    background-color: #fff;
    position: relative;
  }

  .userpage-icon {
    width: 60rpx;
    height: 60rpx;
    position: absolute;
    top: 65rpx;
    right: 60rpx;

    image {
      width: 100%;
      height: 100%;
    }
  }

  .item-name {
    width: 190rpx;
  }

  .merchantsSettled {
    height: 100%;
    padding-top: 80rpx;
  }

  .merchantsSettled .title {
    font-size: 35rpx;
    font-family: Microsoft YaHei;
    font-weight: 400;
    text-align: center;
  }

  .merchantsSettled .list {
    background-color: #fff;
    border-radius: 12px;
    margin: 0 15px;
    position: absolute;
  }

  .application-record {
    position: absolute;
    display: flex;
    align-items: center;
    top: 240rpx;
    right: 0;
    color: #fff;
    font-size: 22rpx;
    background-color: rgba(0, 0, 0, 0.3);
    padding: 8rpx 18rpx;
    border-radius: 20px 0px 0px 20px;
  }

  .item-card {
    display: flex;
    margin-top: 20rpx;

    .item-carda {
      width: 298rpx;
      height: 175rpx;
      margin-right: 20rpx;

      image {
        width: 100%;
        height: 100%;
      }
    }

    .item-cardb {
      width: 298rpx;
      height: 175rpx;

      image {
        width: 100%;
        height: 100%;
      }
    }
  }

  .merchantsSettled .list .item {
    padding: 50rpx 0 20rpx;

    position: relative;
    margin: 0 20px;

    &.no-border {
      border-bottom: none;
      padding-left: 0;
      padding-right: 0;
    }

    .item-title {
      color: #666666;
      font-size: 28rpx;
      display: block;
    }

    .item-desc {
      color: #B2B2B2;
      font-size: 22rpx;
      display: block;
      margin-top: 9rpx;
      line-height: 36rpx;
    }
  }

  .acea-row,
  .upload {
    display: -webkit-box;
    display: -moz-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-lines: multiple;
    -moz-box-lines: multiple;
    -o-box-lines: multiple;
    -webkit-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
  }

  .upload {
    margin-top: 20rpx;
  }

  .acea-row.row-middle {
    -webkit-box-align: center;
    -moz-box-align: center;
    -o-box-align: center;
    -ms-flex-align: center;
    -webkit-align-items: center;
    align-items: center;
    padding-left: 2px;
  }

  .acea-row.row-column {
    -webkit-box-orient: vertical;
    -moz-box-orient: vertical;
    -o-box-orient: vertical;
    -webkit-flex-direction: column;
    -ms-flex-direction: column;
    flex-direction: column;
  }

  .acea-row.row-center-wrapper {
    -webkit-box-align: center;
    -moz-box-align: center;
    -o-box-align: center;
    -ms-flex-align: center;
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-pack: center;
    -moz-box-pack: center;
    -o-box-pack: center;
    -ms-flex-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
  }

  .merchantsSettled .list .item .pictrue {
    width: 130rpx;
    height: 130rpx;
    margin: 24rpx 22rpx 0 0;
    position: relative;
    font-size: 11px;
    color: #bbb;

    &:nth-child(4n) {
      margin-right: 0;
    }

    &:nth-last-child(1) {
      border: 0.5px solid #ddd;
      box-sizing: border-box;
    }

    uni-image,
    image {
      width: 100%;
      height: 100%;
      border-radius: 1px;

      img {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        opacity: 0;
        width: 100%;
        height: 100%;
      }
    }

    .icon-guanbi1 {
      font-size: 33rpx;
      position: absolute;
      top: -10px;
      right: -10px;
    }
  }

  .uni-list-cell-db {
    position: relative;
  }

  .merchantsSettled .submitBtn {
    width: 588rpx;
    margin: 0 auto;
    height: 86rpx;

    border-radius: 25px;
    text-align: center;
    line-height: 86rpx;
    font-size: 15px;
    color: #fff;
    background: #E3E3E3;
    margin-top: 25px;
    pointer-events: none;
  }

  .merchantsSettled .submitBtn.on {
    background: red;
    pointer-events: all;
  }


  .settlementAgreement {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 10;
  }

  .settlementAgreement .setAgCount {
    background: #fff;
    width: 656rpx;
    // height: 458px;
    position: absolute;
    top: 50%;
    left: 50%;

    padding: 52rpx;
    -webkit-transform: translate(-50%, -50%);
    -moz-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    overflow: hidden;

    .content {
      height: 900rpx;
      overflow-y: scroll;

      /deep/ p {
        font-size: 13px;
        line-height: 22px;
      }

      /deep/ img {
        max-width: 100%;
      }
    }
  }

  .settlementAgreement .setAgCount .icon {
    font-size: 42rpx;
    color: #b4b1b4;
    position: absolute;
    top: 15rpx;
    right: 15rpx;
  }

  .settlementAgreement .setAgCount .title {
    color: #333;
    font-size: 32rpx;
    text-align: center;
    font-weight: bold;
  }


  .settlementAgreement .setAgCount .contenta {

    color: #333;
    font-size: 26rpx;
    line-height: 22px;
    text-align: justify;
    text-justify: distribute-all-lines;
    height: 75%;

    overflow-y: scroll;


  }

  .setAgCountbtn {
    display: flex;
    justify-content: space-around;

    .setAgCountbtna {
      margin-top: 40rpx;
      width: 200rpx;
      height: 74rpx;
      text-align: center;
      line-height: 74rpx;
      border-radius: 46rpx 46rpx;
      opacity: 1;
      border: 2rpx solid #B3B3B3;
      font-size: 25rpx;
      font-family: PingFang SC-Medium, PingFang SC;
      font-weight: 500;
      color: #737373;

    }

    .setAgCountbtnb {
      margin-top: 40rpx;
      padding-left: 20rpx;
      padding-right: 20rpx;

      text-align: center;
      line-height: 74rpx;
      background: #cecece;
      border-radius: 46rpx 46rpx;
      opacity: 1;
      font-size: 25rpx;
      font-family: PingFang SC-Medium, PingFang SC;
      font-weight: 500;
      color: #fff;

    }

    .setAgCountbtnc {
      margin-top: 40rpx;
      width: 200rpx;
      height: 74rpx;
      text-align: center;
      line-height: 74rpx;
      background: linear-gradient(270deg, #FF6D20 0%, #F84221 100%);
      border-radius: 46rpx 46rpx;
      opacity: 1;
      font-size: 25rpx;
      font-family: PingFang SC-Medium, PingFang SC;
      font-weight: 500;
      color: #fff;

    }
  }



  .bg-img {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    /* #ifdef MP || APP-PLUS */
    z-index: -100;
    /* #endif */
    /* #ifdef H5 */
    z-index: -100;
    /* #endif */
    z-index: -100;
    filter: blur(0);
    overflow: hidden;


    img {
      width: 100%;
      height: 100%;
      filter: blur(30rpx);
      transform: scale(1.5);
    }
  }

  .site-box {
    width: 100%;
    height: 120rpx;
    margin-bottom: 26.32rpx;
    position: absolute;
    top: 0rpx;
    position: fixed;
    z-index: 999;
    padding-top: 30rpx;
    padding-right: 20rpx;

    // 位置
    .place_wrapper {
      color: #fff;
      margin-right: 24.56rpx;
      font-size: 30rpx;

      .town_name {
        margin-left: 21rpx;
      }
    }

    .iconfont {
      font-size: 35.09rpx;
    }
  }


  .top_box {
    // padding-top: 180rpx;
    background: linear-gradient(#36A2FF, #fff);
  }

  .com {
    margin-left: 50%;
    transform: translate(-50%);
  }

  .business {
    width: 694.74rpx;
    // margin-bottom: 175rpx;
  }

  .special_work {
    // padding: 17.54rpx;
    width: 694.74rpx;
    // margin-top: 52.63rpx;
    padding-top: 32rpx;
    border-radius: 17.54rpx;

    // box-shadow: 0px 0px 6px 1px rgba(0, 0, 0, 0.16);
    .special_work-title {
      display: flex;
      margin-bottom: 50rpx;

      background-color: #efefef;
      padding: 10rpx 10rpx;

      .special_work-titlea {
        width: 40rpx;
        height: 40rpx;

        image {
          width: 100%;
          height: 100%;
        }
      }

      .special_work-titleb {
        font-size: 23rpx;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #737373;
        margin-top: 5rpx;
      }

      .special_work-titlec {
        font-size: 23rpx;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #16C295;
        margin-top: 5rpx;
      }

      .special_work-titled {
        font-size: 23rpx;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        margin-top: 5rpx;
      }
    }

    .title {
      font-size: 31.58rpx;
      font-weight: 700;
      margin-bottom: 38.6rpx;
    }

    .content {
      display: flex;
      align-content: center;
      flex-wrap: wrap;
      // justify-content: space-between;

      .examine {
        margin-bottom: 35rpx;
        width: 173.68rpx;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        // margin: 0 0 33.33rpx 33.33rpx !important;

        .icon_img {
          width: 120rpx;
          height: 120rpx;
        }

        .text {
          font-size: 26.32rpx;
          margin-top: 21.05rpx;
          color: #000;
        }
      }

      .text {
        font-size: 29.82rpx;
        color: #a4a4a4;
      }
    }

    .cont_jus {
      margin-top: 56.14rpx;
      justify-content: flex-start;

      &:first-child {
        // margin-right: 33rpx;
      }

      .examine {
        margin-right: 48rpx;

        &:first-child {
          margin-right: 48rpx;
        }
      }
    }
  }
</style>