Leon пре 1 година
родитељ
комит
a02d104436
5 измењених фајлова са 29 додато и 51 уклоњено
  1. 2 2
      config/env.ts
  2. 2 1
      src/app.config.ts
  3. 2 2
      src/pages/account/Profile.tsx
  4. 22 45
      src/pages/store/product_list.tsx
  5. 1 1
      src/services/http/api.js

+ 2 - 2
config/env.ts

@@ -1,3 +1,3 @@
 
-export const APP_VERSION = '1.0.1'
-export const WX_VERSION = '1.4.5'
+export const APP_VERSION = '1.0.2'
+export const WX_VERSION = '1.4.6'

+ 2 - 1
src/app.config.ts

@@ -26,7 +26,8 @@ const appConfig = defineAppConfig({
     'pages/account/Member',
     'pages/explore/Index',
     'pages/clock/StreakDetail',
-    'pages/notification/setting'
+    'pages/notification/setting',
+    'pages/store/product_list'
   ],
   entryPagePath: 'pages/clock/Clock',
   // subPackages: [

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

@@ -130,7 +130,7 @@ export default function Page() {
 
     function tapBalance(e) {
         if (user.isLogin) {
-            jumpPage('', 'ProductList', navigation)
+            jumpPage('/pages/store/product_list', 'ProductList', navigation)
         }
         else {
             jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
@@ -219,7 +219,7 @@ export default function Page() {
                 {
                     (!user.isLogin||(accessObj && accessObj.access && accessObj.access.member.status == 'NON_MEMBER')) ? <View className="balance" onClick={tapBalance}>
                         <Text className="title">{t('page.more.stone')}</Text>
-                        <Text className="desc" style={{height:rpxToPx(64)}}>{t('page.more.stone_desc')}</Text>
+                        <Text className="desc" style={{height:process.env.TARO_ENV=='weapp'?rpxToPx(32):rpxToPx(64)}}>{t('page.more.stone_desc')}</Text>
                     </View> :
                         <View className="balance" onClick={tapBalance}>
                             <Text className="title">{t('page.more.pro_member')}</Text>

+ 22 - 45
src/pages/store/product_list.tsx

@@ -2,23 +2,21 @@
 import { kIsAndroid, kIsIOS } from "@/utils/tools";
 import { View, Text, Image } from "@tarojs/components";
 import { useEffect, useState } from "react";
-import { FlatList, Pressable } from "react-native";
-import Purchases from 'react-native-purchases'
 import { useDispatch, useSelector } from "react-redux";
 import './product_list.scss'
 import { ColorType } from "@/context/themes/color";
 import { payInfo, products } from "@/services/user";
 import Taro from "@tarojs/taro";
-import showAlert from "@/components/basic/Alert";
 import { useTranslation } from "react-i18next";
 import { AtActivityIndicator } from "taro-ui";
 import NoData from "@/components/view/NoData";
 import { setAccessData } from "@/store/access";
 
-let useNavigation, TouchableOpacity;
+let useNavigation, TouchableOpacity, Purchases;
 if (process.env.TARO_ENV == 'rn') {
     useNavigation = require("@react-navigation/native").useNavigation
     TouchableOpacity = require('react-native').TouchableOpacity
+    Purchases = require("react-native-purchases").default
 }
 export default function ProductList() {
     const dispatch = useDispatch();
@@ -40,21 +38,6 @@ 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>),
             });
         }
     }, [isPurchasing])
@@ -76,21 +59,27 @@ export default function ProductList() {
                     appUserID: user.id
                 })
             }
-            // getProducts();
-            // console.log('aaaa')
-            // setTimeout(() => {
-            // getProducts();
             getSku();
-            // hi()
-            // }, 2000)
 
         }
+        else {
+            getProducts();
+        }
     }, [])
 
-    function getSku() {
-        // Purchases.getOfferings().then(res=>{
+    function getProducts() {
+        setIsLoading(true)
+        products({ store: 'wechat' }).then(res => {
+            setPackages((res as any).data)
+            setShowErrorPage(false)
+            setIsLoading(false)
+        }).catch(e => {
+            setShowErrorPage(true)
+            setIsLoading(false)
+        })
+    }
 
-        // })
+    function getSku() {
         setIsLoading(true)
         Promise.all([Purchases.getOfferings(), products({ store: kIsIOS ? 'app_store' : 'play_store' })]).then(list => {
 
@@ -119,20 +108,8 @@ export default function ProductList() {
         })
     }
 
-    async function getProducts() {
-        console.log('product list get start')
-        try {
-            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))
+    function createOrder(item: any) {
 
-            if (offerings.current !== null && offerings.current.availablePackages.length !== 0) {
-                setPackages((offerings as any).current.availablePackages);
-            }
-        } catch (e) {
-            console.log('product list offerings error', e.message)
-        }
     }
 
     async function pay(item: any) {
@@ -186,11 +163,11 @@ export default function ProductList() {
         <View style={{ height: 40 }} />
         {
             packages.map((item, index) => {
-                return <View className="product_item" key={index} onClick={() => pay(item)}>
-                    <Text className="product_title" style={{ color: ColorType.fast }}>{(item as any).product.title}</Text>
-                    <Text style={{ color: '#fff', fontSize: 16, marginTop: 5, marginBottom: 5 }}>{(item as any).product.description}</Text>
+                return <View className="product_item" key={index} onClick={() => process.env.TARO_ENV == 'weapp' ? createOrder(item) : pay(item)}>
+                    <Text className="product_title" style={{ color: ColorType.fast }}>{process.env.TARO_ENV == 'weapp' ? (item as any).display_name : (item as any).product.title}</Text>
+                    <Text style={{ color: '#fff', fontSize: 16, marginTop: 5, marginBottom: 5 }}>{process.env.TARO_ENV == 'weapp' ? (item as any).description : (item as any).product.description}</Text>
                     <View style={{ flexDirection: 'row', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
-                        <Text className="product_price">{(item as any).product.priceString}</Text>
+                        <Text className="product_price">{process.env.TARO_ENV == 'weapp' ? '¥' + (item as any).price : (item as any).product.priceString}</Text>
                         <Image style={{ width: 24, height: 24 }} src={require('@/assets/images/arrow3.png')} />
                     </View>
 

+ 1 - 1
src/services/http/api.js

@@ -1,4 +1,4 @@
-const online = process.env.TARO_ENV == 'weapp' ? true : true;
+const online = process.env.TARO_ENV == 'weapp' ? false : false;
 
 import { WX_VERSION as _WX_VERSION, APP_VERSION as _APP_VERSION } from "../../../config/env";