resource-service.js 943 Bytes

import Service from './service';
import ResourceApi from '@/api/resource-api';

class ResourceService extends Service {
  constructor() {
    super();
    this.api = new ResourceApi();
  }

  info(id) {
    return this.api.info(id).then(result => {
      // let {resGoodsPools, resContentInfos} = result.data;

      let resGoodsPools = result.data.resGoodsPools;
      let resContentInfos = result.data.resContentInfos;

      resContentInfos.sort((a, b) => {
        if (a.orderBy < b.orderBy) {
          return -1;
        }

        if (a.orderBy > b.orderBy) {
          return 1;
        }

        return 0;
      });

      resContentInfos.push({
        type: 'resGoodsPoools',
        data: resGoodsPools
      });

      return resContentInfos;
    });
  }

  editGoodsPool(data) {
    return this.api.editGoodsPool(data);
  }

  editResource(data) {
    return this.api.editResource(data);
  }

}

export default ResourceService;