diff --git a/pages/index/index.vue b/pages/index/index.vue
index 8fbe721..95bebd1 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -18,8 +18,8 @@
@@ -27,8 +27,11 @@
-
- 拍照打卡
+
+ 定位中...
+ 定位失败
+ 拍照打卡
{{ date.format('YYYY-MM-DD HH:mm:ss') }}
@@ -71,11 +74,11 @@
longitude: 116.39742,
covers: [],
inter : null,
- date : this.$dayjs()
+ date : this.$dayjs(),
}
},
computed : {
- ...mapState(['teamList', 'userInfo']),
+ ...mapState(['teamList', 'userInfo', 'position']),
},
onLoad() {
this.inter = setInterval(() => {
@@ -88,6 +91,7 @@
onShow() {
this.getLocation()
this.$store.commit('getUserInfo')
+ this.$store.commit('getLocation')
},
methods: {
// 跳转签到记录
@@ -104,14 +108,30 @@
toClock(){
+ if(this.position.status == 0){
+ uni.showToast({
+ title: '正在定位中,请稍后!',
+ icon : 'none'
+ })
+ return
+ }
+
+ if(this.position.status == 0){
+ uni.showToast({
+ title: '定位失败,请检查当前定位是否开启!',
+ icon : 'none'
+ })
+ return
+ }
+
// uni.navigateTo({
// url: "/pages/subPack/human/human"
// })
// 检查当前是否在打卡时间段内
this.$api('clockTime', {
- lon : this.longitude,
- lat : this.latitude
+ lon : this.position.longitude,
+ lat : this.position.latitude,
}, res => {
//打卡(跳转人脸识别)
if(res.code == 200){
@@ -126,9 +146,13 @@
//获取用户位置
getLocation() {
let self = this;
+ // uni.showLoading({
+ // title: '定位中...'
+ // })
uni.getLocation({
type: 'gcj02',
success: function(res) {
+ // uni.hideLoading()
self.longitude = res.longitude;
self.latitude = res.latitude;
// self.covers.push({
diff --git a/pages/subPack/human/human.vue b/pages/subPack/human/human.vue
index adcb5c0..a9825ba 100644
--- a/pages/subPack/human/human.vue
+++ b/pages/subPack/human/human.vue
@@ -363,6 +363,7 @@
// 人脸核验
clockVerifyFace(){
+ let self = this
this.$api('clockVerifyFace',
this.form, res => {
if(res.code == 200){
@@ -372,6 +373,15 @@
// })
this.isVerifyFace = true
this.$refs.successPopup.open()
+
+ // if(self.form.lat){
+ // self.submit()
+ // }else{
+ // uni.showLoading({
+ // title: '定位中...'
+ // })
+ // self.isLocationSubmit = true
+ // }
}else{
this.tempImg = ''
this.form.pic = ''
diff --git a/store/store.js b/store/store.js
index 61ed5e3..fe54a82 100644
--- a/store/store.js
+++ b/store/store.js
@@ -12,6 +12,11 @@ const store = new Vuex.Store({
userInfo : {}, //用户信息
teamList : [],//团队列表
authInfo : {},//实名认证信息
+ position : {
+ status : 0,//0正在定位中 1定位成功 2定位失败
+ latitude: 39.909,
+ longitude: 116.39742,
+ },//定位信息
},
getters: {
@@ -117,7 +122,17 @@ const store = new Vuex.Store({
state.authInfo = data
},
getLocation(state){
-
+ uni.getLocation({
+ type: 'gcj02',
+ success: function(res) {
+ state.position.status = 1;
+ state.position.longitude = res.longitude;
+ state.position.latitude = res.latitude;
+ },
+ fail() {
+ state.position.status = 2;
+ }
+ });
},
},
actions: {},