index.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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: '南坪东路588号',
  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: '廖家山地块',
  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: '双峰山1号地块',
  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. },
  108. /**
  109. * 生命周期函数--监听页面加载
  110. */
  111. onLoad(options) {
  112. this.setData({
  113. headerStyle: wx.getMenuButtonBoundingClientRect(),
  114. })
  115. },
  116. /**
  117. * 生命周期函数--监听页面初次渲染完成
  118. */
  119. onReady() {
  120. },
  121. /**
  122. * 生命周期函数--监听页面显示
  123. */
  124. onShow() {
  125. },
  126. /**
  127. * 生命周期函数--监听页面隐藏
  128. */
  129. onHide() {
  130. },
  131. /**
  132. * 生命周期函数--监听页面卸载
  133. */
  134. onUnload() {
  135. },
  136. /**
  137. * 页面相关事件处理函数--监听用户下拉动作
  138. */
  139. onPullDownRefresh() {
  140. },
  141. /**
  142. * 页面上拉触底事件的处理函数
  143. */
  144. onReachBottom() {
  145. },
  146. /**
  147. * 用户点击右上角分享
  148. */
  149. onShareAppMessage() {
  150. return {
  151. title: '2024年土地出让',
  152. imageUrl: imgUrl + '/tdcr/share.jpg'
  153. }
  154. },
  155. handleTouchend() {
  156. let touchData = this.data.touchData
  157. touchData.flag = 0
  158. //停止滑动
  159. this.setData({
  160. touchData
  161. })
  162. },
  163. handleTouchstart(event) {
  164. this.setData({
  165. touchData: {
  166. flag: 0,
  167. lastX: event.changedTouches[0].pageX,
  168. lastY: event.changedTouches[0].pageY
  169. }
  170. })
  171. },
  172. handleTouchmove(event) {
  173. let touchData = this.data.touchData
  174. if (touchData.flag !== 0) {
  175. return;
  176. }
  177. let currentX = event.changedTouches[0].pageX;
  178. let currentY = event.changedTouches[0].pageY;
  179. let tx = currentX - touchData.lastX;
  180. let ty = currentY - touchData.lastY;
  181. //左右方向偏移大于上下偏移认为是左右滑动
  182. if (Math.abs(tx) - Math.abs(ty) > 5) {
  183. // 向左滑动
  184. if (tx < 0) {
  185. // 如果到最右侧
  186. console.log('向左滑动');
  187. touchData.flag = 1;
  188. } else if (tx > 0) {
  189. // 如果到最左侧
  190. touchData.flag = 2;
  191. console.log('向右滑动');
  192. wx.navigateBack()
  193. }
  194. }
  195. //将当前坐标进行保存以进行下一次计算
  196. touchData.lastX = currentX;
  197. touchData.lastY = currentY;
  198. this.setData({
  199. touchData
  200. })
  201. },
  202. gotoDetail(e) {
  203. console.log(e);
  204. wx.navigateTo({
  205. url: '../details/detail?index=' + e.target.dataset.index,
  206. })
  207. }
  208. })