Commit a25494e0a5b77ffefc1e121a152947e2f081997c

Authored by wangfan
1 parent 8a693174

c端预定

@@ -27,7 +27,8 @@ @@ -27,7 +27,8 @@
27 "pages/book/smsbatch/update", 27 "pages/book/smsbatch/update",
28 "pages/book/smsbatch/detail", 28 "pages/book/smsbatch/detail",
29 "pages/book/smsbatch/list", 29 "pages/book/smsbatch/list",
30 - "pages/book/smsbatch/result" 30 + "pages/book/smsbatch/result",
  31 + "pages/reserve/search"
31 ], 32 ],
32 "subpackages": [ 33 "subpackages": [
33 { 34 {
@@ -29,6 +29,8 @@ Page({ @@ -29,6 +29,8 @@ Page({
29 multiArray: [['不确定'].concat(renNum()), ['全部菜系'].concat(DA.caixi)], 29 multiArray: [['不确定'].concat(renNum()), ['全部菜系'].concat(DA.caixi)],
30 multiIndex: [6, 0], 30 multiIndex: [6, 0],
31 scrollIntoView:'', 31 scrollIntoView:'',
  32 + suggestion:{},
  33 + hasSuggestion:false,
32 }, 34 },
33 transverseViewHeight:170,//横向滚动高度 35 transverseViewHeight:170,//横向滚动高度
34 //qqmapsdk:null, 36 //qqmapsdk:null,
@@ -73,6 +75,7 @@ Page({ @@ -73,6 +75,7 @@ Page({
73 */ 75 */
74 onShow: function () { 76 onShow: function () {
75 //this.getPos(); 77 //this.getPos();
  78 + if(this.data.hasSuggestion) return;
76 let sys=getApp().system; 79 let sys=getApp().system;
77 this.setData({ 80 this.setData({
78 [`map.height`]: sys.windowHeight-this.transverseViewHeight, 81 [`map.height`]: sys.windowHeight-this.transverseViewHeight,
@@ -365,4 +368,14 @@ Page({ @@ -365,4 +368,14 @@ Page({
365 multiIndex:util.val(e) 368 multiIndex:util.val(e)
366 }) 369 })
367 }, 370 },
  371 + setSuggestion(suggestion){
  372 + let map=this.data.map;
  373 + map.latitude=suggestion.latitude
  374 + map.longitude=suggestion.longitude
  375 + this.setData({
  376 + suggestion:suggestion,
  377 + hasSuggestion:true,
  378 + map:map,
  379 + })
  380 + },
368 }) 381 })
@@ -14,10 +14,12 @@ @@ -14,10 +14,12 @@
14 enable-rotate 14 enable-rotate
15 show-compass 15 show-compass
16 style="width: 100%; height: {{map.height}}px;"></map> 16 style="width: 100%; height: {{map.height}}px;"></map>
17 - <cover-view class="searchAddr flex-ll" style="top: {{searchAddrTop}}rpx;">  
18 - <cover-image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/search.png"></cover-image>  
19 - <cover-view>请输入位置</cover-view>  
20 - </cover-view> 17 + <formids url="/pages/reserve/search">
  18 + <cover-view class="searchAddr flex-ll" style="top: {{searchAddrTop}}rpx;">
  19 + <cover-image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/search.png"></cover-image>
  20 + <cover-view class="title">{{hasSuggestion?suggestion.title:'请输入位置'}}</cover-view>
  21 + </cover-view>
  22 + </formids>
21 </view> 23 </view>
22 <view class="transverse-view"> 24 <view class="transverse-view">
23 <cover-view class="transverse-view-top"></cover-view> 25 <cover-view class="transverse-view-top"></cover-view>
@@ -104,4 +104,9 @@ @@ -104,4 +104,9 @@
104 width: 42rpx; 104 width: 42rpx;
105 height: 40rpx; 105 height: 40rpx;
106 margin: 0 20rpx; 106 margin: 0 20rpx;
  107 +}
  108 +.searchAddr .title{
  109 + line-height: 60rpx;
  110 + height: 60rpx;
  111 + overflow: hidden;
107 } 112 }
  1 +// pages/reserve/search.js
  2 +// 引入SDK核心类
  3 +var QQMapWX = require('../../utils/qqmap-wx-jssdk');
  4 +// 实例化API核心类
  5 +var qqmapsdk = new QQMapWX({
  6 + key: 'SDEBZ-I74W4-QLGUX-XXYXU-HIR23-3QFBJ' // 必填
  7 +});
  8 +import util from '../../utils/util';
  9 +const {regeneratorRuntime} = global
  10 +Page({
  11 +
  12 + /**
  13 + * 页面的初始数据
  14 + */
  15 + data: {
  16 +
  17 + },
  18 +
  19 + /**
  20 + * 生命周期函数--监听页面加载
  21 + */
  22 + onLoad: function (options) {
  23 +
  24 + },
  25 +
  26 + /**
  27 + * 生命周期函数--监听页面初次渲染完成
  28 + */
  29 + onReady: function () {
  30 +
  31 + },
  32 +
  33 + /**
  34 + * 生命周期函数--监听页面显示
  35 + */
  36 + onShow: function () {
  37 +
  38 + },
  39 +
  40 + /**
  41 + * 生命周期函数--监听页面隐藏
  42 + */
  43 + onHide: function () {
  44 +
  45 + },
  46 +
  47 + /**
  48 + * 生命周期函数--监听页面卸载
  49 + */
  50 + onUnload: function () {
  51 +
  52 + },
  53 +
  54 + //在Page({})中使用下列代码
  55 + //数据回填方法
  56 + backfill: function (e) {
  57 + var id = e.currentTarget.id;
  58 + for (var i = 0; i < this.data.suggestion.length;i++){
  59 + if(i == id){
  60 + console.log(this.data.suggestion[i])
  61 + let pages=getCurrentPages();
  62 + let p=pages[pages.length-2];
  63 + p.setSuggestion(this.data.suggestion[i])
  64 + //util.cache('suggestion',this.data.suggestion[i]);
  65 + this.setData({
  66 + backfill: this.data.suggestion[i].title
  67 + });
  68 + wx.navigateBack();
  69 + }
  70 + }
  71 + },
  72 +
  73 + //触发关键词输入提示事件
  74 + getsuggest: function(e) {
  75 + var _this = this;
  76 + //调用关键词提示接口
  77 + qqmapsdk.getSuggestion({
  78 + //获取输入框值并设置keyword参数
  79 + keyword: e.detail.value, //用户输入的关键词,可设置固定值,如keyword:'KFC'
  80 + //region:'北京', //设置城市名,限制关键词所示的地域范围,非必填参数
  81 + success: function(res) {//搜索成功后的回调
  82 + console.log(res);
  83 + var sug = [];
  84 + for (var i = 0; i < res.data.length; i++) {
  85 + sug.push({ // 获取返回结果,放到sug数组中
  86 + title: res.data[i].title,
  87 + id: res.data[i].id,
  88 + addr: res.data[i].address,
  89 + city: res.data[i].city,
  90 + district: res.data[i].district,
  91 + latitude: res.data[i].location.lat,
  92 + longitude: res.data[i].location.lng
  93 + });
  94 + }
  95 + _this.setData({ //设置suggestion属性,将关键词搜索结果以列表形式展示
  96 + suggestion: sug
  97 + });
  98 + },
  99 + fail: function(error) {
  100 + console.error(error);
  101 + },
  102 + complete: function(res) {
  103 + console.log(res);
  104 + }
  105 + });
  106 + }
  107 +})
  1 +{
  2 + "navigationBarBackgroundColor": "#ffffff",
  3 + "navigationBarTextStyle": "black",
  4 + "navigationBarTitleText":"一键订",
  5 + "usingComponents": {
  6 + "formids":"/components/formids/formids",
  7 + "nav":"/components/nav/nav"
  8 + }
  9 +}
  1 +<!--pages/reserve/search.wxml-->
  2 +<nav>请输入位置</nav>
  3 +<view class="pages">
  4 + <view class="searchAddr flex-ll" style="top: {{searchAddrTop}}rpx;">
  5 + <image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/search.png"></image>
  6 + <input style="width: 100%;" placeholder="请输入位置" bindinput="getsuggest" value="{{backfill}}"/>
  7 + </view>
  8 + <view class="res-view">
  9 + <!--绑定回填事件-->
  10 + <view class="res-item" wx:for="{{suggestion}}" wx:key="index"
  11 + bindtap="backfill" id="{{index}}">
  12 + <!--根据需求渲染相应数据-->
  13 + <!--渲染地址title-->
  14 + <view class="label">{{item.title}}</view>
  15 + <!--渲染详细地址-->
  16 + <view class="address">{{item.addr}}</view>
  17 + </view>
  18 + </view>
  19 +</view>
  1 +/* pages/reserve/search.wxss */
  2 +.pages{
  3 + width: 90%;
  4 + margin: 5% auto;
  5 + color:#353535;
  6 +}
  7 +.searchAddr {
  8 + position: fixed;
  9 + top:140rpx;
  10 + width: 90%;
  11 + height: 60rpx;
  12 + background-color: #fefefe;
  13 + border-radius: 30rpx;
  14 + line-height: 60rpx;
  15 + color:#999999;
  16 + line-height: 60rpx;
  17 + font-size: 28rpx;
  18 + border: 2rpx solid #cccccc;
  19 +}
  20 +.searchAddr .icon{
  21 + width: 42rpx;
  22 + height: 40rpx;
  23 + margin: 0 20rpx;
  24 +}
  25 +.res-view{
  26 + margin-top: 100rpx;
  27 +}
  28 +.res-item{
  29 + width: 100%;
  30 + border-bottom: 2rpx solid #cccccc;
  31 + padding: 20rpx 0;
  32 +}
  33 +.res-item .label{
  34 + font-size: 30rpx;
  35 +}
  36 +.res-item .address{
  37 + font-size: 24rpx;
  38 + color:#4C4E4F;
  39 +}
@@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
31 "list": [] 31 "list": []
32 }, 32 },
33 "miniprogram": { 33 "miniprogram": {
34 - "current": 6, 34 + "current": 38,
35 "list": [ 35 "list": [
36 { 36 {
37 "id": 0, 37 "id": 0,
@@ -321,6 +321,13 @@ @@ -321,6 +321,13 @@
321 "shareName": "8DEbIRpK4pa9mH_QY2vU4ZUKYPuI97WoQ4BQoFej-Q8@cr4dev", 321 "shareName": "8DEbIRpK4pa9mH_QY2vU4ZUKYPuI97WoQ4BQoFej-Q8@cr4dev",
322 "shareKey": "PZhnqMlY2TnRuHhATyGeSamVmBQUDXXr_WtjRSddeeFK17UAiOP-HNOdhxiEN7PFub5S1DjAeUl0IXOdW-VDqg~~" 322 "shareKey": "PZhnqMlY2TnRuHhATyGeSamVmBQUDXXr_WtjRSddeeFK17UAiOP-HNOdhxiEN7PFub5S1DjAeUl0IXOdW-VDqg~~"
323 } 323 }
  324 + },
  325 + {
  326 + "id": -1,
  327 + "name": "pages/reserve/search 在线订座",
  328 + "pathName": "pages/reserve/search",
  329 + "query": "",
  330 + "scene": null
324 } 331 }
325 ] 332 ]
326 } 333 }
  1 +/**
  2 + * 微信小程序JavaScriptSDK
  3 + *
  4 + * @version 1.0
  5 + * @date 2017-01-10
  6 + * @author jaysonzhou@tencent.com
  7 + */
  8 +
  9 +var ERROR_CONF = {
  10 + KEY_ERR: 311,
  11 + KEY_ERR_MSG: 'key格式错误',
  12 + PARAM_ERR: 310,
  13 + PARAM_ERR_MSG: '请求参数信息有误',
  14 + SYSTEM_ERR: 600,
  15 + SYSTEM_ERR_MSG: '系统错误',
  16 + WX_ERR_CODE: 1000,
  17 + WX_OK_CODE: 200
  18 +};
  19 +var BASE_URL = 'https://apis.map.qq.com/ws/';
  20 +var URL_SEARCH = BASE_URL + 'place/v1/search';
  21 +var URL_SUGGESTION = BASE_URL + 'place/v1/suggestion';
  22 +var URL_GET_GEOCODER = BASE_URL + 'geocoder/v1/';
  23 +var URL_CITY_LIST = BASE_URL + 'district/v1/list';
  24 +var URL_AREA_LIST = BASE_URL + 'district/v1/getchildren';
  25 +var URL_DISTANCE = BASE_URL + 'distance/v1/';
  26 +var Utils = {
  27 + /**
  28 + * 得到终点query字符串
  29 + * @param {Array|String} 检索数据
  30 + */
  31 + location2query(data) {
  32 + if (typeof data == 'string') {
  33 + return data;
  34 + }
  35 + var query = '';
  36 + for (var i = 0; i < data.length; i++) {
  37 + var d = data[i];
  38 + if (!!query) {
  39 + query += ';';
  40 + }
  41 + if (d.location) {
  42 + query = query + d.location.lat + ',' + d.location.lng;
  43 + }
  44 + if (d.latitude && d.longitude) {
  45 + query = query + d.latitude + ',' + d.longitude;
  46 + }
  47 + }
  48 + return query;
  49 + },
  50 +
  51 + /**
  52 + * 使用微信接口进行定位
  53 + */
  54 + getWXLocation(success, fail, complete) {
  55 + wx.getLocation({
  56 + type: 'gcj02',
  57 + success: success,
  58 + fail: fail,
  59 + complete: complete
  60 + });
  61 + },
  62 +
  63 + /**
  64 + * 获取location参数
  65 + */
  66 + getLocationParam(location) {
  67 + if (typeof location == 'string') {
  68 + var locationArr = location.split(',');
  69 + if (locationArr.length === 2) {
  70 + location = {
  71 + latitude: location.split(',')[0],
  72 + longitude: location.split(',')[1]
  73 + };
  74 + } else {
  75 + location = {};
  76 + }
  77 + }
  78 + return location;
  79 + },
  80 +
  81 + /**
  82 + * 回调函数默认处理
  83 + */
  84 + polyfillParam(param) {
  85 + param.success = param.success || function () { };
  86 + param.fail = param.fail || function () { };
  87 + param.complete = param.complete || function () { };
  88 + },
  89 +
  90 + /**
  91 + * 验证param对应的key值是否为空
  92 + *
  93 + * @param {Object} param 接口参数
  94 + * @param {String} key 对应参数的key
  95 + */
  96 + checkParamKeyEmpty(param, key) {
  97 + if (!param[key]) {
  98 + var errconf = this.buildErrorConfig(ERROR_CONF.PARAM_ERR, ERROR_CONF.PARAM_ERR_MSG + key +'参数格式有误');
  99 + param.fail(errconf);
  100 + param.complete(errconf);
  101 + return true;
  102 + }
  103 + return false;
  104 + },
  105 +
  106 + /**
  107 + * 验证参数中是否存在检索词keyword
  108 + *
  109 + * @param {Object} param 接口参数
  110 + */
  111 + checkKeyword(param){
  112 + return !this.checkParamKeyEmpty(param, 'keyword');
  113 + },
  114 +
  115 + /**
  116 + * 验证location值
  117 + *
  118 + * @param {Object} param 接口参数
  119 + */
  120 + checkLocation(param) {
  121 + var location = this.getLocationParam(param.location);
  122 + if (!location || !location.latitude || !location.longitude) {
  123 + var errconf = this.buildErrorConfig(ERROR_CONF.PARAM_ERR, ERROR_CONF.PARAM_ERR_MSG + ' location参数格式有误')
  124 + param.fail(errconf);
  125 + param.complete(errconf);
  126 + return false;
  127 + }
  128 + return true;
  129 + },
  130 +
  131 + /**
  132 + * 构造错误数据结构
  133 + * @param {Number} errCode 错误码
  134 + * @param {Number} errMsg 错误描述
  135 + */
  136 + buildErrorConfig(errCode, errMsg) {
  137 + return {
  138 + status: errCode,
  139 + message: errMsg
  140 + };
  141 + },
  142 +
  143 + /**
  144 + * 构造微信请求参数,公共属性处理
  145 + *
  146 + * @param {Object} param 接口参数
  147 + * @param {Object} param 配置项
  148 + */
  149 + buildWxRequestConfig(param, options) {
  150 + var that = this;
  151 + options.header = { "content-type": "application/json" };
  152 + options.method = 'GET';
  153 + options.success = function (res) {
  154 + var data = res.data;
  155 + if (data.status === 0) {
  156 + param.success(data);
  157 + } else {
  158 + param.fail(data);
  159 + }
  160 + };
  161 + options.fail = function (res) {
  162 + res.statusCode = ERROR_CONF.WX_ERR_CODE;
  163 + param.fail(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, result.errMsg));
  164 + };
  165 + options.complete = function (res) {
  166 + var statusCode = +res.statusCode;
  167 + switch(statusCode) {
  168 + case ERROR_CONF.WX_ERR_CODE: {
  169 + param.complete(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg));
  170 + break;
  171 + }
  172 + case ERROR_CONF.WX_OK_CODE: {
  173 + var data = res.data;
  174 + if (data.status === 0) {
  175 + param.complete(data);
  176 + } else {
  177 + param.complete(that.buildErrorConfig(data.status, data.message));
  178 + }
  179 + break;
  180 + }
  181 + default:{
  182 + param.complete(that.buildErrorConfig(ERROR_CONF.SYSTEM_ERR, ERROR_CONF.SYSTEM_ERR_MSG));
  183 + }
  184 +
  185 + }
  186 + }
  187 + return options;
  188 + },
  189 +
  190 + /**
  191 + * 处理用户参数是否传入坐标进行不同的处理
  192 + */
  193 + locationProcess(param, locationsuccess, locationfail, locationcomplete) {
  194 + var that = this;
  195 + locationfail = locationfail || function (res) {
  196 + res.statusCode = ERROR_CONF.WX_ERR_CODE;
  197 + param.fail(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg));
  198 + };
  199 + locationcomplete = locationcomplete || function (res) {
  200 + if (res.statusCode == ERROR_CONF.WX_ERR_CODE) {
  201 + param.complete(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg));
  202 + }
  203 + };
  204 + if (!param.location) {
  205 + that.getWXLocation(locationsuccess, locationfail, locationcomplete);
  206 + } else if (that.checkLocation(param)) {
  207 + var location = Utils.getLocationParam(param.location);
  208 + locationsuccess(location);
  209 + }
  210 + }
  211 +}
  212 +
  213 +
  214 +class QQMapWX {
  215 +
  216 + /**
  217 + * 构造函数
  218 + *
  219 + * @param {Object} options 接口参数,key 为必选参数
  220 + */
  221 + constructor(options) {
  222 + if (!options.key) {
  223 + throw Error('key值不能为空');
  224 + }
  225 + this.key = options.key;
  226 + }
  227 +
  228 + /**
  229 + * POI周边检索
  230 + *
  231 + * @param {Object} options 接口参数对象
  232 + *
  233 + * 参数对象结构可以参考
  234 + * @see http://lbs.qq.com/webservice_v1/guide-search.html
  235 + */
  236 + search(options) {
  237 + var that = this;
  238 + options = options || {};
  239 +
  240 + Utils.polyfillParam(options);
  241 +
  242 + if (!Utils.checkKeyword(options)) {
  243 + return;
  244 + }
  245 +
  246 + var requestParam = {
  247 + keyword: options.keyword,
  248 + orderby: options.orderby || '_distance',
  249 + page_size: options.page_size || 10,
  250 + page_index: options.page_index || 1,
  251 + output: 'json',
  252 + key: that.key
  253 + };
  254 +
  255 + if (options.address_format) {
  256 + requestParam.address_format = options.address_format;
  257 + }
  258 +
  259 + if (options.filter) {
  260 + requestParam.filter = options.filter;
  261 + }
  262 +
  263 + var distance = options.distance || "1000";
  264 + var auto_extend = options.auto_extend || 1;
  265 +
  266 + var locationsuccess = function (result) {
  267 + requestParam.boundary = "nearby(" + result.latitude + "," + result.longitude + "," + distance + "," + auto_extend +")";
  268 + wx.request(Utils.buildWxRequestConfig(options, {
  269 + url: URL_SEARCH,
  270 + data: requestParam
  271 + }));
  272 + }
  273 + Utils.locationProcess(options, locationsuccess);
  274 + }
  275 +
  276 + /**
  277 + * sug模糊检索
  278 + *
  279 + * @param {Object} options 接口参数对象
  280 + *
  281 + * 参数对象结构可以参考
  282 + * http://lbs.qq.com/webservice_v1/guide-suggestion.html
  283 + */
  284 + getSuggestion(options) {
  285 + var that = this;
  286 + options = options || {};
  287 + Utils.polyfillParam(options);
  288 +
  289 + if (!Utils.checkKeyword(options)) {
  290 + return;
  291 + }
  292 +
  293 + var requestParam = {
  294 + keyword: options.keyword,
  295 + region: options.region || '全国',
  296 + region_fix: options.region_fix || 0,
  297 + policy: options.policy || 0,
  298 + output: 'json',
  299 + key: that.key
  300 + };
  301 + wx.request(Utils.buildWxRequestConfig(options, {
  302 + url: URL_SUGGESTION,
  303 + data: requestParam
  304 + }));
  305 + }
  306 +
  307 + /**
  308 + * 逆地址解析
  309 + *
  310 + * @param {Object} options 接口参数对象
  311 + *
  312 + * 请求参数结构可以参考
  313 + * http://lbs.qq.com/webservice_v1/guide-gcoder.html
  314 + */
  315 + reverseGeocoder(options) {
  316 + var that = this;
  317 + options = options || {};
  318 + Utils.polyfillParam(options);
  319 + var requestParam = {
  320 + coord_type: options.coord_type || 5,
  321 + get_poi: options.get_poi || 0,
  322 + output: 'json',
  323 + key: that.key
  324 + };
  325 + if (options.poi_options) {
  326 + requestParam.poi_options = options.poi_options
  327 + }
  328 +
  329 + var locationsuccess = function (result) {
  330 + requestParam.location = result.latitude + ',' + result.longitude;
  331 + wx.request(Utils.buildWxRequestConfig(options, {
  332 + url: URL_GET_GEOCODER,
  333 + data: requestParam
  334 + }));
  335 + };
  336 + Utils.locationProcess(options, locationsuccess);
  337 + }
  338 +
  339 + /**
  340 + * 地址解析
  341 + *
  342 + * @param {Object} options 接口参数对象
  343 + *
  344 + * 请求参数结构可以参考
  345 + * http://lbs.qq.com/webservice_v1/guide-geocoder.html
  346 + */
  347 + geocoder(options) {
  348 + var that = this;
  349 + options = options || {};
  350 + Utils.polyfillParam(options);
  351 +
  352 + if (Utils.checkParamKeyEmpty(options, 'address')) {
  353 + return;
  354 + }
  355 +
  356 + var requestParam = {
  357 + address: options.address,
  358 + output: 'json',
  359 + key: that.key
  360 + };
  361 +
  362 + wx.request(Utils.buildWxRequestConfig(options, {
  363 + url: URL_GET_GEOCODER,
  364 + data: requestParam
  365 + }));
  366 + }
  367 +
  368 +
  369 + /**
  370 + * 获取城市列表
  371 + *
  372 + * @param {Object} options 接口参数对象
  373 + *
  374 + * 请求参数结构可以参考
  375 + * http://lbs.qq.com/webservice_v1/guide-region.html
  376 + */
  377 + getCityList(options) {
  378 + var that = this;
  379 + options = options || {};
  380 + Utils.polyfillParam(options);
  381 + var requestParam = {
  382 + output: 'json',
  383 + key: that.key
  384 + };
  385 +
  386 + wx.request(Utils.buildWxRequestConfig(options, {
  387 + url: URL_CITY_LIST,
  388 + data: requestParam
  389 + }));
  390 + }
  391 +
  392 + /**
  393 + * 获取对应城市ID的区县列表
  394 + *
  395 + * @param {Object} options 接口参数对象
  396 + *
  397 + * 请求参数结构可以参考
  398 + * http://lbs.qq.com/webservice_v1/guide-region.html
  399 + */
  400 + getDistrictByCityId(options) {
  401 + var that = this;
  402 + options = options || {};
  403 + Utils.polyfillParam(options);
  404 +
  405 + if (Utils.checkParamKeyEmpty(options, 'id')) {
  406 + return;
  407 + }
  408 +
  409 + var requestParam = {
  410 + id: options.id || '',
  411 + output: 'json',
  412 + key: that.key
  413 + };
  414 +
  415 + wx.request(Utils.buildWxRequestConfig(options, {
  416 + url: URL_AREA_LIST,
  417 + data: requestParam
  418 + }));
  419 + }
  420 +
  421 + /**
  422 + * 用于单起点到多终点的路线距离(非直线距离)计算:
  423 + * 支持两种距离计算方式:步行和驾车。
  424 + * 起点到终点最大限制直线距离10公里。
  425 + *
  426 + * @param {Object} options 接口参数对象
  427 + *
  428 + * 请求参数结构可以参考
  429 + * http://lbs.qq.com/webservice_v1/guide-distance.html
  430 + */
  431 + calculateDistance(options) {
  432 + var that = this;
  433 + options = options || {};
  434 + Utils.polyfillParam(options);
  435 +
  436 + if (Utils.checkParamKeyEmpty(options, 'to')) {
  437 + return;
  438 + }
  439 +
  440 + var requestParam = {
  441 + mode: options.mode || 'walking',
  442 + to: Utils.location2query(options.to),
  443 + output: 'json',
  444 + key: that.key
  445 + };
  446 +
  447 + var locationsuccess = function (result) {
  448 + requestParam.from = result.latitude + ',' + result.longitude;
  449 + wx.request(Utils.buildWxRequestConfig(options, {
  450 + url: URL_DISTANCE,
  451 + data: requestParam
  452 + }));
  453 + }
  454 + if (options.from) {
  455 + options.location = options.from;
  456 + }
  457 +
  458 + Utils.locationProcess(options, locationsuccess);
  459 + }
  460 +}
  461 +
  462 +module.exports = QQMapWX;