qrshare.dart 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  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. // provider.dispose();
  87. super.dispose();
  88. }
  89. @override
  90. Widget build(BuildContext context) {
  91. double width = MediaQuery.of(context).size.width;
  92. double height = MediaQuery.of(context).size.height;
  93. return Container(
  94. child:
  95. // ListView(
  96. // children: <Widget>[
  97. Container(
  98. // width: width,
  99. // height:ScreenUtil().setWidth(1619),
  100. // decoration: BoxDecoration(
  101. // image: DecorationImage(
  102. // image: AssetImage("assets/images/bg.png"),
  103. // fit: BoxFit.fitHeight,
  104. // )),
  105. child: Scaffold(
  106. // backgroundColor: Colors.transparent,
  107. appBar: MyAppBar(
  108. centerTitle: "邀请朋友",
  109. // backgroundColor:Colors.transparent,
  110. ),
  111. body:
  112. // Container(child:null)
  113. _hasData
  114. ? ListView(
  115. padding: EdgeInsets.all(0.0),
  116. children: <Widget>[
  117. Container(
  118. width: width,
  119. height: ScreenUtil().setWidth(1619),
  120. decoration: BoxDecoration(
  121. image: DecorationImage(
  122. image: AssetImage("assets/images/bg.png"),
  123. fit: BoxFit.cover,
  124. )),
  125. child: Column(children: <Widget>[
  126. Container(
  127. width: width,
  128. padding: EdgeInsets.only(
  129. top: ScreenUtil().setWidth(230)),
  130. child: Row(
  131. mainAxisAlignment: MainAxisAlignment.center,
  132. children: <Widget>[
  133. ClipRRect(
  134. borderRadius:
  135. BorderRadius.all(Radius.circular(12)),
  136. child: Container(
  137. width: ScreenUtil().setWidth(200),
  138. height: ScreenUtil().setWidth(200),
  139. color: Colors.white,
  140. child: Column(
  141. // mainAxisAlignment: MainAxisAlignment.center,
  142. children: <Widget>[
  143. SizedBox(height: 10),
  144. Row(
  145. mainAxisAlignment:
  146. MainAxisAlignment.center,
  147. children: <Widget>[
  148. Text(
  149. "邀请码:",
  150. style: TextStyle(
  151. color: Color(0xff222222),
  152. fontSize: ScreenUtil()
  153. .setSp(14)),
  154. textAlign: TextAlign.start,
  155. ),
  156. SizedBox(width: 5),
  157. Text(
  158. detailObj.requestCode != null
  159. ? detailObj.requestCode
  160. .toString()
  161. : "",
  162. style: TextStyle(
  163. color: Color(0xffff0000),
  164. fontSize: ScreenUtil()
  165. .setSp(18)),
  166. textAlign: TextAlign.start,
  167. ),
  168. ],
  169. ),
  170. SizedBox(height: 10),
  171. Container(
  172. child: GestureDetector(
  173. onLongPress: (){
  174. print("object-------------------");
  175. fluwx.shareToWeChat(fluwx.WeChatShareImageModel(
  176. scene: fluwx.WeChatScene.SESSION,
  177. title:"请扫码",
  178. image: detailObj.qrCodeUrl??"assets/images/no_image.png",
  179. )).then((result){
  180. },
  181. onError: (msg){
  182. // print(msg);
  183. });
  184. },
  185. child: LoadNetworkImage(
  186. detailObj.qrCodeUrl,
  187. width: ScreenUtil().setWidth(110),
  188. height:
  189. ScreenUtil().setWidth(110),
  190. // alignment: Alignment.centerLeft,
  191. ),
  192. )
  193. ),
  194. SizedBox(height: 10),
  195. Text(
  196. "长按二维码可分享",
  197. style: TextStyle(
  198. color: Color(0xff999999),
  199. fontSize:
  200. ScreenUtil().setSp(14)),
  201. textAlign: TextAlign.start,
  202. ),
  203. ],
  204. ),
  205. ),
  206. )
  207. ])),
  208. // Container(
  209. // padding: EdgeInsets.only(top:ScreenUtil().setWidth(30)),
  210. // child:Row(
  211. // mainAxisAlignment: MainAxisAlignment.center,
  212. // children: <Widget>[
  213. // Container(
  214. // child:LoadAssetImage(
  215. // "wode/btn",
  216. // width: ScreenUtil().setWidth(136),
  217. // height: ScreenUtil().setWidth(36),
  218. // // alignment: Alignment.centerLeft,
  219. // ),
  220. // )
  221. // ],
  222. // )
  223. // ),
  224. Container(
  225. padding: EdgeInsets.only(
  226. top: ScreenUtil().setWidth(30)),
  227. child: Row(
  228. mainAxisAlignment: MainAxisAlignment.center,
  229. children: <Widget>[
  230. Container(
  231. child: LoadAssetImage(
  232. "wode/btn_2",
  233. width: ScreenUtil().setWidth(345),
  234. height: ScreenUtil().setWidth(246),
  235. // alignment: Alignment.centerLeft,
  236. ),
  237. )
  238. ],
  239. )),
  240. Container(
  241. padding: EdgeInsets.only(
  242. top: ScreenUtil().setWidth(30)),
  243. child: Row(
  244. mainAxisAlignment: MainAxisAlignment.center,
  245. children: <Widget>[
  246. Container(
  247. child: LoadAssetImage(
  248. "wode/btn_3",
  249. width: ScreenUtil().setWidth(345),
  250. height: ScreenUtil().setWidth(251),
  251. // alignment: Alignment.centerLeft,
  252. ),
  253. )
  254. ],
  255. )),
  256. Container(
  257. padding: EdgeInsets.only(
  258. top: ScreenUtil().setWidth(30)),
  259. child: Row(
  260. mainAxisAlignment: MainAxisAlignment.center,
  261. children: <Widget>[
  262. Container(
  263. width: ScreenUtil().setWidth(370),
  264. height: ScreenUtil().setWidth(522),
  265. decoration: BoxDecoration(
  266. image: DecorationImage(
  267. image: AssetImage(
  268. "assets/images/wode/btn_4.png"),
  269. fit: BoxFit.cover,
  270. )),
  271. child: Column(
  272. children: <Widget>[
  273. Container(
  274. padding: EdgeInsets.only(
  275. left:
  276. ScreenUtil().setWidth(40),
  277. right:
  278. ScreenUtil().setWidth(40),
  279. top: ScreenUtil()
  280. .setWidth(58)),
  281. child: Row(
  282. mainAxisAlignment:
  283. MainAxisAlignment
  284. .spaceBetween,
  285. children: <Widget>[
  286. Container(
  287. child: Text(
  288. "好友账号",
  289. style: TextStyle(
  290. color:
  291. Color(0xffff0000),
  292. fontSize: ScreenUtil()
  293. .setSp(17)),
  294. textAlign:
  295. TextAlign.start,
  296. ),
  297. ),
  298. Container(
  299. child: Text(
  300. "获得奖励($total)",
  301. style: TextStyle(
  302. color:
  303. Color(0xffff0000),
  304. fontSize: ScreenUtil()
  305. .setSp(17)),
  306. textAlign:
  307. TextAlign.start,
  308. ),
  309. ),
  310. ],
  311. )),
  312. SizedBox(
  313. height:
  314. ScreenUtil().setWidth(20)),
  315. Container(
  316. height:
  317. ScreenUtil().setWidth(360),
  318. // color: Colors.red,
  319. child: ListView(
  320. children:
  321. recordlist != null &&
  322. recordlist
  323. .length >
  324. 0
  325. ? recordlist
  326. .map((item) {
  327. return Container(
  328. padding: EdgeInsets.only(
  329. left: ScreenUtil()
  330. .setWidth(
  331. 40),
  332. right: ScreenUtil()
  333. .setWidth(
  334. 40),
  335. top: ScreenUtil()
  336. .setWidth(
  337. 10),
  338. bottom: ScreenUtil()
  339. .setWidth(
  340. 10)),
  341. child: Row(
  342. mainAxisAlignment:
  343. MainAxisAlignment
  344. .spaceBetween,
  345. children: <
  346. Widget>[
  347. Container(
  348. child:
  349. Text(
  350. item.mobile ??
  351. "",
  352. style: TextStyle(
  353. color: Color(0xFF00D9FF),
  354. fontSize: ScreenUtil().setSp(14)),
  355. textAlign:
  356. TextAlign.start,
  357. ),
  358. ),
  359. Container(
  360. child:
  361. Text(
  362. "获得${item.rebate.toString()}元",
  363. style: TextStyle(
  364. color: Color(0xFF00D9FF),
  365. fontSize: ScreenUtil().setSp(14)),
  366. textAlign:
  367. TextAlign.start,
  368. ),
  369. ),
  370. ],
  371. ));
  372. }).toList()
  373. : <Widget>[]))
  374. ],
  375. ))
  376. ],
  377. )),
  378. ]),
  379. ),
  380. ],
  381. )
  382. : Center(
  383. child: Text("正在加载..."),
  384. ),
  385. ),
  386. )
  387. // ],
  388. // )
  389. );
  390. }
  391. @override
  392. bool get wantKeepAlive => true;
  393. }