Leon před 2 roky
rodič
revize
a53c6ac112

+ 58 - 18
src/components/layout/Modal.scss

@@ -9,41 +9,56 @@
     overflow: hidden;
     display: flex;
     flex-direction: column;
-    background-color: rgba($color: #000000, $alpha: 0.9);
+    background-color: rgba($color: #000000, $alpha: 0);
+    animation: modalBgAnim 0.2s linear forwards;
 }
 
+@keyframes modalBgAnim {
 
+    100% {
+        background-color: rgba($color: #000000, $alpha: 0.9);
+    }
+}
 
+.modal_dismiss {
+    background-color: rgba($color: #000000, $alpha: 0.9);
+    animation: modalBgHideAnim 0.2s linear forwards;
+}
 
+@keyframes modalBgHideAnim {
+    100% {
+        background-color: rgba($color: #000000, $alpha: 0);
+    }
+}
 
-/* #endif */ 
 
+/* #endif */
 
-/* #ifdef rn */ 
-.modal{
-    
-}
 
-/* #endif */ 
+/* #ifdef rn */
+.modal {}
+
+/* #endif */
 
-.modal_center_container{
+.modal_center_container {
     align-items: center;
     justify-content: center;
     // margin-bottom: 560px;
 }
 
-.center_modal_detail{
+.center_modal_detail {
     margin-bottom: 192px;
 }
-.modal_center_content{
+
+.modal_center_content {
     // background-color: #1c1c1c;
     // border-radius: 36rpx;
     width: 658px;
-    
+
 }
 
 
-.modal_bottom_content{
+.modal_bottom_content {
     // padding-bottom: 120px;
     width: 750px;
     background-color: #1c1c1c;
@@ -53,9 +68,34 @@
     flex-shrink: 0;
     flex-direction: column;
     z-index: 1000000;
+    margin-bottom: -1000px;
+    animation: modalAnim 0.2s linear forwards;
 }
 
-.modal_title{
+.modal_bottom_dismiss{
+    margin-bottom: 0px;
+    animation: modalHideAnim 0.2s linear forwards;
+}
+
+@keyframes modalAnim {
+    0% {
+        margin-bottom: -1000px;
+    }
+
+    100% {
+        margin-bottom: 0;
+    }
+}
+
+@keyframes modalHideAnim {
+    100% {
+        margin-bottom: -1000px;
+    }
+}
+
+
+
+.modal_title {
     font-size: 36px;
     line-height: 120px;
     height: 120px;
@@ -64,7 +104,7 @@
     text-align: center;
 }
 
-.modal_operate{
+.modal_operate {
     display: flex;
     flex-direction: row;
     width: 750px;
@@ -74,7 +114,7 @@
     margin-top: 36px;
 }
 
-.modal_btn{
+.modal_btn {
     width: 260px;
     height: 84px;
     border-radius: 42px;
@@ -83,16 +123,16 @@
     justify-content: center;
 }
 
-.btn_space{
+.btn_space {
 
     width: 90px;
 }
 
-.modal_cancel_text{
+.modal_cancel_text {
     font-weight: 500;
 }
 
 
-.modal_confirm_text{
+.modal_confirm_text {
     font-weight: 500;
 }

+ 19 - 4
src/components/layout/Modal.tsx

@@ -1,6 +1,6 @@
 import { View, Text, ScrollView } from '@tarojs/components'
 import './Modal.scss'
-import React from 'react';
+import React, { useState } from 'react';
 import { ModalType } from '@/utils/types';
 import Box from './Box';
 import Taro from '@tarojs/taro';
@@ -15,6 +15,8 @@ export default function Modal(props: {
     cancelCatchMove?: boolean
 }) {
 
+    const [isDismiss, setIsDismiss] = useState(false)
+
     //阻止中间内容点击事件穿透
     function click(e) {
         if (process.env.TARO_ENV == 'weapp') {
@@ -55,18 +57,31 @@ export default function Modal(props: {
         }
     }
 
+    function dismiss(){
+        if (props.modalType==ModalType.center){
+            props.dismiss()
+            return
+        }
+        setIsDismiss(true)
+        setTimeout(()=>{
+            props.dismiss()
+        },250)
+    }
+
+    global.dismissModal = dismiss;
+
 
-    return <View className='modal' catchMove onLongPress={longPress}>
+    return <View className={isDismiss?'modal modal_dismiss':'modal'} catchMove onLongPress={longPress}>
         <View style={{ flex: 1, width: 375, flexShrink: 0 }} onClick={(e) => {
             if (process.env.TARO_ENV == 'weapp') {
                 e.stopPropagation()
-            }; props.dismiss()
+            }; dismiss()
         }}>
             {
                 props.testInfo ? props.testInfo : null
             }
         </View>
-        <View className='modal_bottom_content' style={{ flexShrink: 0 }} onClick={onClick}>
+        <View className={isDismiss?'modal_bottom_content modal_bottom_dismiss':'modal_bottom_content'} style={{ flexShrink: 0 }} onClick={onClick}>
             {/* <Text className='modal_title' style={{ color: color }}>{props.title ? props.title : '测试标题 '}</Text> */}
             {
                 props.children

+ 2 - 1
src/context/locales/zh.js

@@ -277,7 +277,8 @@ export default {
         },
         food: {
             action_sheet: {
-                alert_text: '编辑或分享',
+                alert_text: '编辑这一餐',
+                edit_title:'对当前照片进行操作',
                 tag: '标签',
                 start_time: '开始时间',
                 end_time: '结束时间',

+ 8 - 7
src/features/food/FoodConsole.tsx

@@ -60,7 +60,7 @@ export default function Component(props: { addItem: Function }) {
                         console.log(savedFilePath)
                         setImgUrl(savedFilePath as any)
 
-                        uploadFile(savedFilePath)
+                        uploadFile(savedFilePath,isAlbum ? 'album' : 'camera')
                     }
                 })
             }
@@ -106,7 +106,7 @@ export default function Component(props: { addItem: Function }) {
         )
     }
 
-    function uploadFile(path) {
+    function uploadFile(path,source) {
         Taro.showLoading({
             title: '加载中'
         })
@@ -132,7 +132,7 @@ export default function Component(props: { addItem: Function }) {
                     formData: rsp.data.fields,
                     success: rlt => {
                         console.log(rlt)
-                        createData(rsp.data.view_url)
+                        createData(rsp.data.view_url,source)
 
                         // uploadAvatar(rsp.data.view_url)
                         // _this.changeAvatar(rsp.data.view_url);
@@ -148,16 +148,17 @@ export default function Component(props: { addItem: Function }) {
         })
     }
 
-    function createData(url) {
+    function createData(url,source) {
         var date = new Date();
         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());
 
         createFoodJournal({
-            cover: {
+            media: [{
                 url,
-                type: url.indexOf('mp4') != -1 ? 'video' : 'image'
-            },
+                type: url.indexOf('mp4') != -1 ? 'video' : 'image',
+                source:source
+            }],
             start: {
                 timestamp: time,
                 date: strDate

+ 9 - 1
src/features/food/FoodJournal.tsx

@@ -14,6 +14,7 @@ import { setMealTags } from "@/store/common"
 import { getInfoSuccess } from "@/store/user"
 import './FoodJournal.scss'
 import { rpxToPx } from "@/utils/tools"
+import NoData from "@/components/view/NoData"
 
 export default function Component() {
     const { t } = useTranslation()
@@ -25,6 +26,7 @@ export default function Component() {
     const [total, setTotal] = useState(0)
     const [isLoading, setIsLoading] = useState(false)
     const [loaded, setLoaded] = useState(false)
+    const [showError,setShowError] = useState(false)
 
     useEffect(() => {
         getTags()
@@ -95,7 +97,7 @@ export default function Component() {
             limit: 10
         }).then(res => {
             Taro.stopPullDownRefresh()
-
+            setShowError(false)
             setLoaded(true)
             setTotal((res as any).total)
             if (index == 1) {
@@ -106,6 +108,9 @@ export default function Component() {
             setIsLoading(false)
         }).catch(e => {
             Taro.stopPullDownRefresh()
+            if (pageIndex==1){
+                setShowError(true)
+            }
         })
     }
 
@@ -131,6 +136,9 @@ export default function Component() {
             {
                 user.isLogin && list && <FoodTimeline array={list} />
             }
+            {
+                user.isLogin && showError && <NoData refresh={() => { getList(1) }} />
+            }
             <View style={{ height: 60 }} />
             {
                 user.isLogin && <View className="center_line" style={{ height: list.length == 0 ? rpxToPx(304) : rpxToPx(364 * (list.length + 1) - 120) }} />

+ 2 - 2
src/features/food/FoodTimeline.tsx

@@ -36,8 +36,8 @@ export default function Component(props: { array: any }) {
         var urls:any = []
         list.map(item=>{
             urls.push({
-                url:item.cover.url,
-                type:item.cover.url.indexOf('mp4')!=-1?'video':'image'
+                url:item.media[0].url,
+                type:item.media[0].url.indexOf('mp4')!=-1?'video':'image'
             })
         })
         Taro.previewMedia({

+ 11 - 4
src/features/food/FoodTimelineItem.scss

@@ -5,8 +5,8 @@
 }
 
 .tags {
-    margin-left: 55px;
-    width: 144px;
+    margin-left: 45px;
+    width: 164px;
     display: flex;
     flex-direction: column;
     font-size: 24px;
@@ -15,6 +15,14 @@
     
 }
 
+.food_timeline_item_day{
+    font-size: 36px;
+    color: #fff;
+    font-weight: bold;
+    margin-bottom: 12px;
+    margin-bottom: -8px;
+}
+
 .tag-item{
     height: 48px;
     box-sizing: border-box;
@@ -25,11 +33,10 @@
     display: flex;
     align-items: center;
     justify-content: center;
-    margin-top: 24px;
+    margin-top: 20px;
 }
 
 .more_tag{
-    margin-top: 16px;
     height: 72px;
     width: 100%;
     line-height: 72px;

+ 27 - 16
src/features/food/FoodTimelineItem.tsx

@@ -25,7 +25,7 @@ export default function Component(props: { data: any, index: number, delete: Fun
     useEffect(() => {
         setDetail(props.data)
         if (props.index == 0) {
-            global.food_share_img_url = props.data.cover
+            global.food_share_img_url = props.data.media[0].url
         }
     }, [props.data])
 
@@ -39,11 +39,20 @@ export default function Component(props: { data: any, index: number, delete: Fun
 
     function showActionSheet() {
         Taro.showActionSheet({
-            itemList: [t('feature.common.action_sheet.delete')]
+            alertText: t('feature.food.action_sheet.edit_title'),
+            itemList: [t('feature.food.action_sheet.edit_pic'),
+            t('feature.food.action_sheet.share_pic'),
+            t('feature.common.action_sheet.delete')]
         })
             .then(res => {
                 switch (res.tapIndex) {
                     case 0:
+                        editPic();
+                        break;
+                    case 1:
+                        share()
+                        break;
+                    case 2:
                         Taro.showModal({
                             title: t('feature.common.modal.delete_item_title'),
                             content: t('feature.common.modal.delete_item_content'),
@@ -68,8 +77,7 @@ export default function Component(props: { data: any, index: number, delete: Fun
                 t('feature.food.action_sheet.tag'),
                 t('feature.food.action_sheet.start_time'),
                 t('feature.food.action_sheet.end_time'),
-                t('feature.food.action_sheet.edit_pic'),
-                t('feature.food.action_sheet.share_pic')]
+            ]
         })
             .then(res => {
                 switch (res.tapIndex) {
@@ -79,14 +87,14 @@ export default function Component(props: { data: any, index: number, delete: Fun
 
                     case 1:
                         {
-                            global.set_time = new Date().getTime()+24*3600*1000
+                            global.set_time = new Date().getTime() + 24 * 3600 * 1000
                             setIsStart(true)
                             setShowModal(true)
                         }
                         break;
                     case 2:
                         {
-                            global.set_time = new Date().getTime()+24*3600*1000
+                            global.set_time = new Date().getTime() + 24 * 3600 * 1000
                             setIsStart(false)
                             setShowModal(true)
                         }
@@ -108,7 +116,7 @@ export default function Component(props: { data: any, index: number, delete: Fun
 
     function editPic() {
         Taro.downloadFile({
-            url: detail.cover,
+            url: detail.media[0].url,
             success: (res) => {
                 Taro.editImage({
                     src: res.tempFilePath,
@@ -168,10 +176,11 @@ export default function Component(props: { data: any, index: number, delete: Fun
 
     function updatePic(url) {
         editFoodJournal({
-            cover: {
+            media: [{
                 url: url,
-                type: url.indexOf('mp4') != -1 ? 'video' : 'image'
-            }
+                type: url.indexOf('mp4') != -1 ? 'video' : 'image',
+                source: detail.media[0].source ? detail.media[0].source : 'album'
+            }]
         }, detail.id).then(res => {
             setDetail(res)
             setCount(count + 1)
@@ -185,7 +194,7 @@ export default function Component(props: { data: any, index: number, delete: Fun
 
     function share() {
         Taro.downloadFile({
-            url: detail.cover,
+            url: detail.media[0].url,
             success: (res) => {
                 Taro.showShareImageMenu({
                     path: res.tempFilePath
@@ -298,27 +307,29 @@ export default function Component(props: { data: any, index: number, delete: Fun
 
         <View style={{ flex: 1 }}>
             {
-                props.index == 0 && !detail.meal_tag && <View className="tags">
+                <View className="tags">
+                    <Text className="food_timeline_item_day">{TimeFormatter.getMonthDayByTimestamp(detail.start.timestamp)}</Text>
                     {
-                        common.meal_tags.map((item, index) => {
+                        props.index == 0 && !detail.meal_tag && common.meal_tags.map((item, index) => {
                             return index <= 2 ? <View className="tag-item" onClick={() => updateTag(index)}>
                                 <Text style={{ color: ColorType.food }}>{item.label}</Text>
                             </View> : <View />
 
                         })
                     }
-                    <View className="more_tag" onClick={() => { setShowTagModal(true) }}>更多标签</View>
+                    {props.index == 0 && !detail.meal_tag && <View className="more_tag" onClick={() => { setShowTagModal(true) }}>更多标签</View>}
                 </View>
             }
 
         </View>
         <View className="thumb_bg">
             {/* <Image className="thumb" src={detail.cover.url} mode="aspectFill" onClick={preview} /> */}
-            <Image className="thumb" src={detail.cover.url+'?x-oss-process=image/resize,w_300,limit_0'} mode="aspectFill" onClick={preview} />
+            <Image className="thumb" src={detail.media[0].url + '?x-oss-process=image/resize,w_300,limit_0'} mode="aspectFill" onClick={preview} />
             <View className="food_desc" onClick={operateActionSheet}>
-                <Text className="food_desc_text">{detail.start && TimeFormatter.getMonthDayByTimestamp(detail.start.timestamp)}</Text>
+                {/* <Text className="food_desc_text">{detail.start && TimeFormatter.getMonthDayByTimestamp(detail.start.timestamp)}</Text> */}
                 <Text className="food_desc_text">{detail.meal_tag && detail.meal_tag.label}</Text>
                 <Text className="food_desc_text">{detail.start && TimeFormatter.getTimeByTimestamp(detail.start.timestamp)}</Text>
+                <Text className="food_desc_text">{detail.end.timestamp && '~' + TimeFormatter.getTimeByTimestamp(detail.end.timestamp)}</Text>
                 {/* {
                     detail.end.timestamp && <Text>{'-' + getTime(detail.end.timestamp)}</Text>
                 } */}

+ 28 - 25
src/features/trackTimeDuration/components/Console.tsx

@@ -1,5 +1,5 @@
 
-import { View, Text, PickerView,ScrollView } from "@tarojs/components";
+import { View, Text, PickerView, ScrollView } from "@tarojs/components";
 import { useEffect, useRef, useState } from "react";
 import { TimeFormatter } from "@/utils/time_format";
 import { useDispatch, useSelector } from "react-redux";
@@ -36,7 +36,7 @@ export default function Component(props: { isNextStep?: boolean }) {
     const [fastPickerValue, setFastPickerValue] = useState([0, 0])
     const [sleepPickerValue, setSleepPickerValue] = useState([0, 0])
     const [isLoaded, setIsLoaded] = useState(false)
-    const [showPageContainer,setShowPageContainer] = useState(false)
+    const [showPageContainer, setShowPageContainer] = useState(false)
     const limitPickerRef = useRef(null)
     const durationPickerRef = useRef(null)
     const { t } = useTranslation()
@@ -104,7 +104,7 @@ export default function Component(props: { isNextStep?: boolean }) {
 
     }
 
-    function pageContainerDetail(){
+    function pageContainerDetail() {
         return layoutContent()
     }
 
@@ -120,12 +120,12 @@ export default function Component(props: { isNextStep?: boolean }) {
         // }} />);
         // global.showClockModal(true, node);
         var node = layoutContent()
-        global.showClockModal(true, node,testLayout());
+        global.showClockModal(true, node, testLayout());
     }
 
     function hidePicker() {
         var node = layoutContent()
-        global.showClockModal(false, node,null);
+        global.showClockModal(false, node, null);
         if (global.testInfotimer) {
             clearInterval(global.testInfotimer)
             global.testInfotimer = null
@@ -173,18 +173,18 @@ export default function Component(props: { isNextStep?: boolean }) {
         }
 
         return <ScrollView scrollY>
-            <View style={{ color: '#fff',  paddingLeft: 30, display: 'flex', flexDirection: 'column' }}>
-            <Text>check scenario:{isFast ? 'fast' : 'sleep'}</Text>
-            <Text>check type:{isStart ? 'start' : 'end'}</Text>
-            <Text style={{ marginTop: 10 }}>picker restriction</Text>
-            <Text style={{ marginLeft: 50 }}>min:{TimeFormatter.formatTimestamp(global.limit)}</Text>
-            <Text style={{ marginLeft: 50 }}>pick:{TimeFormatter.formatTimestamp(global.picker_time)}</Text>
-            <Text style={{ marginLeft: 50 }}>max{TimeFormatter.formatTimestamp(global.set_time)}</Text>
-            <Text style={{ marginTop: 10 }}>now:{TimeFormatter.formatTimestamp(new Date().getTime())}</Text>
-            <Text>elapsed:{TimeFormatter.calculateTimeDifference(global.picker_time, new Date().getTime())}</Text>
-            <Text style={{ marginTop: 10 }}>real start:{isStart ? '-' : TimeFormatter.formatTimestamp(isFast ? time.fast.real_start_time : time.sleep.real_start_time)}</Text>
-            <Text>real duration:{isStart ? '-' : TimeFormatter.calculateTimeDifference(isFast ? time.fast.real_start_time : time.sleep.real_start_time, new Date().getTime())}</Text>
-        </View>
+            <View style={{ color: '#fff', paddingLeft: 30, display: 'flex', flexDirection: 'column' }}>
+                <Text>check scenario:{isFast ? 'fast' : 'sleep'}</Text>
+                <Text>check type:{isStart ? 'start' : 'end'}</Text>
+                <Text style={{ marginTop: 10 }}>picker restriction</Text>
+                <Text style={{ marginLeft: 50 }}>min:{TimeFormatter.formatTimestamp(global.limit)}</Text>
+                <Text style={{ marginLeft: 50 }}>pick:{TimeFormatter.formatTimestamp(global.picker_time)}</Text>
+                <Text style={{ marginLeft: 50 }}>max{TimeFormatter.formatTimestamp(global.set_time)}</Text>
+                <Text style={{ marginTop: 10 }}>now:{TimeFormatter.formatTimestamp(new Date().getTime())}</Text>
+                <Text>elapsed:{TimeFormatter.calculateTimeDifference(global.picker_time, new Date().getTime())}</Text>
+                <Text style={{ marginTop: 10 }}>real start:{isStart ? '-' : TimeFormatter.formatTimestamp(isFast ? time.fast.real_start_time : time.sleep.real_start_time)}</Text>
+                <Text>real duration:{isStart ? '-' : TimeFormatter.calculateTimeDifference(isFast ? time.fast.real_start_time : time.sleep.real_start_time, new Date().getTime())}</Text>
+            </View>
         </ScrollView>
     }
 
@@ -197,7 +197,7 @@ export default function Component(props: { isNextStep?: boolean }) {
             limit = time.last_real_check_time
             global.limit = limit
             //当set_time秒数<=latest_record_time秒数时,最小限制时间戳需+1分钟
-            if (new Date(global.set_time).getSeconds() <= new Date(time.last_real_check_time).getSeconds() && global.set_time-time.last_real_check_time>60000) {
+            if (new Date(global.set_time).getSeconds() <= new Date(time.last_real_check_time).getSeconds() && global.set_time - time.last_real_check_time > 60000) {
                 debugger
                 limit = limit + 60 * 1000
             }
@@ -213,12 +213,12 @@ export default function Component(props: { isNextStep?: boolean }) {
 
         return <View className="modal_content">
             <LimitPickers ref={limitPickerRef} limit={limit} limitDay={8}
-            themeColor={color}
-            title={title}
-            onCancel={hidePicker} onChange={(e) => {
-                pickerConfirm(e)
-                hidePicker()
-            }} />
+                themeColor={color}
+                title={title}
+                onCancel={hidePicker} onChange={(e) => {
+                    pickerConfirm(e)
+                    hidePicker()
+                }} />
         </View>
     }
 
@@ -374,7 +374,10 @@ export default function Component(props: { isNextStep?: boolean }) {
                 value={isFast ? fastPickerValue : sleepPickerValue}
                 themeColor={color}
                 title={title}
-                showBtns={true} onCancel={() => { global.showClockModal2(false, durationPickerContent()); }} />
+                showBtns={true}
+                onCancel={() => {
+                    global.showClockModal2(false, durationPickerContent());
+                }} />
         </View>
     }
 

+ 3 - 0
src/services/http/request.ts

@@ -112,6 +112,9 @@ export async function request<T>(param: RequestParam): Promise<T> {
                 } else if (statusCode == 401) {
                     // global.postBtnUpdateStatus('idle')
                     //未登录或挤下线处理
+                    if (process.env.TARO_ENV=='weapp'){
+                        Taro.stopPullDownRefresh()
+                    }
                     global.dispatch(logoutSuccess());
                 } else if (statusCode == 500 && response.data.error_code == 'WX_STEP_PARSE_FAIL') {
                     //单独对计步第一次请求失败处理