| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373 |
- import 'dart:convert';
- import 'dart:math';
- import 'package:bbyyy/beans/pay_way_bean_entity.dart';
- import 'package:bbyyy/beans/user_bean_entity.dart';
- import 'package:bbyyy/https/MyDio.dart';
- import 'package:bbyyy/my_tools/dims.dart';
- import 'package:bbyyy/my_tools/event_bus.dart';
- import 'package:bbyyy/my_tools/my_colors.dart';
- import 'package:bbyyy/my_tools/my_cookie.dart';
- import 'package:bbyyy/my_tools/my_tools.dart';
- import 'package:bbyyy/my_tools/my_views.dart';
- import 'package:bbyyy/paegs/mine_page/bind_alipay_page/set_alipay_page.dart';
- import 'package:bbyyy/paegs/mine_page/coupon_page/coupon_view.dart';
- import 'package:bbyyy/pay/pay_tools.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:flutter_svg/svg.dart';
- import 'package:fluwx/fluwx.dart';
- class BindAlipayPage extends StatefulWidget {
- @override
- _BindAlipayPageState createState() => _BindAlipayPageState();
- }
- class _BindAlipayPageState extends State<BindAlipayPage> {
- TextEditingController controller = TextEditingController();
- bool showInput = false;
- List<PayWayBeanData> payWays = [];
- bool showAlipay = false;
- bool showWeChat = false;
- @override
- void initState() {
- super.initState();
- Future.delayed(Duration.zero, () {
- checkPaymentMethod((response, hasError) {
- if (!hasError) {
- PayWayBeanEntity entity =
- PayWayBeanEntity().fromJson(json.decode(response.toString()));
- payWays = entity.data;
- showAlipay =
- payWays[payWays.indexWhere((element) => element.way == 1)]
- .withdraw;
- showWeChat =
- payWays[payWays.indexWhere((element) => element.way == 2)]
- .withdraw;
- setState(() {});
- }
- }, (e) {});
- });
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: Container(
- decoration: BoxDecoration(
- gradient: LinearGradient(
- colors: MyColors.lg2,
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter),
- ),
- child: Column(
- children: [
- SafeArea(
- bottom: false,
- child: Container(
- height: 45,
- width: double.infinity,
- child: Stack(
- children: [
- Text(
- '绑定',
- style: TextStyle(color: Colors.white, fontSize: 16),
- ),
- Positioned(
- left: 0,
- child: GestureDetector(
- onTap: () {
- Navigator.pop(context);
- },
- behavior: HitTestBehavior.translucent,
- child: Transform.rotate(
- angle: pi,
- child: Padding(
- padding: EdgeInsets.only(
- left: 16, right: 16, top: 8, bottom: 8),
- child: SvgPicture.asset(
- 'images/svg/箭头.svg',
- color: Colors.white,
- height: 14,
- ),
- ),
- ),
- ),
- ),
- ],
- alignment: Alignment.center,
- ),
- ),
- ),
- if (showAlipay)
- Container(
- height: 220,
- margin: EdgeInsets.fromLTRB(15, 60, 15, 0),
- width: double.infinity,
- child: ClipShadowPath(
- clipper: TicketClipPath2(),
- shadow: Shadow(blurRadius: 5, color: MyColors.c21333333),
- child: Scaffold(
- body: Stack(
- alignment: Alignment.bottomCenter,
- children: [
- Column(
- children: [
- Container(
- margin: EdgeInsets.only(top: 30),
- child: SvgPicture.asset(
- 'images/svg/支付宝.svg',
- height: 40,
- width: 40,
- ),
- ),
- Container(
- child: MyViews().myText(
- MyCookie()
- .userBean
- .aliPayAccount
- .isNotEmpty &&
- MyCookie().userBean.aliPayName.isEmpty
- ? '未绑定账号持有人真实姓名'
- : '当前绑定支付宝账号',
- MyCookie()
- .userBean
- .aliPayAccount
- .isNotEmpty &&
- MyCookie().userBean.aliPayName.isEmpty
- ? MyColors.cFF4233
- : MyColors.c333333,
- 13),
- margin: EdgeInsets.only(top: 11, bottom: 11),
- ),
- Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(22.5),
- color: MyColors.cFF4233),
- height: 45,
- margin: EdgeInsets.symmetric(horizontal: 22),
- child: MyViews().myText(
- MyCookie().userBean.aliPayAccount.isEmpty
- ? '暂未绑定'
- : MyCookie().userBean.aliPayAccount,
- Colors.white,
- 20),
- alignment: Alignment.center,
- )
- ],
- ),
- Container(
- child: CustomPaint(
- painter: DashedPainter(),
- size: Size(double.infinity, 1),
- ),
- margin:
- EdgeInsets.only(bottom: 38, right: 10, left: 10),
- ),
- Positioned(
- bottom: 0,
- child: GestureDetector(
- onTap: () {
- MyTools().toPage(context, SetAlipayPage(),
- (then) {
- setState(() {});
- });
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- height: 39,
- child: Row(
- children: [
- MyViews().myText(
- MyCookie().userBean.aliPayAccount.isEmpty
- ? '去绑定'
- : '修改绑定账号',
- MyColors.c999999,
- 11),
- Container(
- margin: EdgeInsets.only(left: 5),
- child: SvgPicture.asset(
- 'images/svg/箭头.svg',
- color: MyColors.c999999,
- height: 8,
- width: 8,
- ),
- )
- ],
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.center,
- ),
- alignment: Alignment.center,
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- ),
- // if (showWeChat)
- Container(
- height: 220,
- margin: EdgeInsets.fromLTRB(15, 20, 15, 50),
- width: double.infinity,
- child: ClipShadowPath(
- clipper: TicketClipPath2(),
- shadow: Shadow(blurRadius: 5, color: MyColors.c21333333),
- child: Scaffold(
- body: Stack(
- alignment: Alignment.bottomCenter,
- children: [
- Column(
- children: [
- Container(
- margin: EdgeInsets.only(top: 30),
- child: SvgPicture.asset(
- 'images/svg/微信.svg',
- height: 40,
- width: 40,
- ),
- ),
- Container(
- child: MyViews()
- .myText('当前绑定微信账号', MyColors.c333333, 13),
- margin: EdgeInsets.only(top: 11, bottom: 11),
- ),
- GestureDetector(
- onTap: (){
- Clipboard.setData(ClipboardData(text: '${MyCookie().userBean.wxOpenid}'));
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(22.5),
- color: MyColors.cFF4233),
- height: 45,
- margin: EdgeInsets.symmetric(horizontal: 22),
- child: MyCookie().userBean.wxOpenid.isEmpty
- ? MyViews().myText('暂未绑定', Colors.white, 20)
- : Row(
- children: [
- Container(
- margin: EdgeInsets.only(right: 10),
- child: ClipRRect(
- borderRadius:
- BorderRadius.circular(14),
- child: MyViews().netImg(
- MyCookie().userBean.wxPicture,
- 28,
- 28),
- ),
- ),
- MyViews().myText(
- MyCookie().userBean.wxName,
- Colors.white,
- 20)
- ],
- mainAxisAlignment:
- MainAxisAlignment.center,
- ),
- alignment: Alignment.center,
- ),
- )
- ],
- ),
- Container(
- child: CustomPaint(
- painter: DashedPainter(),
- size: Size(double.infinity, 1),
- ),
- margin:
- EdgeInsets.only(bottom: 38, right: 10, left: 10),
- ),
- Positioned(
- bottom: 0,
- child: GestureDetector(
- onTap: () {
- EventBus().on('bindToWeChat', (arg) {
- showToast('绑定成功');
- setState(() {});
- EventBus().off('bindToWeChat');
- });
- sendWeChatAuth(
- scope: "snsapi_userinfo",
- state: "wechat_sdk_demo_test");
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- height: 39,
- child: Row(
- children: [
- MyViews().myText(
- MyCookie().userBean.wxOpenid.isEmpty
- ? '去绑定'
- : '修改绑定账号',
- MyColors.c999999,
- 11),
- Container(
- margin: EdgeInsets.only(left: 5),
- child: SvgPicture.asset(
- 'images/svg/箭头.svg',
- color: MyColors.c999999,
- height: 8,
- width: 8,
- ),
- )
- ],
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.center,
- ),
- alignment: Alignment.center,
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- )
- ],
- ),
- ),
- );
- }
- void queryPersonalInformation() {
- MyDio().query({
- "key": "user",
- "filters": {
- "conditions": ["uid == ${MyCookie().getUID()}"]
- },
- "dims": userDims,
- "paging": [1, 20]
- }, (response, hasError) {
- if (!hasError) {
- UserBeanEntity entity =
- UserBeanEntity().fromJson(json.decode(response.data.toString()));
- MyCookie().userBean = entity.data.data[0];
- EventBus().emit('userChange');
- setState(() {});
- }
- }, (error) {});
- }
- void saveAlipayNum() {
- MyDio().update({
- "key": "user",
- "values": {
- "name": MyCookie().loginInformation.data.extra.name,
- "picture": MyCookie().loginInformation.data.extra.picture,
- "id": MyCookie().loginInformation.data.extra.id,
- "alipay_account": controller.text.toString()
- }
- }, (response, hasError) {
- if (!hasError) {
- MyCookie().userBean.aliPayAccount = controller.text.toString();
- showInput = false;
- setState(() {});
- }
- }, (error) {});
- }
- }
|