import store from './store';
import { getSharePath } from '../../utils';

Page(store.register({
  async onLoad(options) {
    this.options = options;
    const { pageUuid } = options;
    this.pageUuid = pageUuid;
    await this.dispatch('init', this.options);
  },
  async onResume() {
    this.dispatch('onResume');
  },
  async onReloadHandle() {
    await this.dispatch('init', {
      /*
     * 刷新关闭页面数据缓存
     * */
      noCache: true,
      pageUuid: this.pageUuid,
      isPullRefresh: true,
    });
  },
  onReachBottom() {
  },
  onPageScroll() {
  },
  onShow() {},
  /*
  * 增加下拉刷新
  * */
  async onPullDownRefresh() {
    await this.onReloadHandle();
    my.stopPullDownRefresh();
  },
  onPullIntercept() {
  },
  onUnload() {
  },
  onShareAppMessage() {
    return {
      title: this.data.pageName || '',
      path: getSharePath(this.options),
    };
  },
}));
