order_page.dart 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. import 'dart:math' as math;
  2. import 'package:bbyyy/beans/goods_bean_entity.dart';
  3. import 'package:bbyyy/https/url.dart';
  4. import 'package:bbyyy/my_tools/AsperctRaioImage.dart';
  5. import 'package:bbyyy/my_tools/my_colors.dart';
  6. import 'package:bbyyy/my_tools/my_views.dart';
  7. import 'package:flutter/material.dart';
  8. class OrderPage extends StatefulWidget {
  9. GoodsBeanDataData data;
  10. OrderPage(this.data);
  11. @override
  12. _OrderPageState createState() => _OrderPageState(data);
  13. }
  14. class _OrderPageState extends State<OrderPage> {
  15. List<String> status = ['未支付', '代支付', '已支付'];
  16. List<Color> statusColors = [
  17. MyColors.cFF9353,
  18. MyColors.c73C2FF,
  19. MyColors.cADD358
  20. ];
  21. int statusIndex = 0;
  22. GoodsBeanDataData data;
  23. _OrderPageState(this.data);
  24. @override
  25. void initState() {
  26. // TODO: implement initState
  27. super.initState();
  28. statusIndex = math.Random().nextInt(3);
  29. }
  30. @override
  31. Widget build(BuildContext context) {
  32. return Scaffold(
  33. backgroundColor: MyColors.cF7F7F7,
  34. body: Column(
  35. children: [
  36. MyViews().myAppBar('订单详情', context, []),
  37. Expanded(
  38. child: Stack(
  39. children: [
  40. SingleChildScrollView(
  41. child: Column(
  42. children: [
  43. MyViews().netImg(
  44. imgURL(data.coverPath), 314, double.infinity,
  45. placeholder: 'images/svg/goodsDefImg.svg'),
  46. Container(
  47. color: Colors.white,
  48. padding: EdgeInsets.fromLTRB(15, 15, 15, 18),
  49. child: Column(
  50. children: [
  51. Container(
  52. margin: EdgeInsets.only(bottom: 11),
  53. child: Text(
  54. '${data.title}\n${data.description}',
  55. style: TextStyle(
  56. color: MyColors.c333333,
  57. fontSize: 15,
  58. height: 1.4),
  59. ),
  60. ),
  61. Row(
  62. children: [
  63. Text(
  64. '¥${data.price}',
  65. style: TextStyle(
  66. color: MyColors.cFF4233, fontSize: 17),
  67. ),
  68. Text(
  69. 'x${data.stock}',
  70. style: TextStyle(
  71. color: MyColors.c666666, fontSize: 17),
  72. ),
  73. ],
  74. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  75. )
  76. ],
  77. crossAxisAlignment: CrossAxisAlignment.start,
  78. ),
  79. ),
  80. Container(
  81. color: Colors.white,
  82. padding: EdgeInsets.fromLTRB(12, 2, 12, 2),
  83. margin: EdgeInsets.only(top: 5),
  84. child: Row(
  85. children: [
  86. ClipRRect(
  87. child: MyViews().netImg('path', 40, 40),
  88. borderRadius:
  89. BorderRadius.all(Radius.circular(20)),
  90. ),
  91. Container(
  92. margin: EdgeInsets.only(left: 7, right: 8),
  93. child: Text(
  94. '爱吃饼干的小猪',
  95. style: TextStyle(
  96. color: MyColors.c333333, fontSize: 15),
  97. ),
  98. ),
  99. Container(
  100. decoration: BoxDecoration(
  101. border: Border.all(
  102. color: MyColors.cFF4233, width: 1),
  103. borderRadius: BorderRadius.circular(2),
  104. ),
  105. height: 14,
  106. width: 26,
  107. child: Text(
  108. '卖家',
  109. style: TextStyle(
  110. color: MyColors.cFF4233,
  111. fontSize: 10,
  112. height: 1),
  113. ),
  114. alignment: Alignment.center,
  115. padding: EdgeInsets.only(top: 1),
  116. )
  117. ],
  118. ),
  119. ),
  120. Container(
  121. color: Colors.white,
  122. padding: EdgeInsets.fromLTRB(15, 15, 17, 15),
  123. margin: EdgeInsets.only(top: 5),
  124. child: Row(
  125. children: [
  126. MyViews().myText('优惠', MyColors.c333333, 15),
  127. MyViews().myText('-¥6.00', MyColors.c666666, 15),
  128. ],
  129. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  130. ),
  131. ),
  132. Column(
  133. children: images(),
  134. ),
  135. Container(
  136. color: Colors.white,
  137. padding: EdgeInsets.fromLTRB(15, 15, 17, 15),
  138. margin: EdgeInsets.only(top: 1),
  139. child: Row(
  140. children: [
  141. MyViews().myText('合计', MyColors.c333333, 15),
  142. MyViews().myText('¥114.00', MyColors.c666666, 15),
  143. ],
  144. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  145. ),
  146. ),
  147. Container(
  148. color: Colors.white,
  149. padding: EdgeInsets.fromLTRB(15, 15, 17, 15),
  150. margin: EdgeInsets.only(top: 5),
  151. child: Row(
  152. children: [
  153. MyViews().myText('下单时间', MyColors.c333333, 15),
  154. MyViews().myText(
  155. '2020-12-24 10:00:00', MyColors.c666666, 15),
  156. ],
  157. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  158. ),
  159. ),
  160. ],
  161. ),
  162. ),
  163. Container(
  164. decoration: BoxDecoration(
  165. borderRadius: BorderRadius.only(
  166. bottomRight: Radius.circular(21),
  167. bottomLeft: Radius.circular(21),
  168. ),
  169. color: Colors.white),
  170. height: 56,
  171. padding: EdgeInsets.only(left: 16, right: 14),
  172. child: Row(
  173. children: [
  174. ClipRRect(
  175. child:
  176. MyViews().netImg(imgURL(data.userPic), 40, 40),
  177. borderRadius: BorderRadius.all(Radius.circular(20)),
  178. ),
  179. Expanded(
  180. child: Container(
  181. height: 40,
  182. margin: EdgeInsets.only(left: 10),
  183. child: Column(
  184. children: [
  185. Row(
  186. children: [
  187. MyViews().myText(
  188. data.userName, MyColors.c333333, 15),
  189. Container(
  190. decoration: BoxDecoration(
  191. border: Border.all(
  192. color: MyColors.cFF4233, width: 1),
  193. borderRadius: BorderRadius.circular(2),
  194. ),
  195. margin: EdgeInsets.only(left: 10),
  196. height: 14,
  197. width: 26,
  198. child: Text(
  199. '买家',
  200. style: TextStyle(
  201. color: MyColors.cFF4233,
  202. fontSize: 10,
  203. height: 1),
  204. ),
  205. alignment: Alignment.center,
  206. padding: EdgeInsets.only(top: 1),
  207. )
  208. ],
  209. ),
  210. MyViews().myText('全球带货达人团', MyColors.c999999, 12),
  211. ],
  212. crossAxisAlignment: CrossAxisAlignment.start,
  213. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  214. ),
  215. ),
  216. ),
  217. Container(
  218. decoration: BoxDecoration(
  219. color: statusColors[statusIndex],
  220. borderRadius: BorderRadius.only(
  221. topLeft: Radius.circular(7),
  222. bottomRight: Radius.circular(7),
  223. ),
  224. ),
  225. child: MyViews().myText(
  226. status[statusIndex], Colors.white, 10,
  227. height: 1),
  228. height: 18,
  229. width: 40,
  230. alignment: Alignment.center,
  231. )
  232. ],
  233. ),
  234. ),
  235. ],
  236. ),
  237. ),
  238. Visibility(
  239. visible: statusIndex == 0,
  240. child: SafeArea(
  241. top: false,
  242. child: Container(
  243. padding: EdgeInsets.symmetric(horizontal: 37),
  244. color: Colors.white,
  245. width: double.infinity,
  246. height: 80,
  247. child: Visibility(
  248. visible: statusIndex == 0,
  249. child: Row(
  250. children: [
  251. Expanded(
  252. child: Container(
  253. decoration: BoxDecoration(
  254. borderRadius: BorderRadius.only(
  255. topLeft: Radius.circular(20),
  256. bottomLeft: Radius.circular(20),
  257. ),
  258. border: Border.all(
  259. color: MyColors.cFF4233, width: 1)),
  260. height: 40,
  261. child:
  262. MyViews().myText('取消订单', MyColors.cFF4233, 14),
  263. alignment: Alignment.center),
  264. ),
  265. Expanded(
  266. child: Container(
  267. decoration: BoxDecoration(
  268. borderRadius: BorderRadius.only(
  269. topRight: Radius.circular(20),
  270. bottomRight: Radius.circular(20),
  271. ),
  272. color: MyColors.cFF4233),
  273. height: 40,
  274. child: MyViews().myText('立即支付', Colors.white, 14),
  275. alignment: Alignment.center),
  276. )
  277. ],
  278. ),
  279. ),
  280. ),
  281. ),
  282. )
  283. ],
  284. ),
  285. );
  286. }
  287. images() {
  288. List<Widget> imgs = [];
  289. data.pictures.split(',').forEach((element) {
  290. imgs.add(AsperctRaioImage.network(imgURL(element),
  291. builder: (context, snapshot, url) {
  292. return MyViews().netImg(
  293. imgURL(element),
  294. (snapshot.data.height.toDouble() / 5) /
  295. (snapshot.data.width.toDouble() / 5) *
  296. MediaQuery.of(context).size.width,
  297. MediaQuery.of(context).size.width,placeholder: 'images/svg/goodsDefImg.svg');
  298. }));
  299. });
  300. return imgs;
  301. }
  302. }