list.js 2.4 KB

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