/**
 * 秒杀活动列表
 */
// @ts-nocheck
import qs from 'qs';
Component({
  data: {
    isReady: false,
    pluginAppId: '2021002191638959',
    pluginPageUrl: '/kill-list',
    pluginVersion: '*'
  },

  didMount() {
    this.loadPlugin();
  },

  methods: {
    loadPlugin() {
      const {
        pluginAppId,
        pluginPageUrl,
        pluginVersion,
        tabbarInfo
      } = this.data;
      let {
        query
      } = my.getLaunchOptionsSync();
      const pageQuery = this.$page.data.query || {};
      query = { ...query,
        ...pageQuery
      }; // query = {
      //   buttonText: '',
      //   backgroundUrl: '',
      //   titleUrl: '',
      // }

      query = { ...query,
        tabbarInfo
      };
      const that = this;
      my.loadPlugin({
        plugin: `${pluginAppId}@${pluginVersion}`,
        success: () => {
          that.setData({
            isReady: true
          });
          const fmcg = query ? qs.stringify(query) : '';
          my.reLaunch({
            url: `dynamic-plugin://${pluginAppId}${pluginPageUrl}${fmcg ? `?${fmcg}` : ''}`
          });
        }
      });
    }

  }
});