6 changed files with 158 additions and 3 deletions
@ -0,0 +1,38 @@ |
|||||
|
const HEALTH = '/health'; |
||||
|
const users = `${HEALTH}/users`; |
||||
|
const health = `${HEALTH}/health`; |
||||
|
const sites = `${HEALTH}/sites`; |
||||
|
const journeys = `${HEALTH}/journeys`; |
||||
|
|
||||
|
// 保存个人信息
|
||||
|
const SUBMIT_USER_INFO = `${users}/addInfo`; |
||||
|
|
||||
|
// 获取个人信息
|
||||
|
const GET_USER_INFO = `${users}/info`; |
||||
|
|
||||
|
// 获取健康打卡记录
|
||||
|
const HEALTH_SIGN_HISTORY = `${health}/info`; |
||||
|
|
||||
|
// 健康类型统计
|
||||
|
const HEALTH_TYPE_STATISTICS = `${health}/statistics`; |
||||
|
|
||||
|
// 查询健康状态类型
|
||||
|
const HEALTH_TYPE_STATUS = `${health}/type`; |
||||
|
|
||||
|
// 健康打卡
|
||||
|
const HEALTH_SIGN = `${health}/upload`; |
||||
|
|
||||
|
// 查看自己的打卡记录
|
||||
|
const SCAN_SIGN_INFO = `${sites}/info`; |
||||
|
|
||||
|
// 扫码统计
|
||||
|
const SCAN_SIGN_HISTORY = `${sites}/statistics`; |
||||
|
|
||||
|
// 扫码打卡
|
||||
|
const SCAN_SIGN = `${sites}/upload`; |
||||
|
|
||||
|
// 查询行程
|
||||
|
const GET_JOURNEYS = `${journeys}/info`; |
||||
|
|
||||
|
// 上报行程
|
||||
|
const SUBMIT_JOURNEYS = `${sites}/upload`; |
@ -1,5 +1,5 @@ |
|||||
// api基础地质
|
// api基础地质
|
||||
export const BASE_URL = ``; |
export const BASE_URL = 'https://test.tall.wiki/gateway'; |
||||
|
|
||||
// 错误码
|
// 错误码
|
||||
export const ERR_CODE = 200; |
export const ERR_CODE = 200; |
@ -0,0 +1,85 @@ |
|||||
|
<template> |
||||
|
<view class="padding-top-lg"> |
||||
|
<template v-if="!success"> |
||||
|
<view class="text-xxl padding text-center margin-top-xl"> |
||||
|
<text class="text-black text-bold">{{ address }}</text> |
||||
|
</view> |
||||
|
<button @tap="handleSign" class="cu-btn lg bg-purple margin sign-btn">打卡</button> |
||||
|
</template> |
||||
|
<view class="success" v-else> |
||||
|
<view class="cuIcon-roundcheckfill text-green"></view> |
||||
|
<text class="text-black margin-top">打卡成功</text> |
||||
|
<button @tap="goHome" class="cu-btn lg bg-purple margin-lg sign-btn">返回首页</button> |
||||
|
</view> |
||||
|
</view> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import { formatQuery } from 'utils/util'; |
||||
|
import { SCAN_SIGN } from 'api/api'; |
||||
|
|
||||
|
export default { |
||||
|
name: 'SignScan', |
||||
|
data() { |
||||
|
return { |
||||
|
address: '图书馆', |
||||
|
siteId: '', |
||||
|
siteName: '', |
||||
|
success: true, |
||||
|
}; |
||||
|
}, |
||||
|
|
||||
|
onLoad(options) { |
||||
|
try { |
||||
|
console.log('options: ', options); |
||||
|
const query = formatQuery(decodeURIComponent(options.scene)); |
||||
|
const { siteId, siteName } = query; |
||||
|
this.siteId = query.siteId; |
||||
|
this.siteName = query.siteName; |
||||
|
} catch (error) { |
||||
|
console.log('error: ', error); |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
methods: { |
||||
|
/** |
||||
|
* 扫码打卡 |
||||
|
* @param {string} siteId 场所id |
||||
|
*/ |
||||
|
async handleSign(siteId) { |
||||
|
try { |
||||
|
console.log('打卡'); |
||||
|
const params = { param: { siteId } }; |
||||
|
const res = await this.$http.post(SCAN_SIGN, params); |
||||
|
const { success, code, msg, data } = res.data; |
||||
|
if (success && code === 200) { |
||||
|
this.success = true; |
||||
|
} else { |
||||
|
uni.showToast({ title: msg || '打卡失败', icon: 'none' }); |
||||
|
} |
||||
|
} catch (error) { |
||||
|
console.log('error: ', error); |
||||
|
if (error.data) { |
||||
|
uni.showToast({ title: error.data.msg || '打卡失败', icon: 'none' }); |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.sign-btn { |
||||
|
display: flex; |
||||
|
} |
||||
|
.success { |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
align-items: center; |
||||
|
padding-top: 100rpx; |
||||
|
|
||||
|
.cuIcon-roundcheckfill { |
||||
|
font-size: 200rpx; |
||||
|
} |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,20 @@ |
|||||
|
/** |
||||
|
* 格式化 querystring |
||||
|
* taskId=3&scene=1011 -> |
||||
|
* {taskId:3,scene:1011} |
||||
|
*/ |
||||
|
export const formatQuery = str => { |
||||
|
if (!str) return; |
||||
|
const result = {}; |
||||
|
if (str.includes('&')) { |
||||
|
const arr = str.split('&'); |
||||
|
arr.forEach(item => { |
||||
|
const arr1 = item.split('='); |
||||
|
result[arr1[0]] = arr1[1]; |
||||
|
}); |
||||
|
} else { |
||||
|
const arr = str.split('='); |
||||
|
result[arr[0]] = arr[1]; |
||||
|
} |
||||
|
return result; |
||||
|
}; |
Loading…
Reference in new issue