Leon 2 年 前
コミット
443e52ab3e

+ 15 - 2
src/features/trackSomething/components/Activity.tsx

@@ -20,6 +20,7 @@ export default function Component(props: any) {
     const [isCheking, setIsChecking] = useState(false)
     const [list, setList] = useState([])
     const dispatch = useDispatch();
+    const [returnLoginData,setReturnLoginData] = useState(false)
     // const [title, setTitle] = useState('打卡')
 
     //未登录<->已登录 状态切换时,执行一次授权检查
@@ -40,6 +41,12 @@ export default function Component(props: any) {
 
     function getCards() {
         activityCards().then(res => {
+            if (user.isLogin){
+                setReturnLoginData(true)
+            }
+            else {
+                setReturnLoginData(false)
+            }
             setList((res as any).cards)
         })
     }
@@ -246,6 +253,7 @@ export default function Component(props: any) {
             list.map((item: any, index) => {
                 var value = '0'
                 var desc = ''
+                var unit = ''
                 if (item.latest_record) {
                     value = item.latest_record.items[0].value
                     if (item.latest_record.timestamp == 0) {
@@ -263,17 +271,22 @@ export default function Component(props: any) {
                 if (!allowRun) {
                     value = '0'
                     desc = '开启步数仅自己可见'
+                    unit = ''
+                }
+                else {
+                    unit = '步'
                 }
 
-                if (!user.isLogin){
+                if (!user.isLogin || !returnLoginData){
                     value = '未登录'
                     desc = '登录后可开启打卡'
+                    unit = ''
                 }
 
                 return <MetricItem title={item.name}
                     // value={allowRun ? stepInfo ? (stepInfo as any).step : '' : '未开启'}
                     value={value}
-                    unit={allowRun ? '步' : ''}
+                    unit={unit}
                     desc={desc}
                     btnText={btnTitle}
                     isDisabled={!isEnable}

+ 7 - 4
src/features/trackSomething/components/Metric.tsx

@@ -209,12 +209,12 @@ export default function Component(props: any) {
         closeModal()
         var date = new Date(time)
         var strDate = (date.getFullYear() + '') + (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1)) + (date.getDate() < 10 ? '0' + date.getDate() : date.getDate());
-        
-        var array:any[] = [];
+
+        var array: any[] = [];
         (metricItem as any).schemas.map((item, index) => {
             array.push({
-                code:item.code,
-                value:item.tempValue&&item.tempValue.length>0?item.tempValue:item.default_value
+                code: item.code,
+                value: item.tempValue && item.tempValue.length > 0 ? item.tempValue : item.default_value
             })
         })
         var params = {
@@ -271,6 +271,9 @@ export default function Component(props: any) {
                         {
                             (metricItem as any).schemas.map((item, index) => {
                                 return <View key={index}>
+                                    {
+                                        (metricItem as any).schemas.length > 1 && <Text style={{ textAlign: 'center', width: '100%', display: 'flex', justifyContent: 'center' }}>{item.name}</Text>
+                                    }
                                     <SlidngScale step={item.step} min={item.min} max={item.max} default_value={item.default_value} changed={(e) => { item.tempValue = e }} />
                                 </View>
                             })

+ 7 - 2
src/features/trackTimeDuration/components/ChooseScenario.tsx

@@ -10,7 +10,7 @@ import { useTranslation } from 'react-i18next'
 
 import './ChooseScenario.scss'
 import { useState } from "react";
-import { useReady } from "@tarojs/taro";
+import { useDidShow, useReady } from "@tarojs/taro";
 import Taro from "@tarojs/taro";
 import { useDispatch, useSelector } from "react-redux";
 import { setScenario, setScenarioName, setStep } from "@/store/scenario";
@@ -23,6 +23,11 @@ export default function Component() {
     const [selIndex, setSelIndex] = useState(-1)
     const [scenarios, setScenarios] = useState<any[]>([])
     const selScenario = useSelector((state: any) => state.scenario);
+    const [count,setCount] = useState(0)
+
+    useDidShow(()=>{
+        setCount(count+1)
+    })
 
     useReady(() => {
         console.log(selScenario)
@@ -84,7 +89,7 @@ export default function Component() {
     function durationToArc(startTime: string, endTime: string) {
         var start: number = parseInt(startTime.split(':')[1]) + parseInt(startTime.split(':')[0]) * 60
         var end: number = parseInt(endTime.split(':')[1]) + parseInt(endTime.split(':')[0]) * 60
-        if (end < start) {
+        if (end <= start) {
             end += 1440
         }
 

+ 0 - 3
src/services/user.tsx

@@ -55,7 +55,6 @@ export const wxLogin = (code: string) => (dispatch: any) => {
 }*/
 
 export const register = (name: string, email: string, password: string) => (dispatch: any) => {
-    debugger
     request({
         url: API_REGISTER, method: 'POST', data: { client_type: 'IOS', username: name, email: email, password: password }
     }).then(res => {
@@ -64,7 +63,6 @@ export const register = (name: string, email: string, password: string) => (disp
 }
 
 export const logout = () => (dispatch: any) => {
-    debugger
     request({
         url: API_LOGOUT, method: 'GET', data: {}
     }).then(_ => {
@@ -73,7 +71,6 @@ export const logout = () => (dispatch: any) => {
 }
 
 export const clear = () => (dispatch: any) => {
-    debugger
     request({
         url: API_CLEAR_USER, method: 'DELETE', data: {}
     }).then(_ => {