scenicList.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // pages/scenicList/scenicList.js
  2. import request from '../../utils/request'
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. scenicList:[], //景点列表
  9. imageList:[], //景点照片列表
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad:async function(options) {
  15. let imageList = this.data.imageList
  16. let imagePath = []
  17. let result = await request('/front/scenicSpotAndCallout') //获取景点列表
  18. // console.log(result);
  19. //获取景点照片列表
  20. for(let i = 0;i < result.length;i++){
  21. let id = result[i].id
  22. // console.log(id);
  23. imagePath = await request('/front/findAllScenicSpotFilesPath/'+id)
  24. // console.log(imagePath);
  25. imageList[i] = imagePath
  26. // 将景点照片添加到景点列表
  27. Object.assign(result[i],imagePath)
  28. // console.log(result);
  29. }
  30. this.setData({
  31. scenicList:result,
  32. imageList
  33. })
  34. // console.log(this.data.imageList);
  35. // console.log(this.data.scenicList);
  36. },
  37. //跳转到景点详情
  38. toScenicDetail(e) {
  39. // console.log(e);
  40. // console.log(e.currentTarget.dataset.index);
  41. // let scenicId = e.currentTarget.dataset.index
  42. let scenicId = e.currentTarget.dataset.item.id
  43. // console.log(scenicId);
  44. // 跳转传参
  45. wx.navigateTo({
  46. url: '/pages/scenicDetail/scenicDetail?id=' + scenicId,
  47. })
  48. },
  49. /**
  50. * 生命周期函数--监听页面初次渲染完成
  51. */
  52. onReady() {
  53. },
  54. /**
  55. * 生命周期函数--监听页面显示
  56. */
  57. onShow() {
  58. },
  59. /**
  60. * 生命周期函数--监听页面隐藏
  61. */
  62. onHide() {
  63. },
  64. /**
  65. * 生命周期函数--监听页面卸载
  66. */
  67. onUnload() {
  68. },
  69. /**
  70. * 页面相关事件处理函数--监听用户下拉动作
  71. */
  72. onPullDownRefresh() {
  73. },
  74. /**
  75. * 页面上拉触底事件的处理函数
  76. */
  77. onReachBottom() {
  78. wx.showToast({
  79. title: '没有更多啦',
  80. icon:'none'
  81. })
  82. },
  83. /**
  84. * 用户点击右上角分享
  85. */
  86. onShareAppMessage() {
  87. }
  88. })