feat: 定期更新用户位置
This commit is contained in:
parent
def8b7026f
commit
e8812b9a1b
32
App.vue
32
App.vue
|
|
@ -1,6 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import {onLaunch, onShow, onHide} from '@dcloudio/uni-app'
|
import {onLaunch, onShow, onHide} from '@dcloudio/uni-app'
|
||||||
import {reactive, provide, inject} from 'vue'
|
import {reactive, provide, inject} from 'vue'
|
||||||
|
import api from "./api/api";
|
||||||
|
|
||||||
//定义全局数据
|
//定义全局数据
|
||||||
const globalData = reactive({
|
const globalData = reactive({
|
||||||
|
|
@ -12,16 +13,41 @@ const globalData = reactive({
|
||||||
provide('globalData', globalData)
|
provide('globalData', globalData)
|
||||||
|
|
||||||
onLaunch(() => {
|
onLaunch(() => {
|
||||||
// console.log('App Launch')
|
|
||||||
initSysInfo()
|
initSysInfo()
|
||||||
|
|
||||||
|
setInterval(() => {
|
||||||
|
updateUserLocation()
|
||||||
|
}, 60 * 1000)
|
||||||
})
|
})
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
// console.log('App Show')
|
updateUserLocation()
|
||||||
})
|
})
|
||||||
onHide(() => {
|
onHide(() => {
|
||||||
// console.log('App Hide')
|
updateUserLocation()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户位置
|
||||||
|
*/
|
||||||
|
const updateUserLocation = () => {
|
||||||
|
let token = uni.getStorageSync('token')
|
||||||
|
//未登录不更新位置
|
||||||
|
if (!token) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.getLocation({
|
||||||
|
type: 'gcj02',
|
||||||
|
success(res) {
|
||||||
|
let data = {longitude: res.longitude, latitude: res.latitude}
|
||||||
|
api.updateUserLocation(data).then(() => {
|
||||||
|
}).catch(() => {})
|
||||||
|
},
|
||||||
|
fail() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const initSysInfo = () => {
|
const initSysInfo = () => {
|
||||||
// 获取手机状态栏高度
|
// 获取手机状态栏高度
|
||||||
let statusBar = uni.getWindowInfo().statusBarHeight
|
let statusBar = uni.getWindowInfo().statusBarHeight
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,12 @@ class Api {
|
||||||
let url = `${config.host}/worker/order_dispatch/saveWorkerRemark`;
|
let url = `${config.host}/worker/order_dispatch/saveWorkerRemark`;
|
||||||
return fetch.request('postFrom', url, data, true)
|
return fetch.request('postFrom', url, data, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 保存师傅备注
|
||||||
|
static updateUserLocation(data) {
|
||||||
|
let url = `${config.host}/worker/worker/updateWorkerLocation`;
|
||||||
|
return fetch.request('postFrom', url, data, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Api
|
export default Api
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ let accountInfo = wx.getAccountInfoSync();
|
||||||
let envVersion = accountInfo.miniProgram.envVersion
|
let envVersion = accountInfo.miniProgram.envVersion
|
||||||
|
|
||||||
//手动指定版本
|
//手动指定版本
|
||||||
envVersion = 'trial'
|
// envVersion = 'trial'
|
||||||
|
|
||||||
let hosts = {
|
let hosts = {
|
||||||
"develop": 'http://wanyu.test',
|
"develop": 'http://wanyu.test',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user