1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279 |
- import 'dart:convert';
- import 'dart:math';
- import 'package:flustars/flustars.dart' as FlutterStars;
- import 'package:flutter/material.dart';
- import 'package:flutter_alipay/flutter_alipay.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:flutter_spinkit/flutter_spinkit.dart';
- import 'package:fluwx/fluwx.dart' as fluwx;
- import 'package:liftmanager/common/common.dart';
- import 'package:liftmanager/internal/bbs/bbs_router.dart';
- import 'package:liftmanager/internal/bbs/model/liftcase_model.dart';
- import 'package:liftmanager/net/api_service.dart';
- import 'package:liftmanager/res/resources.dart';
- import 'package:liftmanager/routers/fluro_navigator.dart';
- import 'package:liftmanager/utils/fast_notification.dart';
- import 'package:liftmanager/utils/theme_utils.dart';
- import 'package:liftmanager/utils/time_format.dart';
- import 'package:liftmanager/utils/toast.dart';
- import 'package:liftmanager/widgets/app_bar.dart';
- import 'package:liftmanager/widgets/load_image.dart';
- class BuyService extends StatefulWidget {
- BuyService(this.id);
- final String id;
- @override
- State<StatefulWidget> createState() {
- return BuyServiceState();
- }
- }
- class BuyServiceState extends State<BuyService> {
- // ExpertListState({Key key}) : super(key: key);
- bool sortBool = true;
- String couponChiose = '请选择';
- String redChiose = '请选择';
- String typeName = "卡券";
- String questionType;
- int typeIdssCoupon;
- int typeIdssRed;
- double priceCoupon = 0.0;
- double priceRed = 0.0;
- double priceTotal = 0.0;
- // int dataId;
- // String expertName;
- // double expertFee;
- // double apiExpertFee = 0.0;
- bool _hasData = false;
- @override
- initState() {
- super.initState();
- setSchema();
- _initFluwx();
- // getDataId();
- // getType();
- // getExpertName();
- // getExpertFee();
- getBrandDetail();
- getCoupon();
- indexNow = 0;
- }
- _initFluwx() async {
- await fluwx.registerWxApi(
- appId: "wx0f10e6386fb9969e",
- doOnAndroid: true,
- doOnIOS: true,
- universalLink: "https://www.edtyun.com/");
- var result = await fluwx.isWeChatInstalled();
- setState(() {});
- }
- void setSchema() async {
- // await FlutterAlipay.setIosUrlSchema("tytylift");
- await FlutterAlipay.setIosUrlSchema("com.tyty.lift.managers");
- }
- LiftCasesDetailModel detailObj;
- getBrandDetail() {
- NewApiService().getLiftcaseDetail(widget.id, onSuccess: (res) {
- detailObj = res;
- priceTotal = detailObj.totalCost;
- print(priceTotal);
- print(123);
- _hasData = true;
- setState(() {});
- }, onError: (code, msg) {
- toasts(msg);
- });
- }
- List<dynamic> couponList = [];
- Future getCouponList(type) async {
- couponList = [];
- await NewApiService().getCouponListNoPage(type, detailObj.totalCost,
- onSuccess: (res) {
- if (res != null) {
- couponList = res;
- print(jsonEncode(res));
- print(111222);
- setState(() {});
- }
- }, onError: (code, msg) {
- toasts(msg);
- });
- }
- // 根据orderNo获取支付宝订单信息
- Future getAlipayOrderInfo(ordersNo) async {
- await NewApiService().aliPay(
- orders: ordersNo,
- liftCaseType: detailObj.dataTable,
- onSuccess: (res) {
- callAlipay(res);
- },
- onError: (code, msg) {
- toasts(msg);
- });
- }
- dynamic _wxPay;
- wxMethod(_payInfo) {
- print(_payInfo["appid"]);
- fluwx
- .payWithWeChat(
- appId: _payInfo["appid"],
- partnerId: _payInfo["partnerid"],
- prepayId: _payInfo["prepayid"],
- packageValue: _payInfo["package"],
- nonceStr: _payInfo["noncestr"],
- timeStamp: int.parse(_payInfo["timestamp"]),
- sign: _payInfo["sign"])
- .then((data) {
- print(data);
- });
- _wxPay?.cancel();
- _wxPay = fluwx.responseFromPayment
- .listen((fluwx.WeChatPaymentResponse response) async {
- print("WeChatPaymentResponse" + response.errCode.toString());
- if (response.errCode == -2) {
- //支付取消
- toasts("支付取消");
- } else if (response.errCode == -1) {
- //支付失败
- toasts("支付失败");
- } else if (response.errCode == 0) {
- //支付成功
- upDataMoney();
- if (detailObj.dataTable == 1) {
- getRoom();
- } else {
- Navigator.of(context)..pop()..pop();
- }
- }
- });
- }
- // 根据orderNo获取wx订单信息
- Future getWxOrderInfo(ordersNo) async {
- // int liftCaseType;
- // questionType == "1" ? liftCaseType = 1 : liftCaseType = 2;
- await NewApiService().wxPay(
- orders: ordersNo,
- liftCaseType: detailObj.dataTable,
- onSuccess: (res) {
- wxMethod(res);
- },
- onError: (code, msg) {
- toasts(msg);
- });
- }
- //余额支付
- Future lastMoneyPay(orders) async {
- int liftCaseType;
- String payType;
- detailObj.dataTable == 1 ? liftCaseType = 1 : liftCaseType = 2;
- detailObj.dataTable == 1 ? payType = "CASE" : payType = "CALL";
- await NewApiService().getAlipayBalanceApp({
- "payType": payType,
- "orders": orders,
- "liftCaseType": liftCaseType,
- "userId": FlutterStars.SpUtil.getString(Constant.userId),
- }, onSuccess: (res) {
- // moneyList = res;
- upDataMoney();
- if (detailObj.dataTable == 1) {
- getRoom();
- } else {
- Navigator.of(context)..pop()..pop();
- }
- }, onError: (code, msg) {
- toasts(msg);
- });
- }
- //根据专家Id和诊单Id获取orderId
- Future generateOrder(int type) async {
- if (detailObj.orderNo != null) {
- if (type == 0) {
- showAlert(
- context,
- "提示",
- "确定支付?",
- "确定",
- () {
- lastMoneyPay(detailObj.orderNo);
- NavigatorUtils.goBack(context);
- },
- txt2: "取消",
- onPre2: () {
- NavigatorUtils.goBack(context);
- },
- );
- } else if (type == 1) {
- getAlipayOrderInfo(detailObj.orderNo);
- } else if (type == 2) {
- getWxOrderInfo(detailObj.orderNo);
- }
- } else {
- await NewApiService().generateOrder({
- "id": detailObj.id,
- "chargerId": detailObj.chargerId,
- "couponId": typeIdssCoupon,
- "packetId": typeIdssRed
- }, onSuccess: (res) {
- print(res);
- if (res != null) {
- if (type == 0) {
- lastMoneyPay(res);
- } else if (type == 1) {
- getAlipayOrderInfo(res);
- } else if (type == 2) {
- getWxOrderInfo(res);
- }
- }
- print(555);
- }, onError: (code, msg) {
- toasts(msg);
- });
- }
- }
- upDataMoney() {
- String initThisUserMoney = randomInt(1111, 9999).toString() +
- DateTime.now().millisecondsSinceEpoch.toString();
- FastNotification.push("initUserMoney", initThisUserMoney);
- }
- randomInt(int min, int max) {
- return new Random().nextInt(max) % (max - min + 1) + min;
- }
- //支付完成后用诊单Id获取房间号
- Future getRoom() async {
- // Navigator.of(context)..pop()..pop();
- await NewApiService().findOne(widget.id, onSuccess: (res) {
- print(res);
- String roomId = res.sessionid;
- toasts("支付成功,即将进入聊天室!");
- NavigatorUtils.push(context,
- "${BbsRouter.chatRoom}?id=$roomId&type=someToOne&toUserId=''");
- // toasts("欢迎使用,请在使用过程中注意个人信息及财产安全!");
- print(666);
- }, onError: (code, msg) {
- toasts(msg);
- });
- }
- @override
- void dispose() {
- // setExpertFee(0.0);
- super.dispose();
- }
- void callAlipay(String _payInfo) async {
- AlipayResult payResult;
- try {
- print("The pay info is : " + _payInfo);
- payResult = await FlutterAlipay.pay(_payInfo);
- } on Exception catch (e) {
- payResult = null;
- }
- print(payResult);
- if (payResult != null) {
- if (payResult.resultStatus == "9000") {
- upDataMoney();
- if (detailObj.dataTable == 1) {
- getRoom();
- } else {
- Navigator.of(context)..pop()..pop();
- }
- } else {
- toasts(payResult.memo);
- }
- } else {
- toasts("支付异常");
- }
- }
- String balance = '0';
- Future getCoupon() async {
- await NewApiService().getUserCoupons(onSuccess: (res) {
- if (res != null) {
- balance = res["balance"].toString();
- setState(() {});
- print(6666544);
- }
- }, onError: (code, msg) {
- toasts(msg);
- });
- }
- static const payType = [
- {
- "icon": "tab_first/pay_yue",
- "title": "账户余额",
- "price": "",
- },
- {
- "icon": "tab_first/pay_zhifubao",
- "title": "支付宝",
- },
- {
- "icon": "tab_first/pay_winxin",
- "title": "微信",
- },
- ];
- List<String> labelList = ["特邀专家", "回复及时"];
- List<String> sortListChiose = [
- "综合排序",
- "咨询人数",
- "评论星级",
- "回复速度",
- ];
- getScenario(int type) {
- String str;
- if (type == 0) {
- str = "全场通用";
- } else if (type == 1) {
- str = "出诊问诊服务";
- } else if (type == 2) {
- str = "题库";
- } else if (type == 3) {
- str = "视频";
- }
- return str;
- }
- int indexNow = 999;
- String checkFalse = "tab_first/check_false";
- String checkTrue = "tab_first/check_true";
- @override
- Widget build(BuildContext context) {
- double width = MediaQuery.of(context).size.width;
- double height = MediaQuery.of(context).size.height;
- return Container(
- child: Scaffold(
- appBar: MyAppBar(
- centerTitle: "购买服务",
- ),
- body: _hasData
- ? Container(
- child: Stack(
- children: <Widget>[
- Container(
- // padding: EdgeInsets.only(top:70),
- child: ListView(children: <Widget>[
- Container(
- padding: EdgeInsets.all(ScreenUtil().setWidth(15)),
- decoration: BoxDecoration(
- border: Border(
- bottom: BorderSide(
- width: 5, color: Color(0xfff5f5f5)),
- ),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Row(
- crossAxisAlignment:
- CrossAxisAlignment.center,
- children: <Widget>[
- Text(
- detailObj.dataTable == 1
- ? "问诊服务"
- : "出诊服务",
- style: TextStyle(
- color: Color(0xff333333),
- fontSize: ScreenUtil().setSp(16)),
- textAlign: TextAlign.start,
- ),
- // Container(
- // padding: EdgeInsets.only(
- // left: ScreenUtil().setWidth(10)),
- // child: Text(
- // detailObj.name ?? "",
- // style: TextStyle(
- // color: Color(0xff666666),
- // fontSize: ScreenUtil().setSp(16)),
- // textAlign: TextAlign.start,
- // ),
- // )
- ]),
- Container(
- child: Text(
- detailObj.totalCost != null
- ? detailObj.totalCost.toString()
- : "0.0",
- style: TextStyle(
- color: Colors.red,
- fontSize: ScreenUtil().setSp(16)),
- textAlign: TextAlign.end,
- ),
- )
- ])),
- // ChioseThis(list: quanListChiose,label: "优惠券",labelText: '无可用优惠券',value:quanChiose,fun:(index){
- // setState(() {
- // quanChiose = quanListChiose[index];
- // });
- // Navigator.maybePop(context);
- // }),
- detailObj.dataTable == 2
- ? Container(
- padding: EdgeInsets.only(
- left: ScreenUtil().setWidth(15),
- right: ScreenUtil().setWidth(15),
- top: ScreenUtil().setWidth(10),
- bottom: ScreenUtil().setWidth(10)),
- decoration: BoxDecoration(
- border: Border(
- bottom: BorderSide(
- width: 5, color: Color(0xfff5f5f5)),
- ),
- ),
- child: Row(
- mainAxisAlignment:
- MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text(
- "差旅费",
- style: TextStyle(
- color: Color(0xff222222),
- fontSize: ScreenUtil().setSp(14)),
- textAlign: TextAlign.start,
- ),
- Text(
- "¥${detailObj.travelCost.toString()}",
- style: TextStyle(
- color: Colors.red,
- fontSize: ScreenUtil().setSp(14)),
- textAlign: TextAlign.start,
- ),
- ]),
- )
- : Container(child: null),
- detailObj.dataTable == 2
- ? Container(
- padding: EdgeInsets.only(
- left: ScreenUtil().setWidth(15),
- right: ScreenUtil().setWidth(15),
- top: ScreenUtil().setWidth(10),
- bottom: ScreenUtil().setWidth(10)),
- decoration: BoxDecoration(
- border: Border(
- bottom: BorderSide(
- width: 5, color: Color(0xfff5f5f5)),
- ),
- ),
- child: Row(
- mainAxisAlignment:
- MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text(
- "服务费",
- style: TextStyle(
- color: Color(0xff222222),
- fontSize: ScreenUtil().setSp(14)),
- textAlign: TextAlign.start,
- ),
- Text(
- "¥${detailObj.serviceCost.toString()}",
- style: TextStyle(
- color: Colors.red,
- fontSize: ScreenUtil().setSp(14)),
- textAlign: TextAlign.start,
- ),
- ]),
- )
- : Container(child: null),
- detailObj.orderNo == null
- ? ChioseThisRight(
- label: "优惠券",
- labelText: '无可用优惠券',
- value: couponChiose,
- fun: () {
- setState(() {
- // brandChiose = brandListChiose[index];
- typeName = "卡券";
- sortBool = false;
- print(5656333);
- });
- getCouponList(1);
- // Navigator.maybePop(context);
- })
- : Container(child: null),
- detailObj.orderNo == null
- ? ChioseThisRight(
- label: "红包",
- labelText: '无可用红包',
- value: redChiose,
- fun: () {
- setState(() {
- // brandChiose = brandListChiose[index];
- typeName = "红包";
- sortBool = false;
- print(5656333);
- });
- getCouponList(2);
- // Navigator.maybePop(context);
- })
- : Container(child: null),
- // ChioseThis(list: redListChiose,label: "红包",labelText: '无可用红包',value:redChiose,fun:(index){
- // setState(() {
- // redChiose = redListChiose[index];
- // });
- // Navigator.maybePop(context);
- // }),
- Container(
- padding: EdgeInsets.only(
- left: ScreenUtil().setWidth(15),
- right: ScreenUtil().setWidth(15),
- top: ScreenUtil().setWidth(10),
- bottom: ScreenUtil().setWidth(10)),
- decoration: BoxDecoration(
- border: Border(
- bottom:
- BorderSide(width: 5, color: Color(0xfff5f5f5)),
- ),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text(
- "共需支付",
- style: TextStyle(
- color: Color(0xff222222),
- fontSize: ScreenUtil().setSp(14)),
- textAlign: TextAlign.start,
- ),
- Text(
- "¥${detailObj.orderNo == null ? priceTotal.toStringAsFixed(2).toString() : detailObj.payCost != null ? detailObj.payCost.toStringAsFixed(2).toString() : "0.0"}",
- style: TextStyle(
- color: Colors.red,
- fontSize: ScreenUtil().setSp(14)),
- textAlign: TextAlign.start,
- ),
- ]),
- ),
- Container(
- padding: EdgeInsets.only(
- left: ScreenUtil().setWidth(15),
- right: ScreenUtil().setWidth(15),
- top: ScreenUtil().setWidth(10),
- bottom: ScreenUtil().setWidth(10)),
- decoration: BoxDecoration(
- border: Border(
- bottom: BorderSide(
- width: 0.5, color: Color(0xfff5f5f5)),
- ),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text(
- "选择支付方式",
- style: TextStyle(
- color: Color(0xff000000),
- fontSize: ScreenUtil().setSp(16)),
- textAlign: TextAlign.start,
- ),
- ]),
- ),
- Container(
- padding: EdgeInsets.only(
- left: ScreenUtil().setWidth(15),
- bottom: ScreenUtil().setWidth(80),
- right: ScreenUtil().setWidth(15)),
- child: Column(
- children: payType.asMap().keys.map((i) {
- return Container(
- decoration: BoxDecoration(
- border: Border(
- bottom: BorderSide(
- width: 0.5, color: Color(0xfff5f5f5)),
- ),
- ),
- height: 60,
- child: InkWell(
- onTap: () {
- setState(() {
- indexNow = i;
- });
- print(indexNow);
- },
- child: Row(
- mainAxisAlignment:
- MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Row(
- children: <Widget>[
- LoadAssetImage(
- // image: AssetImage(i['img']),
- payType[i]["icon"],
- width:
- ScreenUtil().setWidth(20),
- height:
- ScreenUtil().setWidth(20),
- // alignment: Alignment.centerLeft,
- ),
- Container(width: 5, child: null),
- Text(
- payType[i]["title"],
- style: TextStyle(
- color: Color(0xff000000),
- fontSize:
- ScreenUtil().setSp(14)),
- textAlign: TextAlign.start,
- ),
- Container(width: 5, child: null),
- Text(
- payType[i]["price"] != null
- ? "¥$balance"
- : "",
- style: TextStyle(
- color: Color(0xff999999),
- fontSize:
- ScreenUtil().setSp(16)),
- textAlign: TextAlign.start,
- ),
- ],
- ),
- Container(
- // padding: EdgeInsets.only(top:10,left:5,right:5,bottom:10),
- child: LoadAssetImage(
- // image: AssetImage(i['img']),
- indexNow == i
- ? checkTrue
- : checkFalse,
- width: ScreenUtil().setWidth(18),
- height: ScreenUtil().setWidth(18),
- // alignment: Alignment.centerLeft,
- ),
- ),
- ])),
- );
- }).toList(),
- ))
- ]),
- ),
- Positioned(
- bottom: 0,
- left: 0,
- child: Container(
- width: width,
- padding: EdgeInsets.only(
- top: ScreenUtil().setWidth(15),
- bottom: ScreenUtil().setWidth(15),
- left: ScreenUtil().setWidth(25),
- right: ScreenUtil().setWidth(25)),
- color: Colors.white,
- child: Container(
- height: 44,
- decoration: BoxDecoration(
- color: Colours.blue_app_main,
- borderRadius: BorderRadius.circular(22.0),
- // gradient: const LinearGradient(
- // colors: [Color(0xFF00D9FF), Color(0xFF0287FF)]),
- ),
- child: FlatButton(
- // padding: EdgeInsets.all(15.0),
- child: Text("立即购买"),
- textColor: Colors.white,
- onPressed: () {
- // NavigatorUtils.push(context, "${BbsRouter.chatRoom}?id=1111");
- if (priceTotal <= 0 && indexNow != 0) {
- toasts("支付金额为0,请使用余额支付!");
- return;
- }
- if (indexNow == 0) {
- generateOrder(0);
- // NavigatorUtils.push(context, BbsRouter.chatRoom);
- } else if (indexNow == 1) {
- generateOrder(1);
- // NewApiService().aliPayOrder(orders,
- // onSuccess: (res) {
- // callAlipay(res);
- // }, onError: (code, msg) {
- // toasts(msg);
- // });
- } else if (indexNow == 2) {
- generateOrder(2);
- } else {
- toasts("选择支付方式");
- }
- },
- ),
- ),
- )),
- !sortBool
- ? Positioned(
- top: 0,
- left: 0,
- child: GestureDetector(
- onTap: () {
- setState(() {
- sortBool = true;
- });
- },
- child: Container(
- width: width,
- height: height,
- color: Color.fromRGBO(0, 0, 0, 0.5)),
- ),
- )
- : Container(child: null),
- !sortBool
- ? Positioned(
- top: 0,
- right: 0,
- child: Container(
- width: width / 4 * 3,
- height: height,
- color: Colors.white,
- padding: EdgeInsets.all(10),
- child: ListView(
- children: <Widget>[
- Container(
- padding: EdgeInsets.only(
- left: 5, top: 5, bottom: 10),
- child: Text(
- typeName,
- style: TextStyle(
- color: Color(0xff666666),
- fontSize: ScreenUtil().setSp(16)),
- textAlign: TextAlign.start,
- ),
- ),
- InkWell(
- onTap: () {
- setState(() {
- priceTotal = detailObj.totalCost;
- sortBool = true;
- if (typeName == "卡券") {
- priceCoupon = 0.0;
- couponChiose = '请选择';
- typeIdssCoupon = null;
- } else if (typeName == "红包") {
- priceRed = 0.0;
- redChiose = '请选择';
- typeIdssRed = null;
- }
- print(priceCoupon);
- print(priceRed);
- print(123465798);
- if ((priceTotal -
- priceCoupon -
- priceRed) <
- 0) {
- priceTotal = 0;
- } else {
- priceTotal = priceTotal -
- priceCoupon -
- priceRed;
- }
- couponList = [];
- });
- },
- child: Container(
- // width: width / 4 - 17,
- padding: EdgeInsets.only(
- bottom: ScreenUtil().setWidth(10),
- left: ScreenUtil().setWidth(10),
- right: ScreenUtil().setWidth(10),
- top: ScreenUtil().setWidth(10)),
- margin: EdgeInsets.only(
- left: 5, right: 5, bottom: 5, top: 5),
- decoration: BoxDecoration(
- // border: Border(
- // bottom: BorderSide(width: 0.5, color: Colours.line),
- // ),
- color: Color(0xfff5f5f5)),
- child: Text(
- "不选择$typeName",
- style: TextStyle(
- color: Color(0xff000000),
- fontSize: ScreenUtil().setSp(14)),
- textAlign: TextAlign.center,
- ),
- ),
- ),
- couponList != null && couponList.length > 0
- ? Container(
- child: Wrap(
- alignment: WrapAlignment.start,
- crossAxisAlignment:
- WrapCrossAlignment.center,
- children: couponList
- .asMap()
- .keys
- .map<Widget>((index) {
- return hongbaoCell(index);
- // InkWell(
- // onTap: () {
- // setState(() {
- // priceTotal =
- // detailObj.totalCost;
- // sortBool = true;
- // if (typeName == "卡券") {
- // // if (priceTotal -
- // // couponList[index]
- // // .coupon
- // // .price >
- // // 0.0) {
- // // priceCoupon =
- // // couponList[index]
- // // .coupon
- // // .price;
- // // }else {
- // // priceTotal = 0.0;
- // // }
- // priceCoupon =
- // couponList[index]
- // .coupon
- // .discount;
- // couponChiose =
- // couponList[index]
- // .coupon
- // .name ??
- // "";
- // typeIdssCoupon =
- // couponList[index].id;
- // } else if (typeName == "红包") {
- // // if (priceTotal -
- // // couponList[index]
- // // .coupon
- // // .price >
- // // 0.0) {
- // // priceRed =
- // // couponList[index]
- // // .coupon
- // // .price;
- // // }else {
- // // priceTotal = 0.0;
- // // }
- // priceRed = couponList[index]
- // .coupon
- // .price;
- // redChiose =
- // couponList[index]
- // .coupon
- // .name ??
- // "";
- // typeIdssRed =
- // couponList[index].id;
- // }
- // if ((priceTotal -
- // priceCoupon -
- // priceRed) <
- // 0) {
- // priceTotal = 0;
- // } else {
- // priceTotal = priceTotal -
- // priceCoupon -
- // priceRed;
- // }
- // couponList = [];
- // });
- // },
- // child: Container(
- // // width: width / 4 - 17,
- // padding: EdgeInsets.only(
- // bottom: ScreenUtil()
- // .setWidth(10),
- // left: ScreenUtil()
- // .setWidth(10),
- // right: ScreenUtil()
- // .setWidth(10),
- // top: ScreenUtil()
- // .setWidth(10)),
- // margin: EdgeInsets.only(
- // left: 5,
- // right: 5,
- // bottom: 5,
- // top: 5),
- // decoration: BoxDecoration(
- // // border: Border(
- // // bottom: BorderSide(width: 0.5, color: Colours.line),
- // // ),
- // color: Color(0xfff5f5f5)),
- // child: Text(
- // couponList[index]
- // .coupon
- // .name ??
- // "",
- // style: typeName == "卡券"
- // ? TextStyle(
- // color: typeIdssCoupon ==
- // couponList[
- // index]
- // .id
- // ? Color(
- // 0xffff0000)
- // : Color(
- // 0xff000000),
- // fontSize: ScreenUtil()
- // .setSp(14))
- // : TextStyle(
- // color: typeIdssRed ==
- // couponList[
- // index]
- // .id
- // ? Color(
- // 0xffff0000)
- // : Color(
- // 0xff000000),
- // fontSize: ScreenUtil()
- // .setSp(14)),
- // textAlign: TextAlign.center,
- // ),
- // ),
- // );
- }).toList(),
- ))
- : Center(child: Text("暂无")),
- ],
- )))
- : Container(child: null),
- ],
- ))
- : Center(
- child: Text("正在加载..."),
- ),
- ),
- );
- }
- hongbaoCell(index) {
- // typeName == "卡券"
- return InkWell(
- onTap: () {
- setState(() {
- priceTotal = detailObj.totalCost;
- sortBool = true;
- if (typeName == "卡券") {
- priceCoupon = couponList[index].coupon.discount;
- couponChiose = couponList[index].coupon.name ?? "";
- typeIdssCoupon = couponList[index].id;
- } else if (typeName == "红包") {
- priceRed = couponList[index].coupon.price;
- redChiose = couponList[index].coupon.name ?? "";
- typeIdssRed = couponList[index].id;
- }
- if ((priceTotal - priceCoupon - priceRed) < 0) {
- priceTotal = 0;
- } else {
- priceTotal = priceTotal - priceCoupon - priceRed;
- }
- couponList = [];
- });
- },
- child: typeName == "红包"
- ? Container(
- margin: EdgeInsets.only(left: 0, right: 0, bottom: 5, top: 5),
- child: Stack(
- children: [
- Container(
- height: 80,
- width: 300,
- // color: Colors.red,
- child: LoadAssetImage(
- "hongbaoBg",
- fit: BoxFit.fill,
- ),
- ),
- Container(
- height: 80,
- width: 300,
- // width: width / 4 - 17,
- padding: EdgeInsets.only(
- bottom: ScreenUtil().setWidth(10),
- left: ScreenUtil().setWidth(10),
- right: ScreenUtil().setWidth(10),
- top: ScreenUtil().setWidth(10)),
- margin:
- EdgeInsets.only(left: 5, right: 5, bottom: 5, top: 5),
- child: Row(
- children: [
- Text('¥${couponList[index].coupon.price}',
- style:
- TextStyle(color: Colors.red, fontSize: 25)),
- Text(' ¥${couponList[index].coupon.name}',
- style:
- TextStyle(color: Colors.red, fontSize: 13)),
- Expanded(child: Container()),
- Text('立即使用',
- style:
- TextStyle(color: Colors.red, fontSize: 14)),
- ],
- )),
- Positioned(
- top: 0,
- left: 0,
- child: Container(
- color: Color(0xFFDDD9),
- child: Text(' 通用红包 ',
- style: TextStyle(color: Colors.red)),
- ))
- ],
- ))
- : Container(
- margin: EdgeInsets.only(left: 0, right: 0, bottom: 5, top: 5),
- child: Stack(
- children: [
- Positioned(
- top: 0,
- left: -10,
- // right: -30,
- child: Container(
- width: 300,
- height: 122,
- child: LoadAssetImage(
- // image: AssetImage(i['img']),
- "youhuijuanBg",
- fit: BoxFit.fill,
- // alignment: Alignment.centerLeft,
- ),
- )),
- Container(
- // decoration: BoxDecoration(
- // border:Border.all(
- // width:2,
- // color:Colors.red
- // )
- // ),
- width: 300,
- height: 90,
- child: Row(
- children: <Widget>[
- Container(
- // padding: EdgeInsets.only(right: 10, left: 15),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Container(
- width: 100,
- child: Row(
- crossAxisAlignment:
- CrossAxisAlignment.end,
- mainAxisAlignment:
- MainAxisAlignment.center,
- children: <Widget>[
- Text(
- '¥',
- textAlign: TextAlign.left,
- style: TextStyle(
- fontSize: ScreenUtil().setSp(16),
- color: Colors.white),
- ),
- Text(
- // '999.0',
- '${couponList[index].coupon?.discount ?? ''}',
- textAlign: TextAlign.left,
- style: TextStyle(
- fontSize: ScreenUtil().setSp(20),
- color: Colors.white,
- fontWeight: FontWeight.bold),
- ),
- SizedBox(
- width: 20,
- )
- ],
- ),
- ),
- Container(
- margin: EdgeInsets.only(left: 20),
- padding: EdgeInsets.fromLTRB(5, 1, 5, 1),
- child: Text(
- // getScenario(provider
- // .list[index]
- // .coupon
- // ?.scenario ??
- // 0),
- '代金劵',
- textAlign: TextAlign.center,
- style: TextStyle(
- fontSize: ScreenUtil().setSp(11),
- color: Colors.white),
- ),
- decoration: new BoxDecoration(
- //背景
- // color: Colors.white,
- //设置四周圆角 角度
- borderRadius: BorderRadius.all(
- Radius.circular(4.0)),
- //设置四周边框
- border: Border.all(
- width: 1, color: Colors.white),
- ),
- ),
- ]),
- ),
- Container(
- padding: EdgeInsets.only(top: 30),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Text(
- '${getScenario(couponList[index].coupon?.scenario ?? 0)}${couponList[index].coupon?.name ?? ""}',
- textAlign: TextAlign.left,
- style: TextStyle(
- fontSize: ScreenUtil().setSp(14),
- color: Color(0xff333333),
- ),
- ),
- Text(
- '有效时间: ' +
- DateUtils.instance.getFormartData(
- timeSamp: couponList[index]
- .coupon
- ?.validity ??
- 0,
- format: "yyyy.MM.dd HH:mm"),
- textAlign: TextAlign.left,
- style: TextStyle(
- fontSize: ScreenUtil().setSp(11),
- color: Color(0xff9F9C9F),
- ),
- ),
- SizedBox(height: 5),
- Container(
- width: 230 * 0.5,
- height: 0.5,
- color: Color(0xffeeeeee),
- child: null,
- ),
- SizedBox(height: 3),
- Text(
- couponList[index].coupon?.remark ?? "",
- textAlign: TextAlign.left,
- style: TextStyle(
- fontSize: ScreenUtil().setSp(11),
- color: Color(0xff9F9C9F),
- ),
- ),
- ])),
- ],
- )),
- ],
- )),
- );
- }
- Widget loadCircle() {
- return Container(
- padding: EdgeInsets.only(top: 10, bottom: 10),
- color: ThemeUtils.getTabsBg(context),
- child: Center(
- child: SpinKitFadingCircle(
- color: Colors.blueAccent,
- size: 30.0,
- ),
- ),
- );
- }
- }
- class ChioseThisRight extends StatelessWidget {
- ChioseThisRight(
- {Key key,
- this.value,
- this.label,
- this.fun,
- this.labelText,
- this.labelTextColor = const Color(0xffcccccc)})
- : super(key: key);
- String value;
- String label;
- Function fun;
- String labelText;
- Color labelTextColor;
- @override
- Widget build(BuildContext context) {
- double width = MediaQuery.of(context).size.width;
- return InkWell(
- onTap: () {
- fun();
- },
- child: Container(
- padding: EdgeInsets.only(
- top: ScreenUtil().setWidth(15), bottom: ScreenUtil().setWidth(15)),
- margin: EdgeInsets.only(left: ScreenUtil().setWidth(15)),
- decoration: BoxDecoration(
- border: Border(
- bottom: BorderSide(width: 0.5, color: Colours.line),
- ),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text(
- label,
- style: TextStyle(
- color: Color(0xff222222),
- // fontSize: ScreenUtil().setSp(14)
- ),
- textAlign: TextAlign.start,
- ),
- value.isEmpty
- ? Container(
- child: Row(children: <Widget>[
- Text(
- labelText,
- style: TextStyle(
- color: labelTextColor,
- // fontSize: ScreenUtil().setSp(14)
- ),
- textAlign: TextAlign.start,
- ),
- Container(
- padding: EdgeInsets.only(top: 3),
- child: Icon(
- Icons.keyboard_arrow_right,
- size: 20.0,
- color: labelTextColor,
- ),
- ),
- SizedBox(width: 10)
- ]),
- )
- : Container(
- padding:
- EdgeInsets.only(right: ScreenUtil().setWidth(15)),
- child: Row(children: <Widget>[
- Text(
- value,
- style: TextStyle(
- color: Color(0xff222222),
- fontSize: ScreenUtil().setSp(14)),
- textAlign: TextAlign.start,
- ),
- ]),
- ),
- ]),
- ),
- );
- }
- }
|