common.js 985 Bytes


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

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

  addWechatFormId(data) {
    return this._get(API_HOST, Object.assign({
      method: 'wechat.formId.add'
    }, data))
  }

  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)
        })
    })
    
  }
}

export default CommonService;