开通vip相关
This commit is contained in:
parent
82f5a38c6c
commit
66740977ab
@ -81,7 +81,7 @@ class Call_outLogic extends GetxController {
|
|||||||
Get.bottomSheet(
|
Get.bottomSheet(
|
||||||
Scaffold(
|
Scaffold(
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
body: Open_vip_tipPage(),
|
body: Open_vip_tipPage(true),
|
||||||
),
|
),
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
enableDrag: false);
|
enableDrag: false);
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import '../../common/Widgets/open_vip_tip/view.dart';
|
||||||
import '../../util/SharedPreferencesHelper.dart';
|
import '../../util/SharedPreferencesHelper.dart';
|
||||||
import '../../util/util.dart';
|
import '../../util/util.dart';
|
||||||
import 'logic.dart';
|
import 'logic.dart';
|
||||||
@ -47,9 +48,15 @@ class MinefragmentPage extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
_buildAvatarRow(logic),
|
_buildAvatarRow(logic),
|
||||||
_friendsRow(logic),
|
_friendsRow(logic),
|
||||||
Image(
|
GestureDetector(
|
||||||
image: AssetImage(getHomeImage("icon_vip")),
|
onTap: () {
|
||||||
fit: BoxFit.fill,
|
showRechargeDialog();
|
||||||
|
|
||||||
|
},
|
||||||
|
child: Image(
|
||||||
|
image: AssetImage(getHomeImage("icon_vip")),
|
||||||
|
fit: BoxFit.fill,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
_circleLiveView(logic),
|
_circleLiveView(logic),
|
||||||
],
|
],
|
||||||
@ -509,4 +516,15 @@ class MinefragmentPage extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showRechargeDialog(){
|
||||||
|
Get.bottomSheet(
|
||||||
|
Scaffold(
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
body: Open_vip_tipPage(false),
|
||||||
|
),
|
||||||
|
isScrollControlled: true,
|
||||||
|
enableDrag: false);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import 'package:circle_app/util/util.dart';
|
import 'package:circle_app/util/util.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
@ -10,15 +9,33 @@ import 'state.dart';
|
|||||||
class Open_vip_tipLogic extends GetxController {
|
class Open_vip_tipLogic extends GetxController {
|
||||||
List<PriceBean> priceBean = [];
|
List<PriceBean> priceBean = [];
|
||||||
bool isZfbPrice = true;
|
bool isZfbPrice = true;
|
||||||
|
bool isYean = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() async {
|
void onInit() async {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
var data = await DioManager.instance.get(url: Api.getVipPrice, params: {});
|
var data = await DioManager.instance.get(url: Api.getVipPrice, params: {});
|
||||||
var vipPriceList = BaseResponse<List<PriceBean>>.fromJson(data, (data) =>
|
var vipPriceList = BaseResponse<List<PriceBean>>.fromJson(
|
||||||
|
data,
|
||||||
|
(data) =>
|
||||||
List<PriceBean>.from(data.map((item) => PriceBean.fromJson(item))),
|
List<PriceBean>.from(data.map((item) => PriceBean.fromJson(item))),
|
||||||
);
|
);
|
||||||
priceBean = vipPriceList.data;
|
priceBean = vipPriceList.data;
|
||||||
|
if (isYean) {
|
||||||
|
setYean();
|
||||||
|
}
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
setYean() {
|
||||||
|
isYean = true;
|
||||||
|
if (priceBean.length > 0) {
|
||||||
|
for (var value in priceBean) {
|
||||||
|
if (value.isYearVip) {
|
||||||
|
index = priceBean.indexOf(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,43 +44,43 @@ class Open_vip_tipLogic extends GetxController {
|
|||||||
|
|
||||||
startPayment() async {
|
startPayment() async {
|
||||||
if (isZfbPrice) {
|
if (isZfbPrice) {
|
||||||
var data = await DioManager.instance.post(url: Api.postAliPayOrder, params: {"product_id": priceBean[index].id, "type": 2});
|
var data = await DioManager.instance.post(
|
||||||
var bean = BaseResponse<PayUrlBean>.fromJson(data, (data) => PayUrlBean.fromJson(data));
|
url: Api.postAliPayOrder,
|
||||||
if(bean.isSuccess()){
|
params: {"product_id": priceBean[index].id, "type": 2});
|
||||||
openAliPay(bean.data.payUrl,(isSuccess,errorMsg){
|
var bean = BaseResponse<PayUrlBean>.fromJson(
|
||||||
|
data, (data) => PayUrlBean.fromJson(data));
|
||||||
|
if (bean.isSuccess()) {
|
||||||
|
openAliPay(bean.data.payUrl, (isSuccess, errorMsg) {
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
// 处理支付成功
|
// 处理支付成功
|
||||||
} else {
|
} else {
|
||||||
// 处理支付失败,errorMessage 可能为 null
|
// 处理支付失败,errorMessage 可能为 null
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}else {
|
} else {
|
||||||
showToast(bean.msg);
|
showToast(bean.msg);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
} else{
|
var data = await DioManager.instance.post(
|
||||||
var data = await DioManager.instance.post(url: Api.postWxOrder, params: {"product_id": priceBean[index].id, "type": 2});
|
url: Api.postWxOrder,
|
||||||
var bean = BaseResponse<PaymentData>.fromJson(data, (data) => PaymentData.fromJson(data));
|
params: {"product_id": priceBean[index].id, "type": 2});
|
||||||
if(bean.isSuccess()){
|
var bean = BaseResponse<PaymentData>.fromJson(
|
||||||
openWxPay(bean.data,(bool isSuccess, String? errorMessage) {
|
data, (data) => PaymentData.fromJson(data));
|
||||||
|
if (bean.isSuccess()) {
|
||||||
|
openWxPay(bean.data, (bool isSuccess, String? errorMessage) {
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
// 处理支付成功
|
// 处理支付成功
|
||||||
} else {
|
} else {
|
||||||
// 处理支付失败,errorMessage 可能为 null
|
// 处理支付失败,errorMessage 可能为 null
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}else {
|
} else {
|
||||||
showToast(bean.msg);
|
showToast(bean.msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PayUrlBean {
|
class PayUrlBean {
|
||||||
String payUrl;
|
String payUrl;
|
||||||
|
|
||||||
@ -78,8 +95,6 @@ class PayUrlBean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PaymentData {
|
class PaymentData {
|
||||||
String appId;
|
String appId;
|
||||||
String mchId;
|
String mchId;
|
||||||
@ -112,13 +127,12 @@ class PaymentData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PriceBean {
|
class PriceBean {
|
||||||
int id;
|
int id;
|
||||||
String title;
|
String title;
|
||||||
double amount;
|
double amount;
|
||||||
double oldAmount;
|
double oldAmount;
|
||||||
|
bool isYearVip;
|
||||||
String iosItem;
|
String iosItem;
|
||||||
|
|
||||||
PriceBean({
|
PriceBean({
|
||||||
@ -126,16 +140,18 @@ class PriceBean {
|
|||||||
required this.title,
|
required this.title,
|
||||||
required this.amount,
|
required this.amount,
|
||||||
required this.oldAmount,
|
required this.oldAmount,
|
||||||
|
required this.isYearVip,
|
||||||
required this.iosItem,
|
required this.iosItem,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory PriceBean.fromJson(Map<String, dynamic> json) {
|
factory PriceBean.fromJson(Map<String, dynamic> json) {
|
||||||
return PriceBean(
|
return PriceBean(
|
||||||
id: json['id'],
|
id: json['id'] as int,
|
||||||
title: json['title'],
|
title: json['title'] as String,
|
||||||
amount: json['amount'].toDouble(),
|
amount: json['amount'] as double,
|
||||||
oldAmount: json['old_amount'].toDouble(),
|
oldAmount: json['old_amount'] as double,
|
||||||
iosItem: json['ios_item'],
|
isYearVip: json['is_year_vip'] as bool,
|
||||||
|
iosItem: json['ios_item'] as String,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,9 @@ import 'package:get/get.dart';
|
|||||||
import 'logic.dart';
|
import 'logic.dart';
|
||||||
|
|
||||||
class Open_vip_tipPage extends StatelessWidget {
|
class Open_vip_tipPage extends StatelessWidget {
|
||||||
Open_vip_tipPage({Key? key}) : super(key: key);
|
final bool isYean;
|
||||||
|
|
||||||
|
Open_vip_tipPage(this.isYean, {Key? key}) : super(key: key);
|
||||||
|
|
||||||
final logic = Get.put(Open_vip_tipLogic());
|
final logic = Get.put(Open_vip_tipLogic());
|
||||||
final state = Get.find<Open_vip_tipLogic>().state;
|
final state = Get.find<Open_vip_tipLogic>().state;
|
||||||
@ -44,6 +46,9 @@ class Open_vip_tipPage extends StatelessWidget {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
return GetBuilder(builder: (Open_vip_tipLogic controller) {
|
return GetBuilder(builder: (Open_vip_tipLogic controller) {
|
||||||
|
if(isYean){
|
||||||
|
controller.setYean();
|
||||||
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
body: SizedBox(
|
body: SizedBox(
|
||||||
@ -91,7 +96,7 @@ class Open_vip_tipPage extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
loop: true,
|
loop: true,
|
||||||
autoplay: true,
|
autoplay: true,
|
||||||
pagination: new SwiperPagination(
|
pagination: SwiperPagination(
|
||||||
builder: DotSwiperPaginationBuilder(
|
builder: DotSwiperPaginationBuilder(
|
||||||
color: Color(0x99FFFFFF),
|
color: Color(0x99FFFFFF),
|
||||||
size: 4.sp,
|
size: 4.sp,
|
||||||
@ -268,8 +273,13 @@ class Open_vip_tipPage extends StatelessWidget {
|
|||||||
String formattedPricePerDay = '${pricePerDay.toStringAsFixed(2)}元/天';
|
String formattedPricePerDay = '${pricePerDay.toStringAsFixed(2)}元/天';
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
controller.index = index;
|
if(!isYean){
|
||||||
controller.update();
|
controller.index = index;
|
||||||
|
controller.update();
|
||||||
|
}else{
|
||||||
|
showToast("只有年会员才可使用至尊喊话哦~");
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
child: Stack(
|
child: Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
@ -292,6 +302,7 @@ class Open_vip_tipPage extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
|
SizedBox(height: 0.1.sp,),
|
||||||
Text(
|
Text(
|
||||||
controller.priceBean[index].title,
|
controller.priceBean[index].title,
|
||||||
style: TextStyle(color: Colors.white, fontSize: 14.sp),
|
style: TextStyle(color: Colors.white, fontSize: 14.sp),
|
||||||
@ -324,7 +335,7 @@ class Open_vip_tipPage extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
controller.priceBean[index].title=="年度会员"? Positioned(
|
controller.priceBean[index].isYearVip ? Positioned(
|
||||||
top: 0.sp,
|
top: 0.sp,
|
||||||
left: 0.sp,
|
left: 0.sp,
|
||||||
child: Image.asset(getMineImage("icon_yean_vip")),
|
child: Image.asset(getMineImage("icon_yean_vip")),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user