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>
<view class="map"> <view class="map">
<map style="width: 100%; height: 100%" <map style="width: 100%; height: 100%"
:latitude="latitude"
:longitude="longitude"
:latitude="position.latitude"
:longitude="position.longitude"
:markers="covers" :scale="13"> :markers="covers" :scale="13">
</map> </map>
</view> </view>
@ -27,8 +27,11 @@
<!-- 打卡按钮 --> <!-- 打卡按钮 -->
<view class="punch-card"> <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 class="time">{{ date.format('YYYY-MM-DD HH:mm:ss') }}</view>
</view> </view>
</view> </view>
@ -71,11 +74,11 @@
longitude: 116.39742, longitude: 116.39742,
covers: [], covers: [],
inter : null, inter : null,
date : this.$dayjs()
date : this.$dayjs(),
} }
}, },
computed : { computed : {
...mapState(['teamList', 'userInfo']),
...mapState(['teamList', 'userInfo', 'position']),
}, },
onLoad() { onLoad() {
this.inter = setInterval(() => { this.inter = setInterval(() => {
@ -88,6 +91,7 @@
onShow() { onShow() {
this.getLocation() this.getLocation()
this.$store.commit('getUserInfo') this.$store.commit('getUserInfo')
this.$store.commit('getLocation')
}, },
methods: { methods: {
// //
@ -104,14 +108,30 @@
toClock(){ 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({ // uni.navigateTo({
// url: "/pages/subPack/human/human" // url: "/pages/subPack/human/human"
// }) // })
// //
this.$api('clockTime', { this.$api('clockTime', {
lon : this.longitude,
lat : this.latitude
lon : this.position.longitude,
lat : this.position.latitude,
}, res => { }, res => {
//() //()
if(res.code == 200){ if(res.code == 200){
@ -126,9 +146,13 @@
// //
getLocation() { getLocation() {
let self = this; let self = this;
// uni.showLoading({
// title: '...'
// })
uni.getLocation({ uni.getLocation({
type: 'gcj02', type: 'gcj02',
success: function(res) { success: function(res) {
// uni.hideLoading()
self.longitude = res.longitude; self.longitude = res.longitude;
self.latitude = res.latitude; self.latitude = res.latitude;
// self.covers.push({ // self.covers.push({


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

@ -363,6 +363,7 @@
// //
clockVerifyFace(){ clockVerifyFace(){
let self = this
this.$api('clockVerifyFace', this.$api('clockVerifyFace',
this.form, res => { this.form, res => {
if(res.code == 200){ if(res.code == 200){
@ -372,6 +373,15 @@
// }) // })
this.isVerifyFace = true this.isVerifyFace = true
this.$refs.successPopup.open() this.$refs.successPopup.open()
// if(self.form.lat){
// self.submit()
// }else{
// uni.showLoading({
// title: '...'
// })
// self.isLocationSubmit = true
// }
}else{ }else{
this.tempImg = '' this.tempImg = ''
this.form.pic = '' this.form.pic = ''


+ 16
- 1
store/store.js View File

@ -12,6 +12,11 @@ const store = new Vuex.Store({
userInfo : {}, //用户信息 userInfo : {}, //用户信息
teamList : [],//团队列表 teamList : [],//团队列表
authInfo : {},//实名认证信息 authInfo : {},//实名认证信息
position : {
status : 0,//0正在定位中 1定位成功 2定位失败
latitude: 39.909,
longitude: 116.39742,
},//定位信息
}, },
getters: { getters: {
@ -117,7 +122,17 @@ const store = new Vuex.Store({
state.authInfo = data state.authInfo = data
}, },
getLocation(state){ 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: {}, actions: {},


Loading…
Cancel
Save