You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
149 lines
3.3 KiB
149 lines
3.3 KiB
// pages/info/roadInfo/index.js
|
|
let device = wx.getSystemInfoSync();
|
|
const ratio = device.windowWidth / 750;
|
|
import commonApi from "../../../utils/https/common"
|
|
let app = getApp();
|
|
import util from "../../../utils/util"
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
fixed:false,
|
|
type:1,
|
|
top:0,
|
|
info:null
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
let rect = wx.getMenuButtonBoundingClientRect();
|
|
let height = (rect.top - device.statusBarHeight) * 2 + rect.height + device.statusBarHeight;
|
|
console.log(height)
|
|
this.setData({
|
|
top:height
|
|
})
|
|
commonApi._post("scene/detail",{
|
|
id:options.id
|
|
}).then(res=>{
|
|
this.setData({
|
|
info:res.data
|
|
})
|
|
this.BroswerRecord()
|
|
})
|
|
},
|
|
BroswerRecord:function(){
|
|
setTimeout(()=>{
|
|
if(app.globalData.uuid){
|
|
commonApi._post('browse/browse_record',{
|
|
type:"scene",
|
|
title:this.data.info.title,
|
|
drive:"mini",
|
|
source_id:this.data.info.id,
|
|
url:"/pages/info/hotelInfo/index?id="+this.data.info.id,
|
|
uuid:app.globalData.uuid
|
|
}).then(res=>{
|
|
})
|
|
}
|
|
else {
|
|
this.BroswerRecord();
|
|
}
|
|
},500)
|
|
},
|
|
changeMenu:function(e){
|
|
let index = e.currentTarget.dataset.index,that = this;
|
|
const query=wx.createSelectorQuery(); //创建节点查询器
|
|
query.select("#box"+index).boundingClientRect() //选择toViewid获取位置信息
|
|
query.selectViewport().scrollOffset() //获取页面查询位置的
|
|
query.exec(function(res) {
|
|
let scrollTop = res[0].top + res[1].scrollTop - 110 * ratio - that.data.top;
|
|
wx.pageScrollTo({
|
|
scrollTop: scrollTop + 4,
|
|
duration: 0
|
|
})
|
|
that.setData({
|
|
type:index
|
|
})
|
|
})
|
|
},
|
|
onPageScroll:function(e){
|
|
let that = this,height = this.data.top;
|
|
let topHeight = height;
|
|
// 滚动时判断滚动到哪个部分了
|
|
const query=wx.createSelectorQuery(); //创建节点查询器
|
|
query.select("#box1").boundingClientRect() //选择toViewid获取位置信息
|
|
query.select("#box2").boundingClientRect() //选择toViewid获取位置信息
|
|
query.select("#box3").boundingClientRect() //选择toViewid获取位置信息
|
|
let minHeight = that.data.fixed?(110 * ratio + height): topHeight;
|
|
query.exec(function(res) {
|
|
if(res[2].top<minHeight){
|
|
that.setData({
|
|
type:3
|
|
})
|
|
}
|
|
else if(res[1].top<minHeight){
|
|
that.setData({
|
|
type:2
|
|
})
|
|
}
|
|
else {
|
|
that.setData({
|
|
type:1
|
|
})
|
|
}
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
})
|