123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065 |
- import 'package:flutter/material.dart';
- import 'package:liftmanager/net/api_service.dart';
- import 'package:liftmanager/utils/toast.dart';
- import 'package:liftmanager/widgets/app_bar.dart';
- import 'package:liftmanager/res/resources.dart';
- import 'package:liftmanager/routers/fluro_navigator.dart';
- import 'package:liftmanager/widgets/load_image.dart';
- import 'package:liftmanager/internal/bbs/bbs_router.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:flutter_alipay/flutter_alipay.dart';
- import 'package:flutter_spinkit/flutter_spinkit.dart';
- import 'dart:convert';
- import 'package:shared_preferences/shared_preferences.dart';
- import 'package:flustars/flustars.dart' as FlutterStars;
- import 'package:liftmanager/common/common.dart';
- import 'package:liftmanager/utils/fast_notification.dart';
- import 'dart:math';
- import 'package:liftmanager/internal/bbs/model/liftcase_model.dart';
- import 'package:fluwx/fluwx.dart' as fluwx;
- import 'package:liftmanager/utils/theme_utils.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();
- // getDataId();
- // getType();
- // getExpertName();
- // getExpertFee();
- getBrandDetail();
- }
- 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);
- });
- }
- // void getDataId() async {
- // SharedPreferences prefs = await SharedPreferences.getInstance();
- // dataId = prefs.getInt("dataId");
- // }
- // void getType() async {
- // SharedPreferences prefs = await SharedPreferences.getInstance();
- // questionType = prefs.getString("questionType");
- // }
- // void getExpertName() async {
- // SharedPreferences prefs = await SharedPreferences.getInstance();
- // expertName = prefs.getString("expertName");
- // }
- // void getExpertFee() async {
- // SharedPreferences prefs = await SharedPreferences.getInstance();
- // expertFee = prefs.getDouble("expertFee");
- // setState(() {});
- // print(expertFee);
- // print(6666543);
- // // if (expertFee == 0.0) {
- // // getApiFee();
- // // } else {
- // // priceTotal = expertFee;
- // // }
- // }
- List<dynamic> couponList = [];
- Future getCouponList(type) async {
- await NewApiService().getCouponListNoPage(
- type,
- detailObj.totalCost, onSuccess: (res) {
- if (res != null) {
- couponList = res;
- print(jsonEncode(res));
- print(111222);
- setState(() {});
- }
- }, onError: (code, msg) {
- toasts(msg);
- });
- }
- // Future getApiFee() async {
- // await NewApiService().getFee(onSuccess: (res) {
- // if (res != null) {
- // apiExpertFee = res;
- // priceTotal = apiExpertFee;
- // setState(() {});
- // print(res);
- // print(6666544);
- // }
- // }, 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;
- }
- //根据orderId来判断支付完成
- // Future getPayType(orderId) async {
- // await NewApiService().getTestAlipayNotify(orderId, onSuccess: (res) {
- // print(res);
- // print(666);
- // getRoom();
- // }, onError: (code, msg) {
- // toasts(msg);
- // });
- // }
- //支付完成后用诊单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=''");
- print(666);
- }, onError: (code, msg) {
- toasts(msg);
- });
- }
- // void setExpertFee(double expertFee) async {
- // SharedPreferences prefs = await SharedPreferences.getInstance();
- // prefs.setDouble("expertFee", expertFee);
- // }
- @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("支付异常");
- }
- }
- 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 = [
- "综合排序",
- "咨询人数",
- "评论星级",
- "回复速度",
- ];
- 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
- // ? "¥${payType[i]["price"]}"
- // : "",
- // 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: ScreenUtil().setWidth(44),
- decoration: BoxDecoration(
- 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((index) {
- return 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("正在加载..."),
- ),
- ),
- );
- }
- 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})
- : super(key: key);
- String value;
- String label;
- Function fun;
- String labelText;
- @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: Color(0xffcccccc),
- // fontSize: ScreenUtil().setSp(14)
- ),
- textAlign: TextAlign.start,
- ),
- Container(
- padding: EdgeInsets.only(top: 3),
- child: Icon(
- Icons.keyboard_arrow_right,
- size: 20.0,
- color: Color(0xffcccccc),
- ),
- ),
- 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,
- ),
- ]),
- ),
- ]),
- ),
- );
- }
- }
|