Leon 1 年之前
父节点
当前提交
7277c37f56

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

@@ -38,7 +38,7 @@ export default function Component(props: {
     const slidngWidth = 10
 
     const [current, setCurrent] = useState(props.default_value)
-    const [left, setLeft] = useState((props.default_value - min) * slidngWidth / props.step);
+    const [left, setLeft] = useState((props.default_value - min) * slidngWidth / props.step-0.5);
     const [isDraging, setIsDraging] = useState(false)
     const [isEnd, setIsEnd] = useState(true)
     const [enableText, setEnableText] = useState(true)
@@ -60,41 +60,6 @@ export default function Component(props: {
     // const [showScrollView, setShowScrollView] = useState(false)
 
     useEffect(() => {
-        // var array: any = []
-        // for (var i: number = min; i <= max; i += props.step) {
-        //     var value: number = parseFloat(i.toFixed(props.scale));
-        //     var isBig: boolean = Math.round((value - min) * jingdu) % Math.round(stepNum * jingdu) == 0;
-        //     var isMiddle: boolean = (Math.round((value - min) * jingdu) * 2) % Math.round(stepNum * jingdu) == 0;
-
-        //     array.push({
-        //         value: props.step < 1 ? value : Math.round(value),
-        //         showBig: isBig && i >= min && i <= max,
-        //         showMiddle: isMiddle && !isBig && i >= min && i <= max
-        //     })
-        // }
-        // setList(array)
-
-        // setTimeout(() => {
-        //     var min2 = props.min
-        //     var max2 = props.max
-        //     setMinNum(min2)
-        //     setMaxNum(max2)
-        //     setLeft((props.default_value - min2) * slidngWidth / props.step)
-
-        //     var array2: any = []
-        //     for (var i: number = min2; i <= max2; i += props.step) {
-        //         var value: number = parseFloat(i.toFixed(1));
-        //         var isBig: boolean = Math.round((value - min2) * jingdu) % Math.round(stepNum * jingdu) == 0;
-        //         var isMiddle: boolean = (Math.round((value - min2) * jingdu) * 2) % Math.round(stepNum * jingdu) == 0;
-
-        //         array2.push({
-        //             value: props.step < 1 ? value : Math.round(value),
-        //             showBig: isBig && i >= min2 && i <= max2,
-        //             showMiddle: isMiddle && !isBig && i >= min2 && i <= max2
-        //         })
-        //     }
-        //     setList(array2)
-        // }, 50)
     }, [])
 
     useEffect(() => {
@@ -328,8 +293,8 @@ export default function Component(props: {
                                         <View style={{ width: list.length * 10 - 8 + 60, marginLeft: -30, height: rpxToPx(38), backgroundImage: imgNum }} />}
                                     {
                                         process.env.TARO_ENV == 'rn' &&
-                                        <View style={{ flexDirection: 'row', marginLeft: -30 }}>
-                                            <SvgXml xml={svgNumber} width={list.length * 10 - 8 + 60} height={rpxToPx(38)} />
+                                        <View style={{ flexDirection: 'row', marginLeft: -30,height:rpxToPx(40) }}>
+                                            <SvgXml xml={svgNumber} width={list.length * 10 - 8 + 60} height={rpxToPx(40)} />
                                         </View>
                                     }
                                 </View>

+ 1 - 1
src/features/trackSomething/components/MetricItem.tsx

@@ -57,7 +57,7 @@ export default function Component(props: {
                 props.valueView ? props.valueView : <Text className="metric_value">{props.value}</Text>
             }
             {
-                !props.valueView && <Text className="metric_unit">{props.unit}</Text>
+                !props.valueView && <Text className="metric_unit" style={{marginBottom:3}}>{props.unit}</Text>
             }
         </View>
         <View className="metric_desc_bg" onClick={() => props.onClickDetail()}>

+ 2 - 2
src/features/trackTimeDuration/components/Streaks.tsx

@@ -89,9 +89,9 @@ export default function Streaks(props: { count: number }) {
             <StreakItem isFast={true} data={fastStreaks} />
             <StreakItem isFast={false} data={sleepStreaks} />
         </View>
-        <View className="vip_calendar2" onClick={() => {}}>
+        {/* <View className="vip_calendar2" onClick={() => {}}>
             <Text style={{ color: '#fff' }}>Restore my streak</Text>
-        </View>
+        </View> */}
 
     </View>
 }

+ 43 - 6
src/pages/store/product_list.scss

@@ -1,4 +1,4 @@
-.product_item{
+.product_item {
     display: flex;
     flex-direction: column;
     margin-bottom: 20px;
@@ -12,18 +12,55 @@
     padding-bottom: 24px;
 }
 
-.product_title{
+.product_title {
     font-size: 36px;
     line-height: 68px;
     font-weight: bold;
 }
 
-.product_desc{
+.product_desc {}
 
-}
-
-.product_price{
+.product_price {
     color: #fff;
     font-size: 36px;
     font-weight: bold;
+}
+
+.pop_loading_bg {
+    position: absolute;
+    left: 0;
+    right: 0;
+    top: 0;
+    bottom: 0;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    flex-direction: column;
+    background-color: #00000090;
+}
+    
+.pop_loading {
+    border-radius: 20px;
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    justify-content: center;
+    background-color: #1C1C1C;
+    padding-left: 30px;
+    padding-right: 30px;
+    padding-top: 30px;
+    padding-bottom: 30px;
+    margin-bottom: 250px;
+
+}
+
+.pop_loading_title {
+    color: #fff;
+    font-size: 28px;
+}
+
+.pop_loading_desc {
+    font-size: 28px;
+    color: #fff;
+    margin-top: 10px;
 }

+ 35 - 36
src/pages/store/product_list.tsx

@@ -10,6 +10,8 @@ import { ColorType } from "@/context/themes/color";
 import { payInfo } from "@/services/user";
 import Taro from "@tarojs/taro";
 import showAlert from "@/components/basic/Alert";
+import { useTranslation } from "react-i18next";
+import { AtActivityIndicator } from "taro-ui";
 
 let useNavigation, TouchableOpacity;
 if (process.env.TARO_ENV == 'rn') {
@@ -23,6 +25,7 @@ export default function ProductList() {
     // - State for displaying an overlay view
     const [isPurchasing, setIsPurchasing] = useState(false);
     const [errorCode, setErrorCode] = useState<any>(-1)
+    const { t } = useTranslation()
 
     let navigation;
     if (useNavigation) {
@@ -33,21 +36,21 @@ export default function ProductList() {
         if (navigation) {
             navigation.setOptions({
                 gestureEnabled: !isPurchasing,
-                headerLeft: () => (<TouchableOpacity activeOpacity={1} style={{ marginLeft: 5, padding: 5 }} onPress={() => {
-                    if (!isPurchasing) {
-                        navigation.goBack()
-                    }
-                    else {
-                        showAlert({
-                            title: '支付进行中',
-                            content: '禁止返回',
-                            showCancel: false
-                        })
-                    }
-
-                }}>
-                    <Image style={{ width: 30, height: 30 }} src={require('@/assets/images/navi_back.png')} />
-                </TouchableOpacity>),
+                // headerLeft: () => (<TouchableOpacity activeOpacity={1} style={{ marginLeft: 5, padding: 5 }} onPress={() => {
+                //     if (!isPurchasing) {
+                //         navigation.goBack()
+                //     }
+                //     else {
+                //         showAlert({
+                //             title: '支付进行中',
+                //             content: '禁止返回',
+                //             showCancel: false
+                //         })
+                //     }
+
+                // }}>
+                //     <Image style={{ width: 30, height: 30 }} src={require('@/assets/images/navi_back.png')} />
+                // </TouchableOpacity>),
             });
         }
     }, [isPurchasing])
@@ -82,7 +85,7 @@ export default function ProductList() {
             const offerings = await Purchases.getOfferings();
             console.log('product list offerings', offerings)
             console.log('product list detail', (offerings as any).current.availablePackages[1])
-            console.log('dddd',JSON.stringify(offerings))
+            console.log('dddd', JSON.stringify(offerings))
 
             if (offerings.current !== null && offerings.current.availablePackages.length !== 0) {
                 setPackages((offerings as any).current.availablePackages);
@@ -92,19 +95,6 @@ export default function ProductList() {
         }
     }
 
-
-    async function hi() {
-        try {
-            // 启动购买流程
-            const purchaseResult = await Purchases.purchaseProduct('pro_lifelong_test');
-            console.log(purchaseResult);
-            // 检查购买是否成功
-            // setIsSubscribed(purchaseResult.purchaserInfo.activeSubscriptions.length > 0);
-        } catch (error) {
-            console.error('Purchase error:', error);
-        }
-    }
-
     async function pay(item: any) {
         setIsPurchasing(true);
         try {
@@ -113,8 +103,8 @@ export default function ProductList() {
                 customerInfo,
                 productIdentifier,
                 transaction,
-                store:kIsIOS?'app_store':'play_store',
-                storeProductIdentifier:item.product.identifier //后端要求额外传入商品id,用于同步数据,区别于productIdentifier
+                store: kIsIOS ? 'app_store' : 'play_store',
+                storeProductIdentifier: item.product.identifier //后端要求额外传入商品id,用于同步数据,区别于productIdentifier
             }).then(res => {
                 global.paySuccess(res)
                 if (process.env.TARO_ENV == 'rn') {
@@ -128,7 +118,10 @@ export default function ProductList() {
             });
             console.log('result', customerInfo)
         } catch (e) {
-            debugger
+            if (e.code === Purchases.PURCHASES_ERROR_CODE.NETWORK_ERROR) {
+                pay(item)
+                return;
+            }
             setErrorCode(e.code)
             if (e.code === Purchases.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR) {
 
@@ -138,7 +131,7 @@ export default function ProductList() {
         }
     }
 
-    return <View>
+    return <View style={{flex:1,position:'relative'}}>
         <View style={{ height: 40 }} />
         {
             packages.map((item, index) => {
@@ -169,10 +162,16 @@ export default function ProductList() {
         /> */}
 
         {
-            isPurchasing && <Text style={{ color: '#fff', fontSize: 40 }}>正在付款</Text>
+            isPurchasing && <View className="pop_loading_bg">
+                <View className="pop_loading">
+                    <AtActivityIndicator size={40} color="#fff" />
+                    <Text className="pop_loading_title">{t('feature.pay.paying_title')}</Text>
+                    <Text className="pop_loading_desc">{t('feature.pay.paying_desc')}</Text>
+                </View>
+            </View>
         }
-        {
+        {/* {
             errorCode != -1 && <Text style={{ color: '#fff', fontSize: 40 }}>出错了,错误代码{errorCode}</Text>
-        }
+        } */}
     </View>
 }