leon 1 ano atrás
pai
commit
13bff5e723

+ 1 - 1
ios/AppDelegate.mm

@@ -131,7 +131,7 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
 - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
 {
 //  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
-#if DEBUGaaa
+#if DEBUG
   return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
 #else
   return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

BIN
src/assets/images/pointer.png


+ 4 - 3
src/components/input/SlidngScale.tsx

@@ -58,6 +58,7 @@ export default function Component(props: {
         }
     }
     else {
+        
         for (var i: number = minNum; i <= maxNum; i += props.step) {
             var value: number = parseFloat(i.toFixed(props.scale == 0 ? 1 : props.scale));
             var isBig: boolean = Math.round((value - minNum) * jingdu) % Math.round(stepNum * jingdu) == 0;
@@ -146,7 +147,7 @@ export default function Component(props: {
 
     function update(e) {
         const { scrollLeft } = e.detail;
-
+        debugger
         var count = scrollLeft / slidngWidth;
         if (isFT_IN) {
             count = count / 1.2
@@ -216,7 +217,7 @@ export default function Component(props: {
         var obj = list[i];
         if (obj.showBig) {
             //字体设置参考 https://segmentfault.com/a/1190000006110417
-            svgNumber += `<text x="${i * (isFT_IN ? 12 : 10) + 1 + 30}" y="${rpxToPx(2 + 36)}" text-anchor="middle" fill="white" font-family="PingFang SC,Helvetica Neue,Helvetica,Arial,Hiragino Sans GB,Heiti SC,Microsoft YaHei" font-size="${rpxToPx(36)}">${parseInt('' + obj.value / 12)}</text>`
+            svgNumber += `<text x="${i * (isFT_IN ? 12 : 10) + 1 + 30}" y="${rpxToPx(2 + 36)}" text-anchor="middle" fill="white" font-family="PingFang SC,Helvetica Neue,Helvetica,Arial,Hiragino Sans GB,Heiti SC,Microsoft YaHei" font-size="${rpxToPx(36)}">${isFT_IN ?parseInt('' + obj.value / 12):obj.value}</text>`
         }
     }
     svgLine += `</svg>`
@@ -267,7 +268,7 @@ export default function Component(props: {
             </View>
         }
         {
-            props.unit != 'in' && <View className="number_bg" style={{ opacity: enableText ? 1 : 0.4 }}>
+            !isFT_IN && <View className="number_bg" style={{ opacity: enableText ? 1 : 0.4 }}>
                 {
                     process.env.TARO_ENV == 'weapp' ? <Text className="number" style={{ fontFamily: "PingFang SC,Helvetica Neue, Helvetica, Arial, Hiragino Sans GB, Heiti SC, Microsoft YaHei, WenQuanYi Micro Hei, sans-serif;" }}>{current}</Text> :
                         <Text className="number">{current}</Text>

+ 20 - 2
src/features/trackSomething/components/Metric.tsx

@@ -145,6 +145,13 @@ export default function Component(props: any) {
         })
         return values
     }
+
+    function getUnit(items) {
+        if (items.length == 1) {
+            return items[0].unit
+        }
+        return null
+    }
     function goDetail(item) {
         if (user.isLogin) {
             if (!item.latest_record) {
@@ -235,6 +242,7 @@ export default function Component(props: any) {
                         var value = t('feature.track_something.metric.no_record')
                         var desc = t('feature.track_something.metric.check_unlock_data')
                         var showDetail = false;
+                        var special = ''
                         if (item.latest_record) {
 
                             if (item.type == 'composite') {
@@ -242,8 +250,12 @@ export default function Component(props: any) {
                                 value = item.latest_record.value
                             }
                             else {
-                                unit = item.schemas[0].default_unit
+                                // unit = item.schemas[0].default_unit
+                                unit = getUnit(item.latest_record.items)?getUnit(item.latest_record.items):item.schemas[0].default_unit
                                 value = getValues(item.latest_record.items)
+                                if (item.latest_record.items.length==1){
+                                    special = item.latest_record.items[0].special
+                                }
                             }
                             desc = TimeFormatter.dateDescription(item.latest_record.timestamp, true)
                             showDetail = true
@@ -261,6 +273,7 @@ export default function Component(props: any) {
                             value={value}
                             unit={unit}
                             desc={desc}
+                            special={special}
                             btnText={t('feature.track_something.btn_record')}
                             isDisabled={false}
                             showDetail={showDetail}
@@ -374,6 +387,9 @@ export default function Component(props: any) {
                             if (item.tempValue) {
                                 item.default_value = item.tempValue
                             }
+                            if (item.tempUnit) {
+                                item.unit = item.tempUnit
+                            }
                         })
                         setTempMetricItem(temp)
                         setModalType(MetricModalType.time)
@@ -450,7 +466,8 @@ export default function Component(props: any) {
         result.schemas.map((item, index) => {
             array.push({
                 code: item.code,
-                value: item.tempValue && item.tempValue > 0 ? item.tempValue : item.default_value
+                value: item.tempValue && item.tempValue > 0 ? item.tempValue : item.default_value,
+                unit: item.tempUnit ?? ''
             })
         })
         var params = {
@@ -469,6 +486,7 @@ export default function Component(props: any) {
             // getCards();
             result.schemas.map((item, index) => {
                 item.tempValue = ''
+                item.tempUnit = ''
             })
 
             list.map((item, index) => {

+ 30 - 13
src/features/trackSomething/components/MetricItem.tsx

@@ -17,8 +17,9 @@ export default function Component(props: {
     showBadge?: boolean,
     showDetail?: boolean,
     longClick?: Function,
-    showTag?:boolean,
-    tagName?:string
+    showTag?: boolean,
+    tagName?: string,
+    special?: string
 }) {
 
     function clickBtn() {
@@ -38,6 +39,27 @@ export default function Component(props: {
 
     }
 
+    function valueContent() {
+        if (props.special && props.special == 'FT_IN') {
+
+            return <View className="metric_value_bg" onClick={() => props.onClickDetail()}>
+                <Text className="metric_value">{parseInt(props.value / 12 + '')}</Text>
+                <Text className="metric_unit" style={{ marginBottom: 3, marginLeft: 2, marginRight: 2 }}>ft</Text>
+                <Text className="metric_value">{props.value % 12}</Text>
+                <Text className="metric_unit" style={{ marginBottom: 3, marginLeft: 2, marginRight: 2 }}>in</Text>
+
+            </View>
+        }
+        return <View className="metric_value_bg" onClick={() => props.onClickDetail()}>
+            {
+                props.valueView ? props.valueView : <Text className="metric_value">{props.value}</Text>
+            }
+            {
+                !props.valueView && <Text className="metric_unit" style={{ marginBottom: 3 }}>{props.unit}</Text>
+            }
+        </View>
+    }
+
     return <View className="metric_bg">
         <View className="metric_title_bg">
             <Text className="metric_title"
@@ -46,20 +68,15 @@ export default function Component(props: {
             <View style={{ flex: 1 }} />
             {
                 props.showTag && <View className="metric_tag_bg">
-                <Text className="metric_tag_text" style={{color:props.themeColor}}>{props.tagName}</Text>
-            </View>
+                    <Text className="metric_tag_text" style={{ color: props.themeColor }}>{props.tagName}</Text>
+                </View>
             }
-            
-        </View>
 
-        <View className="metric_value_bg" onClick={() => props.onClickDetail()}>
-            {
-                props.valueView ? props.valueView : <Text className="metric_value">{props.value}</Text>
-            }
-            {
-                !props.valueView && <Text className="metric_unit" style={{marginBottom:3}}>{props.unit}</Text>
-            }
         </View>
+
+        {
+            valueContent()
+        }
         <View className="metric_desc_bg" onClick={() => props.onClickDetail()}>
             <Text className="mteric_desc">{props.desc}</Text>
             {

+ 17 - 6
src/features/trackSomething/components/MetricModalAdd.tsx

@@ -8,6 +8,7 @@ import { useEffect, useState } from 'react'
 export default function Component(props: { item: any, strTime: string, showPicker: Function, cancel: Function, confirm: Function }) {
     const [metricItem, setMetricItem] = useState(props.item)
     const [enable, setEnable] = useState(true)
+    const [currentSel, setCurrentSel] = useState<any>({})
     // const [disableCode,setDisableCode] = useState(0)
     const { t } = useTranslation()
 
@@ -26,28 +27,38 @@ export default function Component(props: { item: any, strTime: string, showPicke
                         var obj = item;
                         const { unit_options, chosen_unit } = item;
                         if (unit_options && unit_options.length > 0) {
-                            unit_options.map(temp => {
+                            unit_options.map((temp, i) => {
                                 if (temp.unit == chosen_unit) {
                                     obj = temp
+                                    var tempMap = JSON.parse(JSON.stringify(currentSel))
+                                    tempMap[index] = i;
                                 }
                             })
                         }
-                        debugger
-                        return <View key={index}>
+                        return <View key={index} style={{position:'relative'}}>
                             {
                                 (metricItem as any).schemas.length > 1 && <Text style={{
                                     textAlign: 'center', width: '100%', display: 'flex',
                                     justifyContent: 'center', color: (metricItem as any).theme_color,
                                     // opacity:item.code==disableCode?0.4:1
-                                }}>{obj.name}</Text>
+                                }}>{item.name}</Text>
+                            }
+                            {
+                                unit_options && unit_options.length > 1 && <View style={{position:'absolute',right:20,}}>
+                                    <Text style={{color:'#fff'}}>切换</Text>
+                                </View>
                             }
                             <SlidngScale step={obj.step} min={obj.min} max={obj.max}
                                 default_value={obj.default_value}
                                 scale={obj.scale}
-                                unit={obj.unit?obj.unit:item.unit}
+                                unit={obj.unit ? obj.unit : item.default_unit}
                                 special={obj.special ?? null}
                                 themeColor={(metricItem as any).theme_color}
-                                changed={(e) => { obj.tempValue = e }}
+                                changed={(e) => { 
+                                    item.tempValue = e; 
+                                    item.tempUnit = obj.unit ? obj.unit : item.default_unit
+                                    debugger
+                                }}
                                 updateStatus={(isEnable) => {
                                     setEnable(isEnable)
                                 }} />