Leon 2 jaren geleden
bovenliggende
commit
d12c7b0ced
3 gewijzigde bestanden met toevoegingen van 48 en 41 verwijderingen
  1. 45 38
      src/features/food/FoodConsole.tsx
  2. 2 2
      src/features/food/FoodTimelineItem.tsx
  3. 1 1
      src/services/http/api.js

+ 45 - 38
src/features/food/FoodConsole.tsx

@@ -43,7 +43,7 @@ export default function Component(props: { addItem: Function, firstItem: any })
     useEffect(() => {
         if (firstData &&
             firstData.mindful_mode == 'AWARE' &&
-            firstData.status != 'ABANDONED' &&
+            firstData.status != 'PART_COMPLETED' &&
             (!firstData.feel.post_meal || !firstData.feel.pre_meal)) {
             setLastUnFinished(true)
             setModeOn(true)
@@ -70,11 +70,11 @@ export default function Component(props: { addItem: Function, firstItem: any })
         }
 
         var params = {
-            event:'add_a_picture',
-            value:isAlbum?'choose_from_album':'use_camera',
+            event: 'add_a_picture',
+            value: isAlbum ? 'choose_from_album' : 'use_camera',
         }
 
-        saveFoodCache('create',params)
+        saveFoodCache('create', params)
 
         clearFile()
         Taro.chooseMedia({
@@ -84,11 +84,11 @@ export default function Component(props: { addItem: Function, firstItem: any })
             sourceType: [isAlbum ? 'album' : 'camera'],
             success: function (res) {
                 var params = {
-                    event:'add_a_picture',
-                    value:isAlbum?'choose_from_album_confirm':'use_camera_confirm',
+                    event: 'add_a_picture',
+                    value: isAlbum ? 'choose_from_album_confirm' : 'use_camera_confirm',
                 }
-        
-                saveFoodCache('create',params)
+
+                saveFoodCache('create', params)
 
                 var tempFilePath = res.tempFiles[0].tempFilePath
                 // Taro.editImage({
@@ -109,13 +109,13 @@ export default function Component(props: { addItem: Function, firstItem: any })
                     }
                 })
             },
-            fail:function(res){
+            fail: function (res) {
                 var params = {
-                    event:'add_a_picture',
-                    value:isAlbum?'choose_from_album_cancel':'use_camera_cancel',
+                    event: 'add_a_picture',
+                    value: isAlbum ? 'choose_from_album_cancel' : 'use_camera_cancel',
                 }
-        
-                saveFoodCache('create',params)
+
+                saveFoodCache('create', params)
             }
         })
     }
@@ -200,6 +200,9 @@ export default function Component(props: { addItem: Function, firstItem: any })
                 date: strDate
             },
             mindful_mode: modeOn ? 'AWARE' : 'NORMAL',
+            extra: {
+                event: getFoodCache('create')
+            }
             // extra:getFoodCache('create')
 
         }).then(res => {
@@ -221,19 +224,20 @@ export default function Component(props: { addItem: Function, firstItem: any })
     function modeChange(e) {
         setModeOn(e.detail.value)
         Taro.setStorageSync('food_switch', e.detail.value)
-        if (e.detail.value){
-            Taro.showToast({
-                icon:'success',
-                title:t('feature.food.mindful_switch_on')
-            })
-        }
+        // if (e.detail.value) {
+        //     Taro.showToast({
+        //         icon: 'success',
+        //         title: t('feature.food.mindful_switch_on'),
+        //         duration: 500
+        //     })
+        // }
 
         var params = {
-            event:'switch_toggle',
-            value:e.detail.value?'on':'off',
+            event: 'switch_toggle',
+            value: e.detail.value ? 'on' : 'off',
         }
 
-        saveFoodCache('create',params)
+        saveFoodCache('create', params)
     }
 
     function more() {
@@ -244,12 +248,12 @@ export default function Component(props: { addItem: Function, firstItem: any })
         jumpPage('/pages/common/H5?title=' + '' + '&url=' + resource[0].url)
     }
 
-    function getLineBottom(){
-        if (user.isLogin){
-            return props.firstItem?-rpxToPx(60):0
+    function getLineBottom() {
+        if (user.isLogin) {
+            return props.firstItem ? -rpxToPx(60) : 0
         }
         else {
-            return props.firstItem?0:rpxToPx(60)
+            return props.firstItem ? 0 : rpxToPx(60)
             // if (modeOn){
             //     return 0//-rpxToPx(60)
             // }
@@ -259,16 +263,16 @@ export default function Component(props: { addItem: Function, firstItem: any })
         }
     }
 
-    function clickSwitch(){
-        if (lastUnFinished){
+    function clickSwitch() {
+        if (lastUnFinished) {
             Taro.vibrateShort({
-                type:'heavy'
+                type: 'heavy'
             })
             Taro.showModal({
                 title: t('feature.common.prompt'),
-                content:t('feature.food.disable_switch_modal_title'),
-                confirmText:t('feature.food.disable_switch_modal_btn'),
-                showCancel:false
+                content: t('feature.food.disable_switch_modal_title'),
+                confirmText: t('feature.food.disable_switch_modal_btn'),
+                showCancel: false
             })
         }
     }
@@ -277,26 +281,29 @@ export default function Component(props: { addItem: Function, firstItem: any })
         <View className='food_console_box'>
             <View style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
                 <Text className='food_console_title'>感知模式</Text>
-                <Switch className='myswitch' onClick={clickSwitch} disabled={lastUnFinished} checked={modeOn} color={ColorType.food} style={{ marginRight: rpxToPx(40), opacity: lastUnFinished ? 0.4 : 1 }} onChange={modeChange} />
+                <Switch className='myswitch' onClick={clickSwitch} disabled={lastUnFinished} checked={modeOn} color={props.firstItem && props.firstItem.status == 'WAIT_FOR_POSTMEAL' ?ColorType.food:ColorType.fast} style={{ marginRight: rpxToPx(40), opacity: lastUnFinished ? 0.4 : 1 }} onChange={modeChange} />
             </View>
             {
                 modeOn && <View className='food_console_desc'>
-                    <View className='food_console_desc_point' 
-                    style={{ backgroundColor: ColorType.food,marginTop:props.firstItem && props.firstItem.status=='WAIT_FOR_POSTMEAL'?rpxToPx(46+18):rpxToPx(18) }} />
+                    <View className='food_console_desc_point'
+                        style={{
+                            backgroundColor: props.firstItem && props.firstItem.status == 'WAIT_FOR_POSTMEAL' ? ColorType.food : ColorType.fast,
+                            marginTop: props.firstItem && props.firstItem.status == 'WAIT_FOR_POSTMEAL' ? rpxToPx(46 + 18) : rpxToPx(18)
+                        }} />
                     {/* <View className='food_console_desc_point' style={{ backgroundColor: ColorType.food }} /> */}
                     <Text>{t('feature.food.sence_desc')}</Text>
                 </View>
             }
             {
                 !modeOn && <View className='food_console_desc_off'>
-                    
+
                     <Text>{t('feature.food.sence_desc_off')}</Text>
                     {/* <Text style={{ color: ColorType.food }} onClick={more}>{t('feature.food.learn_more')}</Text> */}
                 </View>
             }
         </View>
         {
-            !lastUnFinished && <View style={{ display: 'flex',position:'relative', width: rpxToPx(750), alignItems: 'center', justifyContent: 'center', flexDirection: 'column' }}>
+            !lastUnFinished && <View style={{ display: 'flex', position: 'relative', width: rpxToPx(750), alignItems: 'center', justifyContent: 'center', flexDirection: 'column' }}>
                 <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
                     <View className='camera_bg' onClick={() => choose(false)}>
                         <Image src={require('@assets/images/camera2.png')} className='camera_icon' />
@@ -309,7 +316,7 @@ export default function Component(props: { addItem: Function, firstItem: any })
                     }
                     {modeOn && <Slider edit={true} />}
                 </View>
-                <View className='center_line2' style={{bottom:getLineBottom()}}/>
+                <View className='center_line2' style={{ bottom: getLineBottom() }} />
             </View>
         }
 

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

@@ -310,7 +310,7 @@ export default function Component(props: {
 
     function abandon() {
         editFoodJournal({
-            status: 'ABANDONED'
+            status: 'PART_COMPLETED'
         }, detail.id).then(res => {
             props.forceRefresh()
         }).catch(e => {
@@ -378,7 +378,7 @@ export default function Component(props: {
 
     function more() {
         Taro.showActionSheet({
-            itemList: ['重新开始']
+            itemList: ['开始新记录']
         }).then(res => {
             if (res.tapIndex == 0) {
                 abandon()

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

@@ -1,4 +1,4 @@
-let online = true;
+let online = false;
 export let baseUrl = online ? 'https://api.fast.liveplus.fun' : 'https://api.fast.dev.liveplus.fun';
 export let imgUrl = online
     ? 'https://api.fast.liveplus.fun/static/image/'