decorationhelp.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. var widths=0;
  2. var lengs=0;
  3. var shus=0;
  4. var app=getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. imgUrl:app.globalData.imgUrl,
  11. URL:app.globalData.url,
  12. winHeight: '100%',
  13. toView: 'zxzs01',//锚点跳转的ID
  14. actionView: 'zxzs01',//控制导航显示
  15. zxzs01Top: 0,
  16. zxzs02Top: 0,
  17. zxzs03Top: 0,
  18. zxzs04Top: 0,
  19. zxzs05Top: 0,
  20. zxzs06Top: 0,
  21. zxzs07Top: 0,
  22. zxzs08Top: 0,
  23. navScrollLeft:0,
  24. isdlt:'',
  25. swiperNav: {
  26.   i: 0,
  27.   arr: ['zxzs01','zxzs02','zxzs03','zxzs04','zxzs05','zxzs06','zxzs07','zxzs08']
  28.  },
  29. datalist:[]
  30. },
  31. /**
  32. * 生命周期函数--监听页面加载
  33. */
  34. onLoad: function (options) {
  35. var that = this;
  36. widths = wx.getSystemInfoSync().windowWidth;
  37. lengs = this.data.swiperNav.arr.length;
  38. wx.getSystemInfo({
  39. success: function (res) {
  40. that.setData({
  41. winHeight:res.windowHeight-(res.windowWidth*90/750)-229+'px'
  42. })
  43. }
  44. });
  45. wx.showLoading({
  46. title: '加载中',
  47. })
  48. utils.$get({
  49. url: app.globalData.webUrl+'api/tool/decohelper_struc',
  50. header: {
  51. 'Authorization':'bearer '+app.globalData.token
  52. },
  53. dataType: 'json',
  54. success(res) {
  55. console.log(res.data)
  56. if(res.data.code==0){
  57. wx.hideLoading();
  58. that.setData({
  59. datalist:res.data.data
  60. })
  61. }
  62. }
  63. })
  64. },
  65. /**
  66. * 生命周期函数--监听页面初次渲染完成
  67. */
  68. onReady: function () {
  69. },
  70. /**
  71. * 生命周期函数--监听页面显示
  72. */
  73. onShow: function () {
  74. },
  75. onReady(){
  76. new Promise(resolve => {
  77. let query = wx.createSelectorQuery().in(this);
  78. setTimeout(() => {
  79. query.select('#zxzs01').boundingClientRect();
  80. query.select('#zxzs02').boundingClientRect();
  81. query.select('#zxzs03').boundingClientRect();
  82. query.select('#zxzs04').boundingClientRect();
  83. query.select('#zxzs05').boundingClientRect();
  84. query.select('#zxzs06').boundingClientRect();
  85. query.select('#zxzs07').boundingClientRect();
  86. query.select('#zxzs08').boundingClientRect();
  87. query.exec(function (res) {
  88. resolve(res);
  89. });
  90. },3000);
  91. }).then(res => {
  92. this.setData({
  93. zxzs01Top: res[0].top,
  94. zxzs02Top: res[1].top-res[0].top,
  95. zxzs03Top: res[2].top-res[0].top,
  96. zxzs04Top: res[3].top-res[0].top,
  97. zxzs05Top: res[4].top-res[0].top,
  98. zxzs06Top: res[5].top-res[0].top,
  99. zxzs07Top: res[6].top-res[0].top,
  100. zxzs08Top: res[7].top-res[0].top
  101. });
  102. });
  103. },
  104. toViewClick(e) {
  105. console.log(e)
  106. this.setData({
  107. toView: e.currentTarget.dataset.hash,
  108. actionView: e.currentTarget.dataset.hash
  109. })
  110. },
  111. disx(i){
  112. var disX = (i - 1) * widths / (lengs-2);
  113. if (i != this.data.swiperNav.i) {
  114.   this.setData({
  115.    'swiperNav.i': i
  116.   })
  117.  }
  118.  this.setData({
  119.   'swiperNav.x': disX
  120.  })
  121. },
  122. scrollTo(e){
  123. let scrollTop = e.detail.scrollTop+100;
  124. console.log(scrollTop)
  125. if(scrollTop >= this.data.zxzs08Top){
  126. shus=7;
  127. this.setData({
  128. actionView: 'zxzs08'
  129. })
  130. }else if(scrollTop >= this.data.zxzs07Top){
  131. shus=6;
  132. this.setData({
  133. actionView: 'zxzs07'
  134. })
  135. }else if(scrollTop >= this.data.zxzs06Top){
  136. shus=5;
  137. this.setData({
  138. actionView: 'zxzs06'
  139. })
  140. }else if(scrollTop >= this.data.zxzs05Top){
  141. shus=4;
  142. this.setData({
  143. actionView: 'zxzs05'
  144. })
  145. }else if(scrollTop >= this.data.zxzs04Top){
  146. shus=3;
  147. this.setData({
  148. actionView: 'zxzs04'
  149. })
  150. }else if(scrollTop >= this.data.zxzs03Top){
  151. shus=2;
  152. this.setData({
  153. actionView: 'zxzs03'
  154. })
  155. }else if(scrollTop >= this.data.zxzs02Top){
  156. shus=1;
  157. this.setData({
  158. actionView: 'zxzs02'
  159. })
  160. }else{
  161. shus=0;
  162. this.setData({
  163. actionView: 'zxzs01'
  164. })
  165. }
  166. this.disx(shus);
  167. },
  168. editorbtn(e){
  169. if(!this.data.isdlt){
  170. this.setData({
  171. isdlt:e.currentTarget.dataset.title
  172. })
  173. }else{
  174. this.setData({
  175. isdlt:''
  176. })
  177. }
  178. },
  179. deletebtn(e){
  180. console.log(e.currentTarget.dataset.title)
  181. },
  182. /**
  183. * 生命周期函数--监听页面隐藏
  184. */
  185. onHide: function () {
  186. },
  187. /**
  188. * 生命周期函数--监听页面卸载
  189. */
  190. onUnload: function () {
  191. },
  192. /**
  193. * 页面相关事件处理函数--监听用户下拉动作
  194. */
  195. onPullDownRefresh: function () {
  196. },
  197. /**
  198. * 页面上拉触底事件的处理函数
  199. */
  200. onReachBottom: function () {
  201. },
  202. /**
  203. * 用户点击右上角分享
  204. */
  205. })