inputtip.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. //logs.js
  2. let util = require('../../utils/util.js');
  3. let wechat = require("../../utils/wechat");
  4. let amap = require("../../utils/amap");
  5. Page({
  6. data: {
  7. lonlat: "",
  8. city: "",
  9. longitude: null,
  10. latitude: null,
  11. tips: [],
  12. searchString: null
  13. },
  14. onLoad(e) {
  15. let {
  16. lonlat,
  17. city
  18. } = e;
  19. var longitude = lonlat.split(",")[0];
  20. var latitude = lonlat.split(",")[1];
  21. console.log({
  22. lonlat,
  23. longitude,
  24. latitude,
  25. city
  26. });
  27. this.setData({
  28. lonlat,
  29. longitude,
  30. latitude,
  31. city
  32. })
  33. },
  34. bindInput2(e) {
  35. let {
  36. value
  37. } = e.detail;
  38. let {
  39. lonlat,
  40. city
  41. } = this.data;
  42. amap.getInputtips(city, lonlat, value)
  43. .then(d => {
  44. //console.log(d);
  45. if (d && d.tips) {
  46. this.setData({
  47. tips: d.tips
  48. });
  49. }
  50. })
  51. .catch(e => {
  52. console.log(e);
  53. })
  54. },
  55. bindInput(e) {
  56. this.setData({
  57. searchString: e.detail.value
  58. });
  59. },
  60. bindSearch2(e) {
  61. let {
  62. keywords
  63. } = e.currentTarget.dataset;
  64. let pages = getCurrentPages();
  65. let prevPage = pages[0]; //首页
  66. //console.log(pages);
  67. //console.log(e);
  68. console.log(keywords);
  69. if (keywords) {
  70. prevPage.setData({
  71. keywords
  72. });
  73. console.log(keywords.name, keywords.location);
  74. //amap.getPoiAround(keywords.name, keywords.location)
  75. //.then(d => {
  76. // console.log(d);
  77. // let {
  78. // markers
  79. // } = d;
  80. // markers.forEach((item, index) => {
  81. // item.callout = {}; //marker绑定点击事件后,导致气泡一闪一闪,不想显示
  82. // item.iconPath = "/images/marker.png";
  83. // item.width = '88rpx';
  84. // item.height = '112rpx';
  85. // item.address = d.poisData[index].cityname + d.poisData[index].adname + d.poisData[index].address;
  86. // })
  87. // prevPage.setData({
  88. // markers
  89. // });
  90. // prevPage.showMarkerInfo(markers[0]);
  91. // prevPage.changeMarkerColor(0);
  92. //})
  93. //.catch(e => {
  94. // console.log(e);
  95. //})
  96. }
  97. //let url = `/pages/index/index`;
  98. //wx.navigateBack({
  99. // url
  100. // });
  101. let {
  102. city,
  103. longitude,
  104. latitude
  105. } = this.data;
  106. let url = `/pages/search_result/search_result?city=${city}&longitude=${longitude}&latitude=${latitude}&name=${keywords.name}&location=${keywords.location}`;
  107. wx.navigateTo({
  108. url
  109. });
  110. },
  111. bindSearch(e) {
  112. let {
  113. searchString: keywords
  114. } = this.data;
  115. let pages = getCurrentPages();
  116. let prevPage = pages[0]; //首页
  117. if (keywords) {
  118. prevPage.setData({
  119. keywords
  120. });
  121. let {
  122. city,
  123. longitude,
  124. latitude
  125. } = this.data;
  126. let url = `/pages/search_result/search_result?city=${city}&longitude=${longitude}&latitude=${latitude}&searchString=${keywords}`;
  127. wx.navigateTo({
  128. url
  129. });
  130. }
  131. },
  132. cancel(e) {
  133. console.log(e);
  134. wx.navigateBack();
  135. }
  136. });