qrshare.dart 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. import 'dart:convert';
  2. import 'package:flustars/flustars.dart' as flustars;
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_screenutil/flutter_screenutil.dart';
  5. import 'package:fluwx/fluwx.dart' as fluwx;
  6. import 'package:liftmanager/common/common.dart';
  7. import 'package:liftmanager/internal/account/provider/user_provider.dart';
  8. import 'package:liftmanager/internal/bbs/model/expert_model.dart';
  9. import 'package:liftmanager/internal/wode/model/share_model.dart';
  10. import 'package:liftmanager/net/api_service.dart';
  11. import 'package:liftmanager/utils/toast.dart';
  12. import 'package:liftmanager/widgets/app_bar.dart';
  13. import 'package:liftmanager/widgets/load_image.dart';
  14. class Qrshare extends StatefulWidget {
  15. @override
  16. State<StatefulWidget> createState() {
  17. return QrshareState();
  18. }
  19. }
  20. class QrshareState extends State<Qrshare> with AutomaticKeepAliveClientMixin {
  21. UserProvider provider = UserProvider();
  22. @override
  23. void initState() {
  24. // getMemberAllMenu();
  25. super.initState();
  26. getExpertDetail();
  27. getPayMoneyList();
  28. }
  29. bool _hasData = false;
  30. double total = 0.0;
  31. Records detailObj;
  32. Future getExpertDetail() async {
  33. await NewApiService().getExpertDetail(
  34. flustars.SpUtil.getString(Constant.userId), onSuccess: (res) {
  35. if (res != null) {
  36. detailObj = res;
  37. if (detailObj.requestCode == null || detailObj.qrCodeUrl == null) {
  38. getQrCode();
  39. } else {
  40. _hasData = true;
  41. }
  42. print(123456);
  43. print(jsonEncode(res));
  44. setState(() {});
  45. }
  46. }, onError: (code, msg) {
  47. toasts(msg);
  48. });
  49. }
  50. Future getQrCode() async {
  51. await NewApiService().getQrCode(onSuccess: (res) {
  52. getExpertDetail();
  53. }, onError: (code, msg) {
  54. toasts(msg);
  55. });
  56. }
  57. List<ShareModel> recordlist;
  58. Future getPayMoneyList() async {
  59. await NewApiService().getPayMoneyList(onSuccess: (res) {
  60. if (res != null) {
  61. recordlist = res;
  62. recordlist.forEach((element) {
  63. total += element.rebate;
  64. });
  65. print(123456);
  66. print(jsonEncode(res));
  67. setState(() {});
  68. }
  69. }, onError: (code, msg) {
  70. toasts(msg);
  71. });
  72. }
  73. @override
  74. void dispose() {
  75. // provider.dispose();
  76. super.dispose();
  77. }
  78. @override
  79. Widget build(BuildContext context) {
  80. double width = MediaQuery.of(context).size.width;
  81. double height = MediaQuery.of(context).size.height;
  82. return Container(
  83. child:
  84. // ListView(
  85. // children: <Widget>[
  86. Container(
  87. // width: width,
  88. // height:ScreenUtil().setWidth(1619),
  89. // decoration: BoxDecoration(
  90. // image: DecorationImage(
  91. // image: AssetImage("assets/images/bg.png"),
  92. // fit: BoxFit.fitHeight,
  93. // )),
  94. child: Scaffold(
  95. // backgroundColor: Colors.transparent,
  96. appBar: MyAppBar(
  97. centerTitle: "邀请朋友",
  98. titleColor: Colors.white,
  99. backgroundColor: Color(0xff3071FF),
  100. ),
  101. body:
  102. // Container(child:null)
  103. _hasData
  104. ? Stack(
  105. children: [
  106. Positioned(
  107. // top: 20,
  108. child: ListView(
  109. padding: EdgeInsets.all(0.0),
  110. children: <Widget>[
  111. Container(
  112. width: width,
  113. height: ScreenUtil().setWidth(1619),
  114. decoration: BoxDecoration(
  115. image: DecorationImage(
  116. image: AssetImage("assets/images/bg.png"),
  117. fit: BoxFit.cover,
  118. )),
  119. child: Column(children: <Widget>[
  120. Container(
  121. width: width,
  122. padding: EdgeInsets.only(
  123. top: ScreenUtil().setWidth(230)),
  124. child: Row(
  125. mainAxisAlignment:
  126. MainAxisAlignment.center,
  127. children: <Widget>[
  128. ClipRRect(
  129. borderRadius: BorderRadius.all(
  130. Radius.circular(12)),
  131. child: Container(
  132. width: ScreenUtil().setWidth(200),
  133. height: ScreenUtil().setWidth(200),
  134. color: Colors.white,
  135. child: Column(
  136. // mainAxisAlignment: MainAxisAlignment.center,
  137. children: <Widget>[
  138. SizedBox(height: 10),
  139. Row(
  140. mainAxisAlignment:
  141. MainAxisAlignment.center,
  142. children: <Widget>[
  143. Text(
  144. "邀请码:",
  145. style: TextStyle(
  146. color:
  147. Color(0xff222222),
  148. fontSize: ScreenUtil()
  149. .setSp(14)),
  150. textAlign:
  151. TextAlign.start,
  152. ),
  153. SizedBox(width: 5),
  154. Text(
  155. detailObj.requestCode !=
  156. null
  157. ? detailObj
  158. .requestCode
  159. .toString()
  160. : "",
  161. style: TextStyle(
  162. color:
  163. Color(0xffff0000),
  164. fontSize: ScreenUtil()
  165. .setSp(18)),
  166. textAlign:
  167. TextAlign.start,
  168. ),
  169. ],
  170. ),
  171. SizedBox(height: 10),
  172. Container(
  173. child: GestureDetector(
  174. onLongPress: () {
  175. print(
  176. "object-------------------");
  177. fluwx
  178. .shareToWeChat(fluwx
  179. .WeChatShareImageModel(
  180. scene: fluwx
  181. .WeChatScene.SESSION,
  182. title: "请扫码",
  183. image: detailObj
  184. .qrCodeUrl ??
  185. "assets/images/no_image.png",
  186. ))
  187. .then((result) {},
  188. onError: (msg) {
  189. // print(msg);
  190. });
  191. },
  192. child: LoadNetworkImage(
  193. detailObj.qrCodeUrl,
  194. width: ScreenUtil()
  195. .setWidth(110),
  196. height: ScreenUtil()
  197. .setWidth(110),
  198. // alignment: Alignment.centerLeft,
  199. ),
  200. )),
  201. SizedBox(height: 10),
  202. Text(
  203. "长按二维码可分享",
  204. style: TextStyle(
  205. color: Color(0xff999999),
  206. fontSize: ScreenUtil()
  207. .setSp(14)),
  208. textAlign: TextAlign.start,
  209. ),
  210. ],
  211. ),
  212. ),
  213. )
  214. ])),
  215. // Container(
  216. // padding: EdgeInsets.only(top:ScreenUtil().setWidth(30)),
  217. // child:Row(
  218. // mainAxisAlignment: MainAxisAlignment.center,
  219. // children: <Widget>[
  220. // Container(
  221. // child:LoadAssetImage(
  222. // "wode/btn",
  223. // width: ScreenUtil().setWidth(136),
  224. // height: ScreenUtil().setWidth(36),
  225. // // alignment: Alignment.centerLeft,
  226. // ),
  227. // )
  228. // ],
  229. // )
  230. // ),
  231. Container(
  232. padding: EdgeInsets.only(
  233. top: ScreenUtil().setWidth(30)),
  234. child: Row(
  235. mainAxisAlignment: MainAxisAlignment.center,
  236. children: <Widget>[
  237. Container(
  238. child: LoadAssetImage(
  239. "wode/btn_2",
  240. width: ScreenUtil().setWidth(345),
  241. height: ScreenUtil().setWidth(246),
  242. // alignment: Alignment.centerLeft,
  243. ),
  244. )
  245. ],
  246. )),
  247. Container(
  248. padding: EdgeInsets.only(
  249. top: ScreenUtil().setWidth(30)),
  250. child: Row(
  251. mainAxisAlignment: MainAxisAlignment.center,
  252. children: <Widget>[
  253. Container(
  254. child: LoadAssetImage(
  255. "wode/btn_3",
  256. width: ScreenUtil().setWidth(345),
  257. height: ScreenUtil().setWidth(251),
  258. // alignment: Alignment.centerLeft,
  259. ),
  260. )
  261. ],
  262. )),
  263. Container(
  264. padding: EdgeInsets.only(
  265. top: ScreenUtil().setWidth(30)),
  266. child: Row(
  267. mainAxisAlignment: MainAxisAlignment.center,
  268. children: <Widget>[
  269. Container(
  270. width: ScreenUtil().setWidth(370),
  271. height: ScreenUtil().setWidth(522),
  272. decoration: BoxDecoration(
  273. image: DecorationImage(
  274. image: AssetImage(
  275. "assets/images/wode/btn_4.png"),
  276. fit: BoxFit.cover,
  277. )),
  278. child: Column(
  279. children: <Widget>[
  280. Container(
  281. padding: EdgeInsets.only(
  282. left: ScreenUtil()
  283. .setWidth(40),
  284. right: ScreenUtil()
  285. .setWidth(40),
  286. top: ScreenUtil()
  287. .setWidth(58)),
  288. child: Row(
  289. mainAxisAlignment:
  290. MainAxisAlignment
  291. .spaceBetween,
  292. children: <Widget>[
  293. Container(
  294. child: Text(
  295. "好友账号",
  296. style: TextStyle(
  297. color: Color(
  298. 0xffff0000),
  299. fontSize:
  300. ScreenUtil()
  301. .setSp(
  302. 17)),
  303. textAlign:
  304. TextAlign.start,
  305. ),
  306. ),
  307. Container(
  308. child: Text(
  309. "获得奖励($total)",
  310. style: TextStyle(
  311. color: Color(
  312. 0xffff0000),
  313. fontSize:
  314. ScreenUtil()
  315. .setSp(
  316. 17)),
  317. textAlign:
  318. TextAlign.start,
  319. ),
  320. ),
  321. ],
  322. )),
  323. SizedBox(
  324. height: ScreenUtil()
  325. .setWidth(20)),
  326. Container(
  327. height: ScreenUtil()
  328. .setWidth(360),
  329. // color: Colors.red,
  330. child: ListView(
  331. children: recordlist !=
  332. null &&
  333. recordlist
  334. .length >
  335. 0
  336. ? recordlist
  337. .map((item) {
  338. return Container(
  339. padding: EdgeInsets.only(
  340. left: ScreenUtil()
  341. .setWidth(
  342. 40),
  343. right: ScreenUtil()
  344. .setWidth(
  345. 40),
  346. top: ScreenUtil()
  347. .setWidth(
  348. 10),
  349. bottom: ScreenUtil()
  350. .setWidth(
  351. 10)),
  352. child: Row(
  353. mainAxisAlignment:
  354. MainAxisAlignment
  355. .spaceBetween,
  356. children: <
  357. Widget>[
  358. Container(
  359. child:
  360. Text(
  361. item.mobile ??
  362. "",
  363. style: TextStyle(
  364. color: Color(0xFF00D9FF),
  365. fontSize: ScreenUtil().setSp(14)),
  366. textAlign:
  367. TextAlign.start,
  368. ),
  369. ),
  370. Container(
  371. child:
  372. Text(
  373. "获得${item.rebate.toString()}元",
  374. style: TextStyle(
  375. color: Color(0xFF00D9FF),
  376. fontSize: ScreenUtil().setSp(14)),
  377. textAlign:
  378. TextAlign.start,
  379. ),
  380. ),
  381. ],
  382. ));
  383. }).toList()
  384. : <Widget>[]))
  385. ],
  386. ))
  387. ],
  388. )),
  389. ]),
  390. ),
  391. ],
  392. ))
  393. ],
  394. )
  395. : Center(
  396. child: Text("正在加载..."),
  397. ),
  398. ),
  399. )
  400. // ],
  401. // )
  402. );
  403. }
  404. @override
  405. bool get wantKeepAlive => true;
  406. }