|
|
@@ -102,10 +102,10 @@ export default function ProductList() {
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
- var list0:any = []
|
|
|
- var list1:any = []
|
|
|
+ var list0: any = []
|
|
|
+ var list1: any = []
|
|
|
array.forEach(element => {
|
|
|
- if (element.product.productCategory == 'NON_SUBSCRIPTION'){
|
|
|
+ if (element.product.productCategory == 'NON_SUBSCRIPTION') {
|
|
|
list0.push(element)
|
|
|
}
|
|
|
else {
|
|
|
@@ -156,19 +156,39 @@ export default function ProductList() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ function catchBuyAlert() {
|
|
|
+ showAlert({
|
|
|
+ title: 'Active Subscription',
|
|
|
+ content: `You're currently subscribed to ${accessObj.access.member.product.display_name}`,
|
|
|
+ showCancel: false,
|
|
|
+ confirmText: 'OK'
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
async function pay(item: any) {
|
|
|
- if (segmentIndex == 0){
|
|
|
- if (accessObj.access.member.type == 'AUTO_RENEW' && accessObj.access.member.auto_renew_status == 1) {
|
|
|
- showAlert({
|
|
|
- title:'Active Subscription',
|
|
|
- content:`You're currently subscribed to ${accessObj.access.member.product.display_name}`,
|
|
|
- showCancel:false,
|
|
|
- confirmText:'OK'
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
+ console.log(item)
|
|
|
+ switch (accessObj.access.member.subscription_status) {
|
|
|
+ case 'ACTIVE':
|
|
|
+ if (segmentIndex == 1) {
|
|
|
+ catchBuyAlert()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'ACTIVE_RENEWING':
|
|
|
+ if (segmentIndex == 0) {
|
|
|
+ catchBuyAlert()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ console.log(item.product.identifier,accessObj.access.member.product.product_id)
|
|
|
+ if (item.product.identifier == accessObj.access.member.product.product_id) {
|
|
|
+ catchBuyAlert()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
setIsPurchasing(true);
|
|
|
try {
|
|
|
@@ -197,7 +217,7 @@ export default function ProductList() {
|
|
|
pay(item)
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (e.code === Purchases.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR) {
|
|
|
return
|
|
|
}
|
|
|
@@ -219,36 +239,36 @@ export default function ProductList() {
|
|
|
|
|
|
return <View style={{ flex: 1, position: 'relative' }}>
|
|
|
<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>
|
|
|
+ <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>
|
|
|
+ <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>
|
|
|
- })
|
|
|
- }
|
|
|
- {
|
|
|
- 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>
|
|
|
- <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>
|
|
|
+ })
|
|
|
+ }
|
|
|
+ {
|
|
|
+ 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>
|
|
|
+ <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>
|
|
|
- })
|
|
|
- }
|
|
|
+ </View>
|
|
|
+ })
|
|
|
+ }
|
|
|
</ScrollView>
|
|
|
{/* <FlatList
|
|
|
data={packages}
|