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

打卡成功

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