From 364db319e37b6b0af949cad11dffb32e8f09a465 Mon Sep 17 00:00:00 2001 From: shuiqing Date: Thu, 19 Jul 2018 11:50:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.json | 4 + images/u40.png | Bin 0 -> 342 bytes libs/qqmap-wx-jssdk.js | 462 +++++++++++++++++++++ pages/activity_detail/activity_detail.wxml | 2 +- pages/at_present/at_present.js | 145 +++++-- pages/at_present/at_present.wxml | 21 +- pages/at_present/at_present.wxss | 22 +- pages/city/city.js | 41 ++ pages/city/city.json | 5 + pages/city/city.wxml | 13 + pages/city/city.wxss | 37 ++ pages/district/district.js | 68 +++ pages/district/district.json | 5 + pages/district/district.wxml | 6 + pages/district/district.wxss | 28 ++ pages/index/index.js | 62 ++- pages/index/index.wxml | 14 +- pages/index/index.wxss | 19 +- pages/loding/loding.js | 92 ++++ pages/loding/loding.json | 3 + pages/loding/loding.wxml | 1 + pages/loding/loding.wxss | 0 pages/order/order.wxml | 2 +- 23 files changed, 990 insertions(+), 62 deletions(-) create mode 100644 images/u40.png create mode 100644 libs/qqmap-wx-jssdk.js create mode 100644 pages/city/city.js create mode 100644 pages/city/city.json create mode 100644 pages/city/city.wxml create mode 100644 pages/city/city.wxss create mode 100644 pages/district/district.js create mode 100644 pages/district/district.json create mode 100644 pages/district/district.wxml create mode 100644 pages/district/district.wxss create mode 100644 pages/loding/loding.js create mode 100644 pages/loding/loding.json create mode 100644 pages/loding/loding.wxml create mode 100644 pages/loding/loding.wxss diff --git a/app.json b/app.json index 22cb676..80dacf0 100644 --- a/app.json +++ b/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", diff --git a/images/u40.png b/images/u40.png new file mode 100644 index 0000000000000000000000000000000000000000..f740d3ad011262cd214e52b0e02f6a09ab66e9f5 GIT binary patch literal 342 zcmeAS@N?(olHy`uVBq!ia0vp^AT~b-8<4#FKaLMbF%}28J29*~C-V}>VM%xNb!1@J z*w6hZkrl}2EbxddW?jj*vIORGY2za=-vNClxurw<)F7Z75y)0dGN&Kfx#`$$tiY|@IGSy0B^8-8m zGTP0zZ(=ug7H#GG;eFj@jqiQ6N6JF_DTIOLtIa}xmx4Cb?jO&fJ=Bi)pO-jvg zx9BVWQpPD - {{buttomText}} + {{buttomText}} ¥{{activityDetail.participantPrice / 100}} diff --git a/pages/at_present/at_present.js b/pages/at_present/at_present.js index 41662c3..1248674 100644 --- a/pages/at_present/at_present.js +++ b/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' + }) + }, +}) \ No newline at end of file diff --git a/pages/at_present/at_present.wxml b/pages/at_present/at_present.wxml index 8b94e70..3c07b53 100644 --- a/pages/at_present/at_present.wxml +++ b/pages/at_present/at_present.wxml @@ -1,15 +1,16 @@ 当前定位地址: - {{city}}{{district}} - 此区/县暂未开放,敬请期待 - 手动切换地址 - - - 确定 - 切换 - + + {{city}}{{district}} - - + {{lists}} + 手动切换地址 + + 确定 + 切换 + + + + \ No newline at end of file diff --git a/pages/at_present/at_present.wxss b/pages/at_present/at_present.wxss index c924c30..7d24ae7 100644 --- a/pages/at_present/at_present.wxss +++ b/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; } \ No newline at end of file diff --git a/pages/city/city.js b/pages/city/city.js new file mode 100644 index 0000000..725a22b --- /dev/null +++ b/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, + }) + + }, +}) \ No newline at end of file diff --git a/pages/city/city.json b/pages/city/city.json new file mode 100644 index 0000000..60e5793 --- /dev/null +++ b/pages/city/city.json @@ -0,0 +1,5 @@ +{ + "navigationBarTitleText": "选择城市", + "enablePullDownRefresh": true, + "backgroundColor": "#F7F7F7" +} \ No newline at end of file diff --git a/pages/city/city.wxml b/pages/city/city.wxml new file mode 100644 index 0000000..70760b7 --- /dev/null +++ b/pages/city/city.wxml @@ -0,0 +1,13 @@ + + + +定位区域 {{title}} + + +已开通城市 + + {{citys.cityName}} + + + +其他城市暂未开放,敬请期待 \ No newline at end of file diff --git a/pages/city/city.wxss b/pages/city/city.wxss new file mode 100644 index 0000000..c1e85a9 --- /dev/null +++ b/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; +} \ No newline at end of file diff --git a/pages/district/district.js b/pages/district/district.js new file mode 100644 index 0000000..04ebd26 --- /dev/null +++ b/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' + }) + }, + + +}) \ No newline at end of file diff --git a/pages/district/district.json b/pages/district/district.json new file mode 100644 index 0000000..fd0941d --- /dev/null +++ b/pages/district/district.json @@ -0,0 +1,5 @@ +{ + "navigationBarTitleText": "选择区/县", + "enablePullDownRefresh": true, + "backgroundColor": "#F7F7F7" +} \ No newline at end of file diff --git a/pages/district/district.wxml b/pages/district/district.wxml new file mode 100644 index 0000000..8339f16 --- /dev/null +++ b/pages/district/district.wxml @@ -0,0 +1,6 @@ +已开通区/县 + + + {{districts.districtName}} + +其他区/县暂未开放,敬请期待 \ No newline at end of file diff --git a/pages/district/district.wxss b/pages/district/district.wxss new file mode 100644 index 0000000..905b6d7 --- /dev/null +++ b/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; +} \ No newline at end of file diff --git a/pages/index/index.js b/pages/index/index.js index 67f63c9..efd36b1 100644 --- a/pages/index/index.js +++ b/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 + }) + } + }); }, /** diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 5c33d43..71a599f 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -2,15 +2,13 @@ - - {{addrArray.name[0]}} + {{cityName}} + + - - + + + diff --git a/pages/index/index.wxss b/pages/index/index.wxss index 18cb7cb..30704a1 100644 --- a/pages/index/index.wxss +++ b/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 { diff --git a/pages/loding/loding.js b/pages/loding/loding.js new file mode 100644 index 0000000..2095b98 --- /dev/null +++ b/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', + // }) + // } + // } + // }); + + }, +}) \ No newline at end of file diff --git a/pages/loding/loding.json b/pages/loding/loding.json new file mode 100644 index 0000000..077404a --- /dev/null +++ b/pages/loding/loding.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/pages/loding/loding.wxml b/pages/loding/loding.wxml new file mode 100644 index 0000000..0277891 --- /dev/null +++ b/pages/loding/loding.wxml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/pages/loding/loding.wxss b/pages/loding/loding.wxss new file mode 100644 index 0000000..e69de29 diff --git a/pages/order/order.wxml b/pages/order/order.wxml index 6e67572..f0d59dd 100644 --- a/pages/order/order.wxml +++ b/pages/order/order.wxml @@ -13,7 +13,7 @@ - + 未付款