From 0512f40da106268ac342377256cf9099d7f90b3e Mon Sep 17 00:00:00 2001
From: xuxueyang <xuxy@fengyuntec.com>
Date: 星期五, 18 十月 2024 10:41:35 +0800
Subject: [PATCH] add 首页的定位
---
pages/home/home.vue | 5 +
manifest.json | 8 +-
sub_pages/customer/shopping/confirm.vue | 6 +-
pages/order/order.vue | 6 +-
pages/order/order-detail.vue | 6 +-
pages/user/address/address.vue | 114 ++++++++++++++++++++++++++++++++-----
store/index.js | 6 +
7 files changed, 121 insertions(+), 30 deletions(-)
diff --git a/manifest.json b/manifest.json
index 7553c85..34ae2ab 100644
--- a/manifest.json
+++ b/manifest.json
@@ -42,7 +42,9 @@
},
"ios" : {},
/* ios打包配置 */
- "sdkConfigs" : {}
+ "sdkConfigs" : {
+ "geolocation" : {}
+ }
}
},
/* SDK配置 */
@@ -61,9 +63,9 @@
"desc" : "获取店铺位置与实现蓝牙打印功能"
}
},
- "requiredPrivateInfos" : [ "chooseLocation" ],
+ "requiredPrivateInfos" : [ "chooseLocation", "getLocation" ],
"plugins" : {},
- "lazyCodeLoading": "requiredComponents"
+ "lazyCodeLoading" : "requiredComponents"
},
// "chooseLocation" : {
// "version" : "1.0.10",
diff --git a/pages/home/home.vue b/pages/home/home.vue
index c3cfb6d..0ce708d 100644
--- a/pages/home/home.vue
+++ b/pages/home/home.vue
@@ -15,7 +15,7 @@
<view class="picker flex" @click.stop="goToAddress">
<uni-icons type="location" class="m-r-5" size="18"></uni-icons>
<view>
- {{ address&&address.id?address.address: '选择地址' }}
+ {{ addressDesc || (address&&address.id?address.address: '选择地址') }}
</view>
</view>
</view>
@@ -141,6 +141,9 @@
...mapState({
address: state => {
return state.defaultaddress || {}
+ },
+ addressDesc: state=>{
+ return state.addressDesc || ''
},
currentInfo: state => {
return state.currentInfo || {}
diff --git a/pages/order/order-detail.vue b/pages/order/order-detail.vue
index 53b8a64..43f9a37 100644
--- a/pages/order/order-detail.vue
+++ b/pages/order/order-detail.vue
@@ -21,7 +21,7 @@
async onShow() {
// 支付回调
- // #ifdef PUB_CUSTOMER_DEV
+ // #ifdef PUB_CUSTOMER
let options = wx.getEnterOptionsSync();
if (options.scene == '1038' && options.referrerInfo.appId == 'wxef277996acc166c3') {
// 代表从收银台小程序返回
@@ -356,7 +356,7 @@
if (code === 0) {
//微信接口
let that = this
- // #ifndef PUB_CUSTOMER_DEV
+ // #ifndef PUB_CUSTOMER
wx.requestPayment({
...data,
@@ -371,7 +371,7 @@
}
})
// #endif
- // #ifdef PUB_CUSTOMER_DEV
+ // #ifdef PUB_CUSTOMER
var param = {
// cusid: "平台分配的商户号",
// appid: "平台分配的appid",
diff --git a/pages/order/order.vue b/pages/order/order.vue
index b9921fa..4847452 100644
--- a/pages/order/order.vue
+++ b/pages/order/order.vue
@@ -94,7 +94,7 @@
},
async onShow() {
// 支付回调
- // #ifdef PUB_CUSTOMER_DEV
+ // #ifdef PUB_CUSTOMER
let options = wx.getEnterOptionsSync();
if (options.scene == '1038' && options.referrerInfo.appId == 'wxef277996acc166c3') {
// 代表从收银台小程序返回
@@ -337,7 +337,7 @@
if (code === 0) {
//微信接口
let that = this
- // #ifndef PUB_CUSTOMER_DEV
+ // #ifndef PUB_CUSTOMER
wx.requestPayment({
...data,
async success(res) {
@@ -354,7 +354,7 @@
}
})
// #endif
- // #ifdef PUB_CUSTOMER_DEV
+ // #ifdef PUB_CUSTOMER
var param = {
// cusid: "平台分配的商户号",
// appid: "平台分配的appid",
diff --git a/pages/user/address/address.vue b/pages/user/address/address.vue
index 7a67134..6be831d 100644
--- a/pages/user/address/address.vue
+++ b/pages/user/address/address.vue
@@ -1,8 +1,8 @@
<template>
<!-- 收货地址列表 -->
<view class="p15 container-address">
- <!-- <view class="search-container m-t-12 flex">
- <view class="flex1 input">
+ <view class="search-container m-t-12 flex">
+ <view class="flex1 input" @click="selectWxAddress('input')">
<u-input placeholder="小区名/店铺名/写字楼/街道名等" disabled v-model="search_flow">
<template slot="suffix">
<uni-icons color="#20613D" type="search" size="24"></uni-icons>
@@ -12,19 +12,29 @@
</view>
<view class="m-t-12 ">
<view class="desc-gray">当前位置</view>
- <view class="flex">
- <view class="flex1"></view>
- <view @click="selectWxAddress('input')">
- <image src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/a2/a248385d4fe748ca81ee058ea5bf8c47icon-address.jpg"></image>
- 重新定位
+ <view class="flex current-address">
+ <view class="flex1">
+ {{ addressDesc || (address&&address.id?address.address: '选择地址') }}
+
+ </view>
+ <view class="flex" @click="changeCurrentAddress">
+ <view>
+ <image style="width: 30rpx;height: 30rpx;" class="m-t-2"
+ src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/a2/a248385d4fe748ca81ee058ea5bf8c47icon-address.jpg">
+ </image>
+ </view>
+ <view>重新定位</view>
</view>
</view>
</view>
- -->
+ <view class="m-t-12 ">
+ <view class="desc-gray">我的收获地址</view>
+
+ </view>
<no-data v-if="!list||list.length==0" style="width: 100%;"></no-data>
<!-- 循环 -->
- <view v-for="(item,index) of list" :key="index" class="location-each">
+ <view v-for="(item,index) of list" :key="index" class="location-each m-t-12">
<view class="flex">
<view class="container-info">
<view class="flex">
@@ -73,8 +83,8 @@
<view style="height: 92rpx;width: 690rpx;">
</view>
- <view class="button-green button-fixed-bottom" style="width: 690rpx;line-height: 92rpx;height: 92rpx;"
- @click="addAddress">添加收货地址
+ <view class="button-green button-fixed-bottom" v-if="currentInfo.id"
+ style="width: 690rpx;line-height: 92rpx;height: 92rpx;" @click="addAddress">添加收货地址
</view>
<uni-popup ref="popup_form" type="top" :mask-click="false">
@@ -174,7 +184,12 @@
// this.list = [{}, {}]
this.source = options.source || ''
this.listApi = '/api/address/list'
- await this.getList()
+ if (!this.currentInfo.id) {
+
+ } else {
+ await this.getList()
+
+ }
},
onShow() {
@@ -211,6 +226,12 @@
address: state => {
return state.defaultaddress || {}
},
+ addressDesc: state => {
+ return state.addressDesc || ''
+ },
+ // search_flow() {
+ // return this.addressDesc || ''
+ // }
}),
},
@@ -230,13 +251,14 @@
},
regionDataPlus: [],
list: [],
+ search_flow: '',
};
},
methods: {
selectWxAddress(source) {
let that = this
- if (source === 'form') {
+ {
//表单选择了地址
wx.chooseLocation({
success: location => {
@@ -246,9 +268,17 @@
// latitude: 31.26249
// longitude: 120.63212
// name: "苏州市吴中区人民政府"
- that.submitForm.address = (location.address || '') + (location.name || '')
- that.submitForm.latitude = location.latitude || 0
- that.submitForm.longitude = location.longitude || 0
+ if (source === 'form') {
+ // (location.address || '') +
+ that.submitForm.address = (location.name || '')
+ that.submitForm.latitude = location.latitude || 0
+ that.submitForm.longitude = location.longitude || 0
+ } else if (source === 'input') {
+ // (location.address || '') +
+ // that.search_flow = (location.name || '')
+ that.$store.commit('setAddressDesc', (location.name || ''))
+ }
+
// if (!that.submitForm.province && location.provinceName) {
// that.submitForm.province = location.provinceName
// if (!that.submitForm.city && location.cityName) {
@@ -319,6 +349,50 @@
this.submitForm['region'] = ''
this.submitForm['isDefault'] = false
this.openAddressForm()
+ },
+ changeCurrentAddress() {
+ // if(!this.addressDesc){
+
+ // }
+ let that = this
+ this.$message.showLoading()
+ uni.getLocation({
+ type: 'gcj02',
+ geocode: true,
+ success: async (res) => {
+ // this.location = {
+ // latitude: res.latitude,
+ // longitude: res.longitude,
+ // speed: res.speed,
+ // accuracy: res.accuracy,
+ // address: res.address,
+ // };
+ const {
+ code,data
+ } = that.$http.request('get', '/api/pub/customer/home/address/parse', {
+ data: {},
+ params: {
+ // https://apis.map.qq.com/ws/geocoder/v1/?location=39.984154,116.307490&key=[你的key]&get_poi=1
+ location:`${res.latitude},${res.longitude}`
+ }
+ })
+ console.log('定位成功:', data);
+ if(data){
+ var address = data.address || ''
+
+ that.$store.commit('setAddressDesc', (address || ''))
+ }
+
+
+ },
+ fail: (err) => {
+ this.error = err;
+ console.error('定位失败:', err);
+ },
+ complete() {
+ this.$message.hideLoading()
+ }
+ });
},
PickArea(item, e) {
console.log('PickArea', item, e)
@@ -577,6 +651,14 @@
<style lang="scss" scoped>
.container-address {
+ .current-address {
+ padding: 20rpx;
+ background-color: #FFFFFF;
+ border-radius: 16rpx;
+ margin-top: 16rpx;
+ margin-bottom: 20rpx;
+ }
+
.popup-address-form {
background: #FFFFFF;
border-radius: 16rpx;
diff --git a/store/index.js b/store/index.js
index db2ae33..766cdbf 100644
--- a/store/index.js
+++ b/store/index.js
@@ -39,7 +39,8 @@
coupon: {},
goods:[],
},
- defaultaddress: {}
+ defaultaddress: {},
+ addressDesc:'',
},
mutations: {
@@ -69,6 +70,9 @@
setDefaultAddress(state, defaultaddress) {
state.defaultaddress = defaultaddress
},
+ setAddressDesc(state, addressDesc) {
+ state.addressDesc = addressDesc
+ },
setTestTrue(state) {
state.testvuex = true
},
diff --git a/sub_pages/customer/shopping/confirm.vue b/sub_pages/customer/shopping/confirm.vue
index 570129d..8553dc6 100644
--- a/sub_pages/customer/shopping/confirm.vue
+++ b/sub_pages/customer/shopping/confirm.vue
@@ -68,7 +68,7 @@
},
async onShow() {
// 支付回调
- // #ifdef PUB_CUSTOMER_DEV
+ // #ifdef PUB_CUSTOMER
if (this.sign['cache_topay']) {
let options = wx.getEnterOptionsSync();
if (options.scene == '1038' && options.referrerInfo.appId == 'wxef277996acc166c3') {
@@ -337,7 +337,7 @@
await tmp.$store.dispatch('sign_add', 'shopping')
uni.navigateBack()
} else if (data) {
- // #ifndef PUB_CUSTOMER_DEV
+ // #ifndef PUB_CUSTOMER
wx.requestPayment({
...data,
async success(res) {
@@ -368,7 +368,7 @@
// #endif
// openEmbeddedMiniProgram,需要小程序基础库版本不低于 2.26.2
- // #ifdef PUB_CUSTOMER_DEV
+ // #ifdef PUB_CUSTOMER
var param = {
// cusid: "平台分配的商户号",
// appid: "平台分配的appid",
--
Gitblit v1.9.3