YSUnionHome.dart 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/gestures.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:ysairplane2/base/YSBase.dart';
  5. import 'package:ysairplane2/code/YSIncome.dart';
  6. import 'package:ysairplane2/code/YSMember.dart';
  7. import 'package:ysairplane2/code/YSUnionOrder.dart';
  8. import 'package:ysairplane2/code/YSWithdrawal.dart';
  9. import 'package:ysairplane2/tools/YSNetWorking.dart';
  10. import 'package:ysairplane2/tools/YSTools.dart';
  11. import 'package:flutter/services.dart';
  12. import 'YSUnionOrderDetail.dart';
  13. class YSUnionHome extends StatefulWidget {
  14. const YSUnionHome({Key key}) : super(key: key);
  15. @override
  16. _YSUnionHomeState createState() => _YSUnionHomeState();
  17. }
  18. class _YSUnionHomeState extends State<YSUnionHome> {
  19. Map _msgDict = {'balance':0,'thisMothPrice':0,'servantsUserSize':0,'servantsCode':'',
  20. 'lastMothPrice':0,'servantsPartnerSize':0,'latestOrderList':[]};
  21. @override
  22. void initState() {
  23. Future.delayed(Duration(seconds: 0)).then((value){
  24. _getUnionData();
  25. });
  26. super.initState();
  27. }
  28. @override
  29. Widget build(BuildContext context) {
  30. return YSBase(
  31. ystitle: '顺翔联盟',
  32. yscolor: Color(0xFFF5F6F8),
  33. yschild: Container(
  34. width: MediaQuery.of(context).size.width,
  35. child: Stack(
  36. children: [
  37. Container(
  38. height: hsp(400),
  39. decoration: BoxDecoration(image: DecorationImage(image: AssetImage('lib/images/图层2257.png'),fit: BoxFit.fill)),
  40. padding: EdgeInsets.only(top: hsp(50),left: hsp(20),right: hsp(20)),
  41. width: MediaQuery.of(context).size.width,
  42. child: Column(
  43. children: [
  44. Text('可提现金额(元)',style: TextStyle(fontSize: zsp(28),color: Colors.white),),
  45. Container(
  46. margin: EdgeInsets.only(top: hsp(20)),
  47. child: Text('${_msgDict['balance']}',style: TextStyle(fontSize: zsp(60),color: Colors.white,fontWeight: FontWeight.bold),maxLines: 1,),
  48. ),
  49. Container(
  50. margin: EdgeInsets.only(top: hsp(50)),
  51. height: hsp(100),
  52. child: ListView.separated(
  53. itemBuilder: (context,index){
  54. return Container(
  55. width: (MediaQuery.of(context).size.width-hsp(41))/2,
  56. child: Text('${index==0?'本月':'上月'}预估收入\n¥${index==0?'${_msgDict['thisMothPrice']}':'${_msgDict['lastMothPrice']}'}',
  57. style: TextStyle(fontSize: zsp(22),color: Colors.white),textAlign: TextAlign.center,),
  58. alignment: Alignment.center,
  59. );
  60. },
  61. separatorBuilder: (context,index){
  62. return Container(
  63. margin: EdgeInsets.only(top: hsp(20),bottom: hsp(20)),
  64. width: hsp(2),
  65. color: Colors.white,
  66. );
  67. },
  68. itemCount: 2,
  69. scrollDirection: Axis.horizontal,
  70. ),
  71. )
  72. ],
  73. ),
  74. ),
  75. Container(
  76. margin: EdgeInsets.only(top: hsp(370)),
  77. width: MediaQuery.of(context).size.width,
  78. child: LayoutBuilder(
  79. builder: (context,conSize){
  80. return Column(
  81. children: [
  82. Container(
  83. height: hsp(120),
  84. decoration: BoxDecoration(
  85. color: Colors.white,
  86. borderRadius: BorderRadius.all(Radius.circular(5))
  87. ),
  88. margin: EdgeInsets.only(left: hsp(20),right: hsp(20),bottom: hsp(20)),
  89. child: ListView.separated(
  90. itemBuilder: (context,index){
  91. return GestureDetector(
  92. onTap: (){
  93. Navigator.of(context).push(
  94. CupertinoPageRoute(
  95. builder: (context){
  96. return index==0?YSIncome():YSWithdrawal();
  97. }
  98. )
  99. );
  100. },
  101. child: Container(
  102. width: (MediaQuery.of(context).size.width-hsp(41))/2,
  103. child: Row(
  104. mainAxisSize: MainAxisSize.min,
  105. children: [
  106. Image.asset('lib/images/${index==0?'收入明细':'去提现'}.png',height: hsp(30),width: hsp(30),color: Colors.grey,),
  107. Text(' ${index==0?'收入明细':'去提现'}',style: TextStyle(fontSize: zsp(30),color: Color(0xFF7C7C7C)),textAlign: TextAlign.center,),
  108. ],
  109. ),
  110. alignment: Alignment.center,
  111. padding: EdgeInsets.only(left: hsp(20),right: hsp(20)),
  112. ),
  113. );
  114. },
  115. separatorBuilder: (context,index){
  116. return Container(
  117. margin: EdgeInsets.only(top: hsp(30),bottom: hsp(30)),
  118. width: hsp(2),
  119. color: Color(0xFFE2E2E2),
  120. );
  121. },
  122. itemCount: 2,
  123. scrollDirection: Axis.horizontal,
  124. ),
  125. ),
  126. GestureDetector(
  127. child: Container(
  128. height: hsp(150),
  129. decoration: BoxDecoration(
  130. color: Colors.white,
  131. borderRadius: BorderRadius.all(Radius.circular(5))
  132. ),
  133. margin: EdgeInsets.only(left: hsp(20),right: hsp(20),bottom: hsp(20)),
  134. child: Row(
  135. children: [
  136. Column(
  137. crossAxisAlignment: CrossAxisAlignment.start,
  138. children: [
  139. Row(
  140. children: [
  141. ConstrainedBox(
  142. constraints: BoxConstraints(
  143. maxWidth: MediaQuery.of(context).size.width-hsp(40)-hsp(200)
  144. ),
  145. child: Text('推广码:${_msgDict['servantsCode']} ',style: TextStyle(fontSize: zsp(30),color: Colors.black),maxLines: 1,),
  146. ),
  147. GestureDetector(
  148. child: Text('复制',style: TextStyle(fontSize: zsp(30),color: Color(0xFF007AFF)),),
  149. onTap: (){
  150. Clipboard.setData(ClipboardData(text: '${_msgDict['servantsCode']}'));
  151. ysFlutterToast(context, '推广码已复制');
  152. },
  153. ),
  154. ],
  155. ),
  156. Container(
  157. child: RichText(
  158. text: TextSpan(
  159. text: '推广用户:',
  160. style: TextStyle(fontSize: zsp(22),color: Color(0xFF666666)),
  161. children: [
  162. TextSpan(
  163. text: '${_msgDict['servantsUserSize']}人',
  164. style: TextStyle(color: Color(0xFF007AFF)),
  165. ),
  166. TextSpan(
  167. text: ' 推广商家:',
  168. ),
  169. TextSpan(
  170. text: '${_msgDict['servantsPartnerSize']}',
  171. style: TextStyle(color: Color(0xFF007AFF)),
  172. )
  173. ]
  174. ),
  175. ),
  176. margin: EdgeInsets.only(top: hsp(20)),
  177. )
  178. ],
  179. mainAxisSize: MainAxisSize.min,
  180. ),
  181. Icon(Icons.chevron_right,size: hsp(40),color: Color(0xFFCCCCCC),)
  182. ],
  183. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  184. ),
  185. padding: EdgeInsets.all(hsp(20)),
  186. width: MediaQuery.of(context).size.width-hsp(40),
  187. alignment: Alignment.centerLeft,
  188. ),
  189. onTap: (){
  190. Navigator.of(context).push(
  191. CupertinoPageRoute(
  192. builder: (context){
  193. return YSMember();
  194. }
  195. )
  196. );
  197. },
  198. behavior: HitTestBehavior.opaque,
  199. ),
  200. GestureDetector(
  201. child: Container(
  202. height: hsp(120),
  203. decoration: BoxDecoration(
  204. color: Colors.white,
  205. borderRadius: BorderRadius.all(Radius.circular(5))
  206. ),
  207. margin: EdgeInsets.only(left: hsp(20),right: hsp(20),bottom: hsp(20)),
  208. child: Row(
  209. children: [
  210. Container(
  211. width: hsp(200),
  212. child: Text('订单明细',style: TextStyle(fontSize: zsp(30),color: Colors.black),),
  213. ),
  214. Row(
  215. children: [
  216. Container(
  217. width: MediaQuery.of(context).size.width-hsp(320),
  218. child: Text('更多',style: TextStyle(fontSize: zsp(30),color: Color(0xFFCCCCCC)),),
  219. alignment: Alignment.centerRight,
  220. ),
  221. Icon(Icons.chevron_right,size: hsp(40),color: Color(0xFFCCCCCC),)
  222. ],
  223. )
  224. ],
  225. ),
  226. padding: EdgeInsets.only(left: hsp(20),right: hsp(20)),
  227. ),
  228. onTap: (){
  229. Navigator.of(context).push(
  230. CupertinoPageRoute(
  231. builder: (context){
  232. return YSUnionOrder();
  233. }
  234. )
  235. );
  236. },
  237. behavior: HitTestBehavior.opaque,
  238. ),
  239. ListView.separated(
  240. itemBuilder: (context,index){
  241. Map item = _msgDict['latestOrderList'][index];
  242. return GestureDetector(
  243. onTap: (){
  244. Navigator.of(context).push(
  245. CupertinoPageRoute(
  246. builder: (context){
  247. return YSUnionOrderDetail(order: item,);
  248. }
  249. )
  250. );
  251. },
  252. behavior: HitTestBehavior.opaque,
  253. child: Container(
  254. padding: EdgeInsets.all(hsp(20)),
  255. color: Colors.white,
  256. child: LayoutBuilder(
  257. builder: (context,listSize){
  258. return Column(
  259. children: [
  260. Row(
  261. children: [
  262. Container(
  263. width: listSize.maxWidth-hsp(200),
  264. child: RichText(
  265. text: TextSpan(
  266. text: '订单编号:',
  267. style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),
  268. children: [
  269. TextSpan(
  270. text: '${item['orderSn']}',
  271. style: TextStyle(color: Colors.black)
  272. )
  273. ]
  274. ),
  275. ),
  276. ),
  277. Container(
  278. width: hsp(200),
  279. child: Text(item['orderStatus']==0?'已下单':item['orderStatus']==1?'已核验':'已退款',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),),
  280. alignment: Alignment.centerRight,
  281. )
  282. ],
  283. ),
  284. Container(
  285. margin: EdgeInsets.only(top: hsp(20),bottom: hsp(20)),
  286. child: Row(
  287. children: [
  288. Container(
  289. width: listSize.maxWidth*0.7,
  290. child: Text('${item['typeName']}',style: TextStyle(fontSize: zsp(34),color: Color(0xFF5F5F5F)),),
  291. ),
  292. Container(
  293. width: listSize.maxWidth*0.3,
  294. alignment: Alignment.centerRight,
  295. child: RichText(
  296. text: TextSpan(
  297. text: '${item['orderPrice']}',
  298. style: TextStyle(fontSize: zsp(40),color: Colors.black),
  299. children: [
  300. TextSpan(
  301. text: '元',
  302. style: TextStyle(fontSize: zsp(24))
  303. )
  304. ]
  305. ),
  306. ),
  307. )
  308. ],
  309. ),
  310. ),
  311. Row(
  312. children: [
  313. Container(
  314. width: listSize.maxWidth*0.2,
  315. child: RichText(
  316. text: TextSpan(
  317. text: '佣金:',
  318. style: TextStyle(fontSize: zsp(22),color: Color(0xFF999999)),
  319. children: [
  320. TextSpan(
  321. text: '${item['servantsPrice']}',
  322. style: TextStyle(color: Colors.black)
  323. )
  324. ]
  325. ),
  326. ),
  327. ),
  328. Container(
  329. width: listSize.maxWidth*0.3,
  330. child: RichText(
  331. text: TextSpan(
  332. text: '用户:',
  333. style: TextStyle(fontSize: zsp(22),color: Color(0xFF999999)),
  334. children: [
  335. TextSpan(
  336. text: '${item['nickName']}',
  337. style: TextStyle(color: Colors.black)
  338. )
  339. ]
  340. ),
  341. ),
  342. alignment: Alignment.center,
  343. ),
  344. Container(
  345. width: listSize.maxWidth*0.5,
  346. child: RichText(
  347. text: TextSpan(
  348. text: '支付时间:',
  349. style: TextStyle(fontSize: zsp(22),color: Color(0xFF999999)),
  350. children: [
  351. TextSpan(
  352. text: '${item['payTime']}',
  353. style: TextStyle(color: Colors.black)
  354. )
  355. ]
  356. ),
  357. ),
  358. alignment: Alignment.centerRight,
  359. )
  360. ],
  361. )
  362. ],
  363. );
  364. },
  365. ),
  366. ),
  367. );
  368. },
  369. separatorBuilder: (context,index){
  370. return Divider(height: hsp(1),thickness: hsp(1),color: Color(0xFFF5F6F8),);
  371. },
  372. itemCount: _msgDict['latestOrderList'].length,
  373. physics: NeverScrollableScrollPhysics(),
  374. shrinkWrap: true,
  375. )
  376. ],
  377. );
  378. },
  379. ),
  380. )
  381. ],
  382. ),
  383. ),
  384. );
  385. }
  386. _getUnionData() async{
  387. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/servants/getUnionIndex',parameter: {},isLoading: false,isToken: true);
  388. if(dict!=null){
  389. setState(() {
  390. _msgDict = dict['data'];
  391. });
  392. }
  393. }
  394. }