
import { connect } from 'herculex';
import { prefixPagePath } from '../../utils';

const handleFunc = {
  reload: (url) => {
    my.redirectTo({
      url: url || `${prefixPagePath}/home/index`,
    });
  },
  jumpToAlipayPage: (url) => {
    my.ap.navigateToAlipayPage({
      path: url,
      success: () => {
      },
    });
  },
};

Component(connect({
  mapStateToProps: {
    titleBarHeight: state => state.$global.titleBarHeight,
  },
})({
  props: {
    className: '',
    type: '',
    errorCode: '',
    errorMsg: '',
    errorBrief: '',
    defaultErrMsg: '抱歉，系统繁忙，请稍后再试',
    operations: [{ btnText: '刷新', handleName: 'reload' }],
  },
  methods: {
    onTapBtn(e) {
      const { handleName, url } = e.currentTarget.dataset;
      handleFunc[handleName](url);
    },
  },
}));
