index.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. // pagesPublic/pages/tdcr/tdcr-list/index.js
  2. import {
  3. imgUrl,
  4. request,
  5. request2
  6. } from "../../api/request"
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. imgUrl,
  13. headerStyle: {},
  14. touchData: {
  15. flag: 0,
  16. lastX: 0,
  17. lastY: 0
  18. },
  19. list: [{
  20. left: 18.5,
  21. top: 21,
  22. zIndex: 1,
  23. nameStyle: {
  24. txt: '廖家山一期',
  25. img: 'tdcrlist7.png'
  26. },
  27. lineStyle: {
  28. height: 25,
  29. left: 3,
  30. top: -0.5
  31. },
  32. postionStyle: {
  33. top: -0.5,
  34. left: 0.5
  35. }
  36. },{
  37. left: 30,
  38. top: 34.5,
  39. zIndex: 3,
  40. nameStyle: {
  41. txt: '四公里大片区',
  42. img: 'tdcrlist8.png',
  43. color: '#0F2887',
  44. x: 2
  45. },
  46. lineStyle: {
  47. height: 18,
  48. left: 5,
  49. top: -0.5
  50. },
  51. postionStyle: {
  52. top: -0.5,
  53. left: 2.5
  54. }
  55. }, {
  56. left: 27,
  57. top: 28.5,
  58. zIndex: 2,
  59. nameStyle: {
  60. txt: '双峰山1号',
  61. img: 'tdcrlist7.png'
  62. },
  63. lineStyle: {
  64. height: 13,
  65. left: 3,
  66. top: -0.5
  67. },
  68. postionStyle: {
  69. top: -0.5,
  70. left: 0.5
  71. }
  72. }, {
  73. left: 41,
  74. top: 48,
  75. nameStyle: {
  76. txt: '广阳湾三期',
  77. img: 'tdcrlist7.png',
  78. top: 25.5
  79. },
  80. lineStyle: {
  81. height: 8,
  82. left: 3,
  83. top: 13
  84. },
  85. postionStyle: {
  86. top: -0.5,
  87. left: 0.5
  88. }
  89. }, {
  90. left: 27,
  91. top: 46.5,
  92. nameStyle: {
  93. txt: '广阳湾二期',
  94. img: 'tdcrlist7.png',
  95. top: 33
  96. },
  97. lineStyle: {
  98. height: 12,
  99. left: 3,
  100. top: 16
  101. },
  102. postionStyle: {
  103. top: -0.5,
  104. left: 0.5
  105. }
  106. }, {
  107. left: 50,
  108. top: 30.5,
  109. nameStyle: {
  110. txt: '广阳湾一期',
  111. img: 'tdcrlist7.png',
  112. top: 33
  113. },
  114. lineStyle: {
  115. height: 12,
  116. left: 3,
  117. top: 16
  118. },
  119. postionStyle: {
  120. top: -0.5,
  121. left: 0.5
  122. }
  123. }]
  124. },
  125. /**
  126. * 生命周期函数--监听页面加载
  127. */
  128. onLoad(options) {
  129. this.setData({
  130. headerStyle: wx.getMenuButtonBoundingClientRect(),
  131. })
  132. },
  133. /**
  134. * 生命周期函数--监听页面初次渲染完成
  135. */
  136. onReady() {
  137. },
  138. /**
  139. * 生命周期函数--监听页面显示
  140. */
  141. onShow() {
  142. },
  143. /**
  144. * 生命周期函数--监听页面隐藏
  145. */
  146. onHide() {
  147. },
  148. /**
  149. * 生命周期函数--监听页面卸载
  150. */
  151. onUnload() {
  152. },
  153. /**
  154. * 页面相关事件处理函数--监听用户下拉动作
  155. */
  156. onPullDownRefresh() {
  157. },
  158. /**
  159. * 页面上拉触底事件的处理函数
  160. */
  161. onReachBottom() {
  162. },
  163. /**
  164. * 用户点击右上角分享
  165. */
  166. onShareAppMessage() {
  167. return {
  168. title: '2024年土地供应',
  169. imageUrl: imgUrl + '/tdcr/share.jpg'
  170. }
  171. },
  172. handleTouchend() {
  173. let touchData = this.data.touchData
  174. touchData.flag = 0
  175. //停止滑动
  176. this.setData({
  177. touchData
  178. })
  179. },
  180. handleTouchstart(event) {
  181. this.setData({
  182. touchData: {
  183. flag: 0,
  184. lastX: event.changedTouches[0].pageX,
  185. lastY: event.changedTouches[0].pageY
  186. }
  187. })
  188. },
  189. handleTouchmove(event) {
  190. let touchData = this.data.touchData
  191. if (touchData.flag !== 0) {
  192. return;
  193. }
  194. let currentX = event.changedTouches[0].pageX;
  195. let currentY = event.changedTouches[0].pageY;
  196. let tx = currentX - touchData.lastX;
  197. let ty = currentY - touchData.lastY;
  198. //左右方向偏移大于上下偏移认为是左右滑动
  199. if (Math.abs(tx) - Math.abs(ty) > 5) {
  200. // 向左滑动
  201. if (tx < 0) {
  202. // 如果到最右侧
  203. console.log('向左滑动');
  204. touchData.flag = 1;
  205. } else if (tx > 0) {
  206. // 如果到最左侧
  207. touchData.flag = 2;
  208. console.log('向右滑动');
  209. wx.navigateBack()
  210. }
  211. }
  212. //将当前坐标进行保存以进行下一次计算
  213. touchData.lastX = currentX;
  214. touchData.lastY = currentY;
  215. this.setData({
  216. touchData
  217. })
  218. },
  219. gotoDetail(e) {
  220. console.log(e);
  221. wx.navigateTo({
  222. url: '../details/detail?index=' + e.target.dataset.index,
  223. })
  224. }
  225. })