Commit 9f2ef9453e7a4bff091433e84ff762af5d4a6133

Authored by vking
1 parent bd279d59

搜索平台商户

@@ -628,6 +628,9 @@ Page({ @@ -628,6 +628,9 @@ Page({
628 if(!this.hasSellerConcat){ 628 if(!this.hasSellerConcat){
629 sdobj.markers=[] 629 sdobj.markers=[]
630 } 630 }
  631 + if(suggestion.type==-1){//平台商户
  632 + this.activeSellerID=suggestion.id
  633 + }
631 this.setData(sdobj) 634 this.setData(sdobj)
632 }, 635 },
633 636
1 -// pages/reserve/search.js 1 +// pages/reserve/search.js\
  2 +const map_key='SDEBZ-I74W4-QLGUX-XXYXU-HIR23-3QFBJ'
2 // 引入SDK核心类 3 // 引入SDK核心类
3 var QQMapWX = require('../../utils/qqmap-wx-jssdk'); 4 var QQMapWX = require('../../utils/qqmap-wx-jssdk');
4 // 实例化API核心类 5 // 实例化API核心类
5 var qqmapsdk = new QQMapWX({ 6 var qqmapsdk = new QQMapWX({
6 - key: 'SDEBZ-I74W4-QLGUX-XXYXU-HIR23-3QFBJ' // 必填 7 + key:map_key // 必填
7 }); 8 });
8 import util from '../../utils/util'; 9 import util from '../../utils/util';
  10 +import App from '../../utils/api';
9 const {regeneratorRuntime} = global 11 const {regeneratorRuntime} = global
10 const search_history_cache_key='SEARCH_HISTORY_CACHE_KEY'; 12 const search_history_cache_key='SEARCH_HISTORY_CACHE_KEY';
11 Page({ 13 Page({
@@ -82,7 +84,7 @@ Page({ @@ -82,7 +84,7 @@ Page({
82 var id = e.currentTarget.id; 84 var id = e.currentTarget.id;
83 for (var i = 0; i < this.data.suggestion.length; i++) { 85 for (var i = 0; i < this.data.suggestion.length; i++) {
84 if (i == id) { 86 if (i == id) {
85 - console.log(this.data.suggestion[i]) 87 + console.log('backfill,this.data.suggestion[i]:',this.data.suggestion[i])
86 this.setHistory(this.data.suggestion[i]) 88 this.setHistory(this.data.suggestion[i])
87 let pages = getCurrentPages(); 89 let pages = getCurrentPages();
88 let p = pages[pages.length - 2]; 90 let p = pages[pages.length - 2];
@@ -156,49 +158,41 @@ Page({ @@ -156,49 +158,41 @@ Page({
156 }); 158 });
157 }, 159 },
158 nearby_search: function () { 160 nearby_search: function () {
159 - var _this = this;  
160 - // 调用接口  
161 - let location='';  
162 - if(this.data.suggestion.length>0){  
163 - location=this.data.suggestion[0]  
164 - }  
165 - qqmapsdk.search({  
166 - keyword: this.inputVal, //搜索关键词  
167 - region:this.location.city||'', //设置城市名,限制关键词所示的地域范围,非必填参数 161 + App.Customer.SearchMap({
  162 + //boundary:'region('+this.location.city+',1)',
  163 + boundary:'nearby('+this.location.latitude+','+this.location.longitude+',1000,1)',
  164 + keyword:this.inputVal,
168 page_size:20, 165 page_size:20,
169 - location:location,  
170 - //filter:'category<>美食',  
171 - success: function (res) { //搜索成功后的回调  
172 - var mks = []  
173 - for (var i = 0; i < res.data.length; i++) {  
174 - mks.push({ // 获取返回结果,放到mks数组中  
175 - title: res.data[i].title,  
176 - id: res.data[i].id,  
177 - addr: res.data[i].address,  
178 - city: res.data[i].city,  
179 - district: res.data[i].district,  
180 - latitude: res.data[i].location.lat,  
181 - longitude: res.data[i].location.lng,  
182 - })  
183 - }  
184 - _this.setData({ //设置suggestion属性,将关键词搜索结果以列表形式展示  
185 - suggestion:mks,  
186 - });  
187 - },  
188 - fail: function (res) {  
189 - console.log(res);  
190 - },  
191 - complete: function (res) {  
192 - console.log('nearby_search',res); 166 + page_index:1,
  167 + orderby:'_distance',
  168 + key:map_key,
  169 + }).then(res=>{
  170 + console.log('App.Customer.SearchMap',res)
  171 + res.data=res.data.data
  172 + var mks = []
  173 + for (var i = 0; i < res.data.length; i++) {
  174 + mks.push({ // 获取返回结果,放到mks数组中
  175 + title: res.data[i].title,
  176 + id: res.data[i].id,
  177 + addr: res.data[i].address,
  178 + city: res.data[i].city,
  179 + district: res.data[i].district,
  180 + latitude: res.data[i].location.lat,
  181 + longitude: res.data[i].location.lng,
  182 + type:res.data[i].type,
  183 + })
193 } 184 }
194 - }); 185 + this.setData({ //设置suggestion属性,将关键词搜索结果以列表形式展示
  186 + suggestion:mks,
  187 + });
  188 + })
195 }, 189 },
196 location:'', 190 location:'',
197 getPos(){ 191 getPos(){
198 this._getPos().then(res => { 192 this._getPos().then(res => {
199 console.log('wx.getLocation.then', res); 193 console.log('wx.getLocation.then', res);
200 this.location=res 194 this.location=res
201 - this.getCity() 195 + //this.getCity()
202 }).catch((e) => { 196 }).catch((e) => {
203 console.log('wx.getLocation.catch', e); 197 console.log('wx.getLocation.catch', e);
204 if ('getLocation:fail auth deny' == e.errMsg || 'getLocation:fail:auth denied' == e.errMsg) { 198 if ('getLocation:fail auth deny' == e.errMsg || 'getLocation:fail:auth denied' == e.errMsg) {
@@ -250,6 +250,10 @@ export default { @@ -250,6 +250,10 @@ export default {
250 cachetime: 60, 250 cachetime: 60,
251 }, 251 },
252 252
  253 + //根据腾讯地点搜索api整合现有商家
  254 + 'App.Customer.SearchMap':null,
  255 +
  256 +
253 //获得小程序码 257 //获得小程序码
254 'App.Other.generate_qrcode':{ 258 'App.Other.generate_qrcode':{
255 host: 'https://cli.im/mina/', 259 host: 'https://cli.im/mina/',