index.js 3.5 KB

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