recommendFood.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // pages/recommendFood/recommendFood.js
  2. import request from '../../utils/request'
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. foodList:[]
  9. },
  10. /**
  11. * 生命周期函数--监听页面加载
  12. */
  13. onLoad:async function(options) {
  14. let result = await request('/front/merchantAndCallout') //获取商户信息
  15. console.log(result);
  16. let imagePath = []
  17. for(let i = 0;i < result.length;i++){
  18. let id = result[i].id
  19. imagePath = await request('/front/findAllMerchantFilesPath/'+id)
  20. // console.log(imagePath);
  21. Object.assign(result[i],imagePath)
  22. // console.log(result);
  23. }
  24. this.setData({
  25. foodList:result
  26. })
  27. },
  28. //跳转到美食详情页
  29. tofoodDetail(e){
  30. console.log(e);
  31. let foodId = e.currentTarget.dataset.item.id
  32. wx.navigateTo({
  33. url: '/pages/foodDetail/foodDetail?id=' + foodId,
  34. })
  35. },
  36. /**
  37. * 生命周期函数--监听页面初次渲染完成
  38. */
  39. onReady() {
  40. },
  41. /**
  42. * 生命周期函数--监听页面显示
  43. */
  44. onShow() {
  45. },
  46. /**
  47. * 生命周期函数--监听页面隐藏
  48. */
  49. onHide() {
  50. },
  51. /**
  52. * 生命周期函数--监听页面卸载
  53. */
  54. onUnload() {
  55. },
  56. /**
  57. * 页面相关事件处理函数--监听用户下拉动作
  58. */
  59. onPullDownRefresh() {
  60. },
  61. /**
  62. * 页面上拉触底事件的处理函数
  63. */
  64. onReachBottom() {
  65. },
  66. /**
  67. * 用户点击右上角分享
  68. */
  69. onShareAppMessage() {
  70. }
  71. })