Leon 2 jaren geleden
bovenliggende
commit
0187566ea7

+ 2 - 2
src/components/layout/Box.tsx

@@ -11,7 +11,7 @@ export default function Component(props: {
 }) {
     switch (props.type) {
         case BoxType.outline:
-            return <View style={{display:'flex',flexShrink:0}}>
+            return <View>
                 {props.header ? props.header : null}
                 <View className="box-outline" style={{ ...props.style }}>
                     {
@@ -21,7 +21,7 @@ export default function Component(props: {
                 </View>
             </View>
     }
-    return <View  style={{display:'flex',flexShrink:0}}>
+    return <View>
         {props.header ? props.header : null}
         <View className="box-container" style={{ ...props.style }}>
             {

+ 6 - 1
src/components/layout/layout.scss

@@ -19,9 +19,14 @@
     margin-left: 46px;
     font-size: 72px;
     line-height: 72px;
+    font-weight: 500;
+}
+
+.layout_title_view{
+    display: flex;
+    flex-shrink: 0;
     margin-top: 10px;
     margin-bottom: 10px;
-    font-weight: 500;
 }
 
 .grid_bg {

+ 28 - 8
src/components/layout/layout.tsx

@@ -2,7 +2,7 @@ import { ScrollView, View, Text } from "@tarojs/components";
 import './layout.scss'
 import { NaviBarTitleShowType, TemplateType } from "@/utils/types";
 import { useEffect, useState } from "react";
-import Taro from "@tarojs/taro";
+import Taro, { usePageScroll } from "@tarojs/taro";
 
 
 
@@ -37,30 +37,43 @@ export default function Layout(props: {
 
     }
 
+    usePageScroll((e) => {
+        if (props.titleShowStyle == NaviBarTitleShowType.scrollToShow) {
+            if (e.scrollTop > 70) {
+                setShowTitle(true)
+            }
+            else {
+                setShowTitle(false)
+            }
+        }
+    })
+
 
     switch (type) {
         case TemplateType.list:
             return <ScrollView className="layout_container"
-                style={{WebkitOverflowScrolling:'auto'}}
+                style={{ WebkitOverflowScrolling: 'auto' }}
                 onScroll={onScroll}
                 scrollY refresherEnabled={true}
                 refresherThreshold={100} refresherBackground="#000"
                 refresherDefaultStyle="white"
                 onRefresherRefresh={() => { props.refresh!() }}
                 upperThreshold={50}
-                onScrollToLower={() => { props.more!()}}
+                onScrollToLower={() => { props.more!() }}
                 refresherTriggered={triggered}>
                 {
-                    props.title && <Text className='layout_title'>{props.title}</Text>
+                    props.title && <View className="layout_title_view">
+                        <Text className='layout_title'>{props.title}</Text>
+                    </View>
                 }
                 {children}
-                <View style={{height:50}}/>
+                <View style={{ height: 50 }} />
             </ScrollView>
         case TemplateType.grid:
             return <ScrollView className="layout_container"
                 enableFlex={true}
                 onScroll={onScroll}
-                style={{WebkitOverflowScrolling:'auto'}}
+                style={{ WebkitOverflowScrolling: 'auto' }}
                 scrollY refresherEnabled={true}
                 refresherThreshold={100} refresherBackground="#000"
                 refresherDefaultStyle="white"
@@ -69,15 +82,22 @@ export default function Layout(props: {
                 onScrollToLower={() => { props.more!() }}
                 refresherTriggered={triggered}>
                 {
-                    props.title && <Text className='layout_title'>{props.title}</Text>
+                    props.title && <View className="layout_title_view">
+                        <Text className='layout_title'>{props.title}</Text>
+                    </View>
                 }
                 <View className="grid_bg">
                     {children}
-                    <View style={{height:50}}/>
+                    <View style={{ height: 50 }} />
                 </View>
             </ScrollView>
         case TemplateType.flex:
             return <View className='flex'>
+                {
+                    props.title && <View className="layout_title_view">
+                        <Text className='layout_title'>{props.title}</Text>
+                    </View>
+                }
                 {children}
             </View>
     }

+ 0 - 0
src/custom-tab-bar1/index.scss → src/custom-tab-bar/index.scss


+ 6 - 5
src/custom-tab-bar1/index.tsx → src/custom-tab-bar/index.tsx

@@ -6,16 +6,17 @@ import { useEffect, useState } from 'react'
 
 export default function TabBar() {
     const { t } = useTranslation()
-    const [selIndex, setSelIndex] = useState(0)
-
-    const pages = Taro.getCurrentPages();
-    const currentPage = pages[0];
-    console.log(currentPage)
+    const [selIndex, setSelIndex] = useState(global.index?global.index:0)
+    console.log(selIndex)
     useEffect(() => {
         console.log(global.index+'aaaa')
         setSelIndex(global.index?global.index:0)
       }, [global.index])
 
+    global.updateTab = (index)=>{
+        // setSelIndex(index)
+    }
+
     function switchTab(index: number) {
         global.index = index;
         switch (index) {

+ 9 - 0
src/custom-tab-bar/index.js → src/custom-tab-bar2/index.js

@@ -22,12 +22,21 @@ Component({
   },
   methods: {
     update(index){
+      console.log('update index'+index)
+      this.setData({
+        selected:-1
+      })
       this.setData({
         selected: index
       })
+
     },
     switchTab(e) {
       const data = e.currentTarget.dataset
+      console.log(data.index)
+      this.setData({
+        selected:data.index
+      })
       const url = data.path
       wx.switchTab({url})
       // this.setData({

+ 0 - 0
src/custom-tab-bar/index.json → src/custom-tab-bar2/index.json


+ 0 - 0
src/custom-tab-bar/index.wxml → src/custom-tab-bar2/index.wxml


+ 0 - 0
src/custom-tab-bar/index.wxss → src/custom-tab-bar2/index.wxss


+ 1 - 1
src/pages/account/Profile.tsx

@@ -19,7 +19,7 @@ export default function Page() {
     }
 
     useDidShow(() => {
-        global.tabBar.update(3)
+        global.updateTab(3)
     })
 
     function reset() {

+ 1 - 1
src/pages/activity/Activity.tsx

@@ -11,7 +11,7 @@ export default function Page() {
     // })
 
     useDidShow(() => {
-        global.tabBar.update(2)
+        global.updateTab(2)
     })
 
     function refresh() {

+ 7 - 0
src/pages/clock/Clock.config.ts

@@ -0,0 +1,7 @@
+export default definePageConfig({
+    usingComponents: {
+        // 'ec-canvas': '../../lib/ec-canvas/ec-canvas',
+        // 'demo':'../../components/demo'
+    },
+    "navigationBarTitleText": ""
+})

+ 36 - 30
src/pages/clock/Clock.tsx

@@ -2,7 +2,7 @@ import { Component, PropsWithChildren, useEffect, useRef, useState } from 'react
 import { View, Text, Button, Input, Picker, Swiper, SwiperItem } from '@tarojs/components'
 import '../index/index.scss'
 import './Clock.scss'
-import Taro, { useDidShow, useReady, useRouter } from '@tarojs/taro'
+import Taro, { useDidShow, usePageScroll, useReady, useRouter } from '@tarojs/taro'
 // import ComponentA from './component'
 import Rings from '@components/view/Rings';
 
@@ -27,6 +27,8 @@ import RequestType, { thirdPartRequest } from '@/services/thirdPartRequest'
 import { setConfigs } from '@/store/common'
 import RecordFastSleep from '@/features/trackTimeDuration/components/RecordFastSleep'
 import Box from '@/components/layout/Box'
+import Layout from '@/components/layout/layout'
+import { NaviBarTitleShowType, TemplateType } from '@/utils/types'
 // import TabBar from '../../components/Tabbar';
 
 export default function IndexPage() {
@@ -152,8 +154,12 @@ export default function IndexPage() {
     })
   }
 
+  usePageScroll((e) => {
+
+  })
+
   useDidShow(() => {
-    global.tabBar.update(0)
+    global.updateTab(0)
     if (user.isLogin) {
       checkWXPubFollow()
       getCheckData();
@@ -287,21 +293,22 @@ export default function IndexPage() {
   }
 
   return (
-    <View style={{ flex: 1, flexDirection: 'column', display: 'flex', backgroundColor: '#000', color: '#fff' }}>
-      {
-        needShowAddTip && <Tooltip title="添加到我的小程序" closeTip={() => { setNeedShowAddTip(false) }} />
-      }
+    <Layout type={TemplateType.flex} title='时钟' titleShowStyle={NaviBarTitleShowType.scrollToShow}>
+      <View style={{ flex: 1, flexDirection: 'column', display: 'flex', backgroundColor: '#000', color: '#fff' }}>
+        {
+          needShowAddTip && <Tooltip title="添加到我的小程序" closeTip={() => { setNeedShowAddTip(false) }} />
+        }
 
-      <TitleBar />
-      <Box>
-        <View className='clock_bg'>
-          <Clocks />
-        </View>
+        <TitleBar />
+        <Box>
+          <View className='clock_bg'>
+            <Clocks />
+          </View>
 
-      </Box>
+        </Box>
 
-      {
-        needSwiper() ? <Swiper style={{ flexShrink: 0, display: 'flex', height: 173 }} indicatorColor='#999'
+        {/* {
+        needSwiper() ? <Swiper className='swiper' style={{ flexShrink: 0, display: 'flex', height: 173 }} indicatorColor='#999'
           indicatorActiveColor='#333'
           indicatorDots>
           <SwiperItem className='swiperItem'>
@@ -315,28 +322,27 @@ export default function IndexPage() {
         </Swiper> :
           <Console />
 
-      }
+      } */}
+
+        <Console />
 
 
-      <More ref={global.moreRef} />
-      {/* {
+        <More ref={global.moreRef} />
+        {/* {
         !permission.wxPubFollow && user.isLogin && <Text style={{ textAlign: 'center', width: '100%' }} onClick={() => followWxPub()}>去关注公众号</Text>
       } */}
 
-      {
-        checkData && schedule()
-      }
+        {
+          checkData && schedule()
+        }
 
 
-      {
-        checkData && (checkData as any).latest_record && <RecordFastSleep type='latest' data={(checkData as any).latest_record} delSuccess={getCheckData} />
-        // <Schedule type='latest' delSuccess={getCheckData} />
-      }
-      {/* <Picker mode="time" start="07:00" end="20:00">
-        <Text style="color: #fff;">test picker</Text>
-      </Picker> */}
-      <View style={{ height: 100 }} />
-      {/* <View className='popDemo' catchMove/> */}
-    </View>
+        {
+          checkData && (checkData as any).latest_record && <RecordFastSleep type='latest' data={(checkData as any).latest_record} delSuccess={getCheckData} />
+          // <Schedule type='latest' delSuccess={getCheckData} />
+        }
+        <View style={{ height: 100 }} />
+      </View>
+    </Layout>
   )
 }

+ 1 - 1
src/pages/metric/Metric.tsx

@@ -4,7 +4,7 @@ import { useDidShow } from "@tarojs/taro";
 
 export default function Page() {
     useDidShow(() => {
-        global.tabBar.update(1)
+        global.updateTab(1)
       })
     return <View className="container">
         <Metric />

+ 8 - 2
src/services/trackTimeDuration.tsx

@@ -57,8 +57,14 @@ export const getClockRecords = (params:any)=>{
 
 }
 
-export const recordCheck = (params: Record<string, any> | undefined) => {
-    debugger
+export const recordCheck = (params: Record<string, any>) => {
+    if (params.real_check_time){
+        var date = new Date((params as any).real_check_time)
+        var month = date.getMonth()+1
+        var day = date.getDate()
+        
+        params.real_check_date = date.getFullYear+(month<10?'0'+month:month+'')+(day<10?'0'+day:day+'')
+    }
     return new Promise((resolve) => {
         request({
             url: API_FAST_CLOCKS, method: 'POST', data: { ...params }