Leon há 2 anos atrás
pai
commit
d2ae72ae09

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

@@ -82,6 +82,7 @@ export default {
     },
     feature: {
         common: {
+            action_sheet_cancel:'取消',
             picker_cancel_btn: '取消',
             picker_confirm_btn: '确定',
             wait_for_end: "待结束",
@@ -292,7 +293,7 @@ export default {
             album:'从相册选择',
             share_title:'我的饮食日记',
             prompt:'提示',
-            prompt_detail:'日列表顺序发生变化,点击刷新'
+            prompt_detail:'日列表顺序发生变化,点击刷新'
         },
         track_something: {
             btn_record: '记录',

+ 1 - 1
src/features/common/RecordItem.tsx

@@ -27,7 +27,7 @@ export default function Component(props: { children: React.ReactNode, onClick?:
             return;
         }
         Taro.showActionSheet({
-            itemList: [t('feature.common.action_sheet.delete')]
+            itemList: [t('feature.common.action_sheet.delete')],
         })
             .then(res => {
                 switch (res.tapIndex) {

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

@@ -183,7 +183,7 @@ export default function Component(props: { addItem: Function }) {
     return <View style={{ marginBottom: rpxToPx(60) }}>
         <View style={{ display: 'flex', width: rpxToPx(750), alignItems: 'center', justifyContent: 'center', flexDirection: 'column' }}>
             <View style={{ display: 'flex', flexDirection: 'column' }}>
-                <Slider />
+                {/* <Slider /> */}
                 {/* <View className='box11' onClick={()=>choose(true)}>{
                     imgUrl && <Image style={{ width: '100%', height: '100%' }} src={imgUrl} mode="aspectFill" />
                 }

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

@@ -187,7 +187,7 @@ export default function Component() {
                 <FoodConsole addItem={addItem} />
             }
             {
-                user.isLogin && list && <FoodTimeline array={list} refresh={()=>getList(1)}/>
+                user.isLogin && list && <FoodTimeline array={list} refresh={() => refreshData()} forceRefresh={() => getList(1)} />
             }
             {
                 user.isLogin && showError && <NoData refresh={() => { getList(1) }} />

+ 15 - 13
src/features/food/FoodTimeline.tsx

@@ -5,17 +5,18 @@ import { useEffect, useState } from 'react'
 import { delFoodJournal } from '@/services/foodJournal'
 import Taro from '@tarojs/taro'
 
-export default function Component(props: { array: any,refresh:Function }) {
+export default function Component(props: { array: any, refresh: Function, forceRefresh: Function }) {
     const [list, setList] = useState(props.array)
 
     useEffect(() => {
         setList(props.array)
-    }, [props.array,props.array.length])
+    }, [props.array, props.array.length])
 
     function del(index) {
         delFoodJournal(list[index].id).then(res => {
             var temps = list.splice(index, 1)
             setList(temps)
+            props.refresh()
         }).catch(e => {
 
         })
@@ -32,12 +33,12 @@ export default function Component(props: { array: any,refresh:Function }) {
     //     })
     // }
 
-    function preview(index){
-        var urls:any = []
-        list.map(item=>{
+    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'
+                url: item.media[0].url,
+                type: item.media[0].url.indexOf('mp4') != -1 ? 'video' : 'image'
             })
         })
         Taro.previewMedia({
@@ -46,7 +47,7 @@ export default function Component(props: { array: any,refresh:Function }) {
         })
     }
 
-    function updateItem(index,data){
+    function updateItem(index, data) {
         list[index] = data
         setList(list)
     }
@@ -54,11 +55,12 @@ export default function Component(props: { array: any,refresh:Function }) {
     return <View style={{ flexDirection: 'column', display: 'flex' }}>
         {
             list.map((item, index) => {
-                return <FoodTimelineItem data={item} index={index} key={index} 
-                delete={() => del(index)} 
-                preview={()=>preview(index)}
-                update={(data)=>updateItem(index,data)}
-                forceRefresh={()=>props.refresh()}
+                return <FoodTimelineItem data={item} index={index} key={index}
+                    delete={() => del(index)}
+                    preview={() => preview(index)}
+                    update={(data) => updateItem(index, data)}
+                    forceRefresh={() => props.forceRefresh()}
+                    refresh={() => props.refresh()}
                 />
             })
         }

+ 9 - 3
src/features/food/FoodTimelineItem.scss

@@ -12,7 +12,8 @@
     font-size: 24px;
     align-items: center;
     box-sizing: border-box;
-    
+    position: relative;
+    height: 304px;
 }
 
 .food_timeline_item_day{
@@ -20,8 +21,8 @@
     line-height: 36px;
     color: #fff;
     font-weight: bold;
-    margin-bottom: 12px;
-    margin-bottom: -9px;
+    // margin-bottom: 12px;
+    margin-bottom: -8px;
 }
 
 .tag-item{
@@ -38,6 +39,10 @@
 }
 
 .more_tag{
+    position: absolute;
+    left: 0;
+    right: 0;
+    bottom: 0;
     height: 72px;
     width: 100%;
     line-height: 72px;
@@ -45,6 +50,7 @@
     color: #fff;
     font-size: 20px;
     opacity: 0.4;
+    // background-color: red;
 }
 
 .thumb_bg {

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

@@ -15,7 +15,8 @@ import { baseUrl } from "@/services/http/api";
 
 export default function Component(props: {
     data: any, index: number,
-    delete: Function, preview: Function, update: Function, forceRefresh?: Function
+    delete: Function, preview: Function, update: Function,
+    forceRefresh: Function, refresh: Function
 }) {
     const common = useSelector((state: any) => state.common);
     const [detail, setDetail] = useState(props.data)
@@ -260,6 +261,9 @@ export default function Component(props: {
             if ((res as any).index_change) {
                 showRefreshAlert()
             }
+            else {
+                props.refresh()
+            }
 
 
         }).catch(e => {
@@ -274,7 +278,7 @@ export default function Component(props: {
             showCancel: false,
             success: function (res) {
                 if (res.confirm) {
-                    props.forceRefresh!()
+                    props.forceRefresh()
                 }
             }
         })

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

@@ -1,4 +1,4 @@
-let online = false;
+let online = true;
 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/'