config.js 762 B

123456789101112131415161718192021222324252627282930313233
  1. import WxData from './wxData'
  2. class Config extends WxData {
  3. constructor(component) {
  4. super(component)
  5. this.Component = component
  6. }
  7. getCalendarConfig() {
  8. if (!this.Component || !this.Component.config) return {}
  9. return this.Component.config
  10. }
  11. setCalendarConfig(config) {
  12. return new Promise((resolve, reject) => {
  13. if (!this.Component || !this.Component.config) {
  14. reject('异常:未找到组件配置信息')
  15. return
  16. }
  17. let conf = { ...this.Component.config, ...config }
  18. this.Component.config = conf
  19. this.setData(
  20. {
  21. calendarConfig: conf
  22. },
  23. () => {
  24. resolve(conf)
  25. }
  26. )
  27. })
  28. }
  29. }
  30. export default component => new Config(component)