|
|
@@ -19,6 +19,7 @@ import ShareBtn from "@/components/basic/ShareBtn";
|
|
|
import PickerCard from "../components/picker_card";
|
|
|
import showActionSheet from "@/components/basic/ActionSheet";
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
+import FollowInfo from "@/_moment/components/follow_info";
|
|
|
|
|
|
let timer
|
|
|
let useRoute;
|
|
|
@@ -32,6 +33,7 @@ export default function TimeRecord() {
|
|
|
const systemInfo: any = Taro.getWindowInfo ? Taro.getWindowInfo() : Taro.getSystemInfoSync();
|
|
|
const navigationBarHeight = systemInfo.statusBarHeight + 44;
|
|
|
const record = useSelector((state: any) => state.record);
|
|
|
+ const long = useSelector((state: any) => state.long);
|
|
|
const user = useSelector((state: any) => state.user);
|
|
|
const [enterTime] = useState(new Date().getTime())
|
|
|
|
|
|
@@ -54,6 +56,10 @@ export default function TimeRecord() {
|
|
|
|
|
|
const [posting, setPosting] = useState(false)
|
|
|
|
|
|
+ const [postError, setPostError] = useState('')
|
|
|
+
|
|
|
+ const [pickerTitle,setPickerTitle] = useState('')
|
|
|
+
|
|
|
const { t } = useTranslation()
|
|
|
|
|
|
let router
|
|
|
@@ -69,7 +75,7 @@ export default function TimeRecord() {
|
|
|
router = useRouter()
|
|
|
}
|
|
|
|
|
|
- const { scenario } = router.params
|
|
|
+ const { scenario, join_id } = router.params
|
|
|
|
|
|
|
|
|
if (process.env.TARO_ENV == 'weapp') {
|
|
|
@@ -101,6 +107,19 @@ export default function TimeRecord() {
|
|
|
picker1Ref.current = showDatePicker
|
|
|
picker2Ref.current = showEndDatePicker
|
|
|
picker3Ref.current = showDurationPicker
|
|
|
+ if (!showDatePicker && !showEndDatePicker) {
|
|
|
+ setPostError('')
|
|
|
+ }
|
|
|
+
|
|
|
+ if (showDatePicker){
|
|
|
+ setPickerTitle(scenario=='FAST'?t('health.adjust_fast_start_time'):t('health.adjust_bed_time'))
|
|
|
+ }
|
|
|
+ else if (showEndDatePicker){
|
|
|
+ setPickerTitle(scenario=='FAST'?t('health.adjust_fast_end_time'):t('health.adjust_wake_up'))
|
|
|
+ }
|
|
|
+ else if (showDurationPicker){
|
|
|
+ setPickerTitle(scenario=='FAST'?t('health.adjust_fast_goal'):t('health.adjust_sleep_goal'))
|
|
|
+ }
|
|
|
}, [status, showDatePicker, showEndDatePicker, showDurationPicker])
|
|
|
|
|
|
|
|
|
@@ -184,10 +203,8 @@ export default function TimeRecord() {
|
|
|
// console.log('打卡提交数据', params)
|
|
|
if (posting) return
|
|
|
setPosting(true)
|
|
|
- Taro.showLoading({
|
|
|
- title: t('health.uploading')
|
|
|
- })
|
|
|
addEvents(params).then(res => {
|
|
|
+
|
|
|
Taro.eventCenter.trigger('refreshClockIndex')
|
|
|
Taro.eventCenter.trigger('refreshMoments', '')
|
|
|
setShowHighlight(true)
|
|
|
@@ -201,10 +218,8 @@ export default function TimeRecord() {
|
|
|
// icon: 'success'
|
|
|
// })
|
|
|
setPosting(false)
|
|
|
- Taro.hideLoading()
|
|
|
}).catch(e => {
|
|
|
setPosting(false)
|
|
|
- Taro.hideLoading()
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -231,9 +246,6 @@ export default function TimeRecord() {
|
|
|
|
|
|
if (posting) return
|
|
|
setPosting(true)
|
|
|
- Taro.showLoading({
|
|
|
- title: t('health.uploading')
|
|
|
- })
|
|
|
addEvents(params).then(res => {
|
|
|
setShowHighlight(true)
|
|
|
setTimeout(() => {
|
|
|
@@ -252,10 +264,8 @@ export default function TimeRecord() {
|
|
|
// icon: 'success'
|
|
|
// })
|
|
|
setPosting(false)
|
|
|
- Taro.hideLoading()
|
|
|
}).catch(e => {
|
|
|
setPosting(false)
|
|
|
- Taro.hideLoading()
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -268,10 +278,11 @@ export default function TimeRecord() {
|
|
|
}
|
|
|
if (posting) return
|
|
|
setPosting(true)
|
|
|
- Taro.showLoading({
|
|
|
- title: t('health.uploading')
|
|
|
- })
|
|
|
addEvents(data).then(res => {
|
|
|
+ if ((res as any).result == false) {
|
|
|
+ setPostError((res as any).error_messages[0])
|
|
|
+ return
|
|
|
+ }
|
|
|
Taro.eventCenter.trigger('refreshClockIndex')
|
|
|
Taro.eventCenter.trigger('refreshMoments', '')
|
|
|
setInfo((res as any).data)
|
|
|
@@ -280,17 +291,15 @@ export default function TimeRecord() {
|
|
|
setShowEndDatePicker(false)
|
|
|
setCount((count) => count + 1)
|
|
|
setPosting(false)
|
|
|
- Taro.hideLoading()
|
|
|
}).catch(e => {
|
|
|
setPosting(false)
|
|
|
- Taro.hideLoading()
|
|
|
})
|
|
|
}
|
|
|
|
|
|
function more() {
|
|
|
showActionSheet({
|
|
|
- title: '操作',
|
|
|
- itemList: ['放弃', '重新开始'],
|
|
|
+ // title: '操作',
|
|
|
+ itemList: [t('health.discard'), t('health.discard_restart')],
|
|
|
success: (res) => {
|
|
|
switch (res) {
|
|
|
case 0:
|
|
|
@@ -333,7 +342,7 @@ export default function TimeRecord() {
|
|
|
|
|
|
return {
|
|
|
target: str,
|
|
|
- goal: 'Edit Goal',
|
|
|
+ goal: t('health.adjust_goal'),
|
|
|
color: MainColorType.orange
|
|
|
}
|
|
|
}
|
|
|
@@ -430,22 +439,22 @@ export default function TimeRecord() {
|
|
|
setShowDatePicker(true)
|
|
|
}}>
|
|
|
<View className="operate_item" >
|
|
|
- <View className="g02 h24 white_50">STARTED</View>
|
|
|
+ <View className="g02 h24 white_50">{scenario=='FAST'?t('health.started'):t('health.bedtime1')}</View>
|
|
|
<View className="h44 bold white" style={{ marginTop: rpxToPx(8), marginBottom: rpxToPx(8) }}>{TimeFormatter.dateTimeFormate(info.time.start_timestamp, true)}</View>
|
|
|
- <View className="h30 bold white_50" style={{ color: MainColorType.white }}>Edit Start</View>
|
|
|
+ <View className="h30 bold white_50" style={{ color: MainColorType.white }}>{scenario=='FAST'?t('health.adjust_start'):t('health.adjust_bedtime')}</View>
|
|
|
</View>
|
|
|
</NewButton>
|
|
|
<NewButton type={NewButtonType.custom} onClick={() => {
|
|
|
setShowEndDatePicker(true)
|
|
|
}}>
|
|
|
<View className="operate_item" style={{ backgroundColor: showHighlight ? '#ffffff80' : 'transparent' }} >
|
|
|
- <View className="g02 h24 white_50">FINISHED</View>
|
|
|
+ <View className="g02 h24 white_50">{scenario=='FAST'?t('health.finished'):t('health.wokeup')}</View>
|
|
|
<View className="h44 bold white" style={{ marginTop: rpxToPx(8), marginBottom: rpxToPx(8) }}>{TimeFormatter.dateTimeFormate(info.time.end_timestamp, true)}</View>
|
|
|
- <View className="h30 bold white_50" style={{ color: MainColorType.white }}>Edit Finish</View>
|
|
|
+ <View className="h30 bold white_50" style={{ color: MainColorType.white }}>{scenario=='FAST'?t('health.adjust_end'):t('health.adjust_wake_up')}</View>
|
|
|
</View>
|
|
|
</NewButton>
|
|
|
</View> :
|
|
|
- <View className="white bold" style={{ fontSize: rpxToPx(72), display: 'flex', alignItems: 'center', justifyContent: 'center', flex: 1 }}>You've made it!</View>
|
|
|
+ <View className="white bold" style={{ fontSize: rpxToPx(72), display: 'flex', alignItems: 'center', justifyContent: 'center', flex: 1 }}>{t('health.fast_finished')}</View>
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -508,9 +517,9 @@ export default function TimeRecord() {
|
|
|
function naviTitle() {
|
|
|
switch (status) {
|
|
|
case 'WFS':
|
|
|
- return scenario == 'FAST' ? 'Upcoming fast' : 'Upcoming sleep'
|
|
|
+ return scenario == 'FAST' ? t('health.upcoming_fast') : t('health.upcoming_sleep')
|
|
|
case 'OG':
|
|
|
- return scenario == 'FAST' ? 'Fasting' : 'Sleeping'
|
|
|
+ return scenario == 'FAST' ? t('health.you_are_fasting') : t('health.your_are_sleeping')
|
|
|
case 'DONE':
|
|
|
return scenario == 'FAST' ? 'Fast completed' : 'Sleep completed'
|
|
|
}
|
|
|
@@ -580,18 +589,18 @@ export default function TimeRecord() {
|
|
|
setShowDatePicker(true)
|
|
|
}}>
|
|
|
<View className="operate_item" style={{ backgroundColor: showHighlight ? '#ffffff80' : 'transparent' }}>
|
|
|
- <View className="black_50 h24">STARTED</View>
|
|
|
+ <View className="black_50 h24">{scenario=='FAST'?t('health.started'):t('health.bedtime1')}</View>
|
|
|
<View className="h44 bold" style={{ marginTop: rpxToPx(8), marginBottom: rpxToPx(8) }}>{TimeFormatter.abbrTimestampFormat(info.time.start_timestamp)}</View>
|
|
|
- <View className="h30 bold" style={{ color: MainColorType.orange }}>Edit Start</View>
|
|
|
+ <View className="h30 bold" style={{ color: MainColorType.orange }}>{scenario=='FAST'?t('health.adjust_start'):t('health.adjust_bedtime')}</View>
|
|
|
</View>
|
|
|
</NewButton>
|
|
|
<NewButton type={NewButtonType.custom} onClick={() => {
|
|
|
setShowDurationPicker(true)
|
|
|
}}>
|
|
|
<View className="operate_item">
|
|
|
- <View className="black_50 h24">{TimeFormatter.formateDurationBySeconds(info.time.duration / 1000)} Goal</View>
|
|
|
- <View className="h44 bold" style={{ marginTop: rpxToPx(8), marginBottom: rpxToPx(8) }}>{TimeFormatter.abbrTimestampFormat(info.time.target_end_timestamp, true)}</View>
|
|
|
- <View className="h30 bold" style={{ color: MainColorType.orange }}>Edit Goal</View>
|
|
|
+ <View className="black_50 h24">{t('health.time_goal',{time:TimeFormatter.formateDurationBySeconds(info.time.duration / 1000)})}</View>
|
|
|
+ <View className="h44 bold" style={{ marginTop: rpxToPx(8), marginBottom: rpxToPx(8) }}>{TimeFormatter.abbrTimestampFormat(info.time.target_end_timestamp)}</View>
|
|
|
+ <View className="h30 bold" style={{ color: MainColorType.orange }}>{t('health.adjust_goal')}</View>
|
|
|
</View>
|
|
|
</NewButton>
|
|
|
</View>
|
|
|
@@ -647,7 +656,7 @@ export default function TimeRecord() {
|
|
|
|
|
|
|
|
|
</View>
|
|
|
- {
|
|
|
+ {/* {
|
|
|
status == 'WFS' && <View className="eat_card" onClick={() => {
|
|
|
Taro.redirectTo({
|
|
|
url: `./log_record?scenario=${scenario == 'FAST' ? 'MEAL' : 'ACTIVITY'}`
|
|
|
@@ -659,6 +668,10 @@ export default function TimeRecord() {
|
|
|
<IconArrow width={rpxToPx(34)} color={MainColorType.black_25} />
|
|
|
</View>
|
|
|
</View>
|
|
|
+ } */}
|
|
|
+
|
|
|
+ {
|
|
|
+ router.params.join_id && <FollowInfo user={long.follow} />
|
|
|
}
|
|
|
|
|
|
{/* {
|
|
|
@@ -789,6 +802,8 @@ export default function TimeRecord() {
|
|
|
showDatePicker && <PickerCard onClose={() => { setShowDatePicker(false) }}
|
|
|
value={info.time.start_timestamp}
|
|
|
type="datetime"
|
|
|
+ title={pickerTitle}
|
|
|
+ error={postError}
|
|
|
onConfirm={(e) => {
|
|
|
update({
|
|
|
start_timestamp: e
|
|
|
@@ -804,6 +819,8 @@ export default function TimeRecord() {
|
|
|
showEndDatePicker && <PickerCard onClose={() => { setShowEndDatePicker(false) }}
|
|
|
value={info.time.end_timestamp}
|
|
|
type="datetime"
|
|
|
+ title={pickerTitle}
|
|
|
+ error={postError}
|
|
|
onConfirm={(e) => {
|
|
|
update({
|
|
|
end_timestamp: e
|
|
|
@@ -819,11 +836,15 @@ export default function TimeRecord() {
|
|
|
showDurationPicker && <PickerCard onClose={() => { setShowDurationPicker(false) }}
|
|
|
value={info.time.duration}
|
|
|
type="duration"
|
|
|
+ title={pickerTitle}
|
|
|
onConfirm={(e) => {
|
|
|
var obj = JSON.parse(JSON.stringify(info))
|
|
|
obj.time.duration = e
|
|
|
setInfo(obj)
|
|
|
- if (status == 'WFS') return
|
|
|
+ if (status == 'WFS') {
|
|
|
+ setShowDurationPicker(false)
|
|
|
+ return
|
|
|
+ }
|
|
|
update({
|
|
|
duration: e
|
|
|
})
|