23 changed files with 990 additions and 62 deletions
Split View
Diff Options
-
4app.json
-
BINimages/u40.png
-
462libs/qqmap-wx-jssdk.js
-
2pages/activity_detail/activity_detail.wxml
-
145pages/at_present/at_present.js
-
21pages/at_present/at_present.wxml
-
22pages/at_present/at_present.wxss
-
41pages/city/city.js
-
5pages/city/city.json
-
13pages/city/city.wxml
-
37pages/city/city.wxss
-
68pages/district/district.js
-
5pages/district/district.json
-
6pages/district/district.wxml
-
28pages/district/district.wxss
-
62pages/index/index.js
-
14pages/index/index.wxml
-
19pages/index/index.wxss
-
92pages/loding/loding.js
-
3pages/loding/loding.json
-
1pages/loding/loding.wxml
-
0pages/loding/loding.wxss
-
2pages/order/order.wxml
@ -0,0 +1,462 @@ |
|||
/** |
|||
* 微信小程序JavaScriptSDK |
|||
* |
|||
* @version 1.0 |
|||
* @date 2017-01-10 |
|||
* @author jaysonzhou@tencent.com |
|||
*/ |
|||
|
|||
var ERROR_CONF = { |
|||
KEY_ERR: 311, |
|||
KEY_ERR_MSG: 'key格式错误', |
|||
PARAM_ERR: 310, |
|||
PARAM_ERR_MSG: '请求参数信息有误', |
|||
SYSTEM_ERR: 600, |
|||
SYSTEM_ERR_MSG: '系统错误', |
|||
WX_ERR_CODE: 1000, |
|||
WX_OK_CODE: 200 |
|||
}; |
|||
var BASE_URL = 'https://apis.map.qq.com/ws/'; |
|||
var URL_SEARCH = BASE_URL + 'place/v1/search'; |
|||
var URL_SUGGESTION = BASE_URL + 'place/v1/suggestion'; |
|||
var URL_GET_GEOCODER = BASE_URL + 'geocoder/v1/'; |
|||
var URL_CITY_LIST = BASE_URL + 'district/v1/list'; |
|||
var URL_AREA_LIST = BASE_URL + 'district/v1/getchildren'; |
|||
var URL_DISTANCE = BASE_URL + 'distance/v1/'; |
|||
var Utils = { |
|||
/** |
|||
* 得到终点query字符串 |
|||
* @param {Array|String} 检索数据 |
|||
*/ |
|||
location2query(data) { |
|||
if (typeof data == 'string') { |
|||
return data; |
|||
} |
|||
var query = ''; |
|||
for (var i = 0; i < data.length; i++) { |
|||
var d = data[i]; |
|||
if (!!query) { |
|||
query += ';'; |
|||
} |
|||
if (d.location) { |
|||
query = query + d.location.lat + ',' + d.location.lng; |
|||
} |
|||
if (d.latitude && d.longitude) { |
|||
query = query + d.latitude + ',' + d.longitude; |
|||
} |
|||
} |
|||
return query; |
|||
}, |
|||
|
|||
/** |
|||
* 使用微信接口进行定位 |
|||
*/ |
|||
getWXLocation(success, fail, complete) { |
|||
wx.getLocation({ |
|||
type: 'gcj02', |
|||
success: success, |
|||
fail: fail, |
|||
complete: complete |
|||
}); |
|||
}, |
|||
|
|||
/** |
|||
* 获取location参数 |
|||
*/ |
|||
getLocationParam(location) { |
|||
if (typeof location == 'string') { |
|||
var locationArr = location.split(','); |
|||
if (locationArr.length === 2) { |
|||
location = { |
|||
latitude: location.split(',')[0], |
|||
longitude: location.split(',')[1] |
|||
}; |
|||
} else { |
|||
location = {}; |
|||
} |
|||
} |
|||
return location; |
|||
}, |
|||
|
|||
/** |
|||
* 回调函数默认处理 |
|||
*/ |
|||
polyfillParam(param) { |
|||
param.success = param.success || function () { }; |
|||
param.fail = param.fail || function () { }; |
|||
param.complete = param.complete || function () { }; |
|||
}, |
|||
|
|||
/** |
|||
* 验证param对应的key值是否为空 |
|||
* |
|||
* @param {Object} param 接口参数 |
|||
* @param {String} key 对应参数的key |
|||
*/ |
|||
checkParamKeyEmpty(param, key) { |
|||
if (!param[key]) { |
|||
var errconf = this.buildErrorConfig(ERROR_CONF.PARAM_ERR, ERROR_CONF.PARAM_ERR_MSG + key +'参数格式有误'); |
|||
param.fail(errconf); |
|||
param.complete(errconf); |
|||
return true; |
|||
} |
|||
return false; |
|||
}, |
|||
|
|||
/** |
|||
* 验证参数中是否存在检索词keyword |
|||
* |
|||
* @param {Object} param 接口参数 |
|||
*/ |
|||
checkKeyword(param){ |
|||
return !this.checkParamKeyEmpty(param, 'keyword'); |
|||
}, |
|||
|
|||
/** |
|||
* 验证location值 |
|||
* |
|||
* @param {Object} param 接口参数 |
|||
*/ |
|||
checkLocation(param) { |
|||
var location = this.getLocationParam(param.location); |
|||
if (!location || !location.latitude || !location.longitude) { |
|||
var errconf = this.buildErrorConfig(ERROR_CONF.PARAM_ERR, ERROR_CONF.PARAM_ERR_MSG + ' location参数格式有误') |
|||
param.fail(errconf); |
|||
param.complete(errconf); |
|||
return false; |
|||
} |
|||
return true; |
|||
}, |
|||
|
|||
/** |
|||
* 构造错误数据结构 |
|||
* @param {Number} errCode 错误码 |
|||
* @param {Number} errMsg 错误描述 |
|||
*/ |
|||
buildErrorConfig(errCode, errMsg) { |
|||
return { |
|||
status: errCode, |
|||
message: errMsg |
|||
}; |
|||
}, |
|||
|
|||
/** |
|||
* 构造微信请求参数,公共属性处理 |
|||
* |
|||
* @param {Object} param 接口参数 |
|||
* @param {Object} param 配置项 |
|||
*/ |
|||
buildWxRequestConfig(param, options) { |
|||
var that = this; |
|||
options.header = { "content-type": "application/json" }; |
|||
options.method = 'GET'; |
|||
options.success = function (res) { |
|||
var data = res.data; |
|||
if (data.status === 0) { |
|||
param.success(data); |
|||
} else { |
|||
param.fail(data); |
|||
} |
|||
}; |
|||
options.fail = function (res) { |
|||
res.statusCode = ERROR_CONF.WX_ERR_CODE; |
|||
param.fail(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, result.errMsg)); |
|||
}; |
|||
options.complete = function (res) { |
|||
var statusCode = +res.statusCode; |
|||
switch(statusCode) { |
|||
case ERROR_CONF.WX_ERR_CODE: { |
|||
param.complete(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg)); |
|||
break; |
|||
} |
|||
case ERROR_CONF.WX_OK_CODE: { |
|||
var data = res.data; |
|||
if (data.status === 0) { |
|||
param.complete(data); |
|||
} else { |
|||
param.complete(that.buildErrorConfig(data.status, data.message)); |
|||
} |
|||
break; |
|||
} |
|||
default:{ |
|||
param.complete(that.buildErrorConfig(ERROR_CONF.SYSTEM_ERR, ERROR_CONF.SYSTEM_ERR_MSG)); |
|||
} |
|||
|
|||
} |
|||
} |
|||
return options; |
|||
}, |
|||
|
|||
/** |
|||
* 处理用户参数是否传入坐标进行不同的处理 |
|||
*/ |
|||
locationProcess(param, locationsuccess, locationfail, locationcomplete) { |
|||
var that = this; |
|||
locationfail = locationfail || function (res) { |
|||
res.statusCode = ERROR_CONF.WX_ERR_CODE; |
|||
param.fail(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg)); |
|||
}; |
|||
locationcomplete = locationcomplete || function (res) { |
|||
if (res.statusCode == ERROR_CONF.WX_ERR_CODE) { |
|||
param.complete(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg)); |
|||
} |
|||
}; |
|||
if (!param.location) { |
|||
that.getWXLocation(locationsuccess, locationfail, locationcomplete); |
|||
} else if (that.checkLocation(param)) { |
|||
var location = Utils.getLocationParam(param.location); |
|||
locationsuccess(location); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
class QQMapWX { |
|||
|
|||
/** |
|||
* 构造函数 |
|||
* |
|||
* @param {Object} options 接口参数,key 为必选参数 |
|||
*/ |
|||
constructor(options) { |
|||
if (!options.key) { |
|||
throw Error('key值不能为空'); |
|||
} |
|||
this.key = options.key; |
|||
} |
|||
|
|||
/** |
|||
* POI周边检索 |
|||
* |
|||
* @param {Object} options 接口参数对象 |
|||
* |
|||
* 参数对象结构可以参考 |
|||
* @see http://lbs.qq.com/webservice_v1/guide-search.html
|
|||
*/ |
|||
search(options) { |
|||
var that = this; |
|||
options = options || {}; |
|||
|
|||
Utils.polyfillParam(options); |
|||
|
|||
if (!Utils.checkKeyword(options)) { |
|||
return; |
|||
} |
|||
|
|||
var requestParam = { |
|||
keyword: options.keyword, |
|||
orderby: options.orderby || '_distance', |
|||
page_size: options.page_size || 10, |
|||
page_index: options.page_index || 1, |
|||
output: 'json', |
|||
key: that.key |
|||
}; |
|||
|
|||
if (options.address_format) { |
|||
requestParam.address_format = options.address_format; |
|||
} |
|||
|
|||
if (options.filter) { |
|||
requestParam.filter = options.filter; |
|||
} |
|||
|
|||
var distance = options.distance || "1000"; |
|||
var auto_extend = options.auto_extend || 1; |
|||
|
|||
var locationsuccess = function (result) { |
|||
requestParam.boundary = "nearby(" + result.latitude + "," + result.longitude + "," + distance + "," + auto_extend +")"; |
|||
wx.request(Utils.buildWxRequestConfig(options, { |
|||
url: URL_SEARCH, |
|||
data: requestParam |
|||
})); |
|||
} |
|||
Utils.locationProcess(options, locationsuccess); |
|||
} |
|||
|
|||
/** |
|||
* sug模糊检索 |
|||
* |
|||
* @param {Object} options 接口参数对象 |
|||
* |
|||
* 参数对象结构可以参考 |
|||
* http://lbs.qq.com/webservice_v1/guide-suggestion.html
|
|||
*/ |
|||
getSuggestion(options) { |
|||
var that = this; |
|||
options = options || {}; |
|||
Utils.polyfillParam(options); |
|||
|
|||
if (!Utils.checkKeyword(options)) { |
|||
return; |
|||
} |
|||
|
|||
var requestParam = { |
|||
keyword: options.keyword, |
|||
region: options.region || '全国', |
|||
region_fix: options.region_fix || 0, |
|||
policy: options.policy || 0, |
|||
output: 'json', |
|||
key: that.key |
|||
}; |
|||
wx.request(Utils.buildWxRequestConfig(options, { |
|||
url: URL_SUGGESTION, |
|||
data: requestParam |
|||
})); |
|||
} |
|||
|
|||
/** |
|||
* 逆地址解析 |
|||
* |
|||
* @param {Object} options 接口参数对象 |
|||
* |
|||
* 请求参数结构可以参考 |
|||
* http://lbs.qq.com/webservice_v1/guide-gcoder.html
|
|||
*/ |
|||
reverseGeocoder(options) { |
|||
var that = this; |
|||
options = options || {}; |
|||
Utils.polyfillParam(options); |
|||
var requestParam = { |
|||
coord_type: options.coord_type || 5, |
|||
get_poi: options.get_poi || 0, |
|||
output: 'json', |
|||
key: that.key |
|||
}; |
|||
if (options.poi_options) { |
|||
requestParam.poi_options = options.poi_options |
|||
} |
|||
|
|||
var locationsuccess = function (result) { |
|||
requestParam.location = result.latitude + ',' + result.longitude; |
|||
wx.request(Utils.buildWxRequestConfig(options, { |
|||
url: URL_GET_GEOCODER, |
|||
data: requestParam |
|||
})); |
|||
}; |
|||
Utils.locationProcess(options, locationsuccess); |
|||
} |
|||
|
|||
/** |
|||
* 地址解析 |
|||
* |
|||
* @param {Object} options 接口参数对象 |
|||
* |
|||
* 请求参数结构可以参考 |
|||
* http://lbs.qq.com/webservice_v1/guide-geocoder.html
|
|||
*/ |
|||
geocoder(options) { |
|||
var that = this; |
|||
options = options || {}; |
|||
Utils.polyfillParam(options); |
|||
|
|||
if (Utils.checkParamKeyEmpty(options, 'address')) { |
|||
return; |
|||
} |
|||
|
|||
var requestParam = { |
|||
address: options.address, |
|||
output: 'json', |
|||
key: that.key |
|||
}; |
|||
|
|||
wx.request(Utils.buildWxRequestConfig(options, { |
|||
url: URL_GET_GEOCODER, |
|||
data: requestParam |
|||
})); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 获取城市列表 |
|||
* |
|||
* @param {Object} options 接口参数对象 |
|||
* |
|||
* 请求参数结构可以参考 |
|||
* http://lbs.qq.com/webservice_v1/guide-region.html
|
|||
*/ |
|||
getCityList(options) { |
|||
var that = this; |
|||
options = options || {}; |
|||
Utils.polyfillParam(options); |
|||
var requestParam = { |
|||
output: 'json', |
|||
key: that.key |
|||
}; |
|||
|
|||
wx.request(Utils.buildWxRequestConfig(options, { |
|||
url: URL_CITY_LIST, |
|||
data: requestParam |
|||
})); |
|||
} |
|||
|
|||
/** |
|||
* 获取对应城市ID的区县列表 |
|||
* |
|||
* @param {Object} options 接口参数对象 |
|||
* |
|||
* 请求参数结构可以参考 |
|||
* http://lbs.qq.com/webservice_v1/guide-region.html
|
|||
*/ |
|||
getDistrictByCityId(options) { |
|||
var that = this; |
|||
options = options || {}; |
|||
Utils.polyfillParam(options); |
|||
|
|||
if (Utils.checkParamKeyEmpty(options, 'id')) { |
|||
return; |
|||
} |
|||
|
|||
var requestParam = { |
|||
id: options.id || '', |
|||
output: 'json', |
|||
key: that.key |
|||
}; |
|||
|
|||
wx.request(Utils.buildWxRequestConfig(options, { |
|||
url: URL_AREA_LIST, |
|||
data: requestParam |
|||
})); |
|||
} |
|||
|
|||
/** |
|||
* 用于单起点到多终点的路线距离(非直线距离)计算: |
|||
* 支持两种距离计算方式:步行和驾车。 |
|||
* 起点到终点最大限制直线距离10公里。 |
|||
* |
|||
* @param {Object} options 接口参数对象 |
|||
* |
|||
* 请求参数结构可以参考 |
|||
* http://lbs.qq.com/webservice_v1/guide-distance.html
|
|||
*/ |
|||
calculateDistance(options) { |
|||
var that = this; |
|||
options = options || {}; |
|||
Utils.polyfillParam(options); |
|||
|
|||
if (Utils.checkParamKeyEmpty(options, 'to')) { |
|||
return; |
|||
} |
|||
|
|||
var requestParam = { |
|||
mode: options.mode || 'walking', |
|||
to: Utils.location2query(options.to), |
|||
output: 'json', |
|||
key: that.key |
|||
}; |
|||
|
|||
var locationsuccess = function (result) { |
|||
requestParam.from = result.latitude + ',' + result.longitude; |
|||
wx.request(Utils.buildWxRequestConfig(options, { |
|||
url: URL_DISTANCE, |
|||
data: requestParam |
|||
})); |
|||
} |
|||
if (options.from) { |
|||
options.location = options.from; |
|||
} |
|||
|
|||
Utils.locationProcess(options, locationsuccess); |
|||
} |
|||
} |
|||
|
|||
module.exports = QQMapWX; |
|||
@ -1,42 +1,131 @@ |
|||
// pages/demo/demo.js
|
|||
//获取应用实例
|
|||
const app = getApp() |
|||
var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); |
|||
var util = require("../../utils/util.js"); |
|||
var qqmapsdk; |
|||
var city; |
|||
var district; |
|||
// var cityId;
|
|||
// var districtId;
|
|||
// var merchantNo
|
|||
/** |
|||
* 页面的初始数据 |
|||
*/ |
|||
Page({ |
|||
/** |
|||
* 页面的初始数据 |
|||
*/ |
|||
data: {}, |
|||
// 引入腾讯地图文件js
|
|||
// var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'),
|
|||
// var qqmapsdk
|
|||
data: { |
|||
resData: [], |
|||
showOrHidden: false, |
|||
|
|||
}, |
|||
onLoad: function (options) { |
|||
this.getLocation(); |
|||
let that = this; |
|||
qqmapsdk = new QQMapWX({ |
|||
key: 'C5KBZ-RISKD-INW4P-PWYQJ-QC6C7-BQBGC' |
|||
}); |
|||
// wx.getStorage({
|
|||
// key: 'merchantNo',
|
|||
// success: function (res) {
|
|||
// console.log(res.data)
|
|||
// if (res.data == '') {
|
|||
// console.log(1111);
|
|||
// } else {
|
|||
// console.log(6666);
|
|||
// wx.switchTab({
|
|||
// url: '../index/index'
|
|||
// })
|
|||
// }
|
|||
// that.setData({
|
|||
// merchantNo: res.data
|
|||
// })
|
|||
// console.log(222);
|
|||
// // that.setData({ userName: res.data });
|
|||
// }
|
|||
// });
|
|||
}, |
|||
getLocation() { |
|||
onReady: function () { |
|||
var that = this; |
|||
wx.getLocation({ |
|||
type: "wgs84", |
|||
type: 'wgs84', |
|||
success: function (res) { |
|||
var locationString = res.latitude + "," + res.longitude; |
|||
wx.request({ |
|||
url: "https://apis.map.qq.com/ws/geocoder/v1/", |
|||
data: { |
|||
key: "C5KBZ-RISKD-INW4P-PWYQJ-QC6C7-BQBGC", |
|||
location: locationString |
|||
}, |
|||
method: "GET", |
|||
qqmapsdk.reverseGeocoder({ |
|||
success: function (res) { |
|||
console.log("用户位置信息", res.data, that); |
|||
var district = res.data.result.ad_info.district; |
|||
var city = res.data.result.ad_info.city |
|||
console.log(city); |
|||
console.log(district); |
|||
let district = res.result.address_component.district; |
|||
let city = res.result.address_component.city; |
|||
that.setData({ |
|||
city, |
|||
district |
|||
}); |
|||
wx.request({ |
|||
url: app.gw.hostUrl + '/mall/wxa/index/OpenCity', |
|||
method: 'PUT', |
|||
data: { |
|||
cityName: city, |
|||
districtName:district |
|||
}, |
|||
header: { |
|||
'Content-Type': 'application/x-www-form-urlencoded' |
|||
}, |
|||
success: function (res) { |
|||
// 打印对应想得到的数据
|
|||
console.log(res) |
|||
var cityId = res.data.response[0].cityId; |
|||
var cityName = res.data.response[0].cityName; |
|||
var districtId = res.data.response[0].districtId; |
|||
var districtName = res.data.response[0].districtName; |
|||
var merchantNo = res.data.response[0].merchantNo; |
|||
var lists = res.data.msg |
|||
that.setData({ |
|||
lists |
|||
}); |
|||
wx.setStorage({ |
|||
key: 'cityId', |
|||
data: cityId, |
|||
}); |
|||
wx.setStorage({ |
|||
key: 'cityName', |
|||
data:cityName, |
|||
}); |
|||
wx.setStorage({ |
|||
key: 'districtId', |
|||
data:districtId, |
|||
}); |
|||
wx.setStorage({ |
|||
key: 'districtName', |
|||
data:districtName, |
|||
}); |
|||
wx.setStorage({ |
|||
key: 'merchantNo', |
|||
data: merchantNo, |
|||
}); |
|||
} |
|||
}); |
|||
} |
|||
}); |
|||
} |
|||
}); |
|||
} |
|||
}); |
|||
|
|||
}) |
|||
}, |
|||
groupTaps: function (e) { |
|||
var that = this; |
|||
//获取本地数据
|
|||
// wx.getStorage({
|
|||
// key: 'merchantNo',
|
|||
// success: function (res) {
|
|||
// if (res.data ==''){
|
|||
// console.log(1111);
|
|||
// }else{
|
|||
// console.log(888);
|
|||
// }
|
|||
// // console.log(1111);
|
|||
// // console.log(res.data);
|
|||
// // that.setData({ merchantNo: res.data });
|
|||
|
|||
// // console.log(2222);
|
|||
// // showOrhide:false;
|
|||
|
|||
// }
|
|||
// });
|
|||
wx.switchTab({ |
|||
// url: '../index/index'
|
|||
}) |
|||
}, |
|||
}) |
|||
@ -1,15 +1,16 @@ |
|||
<view class="base"> |
|||
<view class="base_center"> |
|||
<view class="base_top">当前定位地址:</view> |
|||
<view class="base_district"><text>{{city}}{{district}}</text></view> |
|||
<view class="base_hint">此区/县暂未开放,敬请期待</view> |
|||
<view class="choice_switchover">手动切换地址</view> |
|||
<view class="confirm"> |
|||
<view class="choice"> |
|||
<text class="confirm_left">确定</text> |
|||
<text class="confirm_right">切换</text> |
|||
</view> |
|||
<view class="base_district"> |
|||
<text>{{city}}{{district}}</text> |
|||
</view> |
|||
</view> |
|||
|
|||
<view class="base_hint">{{lists}}</view> |
|||
<navigator url="../city/city?title={{city}}{{district}}" class="choice_switchover {{showOrHidden?'show':'hide'}}">手动切换地址</navigator> |
|||
<view class="choice"> |
|||
<text class="confirm_left" bindtap='groupTaps'>确定</text> |
|||
<navigator url="../city/city?title={{city}}{{district}}" class="confirm_right">切换</navigator> |
|||
<!-- <text class="confirm_right" url="../city/city?title={{city}}{{district}}">切换</text> --> |
|||
</view> |
|||
<!-- </view> --> |
|||
</view> |
|||
</view> |
|||
@ -0,0 +1,41 @@ |
|||
|
|||
//获取应用实例
|
|||
const app = getApp() |
|||
Page({ |
|||
onLoad: function (options) { |
|||
// this.setData({
|
|||
// title: options.title
|
|||
// });
|
|||
var that = this |
|||
wx.request({ |
|||
url: app.gw.hostUrl + '/mall/wxa/index/opencitylist', |
|||
data: { cityName: 'cityName' }, |
|||
method: 'GET', |
|||
header: { |
|||
'Content-Type': 'application/x-www-form-urlencoded' |
|||
}, |
|||
success: function (res) { |
|||
console.log(res.data) |
|||
var citys = res.data; |
|||
console.log(citys); |
|||
that.setData({ |
|||
citys |
|||
}); |
|||
}, |
|||
fail: function () { |
|||
// fail
|
|||
}, |
|||
}) |
|||
}, |
|||
openGroup: function (e) { |
|||
// console.log(e.currentTarget.dataset.item)
|
|||
wx.setStorage({ |
|||
key: 'cityId', |
|||
data: e.currentTarget.dataset.item, |
|||
}); |
|||
wx.navigateTo({ |
|||
url: '../district/district?cityId=' + e.currentTarget.dataset.item, |
|||
}) |
|||
|
|||
}, |
|||
}) |
|||
@ -0,0 +1,5 @@ |
|||
{ |
|||
"navigationBarTitleText": "选择城市", |
|||
"enablePullDownRefresh": true, |
|||
"backgroundColor": "#F7F7F7" |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
<!-- <view style="text-align:center"><text class="top_area">定位区域</text> {{title}} </view> --> |
|||
|
|||
<view class="top"> |
|||
<text class="top_area">定位区域</text><text class="top_site"> {{title}}</text> |
|||
<!-- <text class="top_area">定位区域</text><text class="top_site" id="1">未获取定位</text> --> |
|||
</view> |
|||
<view class="top_hint">已开通城市</view> |
|||
<view wx:for="{{citys.response}}" wx:for-item="citys"> |
|||
<view class="top_city" bindtap='openGroup' data-item='{{citys.cityId}}'>{{citys.cityName}}</view> |
|||
|
|||
</view> |
|||
<!-- <navigator url="../district/district" class="top_city" wx:for="{{citys.response}}" wx:for-item="citys">{{citys.cityName}}</navigator> --> |
|||
<view class="presenting">其他城市暂未开放,敬请期待</view> |
|||
@ -0,0 +1,37 @@ |
|||
.top{ |
|||
background-color: #ccc; |
|||
height: 100rpx; |
|||
width: 100%; |
|||
margin-top: 20rpx; |
|||
line-height:100rpx; |
|||
|
|||
} |
|||
.top_area{ |
|||
margin-left: 30rpx; |
|||
margin-right: 70rpx; |
|||
color:#666; |
|||
|
|||
} |
|||
.top_site{ |
|||
text-align: center; |
|||
color: #1E90FF; |
|||
} |
|||
.top_hint{ |
|||
color: #666; |
|||
padding-left:30rpx; |
|||
height: 100rpx; |
|||
line-height: 100rpx; |
|||
border-bottom:1px solid #DEDEDE; |
|||
} |
|||
.top_city{ |
|||
height: 80rpx; |
|||
line-height: 80rpx; |
|||
border-bottom:1px solid #DEDEDE; |
|||
padding-left:100rpx; |
|||
} |
|||
.presenting{ |
|||
font-size: 30rpx; |
|||
height: 180rpx; |
|||
line-height: 180rpx; |
|||
text-align: center; |
|||
} |
|||
@ -0,0 +1,68 @@ |
|||
//获取应用实例
|
|||
const app = getApp() |
|||
var cityId |
|||
Page({ |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面加载 |
|||
*/ |
|||
onLoad: function (options) { |
|||
|
|||
cityId = options.cityId; |
|||
|
|||
// console.log(cityId);
|
|||
// let str = e.currentTarget.dataset.item;
|
|||
let that = this; |
|||
console.log(cityId); |
|||
wx.request({ |
|||
url: app.gw.hostUrl + '/mall/wxa/index/opendistictlist', |
|||
method: 'get', |
|||
data: { |
|||
cityId: cityId, |
|||
}, |
|||
header: { |
|||
'Content-Type': 'application/x-www-form-urlencoded' |
|||
}, |
|||
success: function (res) { |
|||
|
|||
var districts = res.data; |
|||
console.log(districts) |
|||
that.setData({ |
|||
districts |
|||
}); |
|||
}, |
|||
fail: function (res) { |
|||
wx.showToast({ |
|||
title: '加载数据失败', |
|||
}); |
|||
}, |
|||
}) |
|||
}, |
|||
openGroup: function (e) { |
|||
wx.setStorage({ |
|||
key: 'cityId', |
|||
data: e.currentTarget.dataset.item.cityId, |
|||
}); |
|||
wx.setStorage({ |
|||
key: 'cityName', |
|||
data: e.currentTarget.dataset.item.cityName, |
|||
}); |
|||
wx.setStorage({ |
|||
key: 'districtId', |
|||
data: e.currentTarget.dataset.item.districtId, |
|||
}); |
|||
wx.setStorage({ |
|||
key: 'districtName', |
|||
data: e.currentTarget.dataset.item.districtName, |
|||
}); |
|||
wx.setStorage({ |
|||
key: 'merchantNo', |
|||
data: e.currentTarget.dataset.item.merchantNo, |
|||
}); |
|||
wx.switchTab({ |
|||
url: '../index/index' |
|||
}) |
|||
}, |
|||
|
|||
|
|||
}) |
|||
@ -0,0 +1,5 @@ |
|||
{ |
|||
"navigationBarTitleText": "选择区/县", |
|||
"enablePullDownRefresh": true, |
|||
"backgroundColor": "#F7F7F7" |
|||
} |
|||
@ -0,0 +1,6 @@ |
|||
<view class="top_hint">已开通区/县</view> |
|||
<view wx:for="{{districts.response}}" wx:for-item="districts"> |
|||
<!-- data-item='{{districts.cityName}}所需要储存到其他页面的key值() --> |
|||
<view class="top_city" bindtap='openGroup' data-item='{{districts}}'>{{districts.districtName}}</view> |
|||
</view> |
|||
<view class="presenting">其他区/县暂未开放,敬请期待</view> |
|||
@ -0,0 +1,28 @@ |
|||
.top{ |
|||
background-color: #ccc; |
|||
height: 100rpx; |
|||
width: 100%; |
|||
margin-top: 20rpx; |
|||
line-height:100rpx; |
|||
|
|||
} |
|||
|
|||
.top_hint{ |
|||
color: #666; |
|||
padding-left:30rpx; |
|||
height: 100rpx; |
|||
line-height: 100rpx; |
|||
border-bottom:1px solid #DEDEDE; |
|||
} |
|||
.top_city{ |
|||
height: 80rpx; |
|||
line-height: 80rpx; |
|||
border-bottom:1px solid #DEDEDE; |
|||
padding-left:100rpx; |
|||
} |
|||
.presenting{ |
|||
font-size: 30rpx; |
|||
height: 180rpx; |
|||
line-height: 180rpx; |
|||
text-align: center; |
|||
} |
|||
@ -0,0 +1,92 @@ |
|||
// pages/demo/demo.js
|
|||
var QQMapWX = require('../../libs/qqmap-wx-jssdk.js'); |
|||
|
|||
var util = require("../../utils/util.js"); |
|||
|
|||
var qqmapsdk; |
|||
/** |
|||
* 页面的初始数据 |
|||
*/ |
|||
Page({ |
|||
data: { |
|||
hiddenLoading: false, |
|||
resData: [] |
|||
}, |
|||
onLoad: function (options) { // 实例化腾讯地图API核心类
|
|||
let that = this; |
|||
qqmapsdk = new QQMapWX({ |
|||
key: 'C5KBZ-RISKD-INW4P-PWYQJ-QC6C7-BQBGC' |
|||
}); |
|||
wx.getStorage({ |
|||
key: 'merchantNo', |
|||
success: function (res) { |
|||
console.log(res.data) |
|||
if (res.data == '') { |
|||
console.log(1111); |
|||
// 页面渲染完成
|
|||
var tt = this; |
|||
setTimeout(function () { |
|||
tt.setData({ |
|||
hiddenLoading: true |
|||
}); |
|||
tt.update(); |
|||
}, 2000); |
|||
wx.getSetting({ |
|||
success: function (res) { |
|||
if (res.authSetting['scope.userInfo']) { |
|||
//授权了
|
|||
wx.navigateTo({ |
|||
url: '../at_present/at_present', |
|||
}) |
|||
} else { |
|||
//未授权
|
|||
wx.navigateTo({ |
|||
url: '../city/city/?1', |
|||
}) |
|||
} |
|||
} |
|||
}); |
|||
|
|||
} else { |
|||
console.log(6666); |
|||
wx.switchTab({ |
|||
url: '../index/index' |
|||
}) |
|||
} |
|||
that.setData({ |
|||
merchantNo: res.data |
|||
}) |
|||
console.log(222); |
|||
// that.setData({ userName: res.data });
|
|||
} |
|||
}); |
|||
|
|||
}, |
|||
|
|||
onReady: function () { |
|||
// // 页面渲染完成
|
|||
// var tt = this;
|
|||
// setTimeout(function () {
|
|||
// tt.setData({
|
|||
// hiddenLoading: true
|
|||
// });
|
|||
// tt.update();
|
|||
// }, 2000);
|
|||
// wx.getSetting({
|
|||
// success: function (res) {
|
|||
// if (res.authSetting['scope.userInfo']) {
|
|||
// //授权了
|
|||
// wx.navigateTo({
|
|||
// url: '../at_present/at_present',
|
|||
// })
|
|||
// } else {
|
|||
// //未授权
|
|||
// wx.navigateTo({
|
|||
// url: '../city/city/?1',
|
|||
// })
|
|||
// }
|
|||
// }
|
|||
// });
|
|||
|
|||
}, |
|||
}) |
|||
@ -0,0 +1,3 @@ |
|||
{ |
|||
|
|||
} |
|||
@ -0,0 +1 @@ |
|||
<loading hidden="{{hiddenLoading}}" bindtap='groupTaps'>正在加载</loading> |
|||
Write
Preview
Loading…
Cancel
Save