You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
3.2 KiB
121 lines
3.2 KiB
//获取应用实例
|
|
const app = getApp()
|
|
var QQMapWX = require('../../libs/qqmap-wx-jssdk.js');
|
|
var util = require("../../utils/util.js");
|
|
var qqmapsdk;
|
|
// var city;
|
|
// var district;
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
Page({
|
|
data: {
|
|
resData: [],
|
|
showOrHidden: false,
|
|
showorHide: false,
|
|
city: '',
|
|
district: '',
|
|
cityId: '',
|
|
districtId: '',
|
|
merchantNo: '',
|
|
},
|
|
onLoad: function(options) {
|
|
let that = this;
|
|
qqmapsdk = new QQMapWX({
|
|
key: 'C5KBZ-RISKD-INW4P-PWYQJ-QC6C7-BQBGC'
|
|
});
|
|
},
|
|
onReady: function() {
|
|
var that = this;
|
|
wx.getLocation({
|
|
type: 'wgs84',
|
|
success: function(res) {
|
|
qqmapsdk.reverseGeocoder({
|
|
success: function(res) {
|
|
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,
|
|
});
|
|
}
|
|
});
|
|
},
|
|
fail: function(res) {
|
|
showorHide: false,
|
|
wx.showToast({
|
|
title: '加载数据失败',
|
|
});
|
|
},
|
|
});
|
|
}
|
|
})
|
|
},
|
|
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'
|
|
})
|
|
},
|
|
})
|