list.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. // pages/home/map/list.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. workelist:[],
  9. status:"",
  10. inputValue:"",
  11. pageindex: 1
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function (options) {
  17. this.workDesc();
  18. this.setData({
  19. status:app.globalData.status
  20. })
  21. },
  22. /**
  23. * 生命周期函数--监听页面初次渲染完成
  24. */
  25. onReady: function () {
  26. },
  27. /**
  28. * 生命周期函数--监听页面显示
  29. */
  30. onShow: function () {
  31. },
  32. /**
  33. * 生命周期函数--监听页面隐藏
  34. */
  35. onHide: function () {
  36. },
  37. /**
  38. * 生命周期函数--监听页面卸载
  39. */
  40. onUnload: function () {
  41. },
  42. /**
  43. * 页面相关事件处理函数--监听用户下拉动作
  44. */
  45. onPullDownRefresh: function () {
  46. },
  47. /**
  48. * 页面上拉触底事件的处理函数
  49. */
  50. onReachBottom: function () {
  51. this.setData({pageindex:this.data.pageindex+=1})
  52. this.workDesc()
  53. },
  54. //网点列表
  55. workDesc:function(e){
  56. var that=this;
  57. var keyword=that.data.inputValue;
  58. console.log(keyword);
  59. var latitude=wx.getStorageSync('latitude');
  60. var longitude=wx.getStorageSync('longitude');
  61. app.api.useApi(app.globalData.baseAppUrl + "api", {
  62. lat: latitude,
  63. lng: longitude,
  64. keyword: keyword,
  65. page: that.data.pageindex
  66. }, "get").then(function (res) {
  67. if (res.code != 200) {
  68. wx.showLoading({
  69. title: '网点加载失败'+res.status,
  70. })
  71. that.setData({pageindex: that.data.pageindex -= 1})
  72. } else {
  73. if (that.data.pageindex == 1) {
  74. that.setData({workelist: []})
  75. }
  76. if (res.message.data.data.length > 0) {
  77. that.setData({workelist: that.data.workelist.concat(res.message.data.data)})
  78. } else {
  79. that.setData({pageindex: that.data.pageindex -= 1})
  80. }
  81. }
  82. wx.hideLoading();
  83. }).catch(function (err) {
  84. console.log(222);
  85. })
  86. },
  87. bindKeyInput: function (e) {
  88. this.setData({
  89. inputValue: e.detail.value
  90. })
  91. },
  92. setworke(e){
  93. console.log(e);
  94. const network_id=e.currentTarget.dataset.id
  95. var that=this;
  96. app.api.useApi(app.globalData.baseAppUrl+"api/user/"+network_id+"/setNetwork",{
  97. },"post").then(function(res){
  98. if (res.code == 200) {
  99. wx.showLoading({
  100. title: res.message.msg,
  101. })
  102. wx.setStorageSync('nid', network_id);
  103. setTimeout(function () {
  104. wx.switchTab({
  105. url: '/pages/tabber/home/index',
  106. })
  107. }, 1000)
  108. }
  109. }).catch(function(err){
  110. console.log(222);
  111. })
  112. },
  113. location(e){
  114. wx.openLocation({
  115. latitude: Number(e.currentTarget.dataset.lat),
  116. longitude:Number(e.currentTarget.dataset.lng)
  117. });
  118. }
  119. })