bind_alipay_page.dart 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. import 'dart:convert';
  2. import 'dart:math';
  3. import 'package:bbyyy/beans/user_bean_entity.dart';
  4. import 'package:bbyyy/https/MyDio.dart';
  5. import 'package:bbyyy/https/url.dart';
  6. import 'package:bbyyy/my_tools/dims.dart';
  7. import 'package:bbyyy/my_tools/event_bus.dart';
  8. import 'package:bbyyy/my_tools/my_colors.dart';
  9. import 'package:bbyyy/my_tools/my_cookie.dart';
  10. import 'package:bbyyy/my_tools/my_tools.dart';
  11. import 'package:bbyyy/my_tools/my_views.dart';
  12. import 'package:bbyyy/paegs/mine_page/bind_alipay_page/set_alipay_page.dart';
  13. import 'package:bbyyy/paegs/mine_page/coupon_page/coupon_view.dart';
  14. import 'package:flutter/cupertino.dart';
  15. import 'package:flutter/material.dart';
  16. import 'package:flutter_svg/svg.dart';
  17. class BindAlipayPage extends StatefulWidget {
  18. @override
  19. _BindAlipayPageState createState() => _BindAlipayPageState();
  20. }
  21. class _BindAlipayPageState extends State<BindAlipayPage> {
  22. TextEditingController controller = TextEditingController();
  23. bool showInput = false;
  24. @override
  25. Widget build(BuildContext context) {
  26. return Scaffold(
  27. body: Container(
  28. decoration: BoxDecoration(
  29. gradient: LinearGradient(
  30. colors: MyColors.lg2,
  31. begin: Alignment.topCenter,
  32. end: Alignment.bottomCenter),
  33. ),
  34. child: Column(
  35. children: [
  36. SafeArea(
  37. bottom: false,
  38. child: Container(
  39. height: 45,
  40. width: double.infinity,
  41. child: Stack(
  42. children: [
  43. Text(
  44. '绑定',
  45. style: TextStyle(color: Colors.white, fontSize: 16),
  46. ),
  47. Positioned(
  48. left: 0,
  49. child: GestureDetector(
  50. onTap: () {
  51. Navigator.pop(context);
  52. },
  53. behavior: HitTestBehavior.translucent,
  54. child: Transform.rotate(
  55. angle: pi,
  56. child: Padding(
  57. padding: EdgeInsets.only(
  58. left: 16, right: 16, top: 8, bottom: 8),
  59. child: SvgPicture.asset(
  60. 'images/svg/箭头.svg',
  61. color: Colors.white,
  62. height: 14,
  63. ),
  64. ),
  65. ),
  66. ),
  67. ),
  68. ],
  69. alignment: Alignment.center,
  70. ),
  71. ),
  72. ),
  73. Container(
  74. height: 280,
  75. margin: EdgeInsets.fromLTRB(15, 60, 15, 50),
  76. width: double.infinity,
  77. child: ClipShadowPath(
  78. clipper: TicketClipPath2(),
  79. shadow: Shadow(blurRadius: 5, color: MyColors.c21333333),
  80. child: Scaffold(
  81. body: Stack(
  82. alignment: Alignment.bottomCenter,
  83. children: [
  84. Column(
  85. children: [
  86. Container(
  87. margin: EdgeInsets.only(top: 40),
  88. child: ClipRRect(
  89. child: MyViews().netImg(
  90. imgURL(MyCookie().userBean.picture), 64, 64),
  91. borderRadius: BorderRadius.circular(32),
  92. ),
  93. ),
  94. Container(
  95. child: MyViews()
  96. .myText('当前绑定支付宝账号', MyColors.c333333, 13),
  97. margin: EdgeInsets.only(top: 11, bottom: 11),
  98. ),
  99. Container(
  100. decoration: BoxDecoration(
  101. borderRadius: BorderRadius.circular(22.5),
  102. color: MyColors.cFF4233),
  103. height: 45,
  104. margin: EdgeInsets.symmetric(horizontal: 22),
  105. child: MyViews().myText(
  106. MyCookie().userBean.aliPayAccount.isEmpty?'暂未绑定':MyCookie().userBean.aliPayAccount,
  107. Colors.white,
  108. 20),
  109. alignment: Alignment.center,
  110. )
  111. ],
  112. ),
  113. Container(
  114. child: CustomPaint(
  115. painter: DashedPainter(),
  116. size: Size(double.infinity, 1),
  117. ),
  118. margin:
  119. EdgeInsets.only(bottom: 38, right: 10, left: 10),
  120. ),
  121. Positioned(
  122. bottom: 0,
  123. child: GestureDetector(
  124. onTap: () {
  125. MyTools().toPage(context, SetAlipayPage(), (then) {
  126. setState(() {});
  127. });
  128. },
  129. behavior: HitTestBehavior.translucent,
  130. child: Container(
  131. height: 39,
  132. child: Row(
  133. children: [
  134. MyViews()
  135. .myText(MyCookie().userBean.aliPayAccount.isEmpty?'去绑定':'修改绑定账号', MyColors.c999999, 11),
  136. Container(
  137. margin: EdgeInsets.only(left: 5),
  138. child: SvgPicture.asset(
  139. 'images/svg/箭头.svg',
  140. color: MyColors.c999999,
  141. height: 8,
  142. width: 8,
  143. ),
  144. )
  145. ],
  146. mainAxisAlignment: MainAxisAlignment.center,
  147. crossAxisAlignment: CrossAxisAlignment.center,
  148. ),
  149. alignment: Alignment.center,
  150. ),
  151. ),
  152. ),
  153. ],
  154. ),
  155. ),
  156. ),
  157. )
  158. ],
  159. ),
  160. ),
  161. );
  162. }
  163. void queryPersonalInformation() {
  164. MyDio().query({
  165. "key": "user",
  166. "filters": {
  167. "conditions": ["uid == ${MyCookie().getUID()}"]
  168. },
  169. "dims": userDims,
  170. "paging": [1, 20]
  171. }, (response, hasError) {
  172. if (!hasError) {
  173. UserBeanEntity entity =
  174. UserBeanEntity().fromJson(json.decode(response.data.toString()));
  175. MyCookie().userBean = entity.data.data[0];
  176. EventBus().emit('userChange');
  177. setState(() {});
  178. }
  179. }, (error) {});
  180. }
  181. void saveAlipayNum() {
  182. MyDio().update({
  183. "key": "user",
  184. "values": {
  185. "name": MyCookie().loginInformation.data.extra.name,
  186. "picture": MyCookie().loginInformation.data.extra.picture,
  187. "id": MyCookie().loginInformation.data.extra.id,
  188. "alipay_account": controller.text.toString()
  189. }
  190. }, (response, hasError) {
  191. if (!hasError) {
  192. MyCookie().userBean.aliPayAccount = controller.text.toString();
  193. showInput = false;
  194. setState(() {});
  195. }
  196. }, (error) {});
  197. }
  198. }