Leon 2 年 前
コミット
305a83076d

+ 4 - 0
src/components/basic/Buttons.scss

@@ -63,6 +63,7 @@
     display: flex;
     align-items: center;
     justify-content: center;
+    flex-direction: row;
 }
 
 .textClass {
@@ -72,4 +73,7 @@
 
 .outlined{
     box-sizing: border-box;
+    align-items: center;
+    justify-content: center;
+    flex-direction: row;
 }

+ 27 - 13
src/components/basic/Buttons.tsx

@@ -3,6 +3,9 @@ import './Buttons.scss'
 import { ButtonType, ComponentStatus } from "../../utils/types";
 
 import { Button as RNButton } from 'react-native';
+import { AtActivityIndicator } from 'taro-ui';
+import "taro-ui/dist/style/components/activity-indicator.scss";
+import 'taro-ui/dist/style/components/loading.scss';
 
 
 
@@ -21,12 +24,13 @@ export default function Buttons(props: { title: string, type?: ButtonType, statu
 export default function Buttons(props: {
     title: string,
     type?: ButtonType,
-    className?:any,
+    className?: any,
     onClick: () => void,
     disabled?: boolean,
     lowLight?: boolean,
     openType?: string,
     btnStyle?: any,
+    showLoading?: boolean
 }) {
 
     function onClick() {
@@ -40,13 +44,13 @@ export default function Buttons(props: {
 
     if (props.type == ButtonType.text) {
         mainClass = 'texted'
-        
+
         return <View style={{ opacity: (props.lowLight || props.disabled) ? 0.4 : 1 }} onClick={onClick}>
             <Text
                 style={{
                     ...props.btnStyle,
-                    fontWeight:500,
-                }} className={props.className?props.className:''}>{props.title}</Text>
+                    fontWeight: 500,
+                }} className={props.className ? props.className : ''}>{props.title}</Text>
         </View>
     }
 
@@ -56,30 +60,40 @@ export default function Buttons(props: {
 
         return (
             <View className={mainClass} style={{ ...props.btnStyle, opacity: props.lowLight ? 0.4 : 1 }} onClick={onClick}>
+                {
+                    props.showLoading && <View style={{ marginBottom: 2, marginRight: 5 }}>
+                        <AtActivityIndicator size={32} color="#000" />
+                    </View>
+                }
                 <Text
 
                     style={{
                         color: props.btnStyle.color,
                         fontSize: props.btnStyle.fontSize,
-                        fontWeight:500,
-                        marginBottom:2
+                        fontWeight: 500,
+                        marginBottom: 2
                     }}>{props.title}</Text>
             </View>
         )
     }
-    else {
-        mainClass = 'puretext'
-        textClass = 'puretext_text'
-    }
+    // else {
+    //     mainClass = 'puretext'
+    //     textClass = 'puretext_text'
+    // }
     return (
-        <View className={mainClass} style={{ ...props.btnStyle, opacity: props.lowLight ? 0.4 : 1  }} onClick={onClick}>
+        <View className={mainClass} style={{ ...props.btnStyle, opacity: props.lowLight ? 0.4 : 1 }} onClick={onClick}>
+            {
+                props.showLoading && <View style={{ marginBottom: 2, marginRight: 5 }}>
+                    <AtActivityIndicator size={32} color="#000" />
+                </View>
+            }
             <Text
                 // onClick={onClick}
                 style={{
                     color: props.btnStyle.color,
                     fontSize: props.btnStyle.fontSize,
-                    fontWeight:500,
-                    marginBottom:2
+                    fontWeight: 500,
+                    marginBottom: 2
                 }}>{props.title}</Text>
         </View>
         // <View  onClick={onClick}>

+ 21 - 16
src/features/common/PostBtn.tsx

@@ -1,5 +1,6 @@
 import Buttons from "@/components/basic/Buttons"
 import { ButtonType } from "@/utils/types"
+import { View } from "@tarojs/components"
 import { useEffect, useState } from "react"
 
 export default function Component(props: {
@@ -11,10 +12,19 @@ export default function Component(props: {
 }) {
     //idle normal abnormal
     const [btnStatus, setBtnStatus] = useState('idle')
+    const [timer,setTimer] = useState(null)
 
     useEffect(() => {
         if (btnStatus == 'normal') {
-            // setT
+            var t = setTimeout(()=>{
+                setBtnStatus('abnormal')
+            },500)
+            setTimer(t as any)
+        }
+        else if (btnStatus == 'idle'){
+            if (timer){
+                clearTimeout(timer)
+            }
         }
     }, [btnStatus])
 
@@ -34,21 +44,16 @@ export default function Component(props: {
         props.onClick();
     }
 
-    function getLowLight() {
-        var isLowLight = props.lowLight ? props.lowLight : false;
-        if (btnStatus != 'idle') {
-            isLowLight = true;
-        }
-        return isLowLight;
-    }
-
     return (
-        <Buttons title={props.title} type={props.type}
-            lowLight={getLowLight()}
-            onClick={click}
-            disabled={btnStatus != 'idle'}
-            // lowLight={btnStatus != 'idle'}
-            btnStyle={props.btnStyle}
-        />
+        <View style={{ opacity: btnStatus == 'idle' ? 1 : 0.4 }}>
+            <Buttons title={props.title} type={props.type}
+                lowLight={props.lowLight ? props.lowLight : false}
+                onClick={click}
+                disabled={btnStatus != 'idle'}
+                showLoading={btnStatus=='abnormal'}
+                // lowLight={btnStatus != 'idle'}
+                btnStyle={props.btnStyle}
+            />
+        </View>
     )
 }

+ 12 - 10
src/features/common/SpecBtns.tsx

@@ -13,8 +13,9 @@ export const StartFastBtn = (props: { onClick: Function, isLoading?: boolean })
                 height: 50,
                 borderRadius: 25,
                 backgroundColor: '#AAFF00',
-                paddingLeft: 40,
-                paddingRight: 40,
+                width:160,
+                // paddingLeft: 40,
+                // paddingRight: 40,
                 color: 'black',
                 fontSize: 20,
                 fontWeight:500,
@@ -35,8 +36,9 @@ export const StartSleepBtn = (props: { onClick: Function, lowLight?: boolean, is
                 height: 50,
                 borderRadius: 25,
                 backgroundColor: '#00FFFF',
-                paddingLeft: 40,
-                paddingRight: 40,
+                width:160,
+                // paddingLeft: 40,
+                // paddingRight: 40,
                 color: 'black',
                 fontWeight:500,
                 fontSize: 20,
@@ -60,8 +62,9 @@ export const EndSleepBtn = (props: { onClick: Function, lowLight?: boolean, isLo
                 borderColor: '#00FFFF',
                 borderWidth: 2,
                 borderStyle: 'solid',
-                paddingLeft: 40,
-                paddingRight: 40,
+                width:160,
+                // paddingLeft: 40,
+                // paddingRight: 40,
                 color: '#00FFFF',
                 fontWeight:500,
                 fontSize: 20,
@@ -85,8 +88,9 @@ export const EndFastBtn = (props: { onClick: Function, lowLight?: boolean, isLoa
                 borderColor: '#AAFF00',
                 borderWidth: 2,
                 borderStyle: 'solid',
-                paddingLeft: 40,
-                paddingRight: 40,
+                width:160,
+                // paddingLeft: 40,
+                // paddingRight: 40,
                 color: '#AAFF00',
                 fontSize: 20,
                 fontWeight:500,
@@ -133,8 +137,6 @@ export const RecordMetricBtn = (props: { onClick: Function, title: string,themeC
                 boxSizing: 'border-box',
                 borderRadius: 21,
                 backgroundColor: props.themeColor,
-                paddingLeft: 40,
-                paddingRight: 40,
                 color: 'black',
                 fontSize: 20,
                 fontWeight:500,

+ 0 - 1
src/pages/common/RecordsHistory.config.ts

@@ -1,6 +1,5 @@
 export default definePageConfig({
     "disableScroll": false,
-    "pullRefresh":true,
     "navigationBarTitleText":"",
     "enablePullDownRefresh":true
 })

+ 15 - 0
src/pages/common/RecordsHistory.scss

@@ -0,0 +1,15 @@
+.no_records_bg{
+    position: absolute;
+    left: 0;
+    top: 0;
+    right: 0;
+    height: 80vh;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+}
+
+.no_records{
+    color: #fff;
+    font-size: 72px;
+}

+ 10 - 0
src/pages/common/RecordsHistory.tsx

@@ -12,6 +12,7 @@ import NoData from "@/components/view/NoData";
 import { NaviBarTitleShowType, TemplateType } from "@/utils/types";
 import { useSelector } from "react-redux";
 import RecordFastSleep from "@/features/trackTimeDuration/components/RecordFastSleep";
+import './RecordsHistory.scss'
 
 export default function Page() {
     const router = useRouter();
@@ -27,6 +28,7 @@ export default function Page() {
     const [modalDetail, setModalDetail] = useState<any>({})
     const [total, setTotal] = useState(0)
     const [isLoading, setIsLoading] = useState(false)
+    const [loaded,setLoaded] = useState(false)
     const user = useSelector((state: any) => state.user);
 
 
@@ -101,6 +103,7 @@ export default function Page() {
             }).then(res => {
                 Taro.stopPullDownRefresh()
                 setTriggered(false)
+                setLoaded(true)
                 setTotal((res as any).total)
                 if (page == 1) {
                     setRecords((res as any).data)
@@ -120,6 +123,7 @@ export default function Page() {
             ).then(res => {
                 Taro.stopPullDownRefresh()
                 setTriggered(false)
+                setLoaded(true)
                 setTotal((res as any).total)
                 if (page == 1) {
                     setRecords((res as any).data)
@@ -139,6 +143,7 @@ export default function Page() {
             ).then(res => {
                 Taro.stopPullDownRefresh()
                 setTriggered(false)
+                setLoaded(true)
                 setTotal((res as any).total)
                 if (page == 1) {
                     setRecords((res as any).data)
@@ -231,6 +236,11 @@ export default function Page() {
             more={() => { more() }}
             titleShowStyle={NaviBarTitleShowType.scrollToShow}
         />
+        {
+            loaded && records.length == 0 && <View className="no_records_bg">
+                <Text className="no_records">无记录</Text>
+            </View>
+        }
 
         {
             showModal && modalDetail