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

Page(store.register({
  data: {
    url: '',
  },
  onLoad(options) {
    const { url = '', serviceUUID = '', serviceCode = '' } = options;
    serviceReportCM({ serviceUUID, serviceCode });
    this.setData({
      url,
    });
  },
  onCallFunction(e) {
    const { name } = e.detail || {};
    const { appid, path } = e.detail || {};
    switch (name) {
      case 'navigateToMiniProgram':
        my.navigateToMiniProgram({
          appId: appid,
          path,
          extraData: {
          },
          success: (res) => {
            console.log(JSON.stringify(res));
          },
          fail: (res) => {
            console.log(JSON.stringify(res));
          },
        });
        break;
      default:
        break;
    }
  },
  /*
 * 增加下拉刷新
 * */
  async onPullDownRefresh() {
    this.setData({ url: '' }, () => {
      this.setWebViewUrl();
      my.stopPullDownRefresh();
    });
  },
}));
