/* eslint-disable no-unused-vars */
import { navigateTo } from '../../utils';
import { connect } from 'herculex';
import { getIn } from 'herculex/dist/utils/manipulate';

const app = getApp();
Component(connect({
  mapStateToProps: {
    // noticeComponent: (state) => state.noticeComponent,
  },
})({
  data: {
    indicatorDots: false,
    autoplay: true,
    interval: 5,
    vertical: true,
    circular: true,
    disableTouch: true,
    imgSrcPrefix: app.globalData.imgSrcPrefix,
    moreText: '条公告',
  },
  props: {
    componentData: {},
  },
  didMount() {
  },
  methods: {
    onSubmit(e) {
      const item = getIn(e, ['buttonTarget', 'dataset', 'item'], {});
      const formId = getIn(e, ['detail', 'formId'], '');

      this.commit('$global:updateFormId', {
        formId,
      });
      if (item.accessMode === 'customer' && item.from !== 'webview') {
        const customerCheckInPage = this.dispatch.bind(this, 'customerCheck');
        return navigateTo.call(this, {
          ...item,
          customerCheckInPage,
          isToService: true,
        });
      }
      navigateTo.call(this, {
        ...item,
        isToService: true,
      });
    },
  },
}));
