zero-sell.js 1.95 KB


import Service from './service'
import { ACTIVITY_HOST, API_HOST, MINI_QR_TYPE, MINI_APP_TYPE} from '../../../libs/config';

const MODULE = '/activity/zerobuy';

function productTime(product) {
  if (product.status === 1) {
    product.end_time = 0;
  }

  return product;
}
class ZeroSellService extends Service {
  constructor() {
    super(ACTIVITY_HOST + MODULE);
  }

  getList(data) {
    data.channel = 0
    return this._get('/list', data).then(result => {
      if (result.code === 200) {
        const products = result.data;
        const newProducts = products.map(productTime)

        result.data = newProducts;
        return result;
      }

      return result;
    })
  }

  getDetail(data) {
    return this._get('/content', data).then(result => {
      if (result.code === 200) {
        productTime(result.data)

        return result;
      }

      return result;
    });
  }

  getRecommend(data) {
    data.channel = 0
    return this._get('/list/recommend', data).then(result => {
      if (result.code === 200) {
        const products = result.data;
        const newProducts = products.map(productTime)

        result.data = newProducts;
        return result;
      }

      return result
    });
  }
  getMyList(data) {
    data.channel = 0
    return this._get('/list/mine', data);
  }
  getRecentAvatars(data) {
    return this._get('/code/recent', data);
  }

  fetchCode(data) {
    data.miniAppType = MINI_APP_TYPE
    return this._post('/code/gain', data);
  }

  fetchMyPrizeList(data) {
    return this._get('/code/mine', data);
  }

  fetchActivitySum(data) {
    return this._get('/join/sum', data);
  }

  getQrCode(page_param) {
    return API_HOST + '/wechat/miniapp/img-check.jpg?param=' + JSON.stringify(page_param) + `&miniQrType=${MINI_QR_TYPE}` + `&miniapp_type=${MINI_APP_TYPE}`;
  }


  getUserProfile(data) {
    return this._get('', {
      method: 'app.passport.profile',
      uid: data.uid
    });
  }
}

export default ZeroSellService;