fetchGoodsDetailsComments.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { config } from '../../config/index';
  2. /** 获取商品详情页评论数 */
  3. function mockFetchGoodDetailsCommentsCount(spuId = 0) {
  4. const { delay } = require('../_utils/delay');
  5. const {
  6. getGoodsDetailsCommentsCount,
  7. } = require('../../model/detailsComments');
  8. return delay().then(() => getGoodsDetailsCommentsCount(spuId));
  9. }
  10. /** 获取商品详情页评论数 */
  11. export function getGoodsDetailsCommentsCount(spuId = 0) {
  12. if (config.useMock) {
  13. return mockFetchGoodDetailsCommentsCount(spuId);
  14. }
  15. return new Promise((resolve) => {
  16. resolve('real api');
  17. });
  18. }
  19. /** 获取商品详情页评论 */
  20. function mockFetchGoodDetailsCommentList(spuId = 0) {
  21. const { delay } = require('../_utils/delay');
  22. const { getGoodsDetailsComments } = require('../../model/detailsComments');
  23. return delay().then(() => getGoodsDetailsComments(spuId));
  24. }
  25. /** 获取商品详情页评论 */
  26. export function getGoodsDetailsCommentList(spuId = 0) {
  27. if (config.useMock) {
  28. return mockFetchGoodDetailsCommentList(spuId);
  29. }
  30. return new Promise((resolve) => {
  31. resolve('real api');
  32. });
  33. }