index.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. // pages/tabber/news/index.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. selectInfo: {},
  9. logolist: [
  10. {
  11. title: '创星汇科技园45栋门前',
  12. isp: 1,
  13. id: 0
  14. }, {
  15. title: '创星汇科技园45栋门前',
  16. isp: 0,
  17. id: 1
  18. }, {
  19. title: '创星汇科技园45栋门前',
  20. isp: 1,
  21. id: 2
  22. }, {
  23. title: '创星汇科技园45栋门前',
  24. isp: 0,
  25. id: 3
  26. }, {
  27. title: '创星汇科技园45栋门前',
  28. isp: 0,
  29. id: 5
  30. }, {
  31. title: '创星汇科技园45栋门前',
  32. isp: 0,
  33. id: 6
  34. }, {
  35. title: '创星汇科技园45栋门前',
  36. isp: 0,
  37. id: 7
  38. }, {
  39. title: '创星汇科技园45栋门前',
  40. isp: 1,
  41. id: 8
  42. }, {
  43. title: '创星汇科技园45栋门前',
  44. id: 9,
  45. isp: 1,
  46. }, {
  47. title: '创星汇科技园45栋门前',
  48. id: 10,
  49. isp: 1
  50. },
  51. ],
  52. state: "",
  53. detashow: 0,
  54. worke: {"title":"暂无数据",'distance':0,'collect_num':0,'give_num':0,'visit_time':'无','device_no':'无'},
  55. nearby:''
  56. },
  57. /**
  58. * 生命周期函数--监听页面加载
  59. */
  60. onLoad: function (options) {
  61. this.DevicesList()
  62. },
  63. DevicesList(city_id = "", title = "", sort = "") {
  64. var that = this;
  65. app.api.useApi(app.globalData.baseAppUrl + "api/admin/DevicesList", {
  66. lng: wx.getStorageSync('latitude'),
  67. lat: wx.getStorageSync('longitude'),
  68. city_id: city_id,
  69. title: title,
  70. sort: sort
  71. }, "get").then(function (res) {
  72. console.log(res);
  73. if (res.code != 200) {
  74. wx.showLoading({
  75. title: res.message.msg,
  76. })
  77. setTimeout(function () {
  78. wx.navigateBack({
  79. delta: 1
  80. })
  81. wx.hideLoading();
  82. }, 1000);
  83. } else {
  84. wx.hideLoading();
  85. var dataList = res.message.data.list
  86. var nearby = res.message.data.nearby
  87. that.setData({
  88. logolist: dataList,
  89. nearby:nearby,
  90. })
  91. }
  92. }).catch(function (err) {
  93. console.log(222);
  94. })
  95. },
  96. /**
  97. * 生命周期函数--监听页面初次渲染完成
  98. */
  99. onReady: function () {
  100. // const query = wx.createSelectorQuery()
  101. // query.select('#nav').boundingClientRect((res) => {
  102. // console.log(res);
  103. // this.setData({
  104. // selectInfo: res
  105. // })
  106. // })
  107. // query.exec()
  108. },
  109. //点击变色 显示按钮
  110. seled: function (e) {
  111. this.setData({
  112. detashow: 2,
  113. });
  114. var that = this;
  115. var id = e.currentTarget.dataset.id
  116. app.api.useApi(app.globalData.baseAppUrl + "api/admin/SelectNetworker", {
  117. lng: wx.getStorageSync('latitude'),
  118. lat: wx.getStorageSync('longitude'),
  119. id: id
  120. }, "get").then(function (res) {
  121. console.log(res);
  122. if (res.code != 200) {
  123. wx.showLoading({
  124. title: res.message.msg,
  125. })
  126. setTimeout(function () {
  127. wx.hideLoading();
  128. }, 1000);
  129. } else {
  130. wx.hideLoading();
  131. var worke = res.message.data
  132. if(worke){
  133. that.setData({
  134. worke: worke
  135. })
  136. }
  137. }
  138. }).catch(function (err) {
  139. wx.showLoading({
  140. title: '数据获取失败',
  141. })
  142. })
  143. },
  144. deta: function () {
  145. this.setData({
  146. detashow: 0,
  147. });
  148. return false;
  149. if (this.data.detashow) {
  150. this.setData({
  151. detashow: false,
  152. });
  153. } else {
  154. this.setData({
  155. detashow: true,
  156. });
  157. }
  158. },
  159. location(e){
  160. wx.openLocation({
  161. latitude: Number(e.currentTarget.dataset.lat),
  162. longitude:Number(e.currentTarget.dataset.lng)
  163. });
  164. }
  165. })