point.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // pages/tabber/news/index.js
  2. const app=getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. taskInfo:[],
  9. columns: ['北京','杭州', '宁波', '温州', '嘉兴', '湖州'],
  10. show:false,
  11. vtype:'北京',
  12. ktype:'0',
  13. keyword:"",
  14. pageindex: 1
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. this.gettasklist();
  21. },
  22. /**
  23. * 生命周期函数--监听页面初次渲染完成
  24. */
  25. onReady: function () {
  26. },
  27. /**
  28. * 页面上拉触底事件的处理函数
  29. */
  30. onReachBottom: function () {
  31. // this.setData({pageindex:this.data.pageindex+=1})
  32. // this.gettasklist()
  33. },
  34. bindinput(e){
  35. this.setData({
  36. inputValue: e.detail.value
  37. })
  38. },
  39. city(){
  40. this.setData({
  41. show:!this.data.show
  42. })
  43. },
  44. onClose() {
  45. this.setData({ show: false });
  46. },
  47. onChange(event) {
  48. const { picker, value, index } = event.detail;
  49. this.setData({
  50. vtype:value,
  51. show:!this.data.show,
  52. ktype:index
  53. })
  54. console.log(`当前值:${value}, 当前索引:${index}`);
  55. },
  56. deWeightThree(arr){
  57. let map = new Map();
  58. for (let item of arr) {
  59. if (!map.has(item.id)) {
  60. map.set(item.id, item);
  61. }
  62. }
  63. return [...map.values()];
  64. },
  65. gettasklist(){
  66. var that=this
  67. var lng=wx.getStorageSync('longitude');
  68. var lat=wx.getStorageSync('latitude');
  69. var id=this.data.ktype;
  70. var key=this.data.keyword
  71. app.api.useApi(app.globalData.baseAppUrl + "api/admin/GetNetworker", {
  72. city_id:id,
  73. key:key,
  74. lng:lng,
  75. lat:lat,
  76. page: that.data.pageindex
  77. }, "get").then(function (res) {
  78. console.log(res);
  79. if (res.code != 200) {
  80. wx.showLoading({
  81. title: res.message.msg,
  82. })
  83. // that.setData({pageindex: that.data.pageindex -= 1})
  84. setTimeout(function () {
  85. wx.hideLoading();
  86. }, 1000);
  87. } else {
  88. wx.hideLoading();
  89. let arrtask = that.deWeightThree(res.message.data)
  90. that.setData({taskInfo: arrtask})
  91. // if (that.data.pageindex == 1) {
  92. // that.setData({taskInfo: []})
  93. // }
  94. // if (res.message.data.length > 0) {
  95. // that.setData({taskInfo: that.data.taskInfo.concat(res.message.data)})
  96. // } else {
  97. // that.setData({pageindex: that.data.pageindex -= 1})
  98. // }
  99. }
  100. }).catch(function (err) {
  101. console.log(222);
  102. })
  103. }
  104. })