提交 19c8ada2 authored 作者: lidongxu's avatar lidongxu

打卡成功

上级 22bc9a1e
......@@ -18,9 +18,10 @@ export const getAttendanceDetailAPI = (ruleId) => {
* @returns
*/
export const addAttendanceAPI = (data) => {
console.log(data)
return request({
url: '/operation/kqmx/core',
method: 'post',
data
method: 'POST',
data: data
})
}
\ No newline at end of file
......@@ -102,17 +102,20 @@ export default {
'off': 3
// 前端考勤类型,对应后端数字代表考勤类型
}
const { addressComponent, location } = await this.$store.getters.location
const { lng, lat } = location
const { province, city, district, street } = addressComponent
await addAttendanceAPI({
"kqLocal": [
100.111,
99.333
lng,
lat
],
"kqProvinc": "内蒙古自治区",
"kqCity": "呼和浩特市",
"kqCounty": "新城区",
"kqAddress": "第一街道66号",
"kqProvinc": province,
"kqCity": city,
"kqCounty": district,
"kqAddress": street,
"kqPicurl": "https://www.baidu.com",
"kqType": 3
"kqType": attendanceType[type]
})
}
}
......
......@@ -72,14 +72,13 @@ export default {
async addendanceClick() {
const result = await this.$store.getters.location
// 判断用户位置和获取位置-城市是否一致
if (result.result.addressComponent.city.startsWith(this.$store.getters.user.workCityName)) {
if (result.addressComponent.city.startsWith(this.$store.getters.user.workCityName)) {
// 跳转到打卡页面
this.$tab.navigateTo('/pages/attendance/index')
} else {
// 不一致,提示
this.$modal.msgError("工作地点与定位地点不同");
}
}
}
}
......
......@@ -13,8 +13,8 @@ const getters = {
if (state.map.location) {
resolve(state.map.location)
} else {
const location = await store.dispatch('GetLocation')
state.map.location = location
const result = await store.dispatch('GetLocation')
state.map.location = result
resolve(location)
}
})
......
......@@ -24,11 +24,12 @@ const location = {
uni.getLocation({
success: async (res) => {
// 经纬度调 百度 逆地理编码获取省市区名字
const result = await reverseGeocoding({
const { result } = await reverseGeocoding({
params: {
location: res.latitude + "," + res.longitude
}
})
console.log('2', result)
commit('SET_LOCATION', result)
resolve(result)
}
......
......@@ -22,39 +22,39 @@ const request = config => {
}
return new Promise((resolve, reject) => {
uni.request({
method: config.method || 'get',
timeout: config.timeout || timeout,
url: config.baseUrl || baseUrl + config.url,
data: config.data,
header: config.header,
dataType: 'json'
}).then(response => {
let [error, res] = response
if (error) {
toast('后端接口连接异常')
reject('后端接口连接异常')
return
}
const code = res.data.code || 200
const msg = errorCode[code] || res.data.msg || errorCode['default']
if (code === 401) {
showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
if (res.confirm) {
store.dispatch('LogOut').then(res => {
uni.reLaunch({ url: '/pages/login' })
})
}
})
reject('无效的会话,或者会话已过期,请重新登录。')
} else if (code === 500) {
toast(msg)
reject('500')
} else if (code !== 200) {
toast(msg)
reject(code)
}
resolve(res.data)
})
method: config.method || 'get',
timeout: config.timeout || timeout,
url: config.baseUrl || baseUrl + config.url,
data: config.data,
header: config.header,
dataType: 'json'
}).then(response => {
let [error, res] = response
if (error) {
toast('后端接口连接异常')
reject('后端接口连接异常')
return
}
const code = res.data.code || 200
const msg = errorCode[code] || res.data.msg || errorCode['default']
if (code === 401) {
showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
if (res.confirm) {
store.dispatch('LogOut').then(res => {
uni.reLaunch({ url: '/pages/login' })
})
}
})
reject('无效的会话,或者会话已过期,请重新登录。')
} else if (code === 500) {
toast(msg)
reject('500')
} else if (code !== 200) {
toast(msg)
reject(code)
}
resolve(res.data)
})
.catch(error => {
let { message } = error
if (message === 'Network Error') {
......
......@@ -4,7 +4,7 @@ import constant from './constant'
let storageKey = 'storage_data'
// 存储节点变量名
let storageNodeKeys = [constant.avatar, constant.name, constant.roles, constant.permissions, constant.user]
let storageNodeKeys = [constant.avatar, constant.name, constant.roles, constant.permissions, constant.user, constant.location]
const storage = {
set: function(key, value) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论