<!-- type 1拼多多 2淘宝 -->
<template>
  <div class="container">
    <div
      class="l_tabBar flex_r flex_jb"
    >
      <div class="search-box flex_r flex_jb">
        <div class="search flex_r flex_jb flex_ac">
          <span class="iconfont">&#xe661;</span>
          <input
            v-model="keyword"
            @confirm="toSearch"
            class="inp"
            placeholder="搜索你要的内容"
          />
          <span class="search_btn" @click="toSearch">搜索</span>
        </div>
      </div>
    </div>
    <!-- 平台-start -->
    <div class="nav_box flex_r">
      <div
        class="item flex_c flex_ac"
        v-for="(i, s) in platform"
        :key="s"
        @click="toPlatform(i,s)"
      >
        <uni-badge
          size="small"
          :text="i.badge"
          absolute="rightTop"
          type="error"
        >
          <img :src="i.image" alt="" class="ico" />
        </uni-badge>

        <div class="tit">{{ i.name }}</div>
        <div class="tit1">{{ i.text }}</div>
      </div>
    </div>
    <!-- 平台-end -->
    <!-- 平台切换-start -->
    <div class="flex_r flex_ac">
      <div
        :class="navIndex == s ? 'nav nav-active' : 'nav'"
        v-for="(i, s) in platform"
        :key="s"
        @click="changeNav(i, s)"
      >
        <span>{{ i.name }}</span>
      </div>
    </div>
    <!-- 平台切换-end -->
    <!-- 平台下分类-start -->
    <div class="sort_box flex_r  flex_ac">
      <div
        :class="sortIndex == s ? 'sort sort-active' : 'sort'"
        v-for="(i, s) in sort"
        :key="s"
        @click="search(i, s)"
      >
        <span>{{ i.cat_name }}</span>
      </div>
    </div>
    <view class="product-list" v-if="goods.length > 0 && platformObj.type == 8">
      <view
        class="product"
        v-for="(i, s) in goods"
        :key="s"
        @click="NavToGoodsDetail(i)"
      >
        <view class="image-view">
          <image class="product-image" :src="i.goods.original_img"></image>
        </view>
        <view class="content-view">
          <view :class="['product-title', 'ellipsis2']">{{
            i.goods_name
          }}</view>
          <view class="product-price">
            <text class="product-price-original product-price-original1">{{ i.cost_price }}</text>
            <text class="product-text" v-if="['3', '4'].includes(type)"
              >赠<text class="corFE2C15">{{ i.give_cha_bao }}</text
              >贡献值</text
            >
          </view>
          <view class="product-txt" v-if="type == 4">
            <text class="product-price-favour">￥{{ i.market_price }}</text>
            <text class="product-text">消费券抵</text>
            <span class="corFE2C15">￥{{ Number(i.consume) }}</span>
          </view>
          <!-- <view class="product-txt" v-if="type == 1">赠送{{ i.give_integral + "批发券" }}</view> -->
          <view class="product-txt" v-if="type == 6"
            >每<text class="green">{{ i.interval_time }}</text> 分钟降价
            <text class="green">{{ i.drop_range * 100 }}%</text>
          </view>
          <view class="product-txt" v-if="['3'].includes(type)"
            >限时赠送<text class="corFE2C15">{{ i.teac }}</text
            >TeaC</view
          >
          <view class="product-txt fenxiang" v-if="['3'].includes(type)">
            <text class="iconfont red">&#xe62b;</text>
            <text class="red"
              >分享约获得{{ i.first_teac
              }}{{ type == 3 ? "TeaC" : "现金" }}</text
            >
          </view>
          <view v-if="['4'].includes(type)" class="flex_r flex_ac">
            <view class="product-txt"
              >赠<text class="corFE2C15">{{ i.teac }}</text
              >TeaC</view
            >
            <!-- <view class="product-txt fenxiang" style="background-color: rgba(0, 0, 0, 0);">
              <text class="iconfont red">&#xe62b;</text>
              <text class="red"
                >{{ i.first_teac }}</text
              >
            </view> -->
          </view>
        </view>
      </view>
    </view>
    <!-- 平台下分类-end -->
    <view class="product-list" v-if="goods.length > 0 && platformObj.type != 5 && platformObj.type != 8">
      <view
        class="product"
        v-for="(i, s) in goods"
        :key="s"
        @click="NavToGoodsDetail(i)"
      >
        <view class="image-view" v-if="platformObj.type == 1">
          <image class="product-image" :src="i.goods_image_url"></image>
        </view>
        <view class="image-view" v-else-if="platformObj.type == 2">
          <image
            class="product-image"
            :src="i.item_basic_info.pict_url"
          ></image>
        </view>
        <view class="image-view" v-else-if="platformObj.type == 3">
          <image
            class="product-image"
            :src="i.imageInfo.imageList[0].url"
          ></image>
        </view>
        <view class="content-view">
          <view :class="['product-title', 'ellipsis2']">
            <span class="product-type">
              {{ platformObj.name }}
            </span>
            <span v-if="platformObj.type == 1">{{ i.goods_name }}</span>
            <span v-else-if="platformObj.type == 2">{{
              i.item_basic_info.title
            }}</span>
            <span v-else-if="platformObj.type == 3">{{ i.skuName }}</span>
          </view>
          <!-- 拼多多 -->
          <template v-if="platformObj.type == 1">
            <view class="quan_box flex_r flex_as flex_wrap">
              <view class="quan" v-if="i.has_coupon">
                <span class="pl">券</span>
                <span>￥{{ i.coupon_discount / 100 }}</span>
              </view>
              <view class="quan">
                <span>赠付宝：</span>
                <span>
                  {{
                    Math.floor(
                      (i.min_group_price / 100) *
                        (i.promotion_rate / 1000) *
                        platformObj.ratio *
                        100
                    ) / 100
                  }}
                </span>
              </view>
              <view class="quan">
                <span>赠贡献值：</span>
                <span>
                  {{
                    Math.floor(
                      (i.min_group_price / 100 - i.coupon_discount / 100) *
                        platformObj.chabao *
                        100
                    ) / 100
                  }}
                </span>
              </view>
            </view>
            <view class="product-price">
              <text class="product-price-original">
                {{
                  Math.floor(
                    (i.min_group_price / 100 - i.coupon_discount / 100) * 100
                  ) / 100
                }}
              </text>
              <text class="product-price-favour"
                >￥{{ i.min_group_price / 100 }}</text
              >
            </view>
          </template>
          <!-- 淘宝 -->
          <template v-else-if="platformObj.type == 2">
            <view class="quan_box flex_r flex_as flex_wrap">
              <view class="quan" v-if="i.coupon_discount > 0">
                <span class="pl">券</span>
                <span>￥{{ i.coupon_discount }}</span>
              </view>
              <view class="quan">
                <span>赠付宝：</span>
                <span>
                  {{
                    Math.floor(
                      ((i.price_promotion_info.final_promotion_price *
                        i.publish_info.income_rate) /
                        100) *
                        platformObj.ratio *
                        100
                    ) / 100
                  }}
                </span>
              </view>
              <view class="quan">
                <span>赠贡献值：</span>
                <span>
                  {{
                    Math.floor(
                      i.price_promotion_info.final_promotion_price *
                        platformObj.chabao *
                        100
                    ) / 100
                  }}
                </span>
              </view>
            </view>
            <view class="product-price">
              <text class="product-price-original">
                <!-- // Math.floor(
                  //   (i.min_group_price / 100 - i.coupon_discount / 100) * 100
                  // ) / 100 -->
                {{ i.price_promotion_info.final_promotion_price }}
              </text>
              <text class="product-price-favour">
                ￥{{ i.price_promotion_info.zk_final_price }}
              </text>
            </view>
          </template>
          <!-- 京东 -->
          <template v-else-if="platformObj.type == 3">
            <view class="quan_box flex_r flex_as flex_wrap">
              <view class="quan" v-if="i.coupon_discount > 0">
                <span class="pl">券</span>
                <span>￥{{ i.coupon_discount }}</span>
              </view>
              <view class="quan">
                <span>赠付宝：</span>
                <span>
                  {{
                    Math.floor(
                      ((i.priceInfo.lowestCouponPrice *
                        i.commissionInfo.commissionShare) /
                        100) *
                        platformObj.ratio *
                        100
                    ) / 100
                  }}
                </span>
              </view>
              <view class="quan">
                <span>赠贡献值：</span>
                <span>
                  {{
                    Math.floor(
                      i.priceInfo.lowestCouponPrice * platformObj.chabao * 100
                    ) / 100
                  }}
                </span>
              </view>
            </view>
            <view class="product-price">
              <text class="product-price-original">
                <!-- // Math.floor(
                  //   (i.min_group_price / 100 - i.coupon_discount / 100) * 100
                  // ) / 100 -->
                {{ i.priceInfo.lowestCouponPrice }}
              </text>
              <text class="product-price-favour">
                ￥{{ i.priceInfo.price }}
              </text>
            </view>
          </template>
          <!-- 美团 -->
          <template v-else-if="platformObj.type == 5">
            <view class="quan_box flex_r flex_as flex_wrap">
              <!-- <view class="quan" v-if="i.coupon_discount > 0">
                <span class="pl">券</span>
                <span>￥{{ i.coupon_discount }}</span>
              </view> -->
              <view class="quan">
                <span>赠付宝：</span>
                <span>
                  {{
                    Math.floor(
                      (i.couponPackDetail.sellPrice *
                        Number(i.commissionInfo.commissionPercent) /
                        10000) *
                        platformObj.ratio *
                        100
                    ) / 100
                  }}
                </span>
              </view>
              <view class="quan">
                <span>赠贡献值：</span>
                <span>
                  {{
                    Math.floor(
                      i.couponPackDetail.sellPrice * platformObj.chabao * 100
                    ) / 100
                  }}
                </span>
              </view>
            </view>
            <view class="product-price">
              <text class="product-price-original">
                <!-- // Math.floor(
                  //   (i.min_group_price / 100 - i.coupon_discount / 100) * 100
                  // ) / 100 -->
                {{ i.couponPackDetail.sellPrice }}
              </text>
              <text class="product-price-favour">
                ￥{{ i.couponPackDetail.originalPrice }}
              </text>
            </view>
          </template>
        </view>
      </view>
    </view>
    <view class="product-list" v-if="goods.length > 0 && platformObj.type == 5">
      <view
        class="product type5"
        v-for="(i, s) in goods"
        :key="s"
      >
        <view class="flex_r flex_jb flex_ac">
          <view class="image-view">
            <image
              class="product-image"
              :src="i.couponPackDetail.headUrl"
            ></image>
          </view>
          <view class="content-view">
            <view :class="['product-title', 'ellipsis2']">
              <span class="product-type">
                {{ platformObj.name }}
              </span>
              <span>{{ i.couponPackDetail.name }}</span>
            </view>
            <view class="flex_r flex_jb flex_ae">
              <view class="product-price">
                <text class="product-price-original">
                  {{ i.couponPackDetail.sellPrice }}
                </text>
                <text class="product-price-favour"
                  >￥{{ i.couponPackDetail.originalPrice }}</text
                >
              </view>
              <view class="buyed"> {{ i.couponPackDetail.saleVolume }} </view>
            </view>
              <view class="quan_box flex_r flex_as flex_wrap">
                <!-- <view class="quan" v-if="i.coupon_discount > 0">
                  <span class="pl">券</span>
                  <span>￥{{ i.coupon_discount }}</span>
                </view> -->
                <view class="quan">
                  <span>赠付宝：</span>
                  <span>
                    {{
                      Math.floor(
                        (i.couponPackDetail.sellPrice *
                          Number(i.commissionInfo.commissionPercent) /
                          10000) *
                          platformObj.ratio *
                          100
                      ) / 100
                    }}
                  </span>
                </view>
                <view class="quan">
                  <span>赠贡献值：</span>
                  <span>
                    {{
                      Math.floor(
                        i.couponPackDetail.sellPrice * platformObj.chabao * 100
                      ) / 100
                    }}
                  </span>
                </view>
              </view>
              <view class="shop"> {{ i.brandInfo.brandName || i.deliverablePoiInfo.poiName || "美团外卖" }} </view>
          </view>
        </view>
        <view class="flex_r flex_ac flex_jb ">
          <view class="mtBtn1" @click="copyMt(i)">分享好友</view>
          <view class="mtBtn2" @click="toMt(i)">立即抢券</view>
        </view>
      </view>
    </view>
    <not-goods v-if="goods.length <= 0" textStr="暂无数据"></not-goods>
    <!-- 精品推荐-end -->
    <view class="fz_w_text">好生活，茶付宝！</view>
  </div>
</template>
<script>
let page = 1;
import { post } from "@/request/api.js";
import uniCopy from "@/utils/copy";
import notGoods from "@/components/not-goods/index.vue";
export default {
  components: { notGoods },
  data() {
    return {
      goods: [], // 商品列表
      haveGoods: false, // 是否有商品
      platform: [], //平台
      navIndex: 0, // 平台索引
      sort: [], //分类
      sortIndex: 0, // 分类索引
      head: false,
      keyword: "", // 搜索关键字
      banner: {}, // 顶部背景图
      ratio: 0, // 比例
      platformObj: {
        type: 8,
      }, // 选中平台
      catObj: {
        cat_id: 0,
        cat_name: "",
      }, //选中的分类
      type: 4, //享好物的固定类型
      categoryId: 11,
    };
  },
  async mounted() {
    // this.platform = [];
    // this.navIndex = 0;
    // this.platformObj = {
    //   type: 1,
    // };
    // this.sortIndex = 0;
    // this.sort = [];
    // this.catObj = {
    //   cat_id: 0,
    //   cat_name: "",
    // };

    this.getIcon();
    uni.setTabBarStyle({
      color: "#999",
      selectedColor: "#E68B1E",
    });
    page = 1;
    this.goods = [];
    this.duoduoCats();
    this.goodsDay();
    this.$bus.$on("onReachBottom", (url) => {
      console.log(this.platformObj.type)
      if (page != -1) {
        setTimeout(() => {
          ++page;
          this.goodsDay();
        }, 500);
      }
    });
  },
  created(da) {
    this.getIcon();
    uni.setTabBarStyle({
      color: "#999",
      selectedColor: "#E68B1E",
    });
    this.duoduoCats();
    this.goodsDay();
  },
  onHide() {},
  onPageScroll(e) {
    // if (e.scrollTop > 0) {
    //   this.head = true;
    // } else {
    //   this.head = false;
    // }
  },
  methods: {
    // 获取平台
    getIcon() {
      post("v1/cashback/getIcon", {isApp: 1}).then((res) => {
        if (res.code === 0) {
          this.platform = res.data;
          this.platform.length = 5; // 后期要去掉
          this.platformObj = this.platform[this.navIndex];
          this.ratio = this.platform[this.navIndex].ratio;
        } else {
          this.$toast(res.msg);
        }
      });
    },
    // 获取拼多多平台下的分类
    duoduoCats() {
      post("v1/cashback/duoduoCats").then((res) => {
        if (res.code === 0) {
          if (this.platformObj.type == 1) {
            this.sort = res.data.cats;
          }
          this.banner = res.data.banner[0];
        } else {
          this.$toast(res.msg);
        }
      });
    },
    // 获取淘宝平台下的分类
    taobaoCats() {
      post("v1/cashback/taobaoCats").then((res) => {
        if (res.code === 0) {
          this.sort = res.data.cats;
          this.catObj = this.sort[0];
        } else {
          this.$toast(res.msg);
        }
      });
    },
    // 获取京东平台下的分类
    jingdongCats() {
      post("v1/cashback/jingdongCats").then((res) => {
        if (res.code === 0) {
          this.sort = res.data.cats;
          this.catObj = this.sort[0];
        } else {
          this.$toast(res.msg);
        }
      });
    },
    // 获取美团平台下的分类
    meituanCats() {
      post("v1/cashback/meituanCats").then((res) => {
        if (res.code === 0) {
          this.sort = res.data.cats;
          this.catObj = this.sort[0];
        } else {
          this.$toast(res.msg);
        }
      });
    },
    // 切换平台
    changeNav(item, index) {
      this.sortIndex = 0;
      this.catObj = {
        cat_id: 0,
        cat_name: "",
      };
      this.sort = [];
      this.platformObj = item;
      this.navIndex = index;
      if (this.platformObj.type == 1) {
        this.duoduoCats();
      } else if (this.platformObj.type == 2) {
        this.taobaoCats();
      } else if (this.platformObj.type == 3) {
        this.jingdongCats();
      } else if (this.platformObj.type == 5) {
        this.meituanCats();
      }
      page = 1;
      this.goods = [];
      this.goodsDay();
    },
    // 跳转
    toPage(url) {
      this.goto(url);
    },
    toSearch() {
      page = 1;
      this.goods = [];
      this.goodsDay();
    },
    // 搜索/切换分类
    search(item, index) {
      this.catObj = item;
      this.sortIndex = index;
      page = 1;
      this.goods = [];
      this.goodsDay();
    },
    // 获取商品列表
    async goodsDay() {
      uni.showLoading();
      let that = this;
      let data = {};
      if (this.platformObj.type == 1) {
        // post("v1/cashback/taobaoList",{cat:"女装"}).then((res) => {
        data = { p: page, cat_id: this.catObj.cat_id, keyword: this.keyword };
        post("v1/cashback/duoduoList", data)
          .then((res) => {
            uni.hideLoading();
            if (res.code === 0) {
              let obj = JSON.parse(res.data).goods_search_response.goods_list;
              console.log(obj);

              if (page <= 1) that.goods = [];
              if (obj.length > 0) {
                obj.forEach((e) => {
                  that.goods.push(e);
                });
              } else {
                if (page == 1) {
                  that.haveGoods = true;
                  page = -1;
                } else {
                  page = -1;
                  this.$toast("暂无更多");
                }
              }
            } else {
              if (page == 1) {
                that.haveGoods = true;
                page = -1;
              } else {
                page = -1;
                this.$toast("暂无更多");
              }
            }
          })
          .catch((e) => {
            uni.hideLoading();
          });
      } else if (this.platformObj.type == 2) {
        this.catObj.cat_name
          ? (data = {
              p: page,
              cat: this.catObj.cat_name,
              keyword: this.keyword,
            })
          : (data = { p: page, keyword: this.keyword });

        post("v1/cashback/taobaoList", data)
          .then((res) => {
            uni.hideLoading();
            if (res.code === 0) {
              console.log(JSON.parse(res.data));
              let obj = JSON.parse(res.data)
                .tbk_dg_material_optional_upgrade_response.result_list.map_data;
              console.log(obj);

              obj.map((i) => {
                let arr =
                  i.price_promotion_info?.final_promotion_path_list
                    ?.final_promotion_path_map_data || [];

                if (arr.length > 0) {
                  for (let ii = 0; ii < arr.length; ii++) {
                    if (arr[ii].promotion_title == "商品券") {
                      i.coupon_discount = arr[ii].promotion_fee;
                      i.promotion_start_time = arr[ii].promotion_start_time;
                      i.promotion_end_time = arr[ii].promotion_end_time;
                    }
                  }
                } else {
                  i.coupon_discount = 0;
                  i.promotion_start_time = 0;
                  i.promotion_end_time = 0;
                }
                return i;
              });
              if (page <= 1) that.goods = [];
              if (obj.length > 0) {
                obj.forEach((e) => {
                  that.goods.push(e);
                });
              } else {
                if (page == 1) {
                  that.haveGoods = true;
                  page = -1;
                } else {
                  page = -1;
                  this.$toast("暂无更多");
                }
              }
            } else {
              if (page == 1) {
                that.haveGoods = true;
                page = -1;
              } else {
                page = -1;
                this.$toast("暂无更多");
              }
            }
          })
          .catch((e) => {
            uni.hideLoading();
          });
      } else if (this.platformObj.type == 3) {
        this.catObj.cat_name
          ? (data = {
              p: page,
              cat_id: this.catObj.cat_id,
              keyword: this.keyword,
            })
          : (data = { p: page, keyword: this.keyword });

        post("v1/cashback/jingdongList", data)
          .then((res) => {
            uni.hideLoading();
            if (res.code === 0) {
              let obj = JSON.parse(
                res.data.jd_union_open_goods_query_responce.queryResult
              ).data;
              console.log(obj);

              obj.map((i) => {
                if (i.couponInfo.couponList.length > 0) {
                  let arr = i.couponInfo.couponList;
                  for (let ii = 0; ii < arr.length; ii++) {
                    if (arr[ii].isBest == 1) {
                      i.coupon_discount = arr[ii].discount;
                      i.promotion_start_time = arr[ii].useStartTime;
                      i.promotion_end_time = arr[ii].useEndTime;
                    } else {
                      let couponInfo = i.couponInfo.couponList[0] || {};
                      i.coupon_discount = couponInfo.discount || 0;
                      i.promotion_start_time = couponInfo.useStartTime || 0;
                      i.promotion_end_time = couponInfo.useEndTime || 0;
                    }
                  }
                } else {
                  i.coupon_discount = 0;
                  i.promotion_start_time = 0;
                  i.promotion_end_time = 0;
                }
                return i;
              });
              if (page <= 1) that.goods = [];
              if (obj.length > 0) {
                obj.forEach((e) => {
                  that.goods.push(e);
                });
              } else {
                if (page == 1) {
                  that.haveGoods = true;
                  page = -1;
                } else {
                  page = -1;
                  this.$toast("暂无更多");
                }
              }
            } else {
              if (page == 1) {
                that.haveGoods = true;
                page = -1;
              } else {
                page = -1;
                this.$toast("暂无更多");
              }
            }
          })
          .catch((e) => {
            uni.hideLoading();
          });
      } else if (this.platformObj.type == 5) {
        let { lat, lng } = await uni.Location();

        this.catObj.cat_name
          ? (data = {
              pageNo: page,
              listTopiId: this.catObj.cat_id,
              searchText: this.keyword,
              latitude: lat,
              longitude: lng,
            })
          : (data = {
              pageNo: page,
              searchText: this.keyword,
              latitude: lat,
              longitude: lng,
              listTopiId: 2,
            });
        console.log(data);

        uni.request({
          url: "https://meituan-java.chafubao.cn/query_coupon", //仅为示例，并非真实接口地址。
          method: "POST",
          header: {
            token: uni.getStorageSync("token"),
            "Content-Type": "application/x-www-form-urlencoded",
          },
          data: data,
          success: (res) => {
            uni.hideLoading();
            console.log(res.data);
            if (res.data.statusCode === 200) {
              let obj = JSON.parse(
                res.data.body
              ).data;
              console.log(obj);

              if (page <= 1) that.goods = [];
              if (obj.length > 0) {
                obj.forEach((e) => {
                  that.goods.push(e);
                });
              } else {
                if (page == 1) {
                  that.haveGoods = true;
                  page = -1;
                } else {
                  page = -1;
                  this.$toast("暂无更多");
                }
              }
            } else {
              if (page == 1) {
                that.haveGoods = true;
                page = -1;
              } else {
                page = -1;
                this.$toast("暂无更多");
              }
            }
            
          },
          fail: (error) => {
            uni.hideLoading();
          }
        });
      } else if (this.platformObj.type == 8) {
        let that = this;
        let data = { page, type: 4, category_id: 11 };
        post("v1/goods/categoryInfo", data).then((res) => {
            if (res.code === 0) {
                let obj = res.data.data.data;
                console.log(obj);
                if (page <= 1) that.goods = [];
                if (obj.length > 0) {
                    obj.forEach((e) => {
                        that.goods.push(e);
                    });
                } else {
                    if (page == 1) {
                        that.haveGoods = true;
                        page = -1;
                    } else {
                        page = -1;
                        this.$toast("暂无更多");
                    }
                }
                uni.hideLoading();
            } else {
                if (page == 1) {
                    that.haveGoods = true;
                    page = -1;
                } else {
                    page = -1;
                    this.$toast("暂无更多");
                }
                uni.hideLoading();
            }
        });
      }
    },
    toPlatform(i,s) {
      if(i.url) {
        this.goto(i.url + '&name=' + i.name)
      } else {
        this.changeNav(i, s);
      }
    },
    // 跳转到商品详情页
    NavToGoodsDetail(item) {
      if (this.platformObj.type == 1) {
        this.goto("/pagesC/shoppingMallType/p_details", {
          goods_sign: item.goods_sign,
          type: this.platformObj.type,
        });
      } else if (this.platformObj.type == 2) {
        this.goto("/pagesC/shoppingMallType/p_details", {
          item_id: item.item_id,
          type: this.platformObj.type,
          annual_vol: item.item_basic_info.annual_vol,
          yj_price:
            Math.floor(
              ((item.price_promotion_info.final_promotion_price *
                item.publish_info.income_rate) /
                100) *
                this.platformObj.ratio *
                100
            ) / 100 || 0,
          goods_price: item.price_promotion_info.final_promotion_price,
          coupon_discount: item.coupon_discount,
          promotion_start_time: item.promotion_start_time,
          promotion_end_time: item.promotion_end_time,
        });
      } else if (this.platformObj.type == 3) {
        console.log(item);

        this.goto("/pagesC/shoppingMallType/p_details", {
          item_id: item.itemId,
          type: this.platformObj.type,
          annual_vol: item.inOrderCount30Days,
          yj_price:
            Math.floor(
              ((item.priceInfo.lowestCouponPrice *
                item.commissionInfo.commissionShare) /
                100) *
                this.platformObj.ratio *
                100
            ) / 100 || 0,
          goods_price: item.priceInfo.lowestCouponPrice,
          goods_price_origin: item.priceInfo.price,
          coupon_discount: item.coupon_discount,
          shopName: item.shopInfo.shopName,
          promotion_start_time: item.promotion_start_time,
          promotion_end_time: item.promotion_end_time,
        });
      } else if (this.platformObj.type == 8) {
        this.goto("/pages/product/p_details", { id: item.id, type: 4 });
      }
    },
    copyMt(item){
      uni.request({
        url: "https://meituan-java.chafubao.cn/get_referral_link", 
        method: "POST",
        header: {
          token: uni.getStorageSync("token"),
          "Content-Type": "application/x-www-form-urlencoded",
        },
        data: {
          skuViewId: item.couponPackDetail.skuViewId,
          linkType: 2,
          sid: uni.getStorageSync("userinfo").user_id
        },
        success: (res) => {
          uni.hideLoading();
          console.log(res.data);
          if (res.data.statusCode === 200) {
            let url = JSON.parse(
                res.data.body
              ).data;
            uniCopy({
              content: url,
              success: (res1) => {
                uni.showToast({
                  title: "链接已复制",
                  icon: "none",
                  duration: 2000,
                });
              },
              error: (e) => {},
            });
          }
          
        },
        fail: (error) => {
          uni.hideLoading();
        }
      });
    },
    // 前往美团小程序
    toMt(item){
      uni.request({
        url: "https://meituan-java.chafubao.cn/get_referral_link", 
        method: "POST",
        header: {
          token: uni.getStorageSync("token"),
          "Content-Type": "application/x-www-form-urlencoded",
        },
        data: {
          skuViewId: item.couponPackDetail.skuViewId,
          linkType: 4,
          sid: uni.getStorageSync("userinfo").user_id
        },
        success: (res) => {
          uni.hideLoading();
          console.log(res.data);
          if (res.data.statusCode === 200) {
            let url = JSON.parse(
                res.data.body
              ).data;
            wx.navigateToMiniProgram({
              appId: "wxde8ac0a21135c07d",
              path: url,
              extraData: {
              },
              envVersion: "release",
              success(res) {
                // 打开成功
                // _this.$refs.popup.close();
              },
            });
          }
          
        },
        fail: (error) => {
          uni.hideLoading();
        }
      });
      
    }
  },
  //页面上拉触底事件的处理函数
  onReachBottom() {
    if (page != -1) {
      setTimeout(() => {
        ++page;
        this.goodsDay();
      }, 500);
    }
  },
};
</script>
<style lang="scss" scoped>
// 页面配置
page {
  background: #f5f5f5;
}

.head {
  width: 100%;
  height: 160rpx;
  text-align: center;
  position: fixed;
  top: 0;
  z-index: 999;
  //   padding: calc(var(--status-bar-height) + 50rpx) 0 36rpx;
  background: #fff;
  .title {
    font-size: 16px;
    font-weight: 600;
    padding-top: calc(var(--status-bar-height) + 46rpx);
  }
}

// 页面配置-end

.product-list {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  flex-direction: row;
  padding: 0 30rpx;

  .product {
    width: 48.5%;
    margin-bottom: 20rpx;
    padding-bottom: 12rpx;
    border-radius: 10rpx;
    box-shadow: 4rpx 4rpx 8rpx 4rpx rgba(0, 0, 0, 0.06);
    background-color: #fff;

    &:nth-child(2n) {
      margin-left: 3%;
    }
  }

  .type5{
    width: 100%;
    margin-bottom: 20rpx;
    padding: 12rpx;
    border-radius: 10rpx;
    box-shadow: 4rpx 4rpx 8rpx 4rpx rgba(0, 0, 0, 0.06);
    background-color: #fff;
    &:nth-child(2n) {
      margin-left: 0%;
    }

    .product-image {
      border-radius: 10rpx;
      width: 29vw;
      height: 29vw;
      object-fit: cover;
    }
    .content-view {
      width: calc(100% - 29vw);
      padding: 0 16rpx;
      box-sizing: border-box;
    }
    .shop {
      font-size: 22rpx;
      color: #c4c4c4;
    }
    .buyed {
      color: #888888;
      font-size: 22rpx;
      margin: 16rpx 0 4rpx;
    }
    .quan_box {
      min-height: 0;
      font-size: 20rpx;
      color: #e90406;
      margin: 12rpx 0 14rpx;
    }
    .mtBtn1{
      width: 45%;
      color: #FE6232;
      text-align: center;
      font-size: 26rpx;
      font-weight: bold;
      letter-spacing: 2rpx;
      padding: 10rpx 0;
      border-radius: 50rpx;
      border: 1rpx solid #FE6232;
      margin-top: 15rpx;
    }
    .mtBtn2{
      width: 45%;
      color: #fff;
      text-align: center;
      font-size: 26rpx;
      font-weight: bold;
      letter-spacing: 2rpx;
      padding: 10rpx 0;
      border-radius: 50rpx;
      border: 1rpx solid #FE6232;
      background-color: #FE6232;
      margin-top: 15rpx;
    }
  }

  .product-image {
    border-radius: 10rpx 10rpx 0 0;
    width: 100%;
    height: 42.3vw;
    object-fit: cover;
  }

  .content-view {
    padding: 0 16rpx;
  }

  .product-title {
    width: 100%;
    overflow: hidden;
    line-height: 1.5;
    font-size: 26rpx;
    height: 80rpx;
    font-weight: bold;
    color: #121212;
  }
  .product-type {
    font-size: 16rpx;
    font-weight: bold;
    color: #fff;
    height: 26rpx;
    display: inline-block;
    line-height: 26rpx;
    padding: 0 8rpx;
    border-radius: 4rpx;
    margin-right: 16rpx;
    background-color: #e90406;
  }

  .product-price {
    color: #121212;
    font-size: 28rpx;
    // position: relative;
    margin: 16rpx 0 4rpx;
  }

  .product-price-original {
    color: #000;
    font-size: 32rpx;
    font-weight: bold;

    &:before {
      content: "￥";
      font-size: 20rpx;
    }
  }

  .product-price-original1 {
       color: #18bb88;
       font-size: 32rpx;
       font-weight: bold;

       &:before {
           content: "￥";
           font-size: 20rpx;
       }
   }

  .quan_box {
    min-height: 88rpx;
    font-size: 20rpx;
    color: #e90406;
    margin: 12rpx 0 0;

    .quan {
      padding: 2rpx 8rpx;
      border-radius: 8rpx;
      border: 1rpx solid rgba($color: #e90406, $alpha: 0.3);
      margin-right: 10rpx;
      margin-top: 6rpx;

      .pl {
        padding-right: 10rpx;
      }
    }
  }

  .product-price-favour {
    color: #888888;
    font-size: 22rpx;
    text-decoration: line-through;
    // margin-left: 20rpx;
  }

  .product-tip {
    position: absolute;
    right: 20rpx;
    background-color: #ff3333;
    color: #ffffff;
    padding: 0 20rpx;
    border-radius: 10rpx;
  }

  .product-unit {
    font-size: 24rpx;
    color: #18bb88;
  }

  .product-txt,
  .product-text {
    font-size: 22rpx;
    color: #787878;

    .iconfont {
      margin-right: 6rpx;
    }
  }

  .product-text {
    margin-left: 16rpx;
  }

  .red {
    color: #fa2e18;
  }

  .fenxiang {
    font-size: 20rpx;
    background: rgba(250, 46, 24, 0.08);
    display: inline-block;
    border-radius: 6rpx;
    padding: 0 16rpx;
  }
}

// 活动-end

.l_tabBar {
  // height: 400rpx;
  flex-wrap: wrap;
  padding: 10rpx 20rpx;
  border-radius: 10rpx;
  margin: 0 0 30rpx;
  //   background: url("https://img1.baidu.com/it/u=3052557249,4146060588&fm=253&fmt=auto&app=138&f=JPEG?w=1000&h=465")
  // no-repeat;
  // background-size: 100% 100%;

  .search-box {
    width: 100%;
    padding: 10rpx;
    // margin-top: 68rpx;
    margin-bottom: 12rpx;

    .district {
      font-size: 32rpx;
      font-weight: 600;
      color: #333;

      .iconfont {
        font-size: 20rpx;
        margin-left: 12rpx;
      }
    }

    .search {
      border: 1px solid #d78c2e;
      height: 60rpx;
      line-height: 60rpx;
      padding-left: 20rpx;
      border-radius: 31rpx;
      background-color: #fff;

      .iconfont {
        font-size: 30rpx;
      }

      .inp {
        font-size: 25rpx;
        padding: 0 8rpx;
        width: 500rpx;
      }

      .search_btn {
        background-color: #d78c2e;
        height: 100%;
        color: #fff;
        border-radius: 31rpx;
        font-size: 28rpx;
        padding: 0 28rpx;
      }
    }

    .scan-ico {
      font-size: 55rpx;
    }
  }
}

.nav_box {
  margin: -50rpx 0 10rpx;
  padding: 20rpx 20rpx;
  border-radius: 20rpx;
  flex-wrap: wrap;
  justify-content: space-between;
  background-color: #f5f6f8;

  .item {
    width: 17%;
    margin: 10rpx 10rpx;
  }

  .ico {
    width: 62rpx;
    height: 62rpx;
  }

  .tit {
    font-size: 24rpx;
    padding-top: 12rpx;
  }
  .tit1 {
    font-size: 20rpx;
    color: #a0a0a0;
  }
}
.nav {
  width: 25%;
  height: 40rpx;
  line-height: 40rpx;
  text-align: center;
  font-size: 28rpx;
  color: #a0a0a0;
  margin-bottom: 16rpx;
}
.nav:nth-child(2) {
  border-left: 1rpx solid rgba($color: #a0a0a0, $alpha: 0.5);
  border-right: 1rpx solid rgba($color: #a0a0a0, $alpha: 0.5);
}
.nav:nth-child(3) {
  border-right: 1rpx solid rgba($color: #a0a0a0, $alpha: 0.5);
}
.nav:nth-child(4) {
  border-right: 1rpx solid rgba($color: #a0a0a0, $alpha: 0.5);
}
.nav-active {
  color: #1f1f1f;
}
.sort_box {
  // position: sticky;
  position: -webkit-sticky;
  top: 110rpx;
  z-index: 999;
  left: 0;
  overflow: scroll;
  flex-wrap: nowrap;
  padding: 16rpx 0;
  margin: 0 30rpx 10rpx;
  background-color: #f5f6f8;

  .sort {
    white-space: nowrap;
    font-size: 23rpx;
    color: #a0a0a0;
    padding: 6rpx 15rpx;
    border-radius: 6rpx;
    border: 1rpx solid #fff;
    margin-right: 14rpx;
    background-color: #fff;
  }

  .sort-active {
    color: #15acda;
    border: 1rpx solid rgba($color: #58b0d9, $alpha: 0.5);
    background-color: rgba($color: #e3f3fd, $alpha: 1);
  }
}
.container {
  overflow: visible;
}
/* 隐藏滚动条 */
::-webkit-scrollbar {
  display: none;
}
</style>