123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- //logs.js
- let util = require('../../utils/util.js');
- let wechat = require("../../utils/wechat");
- let amap = require("../../utils/amap");
- Page({
- data: {
- lonlat: "",
- city: "",
- longitude: null,
- latitude: null,
- tips: [],
- searchString: null
- },
- onLoad(e) {
- let {
- lonlat,
- city
- } = e;
- var longitude = lonlat.split(",")[0];
- var latitude = lonlat.split(",")[1];
- console.log({
- lonlat,
- longitude,
- latitude,
- city
- });
- this.setData({
- lonlat,
- longitude,
- latitude,
- city
- })
- },
- bindInput2(e) {
- let {
- value
- } = e.detail;
- let {
- lonlat,
- city
- } = this.data;
- amap.getInputtips(city, lonlat, value)
- .then(d => {
- //console.log(d);
- if (d && d.tips) {
- this.setData({
- tips: d.tips
- });
- }
- })
- .catch(e => {
- console.log(e);
- })
- },
- bindInput(e) {
- this.setData({
- searchString: e.detail.value
- });
- },
- bindSearch2(e) {
- let {
- keywords
- } = e.currentTarget.dataset;
- let pages = getCurrentPages();
- let prevPage = pages[0]; //首页
- //console.log(pages);
- //console.log(e);
- console.log(keywords);
- if (keywords) {
- prevPage.setData({
- keywords
- });
- console.log(keywords.name, keywords.location);
- //amap.getPoiAround(keywords.name, keywords.location)
- //.then(d => {
- // console.log(d);
- // let {
- // markers
- // } = d;
- // markers.forEach((item, index) => {
- // item.callout = {}; //marker绑定点击事件后,导致气泡一闪一闪,不想显示
- // item.iconPath = "/images/marker.png";
- // item.width = '88rpx';
- // item.height = '112rpx';
- // item.address = d.poisData[index].cityname + d.poisData[index].adname + d.poisData[index].address;
- // })
- // prevPage.setData({
- // markers
- // });
- // prevPage.showMarkerInfo(markers[0]);
- // prevPage.changeMarkerColor(0);
- //})
- //.catch(e => {
- // console.log(e);
- //})
- }
- //let url = `/pages/index/index`;
- //wx.navigateBack({
- // url
- // });
- let {
- city,
- longitude,
- latitude
- } = this.data;
- let url = `/pages/search_result/search_result?city=${city}&longitude=${longitude}&latitude=${latitude}&name=${keywords.name}&location=${keywords.location}`;
- wx.navigateTo({
- url
- });
- },
- bindSearch(e) {
- let {
- searchString: keywords
- } = this.data;
- let pages = getCurrentPages();
- let prevPage = pages[0]; //首页
- if (keywords) {
- prevPage.setData({
- keywords
- });
- let {
- city,
- longitude,
- latitude
- } = this.data;
- let url = `/pages/search_result/search_result?city=${city}&longitude=${longitude}&latitude=${latitude}&searchString=${keywords}`;
- wx.navigateTo({
- url
- });
- }
- },
- cancel(e) {
- console.log(e);
- wx.navigateBack();
- }
- });
|