<template>
  <view class="group-list">
    <navbar ref="navbar" :config="config"></navbar>
    <view class="today">
      <view class="today-item">
        <view class="today-left"> 今日必拼 </view>
        <!-- <view class="line">
					
				</view>
				<view class="surplus">
					16点场次仅剩
				</view>
				<view class="time">
					<text>00</text>:<text>07</text>:<text>43</text>
				</view> -->
      </view>
    </view>
    <!-- <view class="commodity" > -->
    <swiper
      class="commodity"
      v-if="groupList && groupList.length > 0"
      :indicator-dots="false"
      :autoplay="false"
      @change="imgActiveFun"
    >
      <!-- <view class="commodity-item"> -->
      <swiper-item
        v-for="(item, index) in groupList"
        :key="index"
        @click="
          goProductDetails('/pages/product/goods/puzzleGoods?id=' + item.id)
        "
      >
        <view class="commodity-item">
          <image :src="item.cover" mode=""></image>
          <view class="number">
            <text>{{ item.group_people_num}}人团 </text>
			<view class="u-FF0000 " style="font-weight: Bold;">
            <rich-text
              :nodes="$mUtil.priceBigSmall(item.min_price)"
            ></rich-text>
			</view>
          </view>
         <view class="completed" v-if="item.result_sale_num/10000>1">
            已有<text>{{ (item.result_sale_num/10000).toFixed(1)}}万</text> 人拼
          </view>
		  <view class="completed" v-else>
		  	已有<text>{{ item.result_sale_num}}</text> 人拼
		  </view>
        </view>
      </swiper-item>
      <!-- </view> -->
    </swiper>
    <!-- </view> -->
    <nodata v-else :config="{ top: 1, content: '暂无商品~' }"></nodata>
    <view class="option" v-if="groupList && groupList.length > 0">
      <!-- <view class="option-item active">
				
			</view> -->
      <view
        class="option-item"
        :class="{ active: activeBannerIndex == index }"
        v-for="(item, index) in groupList"
        :key="index"
      >
      </view>
    </view>
    <view class="content">
      <view class="content-top">
        <view class="content-left"> 精选商品 </view>
        <view class="line"> </view>
        <view class="content-right"> 热销优品快来拼购 </view>
      </view>
      <view class="middle" v-if="hotGroupList && hotGroupList.length > 0">
        <view
          class="middle-item"
          v-for="(item, index) in hotGroupList"
          :key="index"
          @click="
            goProductDetails('/pages/product/goods/puzzleGoods?id=' + item.id)
          "
        >
          <view class="image">
            <image :src="item.cover" mode=""></image>
          </view>
          <view class="middle-right">
            <view class="title u-text2">
              {{ item.title }}
            </view>
            <view class="large-box">
              <view class="box">
                <view class="number">
                  <view class="large">
                    <rich-text
                      :nodes="$mUtil.priceBigSmall(item.min_price)"
                    ></rich-text>
                  </view>
                  <view class="small">
                    <rich-text
                      :nodes="$mUtil.priceBigSmall(item.min_sale_price)"
                    ></rich-text>
                  </view>
                </view>
                <view class="three-people">
                  {{ item.group_people_num }}人拼，已拼<text>{{
                    item.result_sale_num
                  }}</text
                  >件
                </view>
              </view>
              <view class="go-group-work"> 去拼团 </view>
            </view>
          </view>
        </view>
        <loadMore v-if="hotGroupList.length > 0" :status="status"></loadMore>
      </view>
      <nodata v-else :config="{ top: 1, content: '暂无商品~' }"></nodata>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      config: {
        back: true, //false是tolbar页面 是则不写
        title: "拼团",
        color: "#FFFFFF",
        //背景颜色;参数一：透明度（0-1）;参数二：背景颜色（array则为线性渐变，string为单色背景）
        backgroundColor: [1, '#FA6138'],
        // statusBarFontColor: "#1A1A1A",
      },
      groupList: [],

      page: 1,
      hotGroupList: [],
      status: "more",
      activeBannerIndex: 0,
    
       params:{}
    
    };
  },
  onLoad(options) {

if(options.shopid){
  this.params.shop_id=options.shopid
   
}
  },
  onShow() {
    this.getGroup();
    this.getHotGroup();
  },
  onPullDownRefresh() {
    this.page = 1;
    this.hotGroupList = [];
    this.groupList = [];
    this.getGroup();
    this.getHotGroup();
    uni.stopPullDownRefresh();
  },
  onReachBottom() {
    this.page++;
    this.getHotGroup();
  },
  methods: {
    goProductDetails(url) {
      uni.navigateTo({
        url: url,
      });
    },
    imgActiveFun(e) {
      this.activeBannerIndex = e.detail.current;
    },
    getGroup() {
      this.$http
        .get(
          `/groupbuy/activitygoods/will-you-spell`,
          { limit: 12, page: 1 ,...this.params},
          false
        )
        .then((res) => {
          if (res && res.code == 200) {
            this.groupList = res.list;
          }
        });
    },
    getHotGroup() {
   
      this.$http
        .get(
          `/groupbuy/activitygoods/will-you-spell-page`,
          { limit: 10, page: this.page,...this.params },
          false
        )
        .then((res) => {
          if (res && res.code == 200) {
            this.hotGroupList =this.page==1? res.page.list:this.hotGroupList.concat(res.page.list);
            if (res.page.totalPage <= res.page.currPage) {
              this.status = "noMore";
            } else {
              this.status = "more";
            }
          }
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.middle {
  margin: 0 20rpx 0 0;
  .middle-item {
    display: flex;
    padding: 20rpx 0rpx 25rpx 16rpx;
    .image {
      image {
        width: 187rpx;
        height: 187rpx;
        border-radius: 18rpx;
      }
    }
    .middle-right {
      margin-left: 30rpx;
	 display: flex;
	 flex-direction: column;
	 justify-content: space-between;
	  
      width: 100%;
      .title {
        font-size: 28rpx;
        font-weight: 400;
        color: #181818;
      }
      .large-box {
        display: flex;
        align-items: flex-end;
        justify-content: space-between;
        .box {
          .number {
            display: flex;
            align-items: flex-end;
            margin-top: 25rpx;
            .large {
              font-size: 36rpx;
              color: #ff0000;
              font-weight: bold;
              text {
                font-size: 36rpx;
                color: 700;
              }
            }
            .small {
              font-size: 22rpx;
              font-weight: 500;
              color: #cccccc;
              text-decoration: line-through;
              margin-left: 16rpx;
            }
          }
          .three-people {
            font-size: 24rpx;
            color: #333333;
            font-weight: 400;
            text {
              color: #fe9000;
            }
          }
        }
        .go-group-work {
          color: #ffffff;
          font-size: 28rpx;
          font-weight: 500;
          padding: 12rpx 27rpx;
          background-color: #FA6138;
          border-radius: 32rpx;
        }
      }
    }
  }
}
.content {
  padding: 0 30rpx;
  background-color: #ffffff;
  overflow: hidden;
  .content-top {
    display: flex;
    align-items: center;
    margin-top: 36rpx;
    margin-bottom: 22rpx;
    .content-left {
      font-size: 36rpx;
      color: #1a1a1a;
      font-weight: 700;
    }
    .line {
      width: 1rpx;
      height: 33rpx;
      margin: 0 15rpx;
      background-color: #707070;
    }
    .content-right {
      font-size: 24rpx;
      color: #666666;
      font-weight: 400;
    }
  }
}
.option {
  margin: 30rpx 0;
  display: flex;
  justify-content: center;
  .option-item {
    background-color: #d9d9d9;
    margin: 0 8rpx;
    width: 14rpx;
    height: 14rpx;
    border-radius: 7rpx;
  }
  .active {
    background-color: #FA6138;
    width: 35rpx;
    height: 14rpx;
    border-radius: 7rpx;
  }
}

.commodity {
  margin-top: -195rpx;

  margin-left: 30rpx;
  margin-right: 30rpx;
  height: 367rpx;
  /deep/ .uni-swiper-slide-frame {
    width: 42% !important;
  }
  .commodity-item {
    // margin-right: 30rpx;
    border-radius: 16rpx;
    background-color: #ffffff;
    padding: 18rpx;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    image {
      width: 232rpx;
      height: 232rpx;
      border-radius: 16rpx;
    }
    .completed {
      font-size: 22rpx;
      margin-top: 2rpx;
      font-weight: 400;
      color: #333333;
      text {
        color: #ff0000;
      }
    }
    .number {
      margin-top: 20rpx;
      font-size: 22rpx;
      color: #333333;
      font-weight: 500;
      display: flex;
      align-items: center;
      .zero {
        margin-left: 20rpx;
        font-size: 22rpx;
        color: #ff0000;
        font-weight: 500;
      }
      .one {
        color: #ff0000;
        font-size: 34rpx;
        font-weight: 700;
      }
      .two {
        color: #ff0000;
        font-size: 18rpx;
        font-weight: 700;
      }
    }
  }
}

.today {
  background-color: #FA6138;
  overflow: hidden;
  height: 300rpx;
  .today-item {
    display: flex;
    align-items: center;
    margin: 30rpx;
    .today-left {
      font-size: 36rpx;
      color: #ffffff;
      font-weight: 700;
    }
    .line {
      width: 1rpx;
      height: 33rpx;
      background-color: #ffffff;
      margin: 0 15rpx;
    }
    .surplus {
      font-size: 24rpx;
      color: #ffffff;
      font-weight: 400;
      margin-right: 14rpx;
    }
    .time {
      font-size: 24rpx;
      font-weight: 500;
      color: #ffffff;
      text {
        color: #ff0000;
        padding: 0 4rpx;
        background-color: #dccda4;
        border-radius: 4rpx;
        margin: 0 4rpx;
      }
    }
  }
}
.group-list {
  background-color: #f6f6f6;
}
</style>
