Browse Source

修改地图

feature/v1.1.0
shuiqing 7 years ago
parent
commit
c4be9d9d44
5 changed files with 51 additions and 82 deletions
  1. 88
      pages/at_present/at_present.js
  2. 5
      pages/at_present/at_present.wxml
  3. 4
      pages/city/city.wxml
  4. 10
      pages/index/index.js
  5. 26
      pages/loding/loding.js

88
pages/at_present/at_present.js

@ -3,11 +3,9 @@ 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
// var city;
// var district;
/**
* 页面的初始数据
*/
@ -15,42 +13,28 @@ Page({
data: {
resData: [],
showOrHidden: false,
showorHide: false,
city: '',
district: '',
cityId: '',
districtId: '',
merchantNo: '',
},
onLoad: function (options) {
onLoad: function(options) {
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 });
// }
// });
key: 'C5KBZ-RISKD-INW4P-PWYQJ-QC6C7-BQBGC'
});
},
onReady: function () {
onReady: function() {
var that = this;
wx.getLocation({
type: 'wgs84',
success: function (res) {
success: function(res) {
qqmapsdk.reverseGeocoder({
success: function (res) {
let district = res.result.address_component.district;
let city = res.result.address_component.city;
success: function(res) {
let district = res.result.address_component.district;
let city = res.result.address_component.city;
that.setData({
city,
district
@ -60,19 +44,19 @@ Page({
method: 'PUT',
data: {
cityName: city,
districtName:district
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;
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
@ -83,15 +67,15 @@ Page({
});
wx.setStorage({
key: 'cityName',
data:cityName,
data: cityName,
});
wx.setStorage({
key: 'districtId',
data:districtId,
data: districtId,
});
wx.setStorage({
key: 'districtName',
data:districtName,
data: districtName,
});
wx.setStorage({
key: 'merchantNo',
@ -99,12 +83,18 @@ Page({
});
}
});
}
},
fail: function(res) {
showorHide: false,
wx.showToast({
title: '加载数据失败',
});
},
});
}
})
},
groupTaps: function (e) {
groupTaps: function(e) {
var that = this;
//获取本地数据
// wx.getStorage({
@ -118,10 +108,10 @@ Page({
// // console.log(1111);
// // console.log(res.data);
// // that.setData({ merchantNo: res.data });
// // console.log(2222);
// // showOrhide:false;
// }
// });
wx.switchTab({

5
pages/at_present/at_present.wxml

@ -4,13 +4,12 @@
<view class="base_district">
<text>{{city}}{{district}}</text>
</view>
<view class="base_hint">{{lists}}</view>
<!-- {{showorHide?'show':'hide'}} -->
<view class="base_hint {{showorHide?'show':'hide'}}">{{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>

4
pages/city/city.wxml

@ -1,13 +1,9 @@
<!-- <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>

10
pages/index/index.js

@ -51,26 +51,18 @@ Page({
wx.getStorage({
key: 'districtName',
success: function (res) {
console.log(111111111111111111)
console.log(res.data)
that.setData({
districtName: res.data
})
console.log(222222222222222222)
// that.setData({ userName: res.data });
}
});
// 商家编号
wx.getStorage({
key: 'merchantNo',
success: function (res) {
console.log(6666666666666666666666)
console.log(res.data)
that.setData({
merchantNo: res.data
})
console.log(888888888888888888888888)
}
});
wx.request({
@ -88,7 +80,7 @@ Page({
if (status == 0) {
var data = res.data;
var status = data.code;
console.log(res);
// console.log(res);
that.setData({
imgUrls: data.response
})

26
pages/loding/loding.js

@ -16,15 +16,15 @@ Page({
let that = this;
qqmapsdk = new QQMapWX({
key: 'C5KBZ-RISKD-INW4P-PWYQJ-QC6C7-BQBGC'
//正式版 key: ' JN7BZ-MJBK5-52SIH-QOKGH-FJE5F-IWFGG'
});
wx.getStorage({
key: 'merchantNo',
success: function (res) {
console.log(res.data)
if (res.data == '') {
that.queryCartList();
} else {
console.log(6666);
wx.switchTab({
url: '../index/index'
})
@ -32,20 +32,14 @@ Page({
that.setData({
merchantNo: res.data
})
console.log(222);
// that.setData({ userName: res.data });
},
fail: function (res) {
console.log(res)
that.queryCartList();
}
});
},
onReady: function () {
// 页面渲染完成
var tt = this;
setTimeout(function () {
tt.setData({
hiddenLoading: true
});
tt.update();
}, 2000);
queryCartList: function () {
wx.getSetting({
success: function (res) {
if (res.authSetting['scope.userInfo']) {
@ -56,12 +50,10 @@ Page({
} else {
//未授权
wx.switchTab({
url: '../city/city/',
url: '../city/city',
})
}
}
});
}
})
// });
})
Loading…
Cancel
Save