qrshare.dart 21 KB

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