data.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. var products = [
  2. {
  3. "img": "https://img.alicdn.com/tfs/TB1Q2Org4rI8KJjy0FpXXb5hVXa-468-1236.jpg",
  4. "title": "精品女装 限时出售",
  5. "price": "¥99.88",
  6. "tip": "HOT"
  7. },
  8. {
  9. "img": "https://img.alicdn.com/bao/uploaded/i1/2146742267/O1CN011ScKLXPJaX9UQyq_!!0-item_pic.jpg",
  10. "title": "女装特价",
  11. "price": "¥16.99",
  12. "tip": "名牌"
  13. },
  14. {
  15. "img": "https://img.alicdn.com/tps/i4/TB1q42TjMTqK1RjSZPhSutfOFXa.jpg",
  16. "title": "千元手机爆款",
  17. "price": "¥999.99",
  18. "tip": "推荐"
  19. },
  20. {
  21. "img": "https://img.alicdn.com/tps/i4/TB1bhT6kr2pK1RjSZFswu1NlXXa.png",
  22. "title": "进口儿童座椅",
  23. "price": "¥698.99",
  24. "tip": "进口"
  25. },
  26. {
  27. "img": "https://img.alicdn.com/bao/uploaded/i1/2787417447/O1CN0124sly8iXb80L4OS_!!0-item_pic.jpg",
  28. "title": "品牌T恤",
  29. "price": "¥22.99",
  30. "tip": "nike"
  31. },
  32. {
  33. "img": "https://img.alicdn.com/tfs/TB13FixCeuSBuNjy1XcXXcYjFXa-468-1236.jpg",
  34. "title": "好吃坚果",
  35. "price": "¥55.99",
  36. "tip": "吃货"
  37. },
  38. {
  39. "img": "https://img.alicdn.com/bao/uploaded/i2/452325706/O1CN011s1OQAszoPWK8Rt_!!0-item_pic.jpg",
  40. "title": "进口化妆品特价",
  41. "price": "¥22.99",
  42. "tip": "热卖"
  43. },
  44. {
  45. "img": "https://img.alicdn.com/tps/i4/TB1bhT6kr2pK1RjSZFswu1NlXXa.png",
  46. "title": "进口儿童座椅",
  47. "price": "¥698.99",
  48. "tip": "进口"
  49. }
  50. ];
  51. var getArrRandomly = function (arr) {
  52. var len = arr.length;
  53. for (var i = 0; i < len; i++) {
  54. var randomIndex = Math.floor(Math.random() * (len - i));
  55. var itemAtIndex = arr[randomIndex];
  56. arr[randomIndex] = arr[i];
  57. arr[i] = itemAtIndex;
  58. }
  59. return arr;
  60. }
  61. module.exports = {
  62. products : products,
  63. getArrRandomly : getArrRandomly
  64. }