StoreApi.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const Api = require('./Api');
  2. class StoreApi {
  3. /**
  4. * 根据类型获取商品列表
  5. * type 商品类型(1推荐,2砖石,3金币,4礼包)
  6. */
  7. static getShopsByType(typeId, success, fail) {
  8. let url = "/shop/getShopsByType";
  9. Api.httpGet(this.setRequestBody(url, {'type': typeId}, success, fail));
  10. }
  11. /**
  12. * 上报商品弹窗
  13. */
  14. static reportShop(shopId, success, fail) {
  15. let url = "/shop/report";
  16. Api.httpPost(this.setRequestBody(url, {'shopId': shopId}, success, fail));
  17. }
  18. //// 根据商品id 购买商品
  19. static buyShop(shopId, success, fail) {
  20. let url = "/shop/buyShop";
  21. Api.httpPost(this.setRequestBody(url, {'shopId': shopId}, success, fail));
  22. }
  23. static setRequestBody(url, data, success, fail) {
  24. let requestBody = {
  25. url: url,
  26. data: data,
  27. success: success,
  28. fail: fail,
  29. complete: () => {
  30. }
  31. };
  32. return requestBody;
  33. }
  34. }
  35. module.exports = StoreApi;