"use strict";
const common_vendor = require("../../../common/vendor.js");
const sheep_index = require("../../../sheep/index.js");
const sheep_hooks_useGoods = require("../../../sheep/hooks/useGoods.js");
const sheep_api_promotion_bargain = require("../../../sheep/api/promotion/bargain.js");
require("../../../sheep/api/index.js");
require("../../../sheep/api/distri/score.js");
require("../../../sheep/request/index.js");
require("../../../sheep/config/index.js");
require("../../../sheep/store/index.js");
require("../../../sheep/store/app.js");
require("../../../sheep/api/promotion/diy.js");
require("../../../sheep/platform/index.js");
require("../../../sheep/platform/provider/wechat/index.js");
require("../../../sheep/platform/provider/wechat/miniProgram.js");
require("../../../sheep/api/member/auth.js");
require("../../../sheep/api/member/social.js");
require("../../../sheep/api/member/user.js");
require("../../../sheep/platform/provider/apple/index.js");
require("../../../sheep/platform/share.js");
require("../../../sheep/router/index.js");
require("../../../sheep/hooks/useModal.js");
require("../../../sheep/helper/index.js");
require("../../../sheep/helper/test.js");
require("../../../sheep/helper/digit.js");
require("../../../sheep/api/member/signin.js");
require("../../../sheep/helper/throttle.js");
require("../../../sheep/url/index.js");
require("../../../sheep/platform/pay.js");
require("../../../sheep/api/pay/order.js");
require("../../../sheep/store/user.js");
require("../../../sheep/store/cart.js");
require("../../../sheep/api/trade/cart.js");
require("../../../sheep/api/pay/wallet.js");
require("../../../sheep/api/trade/order.js");
require("../../../sheep/api/promotion/coupon.js");
require("../../../sheep/store/sys.js");
require("../../../sheep/store/modal.js");
require("../../../sheep/api/distri/share.js");
require("../../../sheep/api/distri/team.js");
require("../../../sheep/api/infra/file.js");
require("../../../sheep/api/member/address.js");
require("../../../sheep/api/member/point.js");
require("../../../sheep/api/migration/app.js");
require("../../../sheep/api/migration/chat.js");
require("../../../sheep/api/migration/index.js");
require("../../../sheep/api/migration/third.js");
require("../../../sheep/api/pay/channel.js");
require("../../../sheep/api/product/category.js");
require("../../../sheep/api/product/comment.js");
require("../../../sheep/api/product/favorite.js");
require("../../../sheep/api/product/history.js");
require("../../../sheep/api/product/spu.js");
require("../../../sheep/api/promotion/activity.js");
require("../../../sheep/api/promotion/article.js");
require("../../../sheep/api/promotion/combination.js");
require("../../../sheep/api/promotion/rewardActivity.js");
require("../../../sheep/api/promotion/seckill.js");
require("../../../sheep/api/system/area.js");
require("../../../sheep/api/system/voice.js");
require("../../../sheep/api/trade/afterSale.js");
require("../../../sheep/api/trade/brokerage.js");
require("../../../sheep/api/trade/config.js");
require("../../../sheep/api/trade/delivery.js");
require("../../../sheep/config/zIndex.js");
require("../../../sheep/util/index.js");
if (!Array) {
  const _easycom_s_count_down2 = common_vendor.resolveComponent("s-count-down");
  const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  (_easycom_s_count_down2 + _easycom_s_layout2)();
}
const _easycom_s_count_down = () => "../../../sheep/components/s-count-down/s-count-down.js";
const _easycom_s_layout = () => "../../../sheep/components/s-layout/s-layout.js";
if (!Math) {
  (_easycom_s_count_down + _easycom_s_layout)();
}
const _sfc_main = {
  __name: "list",
  setup(__props) {
    const state = common_vendor.reactive({
      navH: "",
      returnShow: true,
      // ========== 砍价记录概要的相关变量 ==========
      bargainTotal: 0,
      bargainSuccessList: [],
      // ========== 砍价活动的相关变量 ==========
      bargainList: [],
      page: 1,
      limit: 10,
      loading: false,
      loadend: false,
      bgColor: {
        "bgColor": "#E93323",
        "Color": "#fff",
        "width": "44rpx",
        "timeTxtwidth": "16rpx",
        "isDay": true
      },
      loadTitle: "加载更多"
    });
    async function getBargainHeader() {
      let {
        code,
        data
      } = await sheep_api_promotion_bargain.BargainApi.getBargainRecordSummary();
      if (code == 0) {
        state.bargainTotal = data.successUserCount;
        state.bargainSuccessList = data.successList;
      } else {
        state.$util.Tips({
          title: data
        });
      }
    }
    async function getBargainList() {
      if (state.loadend || state.loading) {
        return;
      }
      state.loading = true;
      state.loadTitle = "";
      let {
        data,
        code
      } = await sheep_api_promotion_bargain.BargainApi.getBargainActivityPage({
        pageNo: state.page,
        pageSize: state.limit
      });
      if (code == 0) {
        const list = data.list;
        common_vendor._.concat(state.bargainList, list);
        const loadend = list.length < state.limit;
        state.loadend = loadend;
        state.loading = false;
        state.loadTitle = loadend ? "已全部加载" : "加载更多";
        state.bargainList = data.list;
        state.page = state.page + 1;
      } else {
        state.loading = false;
        state.loadTitle = "加载更多";
      }
    }
    function openSubscribe(e) {
      console.log("跳转");
      console.log(e);
      sheep_index.sheep.$router.go(e);
      return;
    }
    common_vendor.onLoad(function() {
      getBargainHeader();
      getBargainList();
    });
    common_vendor.onReachBottom(() => {
      getBargainList();
    });
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.f(state.bargainSuccessList, (item, index, i0) => {
          return {
            a: item.avatar,
            b: common_vendor.t(item.nickname),
            c: common_vendor.t(item.activityName),
            d: index
          };
        }),
        b: common_vendor.t(state.bargainTotal),
        c: common_vendor.f(state.bargainList, (item, index, i0) => {
          return common_vendor.e({
            a: item.picUrl,
            b: common_vendor.t(item.name),
            c: "7572db9c-1-" + i0 + ",7572db9c-0",
            d: common_vendor.p({
              tipText: " ",
              bgColor: state.bgColor,
              dayText: ":",
              hourText: ":",
              minuteText: ":",
              secondText: " ",
              datatime: item.endTime / 1e3,
              isDay: true
            }),
            e: item.stock === 0
          }, item.stock === 0 ? {
            f: common_vendor.o(($event) => openSubscribe("/pages/activity/goods_bargain_details/index?id=" + item.id + "&startBargainUid=" + _ctx.uid), index)
          } : {}, {
            g: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(item.bargainMinPrice)),
            h: item.stock > 0
          }, item.stock > 0 ? {} : {}, {
            i: item.stock === 0
          }, item.stock === 0 ? {} : {}, {
            j: common_vendor.o(($event) => openSubscribe("/pages/activity/bargain/detail?id=" + item.id), index),
            k: index
          });
        }),
        d: state.bargainList.length > 0
      }, state.bargainList.length > 0 ? {
        e: !_ctx.loading,
        f: common_vendor.t(state.loadTitle)
      } : {}, {
        g: common_vendor.p({
          navbar: "inner",
          title: "砍价列表"
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-7572db9c"], ["__file", "D:/zx/mall-front-app/pages/activity/bargain/list.vue"]]);
wx.createPage(MiniProgramPage);
