wangguoyu 2 月之前
父節點
當前提交
0a13d4cd4a

+ 3 - 2
components/customMap/customMap.vue

@@ -55,7 +55,7 @@
 		useCustomMap
 	} from "@/components/customMap/useMap.js"
 
-	const emits = defineEmits(['close', 'xuanzeAdress'])
+	const emits = defineEmits(['close', 'xuanzeAdress','currentWeizhi'])
 	const {
 		getPositionSearchByKeyword
 	} = useCustomMap();
@@ -130,8 +130,9 @@
 	}
 
 	function xuanzeAdress(item) {
-		console.log('item');
+		console.log('item',item);
 		emits('xuanzeAdress', item.address);
+		emits('currentWeizhi', item.location);
 
 	}
 

+ 145 - 0
pages/admin/Jiazheng/common/share.vue

@@ -0,0 +1,145 @@
+<template>
+ <button @click="showShareMenu">分享</button>
+</template>
+
+<script>
+export default {
+  data() {
+    return {
+      imageUrl: 'https://example.com/path/to/your/image.jpg' // 后端提供的图片地址
+    };
+  },
+  methods: {
+    // 显示分享菜单
+    showShareMenu() {
+      uni.showActionSheet({
+        itemList: ['下载图片'],
+        success: (res) => {
+          if (res.tapIndex === 0) {
+            this.downloadImage(); // 点击“下载图片”
+          }
+        }
+      });
+    },
+
+    // 下载图片
+    downloadImage() {
+      // #ifdef H5
+      this.downloadImageForH5();
+      // #endif
+
+      // #ifdef APP-PLUS
+      this.downloadImageForApp();
+      // #endif
+    },
+
+    // H5 环境下载图片
+    downloadImageForH5() {
+      // 创建一个隐藏的 <a> 标签
+      const link = document.createElement('a');
+      link.href = this.imageUrl;
+      link.download = 'image.jpg'; // 设置下载文件名
+      document.body.appendChild(link);
+      link.click(); // 触发下载
+      document.body.removeChild(link);
+
+      // 提示用户手动保存
+      uni.showToast({
+        title: '图片已下载,请手动保存到相册。',
+        icon: 'none'
+      });
+    },
+
+    // APP 环境下载图片
+    downloadImageForApp() {
+      uni.showLoading({
+        title: '下载中...',
+        mask: true
+      });
+
+      // 下载图片
+      uni.downloadFile({
+        url: this.imageUrl, // 图片地址
+        success: (res) => {
+          if (res.statusCode === 200) {
+            const tempFilePath = res.tempFilePath; // 下载后的临时文件路径
+            this.saveImageToAlbum(tempFilePath); // 保存到相册
+          } else {
+            uni.showToast({
+              title: '下载失败',
+              icon: 'none'
+            });
+          }
+        },
+        fail: (err) => {
+          console.error('下载失败:', err);
+          uni.showToast({
+            title: '下载失败',
+            icon: 'none'
+          });
+        },
+        complete: () => {
+          uni.hideLoading();
+        }
+      });
+    },
+
+    // 保存图片到相册(APP 环境)
+    saveImageToAlbum(tempFilePath) {
+      // 检查权限(仅 Android 需要)
+      // #ifdef APP-PLUS
+      if (uni.getSystemInfoSync().platform === 'android') {
+        uni.authorize({
+          scope: 'scope.writePhotosAlbum',
+          success: () => {
+            this.saveImage(tempFilePath);
+          },
+          fail: () => {
+            // 无权限,提示用户去设置
+            uni.showModal({
+              title: '提示',
+              content: '需要相册权限才能保存图片,是否去设置?',
+              success: (res) => {
+                if (res.confirm) {
+                  uni.openSetting(); // 打开设置页面
+                }
+              }
+            });
+          }
+        });
+      } else {
+        this.saveImage(tempFilePath);
+      }
+      // #endif
+    },
+    saveImage(tempFilePath) {
+      uni.saveImageToPhotosAlbum({
+        filePath: tempFilePath,
+        success: () => {
+          uni.showToast({
+            title: '保存成功',
+            icon: 'success'
+          });
+        },
+        fail: (err) => {
+          console.error('保存失败:', err);
+          uni.showToast({
+            title: '保存失败',
+            icon: 'none'
+          });
+        }
+      });
+    }
+  }
+};
+</script>
+
+<style>
+button {
+  margin-top: 20px;
+  padding: 10px 20px;
+  background-color: #007AFF;
+  color: white;
+  border-radius: 5px;
+}
+</style>

+ 9 - 1
pages/admin/Jiazheng/gerenZiliao.vue

@@ -126,7 +126,7 @@
 			<button type="default" v-if="status =='edit'" @click="editSave" class="phone-green-btn">保存</button>
 		</view>
 		<uni-popup ref="popupMap" background-color="#fff" :is-mask-click="false" :mask-click="false">
-			<customMap style="100vh" @xuanzeAdress="xuanzeAdress" @close="mapClose"></customMap>
+			<customMap style="100vh" @xuanzeAdress="xuanzeAdress" @currentWeizhi="currentWeizhi" @close="mapClose"></customMap>
 		</uni-popup>
 	</view>
 </template>
@@ -168,6 +168,8 @@
 					idtype: '1',
 					gender: '',
 					juzhuDizhi: '',
+					jingdu: '',
+					weidu: '',
 					shenfenzhengUrl: '',
 					minzu: {},
 					shuxiang: {
@@ -224,6 +226,12 @@
 				this.formData.juzhuDizhi = data
 				this.mapClose()
 			},
+			currentWeizhi(data) {
+				console.log('data', data);
+				this.formData.jingdu = data.lng
+				this.formData.weidu = data.lat
+				this.mapClose()
+			},
 			openMap() {
 				this.$refs.popupMap.open('bottom')
 			},

+ 15 - 0
pages/admin/Jiazheng/index.vue

@@ -49,6 +49,7 @@
 								<view class="head-name">{{item.realName}}</view>
 								<button type="default" class="phone-green-btn bz-tel-btn"
 									@click.stop="telephone(item)">打电话</button>
+									<shareRef ref="shareRef">分享</shareRef>
 							</view>
 							<view @click="lookUserInfo(item)" class="card-body-row">
 								<view class="card-img-box">
@@ -94,8 +95,10 @@
 	} from "@/api/jiazheng.js"
 	import dataChecked from './common/dataChecked.vue';
 	import searchDialog from "./common/search.vue";
+	import share from "./common/share.vue";
 	import customTabbarAdminVue from "@/components/custom-tabbar/custom-tabbar-admin.vue";
 	const searchDialogRef = ref(null);
+	const shareRef = ref(null);
 	let allType = ref([])
 	let data = reactive({
 		leixing: '全部类型',
@@ -365,8 +368,20 @@
 		}));
 		return newList
 	}
+	
+	function getCurrentWeizhi(){
+		uni.getLocation({
+			type: 'gcj02',
+			success: function(res) {
+				console.log('res', res)
+				console.log('当前位置的经度:' + res.longitude);
+				console.log('当前位置的纬度:' + res.latitude);
+			}
+		});
+	}
 	onLoad(() => {
 		getMore()
 		getLeixing()
+		getCurrentWeizhi()
 	})
 </script>