leon 1 год назад
Родитель
Сommit
710b7e06e6

+ 12 - 4
src/pages/clock/ClockIndex.tsx

@@ -22,6 +22,7 @@ import TimeRecord from "@/_record/pages/time_record";
 import RecordTime from "./components/record_time";
 import RecordLog from "./components/record_log";
 import PickerCard from "@/_record/components/picker_card";
+import LogPublish from "./components/log_publish";
 
 var timer
 let useNavigation, LinearGradient;
@@ -58,7 +59,7 @@ export default function ClockIndex() {
     const [showEndDatePicker, setShowEndDatePicker] = useState(false)
     const [pickerTitle, setPickerTitle] = useState('')
     const [pickerValue, setPickerValue] = useState<any>(null)
-    const [pickerFunc, setPickerFunc] = useState<any>(null)
+    const [showLogPublish, setShowLogPublish] = useState(false)
 
     dayjs.locale(global.language == 'en' ? 'en' : 'zh-cn');
 
@@ -238,7 +239,7 @@ export default function ClockIndex() {
     }
 
     function swiperHeight() {
-        return screenHeight - navigationBarHeight - rpxToPx(94) - rpxToPx(112) - bottomSafeAreaHeight+4
+        return screenHeight - navigationBarHeight - rpxToPx(94) - rpxToPx(112) - bottomSafeAreaHeight + 4
     }
 
     if (!loaded) return <View />
@@ -257,10 +258,10 @@ export default function ClockIndex() {
                 <RecordTime scenario="SLEEP" contentHeight={swiperHeight()} showPicker={showPicker} hidePicker={hidePicker} />
             </SwiperItem>
             <SwiperItem>
-                <RecordLog scenario="MEAL" contentHeight={swiperHeight()} />
+                <RecordLog scenario="MEAL" contentHeight={swiperHeight()} showPublish={()=>setShowLogPublish(true)}/>
             </SwiperItem>
             <SwiperItem>
-                <RecordLog scenario="ACTIVITY" contentHeight={swiperHeight()} />
+                <RecordLog scenario="ACTIVITY" contentHeight={swiperHeight()} showPublish={()=>setShowLogPublish(true)}/>
             </SwiperItem>
         </Swiper>
         {
@@ -327,6 +328,13 @@ export default function ClockIndex() {
                 />
             }
         </Block>
+        <Block>
+            {
+                showLogPublish && <LogPublish onClose={() => {
+                    setShowLogPublish(false)
+                }} />
+            }
+        </Block>
         {
             process.env.TARO_ENV == 'weapp' && <TabBar index={0} />
         }

+ 8 - 0
src/pages/clock/components/log_publish.scss

@@ -0,0 +1,8 @@
+.log_publish_bg{
+    position: fixed;
+    left: 0;
+    right: 0;
+    width: 100vw;
+    height: 100vh;
+    z-index: 10000;
+}

+ 121 - 0
src/pages/clock/components/log_publish.tsx

@@ -0,0 +1,121 @@
+import { View } from "@tarojs/components";
+import './log_publish.scss'
+import { rpxToPx } from "@/utils/tools";
+import { useState } from "react";
+import { useSelector } from "react-redux";
+import Taro from "@tarojs/taro";
+import { IconClose } from "@/components/basic/Icons";
+
+let useRoute;
+let useNavigation;
+let LinearGradient;
+if (process.env.TARO_ENV == 'rn') {
+    useRoute = require("@react-navigation/native").useRoute
+    useNavigation = require("@react-navigation/native").useNavigation
+    LinearGradient = require('react-native-linear-gradient').default
+}
+
+export default function LogPublish(props: { onClose: any }) {
+    const systemInfo: any = Taro.getWindowInfo ? Taro.getWindowInfo() : Taro.getSystemInfoSync();
+    const navigationBarHeight = systemInfo.statusBarHeight + 44;
+    const screenHeight = systemInfo.screenHeight
+
+    const [showChoose, setShowChoose] = useState(false)
+    const record = useSelector((state: any) => state.record);
+
+    function getBackground() {
+        var time = record.time
+        if (!time) return '#fff'
+        const { background_colors } = time
+        if (!background_colors) {
+            return '#fff'
+        }
+        else if (background_colors.length == 1) {
+            return background_colors[0]
+        }
+        return `linear-gradient(to bottom, ${background_colors[0]}, ${background_colors[1]})`
+    }
+
+    function bgView() {
+        if (process.env.TARO_ENV == 'weapp') {
+            return <View className="main_bg" style={{ background: getBackground() }} />
+        }
+        var time = record.time
+        if (!time) return <View />
+        const { background_colors } = time
+        if (!background_colors) {
+            return <View />
+        }
+        else if (background_colors.length == 1) {
+            return <View />
+        }
+        return <LinearGradient style={{
+            position: 'absolute',
+            left: 0,
+            top: 0,
+
+            width: rpxToPx(750),
+            height: screenHeight,
+            zIndex: 0,
+            pointerEvents: 'none'
+        }}
+            colors={[background_colors[0], background_colors[1]]}
+            start={{ x: 0, y: 0 }}
+            end={{ x: 0, y: 1 }} pointerEvents="none" />
+    }
+
+
+    return <View className="log_publish_bg" style={{ position: 'relative', overflow: showChoose ? 'hidden' : 'visible' }}>
+        {
+            bgView()
+        }
+        <View className="navi_bar" style={{ height: navigationBarHeight, zIndex: 1000 }}>
+            <View style={{
+                position: 'absolute',
+                left: 0,
+                right: 0,
+                bottom: 0,
+                height: 44,
+                display: 'flex',
+                alignItems: 'center',
+                justifyContent: 'center'
+            }}>
+                <View style={{
+                    position: 'absolute',
+                    width: rpxToPx(92),
+                    height: rpxToPx(64),
+                    left: 22,
+                    top: 22 - rpxToPx(32)
+                }}
+                    onClick={() => {
+                        props.onClose()
+                        // if (showResult) {
+                        //     process.env.TARO_ENV == 'weapp' ? Taro.navigateBack() : navigation.goBack()
+                        //     return
+                        // }
+                        // if (chooseTitle.length > 0 && step == 0) {
+                        //     setStep(2)
+                        //     return
+                        // }
+                        // if (step == 2 && (desc.length > 0 || pics.length > 0)) {
+                        //     showAlert({
+                        //         title: t('health.back_no_save'),
+                        //         content: '',
+                        //         showCancel: true,
+                        //         cancelText: t('health.cancel'),
+                        //         confirmText: t('health.exit'),
+                        //         confirm: () => {
+                        //             process.env.TARO_ENV == 'weapp' ? Taro.navigateBack() : navigation.goBack()
+                        //         }
+                        //     })
+                        //     return
+                        // }
+                        // process.env.TARO_ENV == 'weapp' ? Taro.navigateBack() : navigation.goBack()
+                    }}>
+                    <IconClose color={"#000"} width={rpxToPx(64)} height={rpxToPx(64)} />
+                </View>
+            </View>
+        </View>
+        <View style={{ height: navigationBarHeight }} />
+    </View>
+}

+ 8 - 6
src/pages/clock/components/record_log.tsx

@@ -38,7 +38,9 @@ if (process.env.TARO_ENV == 'rn') {
 }
 
 export default function RecordLog(props: {
-    scenario, contentHeight: number, imgs?: any, only_text?: any, quick?: any, join_id?: any,
+    scenario,
+    showPublish: any,
+    contentHeight: number, imgs?: any, only_text?: any, quick?: any, join_id?: any,
     id?: any,
     edit?: any,
     check_in?: any
@@ -572,11 +574,11 @@ export default function RecordLog(props: {
                         tags.map((item, index) => {
                             return <NewButton key={index} type={NewButtonType.custom}
                                 onClick={() => {
-                                    setChooseTitle(item.title)
-                                    setPostCount(item.log_count + 1)
-                                    setStep(2)
-                                    setSelTag(item)
-                                    // setShowChoose(true)
+                                    // setChooseTitle(item.title)
+                                    // setPostCount(item.log_count + 1)
+                                    // setStep(2)
+                                    // setSelTag(item)
+                                    props.showPublish()
                                 }}>
                                 <View key={index} className="operate_item h34"
                                     style={{ backgroundColor: MainColorType.white_25 }}