Browse Source

对接接口

master
前端-胡立永 2 months ago
parent
commit
2218f39f12
3 changed files with 58 additions and 9 deletions
  1. +32
    -8
      pages/index/index.vue
  2. +10
    -0
      pages/subPack/human/human.vue
  3. +16
    -1
      store/store.js

+ 32
- 8
pages/index/index.vue View File

@ -18,8 +18,8 @@
</view>
<view class="map">
<map style="width: 100%; height: 100%"
:latitude="latitude"
:longitude="longitude"
:latitude="position.latitude"
:longitude="position.longitude"
:markers="covers" :scale="13">
</map>
</view>
@ -27,8 +27,11 @@
<!-- 打卡按钮 -->
<view class="punch-card">
<view @click="toClock" class="circle">
<view class="title">拍照打卡</view>
<view @click="toClock" class="circle"
:style="{background : ['#aaa', '', '#f40'][position.status]}">
<view class="title" v-if="position.status == 0">定位中...</view>
<view class="title" v-else-if="position.status == 2">定位失败</view>
<view class="title" v-else>拍照打卡</view>
<view class="time">{{ date.format('YYYY-MM-DD HH:mm:ss') }}</view>
</view>
</view>
@ -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({


+ 10
- 0
pages/subPack/human/human.vue View File

@ -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 = ''


+ 16
- 1
store/store.js View File

@ -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: {},


Loading…
Cancel
Save