<view id="createGroup">
  <view wx:if="{{step == 1}}">
    <van-cell-group>
      <van-field required input-align="right" value="{{ form.title }}" placeholder="请输入活动标题" label="活动标题"
        bind:change="onChangetitle" />
      <van-field required input-align="right" right-icon='arrow' value="{{ has_one_goods.title }}" placeholder="请选择活动商品"
        label="活动商品" clickable readonly disabled='{{disableds}}' bindtap="getCategoryOne" />
      <!-- bind:click-icon="getCategoryOne" -->
    </van-cell-group>
    <view class="upload-img-box" wx:if="{{has_one_goods.title}}">
      <view class="selest-goods">
        <image src="{{has_one_goods.thumb}}" alt="" />
        <view class="goods-right">
          <view class="g-titles" style="font-size:0.875rem">{{ has_one_goods.title }}</view>
          <view class="g-titles">库存：{{ has_one_goods.stock }}</view>
          <view class="g-titles">价格：￥{{ has_one_goods.price }}</view>
        </view>
      </view>
    </view>
    <van-field required input-align="right" disabled='{{disableds}}' value="{{ start_time }}" placeholder="请选择开始时间"
      label="开始时间" bindtap="showTime" data-index="1" is-link readonly />
    <van-field input-align="right" disabled='{{disableds}}' value="{{ end_time }}" placeholder="请选择结束时间" label="结束时间"
      bindtap="showTime" data-index="2" is-link readonly />
    <view class="text">
      PS:结束时间可不填，若不填商品详情页也不展示结束时间；不填则活动不会自动结束，需手动结束！
    </view>
    <view class="level-box">
      <view class="big-titel">
        <view>拼团层级</view>
        <view class="btn-class bg-color add-margin" bindtap="addTier" wx:if="{{!disableds}}">+ 新增一个拼团层级</view>
        <view class="small-text">最多可设置3个阶梯</view>
      </view>
      <view class="add-level">
        <view class="add-level-title">
          <view class="w20">层级</view>
          <view class="w30">拼团人数</view>
          <view class="w30">拼团时间</view>
          <view class="w20">操作</view>
        </view>
        <view class="edit-level">
          <view class="small-text no-blank" wx:if="{{form.has_many_level.length==0}}">暂无数据</view>
          <view class="level-edit" wx:for="{{form.has_many_level}}" wx:for-index="index" wx:for-item="item"
            wx:key="index">
            <view class="w20">{{ item.level_num }}</view>
            <view class="w30"><input type="number" bindinput='changeLevelInput' data-index="{{index}}"
                data-tag="member_num" class="{{disableds ? 'disableds-input' : ''}}" placeholder='填写人数' disabled='{{disableds}}' value="{{item.member_num}}" />人</view>
            <view class="w30"><input type="number" placeholder='填写时间' value="{{item.expire_in}}"
                bindinput='changeLevelInput' data-index="{{index}}" data-tag="expire_in" />小时</view>
            <view class="w20 del-color" bindtap="delTier" data-index="{{index}}" wx:if="{{!disableds}}">删除</view>
          </view>
        </view>
      </view>
    </view>
    <view class="checkbox-box">
      <view class="label-box">展示设置</view>
      <van-checkbox class="checkbox-main" value="{{ form.menu_show }}" checked-color="#ee0a24" shape="square"
        bind:change="onChangeMenu">
        隐藏开关<icon class="iconfont icon-ht_tips" catchtap="showTextPopup"></icon>
      </van-checkbox>
    </view>
    <view wx:if="{{form.menu_show}}" class="file-diystyle">当可参的团数达到
      <van-field bind:input='inputHideNum' custom-style='width:120rpx;background: #dedede;' type='digit'
        wx:if="{{form.menu_show}}" value="{{form.hide_num}}" label="" placeholder="" />时，隐藏开团按钮</view>
    <view class="checkbox-box">
      <view class="label-box">团长福利</view>
      <van-checkbox class="checkbox-main" value="{{ form.is_coupon }}" checked-color="#ee0a24" shape="square"
        bind:change="onChangeCoupon">
        团长送优惠券
      </van-checkbox>
    </view>
    <!--团长福利 团长送优惠券 -->
    <view class="coupon-box" wx:if="{{form.is_coupon}}">
      <view class="select-btn btn-class bg-color" wx:if="{{form.is_coupon}}" bindtap="openCoupon">+ 选择优惠券</view>
      <view class="coupon-list">
        <view class="coupon-child" wx:for="{{form.coupon}}" wx:for-index="index" wx:for-item="item" wx:key="index">
          <view class="coupon-name">{{ item.name }}</view>
          <view class="coupon-num">赠送 <input type="number" bindinput='changeCouponInput' data-index="{{index}}"
              value="{{item.coupon_num}}" /> 张</view>
          <view class="coupon-del del-color" bindtap="delCoupon" data-index="{{index}}"> 删除</view>
        </view>
      </view>
    </view>
    <!-- ------------end--------------- -->
    <view class="checkbox-box">
      <view class="label-box">老拉新</view>
      <van-checkbox class="checkbox-main" value="{{ form.is_lead }}" checked-color="#ee0a24" shape="square"
        bind:change="onChangeLead">
        开启老拉新<icon class="iconfont icon-ht_tips" catchtap="showTextPopup1"></icon>
      </van-checkbox>
    </view>
    <van-field wx:if="{{!form.is_lead}}" type='number' value="{{form.setting}}" label="拼团设置" bind:input='inputLead'
      placeholder="每人最多参加几次不同的团" />

    <!-- ------------end--------------- -->
    <view class="big-titel" style="padding:0 0.938rem;">活动分享</view>
    <view class="share-config">
      <view class="config-title">标题</view>
      <view class="config-content">
        <textarea bindinput="inputShare" bindblur="inputblurShare" id="share_title" data-tag="share_title"
          value="{{form.share_title}}" auto-height placeholder="原价￥《商品最高价》，现价￥《商品最低价》起，参加《拼团活动名称》即可享受" />
        <!-- <van-field value="{{form.share_title}}" rows="2" autosize id="share_title" type="textarea"
        bind:input='inputShare' data-tag="share_title" placeholder="原价￥《商品最高价》，现价￥《商品最低价》起，参加《拼团活动名称》即可享受" /> -->
      </view>
      <view class="add-confid">
        <view>点击添加数据</view>
        <view class="add-btn">
          <view class="btn-class" wx:for="{{keywords.share_title}}" wx:for-index="index" wx:for-item="item"
            wx:key="index" bindtap="addContent" data-name="share_title" data-index="{{index}}" data-num="1">{{ item }}
          </view>
        </view>
      </view>
      <!-- ------------end--------------- -->
      <view class="config-title">商家说明</view>
      <view class="config-content">
        <textarea bindinput="inputShare" bindblur="inputblurShare" id="share_content" data-tag="share_content"
          value="{{form.share_content}}" auto-height placeholder="活动商品数量有限，先到先得" />
        <!-- <van-field value="{{form.share_content}}" rows="2" id="share_content" autosize type="textarea"
        bind:input='inputShare' data-tag="share_content" placeholder="活动商品数量有限，先到先得" /> -->
      </view>
      <view class="add-confid">
        <view>点击添加数据</view>
        <view class="add-btn">
          <view class="btn-class" wx:for="{{keywords.share_content}}" wx:for-index="index" wx:for-item="item"
            wx:key="index" bindtap="addContent"  data-name="share_content" data-index="{{index}}" data-num="2">{{ item }}
          </view>
        </view>
      </view>
      <!-- ------------end--------------- -->
      <view class="big-titel" style="padding:0">活动详情分享</view>
      <view class="config-title">标题</view>
      <view class="config-content">
        <textarea bindinput="inputShare" bindblur="inputblurShare" id="desc_title" data-tag="desc_title"
          value="{{form.desc_title}}" auto-height placeholder="我已经参加了《团长名称》发起的拼团" />
        <!-- <van-field value="{{form.desc_title}}" rows="2" autosize id="desc_title" type="textarea"
        bind:input='inputShare' data-tag="desc_title" placeholder="我已经参加了《团长名称》发起的拼团" /> -->
      </view>
      <view class="add-confid">
        <view>点击添加数据</view>
        <view class="add-btn">
          <view class="btn-class" wx:for="{{keywords.desc_title}}" wx:for-index="index" wx:for-item="item"
            wx:key="index" bindtap="addContent" data-name="desc_title" data-index="{{index}}" data-num="3">{{ item }}
          </view>
        </view>
      </view>
      <!-- ------------end--------------- -->
      <view class="config-title">商家说明</view>
      <view class="config-content">
        <textarea bindinput="inputShare" bindblur="inputblurShare" id="desc_content" data-tag="desc_content"
          value="{{form.desc_content}}" auto-height placeholder="满足《拼团人数》人即可享受拼团优惠，我已经参加，你也来吧。" />
        <!-- <van-field value="{{form.desc_content}}" rows="2" id="desc_content" autosize type="textarea"
        bind:input='inputShare' data-tag="desc_content" placeholder="满足《拼团人数》人即可享受拼团优惠，我已经参加，你也来吧。" /> -->
      </view>
      <view class="add-confid">
        <view>点击添加数据</view>
        <view class="add-btn">
          <view class="btn-class" wx:for="{{keywords.desc_content}}" wx:for-index="index" wx:for-item="item"
            wx:key="index" bindtap="addContent" data-name="desc_content" data-index="{{index}}" data-num="4">{{ item }}
          </view>
        </view>
      </view>
      <!-- ------------end--------------- -->
      <view class="next-btn" bindtap="next">下一步</view>
    </view>
  </view>
  <view wx:if="{{step == 2}}" id="groupDataStatistics">
    <van-nav-bar title="设置拼团价" />
      <van-sticky>
        <view class="list line">
          <view class="list-small">规格</view>
          <view class="list-small">原价(元)</view>
          <view class="list-big">拼团价格</view>
          <view class="list-big">活动库存</view>
          <view class="list-big">限购件数(0为不限购)</view>
        </view>
      </van-sticky>
      <view class="list-main">
        <view class="list " wx:for="{{form.has_many_options}}" wx:for-index="index" wx:for-item="item"
            wx:key="index">
          <view class="list-small">{{ item.option_title }}</view>
          <view class="list-small">{{ item.option_price }}</view>
          <view class="list-big">
            <view class="list-child" wx:for="{{item.has_many_option_level}}" wx:for-index="index1" wx:for-item="item1"
            wx:key="index1" >
              <view class="list-child-margin">{{ item1.member_num }}人团 <input type="number" bindinput='changeGroupPrice' data-index="{{index}}"
                data-index1="{{index1}}" value="{{item1.group_price}}" />  元</view>
            </view>
          </view>
          <view class="list-big">
            <view class="list-child">
              <view class="list-child-margin">
                <input type="number" bindinput='changeStock' data-index="{{index}}" value="{{item.stock}}" /> 
              </view>
            </view>
          </view>
          <view class="list-big">
            <view class="list-child">
              <view class="list-child-margin">
                <input type="number" bindinput='changeLimit' data-index="{{index}}" value="{{item.buy_limit}}" /> 
              </view>
            </view>
          </view>
        </view>
      </view>
      <view class="btn-main">
        <view class="next-btn" bindtap="last" style="background: #fff;color: #666;border: 1px solid #ececec;">上一步</view>
        <view class="next-btn" bindtap="submitForm">保存</view>
      </view>
  </view>
</view>

<van-popup show="{{ showSearchGood }}" class="search-good-class" position="bottom"
  custom-style="height: 80%; width: 100%">
  <van-nav-bar title="选择您的商品" right-text="关闭" bind:click-right="cloneSearchGood" />
  <view class="searchgood-top">
    <van-search value="{{kwd}}" shape="round" use-action-slot show-action placeholder="请输入标题"
      bind:search="getChildCate" bind:change="onChangeCate">
      <view slot="action" bind:tap="getChildCate">搜索</view>
    </van-search>
    <van-dropdown-menu class="classic">
      <van-dropdown-item value="{{ category1 }}" disabled='{{category1_disabled}}' options="{{ categoryOption1 }}"
        bind:change="selectCate1" />
      <van-dropdown-item value="{{ category2 }}" id="categoryShow2" disabled='{{category1_disabled}}'
        options="{{ categoryOption2 }}" bind:change="selectCate2" />
    </van-dropdown-menu>
  </view>
  <van-radio-group value="{{goodradio}}" class="search-goodlist">
    <van-cell-group>
      <van-cell clickable class="goodchild" wx:for="{{listOne}}" wx:for-index="index" wx:for-item="item" wx:key="index">
        <van-radio name="{{index}}" disabled="{{item.has_many_activity_goods_count >= 1 ? true : false}}" checked-color="#ee0a24" bindtap="clickGoodRadio" data-item="{{item}}"
          data-index="{{index}}">
          <view class="search-goodlist-main">
            <image src="{{item.thumb}}" alt="" />
            <view class="search-goodlist-main-right">
              <view class="good-title">{{ item.title }}</view>
              <view class="good-other">
                <view style="color:#ff2c29;">ID：{{ item.id }}</view>
                <view style="color: #666666;">库存：{{ item.stock }}</view>
              </view>
              <view class="good-price">￥{{ item.price }}</view>
            </view>
          </view>
        </van-radio>
      </van-cell>
    </van-cell-group>
  </van-radio-group>
  <view class="good-more-btn" wx:if="{{isLoadMore}}" bindtap="getMore">加载更多</view>
</van-popup>
<!-- 开始时间 -->
<van-popup show="{{ showStartTime}}" position="bottom" close-on-click-overlay="{{false}}">
  <van-datetime-picker value="{{currentStartTime}}" type="datetime" title="选择开始时间" min-date="{{minDate}}"
    bind:cancel="cancelStartTime" bind:confirm="confirmStartTime" />
</van-popup>
<!-- 结束时间 -->
<van-popup show="{{ showEndTime}}" position="bottom" close-on-click-overlay="{{false}}">
  <van-datetime-picker value="{{currentEndTime}}" type="datetime" cancel-button-text="重置" title="选择结束时间"
    min-date="{{minDate}}" bind:cancel="cancelEndtTime" bind:confirm="confirmEndtTime" />
</van-popup>
<van-popup show="{{ coupon_show }}" position="bottom" close-on-click-overlay="{{false}}"
  custom-style="height: 80%; width: 100% ">
  <van-nav-bar title="选择优惠券" right-text="确定" bind:click-right="onCloneCoupon" />
  <view class="coupon_list">
    <van-search value="{{coupon_keyword}}" shape="round" use-action-slot show-action placeholder="请输入标题"
      bind:search="searchCoupon" bind:change="onChangeCouInput">
      <view slot="action" bind:tap="searchCoupon">搜索</view>
    </van-search>
    <van-checkbox-group value="{{coupon_result}}">
      <van-checkbox checked-color="#f14e4e" name="{{index}}" bindtap="chooseCoupon" data-item="{{item}}" data-index="{{index}}" wx:for="{{coupon_list}}" wx:for-index="index"
        wx:for-item="item" wx:key="index">
        <view class="shopCoupon">
          <view class="shopCouponNew">
            <view class="left">
              <view class="postLeft" style="background-image: url(https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/couponsbg_1.png)">
                <block wx:if="{{item.coupon_method == 1}}">
                  <view class="textOne" style=" font-size: {{item.deduct.length > 5 ? '0.7rem' : '' }}">
                    ￥{{ item.deduct }} </view>
                  <view class="line"></view>
                  <view class="textTwo">满{{ item.enough }}可用</view>
                </block>
                <block wx:if="{{item.coupon_method == 2}}">
                  <view class="textOne">{{ item.discount }}折</view>
                  <view class="line"></view>
                  <view class="textTwo">满{{ item.enough }}立享</view>
                </block>
              </view>
            </view>
            <view class="right">
              <view class="coupon_name">{{ item.name }}</view>
              <view class="coupon_total">剩余数量：{{ item.total - item.enough > 0 ? item.total - item.enough : 0 }}</view>
            </view>
          </view>
        </view>
      </van-checkbox>
    </van-checkbox-group>
  </view>
</van-popup>