|
|
@@ -1,6 +1,6 @@
|
|
|
|
|
|
import { kIsAndroid, kIsIOS } from "@/utils/tools";
|
|
|
-import { View, Text, Image } from "@tarojs/components";
|
|
|
+import { View, Text, Image, ScrollView } from "@tarojs/components";
|
|
|
import { useEffect, useState } from "react";
|
|
|
import { useDispatch, useSelector } from "react-redux";
|
|
|
import './product_list.scss'
|
|
|
@@ -11,6 +11,7 @@ import { useTranslation } from "react-i18next";
|
|
|
import { AtActivityIndicator } from "taro-ui";
|
|
|
import NoData from "@/components/view/NoData";
|
|
|
import { setAccessData } from "@/store/access";
|
|
|
+import Segment from "@/components/navigation/Segment";
|
|
|
|
|
|
let useNavigation, TouchableOpacity, Purchases;
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
|
@@ -21,6 +22,8 @@ if (process.env.TARO_ENV == 'rn') {
|
|
|
export default function ProductList() {
|
|
|
const dispatch = useDispatch();
|
|
|
const [packages, setPackages] = useState([]);
|
|
|
+ const [packages2, setPackages2] = useState<any>([]);
|
|
|
+ const [segmentIndex, setSegmentIndex] = useState(0);
|
|
|
const user = useSelector((state: any) => state.user);
|
|
|
// - State for displaying an overlay view
|
|
|
const [isPurchasing, setIsPurchasing] = useState(false);
|
|
|
@@ -82,6 +85,7 @@ export default function ProductList() {
|
|
|
function getSku() {
|
|
|
setIsLoading(true)
|
|
|
Promise.all([Purchases.getOfferings(), products({ store: kIsIOS ? 'app_store' : 'play_store' })]).then(list => {
|
|
|
+ console.log('product list', list[0], list[1])
|
|
|
|
|
|
var offerings = list[0]
|
|
|
var skus: any = (list[1] as any).data
|
|
|
@@ -95,8 +99,19 @@ export default function ProductList() {
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
+ var list0:any = []
|
|
|
+ var list1:any = []
|
|
|
+ array.forEach(element => {
|
|
|
+ if (element.product.productCategory == 'NON_SUBSCRIPTION'){
|
|
|
+ list0.push(element)
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ list1.push(element)
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- setPackages(array)
|
|
|
+ setPackages(list0)
|
|
|
+ setPackages2(list1)
|
|
|
|
|
|
}
|
|
|
setShowErrorPage(false)
|
|
|
@@ -186,9 +201,26 @@ export default function ProductList() {
|
|
|
</View>
|
|
|
|
|
|
return <View style={{ flex: 1, position: 'relative' }}>
|
|
|
- <View style={{ height: 40 }} />
|
|
|
+ <View className='seg_bg'>
|
|
|
+ <Text className={segmentIndex==0?'seg_sel':'seg_nor'} onClick={() => setSegmentIndex(0)}>Non-renew</Text>
|
|
|
+ <Text className={segmentIndex==1?'seg_sel':'seg_nor'} onClick={() => setSegmentIndex(1)}>Auto-renew</Text>
|
|
|
+ </View>
|
|
|
+ <ScrollView style={{flex:1}}>
|
|
|
+ {
|
|
|
+ segmentIndex==0 && packages.map((item, index) => {
|
|
|
+ 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">{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>
|
|
|
+
|
|
|
+ </View>
|
|
|
+ })
|
|
|
+ }
|
|
|
{
|
|
|
- packages.map((item, index) => {
|
|
|
+ segmentIndex==1 && packages2.map((item, index) => {
|
|
|
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>
|
|
|
@@ -200,6 +232,7 @@ export default function ProductList() {
|
|
|
</View>
|
|
|
})
|
|
|
}
|
|
|
+ </ScrollView>
|
|
|
{/* <FlatList
|
|
|
data={packages}
|
|
|
renderItem={({ item }) => <View className="product_item" onClick={() => pay(item)}>
|