common.js 1.02 KB


import Service from './service'
import { API_HOST} from '../../../libs/config';
// import Promise from '../../../vendors/es6-promise';

class CommonService extends Service {
  constructor() {
    super();
  }

  getResourceCode(content_code) {
    let param = {
      content_code
    }
    let self = this;

    return new Promise(function(resolve,reject) {
       self._get(API_HOST + '/operations/api/v5/resource/get', param)
        .then(json => {
          if (json && json.code == 200 && json.data && json.data[0] && json.data[0].data && json.data[0].data.list && json.data[0].data.list[0] && json.data[0].data.list[0].src ) {
            resolve(json.data[0].data.list[0])
          } else {
            reject(json)
          }
        })
        .catch(error => {
          reject(error)
        });
    })
    
  }

  getGroupList(data) {
    return this._get(API_HOST, Object.assign({ 
      method: 'app.collage.promoteList', 
      business_line: 'miniappGroup',
      joinLimit: 1
    }, data));
  }
}

export default CommonService;