scenicDetail.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // pages/scenicDetail/scenicDetail.js
  2. import request from '../../utils/request'
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. imgList:[], //景点路径列表
  9. scenicTitle:'', //景点标题
  10. scenicDescribe:'', //景点介绍
  11. scenicLatitude:'', //景点纬度
  12. scenicLongtitude:'' //景点经度
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad:async function(options) {
  18. // 获取上一个页面传过来的景点id
  19. // console.log(options.id);
  20. let id = options.id
  21. await request('/front/scenicSpot/'+id) //更新浏览量
  22. let imagePath = await request('/front/findAllScenicSpotFilesPath/'+id) //获取景点照片
  23. // console.log(imagePath);
  24. let result = await request('/front/scenicSpotAndCallout') //获取景点列表
  25. // console.log(result);
  26. for(let i = 0;i < result.length;i++){
  27. if(result[i].id == id){
  28. this.setData({
  29. scenicTitle:result[i].title,
  30. scenicDescribe:result[i].describes,
  31. scenicLatitude:result[i].latitude,
  32. scenicLongtitude:result[i].longitude
  33. })
  34. }
  35. }
  36. let imgList = this.data.imgList
  37. for(let j = 0;j < imagePath.length;j++){
  38. imgList[j] = imagePath[j].iconPath
  39. }
  40. this.setData({
  41. imgList
  42. })
  43. // console.log(this.data.imgList);
  44. },
  45. //点击预览图片
  46. toPreviewImage(){
  47. let imgList = this.data.imgList
  48. wx.previewImage({
  49. // current: imgList, // 当前显示图片的 http 链接
  50. urls: imgList // 需要预览的图片 http 链接列表
  51. })
  52. },
  53. // 去目的地按钮功能
  54. goDestination(){
  55. let latitude = parseFloat(this.data.scenicLatitude)
  56. let longtitude = parseFloat(this.data.scenicLongtitude)
  57. wx.openLocation({
  58. latitude: latitude,
  59. longitude: longtitude,
  60. name:this.data.scenicTitle
  61. })
  62. },
  63. /**
  64. * 生命周期函数--监听页面初次渲染完成
  65. */
  66. onReady() {
  67. },
  68. /**
  69. * 生命周期函数--监听页面显示
  70. */
  71. onShow() {
  72. },
  73. /**
  74. * 生命周期函数--监听页面隐藏
  75. */
  76. onHide() {
  77. },
  78. /**
  79. * 生命周期函数--监听页面卸载
  80. */
  81. onUnload() {
  82. },
  83. /**
  84. * 页面相关事件处理函数--监听用户下拉动作
  85. */
  86. onPullDownRefresh() {
  87. },
  88. /**
  89. * 页面上拉触底事件的处理函数
  90. */
  91. onReachBottom() {
  92. },
  93. /**
  94. * 用户点击右上角分享
  95. */
  96. onShareAppMessage() {
  97. }
  98. })