index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import { connect } from 'herculex';
  2. Component(connect({
  3. mapStateToProps: {
  4. cityCode: state => state.$global.cityCode
  5. }
  6. })({
  7. props: {
  8. componentData: {}
  9. },
  10. data: {
  11. isReady: false,
  12. pluginAppId: '',
  13. pluginComponent: '',
  14. pluginVersion: ''
  15. },
  16. didMount() {
  17. const {
  18. componentData: {
  19. componentExtInfo
  20. }
  21. } = this.props;
  22. const {
  23. pluginAppId,
  24. pluginComponent,
  25. pluginVersion
  26. } = componentExtInfo;
  27. this.setData({
  28. pluginAppId,
  29. pluginComponent,
  30. pluginVersion
  31. });
  32. this.loadPlugin();
  33. },
  34. methods: {
  35. onHeadHeight(height) {
  36. this.commitGlobal && this.commitGlobal({
  37. headB2bHight: height
  38. });
  39. },
  40. onChangeStore(e) {
  41. const {
  42. cityCode,
  43. storeId
  44. } = e;
  45. this.commitGlobal && this.commitGlobal({
  46. cityCode,
  47. globalShopId: storeId,
  48. globalShop: { ...e
  49. }
  50. });
  51. },
  52. loadPlugin() {
  53. const {
  54. pluginAppId,
  55. pluginVersion
  56. } = this.data;
  57. const that = this;
  58. my.loadPlugin({
  59. plugin: `${pluginAppId}@${pluginVersion}`,
  60. success: () => {
  61. that.setData({
  62. isReady: true
  63. });
  64. }
  65. });
  66. }
  67. }
  68. }));