// packageA/mycomponent/floatOrder/floatOrder.js
const app = getApp();
Component({
  options: {
    styleIsolation: "isolated",
  },
  /**
   * 组件的属性列表
   */
  properties: {
    broadcast_data: {
      type: null,
    },
    goodsType: {
      type: null,
    },
  },
  observers: {},
  /**
   * 组件的初始数据
   */
  data: {
    page: 1,
    morePage: null,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    bindChange(e) {
      if (e.detail.source == "autoplay") {
        let ind = e.detail.current;
        if (ind == this.data.broadcast_data.data.length - 8) {
          if (this.data.broadcast_data.current_page >= this.data.broadcast_data.last_page) {
            console.log("没有更多");
            return;
          } else {
            this.setData({
              page: this.data.page + 1,
            });
            this.zhpBroadcast();
          }
        }
      }
    },
    // 飘窗
    zhpBroadcast() {
      let that = this;
      let urlStr = app.getNetAddresss("plugin.zhp-group-lottery.frontend.goods.get-window-list");
      app._getNetWork({
        url: urlStr,
        data: {
          activity_id: this.data.broadcast_data.goodsId,
          page: this.data.page,
        },
        success: (resdata) => {
          var res = resdata.data;
          if (res.result == 1) {
            let darr = that.data.broadcast_data.data.concat(res.data.data);
            that.setData({
              morePage: res.data.last_page,
              ["broadcast_data.data"]: darr,
            });
          } else {
            wx.showToast({
              icon: "none",
              title: res.msg,
              duration: 1500,
            });
          }
        },
      });
    },
  },
});
