buy_service.dart 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:liftmanager/internal/bbs/bbs_router.dart';
  4. import 'package:liftmanager/net/api_service.dart';
  5. import 'package:liftmanager/res/colors.dart';
  6. import 'package:liftmanager/routers/fluro_navigator.dart';
  7. import 'package:liftmanager/utils/toast.dart';
  8. import 'package:liftmanager/widgets/app_bar.dart';
  9. import 'package:liftmanager/widgets/bbs_content.dart';
  10. import 'package:liftmanager/widgets/load_image.dart';
  11. class BuyServiceMaster extends StatefulWidget {
  12. // BuyService(this.id);
  13. // final String id;
  14. @override
  15. State<StatefulWidget> createState() {
  16. return BuyServiceMasterState();
  17. }
  18. }
  19. class BuyServiceMasterState extends State<BuyServiceMaster> {
  20. // ExpertListState({Key key}) : super(key: key);
  21. static const payType = [
  22. {
  23. "icon": "tab_first/pay_yue",
  24. "title": "账户余额",
  25. "price": "",
  26. },
  27. {
  28. "icon": "tab_first/pay_zhifubao",
  29. "title": "支付宝",
  30. },
  31. {
  32. "icon": "tab_first/pay_winxin",
  33. "title": "微信",
  34. },
  35. ];
  36. List<String> labelList = ["特邀专家", "回复及时"];
  37. List<String> sortListChiose = [
  38. "综合排序",
  39. "咨询人数",
  40. "评论星级",
  41. "回复速度",
  42. ];
  43. String quanChiose = "";
  44. List<String> quanListChiose = ['quan1', 'quan2'];
  45. String redChiose = "";
  46. List<String> redListChiose = ['red1', 'red2'];
  47. int indexNow = 999;
  48. String checkFalse = "tab_first/check_false";
  49. String checkTrue = "tab_first/check_true";
  50. String balance = '0';
  51. Future getCoupon() async {
  52. await NewApiService().getUserCoupons(onSuccess: (res) {
  53. if (res != null) {
  54. balance = res["balance"].toString();
  55. setState(() {});
  56. print(6666544);
  57. }
  58. }, onError: (code, msg) {
  59. toasts(msg);
  60. });
  61. }
  62. @override
  63. Widget build(BuildContext context) {
  64. double width = MediaQuery.of(context).size.width;
  65. double height = MediaQuery.of(context).size.height;
  66. return Container(
  67. child: Scaffold(
  68. resizeToAvoidBottomPadding: false,
  69. appBar: MyAppBar(
  70. centerTitle: "购买服务",
  71. ),
  72. body: Container(
  73. child: Stack(
  74. children: <Widget>[
  75. Container(
  76. // padding: EdgeInsets.only(top:70),
  77. child: ListView(children: <Widget>[
  78. Container(
  79. padding: EdgeInsets.all(ScreenUtil().setWidth(15)),
  80. decoration: BoxDecoration(
  81. border: Border(
  82. bottom:
  83. BorderSide(width: 5, color: Color(0xfff5f5f5)),
  84. ),
  85. ),
  86. child: Row(
  87. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  88. children: <Widget>[
  89. Row(
  90. crossAxisAlignment: CrossAxisAlignment.center,
  91. children: <Widget>[
  92. Text(
  93. "问诊服务",
  94. style: TextStyle(
  95. color: Color(0xff333333),
  96. fontSize: ScreenUtil().setSp(16)),
  97. textAlign: TextAlign.start,
  98. ),
  99. Container(
  100. padding: EdgeInsets.only(
  101. left: ScreenUtil().setWidth(10)),
  102. child: Text(
  103. "张涛",
  104. style: TextStyle(
  105. color: Color(0xff666666),
  106. fontSize: ScreenUtil().setSp(16)),
  107. textAlign: TextAlign.start,
  108. ),
  109. )
  110. ]),
  111. Container(
  112. child: Text(
  113. "¥20",
  114. style: TextStyle(
  115. color: Colors.red,
  116. fontSize: ScreenUtil().setSp(16)),
  117. textAlign: TextAlign.end,
  118. ),
  119. )
  120. ])),
  121. ChioseThis(
  122. list: quanListChiose,
  123. label: "优惠券",
  124. labelText: '无可用优惠券',
  125. value: quanChiose,
  126. fun: (index) {
  127. setState(() {
  128. quanChiose = quanListChiose[index];
  129. });
  130. Navigator.maybePop(context);
  131. }),
  132. ChioseThis(
  133. list: redListChiose,
  134. label: "红包",
  135. labelText: '无可用红包',
  136. value: redChiose,
  137. fun: (index) {
  138. setState(() {
  139. redChiose = redListChiose[index];
  140. });
  141. Navigator.maybePop(context);
  142. }),
  143. Container(
  144. padding: EdgeInsets.only(
  145. left: ScreenUtil().setWidth(15),
  146. right: ScreenUtil().setWidth(15),
  147. top: ScreenUtil().setWidth(10),
  148. bottom: ScreenUtil().setWidth(10)),
  149. decoration: BoxDecoration(
  150. border: Border(
  151. bottom: BorderSide(width: 5, color: Color(0xfff5f5f5)),
  152. ),
  153. ),
  154. child: Row(
  155. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  156. children: <Widget>[
  157. Text(
  158. "共需支付",
  159. style: TextStyle(
  160. color: Color(0xff222222),
  161. fontSize: ScreenUtil().setSp(14)),
  162. textAlign: TextAlign.start,
  163. ),
  164. Text(
  165. "¥20",
  166. style: TextStyle(
  167. color: Colors.red,
  168. fontSize: ScreenUtil().setSp(14)),
  169. textAlign: TextAlign.start,
  170. ),
  171. ]),
  172. ),
  173. Container(
  174. padding: EdgeInsets.only(
  175. left: ScreenUtil().setWidth(15),
  176. right: ScreenUtil().setWidth(15),
  177. top: ScreenUtil().setWidth(10),
  178. bottom: ScreenUtil().setWidth(10)),
  179. decoration: BoxDecoration(
  180. border: Border(
  181. bottom:
  182. BorderSide(width: 0.5, color: Color(0xfff5f5f5)),
  183. ),
  184. ),
  185. child: Row(
  186. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  187. children: <Widget>[
  188. Text(
  189. "选择支付方式",
  190. style: TextStyle(
  191. color: Color(0xff000000),
  192. fontSize: ScreenUtil().setSp(16)),
  193. textAlign: TextAlign.start,
  194. ),
  195. ]),
  196. ),
  197. Container(
  198. padding: EdgeInsets.only(
  199. left: ScreenUtil().setWidth(15),
  200. right: ScreenUtil().setWidth(15)),
  201. child: Column(
  202. children: payType.asMap().keys.map((i) {
  203. return Container(
  204. decoration: BoxDecoration(
  205. border: Border(
  206. bottom: BorderSide(
  207. width: 0.5, color: Color(0xfff5f5f5)),
  208. ),
  209. ),
  210. height: 60,
  211. child: Row(
  212. mainAxisAlignment:
  213. MainAxisAlignment.spaceBetween,
  214. children: <Widget>[
  215. Row(
  216. children: <Widget>[
  217. LoadAssetImage(
  218. // image: AssetImage(i['img']),
  219. payType[i]["icon"],
  220. width: ScreenUtil().setWidth(20),
  221. height: ScreenUtil().setWidth(20),
  222. // alignment: Alignment.centerLeft,
  223. ),
  224. Container(width: 5, child: null),
  225. Text(
  226. payType[i]["title"],
  227. style: TextStyle(
  228. color: Color(0xff000000),
  229. fontSize: ScreenUtil().setSp(14)),
  230. textAlign: TextAlign.start,
  231. ),
  232. Container(width: 5, child: null),
  233. Text(
  234. payType[i]["price"] != null
  235. ? "¥$balance"
  236. : "",
  237. style: TextStyle(
  238. color: Color(0xff999999),
  239. fontSize: ScreenUtil().setSp(16)),
  240. textAlign: TextAlign.start,
  241. ),
  242. // Text(
  243. // payType[i]["price"] != null?"¥${payType[i]["price"]}":"",
  244. // style: TextStyle(
  245. // color:Color(0xff999999),
  246. // fontSize:ScreenUtil().setSp(16)
  247. // ),
  248. // textAlign:TextAlign.start,
  249. // ),
  250. ],
  251. ),
  252. InkWell(
  253. child: Container(
  254. // padding: EdgeInsets.only(top:10,left:5,right:5,bottom:10),
  255. child: LoadAssetImage(
  256. // image: AssetImage(i['img']),
  257. indexNow == i
  258. ? checkTrue
  259. : checkFalse,
  260. width: ScreenUtil().setWidth(18),
  261. height: ScreenUtil().setWidth(18),
  262. // alignment: Alignment.centerLeft,
  263. ),
  264. ),
  265. onTap: () {
  266. setState(() {
  267. indexNow = i;
  268. });
  269. print(indexNow);
  270. },
  271. ),
  272. ]));
  273. }).toList(),
  274. ))
  275. ]),
  276. ),
  277. Positioned(
  278. bottom: 0,
  279. left: 0,
  280. child: Container(
  281. width: width,
  282. padding: EdgeInsets.only(
  283. top: ScreenUtil().setWidth(15),
  284. bottom: ScreenUtil().setWidth(15),
  285. left: ScreenUtil().setWidth(25),
  286. right: ScreenUtil().setWidth(25)),
  287. color: Colors.white,
  288. child: Container(
  289. height: 44,
  290. decoration: BoxDecoration(
  291. color: Colours.blue_app_main,
  292. borderRadius: BorderRadius.circular(22.0),
  293. // gradient: const LinearGradient(
  294. // colors: [Color(0xFF00D9FF), Color(0xFF0287FF)]),
  295. ),
  296. child: FlatButton(
  297. // padding: EdgeInsets.all(15.0),
  298. child: Text("立即购买"),
  299. textColor: Colors.white,
  300. onPressed: () {
  301. NavigatorUtils.push(context, BbsRouter.chatRoom);
  302. },
  303. ),
  304. ),
  305. ))
  306. ],
  307. ))),
  308. );
  309. }
  310. }