ws il y a 1 an
Parent
commit
6199bf4447

+ 3 - 0
nnzwminiapp/pagesPublic/pages/tdcr/details/detail.js

@@ -86,5 +86,8 @@ Page({
     this.setData({
       tabActive: e.target.dataset.index,
     })
+  },
+  goBack() {
+    wx.navigateBack()
   }
 })

+ 1 - 1
nnzwminiapp/pagesPublic/pages/tdcr/details/detail.wxml

@@ -1,6 +1,6 @@
 <!--pagesPublic/pages/tdcr/details/detail.wxml-->
 <view class="main" style="background-image: url({{imgPath}}/index/bg.png);">
-  <view class="header" style="height: {{headerStyle.height}}px;line-height: {{headerStyle.height}}px;margin-top: {{headerStyle.top}}px;">{{title}}</view>
+  <view class="header" style="height: {{headerStyle.height}}px;line-height: {{headerStyle.height}}px;margin-top: {{headerStyle.top}}px;"><image class="go-back" bindtap="goBack" src="{{imgPath}}/details/back.png" />{{title}}</view>
   <view class="map-content" style="background-image: url({{imgPath}}/details/map-border.png);">
     <map class="map" enable-satellite="true" longitude="{{map.longitude}}" latitude="{{map.latitude}}"></map>
   </view>

+ 10 - 1
nnzwminiapp/pagesPublic/pages/tdcr/details/detail.wxss

@@ -12,7 +12,9 @@
   font-weight: 800;
   font-size: 42rpx;
   width: 96vw;
-  margin: 0 auto;
+  display: flex;
+  justify-content: center;
+  align-items: center;
 }
 .map-content {
   background-size: 100% 100%;
@@ -80,3 +82,10 @@
 @import './wxml/info.wxss';
 @import './wxml/periphery.wxss';
 @import './wxml/ohter.wxss';
+
+.go-back {
+  height: 60rpx;
+  width: 60rpx;
+  position: absolute;
+  left: 2vw;
+}

+ 57 - 2
nnzwminiapp/pagesPublic/pages/tdcr/index.js

@@ -58,7 +58,12 @@ Page({
       txt: '产业坚实  人才汇聚',
       top: 1,
       left: 20
-    }]
+    }],
+    touchData: {
+      flag: 0,
+      lastX: 0,
+      lastY: 0
+    }
   },
 
   /**
@@ -114,5 +119,55 @@ Page({
    */
   onShareAppMessage() {
 
-  }
+  },
+  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;
+        wx.navigateTo({
+          url: './tdcr-list/index',
+        })
+      } else if (tx > 0) {
+        // 如果到最左侧
+        touchData.flag = 2;
+        console.log('向右滑动');
+      }
+    }
+    //将当前坐标进行保存以进行下一次计算
+    touchData.lastX = currentX;
+    touchData.lastY = currentY;
+    this.setData({
+      touchData
+    })
+  },
+
 })

+ 5 - 1
nnzwminiapp/pagesPublic/pages/tdcr/index.wxml

@@ -1,5 +1,9 @@
 <!--pagesPublic/pages/tdcr/index.wxml-->
-<view class="main" style="background-image: url({{imgPath}}/index/bg.png);">
+<view
+  capture-bind:touchmove="handleTouchmove"
+  capture-bind:touchstart="handleTouchstart"
+  capture-catch:touchend="handleTouchend"
+  class="main" style="background-image: url({{imgPath}}/index/bg.png);">
   <image class="main-header" src="{{imgPath}}/index/header.png" />
   <view class="cursor-guy">
     <image class="cursor-size" wx:for="{{cursorGuys}}" src="{{imgPath}}/index/cursor.png" 

+ 59 - 1
nnzwminiapp/pagesPublic/pages/tdcr/tdcr-list/index.js

@@ -10,7 +10,12 @@ Page({
    * 页面的初始数据
    */
   data: {
-	imgUrl
+  imgUrl,
+  touchData: {
+    flag: 0,
+    lastX: 0,
+    lastY: 0
+  }
   },
 
   /**
@@ -67,5 +72,58 @@ Page({
    */
   onShareAppMessage() {
 
+  },
+  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() {
+    wx.navigateTo({
+      url: '../details/detail',
+    })
   }
 })

+ 6 - 2
nnzwminiapp/pagesPublic/pages/tdcr/tdcr-list/index.wxml

@@ -1,5 +1,9 @@
 <!--pagesPublic/pages/tdcr/tdcr-list/index.wxml-->
-<view class="list_main" style="background-image: url('{{imgUrl}}tdcrlist/tdcrlist3.png'); background-size: 100% 100%;">
+<view
+  capture-bind:touchmove="handleTouchmove"
+  capture-bind:touchstart="handleTouchstart"
+  capture-catch:touchend="handleTouchend"
+ class="list_main" style="background-image: url('{{imgUrl}}tdcrlist/tdcrlist3.png'); background-size: 100% 100%;">
 	<view style="height: 14vh;"></view>
 	<view class="map-block" style="background-image: url('{{imgUrl}}tdcrlist/tdcrlist1.png'); background-repeat: no-repeat; ">
 	
@@ -9,7 +13,7 @@
 		<view class="block-name2" style="background-image:url('{{imgUrl}}tdcrlist/tdcrlist7.png');">
 			廖家山地块
 		</view>
-		<view class="block-name3" style="background-image:url('{{imgUrl}}tdcrlist/tdcrlist8.png');">
+		<view class="block-name3" style="background-image:url('{{imgUrl}}tdcrlist/tdcrlist8.png');" bindtap="gotoDetail">
 			南坪东路588号
 		</view>
 		<view class="block-name4" style="background-image:url('{{imgUrl}}tdcrlist/tdcrlist7.png');">