|
@@ -30,13 +30,20 @@ export default function Component(props: any) {
|
|
|
const [latestRecord, setLatestRecord] = useState(null)
|
|
const [latestRecord, setLatestRecord] = useState(null)
|
|
|
const [triggered, setTriggered] = useState(true)
|
|
const [triggered, setTriggered] = useState(true)
|
|
|
const [showErrorPage, setErrorPage] = useState(false)
|
|
const [showErrorPage, setErrorPage] = useState(false)
|
|
|
|
|
+ const [count,setCount] = useState(0)
|
|
|
// const [title, setTitle] = useState('打卡')
|
|
// const [title, setTitle] = useState('打卡')
|
|
|
|
|
|
|
|
//未登录<->已登录 状态切换时,重新拉取一次列表数据
|
|
//未登录<->已登录 状态切换时,重新拉取一次列表数据
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
dispatch(resetStatus())
|
|
dispatch(resetStatus())
|
|
|
getCards();
|
|
getCards();
|
|
|
- // checkAuth(false)
|
|
|
|
|
|
|
+ const now = new Date();
|
|
|
|
|
+ const nextMidnight = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0, 0);
|
|
|
|
|
+ const timeUntilMidnight = nextMidnight.getTime() - now.getTime();
|
|
|
|
|
+
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ setCount(count+1)
|
|
|
|
|
+ }, timeUntilMidnight);
|
|
|
}, [user.isLogin])
|
|
}, [user.isLogin])
|
|
|
|
|
|
|
|
// useEffect(() => {
|
|
// useEffect(() => {
|
|
@@ -146,11 +153,9 @@ export default function Component(props: any) {
|
|
|
|
|
|
|
|
function getWeRunData(autoCheck = false) {
|
|
function getWeRunData(autoCheck = false) {
|
|
|
if (autoCheck) {
|
|
if (autoCheck) {
|
|
|
- console.log('自动打卡')
|
|
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
- console.log('开始打卡')
|
|
|
|
|
dispatch(checkStart());
|
|
dispatch(checkStart());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -159,7 +164,6 @@ export default function Component(props: any) {
|
|
|
var date = new Date();
|
|
var date = new Date();
|
|
|
var time = date.getTime()
|
|
var time = date.getTime()
|
|
|
var strDate = (date.getFullYear() + '') + (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1)) + (date.getDate() < 10 ? '0' + date.getDate() : date.getDate());
|
|
var strDate = (date.getFullYear() + '') + (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1)) + (date.getDate() < 10 ? '0' + date.getDate() : date.getDate());
|
|
|
- console.log('开始取步数的时间戳:' + new Date().getTime())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
thirdPartRequest(RequestType.RequestTypeWXRunData).then(res => {
|
|
thirdPartRequest(RequestType.RequestTypeWXRunData).then(res => {
|
|
@@ -175,19 +179,20 @@ export default function Component(props: any) {
|
|
|
if ((res as any).error_code == 'WX_STEP_PARSE_FAIL') {
|
|
if ((res as any).error_code == 'WX_STEP_PARSE_FAIL') {
|
|
|
retry(params, autoCheck, time)
|
|
retry(params, autoCheck, time)
|
|
|
dispatch(checkRetry())
|
|
dispatch(checkRetry())
|
|
|
- console.log('上报失败 ')
|
|
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
- console.log('上报成功 ')
|
|
|
|
|
|
|
+
|
|
|
setShowErrorBadge(false)
|
|
setShowErrorBadge(false)
|
|
|
uploadSuccess(res, autoCheck, time)
|
|
uploadSuccess(res, autoCheck, time)
|
|
|
|
|
+ setTimeout(()=>{
|
|
|
|
|
+ setCount(count+1)
|
|
|
|
|
+ },31000)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}).catch(e => {
|
|
}).catch(e => {
|
|
|
retry(params, autoCheck, time)
|
|
retry(params, autoCheck, time)
|
|
|
});
|
|
});
|
|
|
}).catch(_ => {
|
|
}).catch(_ => {
|
|
|
- console.log('回调失败')
|
|
|
|
|
dispatch(setResult({ isSuccess: false }) as any)
|
|
dispatch(setResult({ isSuccess: false }) as any)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -214,6 +219,9 @@ export default function Component(props: any) {
|
|
|
|
|
|
|
|
setShowErrorBadge(false)
|
|
setShowErrorBadge(false)
|
|
|
uploadSuccess(res, autoCheck, time)
|
|
uploadSuccess(res, autoCheck, time)
|
|
|
|
|
+ setTimeout(()=>{
|
|
|
|
|
+ setCount(count+1)
|
|
|
|
|
+ },31000)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}).catch(e => {
|
|
}).catch(e => {
|
|
@@ -252,7 +260,7 @@ export default function Component(props: any) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
Taro.navigateTo({
|
|
Taro.navigateTo({
|
|
|
- url: '/pages/common/RecordsHistory?type=activity&refreshList=getCards&title='+item.name+'&themeColor='+item.theme_color
|
|
|
|
|
|
|
+ url: '/pages/common/RecordsHistory?type=activity&refreshList=getCards&title=' + item.name + '&themeColor=' + item.theme_color
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
@@ -352,7 +360,7 @@ export default function Component(props: any) {
|
|
|
showDetail = true
|
|
showDetail = true
|
|
|
if (item.latest_record) {
|
|
if (item.latest_record) {
|
|
|
value = item.latest_record.items[0].value
|
|
value = item.latest_record.items[0].value
|
|
|
- desc = TimeFormatter.datetimeDescription(item.latest_record.timestamp)
|
|
|
|
|
|
|
+ desc = TimeFormatter.datetimeDescription(item.latest_record.timestamp)
|
|
|
unit = '步'
|
|
unit = '步'
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
@@ -376,7 +384,7 @@ export default function Component(props: any) {
|
|
|
btnText={btnTitle}
|
|
btnText={btnTitle}
|
|
|
isDisabled={!isEnable}
|
|
isDisabled={!isEnable}
|
|
|
themeColor={item.theme_color}
|
|
themeColor={item.theme_color}
|
|
|
- onClickDetail={()=>{goDetail(item)}}
|
|
|
|
|
|
|
+ onClickDetail={() => { goDetail(item) }}
|
|
|
showBadge={showErrorBadge && checkResult.type == 'idle'}
|
|
showBadge={showErrorBadge && checkResult.type == 'idle'}
|
|
|
showDetail={showDetail}
|
|
showDetail={showDetail}
|
|
|
onClick={() => {
|
|
onClick={() => {
|