import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:liftmanager/internal/bbs/bbs_router.dart'; import 'package:liftmanager/net/api_service.dart'; import 'package:liftmanager/res/colors.dart'; import 'package:liftmanager/routers/fluro_navigator.dart'; import 'package:liftmanager/utils/toast.dart'; import 'package:liftmanager/widgets/app_bar.dart'; import 'package:liftmanager/widgets/bbs_content.dart'; import 'package:liftmanager/widgets/load_image.dart'; class BuyServiceMaster extends StatefulWidget { // BuyService(this.id); // final String id; @override State createState() { return BuyServiceMasterState(); } } class BuyServiceMasterState extends State { // ExpertListState({Key key}) : super(key: key); static const payType = [ { "icon": "tab_first/pay_yue", "title": "账户余额", "price": "", }, { "icon": "tab_first/pay_zhifubao", "title": "支付宝", }, { "icon": "tab_first/pay_winxin", "title": "微信", }, ]; List labelList = ["特邀专家", "回复及时"]; List sortListChiose = [ "综合排序", "咨询人数", "评论星级", "回复速度", ]; String quanChiose = ""; List quanListChiose = ['quan1', 'quan2']; String redChiose = ""; List redListChiose = ['red1', 'red2']; int indexNow = 999; String checkFalse = "tab_first/check_false"; String checkTrue = "tab_first/check_true"; 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); }); } @override Widget build(BuildContext context) { double width = MediaQuery.of(context).size.width; double height = MediaQuery.of(context).size.height; return Container( child: Scaffold( resizeToAvoidBottomPadding: false, appBar: MyAppBar( centerTitle: "购买服务", ), body: Container( child: Stack( children: [ Container( // padding: EdgeInsets.only(top:70), child: ListView(children: [ Container( padding: EdgeInsets.all(ScreenUtil().setWidth(15)), decoration: BoxDecoration( border: Border( bottom: BorderSide(width: 5, color: Color(0xfff5f5f5)), ), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( "问诊服务", style: TextStyle( color: Color(0xff333333), fontSize: ScreenUtil().setSp(16)), textAlign: TextAlign.start, ), Container( padding: EdgeInsets.only( left: ScreenUtil().setWidth(10)), child: Text( "张涛", style: TextStyle( color: Color(0xff666666), fontSize: ScreenUtil().setSp(16)), textAlign: TextAlign.start, ), ) ]), Container( child: Text( "¥20", 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); }), 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: [ Text( "共需支付", style: TextStyle( color: Color(0xff222222), fontSize: ScreenUtil().setSp(14)), textAlign: TextAlign.start, ), Text( "¥20", 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: [ Text( "选择支付方式", style: TextStyle( color: Color(0xff000000), fontSize: ScreenUtil().setSp(16)), textAlign: TextAlign.start, ), ]), ), Container( padding: EdgeInsets.only( left: ScreenUtil().setWidth(15), 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: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ 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, ), // Text( // payType[i]["price"] != null?"¥${payType[i]["price"]}":"", // style: TextStyle( // color:Color(0xff999999), // fontSize:ScreenUtil().setSp(16) // ), // textAlign:TextAlign.start, // ), ], ), InkWell( child: 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, ), ), onTap: () { setState(() { indexNow = i; }); print(indexNow); }, ), ])); }).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); }, ), ), )) ], ))), ); } }