Browse Source

小程序地址切换

feature/v1.1.0
shuiqing 7 years ago
parent
commit
364db319e3
23 changed files with 990 additions and 62 deletions
  1. 4
      app.json
  2. BIN
      images/u40.png
  3. 462
      libs/qqmap-wx-jssdk.js
  4. 2
      pages/activity_detail/activity_detail.wxml
  5. 145
      pages/at_present/at_present.js
  6. 21
      pages/at_present/at_present.wxml
  7. 22
      pages/at_present/at_present.wxss
  8. 41
      pages/city/city.js
  9. 5
      pages/city/city.json
  10. 13
      pages/city/city.wxml
  11. 37
      pages/city/city.wxss
  12. 68
      pages/district/district.js
  13. 5
      pages/district/district.json
  14. 6
      pages/district/district.wxml
  15. 28
      pages/district/district.wxss
  16. 62
      pages/index/index.js
  17. 14
      pages/index/index.wxml
  18. 19
      pages/index/index.wxss
  19. 92
      pages/loding/loding.js
  20. 3
      pages/loding/loding.json
  21. 1
      pages/loding/loding.wxml
  22. 0
      pages/loding/loding.wxss
  23. 2
      pages/order/order.wxml

4
app.json

@ -1,6 +1,10 @@
{
"pages": [
"pages/loding/loding",
"pages/at_present/at_present",
"pages/city/city",
"pages/district/district",
"pages/index/index",
"pages/mall/mall",
"pages/jz/jz",

BIN
images/u40.png

Before After
Width: 10  |  Height: 15  |  Size: 342 B

462
libs/qqmap-wx-jssdk.js

@ -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;

2
pages/activity_detail/activity_detail.wxml

@ -79,7 +79,7 @@
</scroll-view>
<view class='bottom_view'>
<!-- 我要开团按钮 -->
<view class='one_content' id='one_button' style='display: {{one_content}};background-color:{{bottomBGColor}};' bindtap='groupTap'>{{buttomText}}</view>
<view class='one_content' id='one_button' style='display: {{one_content}};background-color:{{bottomBGColor}};' bindtap='groupTap'>{{buttomText}}</view>
<view class='two_content' id='two_content' style='display: {{two_content}};'>
<!-- 参与拼团的成员---左边价格,右边参与拼团 -->
<view class='left'>¥{{activityDetail.participantPrice / 100}}</view>

145
pages/at_present/at_present.js

@ -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'
})
},
})

21
pages/at_present/at_present.wxml

@ -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>

22
pages/at_present/at_present.wxss

@ -32,13 +32,29 @@ padding-bottom: 30rpx;
}
.choice{
width: 100%;
border-top:1px solid #ccc;
height:100rpx;
line-height:100rpx;
}
.confirm_left{
width: 50%;
display: inline-block;
width:49%;
display:inline-block;
color:#1E90FF;
border-right:1px solid #ccc;
}
.confirm_right{
width: 50%;
display: inline-block;
padding-bottom: 30rpx;
/* padding-bottom: 30rpx; */
color: #1E90FF;
}
.hide {
display: none;
}
.show {
display: block;
}

41
pages/city/city.js

@ -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,
})
},
})

5
pages/city/city.json

@ -0,0 +1,5 @@
{
"navigationBarTitleText": "选择城市",
"enablePullDownRefresh": true,
"backgroundColor": "#F7F7F7"
}

13
pages/city/city.wxml

@ -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>

37
pages/city/city.wxss

@ -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;
}

68
pages/district/district.js

@ -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'
})
},
})

5
pages/district/district.json

@ -0,0 +1,5 @@
{
"navigationBarTitleText": "选择区/县",
"enablePullDownRefresh": true,
"backgroundColor": "#F7F7F7"
}

6
pages/district/district.wxml

@ -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>

28
pages/district/district.wxss

@ -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;
}

62
pages/index/index.js

@ -11,6 +11,7 @@ Page({
interval: 5000,
duration: 1000,
imgUrls: [],
merchantNo:'',
// bannerImage: '/images/activity_banner.png',
menu_list:[
{ name: '拼团', disabled:false, className:'green_button'},
@ -23,11 +24,12 @@ Page({
pageNum: 1,
pageSize: 20,
hasMoreData: true,
img1: '/images/title-icon.png',
cityId: 440100000,
typeNum: 10,
addrArray: { id: [440100000, 430426000], name: ['长沙', '深圳', '上海', '长沙', '武汉', '杭州', '北京'] },
img1: '/images/u40.png',
// cityId: 440100000,
// typeNum: 10,
// addrArray: { id: [440100000, 430426000], name: ['长沙', '深圳', '上海', '长沙', '武汉', '杭州', '北京'] },
addrIndex: 0,
cityName:'',
},
/**
* 城市选择
@ -44,11 +46,38 @@ Page({
*/
onLoad: function (options) {
let that = this;
// //获取本地数据
// // 获取地址
// wx.getStorage({
// key: 'cityName',
// success: function (res) {
// console.log(111111111111111111)
// console.log(res.data)
// that.setData({
// cityName: 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({
url: app.gw.hostUrl + '/mall/wxa/activity/banner',
method: 'get',
data: {
merchantNo: 'SH180331153109966163'
merchantNo: that.merchantNo
},
header: {
'Content-Type': 'application/x-www-form-urlencoded'
@ -88,7 +117,7 @@ Page({
url: app.gw.hostUrl + '/mall/wxa/activity/list',
method: 'get',
data: {
merchantNo: 'SH180331153109966163',
merchantNo: that.merchantNo,
// selectedCityId: that.data.addrArray.id[that.data.addrIndex] == undefined ? 0 : that.data.addrArray.id[that.data.addrIndex],
pageNum: that.data.pageNum,
pageSize: that.data.pageSize
@ -162,7 +191,26 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
let that = this;
//获取本地数据
// 获取地址
wx.getStorage({
key: 'cityName',
success: function (res) {
that.setData({
cityName: res.data
})
}
});
// 商家编号
wx.getStorage({
key: 'merchantNo',
success: function (res) {
that.setData({
merchantNo: res.data
})
}
});
},
/**

14
pages/index/index.wxml

@ -2,15 +2,13 @@
<view class="content">
<view class='header'>
<view class='top-left'>
<!-- <picker class='address' bindchange="bindAddrChange" value="{{addrIndex1}}" range="{{addrArray.name}}">
<view>
<text>{{addrArray.name[addrIndex]}}</text>
</view>
</picker> -->
<text class='address'>{{addrArray.name[0]}}</text>
<navigator url="../city/city" class="address"><image src='{{img1}}' mode='widthFix' class="imgs"></image> {{cityName}}</navigator>
<!-- 地址 -->
<!-- <text class='address'>{{addrArray.name[0]}}</text> -->
</view>
<image class='title_img' src='{{img1}}' mode='widthFix'></image>
<view class='top-right'></view>
<!-- <image class='title_img' src='{{img1}}' mode='widthFix'></image> -->
<!-- 暂时top-right不清楚干嘛的 -->
<!-- <view class='top-right'></view> -->
</view>
<swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
<block wx:for="{{imgUrls}}" wx:key="imgUrl">

19
pages/index/index.wxss

@ -6,25 +6,36 @@
.header {
width: 100%;
background-color: #26ae76;
background-color: #21BE8D;
}
.title_img {
width: 24%;
margin: 10rpx 10%;
display: inline-block;
}
.top-left{
width: 100%;
display: inline-block;
vertical-align: super;
text-align: center;
.top-left, .top-right {
}
.imgs{
width: 20rpx;
margin-right:10rpx;
}
/* .top-right {
width: 28%;
display: inline-block;
vertical-align: super;
}
} */
.address {
font-size: 30rpx;
color: #fff;
margin-left: 44rpx;
/* margin-left: 44rpx; */
}
.middle {

92
pages/loding/loding.js

@ -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',
// })
// }
// }
// });
},
})

3
pages/loding/loding.json

@ -0,0 +1,3 @@
{
}

1
pages/loding/loding.wxml

@ -0,0 +1 @@
<loading hidden="{{hiddenLoading}}" bindtap='groupTaps'>正在加载</loading>

0
pages/loding/loding.wxss

2
pages/order/order.wxml

@ -13,7 +13,7 @@
<!-- <view class='intro'>{{item.intro}}</view> -->
</view>
</view>
<view class='line'></view>
<view class='line'></view>
<view class='go-box' wx:if="{{item.status==0}}">
<text class='status'>未付款</text>
<button class='booking' bindtap='goPay' data-item='{{item}}'>去付款</button>

Loading…
Cancel
Save