Leon 2 năm trước cách đây
mục cha
commit
d22d660a12

+ 20 - 1
src/components/input/Slider.scss

@@ -92,6 +92,8 @@
     align-items: center;
     justify-content: center;
     pointer-events: none;
+    // background-color: red;
+    // opacity: 0.5;
 }
 
 .slider-text {
@@ -171,10 +173,27 @@
     font-size: 32px;
     line-height: 32px;
     font-weight: bold;
-    color: $foodColor;
+    color: $fastColor;
 }
 
 .slider-tip-desc {
+    margin-top: 12px;
+    font-size: 20px;
+    line-height: 24px;
+    background: linear-gradient(90deg, $fastColor 0%, #fff 100%);
+    -webkit-background-clip: text;
+    background-clip: text;
+    color: transparent;
+}
+
+.slider-tip-title-post {
+    font-size: 32px;
+    line-height: 32px;
+    font-weight: bold;
+    color: $foodColor;
+}
+
+.slider-tip-desc-post {
     margin-top: 12px;
     font-size: 20px;
     line-height: 24px;

+ 23 - 11
src/components/input/Slider.tsx

@@ -8,13 +8,15 @@ import { useSelector } from 'react-redux';
 import { useTranslation } from 'react-i18next';
 
 var currentValue = 0;
-export default function (props: { onChanged?: Function, value?: number, edit?: boolean, isPreMeal?: boolean, id?: string }) {
+var lastValue = 0;
+export default function (props: { onChanged?: Function, value?: number, edit?: boolean, isPreMeal?: boolean, isPostMeal?: boolean, id?: string }) {
     const sliderWidth = 578;
     const [brightness, setBrightness] = useState(props.value ? props.value * 10 : 0);
     const [isSliding, setIsSliding] = useState(false);
     const [value, setValue] = useState(props.value ? props.value : 0)
     const [startX, setStartX] = useState(0);
     const common = useSelector((state: any) => state.common);
+    const [showArrow, setShowArrow] = useState(true)
     const { t } = useTranslation()
 
     useEffect(() => {
@@ -25,6 +27,7 @@ export default function (props: { onChanged?: Function, value?: number, edit?: b
 
     const handleTouchStart = (event) => {
         setIsSliding(true);
+        setShowArrow(false);
         setStartX(event.touches[0].clientX);
     };
 
@@ -43,8 +46,15 @@ export default function (props: { onChanged?: Function, value?: number, edit?: b
             setStartX(touchX)
             setBrightness(brightnessValue);
             currentValue = brightnessValue;
+            var data = calculateNumber(brightnessValue)
+            if (lastValue != data && data == 5) {
+                Taro.vibrateShort({
+                    type: 'heavy'
+                })
+            }
+            lastValue = data
 
-            setValue(calculateNumber(brightnessValue))
+            setValue(data)
         }
     };
 
@@ -65,6 +75,7 @@ export default function (props: { onChanged?: Function, value?: number, edit?: b
                         props.onChanged && props.onChanged(value);
                     }
                     else {
+                        setShowArrow(true)
                         if (props.isPreMeal) {
                             setStartX(0);
                             setBrightness(0)
@@ -95,6 +106,7 @@ export default function (props: { onChanged?: Function, value?: number, edit?: b
                     confirmText: '好的',
                     success: function (res) {
                         if (res.confirm) {
+                            setShowArrow(true)
                             setStartX(0);
                             setBrightness(0)
                             setValue(0)
@@ -176,31 +188,31 @@ export default function (props: { onChanged?: Function, value?: number, edit?: b
             onTouchMove={handleTouchMove}
             onTouchEnd={handleTouchEnd}>
             <View className='slider-tip-bg' style={{ width: (100 - brightness) * 0.01 * rpxToPx(sliderWidth - 120) + rpxToPx(28) }}>
-                <Text className='slider-tip-title'>{props.isPreMeal || !props.onChanged ?
+                <Text className={value < 5 ? 'slider-tip-title' : 'slider-tip-title-post'}>{value < 5 ?
                     t('feature.food.slider_tip_pre_meal_title') :
                     t('feature.food.slider_tip_post_meal_title')}</Text>
-                <Text className='slider-tip-desc'>{props.isPreMeal || !props.onChanged ?
+                <Text className={value < 5 ? 'slider-tip-desc' : 'slider-tip-desc-post'}>{value < 5 ?
                     t('feature.food.slider_tip_pre_meal_desc') :
                     t('feature.food.slider_tip_post_meal_desc')}</Text>
             </View>
             <View className='slider-item-content'>
-                <View className='slider-item-bg' style={{ width: brightness * 0.01 * rpxToPx(sliderWidth - 126) + rpxToPx(112) }}>
-                    <View className='slider-item' style={{
-                        width: brightness * 0.01 * rpxToPx(sliderWidth - 126) + rpxToPx(112)+1,
+                <View className='slider-item-bg' style={{ width: brightness * 0.01 * rpxToPx(sliderWidth - 126) + rpxToPx(112),
+                    backgroundColor: value==5?'#fff':value<5?ColorType.fast:ColorType.food}}>
+                    {/* <View className='slider-item' style={{
+                        width: brightness * 0.01 * rpxToPx(sliderWidth - 126) + rpxToPx(112) + 1,
                         backgroundColor: brightness <= 50 ? ColorType.fast : ColorType.food,
                         opacity: calculateOpacity(brightness),
                     }}>
-
-                    </View>
+                    </View> */}
 
 
                 </View>
             </View>
             {
-                isSliding || value != 0 ? <View className='slider-text-bg'>
+                !showArrow ? <View className='slider-text-bg'>
                     <Text className='slider-text'>{value}</Text>
                 </View> :
-                    <View className='slider-arrow-bg'>
+                    <View className='slider-arrow-bg' style={{ left: props.isPostMeal ? brightness * 0.01 * rpxToPx(sliderWidth - 120) : 0 }}>
                         <Image src={require('@assets/images/arrow4.png')} className='slider-arrow' />
                     </View>
             }

+ 31 - 8
src/features/food/FoodTimeline.tsx

@@ -35,14 +35,37 @@ export default function Component(props: { array: any, refresh: Function, forceR
 
     function preview(index) {
         var urls: any = []
-        list.map(item => {
-            urls.push({
-                url: item.media[0].url,
-                type: item.media[0].url.indexOf('mp4') != -1 ? 'video' : 'image'
+        //微信限制 最多50张
+        if (list.length <= 50) {
+            list.map(item => {
+                urls.push({
+                    url: item.media[0].url,
+                    type: item.media[0].url.indexOf('mp4') != -1 ? 'video' : 'image'
+                })
             })
-        })
+        }
+        else {
+
+            var begin = index - 20 < 0 ? 0 : index - 20
+            var end = index + 20 > list.length - 1 ? list.length - 1 : index + 20
+            for (var i = begin; i <= end; i++) {
+                var item = list[i]
+                urls.push({
+                    url: item.media[0].url,
+                    type: item.media[0].url.indexOf('mp4') != -1 ? 'video' : 'image'
+                })
+            }
+        }
+
+        var currentUrl = list[index].media[0].url
+        var page = 0;
+        for (var i = 0; i < urls.length; i++) {
+            if (currentUrl == urls[i].url) {
+                page = i
+            }
+        }
         Taro.previewMedia({
-            current: index,
+            current: page,
             sources: urls
         })
     }
@@ -60,8 +83,8 @@ export default function Component(props: { array: any, refresh: Function, forceR
                     preview={() => preview(index)}
                     update={(data) => updateItem(index, data)}
                     forceRefresh={() => props.forceRefresh()}
-                    refresh={() => {props.refresh();}}
-                    isLast={index==list.length-1}
+                    refresh={() => { props.refresh(); }}
+                    isLast={index == list.length - 1}
                 />
             })
         }

+ 1 - 1
src/features/food/FoodTimelineItem.tsx

@@ -390,7 +390,7 @@ export default function Component(props: {
         {
             detail.mindful_mode == 'AWARE' && detail.status == 'WAIT_FOR_POSTMEAL' &&
             <View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', marginBottom: rpxToPx(60), position: 'relative' }}>
-                <Slider onChanged={(value) => { updateFeel(value, false) }} value={detail.feel.pre_meal} isPreMeal={false} />
+                <Slider onChanged={(value) => { updateFeel(value, false) }} value={detail.feel.pre_meal} isPreMeal={false} isPostMeal={true}/>
                 <Image src={require('@assets/images/more-vertical.png')} className="food_timeline_more" onClick={more} />
             </View>
         }

+ 1 - 0
src/features/trackSomething/components/MetricItem.scss

@@ -67,6 +67,7 @@
     width: 40px;
     height: 40px;
     opacity: 0.2;
+    margin-left: -10px;
 }
 
 .operate {

+ 12 - 1
src/services/common.tsx

@@ -1,5 +1,5 @@
 import { setResources, setConfigs } from "@/store/common";
-import { API_DEL_SESSION, API_GLOBAL_CONFIGS, API_STATIC_RESOURCES, API_UPLOAD_SESSION } from "./http/api";
+import { API_CONFIGS, API_DEL_SESSION, API_GLOBAL_CONFIGS, API_STATIC_RESOURCES, API_UPLOAD_SESSION } from "./http/api";
 import { request } from "./http/request";
 import Taro from "@tarojs/taro";
 
@@ -25,6 +25,17 @@ export const gobalConfigs = () => (dispatch: any) => {
     })
 }
 
+export const getConfigs = (params) => (dispatch: any) => {
+    request({
+        url: API_CONFIGS, method: 'GET', data: {
+            keys: 'time_duration'
+        }
+    }).then(res => {
+        // resolve(res);
+        dispatch(setConfigs(res));
+    })
+}
+
 export const uploadSessionKey = (params) => {
     request({
         url: API_UPLOAD_SESSION, method: 'POST', data: {

+ 1 - 0
src/services/http/api.js

@@ -14,6 +14,7 @@ export const API_LOGOUT = `${baseUrl}/api/user/logout`
 export const API_CLEAR_USER = `${baseUrl}/api/user/account`
 export const API_STATIC_RESOURCES = `${baseUrl}/api/static-resource-urls`
 export const API_GLOBAL_CONFIGS = `${baseUrl}/api/system/global-configs`
+export const API_CONFIGS = `${baseUrl}/api/system/configs`
 export const API_USER_INFO = `${baseUrl}/api/user/info`
 export const API_CLEAR_FAST = `${baseUrl}/api/clear/fasting`
 export const API_CLEAR_SLEEP = `${baseUrl}/api/sleep/clear-my-data`