import { pmb } from "../bridge";

let _this = null;
class Interaction {
  actionName = "interaction";

  constructor() {
    _this = this;
  }

  default(params = {}, mergeParams = { action: this.actionName, ...params }) {
    if (!params) throw new Error("传入的params参数错误");
    return new Promise((resolve, reject) => pmb.publish(mergeParams, (e) => resolve(e)));
  }

  layoutHtml(userParams = {}) {
    return _this.default({
      method: "layoutHtml",
      params: { ...userParams }
    });
  }

  syncScroll(userParams = {}) {
    return _this.default({
      method: "syncScroll",
      params: { ...userParams }
    });
  }

  showConditions(userParams = {}) {
    return _this.default({
      method: "showConditions",
      params: { ...userParams }
    });
  }
}

export default Interaction;