import 'dart:async'; import 'dart:convert'; import 'package:bbyyy/beans/apply_for_red_packet_bean_entity.dart'; import 'package:bbyyy/beans/goods_bean_entity.dart'; import 'package:bbyyy/beans/my_shop_bean_entity.dart'; import 'package:bbyyy/beans/new_order_bean_entity.dart'; import 'package:bbyyy/beans/red_envelope_wall_bean_entity.dart'; import 'package:bbyyy/beans/smart_order_bean_entity.dart'; import 'package:bbyyy/beans/store_bean_entity.dart'; import 'package:bbyyy/beans/user_vp_bean_entity.dart'; import 'package:bbyyy/https/MyDio.dart'; import 'package:bbyyy/https/url.dart'; import 'package:bbyyy/my_tools/const.dart'; import 'package:bbyyy/my_tools/dims.dart'; import 'package:bbyyy/my_tools/easy_loading/easy_loading.dart'; import 'package:bbyyy/my_tools/event_bus.dart'; import 'package:bbyyy/my_tools/my_apis.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/my_tools/pop_up_queue.dart'; import 'package:bbyyy/my_tools/role_permissions.dart'; import 'package:bbyyy/paegs/chat_page/chat_page.dart'; import 'package:bbyyy/paegs/gang_page/create_a_gang_page/create_a_gang_page.dart'; import 'package:bbyyy/paegs/gang_page/gang_in_page/gang_information_page/add_member_page/add_member_page.dart'; import 'package:bbyyy/paegs/gang_page/gang_in_page/qr_pay_page/set_amount_page.dart'; import 'package:bbyyy/paegs/gang_page/gang_in_page/send_red_envelope_page/send_red_envelope_page.dart'; import 'package:bbyyy/paegs/gang_page/gang_in_page/shop_flow_page/shop_flow_page.dart'; import 'package:bbyyy/paegs/gang_page/qr_code_for_store_payment_page/qr_code_for_store_payment_page.dart'; import 'package:bbyyy/paegs/home_page/qr_code_payment/new_qr_code_payment_page.dart'; import 'package:bbyyy/paegs/mine_page/privacy_protection_props_page/privacy_protection_props_page.dart'; import 'package:bbyyy/paegs/other_people_s_turnover_page/other_people_s_turnover_page.dart'; import 'package:bbyyy/paegs/pay_page/order_information_page.dart'; import 'package:bbyyy/paegs/release_goods_page/release_goods_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:flutter_svg/svg.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:url_launcher/url_launcher.dart'; import 'gang_information_page/gang_information_page.dart'; import 'gang_information_page/member_list_page/member_details_page.dart'; import 'initiate_collection_page/initiate_collection_page.dart'; import 'scan_page/scan_page.dart'; class GangInPage extends StatefulWidget { MyShopBeanDataData data; NewOrderBeanContent order; GangInPage(this.data, this.order); @override _GangInPageState createState() => _GangInPageState(); } class _GangInPageState extends State { int selectedIndex = 0; RefreshController controller = RefreshController(initialRefresh: true); int page = 1; bool collect = false; bool needRE = false; bool canSendGood = false; bool hideOfflinePay = true; bool showMore = false; List redEnvelopes = []; _GangInPageState(); List goods = []; List orders = []; double ppx; bool redWallShowMore = false; TextEditingController _textEditingController = TextEditingController(); @override void initState() { // TODO: implement initState super.initState(); EventBus().on('payAnOrder', (arg) { controller.requestRefresh(); }); EventBus().on('reNoPayOrder', (arg) { controller.requestRefresh(); }); EventBus().on('刷新未付订单', (arg) { controller.requestRefresh(); }); Future.delayed(Duration.zero, () { if (widget.order != null) { setState(() { selectedIndex = 2; payTheOrder(); }); } }); if (paymentAuthority(widget.data.role)) { selectedIndex = 1; } Future.delayed(Duration.zero, () { // queryRedEnvelope(); queryWhetherToFollow(); queryStoreInformation(); }); } @override void dispose() { // TODO: implement dispose super.dispose(); EventBus().off('payAnOrder'); EventBus().off('reNoPayOrder'); EventBus().off('刷新未付订单'); } @override Widget build(BuildContext context) { ppx = MediaQuery.of(context).size.width / 375; return GestureDetector( onTap: () { MyTools().hideKeyboard(context); }, child: Scaffold( body: Column( children: [ MyViews().myAppBar(widget.data.shopName, context, [ Visibility( visible: false, child: IconButton( icon: Icon(Icons.qr_code_scanner), onPressed: () async { MyTools().toPage(context, ScanPage(), (then) { if (then is String) { if (then.isNotEmpty && then != null && then.length == 8) { Timer(Duration(milliseconds: 200), () { StoreBeanDataData store = StoreBeanDataData(); store.ownerUid = widget.data.ownerUid; store.ownerName = widget.data.ownerName; store.uid = widget.data.shopUid; MyTools().toPage( context, AddMemberPage( store: store, qrUID: then, ), (then) {}); MyTools().hideKeyboard(context); controller.requestRefresh(); }); } } }); }), ), Visibility( visible: false, child: IconButton( icon: Icon(Icons.more_horiz), onPressed: () { MyTools().toPage( context, GangInformationPage(widget.data), (then) { if (then == '删除货帮') { Navigator.pop(context, '删除货帮'); } }); }), ), PopupMenuButton( icon: Icon(Icons.more_horiz), onSelected: (v) { switch (v) { case '扫一扫': MyTools().toPage(context, ScanPage(), (then) { if (then is String) { if (then.isNotEmpty && then != null && then.length == 8) { Timer(Duration(milliseconds: 200), () { StoreBeanDataData store = StoreBeanDataData(); store.ownerUid = widget.data.ownerUid; store.ownerName = widget.data.ownerName; store.uid = widget.data.shopUid; MyTools().toPage( context, AddMemberPage( store: store, qrUID: then, ), (then) {}); MyTools().hideKeyboard(context); controller.requestRefresh(); }); } } }); break; case '发布商品': MyTools().toPage( context, ReleaseGoodsPage(null, widget.data.shopName), (then) { controller.requestRefresh(); }); break; case '货帮详情': MyTools().toPage( context, GangInformationPage(widget.data), (then) { queryStoreInformation(); if (then == '删除货帮') { Navigator.pop(context, '删除货帮'); } }); break; case '收款二维码': MyTools().toPage(context, QRCodeForStorePaymentPage(widget.data), (then) {}); break; case '货帮流水': MyTools().toPage( context, ShopFlowPage(widget.data), (then) {}); break; // case '推荐人': // MyTools().toPage( // context, ReferrerPage(data: widget.data), (then) {}); // break; case '发送红包': MyTools().toPage( context, SendRedEnvelopePage(widget.data), (then) { queryRedEnvelope(); }); break; case '开设分店': if(store!=null){ MyTools().toPage(context, CreateAGangPage(shop:store), (then){ Navigator.pop(context, '删除货帮'); }); } break; default: break; } }, itemBuilder: (context) { return >[ if (canSendGood) PopupMenuItem( value: '发布商品', child: Row( children: [ SvgPicture.asset( 'images/svg/发布商品_icon.svg', height: 22, width: 22, ), Container( child: Text( '发布商品', style: TextStyle( fontSize: 14, color: MyColors.c333333), ), margin: EdgeInsets.only(left: 5), ), ], ), ), PopupMenuItem( value: '货帮详情', child: Row( children: [ SvgPicture.asset( 'images/svg/货帮详情_icon.svg', height: 20, width: 20, ), Container( child: Text( '货帮详情', style: TextStyle( fontSize: 14, color: MyColors.c333333), ), margin: EdgeInsets.only(left: 5), ), ], ), ), if (addMemberPermissions(widget.data.role)) PopupMenuItem( value: '扫一扫', child: Row( children: [ SvgPicture.asset( 'images/svg/扫一扫_icon.svg', height: 20, width: 20, ), Container( child: Text( '扫一扫', style: TextStyle( fontSize: 14, color: MyColors.c333333), ), margin: EdgeInsets.only(left: 5), ), ], ), ), if (MyCookie().getUID() == widget.data.ownerUid) PopupMenuItem( value: '收款二维码', child: Row( children: [ SvgPicture.asset( 'images/svg/二维码.svg', height: 20, width: 20, ), Container( child: Text( '收款二维码', style: TextStyle( fontSize: 14, color: MyColors.c333333), ), margin: EdgeInsets.only(left: 5), ), ], ), ), if (checkStoreFlowPermissions(widget.data.role)) PopupMenuItem( value: '货帮流水', child: Row( children: [ SvgPicture.asset( 'images/svg/流水.svg', height: 20, width: 20, ), Container( child: Text( '货帮流水', style: TextStyle( fontSize: 14, color: MyColors.c333333), ), margin: EdgeInsets.only(left: 5), ), ], ), ), if (openABranch(widget.data.role)) PopupMenuItem( value: '开设分店', child: Row( children: [ SvgPicture.asset( 'images/svg/开设分店.svg', height: 20, width: 20, ), Container( child: Text( '开设分店', style: TextStyle( fontSize: 14, color: MyColors.c333333), ), margin: EdgeInsets.only(left: 5), ), ], ), ), // if (viewReferralAuthority(widget.data.role)) // PopupMenuItem( // value: '推荐人', // child: Row( // children: [ // SvgPicture.asset( // 'images/svg/推荐人.svg', // height: 20, // width: 20, // ), // Container( // child: Text( // '推荐人', // style: TextStyle( // fontSize: 14, color: MyColors.c333333), // ), // margin: EdgeInsets.only(left: 5), // ), // ], // ), // ), // PopupMenuItem( // value: '发送红包', // child: Row( // children: [ // SvgPicture.asset( // 'images/svg/红包_icon.svg', // height: 20, // width: 20, // ), // Container( // child: Text( // '发送红包', // style: TextStyle( // fontSize: 14, color: MyColors.c333333), // ), // margin: EdgeInsets.only(left: 5), // ), // ], // ), // ), ]; }, ) ]), Container( color: MyColors.cF7F7F7, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(4), color: Colors.white), margin: EdgeInsets.only(top: 10, left: 10, right: 10), child: Column( children: [ Row( children: [ Container( margin: EdgeInsets.only( right: 10, top: 6, left: 6, bottom: 6), child: GestureDetector( onTap: () { shopInfo(); }, behavior: HitTestBehavior.translucent, child: Container( decoration: BoxDecoration( border: Border.all(color: MyColors.cE7E7E7), borderRadius: BorderRadius.circular(4)), child: ClipRRect( child: MyViews().netImg( imgURL(widget.data.shopPic), 65, 65), borderRadius: BorderRadius.circular(4), ), ), ), ), Expanded( child: Container( height: 65, margin: EdgeInsets.only(right: 6), child: Column( children: [ Row( children: [ Text( widget.data.shopName, style: TextStyle( color: MyColors.c333333, fontSize: 13), maxLines: 1, overflow: TextOverflow.ellipsis, softWrap: true, ), ], mainAxisAlignment: MainAxisAlignment.spaceBetween, ), Row( children: [ Expanded( child: Text( store != null && store.introduction.isNotEmpty ? '货帮介绍:${store.introduction}' : '货帮介绍:暂无', style: TextStyle( color: MyColors.c666666, fontSize: 11), maxLines: 1, overflow: TextOverflow.ellipsis, softWrap: true, ), ), ], crossAxisAlignment: CrossAxisAlignment.center, ), GestureDetector( onTap: () { MyViews().mapNavigationPopup(store.latitude, store.longitude, context); }, behavior: HitTestBehavior.translucent, child: Row( children: [ SvgPicture.asset( 'images/svg/地址.svg', color: MyColors.c666666, height: 12, width: 12, ), Container( width: 5, ), Expanded( child: Text( store != null && store.address.isNotEmpty ? store.address : '暂无', style: TextStyle( color: MyColors.c666666, fontSize: 11), maxLines: 1, overflow: TextOverflow.ellipsis, softWrap: true, ), ), ], ), ), ], crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, ), ), ), Visibility( visible: !widget.data.privateShop, child: GestureDetector( child: Container( margin: EdgeInsets.all(12), child: SvgPicture.asset( collect ? 'images/svg/已收藏.svg' : 'images/svg/未收藏.svg', height: 20, width: 20, ), ), onTap: () { if (MyCookie().getUID() == widget.data.ownerUid) { return; } EasyLoading.show(); collectionShop(); }, ), ), ], ), Container( height: 0.5, color: MyColors.cE7E7E7, ), Visibility( visible: store != null && store.mobile.isNotEmpty, child: Container( margin: EdgeInsets.all(6), child: Row( children: [ Row( children: [ SvgPicture.asset( 'images/svg/电话.svg', height: 18, width: 18, ), Container( width: 5, ), Text( store == null ? '暂无' : store.mobile, style: TextStyle( color: MyColors.cFF4233, fontSize: 12), ), ], ), GestureDetector( onTap: () { launch('tel:${store.mobile}'); }, behavior: HitTestBehavior.translucent, child: Container( decoration: BoxDecoration( color: MyColors.cFF4233, borderRadius: BorderRadius.circular(10), ), height: 20, width: 50, child: MyViews().myText('点击拨打', Colors.white, 9), alignment: Alignment.center, ), ) ], mainAxisAlignment: MainAxisAlignment.spaceBetween, ), ), ) ], ), ), ), if (store != null && store.notice.isNotEmpty) GestureDetector( onTap: () { setState(() { showMore = !showMore; }); }, behavior: HitTestBehavior.translucent, child: AnimatedContainer( child: showMore ? Text( '货帮公告 : ${store.notice.isEmpty ? '暂无' : store.notice}', ) : Text( '货帮公告 : ${store.notice.isEmpty ? '暂无' : store.notice}', maxLines: 1, overflow: TextOverflow.ellipsis, softWrap: true, ), color: Colors.white, width: double.infinity, padding: EdgeInsets.all(12), margin: EdgeInsets.only(top: 10), duration: Duration(seconds: 1), ), ), if (/*redEnvelopes.isNotEmpty*/ false) redEnvelopeWall(), Visibility( visible: widget.data.privateShop || paymentAuthority(widget.data.role), child: Container( height: 40, margin: EdgeInsets.only(top: 10), color: Colors.white, child: Row( children: [ Expanded( flex: 1, child: GestureDetector( onTap: () { setState(() { selectedIndex = 0; }); controller.requestRefresh(); }, behavior: HitTestBehavior.translucent, child: Padding( padding: EdgeInsets.only(left: 10, right: 10), child: Column( children: [ Text( '货帮商品', style: TextStyle( color: selectedIndex == 0 ? MyColors.cFF4233 : MyColors.c666666, fontSize: 15), ), Container( height: 10, child: Visibility( child: SvgPicture.asset('images/svg/tab.svg'), visible: selectedIndex == 0, ), ) ], mainAxisAlignment: MainAxisAlignment.end, ), ), ), ), Expanded( flex: 1, child: GestureDetector( onTap: () { setState(() { selectedIndex = 1; }); controller.requestRefresh(); }, behavior: HitTestBehavior.translucent, child: Padding( padding: EdgeInsets.only(left: 10, right: 10), child: Column( children: [ Text( paymentAuthority(widget.data.role) ? '未付订单' : '未收订单', style: TextStyle( color: selectedIndex == 1 ? MyColors.cFF4233 : MyColors.c666666, fontSize: 15), ), Container( height: 10, child: Visibility( child: SvgPicture.asset('images/svg/tab.svg'), visible: selectedIndex == 1, ), ) ], mainAxisAlignment: MainAxisAlignment.end, ), ), ), ), Expanded( flex: 1, child: GestureDetector( onTap: () { setState(() { selectedIndex = 2; }); controller.requestRefresh(); }, behavior: HitTestBehavior.translucent, child: Padding( padding: EdgeInsets.only(left: 10, right: 10), child: Column( children: [ Text( paymentAuthority(widget.data.role) ? '已付订单' : '未付订单', style: TextStyle( color: selectedIndex == 2 ? MyColors.cFF4233 : MyColors.c666666, fontSize: 15), ), Container( height: 10, child: Visibility( child: SvgPicture.asset('images/svg/tab.svg'), visible: selectedIndex == 2, ), ) ], mainAxisAlignment: MainAxisAlignment.end, ), ), ), ), Expanded( flex: addMemberPermissions(widget.data.role) || !hideMember ? 1 : 0, child: Visibility( visible: addMemberPermissions(widget.data.role) || !hideMember, child: GestureDetector( onTap: () { setState(() { selectedIndex = 3; }); controller.requestRefresh(); }, behavior: HitTestBehavior.translucent, child: Padding( padding: EdgeInsets.only(left: 10, right: 10), child: Column( children: [ Text( '货帮成员', style: TextStyle( color: selectedIndex == 3 ? MyColors.cFF4233 : MyColors.c666666, fontSize: 15), ), Container( height: 10, child: Visibility( child: SvgPicture.asset('images/svg/tab.svg'), visible: selectedIndex == 3, ), ) ], mainAxisAlignment: MainAxisAlignment.end, ), ), ), ), ) ], ), ), ), Expanded( child: Column( children: [ if (selectedIndex == 3) Container( height: 40, decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.white), margin: EdgeInsets.only(left: 15, right: 15, top: 10), child: Row( children: [ Expanded( child: TextField( controller: _textEditingController, decoration: InputDecoration( border: InputBorder.none, disabledBorder: InputBorder.none, enabledBorder: InputBorder.none, focusedBorder: InputBorder.none, isDense: true, hintText: '请输入信息', hintStyle: TextStyle( color: MyColors.c999999, fontSize: 16), contentPadding: const EdgeInsets.fromLTRB(14, 4.5, 8, 4.5), ), ), ), GestureDetector( onTap: () { controller.requestRefresh(); MyTools().hideKeyboard(context); }, behavior: HitTestBehavior.translucent, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: MyColors.cFF4233), height: 40, width: 80, child: Text( '搜 索', style: TextStyle( color: Colors.white, fontSize: 14), ), alignment: Alignment.center, ), ), if (addMemberPermissions(widget.data.role)) GestureDetector( onTap: () { MyTools().toPage( context, AddMemberPage(store: store), (then) { controller.requestRefresh(needMove: false); }); }, behavior: HitTestBehavior.translucent, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: MyColors.cFF4233), height: 40, width: 40, margin: EdgeInsets.only(left: 10), child: SvgPicture.asset( 'images/svg/添加成员.svg', height: 18, width: 18, color: Colors.white, ), alignment: Alignment.center, ), ), ], ), ), Expanded( child: SmartRefresher( controller: controller, onRefresh: onRefresh, onLoading: onLoading, enablePullDown: true, enablePullUp: true, child: body(), ), ), ], ), ), Container( color: Colors.white, child: SafeArea( top: false, child: Container( padding: EdgeInsets.symmetric(horizontal: 37), color: Colors.white, width: double.infinity, height: 60, child: Row( children: [ Expanded( child: GestureDetector( onTap: () { if (!widget.data.privateShop && MyCookie().getUID() == widget.data.ownerUid) { MyTools().toPage(context, SetAmountPage(widget.data), (then) {}); } else { queryShopMembers(true); } }, behavior: HitTestBehavior.translucent, child: Container( decoration: BoxDecoration( borderRadius: !hideOfflinePay ? BorderRadius.only( topLeft: Radius.circular(20), bottomLeft: Radius.circular(20), ) : BorderRadius.circular(20), border: Border.all( color: MyColors.cFF4233, width: 1)), height: 40, child: MyViews().myText( !widget.data.privateShop && MyCookie().getUID() == widget.data.ownerUid ? '扫码收款' : '联系帮主', MyColors.cFF4233, 14), alignment: Alignment.center), ), ), if (!hideOfflinePay) Expanded( child: GestureDetector( onTap: () { if (MyCookie().getUID() == widget.data.ownerUid) { MyTools().toPage(context, InitiateCollectionPage(widget.data), (then) { if (then is String && then == '发起收款') { controller.requestRefresh(); } }); } else { // MyTools().toPage(context, // PayToTheHelperPage(widget.data), (then) {}); MyTools().toPage( context, NewPayToTheGangPage(widget.data.shopUid, orderTypeOfflineTransfer), (then) {}); } }, behavior: HitTestBehavior.translucent, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.only( topRight: Radius.circular(20), bottomRight: Radius.circular(20), ), color: MyColors.cFF4233), height: 40, child: MyViews().myText( MyCookie().getUID() == widget.data.ownerUid ? '发起收款' : '到店付款', Colors.white, 14), alignment: Alignment.center), ), ) ], ), ), ), ) ], ), ), ); } body() { if (selectedIndex == 0) { return goods.length == 0 ? SingleChildScrollView(child: noData()) : GridView.builder( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, //每行三列 childAspectRatio: 164 / 261, //显示区域宽高相等 mainAxisSpacing: 8, crossAxisSpacing: 8), itemCount: goods.length, padding: EdgeInsets.only(left: 14, right: 14, top: 14, bottom: 65), itemBuilder: (context, index) { return MyViews().getGoodsItem(goods[index], context); }); } else if (selectedIndex == 1) { return orders.length == 0 ? SingleChildScrollView(child: noData()) : ListView.builder( itemBuilder: (c, index) { return Slidable( child: MyViews().getNoPayGoodsItem(orders[index], context, widget.data.ownerUid, widget.data.role), actionPane: SlidableDrawerActionPane(), enabled: paymentAuthority(widget.data.role) && orders[index].state != orderStatePaying, actionExtentRatio: 0.25, secondaryActions: [ SlideAction( child: Container( child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(30), color: MyColors.cFF4233, ), height: 60, width: 60, child: SvgPicture.asset( 'images/svg/del.svg', height: 40, width: 40, ), alignment: Alignment.center, ), ), onTap: () { showSimpleDialog('将删除订单(${orders[index].uid})', context, () { Navigator.pop(context); deleteOrder(orders[index]); }); }, ) ], ); }, itemCount: orders.length, padding: EdgeInsets.only(left: 10, right: 10, top: 10), ); } else if (selectedIndex == 2) { return orders.length == 0 ? SingleChildScrollView(child: noData()) : ListView.builder( itemBuilder: (c, index) { return Slidable( child: MyViews().getNoPayGoodsItem(orders[index], context, widget.data.ownerUid, widget.data.role), actionPane: SlidableDrawerActionPane(), enabled: orders[index].type == orderTypeOfflineTransfer && orders[index].buyerUid == MyCookie().getUID() && orders[index].state != orderStatePaying, actionExtentRatio: 0.25, secondaryActions: [ SlideAction( child: Container( child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(30), color: MyColors.cFF4233, ), height: 60, width: 60, child: SvgPicture.asset( 'images/svg/del.svg', height: 40, width: 40, ), alignment: Alignment.center, ), ), onTap: () { showSimpleDialog('将删除订单(${orders[index].uid})', context, () { Navigator.pop(context); deleteOrder(orders[index]); }); }, ) ], ); }, itemCount: orders.length, padding: EdgeInsets.only(left: 10, right: 10, top: 10), ); } else if (selectedIndex == 3) { return member.length == 0 ? SingleChildScrollView(child: noData()) : ListView.builder( itemBuilder: (BuildContext context, int index) { return GestureDetector( onTap: () { if (permissionToModifyCustomerName(widget.data.role)) { if (MyCookie().getUID() != member[index].userUid) { MyTools().toPage( context, MemberDetailsPage(member[index]), (then) { controller.requestRefresh(); }); } } else { return; } }, behavior: HitTestBehavior.translucent, child: Container( padding: EdgeInsets.only(left: 15, right: 15), color: Colors.white, child: Column( children: [ Container( margin: EdgeInsets.only(top: 8, bottom: 6), child: Row( children: [ Row( children: [ Container( margin: EdgeInsets.only(right: 6), child: ClipRRect( child: MyViews().netImg( imgURL(member[index].userPic), 42, 42), borderRadius: BorderRadius.circular(21), ), ), MyViews().myText( '${member[index].userName} ${store.ownerUid == MyCookie().getUID() ? '(${member[index].userUid})' : ''}', MyColors.c333333, 15), Visibility( visible: member[index].role != shopUserMember, child: Container( decoration: BoxDecoration( color: MyColors.cFFCD00, borderRadius: BorderRadius.circular(8)), height: 16, padding: EdgeInsets.symmetric(horizontal: 5), child: MyViews().myText( roleText(member[index].role), Colors.white, 10), alignment: Alignment.center, margin: EdgeInsets.only(left: 5), ), ) ], ), Visibility( // visible: member[index].role != shopUserOwner && // member[index].userUid != // MyCookie().getUID(), visible: false, child: GestureDetector( child: Container( margin: EdgeInsets.only(right: 10), child: SvgPicture.asset( 'images/svg/透视.svg', height: 25, width: 25, ), ), onTap: () { queryWhetherThereIsANumberOfPerspectives( member[index], store, context); }, behavior: HitTestBehavior.translucent, ), ), ], mainAxisAlignment: MainAxisAlignment.spaceBetween, ), ), Container( height: 0.5, color: MyColors.cE7E7E7, ) ], ), ), ); }, itemCount: member.length, padding: EdgeInsets.only(top: 10), ); } else { return SingleChildScrollView(child: noData()); } } void onRefresh() { page = 1; if (selectedIndex == 0) { queryProducts(); } else if (selectedIndex == 1) { unreceivedOrder(); } else if (selectedIndex == 3) { queryShopMembers(false); } else { unpaidOrder(); } } void onLoading() { page++; if (selectedIndex == 0) { queryProducts(); } else if (selectedIndex == 1) { unreceivedOrder(); } else if (selectedIndex == 3) { queryShopMembers(false); } else { unpaidOrder(); } } //查询商品 void queryProducts() { MyDio().query({ "key": "commodity", "filters": { "conditions": ["shop_uid == ${widget.data.shopUid}", "on_sale == true"] }, "dims": commodityDims, "order_by": ["id,desc", "no,desc"], "paging": [page, 20] }, (response, hasError) { if (!hasError) { GoodsBeanEntity entity = GoodsBeanEntity.fromJson(json.decode(response.data.toString())); if (page == 1) { goods.clear(); } goods.addAll(entity.data.data); } setState(() { endRe(controller); }); }, (error) { setState(() { endRe(controller); }); }); } //查询未收订单 void unreceivedOrder() { var conditions = []; if (paymentAuthority(widget.data.role)) { conditions.add('state IN [$orderStateUnpaid,$orderStatePaying]'); conditions.add('shop_uid == ${widget.data.shopUid}'); } else { conditions.add('state IN [$orderStateUnpaid,$orderStatePaying]'); conditions.add('shop_uid == ${widget.data.shopUid}'); conditions.add('seller_uid == ${MyCookie().getUID()}'); } MyDio().query({ "key": "order", "filters": {"conditions": conditions}, "dims": orderDims, "paging": [page, 20], "order_by": ["create_time,DESC"] }, (response, hasError) { if (!hasError) { SmartOrderBeanEntity entity = SmartOrderBeanEntity.fromJson( json.decode(response.data.toString())); if (page == 1) { orders.clear(); } orders.addAll(entity.data.data); setState(() {}); } endRe(controller); }, (error) {}); } //查询未付订单 void unpaidOrder() { var conditions = []; if (paymentAuthority(widget.data.role)) { conditions.add('state == $orderStatePaid'); conditions.add('shop_uid == ${widget.data.shopUid}'); } else { conditions.add('state IN [$orderStateUnpaid,$orderStatePaying]'); conditions.add('shop_uid == ${widget.data.shopUid}'); conditions.add('buyer_uid==0'); conditions.add('buyer_name LIKE ${MyCookie().getName()}'); } var filters; if (paymentAuthority(widget.data.role)) { filters = {"conditions": conditions}; } else { filters = { "conditions": conditions, "or": true, "filters": [ { "conditions": [ "state == $orderStateUnpaid", 'shop_uid == ${widget.data.shopUid}', 'buyer_uid==${MyCookie().getUID()}' ] } ] }; } MyDio().query({ "key": "order", "filters": filters, "dims": orderDims, "paging": [page, 20], "order_by": ["create_time,DESC"] }, (response, hasError) { if (!hasError) { SmartOrderBeanEntity entity = SmartOrderBeanEntity.fromJson( json.decode(response.data.toString())); if (page == 1) { orders.clear(); } orders.addAll(entity.data.data); setState(() {}); } endRe(controller); }, (error) {}); } payTheOrder() { SmartOrderBeanDataData data = SmartOrderBeanDataData(); data.sellerUid = widget.order.sellerUID; data.sellerName = widget.order.sellerName; data.sellerPic = widget.order.sellerPic; data.buyerUid = 0; data.buyerName = widget.order.buyerName; data.buyerPic = ''; data.amount = widget.order.amount; data.uid = widget.order.uID; MyTools().toPage( context, OrderInformationPage( false, orderType: orderTypeThirdPlatform, amount: widget.order.amount, uid: widget.order.uID, buyerUid: MyCookie().getUID(), buyerName: widget.order.buyerName, buyerPic: MyCookie().getPic(), commodityCount: 1, commodityTitle: '第三方订单', commodityCover: '', sellName: widget.order.sellerName, sellPic: widget.order.sellerPic, sellUid: widget.order.sellerUID, ), (then) { controller.requestRefresh(); PopUpQueue().onShow = false; PopUpQueue().showNext(); }); // showPayDialog(data, context, () { // Navigator.pop(context); // // MyTools().toPage(context, // // PayPage(widget.order.uID, false, widget.order.amount), (then) {}); // // }); } List member = []; List helper = []; queryShopMembers(bool toOwner) { var conditions = ["shop_uid==${store.uid}", "review_state==1"]; if (_textEditingController.text.isNotEmpty) { conditions .add('user_name LIKE ${_textEditingController.text.toString()}'); } MyDio().query({ "key": "shop_user", "filters": {"conditions": conditions}, "dims": shopUserDims, "paging": [page, 50] }, (response, hasError) { if (!hasError) { MyShopBeanEntity entity = MyShopBeanEntity.fromJson(json.decode(response.data.toString())); if (page == 1) { member.clear(); } member.addAll(entity.data.data); if (toOwner) { helper.clear(); member.forEach((element) { if (element.role == shopUserStaff) { helper.add(element); } }); MyShopBeanDataData chatWith; // if (helper.length == 0) { chatWith = member[ member.indexWhere((element) => element.role == shopUserOwner)]; // } else { // chatWith = helper[Random().nextInt(helper.length)]; // } MyTools().toPage(context, ChatPage(chatWith, null), (then) {}); } else { controller.refreshCompleted(); controller.loadComplete(); setState(() {}); } _textEditingController.clear(); } }, (error) {}); } void deleteOrder(SmartOrderBeanDataData order) { MyDio().del({ 'key': 'order', 'ids': [order.id] }, (response, hasError) { if (!hasError) { orders.remove(order); setState(() {}); } }, (error) {}); } StoreBeanDataData store; bool hideMember = true; queryStoreInformation() { MyDio().query({ "key": "shop", "filters": { "conditions": ["uid == ${widget.data.shopUid}"] }, "dims": shopDims, "paging": [1, 5] }, (response, hasError) { if (!hasError) { StoreBeanEntity entity = StoreBeanEntity.fromJson(json.decode(response.data.toString())); store = entity.data.data[0]; hideMember = store.hideMembers; hideOfflinePay = store.hideOfflinePay; //自己的公开店铺 if (!store.private && store.ownerUid == MyCookie().getUID()) { canSendGood = true; } //自己在某个允许顾客间交易的私有店铺中 if (store.innerTrade && store.private) { canSendGood = true; } setState(() {}); } endRe(controller); }, (error) {}); } void queryWhetherThereIsANumberOfPerspectives( MyShopBeanDataData data, StoreBeanDataData store, BuildContext context) { MyDio().query({ "key": "user_vp", "filters": { "conditions": [ "user_uid == ${MyCookie().getUID()}", "vp_key == $vpKeyXRay" ] }, "dims": userVpDims, "paging": [1, 2000] }, (response, hasError) { UserVpBeanEntity entity = UserVpBeanEntity.fromJson(json.decode(response.data.toString())); if (entity.data.data.length != 0) { MyTools().toPage(context, OtherPeopleSTurnoverPage(data), (then) {}); } else { // showSimpleDialog('你还未获取透视道具或道具用完,请先购买次数再查看。', context, () { // Navigator.pop(context); // MyShopBeanDataData shop = MyShopBeanDataData(); // shop.shopUid = store.uid; // shop.shopName = store.name; // shop.shopPic = store.picture; // MyTools().toPage( // context, PrivacyProtectionPropsPage(shop, vpKeyXRay), (then) {}); // }); MyShopBeanDataData shop = MyShopBeanDataData(); shop.shopUid = store.uid; shop.shopName = store.name; shop.shopPic = store.picture; MyTools().toPage( context, PrivacyProtectionPropsPage(shop, vpKeyXRay), (then) {}); } }, (error) {}); } void shopInfo() { showDialog( context: context, builder: (BuildContext context) { return GestureDetector( onTap: () { Navigator.pop(context); }, child: Material( color: Colors.black12, child: Center( child: GestureDetector( onTap: () {}, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(16), color: Colors.white, ), height: 510, margin: EdgeInsets.symmetric(horizontal: 28), padding: EdgeInsets.symmetric(horizontal: 14, vertical: 15), child: Column( children: [ Container( height: MediaQuery.of(context).size.width - 71, width: MediaQuery.of(context).size.width - 56, child: ClipRRect( child: MyViews().netImg( imgURL(widget.data.shopPic), MediaQuery.of(context).size.width - 84, MediaQuery.of(context).size.width - 84), borderRadius: BorderRadius.circular(4), ), ), Row( children: [ SvgPicture.asset( 'images/svg/店铺.svg', height: 21, width: 21, ), Container( width: 6, ), Expanded( child: Text( widget.data.shopName, style: TextStyle( color: MyColors.c333333, fontSize: 16), )) ], ), Container( height: 10, ), Text( store != null && store.introduction.isNotEmpty ? '货帮介绍:${store.introduction}' : '货帮介绍:暂无', style: TextStyle( color: MyColors.c333333, fontSize: 12, ), maxLines: 3, overflow: TextOverflow.ellipsis, softWrap: true, ), Container( height: 10, ), Row( children: [ SvgPicture.asset( 'images/svg/地址.svg', color: MyColors.c666666, height: 12, width: 12, ), Container( width: 5, ), Expanded( child: Text( store != null && store.address.isNotEmpty ? store.address : '暂无', style: TextStyle( color: MyColors.c666666, fontSize: 11), maxLines: 1, overflow: TextOverflow.ellipsis, softWrap: true, ), ), ], ), Container( height: 10, ), Visibility( visible: store != null && store.mobile.isNotEmpty, child: GestureDetector( onTap: () { launch('tel:${store.mobile}'); }, behavior: HitTestBehavior.translucent, child: Container( decoration: BoxDecoration( color: MyColors.cFF4233, borderRadius: BorderRadius.circular(20), ), height: 40, child: Row( children: [ SvgPicture.asset( 'images/svg/电话.svg', color: Colors.white, height: 24, width: 24, ), Container( width: 4, ), Text( store == null ? '' : store.mobile, style: TextStyle( color: Colors.white, fontSize: 15), ), ], mainAxisAlignment: MainAxisAlignment.center, ), alignment: Alignment.center, ), ), ) ], mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, ), ), ), ), ), ); }, ); } void collectionShop() { if (!collect) { MyDio().save({ 'key': 'shop_user', 'object': { 'review_state': 1, 'user_uid': MyCookie().getUID(), 'shop_uid': widget.data.shopUid, 'role': shopUserMember } }, (response, hasError) { if (!hasError) { needRE = !needRE; EventBus().emit('needRE', needRE); showToast('收藏成功'); queryWhetherToFollow(); } }, (error) {}); } else { MyDio().del({ 'key': 'shop_user', 'ids': [shopUserID] }, (response, hasError) { if (!hasError) { needRE = !needRE; EventBus().emit('needRE', needRE); showToast('取消收藏'); collect = false; shopUserID = null; setState(() {}); } }, (error) {}); } } int shopUserID; void queryWhetherToFollow() { MyDio().query({ "key": "shop_user", "filters": { "conditions": [ "shop_uid==${widget.data.shopUid}", "user_uid==${MyCookie().getUID()}" ] }, "dims": shopUserDims, "paging": [1, 1] }, (response, hasError) { if (!hasError) { MyShopBeanEntity entity = MyShopBeanEntity.fromJson(json.decode(response.data.toString())); collect = entity.data.data.length != 0; if (entity.data.data.isNotEmpty) { shopUserID = entity.data.data[0].id; } setState(() {}); } }, (error) {}); } ScrollController _controller = ScrollController(); redEnvelopeWall() { return Column( children: [ Container( height: redWallShowMore ? 375 / 3 * ppx / 19 * 48 : 375 / 3 * ppx / 19 * 24, child: GridView.builder( controller: _controller, itemBuilder: (BuildContext context, int index) { return Stack( children: [ Positioned( child: Container( width: 375 / 3 * ppx, height: 375 / 3 * ppx / 19 * 24, decoration: BoxDecoration( borderRadius: BorderRadius.circular(16), color: MyColors.cF25D4B), alignment: Alignment.bottomCenter, child: CustomPaint( painter: RedEnvelope1Path(), size: Size(375 / 3 * ppx, 375 / 171 * 24 * ppx)), ), ), Positioned( top: 375 / 185 * 43.2 * ppx, child: GestureDetector( onTap: () { grabARedEnvelope(redEnvelopes[index]); }, behavior: HitTestBehavior.translucent, child: Container( decoration: BoxDecoration( color: MyColors.cF1D19B, borderRadius: BorderRadius.circular(45 * ppx)), height: 375 / 57 * ppx * 5, width: 375 / 57 * ppx * 5, child: Text( '开', style: TextStyle( color: MyColors.c333333, fontSize: 375 / 57 * ppx * 3, decoration: TextDecoration.none, fontWeight: FontWeight.normal), ), alignment: Alignment.center, ), ), ), Positioned( top: 15, child: Column( children: [ ClipRRect( child: MyViews().netImg( imgURL(redEnvelopes[index].payerPic), 375 / 57 * ppx * 4, 375 / 57 * ppx * 4), borderRadius: BorderRadius.circular(375 / 57 * ppx * 2), ), Container( child: Text( '${redEnvelopes[index].payerName}(${hideUID(redEnvelopes[index].payerUid.toString())})', style: TextStyle( color: Colors.white, fontSize: 25 / 3 * ppx), maxLines: 1, ), margin: EdgeInsets.symmetric(vertical: 5), ), Text( '${redEnvelopes[index].title}', style: TextStyle( color: Colors.white, fontSize: 25 / 3 * ppx), maxLines: 1, ) ], ), ), ], alignment: Alignment.topCenter, ); }, physics: redWallShowMore ? null : NeverScrollableScrollPhysics(), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 3, childAspectRatio: 19 / 24, mainAxisSpacing: 8, crossAxisSpacing: 8), itemCount: redEnvelopes.length, padding: EdgeInsets.fromLTRB(10, 10, 10, 10), ), ), GestureDetector( onTap: () { setState(() { redWallShowMore = !redWallShowMore; if (!redWallShowMore) { _controller.animateTo(0.0, duration: Duration(milliseconds: 500), curve: Curves.ease); } }); }, behavior: HitTestBehavior.translucent, child: Container( height: 30, child: Icon(redWallShowMore ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down), alignment: Alignment.center, ), ) ], ); } int rPage = 1; void queryRedEnvelope() { MyDio().query({ "key": "red_packet", "filters": { "conditions": ["shop_uid==${widget.data.shopUid}", 'left_count>0'], }, "dims": redPacketDims, "paging": [rPage, 10] }, (response, hasError) { if (!hasError) { RedEnvelopeWallBeanEntity entity = RedEnvelopeWallBeanEntity.fromJson( json.decode(response.toString())); if (rPage == 1) { redEnvelopes.clear(); } redEnvelopes.addAll(entity.data.data); setState(() {}); } }, (error) {}); } void grabARedEnvelope(RedEnvelopeWallBeanDataData redEnvelope) { EasyLoading.show(); MyDio().post(MyApis.getApi('applyForRedPacket2'), { 'id': redEnvelope.id, 'user_uid': MyCookie().getUID() }, (response, hasError) { if (!hasError) { rPage = 1; queryRedEnvelope(); ApplyForRedPacketBeanEntity entity = ApplyForRedPacketBeanEntity.fromJson( json.decode(response.toString())); showResult(entity.data, redEnvelope); EasyLoading.dismiss(); } }, (error) {}); } void showResult( ApplyForRedPacketBeanData data, RedEnvelopeWallBeanDataData redEnvelope) { showDialog( context: context, barrierDismissible: false, // false = user must tap button, true = tap outside dialog builder: (BuildContext dialogContext) { return StatefulBuilder( builder: (BuildContext context, void Function(void Function()) setState) { return Container( child: Column( children: [ Stack( children: [ Positioned( child: Container( height: 396 * ppx, width: double.infinity, decoration: BoxDecoration( borderRadius: BorderRadius.circular(16), color: MyColors.cEB4935), margin: EdgeInsets.symmetric(horizontal: 45 * ppx), alignment: Alignment.bottomCenter, ), ), Positioned( child: Column( children: [ SvgPicture.asset('images/svg/logo.svg'), Container( margin: EdgeInsets.only(top: 67 * ppx), child: Text( '${double.parse(data.amount.toString()).toStringAsFixed(2)}元', style: TextStyle( color: MyColors.cF1D19B, fontSize: 38 * ppx, fontWeight: FontWeight.bold, decoration: TextDecoration.none), ), ), Container( margin: EdgeInsets.only(top: 20 * ppx), child: Text( '${redEnvelope.title}', style: TextStyle( color: Colors.white, fontSize: 20 * ppx, decoration: TextDecoration.none), ), ), ], ), top: 37 * ppx, ), ], alignment: Alignment.topCenter, ), GestureDetector( onTap: () { Navigator.pop(context); }, child: Container( margin: EdgeInsets.only(top: 24 * ppx), child: Icon( Icons.clear, color: Colors.white, ), height: 28 * ppx, width: 28 * ppx, alignment: Alignment.center, decoration: BoxDecoration( color: MyColors.c25E7E7E7, borderRadius: BorderRadius.circular(14 * ppx)), ), ) ], mainAxisAlignment: MainAxisAlignment.center, ), alignment: Alignment.center, ); }, ); }, ); } } class RedEnvelope1Path extends CustomPainter { Paint _paint = Paint() ..color = MyColors.cF55544 //画笔颜色 ..strokeCap = StrokeCap.round //画笔笔触类型 ..isAntiAlias = true //是否启动抗锯齿 ..strokeWidth = 15.0; //画笔的宽度 @override void paint(Canvas canvas, Size size) { var path = Path() ..moveTo(0, 0) ..quadraticBezierTo(size.width / 2, 25, size.width, 0) ..lineTo(size.width, size.height - 16) ..quadraticBezierTo(size.width, size.height, size.width - 16, size.height) ..lineTo(16, size.height) ..quadraticBezierTo(0, size.height, 0, size.height - 16) ..close(); canvas.drawPath(path, _paint); } @override bool shouldRepaint(covariant CustomPainter oldDelegate) { return false; } }