vip.dart 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220
  1. // import 'dart:html';
  2. import 'package:flustars/flustars.dart' as flustars;
  3. import 'package:flutter/services.dart';
  4. import 'package:flutter_spinkit/flutter_spinkit.dart';
  5. import 'package:liftmanager/internal/bbs/model/expert_model.dart'
  6. as ExportModel;
  7. import 'package:flutter/material.dart';
  8. import 'package:flutter_screenutil/flutter_screenutil.dart';
  9. import 'package:flutter_swiper/flutter_swiper.dart';
  10. import 'package:liftmanager/common/common.dart';
  11. import 'package:liftmanager/common/user_db.dart';
  12. import 'package:liftmanager/internal/account/account_router.dart';
  13. import 'package:liftmanager/internal/account/provider/user_provider.dart';
  14. import 'package:liftmanager/internal/bbs/provide/websocket.dart';
  15. import 'package:liftmanager/internal/wode/model/privilege_model.dart';
  16. import 'package:liftmanager/internal/wode/model/vipfee_model.dart';
  17. import 'package:liftmanager/internal/wode/wode_router.dart';
  18. import 'package:liftmanager/net/api_service.dart';
  19. import 'package:liftmanager/res/colors.dart';
  20. import 'package:liftmanager/routers/fluro_navigator.dart';
  21. import 'package:liftmanager/utils/fast_notification.dart';
  22. import 'package:liftmanager/utils/theme_utils.dart';
  23. import 'package:liftmanager/utils/time_format.dart';
  24. import 'package:liftmanager/utils/toast.dart';
  25. import 'package:liftmanager/widgets/app_bar.dart';
  26. import 'package:liftmanager/widgets/load_image.dart';
  27. import 'package:liftmanager/widgets/round_widget.dart';
  28. import 'package:oktoast/oktoast.dart';
  29. import 'package:provider/provider.dart';
  30. import 'package:umeng_common_sdk/umeng_common_sdk.dart';
  31. class Vip extends StatefulWidget {
  32. Vip(this.id);
  33. final String id;
  34. @override
  35. State<StatefulWidget> createState() {
  36. return VipState();
  37. }
  38. }
  39. class VipState extends State<Vip> with AutomaticKeepAliveClientMixin {
  40. UserProvider provider = UserProvider();
  41. int currentIndex = -1;
  42. /// 月卡季卡年卡
  43. int selectVipType = 0;
  44. ///选中的套餐
  45. Records selectedRecord = Records();
  46. List<PrivilegeModel> vipList = [];
  47. ///推荐套餐列表
  48. List<Records> moneyList = [];
  49. ExportModel.Records _userInfo = ExportModel.Records();
  50. TextEditingController _vipnumController = TextEditingController();
  51. void getUserInfo() {
  52. NewApiService().getExpertDetail(flustars.SpUtil.getString(Constant.userId),
  53. onSuccess: (res) {
  54. _userInfo = res;
  55. setState(() {});
  56. print("res");
  57. }, onError: (code, msg) {
  58. toasts(msg);
  59. });
  60. ApiService(context: context).userInfo(
  61. onSuccess: (data) {
  62. provider.setUser(data);
  63. // setUser(data);
  64. },
  65. onError: (code, msg) {},
  66. );
  67. }
  68. bool _isAuth = true;
  69. void getAuthInfo() {
  70. NewApiService().getAuthDetail(false, onSuccess: (res) {
  71. List dataArr = res ?? [];
  72. if (dataArr?.last['key'] == '1') {
  73. _isAuth = true;
  74. } else {
  75. _isAuth = false;
  76. }
  77. setState(() {});
  78. print("$res");
  79. }, onError: (code, msg) {
  80. toasts(msg);
  81. });
  82. }
  83. void getMemberAllMenu() {
  84. NewApiService().getVipFeeList(widget.id, onSuccess: (res) {
  85. moneyList = res.records;
  86. selectedRecord = moneyList[0];
  87. setState(() {});
  88. }, onError: (code, msg) {
  89. toasts(msg);
  90. });
  91. NewApiService().getMemberAllMenu(onSuccess: (res) {
  92. vipList = res;
  93. currentIndex = res.length > 0 ? 0 : -1;
  94. setState(() {});
  95. }, onError: (code, msg) {
  96. vipList = [];
  97. toasts(msg);
  98. });
  99. }
  100. bool vip = false;
  101. Future isVipOrExpert() async {
  102. await NewApiService().getIsVipOrExpert(onSuccess: (res) {
  103. if (res != null) {
  104. vip = true;
  105. }
  106. }, onError: (code, msg) {
  107. toasts(msg);
  108. });
  109. }
  110. Future becomeLowerMember() async {
  111. await NewApiService().getUserRebates(widget.id, onSuccess: (res) {
  112. toastsF(context, "你已成功接受${res != null ? res.toString() : ''}的邀请,立即成为会员!",
  113. timeInSecForIos: 3);
  114. // toasts("您已成为${res!=null?res.toString():''}的下级用户");
  115. }, onError: (code, msg) {
  116. toasts(msg);
  117. });
  118. }
  119. void updateVip(userLevel) {
  120. NewApiService().updateVip(userLevel, onSuccess: (res) {
  121. toasts("充值成功,请重新登录");
  122. setState(() {});
  123. User().clearUser();
  124. Provider.of<WebSocketProvide>(context, listen: false).closeWebSocket();
  125. // removeSocket();
  126. // _push.unbindAccount(account: flustars.SpUtil.getString(Constant.phone));
  127. NavigatorUtils.push(context, AccountRouter.loginPage, clearStack: true);
  128. }, onError: (code, msg) {
  129. toasts(msg);
  130. });
  131. }
  132. @override
  133. void initState() {
  134. UmengCommonSdk.onPageStart("会员中心");
  135. getMemberAllMenu();
  136. getUserInfo();
  137. getAuthInfo();
  138. super.initState();
  139. print(widget.id);
  140. print(66666);
  141. FastNotification.addListener("initUserMoney", (initThisUserMoney) {
  142. if (mounted) {
  143. getUserInfo();
  144. setState(() {});
  145. }
  146. });
  147. if (widget.id != null && widget.id != "") {
  148. print("触发绑定");
  149. becomeLowerMember();
  150. }
  151. }
  152. @override
  153. void dispose() {
  154. UmengCommonSdk.onPageEnd("会员中心");
  155. // provider.dispose();
  156. super.dispose();
  157. }
  158. @override
  159. Widget build(BuildContext context) {
  160. double width = MediaQuery.of(context).size.width;
  161. double height = MediaQuery.of(context).size.height;
  162. return ChangeNotifierProvider<UserProvider>(
  163. create: (_) => provider,
  164. child: Container(
  165. child: Scaffold(
  166. // resizeToAvoidBottomPadding: false,
  167. appBar: MyAppBar(
  168. centerTitle: "会员中心",
  169. titleColor: Colors.white,
  170. bgColors: [Color(0xff3B3633), Color(0xff5B5350)],
  171. ),
  172. body: Consumer<UserProvider>(
  173. builder: (_, provider, __) {
  174. return Container(
  175. color: Color(0xfff5f5f5),
  176. child: ListView(
  177. padding: EdgeInsets.all(0.0),
  178. children: <Widget>[
  179. _headeWidget(),
  180. _vipTip(),
  181. _setMeal(),
  182. _frindes(),
  183. _buybtn(),
  184. // Container(
  185. // padding:
  186. // EdgeInsets.only(left: 20.0, right: 20.0, top: 10.0),
  187. // // height: ScreenUtil().setWidth(345),
  188. // child: Column(
  189. // children: <Widget>[
  190. // vipList.length > 0
  191. // ? SwipeWidget(
  192. // banners: vipList,
  193. // onClickItem: (index, item) {
  194. // // showAlert(
  195. // // context,
  196. // // "提示",
  197. // // "您确定需要充值升级为Vip吗?",
  198. // // "确认",
  199. // // () {
  200. // // // updateVip(item.id);
  201. // // // NavigatorUtils.goBack(context);
  202. // // },
  203. // // txt2: "取消",
  204. // // onPre2: () {
  205. // // NavigatorUtils.goBack(context);
  206. // // },
  207. // // );
  208. // // print(333);
  209. // // print(provider);
  210. // NavigatorUtils.push(context,
  211. // "${WodeRouter.vipService}?id=${item.id.toString()}");
  212. // },
  213. // onChangItem: (index, item) {
  214. // currentIndex = index;
  215. // setState(() {});
  216. // },
  217. // )
  218. // : Container()
  219. // ],
  220. // ),
  221. // ),
  222. // LabelTitle(
  223. // title: "会员特权",
  224. // isMore: true,
  225. // userTap: () {
  226. // if (currentIndex != -1) {
  227. // NavigatorUtils.push(context,
  228. // "${WodeRouter.privilege}?id=${vipList[currentIndex].id.toString()}");
  229. // }
  230. // },
  231. // ),
  232. // Container(
  233. // color: ThemeUtils.getTabsBg(context),
  234. // height: ScreenUtil().setWidth(150),
  235. // padding: EdgeInsets.only(
  236. // top: ScreenUtil().setWidth(5),
  237. // left: ScreenUtil().setWidth(10),
  238. // right: ScreenUtil().setWidth(10),
  239. // ),
  240. // child: Privilege(
  241. // initList: currentIndex != -1
  242. // ? vipList[currentIndex].menuList
  243. // : []),
  244. // ),
  245. // LabelTitle(
  246. // title: "邀请好友",
  247. // isMore: false,
  248. // userTap: () {},
  249. // ),
  250. // GestureDetector(
  251. // onTap: () async {
  252. // await isVipOrExpert();
  253. // if (vip) {
  254. // NavigatorUtils.push(context, "${WodeRouter.qrshare}");
  255. // vip = false;
  256. // } else {
  257. // print(999);
  258. // toasts("请开通会员或成为专家");
  259. // }
  260. // },
  261. // child: Container(
  262. // color: ThemeUtils.getTabsBg(context),
  263. // height: ScreenUtil().setWidth(110),
  264. // padding: EdgeInsets.only(
  265. // top: ScreenUtil().setWidth(10),
  266. // left: ScreenUtil().setWidth(10),
  267. // right: ScreenUtil().setWidth(10),
  268. // ),
  269. // child: LoadAssetImage(
  270. // "wode/invite_friends",
  271. // width: ScreenUtil().setWidth(724),
  272. // height: ScreenUtil().setWidth(183),
  273. // ),
  274. // ),
  275. // )
  276. ],
  277. ),
  278. );
  279. },
  280. ),
  281. ),
  282. ),
  283. );
  284. }
  285. _headeWidget() {
  286. return Stack(
  287. children: [
  288. Positioned(
  289. // left: 10,
  290. // right: 10,
  291. // bottom: 0,
  292. child: Container(
  293. // margin: EdgeInsets.only(left: 10,right: 10),
  294. width: double.infinity,
  295. height: 160,
  296. decoration: BoxDecoration(
  297. gradient: const LinearGradient(
  298. colors: [Color(0xff3B3633), Color(0xff5B5350)],
  299. )),
  300. )),
  301. Positioned(
  302. bottom: 0,
  303. left: 10,
  304. right: 10,
  305. child: LoadAssetImage(
  306. "img_vipcenter_bg",
  307. width: 350,
  308. height: 152,
  309. fit: BoxFit.fill,
  310. ),
  311. ),
  312. Positioned(
  313. // top: 50,
  314. bottom: 10,
  315. left: 10,
  316. right: 20,
  317. // left: 0,
  318. child: Row(
  319. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  320. // crossAxisAlignment: CrossAxisAlignment.center,
  321. children: <Widget>[
  322. GestureDetector(
  323. onTap: () {
  324. NavigatorUtils.push(context, WodeRouter.personalPage);
  325. },
  326. child: Container(
  327. padding: EdgeInsets.only(
  328. left: ScreenUtil().setWidth(10),
  329. ),
  330. child: Row(
  331. crossAxisAlignment: CrossAxisAlignment.start,
  332. children: <Widget>[
  333. Container(
  334. padding: EdgeInsets.only(
  335. right: ScreenUtil().setWidth(10),
  336. ),
  337. child: ClipRRect(
  338. borderRadius: BorderRadius.circular(
  339. ScreenUtil().setWidth(35)),
  340. child: Container(
  341. child: LoadNetworkImage(
  342. provider.user?.avatarUrl,
  343. // fit: BoxFit.fitWidth,
  344. width: ScreenUtil().setWidth(40),
  345. height: ScreenUtil().setWidth(40),
  346. ),
  347. ))),
  348. Column(
  349. mainAxisAlignment: MainAxisAlignment.start,
  350. crossAxisAlignment: CrossAxisAlignment.start,
  351. children: <Widget>[
  352. Text(
  353. provider.user?.showWhichName == 1
  354. ? (provider.user?.nickName ?? "")
  355. : (provider.user?.userName ?? ""),
  356. // _userInfo.name ?? '',
  357. // '小小维修工',
  358. textAlign: TextAlign.left,
  359. style: TextStyle(
  360. fontSize: ScreenUtil().setSp(16),
  361. color: Color(0xff2F2B29),
  362. ),
  363. ),
  364. Text(
  365. _userInfo.vipFlag == 2 ? '尊敬的会员,您好!' : '',
  366. textAlign: TextAlign.left,
  367. style: TextStyle(
  368. fontSize: ScreenUtil().setSp(13),
  369. color: Color(0xffAB7223),
  370. ),
  371. ),
  372. SizedBox(height: 3),
  373. _userInfo.vipFlag == 2
  374. ? InkWell(
  375. onTap: () {
  376. if (_userInfo.vipId != null) {
  377. showToast('您已经填写了会员id哦');
  378. return;
  379. }
  380. showDialog(
  381. barrierDismissible: false,
  382. context: context,
  383. builder: (context) => new AlertDialog(
  384. title: Text('输入幸运数字'),
  385. content: Container(
  386. child: TextField(
  387. inputFormatters: <
  388. TextInputFormatter>[
  389. LengthLimitingTextInputFormatter(
  390. 8),
  391. FilteringTextInputFormatter
  392. .digitsOnly //限制长度
  393. ],
  394. maxLength: 8,
  395. controller: _vipnumController,
  396. keyboardType: TextInputType.phone,
  397. ),
  398. ),
  399. actions: <Widget>[
  400. FlatButton(
  401. onPressed: () {
  402. NavigatorUtils.goBack(context);
  403. },
  404. child: new Text("取消"),
  405. ),
  406. FlatButton(
  407. onPressed: () {
  408. if (_vipnumController.text ==
  409. '') {
  410. showToast('请输入幸运数字');
  411. return;
  412. }
  413. NewApiService().upLoadVipluckNum(
  414. vipId: _vipnumController.text,
  415. onSuccess: (res) {
  416. showToast(res);
  417. getUserInfo();
  418. print("res");
  419. NavigatorUtils.goBack(
  420. context);
  421. },
  422. onError: (code, msg) {
  423. toasts(msg);
  424. });
  425. },
  426. child: new Text('确认'),
  427. ),
  428. ],
  429. ),
  430. );
  431. },
  432. child: Container(
  433. padding: EdgeInsets.all(2),
  434. decoration: BoxDecoration(
  435. borderRadius: BorderRadius.all(
  436. Radius.circular(8.0)),
  437. gradient: LinearGradient(
  438. colors: [
  439. Color(0xffF3D99E),
  440. Color(0xffF4EDCE)
  441. ],
  442. )),
  443. child: Text(_userInfo.vipId == null
  444. ? ' 抢占自己的幸运id '
  445. : ' ID:${_userInfo.vipId} '),
  446. ),
  447. )
  448. : Container()
  449. ],
  450. ),
  451. ],
  452. ),
  453. ),
  454. ),
  455. Expanded(child: Container()),
  456. InkWell(
  457. onTap: () {
  458. // /api/tableDicts/query-constant
  459. if (_isAuth) {
  460. showToast('产品正在免费体验期,无需付费购买');
  461. return;
  462. }
  463. NavigatorUtils.push(context,
  464. "${WodeRouter.vipService}?id=&selectid=${selectedRecord.id.toString()}");
  465. // NavigatorUtils.push(context, WodeRouter.walletPage);
  466. },
  467. child: Column(
  468. crossAxisAlignment: CrossAxisAlignment.end,
  469. // mainAxisAlignment: MainAxisAlignment.end,
  470. children: [
  471. Container(
  472. // alignment: Alignment.centerRight,
  473. child: Text(
  474. _userInfo.vipFlag == 2
  475. ? "您的会员到期日:${DateUtils.instance.getFormartData(timeSamp: _userInfo.vipEndTime, format: 'yyyy/MM/dd')}"
  476. : "",
  477. style: TextStyle(
  478. color: Color(0xff252426),
  479. fontSize: ScreenUtil().setSp(11)),
  480. ),
  481. ),
  482. SizedBox(
  483. height: 20,
  484. ),
  485. Container(
  486. decoration: BoxDecoration(
  487. color: Color(0xff272527),
  488. borderRadius: BorderRadius.all(Radius.circular(15)),
  489. ),
  490. padding: EdgeInsets.all(5),
  491. child: Text(
  492. ' 立即续费 ',
  493. style: TextStyle(
  494. color: Color(0xffFFDBB7),
  495. fontSize: ScreenUtil().setSp(12)),
  496. ),
  497. )
  498. ],
  499. ),
  500. )
  501. ],
  502. ),
  503. ),
  504. ],
  505. );
  506. // Container(
  507. // decoration: BoxDecoration(
  508. // gradient: LinearGradient(
  509. // colors: [Color(0xff3B3633), Color(0xff5B5350)],
  510. // ),
  511. // ),
  512. // // width: double.infinity,
  513. // // color: Colors.redAccent,
  514. // child:
  515. // );
  516. }
  517. _vipTip() {
  518. const OrderTypeList = [
  519. {
  520. 'id': 2,
  521. "title": "题库问答",
  522. "img": "wode/icon_viptag_0",
  523. },
  524. {
  525. 'id': 3,
  526. "title": "海量学堂",
  527. "img": "wode/icon_viptag_1",
  528. },
  529. {
  530. 'id': 4,
  531. "title": "商品专区",
  532. "img": "wode/icon_viptag_2",
  533. },
  534. {
  535. 'id': 5,
  536. "title": "招聘特权",
  537. "img": "wode/icon_viptag_3",
  538. },
  539. {
  540. 'id': 10,
  541. "title": "资料库查看",
  542. "img": "wode/icon_viptag_4",
  543. },
  544. {
  545. 'id': 9,
  546. "title": "附近的人",
  547. "img": "wode/icon_viptag_5",
  548. },
  549. {
  550. 'id': 209,
  551. "title": "快速问诊",
  552. "img": "wode/icon_viptag_6",
  553. },
  554. {
  555. "id": 210,
  556. "title": "专家出诊",
  557. "img": "wode/icon_viptag_7",
  558. },
  559. ];
  560. List<Container> _buildGuidTitleList(int count) {
  561. return List<Container>.generate(
  562. count,
  563. (int index) => Container(
  564. // padding: EdgeInsets.only(top: 15),
  565. child: _iconItem(
  566. title: OrderTypeList[index]["title"],
  567. icon: OrderTypeList[index]['img'],
  568. ontap: () {
  569. NavigatorUtils.push(context,
  570. "${WodeRouter.privilege}?id=${vipList[currentIndex].id.toString()}&index=${OrderTypeList[index]["id"].toString()}");
  571. // int nums = index + 1;
  572. // String index = nums.toString();
  573. // NavigatorUtils.push(
  574. // context, "${WodeRouter.orderPage}?checkType=$index");
  575. },
  576. ),
  577. ));
  578. }
  579. return TitleCard(
  580. title: '会员尊享8大权益',
  581. height: 230,
  582. body: Container(
  583. child: GridView.count(
  584. physics: const NeverScrollableScrollPhysics(),
  585. padding: EdgeInsets.all(10), // 内边距
  586. scrollDirection: Axis.vertical, // 滚动方向
  587. crossAxisSpacing: 10, // 列间距
  588. crossAxisCount:
  589. 4, // 每行的个数(Axis.vertic == 横向三个, Axis.horizontal == 竖方向三个)
  590. mainAxisSpacing: 10,
  591. //次轴元素间距
  592. children: _buildGuidTitleList(8), //添加
  593. ),
  594. ));
  595. // Stack(
  596. // children: [
  597. // // Positioned(
  598. // // top: -20,
  599. // // child: Container(
  600. // // height: 50,
  601. // // color: Colors.redAccent,
  602. // // )),
  603. // Container(
  604. // height: 200,
  605. // color: Colors.blue,
  606. // )
  607. // ],
  608. // );
  609. }
  610. _iconItem({String title, double size = 45, String icon, Function ontap}) {
  611. return InkWell(
  612. onTap: ontap,
  613. child: Container(
  614. // padding: EdgeInsets.only(top: 15),
  615. child: Column(
  616. // crossAxisAlignment: CrossAxisAlignment.center,
  617. children: [
  618. Container(
  619. // height: 70,
  620. // color: Colors.red,
  621. child: LoadAssetImage(
  622. // image: AssetImage(i['img']),
  623. icon,
  624. width: ScreenUtil().setWidth(size),
  625. height: ScreenUtil().setWidth(size),
  626. // alignment: Alignment.centerLeft,
  627. ),
  628. ),
  629. // SizedBox(height: ScreenUtil().setWidth(10)),
  630. Container(
  631. child: Text(
  632. title,
  633. style: TextStyle(
  634. color: Colours.text, fontSize: ScreenUtil().setSp(11)),
  635. textAlign: TextAlign.start,
  636. ),
  637. ),
  638. ],
  639. ),
  640. ),
  641. );
  642. }
  643. _setMeal() {
  644. const setMealList = [
  645. {"title": "月卡", "money": "40", "detalMoney": "50"},
  646. {"title": "季卡", "money": "100", "detalMoney": "150"},
  647. {"title": "半年卡", "money": "200", "detalMoney": "300"},
  648. {"title": "年卡", "money": "400", "detalMoney": "600"},
  649. {"title": "年卡", "money": "400", "detalMoney": "600"},
  650. {"title": "年卡", "money": "400", "detalMoney": "600"},
  651. {"title": "年卡", "money": "400", "detalMoney": "600"},
  652. {"title": "年卡", "money": "400", "detalMoney": "600"},
  653. {"title": "年卡", "money": "400", "detalMoney": "600"},
  654. {"title": "年卡", "money": "400", "detalMoney": "600"},
  655. ];
  656. _cell({title, money, detalMoney, bool isSelect, Function ontap, index}) {
  657. return InkWell(
  658. onTap: ontap,
  659. child: Stack(
  660. children: [
  661. Container(
  662. alignment: Alignment.center,
  663. height: 200,
  664. width: 200,
  665. decoration: BoxDecoration(
  666. color: isSelect ? Color(0x21FA4F21) : Colors.white,
  667. //设置四周圆角 角度
  668. borderRadius: BorderRadius.all(Radius.circular(8.0)),
  669. //设置四周边框
  670. border: Border.all(
  671. width: 1,
  672. color: isSelect ? Colors.red : Colours.text_gray),
  673. ),
  674. child: Column(
  675. // crossAxisAlignment: CrossAxisAlignment.center,
  676. mainAxisAlignment: MainAxisAlignment.center,
  677. children: [
  678. Text(
  679. '${moneyList[index].name}',
  680. // '$title',
  681. style: TextStyle(color: Colours.text, fontSize: 15),
  682. ),
  683. Text(
  684. '${moneyList[index].price}',
  685. // '¥$money',
  686. style: TextStyle(
  687. color: Color(0xffFA4F21),
  688. fontSize: 18,
  689. fontWeight: FontWeight.bold),
  690. ),
  691. // Text(
  692. // '原价${moneyList[index].price}/月',
  693. // style: TextStyle(
  694. // color: Colours.text_gray,
  695. // fontSize: 11,
  696. // decoration: TextDecoration.lineThrough,
  697. // decorationColor: Colours.text_gray,
  698. // ),
  699. // ),
  700. ],
  701. )),
  702. (index == 0 || index == moneyList.length - 1)
  703. ? RoundPathWidget(
  704. pathShape: PathShapeEnum.PartRoundRect,
  705. leftTopRadius: 8,
  706. rightBottomRadius: 8,
  707. child: Container(
  708. height: 20,
  709. width: 35,
  710. alignment: Alignment.center,
  711. decoration: BoxDecoration(
  712. gradient: LinearGradient(
  713. colors: index == 0
  714. ? [Color(0xff840AF5), Color(0xff9D32FE)]
  715. : [Color(0xffFF934C), Color(0xffFC686F)],
  716. )),
  717. // color: Color(0xff840AF5),
  718. child: Text(
  719. index == 0 ? '热销' : '超值',
  720. style: TextStyle(color: Colors.white, fontSize: 11),
  721. ),
  722. ))
  723. : Container(),
  724. ],
  725. ));
  726. }
  727. List<Container> _buildGuidTitleList() {
  728. return List<Container>.generate(
  729. moneyList.length,
  730. // setMealList.length,
  731. (int index) => Container(
  732. // padding: EdgeInsets.only(top: 15),
  733. child: _cell(
  734. title: setMealList[index]["title"],
  735. money: setMealList[index]["money"],
  736. detalMoney: setMealList[index]["detalMoney"],
  737. isSelect: moneyList[index] == selectedRecord,
  738. index: index,
  739. ontap: () {
  740. setState(() {
  741. selectedRecord = moneyList[index];
  742. });
  743. // int nums = index + 1;
  744. // String index = nums.toString();
  745. // NavigatorUtils.push(
  746. // context, "${WodeRouter.orderPage}?checkType=$index");
  747. },
  748. ),
  749. ));
  750. }
  751. return TitleCard(
  752. height: 260,
  753. title: '推荐套餐',
  754. body: Container(
  755. margin: EdgeInsets.only(top: 10),
  756. child: moneyList.length > 0
  757. ? GridView(
  758. // physics: const NeverScrollableScrollPhysics(),
  759. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  760. // 一行几列
  761. crossAxisCount: 2,
  762. // 设置每子元素的大小(宽高比)
  763. childAspectRatio: 2.0,
  764. // 元素的左右的 距离
  765. crossAxisSpacing: 20,
  766. // 子元素上下的 距离
  767. mainAxisSpacing: 10,
  768. ),
  769. //次轴元素间距
  770. children: _buildGuidTitleList(), //添加
  771. )
  772. : loadCircle(),
  773. ));
  774. }
  775. _frindes() {
  776. return GestureDetector(
  777. onTap: () {
  778. NavigatorUtils.push(context, "${WodeRouter.qrshare}");
  779. },
  780. child: Container(
  781. height: 185,
  782. margin: EdgeInsets.only(left: 10, right: 10, bottom: 5),
  783. decoration: new BoxDecoration(
  784. color: Colors.white,
  785. //设置四周圆角 角度
  786. borderRadius: BorderRadius.all(Radius.circular(6.0)),
  787. ),
  788. child: Stack(
  789. children: [
  790. Positioned(
  791. top: 0,
  792. right: -10,
  793. left: -10,
  794. bottom: -10,
  795. child: ClipRRect(
  796. borderRadius: BorderRadius.circular(6),
  797. child: LoadAssetImage("img_Invite_friends_bg",
  798. // width: double.infinity,
  799. // height: ScreenUtil().setHeight(260),
  800. fit: BoxFit.fill),
  801. ),
  802. ),
  803. Positioned(
  804. top: 30,
  805. left: 25,
  806. child: Column(
  807. // mainAxisAlignment: MainAxisAlignment.start,
  808. crossAxisAlignment: CrossAxisAlignment.start,
  809. children: [
  810. RichText(
  811. text: TextSpan(
  812. text: '邀请好友',
  813. style: TextStyle(
  814. fontSize: 24,
  815. color: Colors.black,
  816. fontWeight: FontWeight.bold,
  817. ),
  818. children: [
  819. TextSpan(
  820. text: '返佣金',
  821. style: TextStyle(
  822. fontSize: 24,
  823. color: Colors.red,
  824. fontWeight: FontWeight.bold),
  825. ),
  826. ],
  827. ),
  828. ),
  829. SizedBox(
  830. height: 10,
  831. ),
  832. Text('邀请好友开会员赚佣金')
  833. ],
  834. )),
  835. Positioned(
  836. left: 15,
  837. bottom: 15,
  838. right: 15,
  839. child: Row(
  840. // mainAxisAlignment:MainAxisAlignment.spaceBetween ,
  841. // crossAxisAlignment: CrossAxisAlignment.baseline,
  842. children: [
  843. Column(
  844. crossAxisAlignment: CrossAxisAlignment.start,
  845. children: [
  846. Text(
  847. '邀请好友',
  848. style: TextStyle(color: Color(0xffEEA025)),
  849. ),
  850. Text('多邀多得,超多佣金等你来拿',
  851. style: TextStyle(color: Colours.text_gray))
  852. ],
  853. ),
  854. Expanded(child: Container()),
  855. Container(
  856. padding: EdgeInsets.all(3),
  857. decoration: BoxDecoration(
  858. //背景
  859. color: Colors.white,
  860. //设置四周圆角 角度
  861. borderRadius: BorderRadius.all(Radius.circular(15.0)),
  862. //设置四周边框
  863. border: Border.all(
  864. width: 1,
  865. color: Colors.red,
  866. ),
  867. ),
  868. child: InkWell(
  869. onTap: () {
  870. NavigatorUtils.push(
  871. context, "${WodeRouter.qrshare}");
  872. },
  873. child: Text(' 立即邀请 ',
  874. style:
  875. TextStyle(color: Colors.red, fontSize: 13)),
  876. ),
  877. )
  878. ],
  879. ))
  880. ],
  881. ),
  882. ));
  883. }
  884. _buybtn() {
  885. return InkWell(
  886. onTap: () {
  887. if (_isAuth) {
  888. showToast('产品正在免费体验期,无需付费购买');
  889. return;
  890. }
  891. NavigatorUtils.push(context,
  892. "${WodeRouter.vipService}?id=&selectid=${selectedRecord.id.toString()}");
  893. },
  894. child: Container(
  895. height: 72,
  896. margin: EdgeInsets.only(left: 0, right: 0, bottom: 5),
  897. child: Stack(
  898. children: [
  899. Positioned(
  900. top: 0,
  901. right: 0,
  902. left: 0,
  903. bottom: 0,
  904. child: LoadAssetImage(
  905. "img_buyvip_btnbg",
  906. // width: double.infinity,
  907. // height: ScreenUtil().setHeight(260),
  908. fit: BoxFit.cover,
  909. ),
  910. ),
  911. Positioned(
  912. left: 40,
  913. child: Container(
  914. alignment: Alignment.centerLeft,
  915. height: 60,
  916. child: RichText(
  917. text: TextSpan(
  918. text: '¥',
  919. style: TextStyle(
  920. fontSize: 15,
  921. color: Color(0xff3E3835),
  922. fontWeight: FontWeight.bold,
  923. ),
  924. children: [
  925. TextSpan(
  926. text: '${selectedRecord.price}',
  927. style: TextStyle(
  928. fontSize: 30,
  929. color: Color(0xff3E3835),
  930. fontWeight: FontWeight.bold),
  931. ),
  932. TextSpan(
  933. text: '/${selectedRecord.period}个月',
  934. style: TextStyle(
  935. fontSize: 15,
  936. color: Color(0xff3E3835),
  937. fontWeight: FontWeight.bold),
  938. ),
  939. // TextSpan(
  940. // text: '¥${selectedRecord.price}',
  941. // style: TextStyle(
  942. // fontSize: 15,
  943. // color: Color(0xff3E3835),
  944. // fontWeight: FontWeight.bold,
  945. // decoration: TextDecoration.lineThrough,
  946. // decorationColor: Color(0xff3E3835),
  947. // ),
  948. // ),
  949. ],
  950. ),
  951. ),
  952. )),
  953. Positioned(
  954. right: 40,
  955. child: Container(
  956. alignment: Alignment.centerLeft,
  957. height: 65,
  958. child: Text(
  959. '立即续费',
  960. style: TextStyle(color: Colors.white, fontSize: 18),
  961. )))
  962. ],
  963. ),
  964. ),
  965. );
  966. }
  967. Widget loadCircle() {
  968. return Container(
  969. padding: EdgeInsets.only(top: 10, bottom: 10),
  970. color: ThemeUtils.getTabsBg(context),
  971. child: Center(
  972. child: SpinKitFadingCircle(
  973. color: Colors.blueAccent,
  974. size: 30.0,
  975. ),
  976. ),
  977. );
  978. }
  979. @override
  980. bool get wantKeepAlive => true;
  981. }
  982. class TitleCard extends StatelessWidget {
  983. String title;
  984. String rightText;
  985. Function onTapRight;
  986. double height;
  987. Widget body;
  988. TitleCard(
  989. {this.title,
  990. this.rightText,
  991. this.onTapRight,
  992. this.body,
  993. this.height = 120});
  994. @override
  995. Widget build(BuildContext context) {
  996. return Container(
  997. // color: Colors.red,
  998. margin: EdgeInsets.only(left: 10, right: 10, bottom: 10),
  999. decoration: new BoxDecoration(
  1000. color: Colors.white,
  1001. //设置四周圆角 角度
  1002. borderRadius: BorderRadius.all(Radius.circular(6.0)),
  1003. ),
  1004. padding: EdgeInsets.only(left: 10, right: 10, top: 15, bottom: 15),
  1005. height: height,
  1006. // width: ScreenUtil().setWidth(355),
  1007. child: Column(
  1008. children: [
  1009. Row(
  1010. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  1011. children: [
  1012. Text(
  1013. title,
  1014. style: TextStyle(
  1015. color: Color(0xff222222),
  1016. fontSize: 15,
  1017. fontWeight: FontWeight.bold),
  1018. ),
  1019. rightText != null
  1020. ? InkWell(
  1021. onTap: onTapRight,
  1022. child: Row(
  1023. children: [
  1024. Text(rightText,
  1025. style: TextStyle(
  1026. color: Colours.dark_text_gray, fontSize: 13)),
  1027. Icon(
  1028. Icons.arrow_forward_ios,
  1029. color: Colours.dark_text_gray,
  1030. size: 15,
  1031. )
  1032. ],
  1033. ),
  1034. )
  1035. : Container()
  1036. ],
  1037. ),
  1038. // SizedBox(
  1039. // height: 15,
  1040. // ),
  1041. Expanded(child: body)
  1042. // body
  1043. ],
  1044. ),
  1045. );
  1046. }
  1047. }
  1048. class SwipeWidget extends StatelessWidget {
  1049. const SwipeWidget({Key key, this.banners, this.onClickItem, this.onChangItem})
  1050. : super(key: key);
  1051. final List<dynamic> banners;
  1052. final Function onClickItem;
  1053. final Function onChangItem;
  1054. @override
  1055. Widget build(BuildContext context) {
  1056. double width = MediaQuery.of(context).size.width;
  1057. double height = ScreenUtil().setWidth(180);
  1058. return Container(
  1059. width: width,
  1060. height: height,
  1061. child: Swiper(
  1062. itemBuilder: (BuildContext context, index) {
  1063. return Container(
  1064. width: width,
  1065. height: height,
  1066. child: LoadNetworkImage(
  1067. banners[index].image,
  1068. width: width,
  1069. height: height,
  1070. // fit: BoxFit.none
  1071. ),
  1072. );
  1073. },
  1074. pagination: SwiperPagination(
  1075. builder: DotSwiperPaginationBuilder(
  1076. color: Colors.grey,
  1077. activeColor: Colors.white,
  1078. size: 6,
  1079. activeSize: 6,
  1080. ),
  1081. ),
  1082. itemCount: banners.length,
  1083. scrollDirection: Axis.horizontal,
  1084. autoplay: false,
  1085. onTap: (index) {
  1086. onClickItem(index, banners[index]);
  1087. },
  1088. onIndexChanged: (index) {
  1089. onChangItem(index, banners[index]);
  1090. },
  1091. ),
  1092. );
  1093. }
  1094. }
  1095. class Privilege extends StatelessWidget {
  1096. const Privilege({Key key, this.initList}) : super(key: key);
  1097. final List<dynamic> initList;
  1098. List<Widget> listWidget(context) => initList.asMap().keys.map((i) {
  1099. double width = MediaQuery.of(context).size.width;
  1100. return GestureDetector(
  1101. child: Container(
  1102. margin: EdgeInsets.only(right: 10),
  1103. padding: EdgeInsets.only(top: 10, bottom: 10),
  1104. child: Row(
  1105. children: <Widget>[
  1106. SizedBox(width: ScreenUtil().setWidth(i == 0 ? 10 : 10)),
  1107. Container(
  1108. width: ScreenUtil().setWidth(120),
  1109. padding: EdgeInsets.only(top: 20, bottom: 20),
  1110. decoration: BoxDecoration(
  1111. color: ThemeUtils.getTabsBg(context),
  1112. borderRadius: BorderRadius.circular(5),
  1113. boxShadow: [
  1114. BoxShadow(
  1115. offset: Offset(0, 0), //x,y轴
  1116. color: Colors.grey[300], //投影颜色
  1117. blurRadius: 5, //投影距离
  1118. )
  1119. ],
  1120. ),
  1121. child: Column(
  1122. crossAxisAlignment: CrossAxisAlignment.center,
  1123. children: <Widget>[
  1124. // Icon(
  1125. // IconData(initList[i]['icon'], fontFamily: "Iconfont"),
  1126. // size: 24.0,
  1127. // color: Color.fromRGBO(51, 51, 51, 1),
  1128. // ),
  1129. Container(
  1130. margin: EdgeInsets.only(bottom: 8),
  1131. child: LoadNetworkImage(
  1132. initList[i].image,
  1133. width: 30,
  1134. height: 30,
  1135. ),
  1136. ),
  1137. Text(
  1138. initList[i].name ?? '',
  1139. textAlign: TextAlign.start,
  1140. style: TextStyle(
  1141. fontSize: ScreenUtil().setSp(14),
  1142. ),
  1143. ),
  1144. Text(
  1145. initList[i].descr ?? '',
  1146. textAlign: TextAlign.start,
  1147. style: TextStyle(
  1148. fontSize: ScreenUtil().setSp(14),
  1149. color: Color(0xff999999),
  1150. ),
  1151. overflow: TextOverflow.ellipsis,
  1152. ),
  1153. ],
  1154. ),
  1155. ),
  1156. ],
  1157. ),
  1158. ),
  1159. onTap: () {
  1160. // print(i);
  1161. },
  1162. );
  1163. }).toList();
  1164. @override
  1165. Widget build(BuildContext context) {
  1166. return ListView(
  1167. scrollDirection: Axis.horizontal,
  1168. padding: EdgeInsets.all(0),
  1169. children: listWidget(context),
  1170. );
  1171. }
  1172. }