// pagesPublic/pages/tdcr/tdcr-list/index.js import { imgUrl, request, request2 } from "../../api/request" Page({ /** * 页面的初始数据 */ data: { imgUrl, headerStyle: {}, touchData: { flag: 0, lastX: 0, lastY: 0 }, list: [{ left: 18.5, top: 21, zIndex: 1, nameStyle: { txt: '中西医结合医院', img: 'tdcrlist7.png' }, lineStyle: { height: 25, left: 3, top: -0.5 }, postionStyle: { top: -0.5, left: 0.5 } },{ left: 30, top: 34.5, zIndex: 3, nameStyle: { txt: '南坪东路588号', img: 'tdcrlist8.png', color: '#0F2887', x: 2 }, lineStyle: { height: 18, left: 5, top: -0.5 }, postionStyle: { top: -0.5, left: 2.5 } }, { left: 27, top: 28.5, zIndex: 2, nameStyle: { txt: '廖家山地块', img: 'tdcrlist7.png' }, lineStyle: { height: 13, left: 3, top: -0.5 }, postionStyle: { top: -0.5, left: 0.5 } }, { left: 41, top: 48, nameStyle: { txt: '四公里片区', img: 'tdcrlist7.png', top: 25.5 }, lineStyle: { height: 8, left: 3, top: 13 }, postionStyle: { top: -0.5, left: 0.5 } }, { left: 27, top: 46.5, nameStyle: { txt: '双峰山1号地块', img: 'tdcrlist7.png', top: 33 }, lineStyle: { height: 12, left: 3, top: 16 }, postionStyle: { top: -0.5, left: 0.5 } }] }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.setData({ headerStyle: wx.getMenuButtonBoundingClientRect(), }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { return { title: '2024年土地出让', imageUrl: imgUrl + '/tdcr/share.jpg' } }, handleTouchend() { let touchData = this.data.touchData touchData.flag = 0 //停止滑动 this.setData({ touchData }) }, handleTouchstart(event) { this.setData({ touchData: { flag: 0, lastX: event.changedTouches[0].pageX, lastY: event.changedTouches[0].pageY } }) }, handleTouchmove(event) { let touchData = this.data.touchData if (touchData.flag !== 0) { return; } let currentX = event.changedTouches[0].pageX; let currentY = event.changedTouches[0].pageY; let tx = currentX - touchData.lastX; let ty = currentY - touchData.lastY; //左右方向偏移大于上下偏移认为是左右滑动 if (Math.abs(tx) - Math.abs(ty) > 5) { // 向左滑动 if (tx < 0) { // 如果到最右侧 console.log('向左滑动'); touchData.flag = 1; } else if (tx > 0) { // 如果到最左侧 touchData.flag = 2; console.log('向右滑动'); wx.navigateBack() } } //将当前坐标进行保存以进行下一次计算 touchData.lastX = currentX; touchData.lastY = currentY; this.setData({ touchData }) }, gotoDetail(e) { console.log(e); wx.navigateTo({ url: '../details/detail?index=' + e.target.dataset.index, }) } })