groupbuying.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. Page({
  2. data: {
  3. categoriesindex: 1,
  4. categories: [
  5. {
  6. title: '全部',
  7. type: 1,
  8. },{
  9. title: '益智玩具',
  10. type: 2,
  11. },{
  12. title: '绘本图书',
  13. type: 3,
  14. },{
  15. title: '文具用品',
  16. type: 4,
  17. },{
  18. title: '健康零食',
  19. type: 5,
  20. }
  21. ],
  22. goods: [
  23. {
  24. image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
  25. title: '儿童大颗粒积木 安全无毒 益智玩具',
  26. price: '68.00',
  27. originalPrice: '88.00',
  28. sold: 256
  29. },
  30. {
  31. image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
  32. title: '幼儿启蒙绘本 10册套装',
  33. price: '68.00',
  34. originalPrice: '88.00',
  35. sold: 256
  36. },
  37. {
  38. image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
  39. title: '防摔儿童保温水杯 350ml',
  40. price: '68.00',
  41. originalPrice: '88.00',
  42. sold: 256
  43. },
  44. {
  45. image: 'https://img1.baidu.com/it/u=2052658756,3021621759&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
  46. title: '可水洗儿童彩笔24色套装',
  47. price: '68.00',
  48. originalPrice: '88.00',
  49. sold: 256
  50. }
  51. ],
  52. souimg: '',
  53. gouwucimg: '',
  54. },
  55. onLoad(options) {
  56. // const title = options.title ? decodeURIComponent(options.title) : '商品列表';
  57. // this.setData({ title });
  58. // wx.setNavigationBarTitle({ title });
  59. const fileIDs = [
  60. 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/sou.png',
  61. 'cloud://cloud1-6g98iw7i28b01747.636c-cloud1-6g98iw7i28b01747-1367995226/images/icon/gouwuc_img.png'
  62. ];
  63. // 并发下载多个 fileID
  64. Promise.all(
  65. fileIDs.map(fileID => wx.cloud.downloadFile({ fileID }))
  66. ).then(results => {
  67. // 每个 result 对应一个下载结果
  68. const tempFilePaths = results.map(r => r.tempFilePath);
  69. console.log('全部下载成功:', tempFilePaths);
  70. this.setData({
  71. souimg: tempFilePaths[0],
  72. gouwucimg: tempFilePaths[1]
  73. });
  74. }).catch(err => {
  75. console.error('有文件下载失败:', err);
  76. });
  77. },
  78. tabcategories(e) {
  79. const type = e.currentTarget.dataset.type;
  80. this.setData({
  81. categoriesindex: type
  82. });
  83. },
  84. navigateToDetail(e) {
  85. const index = e.currentTarget.dataset.index;
  86. const item = this.data.goods[index];
  87. wx.navigateTo({
  88. url: '/subpackages/productdetails/productdetails?data=' + encodeURIComponent(JSON.stringify(item))
  89. });
  90. console.log('走进来了');
  91. }
  92. });