From e05f156dcc1c41b2efb29738deddb1b39b39a19b Mon Sep 17 00:00:00 2001 From: liutong <836164388@qq.com> Date: Tue, 27 May 2025 16:57:40 +0800 Subject: [PATCH] =?UTF-8?q?feat(my=5Fattendance):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=80=83=E5=8B=A4=E8=AF=A6=E6=83=85=E5=8A=9F=E8=83=BD=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AE=9A=E4=BD=8D=E6=9D=83=E9=99=90=E5=A4=84?= =?UTF-8?q?=E7=90=86-=20=E6=96=B0=E5=A2=9E=E8=80=83=E5=8B=A4=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E5=BC=B9=E7=AA=97=EF=BC=8C=E5=B1=95=E7=A4=BA=E8=80=83?= =?UTF-8?q?=E5=8B=A4=E7=8A=B6=E6=80=81=E3=80=81=E6=97=A5=E6=9C=9F=E3=80=81?= =?UTF-8?q?=E6=A0=A1=E5=8C=BA=E5=90=8D=E7=A7=B0=E7=AD=89=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=20-=20=E6=B7=BB=E5=8A=A0=E5=9C=B0=E5=9B=BE=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=98=BE=E7=A4=BA=E8=80=83=E5=8B=A4?= =?UTF-8?q?=E5=9C=B0=E7=82=B9-=20=E4=BC=98=E5=8C=96=E5=AE=9A=E4=BD=8D?= =?UTF-8?q?=E6=9D=83=E9=99=90=E5=A4=84=E7=90=86=E6=B5=81=E7=A8=8B=EF=BC=8C?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=8B=92=E7=BB=9D=E6=8E=88=E6=9D=83=E6=97=B6?= =?UTF-8?q?=E5=BC=B9=E5=87=BA=E6=8F=90=E7=A4=BA-=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=BD=8D=E7=BD=AE=E4=BF=A1=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8C=E6=8F=90=E9=AB=98=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=8F=AF=E8=AF=BB=E6=80=A7=E5=92=8C=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.json | 3 +- pages/common/my_attendance.vue | 211 +++++++++++++++++++++++++++++++-- 2 files changed, 205 insertions(+), 9 deletions(-) diff --git a/manifest.json b/manifest.json index 8466e67..fea1073 100644 --- a/manifest.json +++ b/manifest.json @@ -77,7 +77,8 @@ "desc" : "用于获取当前所在城市信息" } }, - "requiredPrivateInfos" : [ "getLocation", "chooseLocation" ] + "requiredPrivateInfos" : [ "getLocation", "chooseLocation" ], + "libVersion":"latest" }, "mp-alipay" : { "usingComponents" : true diff --git a/pages/common/my_attendance.vue b/pages/common/my_attendance.vue index 25468fd..7e12fee 100644 --- a/pages/common/my_attendance.vue +++ b/pages/common/my_attendance.vue @@ -23,8 +23,9 @@ > @@ -198,9 +199,49 @@ + + + + - + + + 详情 + + + 考勤状态: + 请假 + + + 考勤日期: + 请假 + + + 校区名称: + 请假 + + + 备注: + 请假 + + + 地图: + + + + + + @@ -303,7 +344,9 @@ export default { // }, ],//选择器可选值列表 - + //详情模态窗 + info_show:false,//是否展示|true=是,false=否 + info_data:{},//详情数据 } }, onLoad(options) {}, @@ -313,6 +356,23 @@ export default { methods: { //初始化 async init(){ + // 条件编译-小程序 + // #ifdef MP-WEIXIN + uni.authorize({ + scope: 'scope.userLocation', + success() { + // 用户已授权 + + }, + fail() { + uni.showToast({ + title: '请开启定位权限', + icon: 'none' + }); + return + } + }); + // #endif this.userType = uni.getStorageSync('userType') this.getCurrentDate()//获取并格式化当前日期 await this.getUserInfo()//获取用户信息 @@ -459,7 +519,6 @@ export default { } //确认按钮 this.formData.status='absent'//考勤类型|present-出勤, absent-缺勤 - await this.getLocation()//获取经纬度 await this.submitFormData() } }, @@ -492,6 +551,9 @@ export default { this.formData.remarks = '' this.formData.longitude = '' this.formData.latitude = '' + + this.getlocation()//获取经纬度 + }, //关闭打卡弹窗 closeSignInShow(){ @@ -511,7 +573,6 @@ export default { }) return } - await this.getLocation()//获取经纬度 await this.submitFormData() } }, @@ -537,12 +598,16 @@ export default { //获取用户经纬度 - async getLocation() { + async getLocation_COPY() { try { const location = await new Promise((resolve, reject) => { uni.getLocation({ type: 'wgs84', // 坐标类型,wgs84 返回 gps 坐标,gcj02 返回国测局坐标 success: (res) => { + console.log('当前位置的经度:' + res.longitude); + console.log('当前位置的纬度:' + res.latitude); + this.longitude = res.longitude + this.latitude = res.latitude resolve(res); }, fail: (err) => { @@ -558,6 +623,11 @@ export default { this.formData.latitude = location.latitude; this.formData.longitude = location.longitude; + uni.showToast({ + title: `定位-${this.formData.latitude}`, + icon: 'none' + }); + // uni.showToast({ // title: '位置获取成功', // icon: 'success' @@ -571,6 +641,60 @@ export default { } }, + getlocation() { + uni.getLocation({ + type: 'wgs84', + success: (res) => { + console.log('当前位置的经度:' + res.longitude); + console.log('当前位置的纬度:' + res.latitude); + this.formData.longitude = res.longitude + this.formData.latitude = res.latitude + // 调用后端接口根据得到的经纬度获取地址 + console.log(res, "根据经纬度获取地址"); + }, + // 若用户点击拒绝获取位置则弹出提示 + fail: (err) => { + uni.showModal({ + content: '检测到您没打开获取位置功能权限,是否去设置打开?', + confirmText: "确认", + cancelText: '取消', + success: (res) => { + if (res.confirm) { + uni.openSetting({ + success: (res) => { + uni.showToast({ + title: '授权后请重新打开此页面', + icon: 'none' + }) + }, + fail: (err) => { + console.log(err) + } + }) + } else { + uni.showToast({ + title: '获取地理位置授权失败', + icon: 'none', + success: () => { + // 返回上一页 + setTimeout(() => { + uni.showToast({ + title: "返回上一页", + icon: 'none' + }) + // uni.navigateBack({ + // delta: 1 + // }) + }, 500) + } + }) + } + } + }) + }, + }) + }, + //发起请假/打卡请求 async submitFormData() { this.closeSignInShow() @@ -594,8 +718,51 @@ export default { setTimeout(() => { this.segmented({id:0})//初始化 }, 1500) - } + }, + + //打开详情 + openInfo(item){ + + + let coordinate_arr= [] + if (item.coordinate){ + coordinate_arr = item.coordinate.split(',') + } + item.latitude = Number(coordinate_arr[0] || 0) + item.longitude = Number(coordinate_arr[1] || 0) + + // item.latitude = 18.252865 + // item.longitude = 109.511709 + + this.info_data = {...item}; + // 设置 info_data 并打开弹窗 + this.info_show = true + + }, + //关闭详情 + closeInfoShow(){ + this.info_show = false + }, + + // 获取标记点 + getMarkers(id,item) { + console.log('获取标记点',item) + let data = { + id: Number(id), + // 设置标记点的纬度坐标 + latitude: Number(item.latitude), + // 设置标记点的经度坐标 + longitude: Number(item.longitude), + + // name: item.campus_address, + iconPath: '/static/icon-img/ding_wei.png', + width: 30, + height: 30 + } + console.log(88888,data) + return [data]; + }, } } @@ -736,4 +903,32 @@ export default { } } +//详情 +.info_ul{ + padding: 30rpx; + display: flex; + flex-direction: column; + gap: 20rpx; + width: 100%; + .li{ + border: 1px solid red; + display: flex; + .title{ + width: 130rpx; + } + } + .map_section{ + display: flex; + flex-direction: column; + .title{ + width: 130rpx; + } + .map{ + margin-top: 10rpx; + border: 1px solid red; + width: 100%; + } + } +} + \ No newline at end of file