/**
 * 芝麻go活动签约详情页
 */
// @ts-nocheck
import qs from 'qs';
Component({
  data: {
    pluginAppId: '2021002191638959',
    pluginPageUrl: '/sesame-aoi',
    pluginVersion: '*'
  },

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

  methods: {
    loadPlugin() {
      const {
        pluginAppId,
        pluginPageUrl,
        pluginVersion
      } = this.data;
      let {
        query = {}
      } = my.getLaunchOptionsSync();
      const pageQuery = this.$page.data.query || {};
      const extInfo = this.props.componentData.componentExtInfo || {};
      const props = {
        alipayStoreId: extInfo.alipayStoreId,
        storeId: extInfo.storeId,
        returnUrl: extInfo.returnUrl,
        failedUrl: extInfo.failedUrl,
        appId: extInfo.appId
      };
      query = { ...props,
        ...query,
        ...pageQuery
      };
      my.loadPlugin({
        plugin: `${pluginAppId}@${pluginVersion}`,
        success: () => {
          const fmcg = query && qs.stringify(query) || '';
          my.reLaunch({
            url: `dynamic-plugin://${pluginAppId}${pluginPageUrl}${fmcg ? `?${fmcg}` : ''}`
          });
        }
      });
    }

  }
});