home.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { config, cdnBase } from '../../config/index';
  2. /** 获取首页数据 */
  3. function mockFetchHome() {
  4. const { delay } = require('../_utils/delay');
  5. const { genSwiperImageList } = require('../../model/swiper');
  6. return delay().then(() => {
  7. return {
  8. swiper: genSwiperImageList(),
  9. tabList: [
  10. {
  11. text: '精选推荐',
  12. key: 0,
  13. },
  14. {
  15. text: '夏日防晒',
  16. key: 1,
  17. },
  18. {
  19. text: '二胎大作战',
  20. key: 2,
  21. },
  22. {
  23. text: '人气榜',
  24. key: 3,
  25. },
  26. {
  27. text: '好评榜',
  28. key: 4,
  29. },
  30. {
  31. text: 'RTX 30',
  32. key: 5,
  33. },
  34. {
  35. text: '手机也疯狂',
  36. key: 6,
  37. },
  38. ],
  39. activityImg: `${cdnBase}/activity/banner.png`,
  40. };
  41. });
  42. }
  43. /** 获取首页数据 */
  44. export function fetchHome() {
  45. if (config.useMock) {
  46. return mockFetchHome();
  47. }
  48. return new Promise((resolve) => {
  49. resolve('real api');
  50. });
  51. }