index.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. Component({
  2. props: {
  3. componentData: {}
  4. },
  5. data: {
  6. isReady: false,
  7. pluginAppId: '',
  8. pluginComponent: '',
  9. pluginVersion: '',
  10. fmcg: {}
  11. },
  12. didMount() {
  13. const {
  14. componentData: {
  15. componentExtInfo
  16. }
  17. } = this.props;
  18. const {
  19. query
  20. } = my.getLaunchOptionsSync() || {};
  21. const {
  22. pluginAppId,
  23. pluginComponent,
  24. pluginVersion
  25. } = componentExtInfo;
  26. this.setData({
  27. pluginAppId,
  28. pluginComponent,
  29. pluginVersion,
  30. fmcg: query || {}
  31. });
  32. this.loadPlugin();
  33. },
  34. methods: {
  35. loadPlugin() {
  36. const {
  37. pluginVersion,
  38. pluginAppId
  39. } = this.data;
  40. try {
  41. my.loadPlugin({
  42. plugin: `${pluginAppId}@${pluginVersion}`,
  43. success: () => {
  44. this.setData({
  45. isReady: true
  46. });
  47. }
  48. });
  49. } catch (e) {
  50. throw new Error('plugin must be pluginAppId and pluginVersion, please configure on AB saas!');
  51. }
  52. }
  53. }
  54. });