index.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * 大转盘
  3. */
  4. // @ts-nocheck
  5. import qs from 'qs';
  6. Component({
  7. data: {
  8. isReady: false,
  9. pluginAppId: '2021002191638959',
  10. pluginPageUrl: '/wheel',
  11. pluginVersion: '*'
  12. },
  13. didMount() {
  14. this.loadPlugin();
  15. },
  16. methods: {
  17. loadPlugin() {
  18. const {
  19. pluginAppId,
  20. pluginPageUrl,
  21. pluginVersion
  22. } = this.data;
  23. let {
  24. query = {}
  25. } = my.getLaunchOptionsSync();
  26. const pageQuery = this.$page.data.query || {};
  27. const extInfo = this.props.componentData.componentExtInfo || {};
  28. const props = {
  29. alipayStoreId: extInfo.alipayStoreId
  30. };
  31. query = { ...props,
  32. ...query,
  33. ...pageQuery
  34. };
  35. const that = this;
  36. my.loadPlugin({
  37. plugin: `${pluginAppId}@${pluginVersion}`,
  38. success: () => {
  39. that.setData({
  40. isReady: true
  41. });
  42. const fmcg = query && qs.stringify(query) || '';
  43. my.reLaunch({
  44. url: `dynamic-plugin://${pluginAppId}${pluginPageUrl}${fmcg ? `?${fmcg}` : ''}`
  45. });
  46. }
  47. });
  48. }
  49. }
  50. });