From 93e195f0a53142abefe5a9aed1b131239f2c7b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=81=B0=E7=81=B0?= Date: Mon, 31 Oct 2022 22:00:43 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=B0=83=E6=95=B4=E3=80=91=E5=9B=A0?= =?UTF-8?q?=E8=85=BE=E8=AE=AF=E8=8E=B7=E5=8F=96=E9=AB=98=E7=B2=BE=E5=BA=A6?= =?UTF-8?q?=E5=9D=90=E6=A0=87=E6=8E=A5=E5=8F=A3=E3=80=90wx.getLocation?= =?UTF-8?q?=E3=80=91=E9=9D=9E=E5=B8=B8=E9=9A=BE=E7=94=B3=E8=AF=B7=EF=BC=8C?= =?UTF-8?q?=E8=80=8C=E5=AF=BC=E8=87=B4=E5=8A=9F=E8=83=BD=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E5=8F=97=E5=BD=B1=E5=93=8D=EF=BC=8C=E4=BD=BF=E7=94=A8=E3=80=90?= =?UTF-8?q?wx.getFuzzyLocation=E3=80=91=E6=A8=A1=E7=B3=8A=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=BB=8F=E7=BA=AC=E5=BA=A6=EF=BC=8C=E4=BD=86=E6=98=AF?= =?UTF-8?q?=E7=A1=AE=E5=AE=9E=E6=98=AF=E6=A8=A1=E7=B3=8A=E7=9A=84=EF=BC=8C?= =?UTF-8?q?=E7=B2=BE=E5=BA=A6=E4=B8=8D=E5=A4=9F=E9=AB=98=EF=BC=8C=E8=AF=AF?= =?UTF-8?q?=E5=B7=AE=E6=9C=89=E7=82=B9=E5=A4=A7=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CoreCms.Net.Uni-App/CoreShop/manifest.json | 336 +++++++++--------- .../pages/member/address/index/index.vue | 61 +++- .../CoreShop/pages/member/address/map/map.vue | 35 +- .../member/merchant/storeList/storeList.vue | 44 ++- .../pages/placeOrder/storeList/storeList.vue | 41 ++- .../CoreShop/pages/storeMap/storeMap.vue | 56 ++- 6 files changed, 371 insertions(+), 202 deletions(-) diff --git a/CoreCms.Net.Uni-App/CoreShop/manifest.json b/CoreCms.Net.Uni-App/CoreShop/manifest.json index 4b0686c0..3268ae6f 100644 --- a/CoreCms.Net.Uni-App/CoreShop/manifest.json +++ b/CoreCms.Net.Uni-App/CoreShop/manifest.json @@ -1,179 +1,179 @@ { - "name" : "核心商城系统", - "appid" : "__UNI__EAACF14", - "description" : "核心商城系统(CoreShop)是基于uni-app框架开发的商城应用程序", - "versionName" : "1.0", - "versionCode" : 1, - "transformPx" : false, - "app-plus" : { - /* 5+App特有相关 */ - "modules" : { - "Payment" : {}, - "VideoPlayer" : {}, - "Maps" : {} + "name": "核心商城系统", + "appid": "__UNI__EAACF14", + "description": "核心商城系统(CoreShop)是基于uni-app框架开发的商城应用程序", + "versionName": "1.0", + "versionCode": 1, + "transformPx": false, + "app-plus": { + /* 5+App特有相关 */ + "modules": { + "Payment": {}, + "VideoPlayer": {}, + "Maps": {} + }, + /* 模块配置 */ + "distribute": { + /* 应用发布信息 */ + "android": { + /* android打包配置 */ + "permissions": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "abiFilters": [ "armeabi-v7a", "arm64-v8a", "x86" ] + }, + "ios": {}, + /* ios打包配置 */ + "sdkConfigs": { + "payment": { + "weixin": { + "appid": "wx11d95cdaee6058f6" + } }, - /* 模块配置 */ - "distribute" : { - /* 应用发布信息 */ - "android" : { - /* android打包配置 */ - "permissions" : [ - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "" - ], - "abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ] - }, - "ios" : {}, - /* ios打包配置 */ - "sdkConfigs" : { - "payment" : { - "weixin" : { - "appid" : "wx11d95cdaee6058f6" - } - }, - "ad" : {}, - "maps" : { - "amap" : { - "appkey_ios" : "91b94ecb48605c4e048aa1971459eca7", - "appkey_android" : "91b94ecb48605c4e048aa1971459eca7" - } - }, - "oauth" : { - "univerify" : {} - }, - "share" : {} - }, - "icons" : { - "android" : { - "hdpi" : "", - "xhdpi" : "", - "xxhdpi" : "", - "xxxhdpi" : "" - }, - "ios" : { - "appstore" : "", - "ipad" : { - "app" : "", - "app@2x" : "", - "notification" : "", - "notification@2x" : "", - "proapp@2x" : "", - "settings" : "", - "settings@2x" : "", - "spotlight" : "", - "spotlight@2x" : "" - }, - "iphone" : { - "app@2x" : "", - "app@3x" : "", - "notification@2x" : "", - "notification@3x" : "", - "settings@2x" : "", - "settings@3x" : "", - "spotlight@2x" : "", - "spotlight@3x" : "" - } - } - } + "ad": {}, + "maps": { + "amap": { + "appkey_ios": "91b94ecb48605c4e048aa1971459eca7", + "appkey_android": "91b94ecb48605c4e048aa1971459eca7" + } }, - "splashscreen" : { - "waiting" : true + "oauth": { + "univerify": {} + }, + "share": {} + }, + "icons": { + "android": { + "hdpi": "", + "xhdpi": "", + "xxhdpi": "", + "xxxhdpi": "" + }, + "ios": { + "appstore": "", + "ipad": { + "app": "", + "app@2x": "", + "notification": "", + "notification@2x": "", + "proapp@2x": "", + "settings": "", + "settings@2x": "", + "spotlight": "", + "spotlight@2x": "" + }, + "iphone": { + "app@2x": "", + "app@3x": "", + "notification@2x": "", + "notification@3x": "", + "settings@2x": "", + "settings@3x": "", + "spotlight@2x": "", + "spotlight@3x": "" + } } + } }, - /* SDK配置 */ - "quickapp" : {}, - /* 快应用特有相关 */ - "mp-weixin" : { - "appid" : "wx6fc139d4de0b470f", - "setting" : { - "urlCheck" : true, - "postcss" : true, - "minified" : true, - "es6" : true, - "checkSiteMap" : false - }, - "plugins" : { - "chooseLocation" : { - "version" : "1.0.9", - "provider" : "wx76a9a06e5b4e693e" - } - }, - "permission" : { - "scope.userLocation" : { - "desc" : "你的位置信息将用于小程序定位" - } - }, - "optimization" : { - "subPackages" : true - }, - "requiredPrivateInfos" : [ "getLocation", "chooseAddress" ] + "splashscreen": { + "waiting": true + } + }, + /* SDK配置 */ + "quickapp": {}, + /* 快应用特有相关 */ + "mp-weixin": { + "appid": "wx6fc139d4de0b470f", + "setting": { + "urlCheck": true, + "postcss": true, + "minified": true, + "es6": true, + "checkSiteMap": false }, - "h5" : { - "title" : "南山田舍", - "domain" : "https://h5.coreshop.coreshop.net", - "router" : { - "base" : "./", - "mode" : "hash" - }, - "template" : "index.html", - "devServer" : { - "port" : 80, - "disableHostCheck" : true, - "https" : true - }, - "sdkConfigs" : { - "maps" : { - "qqmap" : { - "key" : "AEIBZ-H5TRI-A6VGA-5KRNA-QKKK6-JGB33" - } - } - }, - "optimization" : { - "treeShaking" : { - "enable" : false - } + "plugins": { + "chooseLocation": { + "version": "1.0.9", + "provider": "wx76a9a06e5b4e693e" + } + }, + "permission": { + "scope.userLocation": { + "desc": "你的位置信息将用于小程序定位" + } + }, + "optimization": { + "subPackages": true + }, + "requiredPrivateInfos": [ "getFuzzyLocation", "chooseAddress" ] + }, + "h5": { + "title": "南山田舍", + "domain": "https://h5.demo.coreshop.cn", + "router": { + "base": "./", + "mode": "hash" + }, + "template": "index.html", + "devServer": { + "port": 80, + "disableHostCheck": true, + "https": true + }, + "sdkConfigs": { + "maps": { + "qqmap": { + "key": "AEIBZ-H5TRI-A6VGA-5KRNA-QKKK6-JGB33" } + } }, - "mp-toutiao" : { - "setting" : { - "es6" : true, - "postcss" : true, - "minified" : true - }, - "appid" : "" + "optimization": { + "treeShaking": { + "enable": false + } + } + }, + "mp-toutiao": { + "setting": { + "es6": true, + "postcss": true, + "minified": true }, - "mp-qq" : { - "setting" : { - "es6" : true, - "postcss" : true, - "minified" : true - }, - "optimization" : { - "subPackages" : true - } + "appid": "" + }, + "mp-qq": { + "setting": { + "es6": true, + "postcss": true, + "minified": true }, - "mp-alipay" : {}, - "mp-baidu" : {} + "optimization": { + "subPackages": true + } + }, + "mp-alipay": {}, + "mp-baidu": {} } diff --git a/CoreCms.Net.Uni-App/CoreShop/pages/member/address/index/index.vue b/CoreCms.Net.Uni-App/CoreShop/pages/member/address/index/index.vue index 68976d99..8b3f2db0 100644 --- a/CoreCms.Net.Uni-App/CoreShop/pages/member/address/index/index.vue +++ b/CoreCms.Net.Uni-App/CoreShop/pages/member/address/index/index.vue @@ -10,6 +10,11 @@ + + + + + @@ -78,6 +83,9 @@ + + + @@ -158,10 +166,15 @@ } ] }, + alert: { + title: '获取定位失败,请检查是否开启定位功能。', + description: '未获取到您的经纬度坐标,我们需要获取您的经纬度坐标,来计算与发货点的配送距离。不然无法开启同城配送计算运费。', + closable: true, + show: false + }, } }, onShow() { - // #ifdef MP-WEIXIN const chooseLocation = requirePlugin('chooseLocation'); const location = chooseLocation.getLocation(); @@ -208,17 +221,32 @@ // 获取自己的位置信息 getMyLocation() { let _this = this; + // #ifdef MP-WEIXIN + wx.getFuzzyLocation({ + type: 'wgs84', + success(res) { + _this.latitude = res.latitude + _this.longitude = res.longitude + console.log('当前位置的经度1:' + res); + }, + fail: function () { + _this.$u.toast("获取您的经纬度坐标失败") + } + }) + // #endif + // #ifndef MP-WEIXIN uni.getLocation({ type: 'wgs84', success: function (res) { _this.longitude = res.longitude; _this.latitude = res.latitude; + console.log('当前位置的经度2:' + res); }, fail: function () { - _this.$u.toast("获取位置信息失败") + _this.$u.toast("获取您的经纬度坐标失败") } }); - + // #endif }, onConfirm(e) { console.log(e); @@ -442,10 +470,33 @@ } }); // #endif - + }, + // #ifdef MP-WEIXIN + wechatAddress: function () { + let _that = this; + wx.chooseAddress({ + success: res => { + if (res.errMsg == "chooseAddress:ok") { + //获取成功 + //存储这个收获地区信息到数据库 + let data = { + provinceName: res.provinceName, + cityName: res.cityName, + countyName: res.countyName, + postalCode: res.postalCode + }; + + console.log(res); - } + + } else { + this.$refs.uToast.show({ title: '获取微信地址失败', type: 'error' }); + } + } + }); + }, + // #endif }, diff --git a/CoreCms.Net.Uni-App/CoreShop/pages/member/address/map/map.vue b/CoreCms.Net.Uni-App/CoreShop/pages/member/address/map/map.vue index ff1fc94e..02a1820b 100644 --- a/CoreCms.Net.Uni-App/CoreShop/pages/member/address/map/map.vue +++ b/CoreCms.Net.Uni-App/CoreShop/pages/member/address/map/map.vue @@ -251,30 +251,37 @@ }, // 查询现在的位置 getLocation() { - let this_ = this - uni.getLocation({ - // type: 'gcj02', // 返回国测局坐标 - geocode: true, - success: function (res) { - this_.initMap(res) - //console.log(res); + let _this = this; + // #ifdef MP-WEIXIN + wx.getFuzzyLocation({ + type: 'wgs84', + success(res) { + _this.initMap(res) }, - fail: function (e) { - uni.showToast({ - icon: 'none', - title: '获取地址失败, 请检查是否开启定位权限~~' - }) + fail: function () { + _this.$u.toast("获取您的经纬度坐标失败") } }) + // #endif + // #ifndef MP-WEIXIN + uni.getLocation({ + type: 'wgs84', + success: function (res) { + _this.initMap(res) + }, + fail: function () { + _this.$u.toast("获取您的经纬度坐标失败") + } + }); + // #endif }, // 查询现在的位置 getOldLocation(longitude, latitude) { - let this_ = this; var res = { longitude: longitude, latitude: latitude } - this_.initMap(res) + this.initMap(res) }, // 初始化我的位置 async initMap(res) { diff --git a/CoreCms.Net.Uni-App/CoreShop/pages/member/merchant/storeList/storeList.vue b/CoreCms.Net.Uni-App/CoreShop/pages/member/merchant/storeList/storeList.vue index c632647e..99baa82a 100644 --- a/CoreCms.Net.Uni-App/CoreShop/pages/member/merchant/storeList/storeList.vue +++ b/CoreCms.Net.Uni-App/CoreShop/pages/member/merchant/storeList/storeList.vue @@ -64,11 +64,52 @@ //获取门店列表 getStoreAddress() { let _this = this; + // #ifdef MP-WEIXIN + wx.getFuzzyLocation({ + type: 'wgs84', + success(res) { + _this.latitude = res.latitude + _this.longitude = res.longitude + console.log('当前位置的经度1:' + res); + }, + fail: function () { + _this.$u.toast("获取您的经纬度坐标失败") + }, + complete: function (res) { + if (!_this.longitude || !_this.latitude) { + _this.longitude = '0'; + _this.latitude = '0'; + } + let data = { + 'key': _this.key, + 'longitude': _this.longitude, + 'latitude': _this.latitude, + 'page': _this.page, + 'limit': _this.limit, + } + _this.$u.api.storeList(data).then(e => { + if (e.status) { + console.log(e); + _this.storeList = [..._this.storeList, ...e.data] + } else { + _this.$u.toast("门店数据获取失败。"); + } + }); + } + }) + // #endif + // #ifndef MP-WEIXIN uni.getLocation({ - type: 'gcj02', + type: 'wgs84', success: function (res) { _this.longitude = res.longitude; _this.latitude = res.latitude; + console.log('当前位置的经度2:' + res); + }, + fail: function () { + _this.latitude = 0; + _this.longitude = 0; + _this.$u.toast("获取您的经纬度坐标失败") }, complete: function (res) { let data = { @@ -88,6 +129,7 @@ }); } }); + // #endif }, } }; diff --git a/CoreCms.Net.Uni-App/CoreShop/pages/placeOrder/storeList/storeList.vue b/CoreCms.Net.Uni-App/CoreShop/pages/placeOrder/storeList/storeList.vue index a37a7242..b5f47028 100644 --- a/CoreCms.Net.Uni-App/CoreShop/pages/placeOrder/storeList/storeList.vue +++ b/CoreCms.Net.Uni-App/CoreShop/pages/placeOrder/storeList/storeList.vue @@ -83,12 +83,50 @@ //获取门店列表 getStoreList() { let _this = this; + // #ifdef MP-WEIXIN + wx.getFuzzyLocation({ + type: 'wgs84', + success(res) { + _this.latitude = res.latitude + _this.longitude = res.longitude + console.log('当前位置的经度1:' + res); + }, + fail: function () { + _this.$u.toast("获取您的经纬度坐标失败") + }, + complete: function (res) { + if (!_this.longitude || !_this.latitude) { + _this.longitude = '0'; + _this.latitude = '0'; + } + let data = { + 'key': _this.key, + 'longitude': _this.longitude, + 'latitude': _this.latitude, + 'page': _this.page, + 'limit': _this.limit, + } + _this.$u.api.storeList(data).then(e => { + if (e.status) { + console.log(e); + _this.storeList = [..._this.storeList, ...e.data] + } else { + _this.$u.toast("门店数据获取失败。"); + } + }); + } + }) + // #endif + // #ifndef MP-WEIXIN uni.getLocation({ - type: 'gcj02', + type: 'wgs84', success: function (res) { _this.longitude = res.longitude; _this.latitude = res.latitude; }, + fail: function () { + _this.$u.toast("获取您的经纬度坐标失败") + }, complete: function (res) { if (!_this.longitude || !_this.latitude) { _this.longitude = '0'; @@ -111,6 +149,7 @@ }); } }); + // #endif }, //门店选择 selectStore(id, name, mobile, address) { diff --git a/CoreCms.Net.Uni-App/CoreShop/pages/storeMap/storeMap.vue b/CoreCms.Net.Uni-App/CoreShop/pages/storeMap/storeMap.vue index 8c6a309c..2323934c 100644 --- a/CoreCms.Net.Uni-App/CoreShop/pages/storeMap/storeMap.vue +++ b/CoreCms.Net.Uni-App/CoreShop/pages/storeMap/storeMap.vue @@ -78,6 +78,27 @@ // 获取自己的位置信息 getMyLocation() { let _this = this; + // #ifdef MP-WEIXIN + wx.getFuzzyLocation({ + type: 'wgs84', + success(res) { + _this.longitude = res.longitude; + _this.latitude = res.latitude; + _this.getStoreList(); + }, + fail: function () { + _this.$u.toast("获取您的经纬度坐标失败") + }, + complete: function (res) { + if (!_this.longitude || !_this.latitude) { + _this.longitude = '0'; + _this.latitude = '0'; + } + _this.getStoreList(); + } + }) + // #endif + // #ifndef MP-WEIXIN uni.getLocation({ type: 'wgs84', success: function (res) { @@ -86,36 +107,45 @@ _this.getStoreList(); }, fail: function () { - _this.$u.toast("获取位置信息失败") + _this.$u.toast("获取您的经纬度坐标失败") + }, + complete: function (res) { + if (!_this.longitude || !_this.latitude) { + _this.longitude = '0'; + _this.latitude = '0'; + } + _this.getStoreList(); } }); - + // #endif }, // 获取店铺列表信息 getStoreList() { let _this = this; - let data = { 'longitude': _this.longitude, 'latitude': _this.latitude, 'page': _this.page, 'limit': _this.limit, } - _this.$u.api.storeList(data).then(res => { if (res.status) { _this.storeList = res.data; let storeList = res.data; - for (let i = 0; i < storeList.length; i++) { - let mark = { - id: storeList[i].id, - latitude: storeList[i].latitude, - longitude: storeList[i].longitude, - iconPath: '/static/images/map/location.png', - width: 15, - height: 23, + if (storeList.length > 0) { + _this.longitude = storeList[0].longitude; + _this.latitude = storeList[0].latitude; + for (let i = 0; i < storeList.length; i++) { + let mark = { + id: storeList[i].id, + latitude: storeList[i].latitude, + longitude: storeList[i].longitude, + iconPath: '/static/images/map/location.png', + width: 15, + height: 23, + } + _this.covers.push(mark); } - _this.covers.push(mark); } } else { _this.$u.toast("门店信息获取失败")