liujd 6 лет назад
Родитель
Сommit
9d30284a86

+ 237 - 0
mobile-code/src/components/app-area-sel - 副本.vue

@@ -0,0 +1,237 @@
+<template>
+	<div class="app-area-sel">
+		<bottom-popup class="popup-wrap" :show="show" @close="hidePopup">
+			<div class="map-wrap">
+				<div class="map-top-tit-wrap">
+					<div class="map-top-tit">选择收货地址</div>
+					<app-close icon="iconguanbi" @close="hidePopup" />
+				</div>
+				<!-- 搜索 -->
+				<div class="map-search">
+					<app-search-module placeholder="请输入你的收货地址" />
+				</div>
+				<!-- 地图 -->
+				<div class="map-box">
+					<map id="myMap" style="width: 100%; height: 140px;" :latitude="latitude" :longitude="longitude" @regionchange="mapChange">
+						<cover-image class="current-site-icon" src="../../static/images/common/localposition.png"></cover-image>
+						<cover-view class="reload" @click="reload">
+							<cover-view class="center1">
+								<cover-view class="center2"></cover-view>
+							</cover-view>
+						</cover-view>
+					</map>
+				</div>
+				<!-- 列表 -->
+				<scroll-view class="near-list" scroll-y>
+					<view v-for="(item,index) in nearListData" :key="index" @click="switchAddress(item,index)" class="near-item">
+						<div class="current-site" :class="{'active' : currentSelectAddress === index}"></div>
+						<view>
+							<view :class="['title',currentSelectAddress === index? 'title1':'']">{{item.title}}</view>
+							<view class="add">{{item.address}}</view>
+						</view>
+					</view>
+				</scroll-view>
+			</div>
+		</bottom-popup>
+	</div>
+</template>
+
+<script>
+import BottomPopup from '@/components/plugin/bottom-popup'
+import AppClose from '@/components/module/app-close'
+import AppSearchModule from '@/components/module/app-search'
+export default {
+	name: 'app-area-sel',
+	components: {
+		BottomPopup,
+		AppClose,
+		AppSearchModule
+	},
+	props: {
+		show: {
+			type: Boolean,
+			default: false
+		}
+	},
+	data() {
+		return {
+			// 地图
+			latitude: 24.44579,
+			longitude: 118.08243,
+			// 列表
+			currentSelectAddress: 0,
+			nearListData: [
+				{
+					title: '中国共产党厦门市思明区纪律检查委员会',
+					address: '福建省厦门市思明区民族路33号'
+				},
+				{
+					title: '厦门市思明区人民政府',
+					address: '福建省厦门市思明区民族路33号'
+				},
+				{
+					title: '海滨商厦',
+					address: '福建省厦门市思明区民族路42~44'
+				},
+				{
+					title: '卢卡国际青年旅舍',
+					address: '福建省厦门市思明区民族路35号(思明区政府对面)'
+				},
+				{
+					title: '中国共产党厦门市思明区纪律检查委员会',
+					address: '福建省厦门市思明区民族路33号'
+				},
+				{
+					title: '厦门市思明区人民政府',
+					address: '福建省厦门市思明区民族路33号'
+				},
+				{
+					title: '海滨商厦',
+					address: '福建省厦门市思明区民族路42~44'
+				}
+			]
+		}
+	},
+	onLoad(val) {
+		this.mapCtx = uni.createMapContext('myMap')
+		this.query = val
+		this.reload()
+	},
+	methods: {
+		hidePopup() {
+			this.$emit('hide')
+		},
+		// 地图操作
+		reload() {
+			uni.getLocation({
+				type: 'wgs84',
+				success: res => {
+					this.latitude = res.latitude
+					this.longitude = res.longitude
+					// this.nearList()
+				},
+				// eslint-disable-next-line handle-callback-err
+				fail: err => {
+					this.$msg('定位失败')
+					// setTimeout(function() {
+					// 	uni.navigateBack({
+					// 		delta: 1
+					// 	})
+					// }, 1500)
+				}
+			})
+		},
+		mapChange(e) {
+			if (e.type == 'end' && (e.causedBy == 'scale' || e.causedBy == 'drag')) {
+				this.mapCtx.getCenterLocation({
+					success: res => {
+						this.longitude = res.longitude
+						this.latitude = res.latitude
+						// this.nearList()
+					}
+				})
+			}
+		},
+		// 获取列表
+		nearList() {
+			geocoder({
+				latitude: this.latitude,
+				longitude: this.longitude
+			}).then(res => {
+				console.log(res)
+				let data = res.result
+				this.currentSelectAddress = 0
+				this.nearListData = data.pois
+				// this.currentRegion = [data.address_component.province, data.address_component.city, data.address_component.district]
+			})
+		},
+		switchAddress(item, index) {
+			// this.currentSelectAddress = index
+			// this.latitude = item.location.lat
+			// this.longitude = item.location.lng
+			// if (!this.$util.isEmpty(item.province) && !this.$util.isEmpty(item.city)) {
+			// 	this.currentRegion = [item.province, item.city, item.district]
+			// }
+			this.$emit('change', item)
+		}
+	}
+}
+</script>
+
+<style lang="scss" scoped>
+	// 弹窗
+	/deep/.popup-wrap {
+		.tui-popup-class {
+			border-top-left-radius: 20px;
+			border-top-right-radius: 20px;
+		}
+	}
+	.map-wrap {
+		.map-top-tit-wrap {
+			padding: 30px 0;
+			text-align: center;
+			font-size: 34px;
+		}
+		.map-search {
+			padding: 0 30px;
+			margin-bottom: 20px;
+		}
+		.map-box {
+			.current-site-icon {
+				width: 63px;
+				height: 90px;
+				position: absolute;
+				top: 50%;
+				left: 50%;
+				transform: translate(-50%, -50%);
+			}
+		}
+
+		// 列表
+		.near-list {
+			height: 620rpx;
+			// padding-bottom: 110rpx;
+			box-sizing: border-box;
+			.near-item {
+				line-height: 40rpx;
+				padding: 18rpx 50rpx 18rpx 0;
+				margin-left: 90px;
+				text-align: left;
+				border-bottom: 1px solid #eee;
+				position: relative;
+			}
+			.current-site {
+				width: 16px;
+				height: 16px;
+				background-color: #dedede;
+				border-radius: 50%;
+				position: absolute;
+				top: 60rpx;
+				left: -60rpx;
+				&.active {
+					background-color: $mainColor;
+				}
+			}
+			.near-item .title {
+				color: #282828;
+				font-size: 28rpx;
+				white-space: nowrap;
+				overflow: hidden;
+				text-overflow: ellipsis;
+			}
+			.near-item .add {
+				color: $fontColor3;
+				font-size: 22rpx;
+				white-space: nowrap;
+				overflow: hidden;
+				text-overflow: ellipsis;
+			}
+			.near-item .title1 {
+				color: $mainColor;
+			}
+			.near-item .add1 {
+				color: $mainColor;
+			}
+		}
+	}
+</style>

+ 11 - 1
mobile-code/src/components/app-area-sel.vue

@@ -8,7 +8,7 @@
 				</div>
 				<!-- 搜索 -->
 				<div class="map-search">
-					<app-search-module placeholder="请输入你的收货地址" />
+					<app-search-module placeholder="请输入你的收货地址" @search="searchFn" />
 				</div>
 				<!-- 地图 -->
 				<div class="map-box">
@@ -98,6 +98,16 @@ export default {
 		this.reload()
 	},
 	methods: {
+		// 搜索
+		searchFn(e) {
+			this.$emit('search', e)
+			uni.reverseGeocode({
+				latitude: 25.661333498914413,
+				longitude: 117.5537109375
+			}, (e) => {
+				console.log(e)
+			})
+		},
 		hidePopup() {
 			this.$emit('hide')
 		},

+ 2 - 2
mobile-code/src/components/module/app-search.vue

@@ -8,10 +8,10 @@
 				<input type="text" v-model="search" :style="{fontSize: fontSize + 'rpx'}" :placeholder="placeholder" placeholder-class="placeholder" />
 			</div>
 		</div>
-        <block v-if="isBtn">
+        <!-- <block v-if="isBtn"> -->
             <button v-if="isTextBtn" class="search-btn" :style="{fontSize: fontSize + 'rpx'}" @click="searchFn">{{ btnText }}</button>
 		    <button v-else class="search-btn admin-button-com middle blue" :style="{fontSize: fontSize + 'rpx'}" @click="searchFn">{{ btnText }}</button>
-        </block>
+        <!-- </block> -->
 	</div>
 </template>
 

+ 14 - 11
mobile-code/src/official/apply.vue

@@ -50,7 +50,7 @@
 				<button class="admin-button-com blue big" formType="submit">确认</button>
 			</div>
 			<!-- 选择地区 -->
-			<app-area-sel :show="showRegion" @hide="hideAreaSel" @change="changeAreaFn" />
+			<!-- <app-area-sel :show="showRegion" @hide="hideAreaSel" @change="changeAreaFn" /> -->
 			<!-- 省市联动 -->
 			<simple-address ref="simpleAddress" :region="orderShop.region" :pickerValueDefault="cityPickerValueDefault" @onConfirm="onCityConfirm"></simple-address>
 		</form>
@@ -90,8 +90,6 @@ export default {
 			},
 			// 省市联动
 			cityPickerValueDefault: [0, 0],
-			// 选择地区
-			showRegion: false,
 			// 验证码
 			isSend: 0,
 			countDown: 59,
@@ -102,6 +100,7 @@ export default {
 		...mapGetters({ orderShop: 'getOrderShop' })
 	},
 	methods: {
+		// ==============
 		confirmFn() {
 			this.$util.pageTo('/official/pay')
 		},
@@ -139,14 +138,18 @@ export default {
 		},
 		// 选择地址
 		selRegionFn() {
-			this.showRegion = true
-		},
-		changeAreaFn(item) {
-			this.form.receiveFullAddress = item.address
-			this.hideAreaSel()
-		},
-		hideAreaSel() {
-			this.showRegion = false
+			let that = this
+			uni.chooseLocation({
+				success: (res) => {
+					this.form.address = res.address
+					this.form.latitude = res.latitude
+					this.form.longitude = res.longitude
+					console.log('位置名称:' + res.name)
+					console.log('详细地址:' + res.address)
+					console.log('纬度:' + res.latitude)
+					console.log('经度:' + res.longitude)
+				}
+			})
 		},
 		// 省市联动
 		openAddres() {

+ 1 - 2
mobile-code/src/official/callback.vue

@@ -126,9 +126,8 @@ export default {
 		padding-top: 30px;
 		.callback-blo {
 			width: calc(100% - 60px);
-			margin: 0 auto;
-			padding: 70px 0;
 			margin: 0 30px;
+			padding: 70px 0;
 			background-color: #fff;
 			box-shadow: 2px 2px 16px 0px rgba(181, 181, 181, 0.29);
 			border-radius: 10px;