qujingdidetail.js 3.0 KB
const app=getApp()
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		locat_id:'',
		qujingdetail:'',
		markers: [],
		qujingtail:true,
		page:1,
		keywordname:'',
		qujinglistarr:[],
		showpull:false
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function (options) {
		this.setData({
			locat_id:options.locat_id
		})
		this.getdetail()
	},
	getdetail(){
		let that = this;
    let url = 'locat/locat_detail';
    let param = {
			locat_id:that.data.locat_id
		}
    app.post(url,param, 'post').then((res) => {
			console.log(res);
			that.setData({
				qujingdetail:res
			})
			console.log(res.lat)
			let newmarkers=[];
			let obj={
				iconPath: "/img/map.png",
				id: 0,
				latitude:parseFloat(res.lat),
				longitude: parseFloat(res.lng),
				width: 30,
				height: 30
			}
			console.log(obj)
			newmarkers.push(obj);
			console.log(newmarkers)
			that.setData({
				markers:newmarkers
			})	
			
    }).catch((err) => {
    })
	},
	searchword(e){
		this.setData({
			keywordname:e.currentTarget.dataset.word,
			page:1,
			qujinglistarr:[],
			qujingtail:false
		})
		this.getqujinglist()
	},

	// 获取取景列表
	getqujinglist(){
		let that = this;
    let url = 'locat/locat_list';
    let param = {
			keyword:that.data.keywordname,
			page:that.data.page,
			pageNum:10
		}
    app.post(url,param, 'post').then((res) => {
			console.log(res);
			that.setData({
				qujinglistarr:that.data.qujinglistarr.concat(res.info)
			})
			if(that.data.page>1){
				if(res.info.length==0){
					that.setData({
						showpull:true
					})
					wx.showToast({
						title: '没有更多了~',
						icon:"none"
					})
				}
			}
    }).catch((err) => {
    })
	},
	getqujingtail(e){
			this.setData({
				locat_id:e.currentTarget.dataset.id,
				qujingtail:true
			})
			this.getdetail()
	},

	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function () {
	},
	regionchange(e) {
    console.log(e.type)
	},
	markertap(e) {
		let that=this;
		let latitude=e.currentTarget.dataset.lat;
		let longitude=e.currentTarget.dataset.lng
		console.log(latitude,longitude,'49465465sdfsfsdfs');
		wx.openLocation({
			latitude: parseFloat(latitude),
			longitude: parseFloat(longitude),
			name:that.data.qujingdetail.address,
			address:that.data.qujingdetail.address,
			success: function() {
				console.log('success');
			}
		});
  },

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function () {

	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function () {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function () {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function () {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function () {
		let newpage=this.data.page;
		newpage++;
		this.setData({
			page:newpage
		})
		if(this.data.showpull==false){
			this.getqujinglist()
		}
	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function () {

	}
})