| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937 |
- 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/gang_in_page/gang_information_page/add_member_page/add_member_page.dart';
- import 'package:bbyyy/paegs/gang_page/gang_in_page/pay_to_the_helper_page/pay_to_the_helper_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/mine_page/privacy_protection_props_page/privacy_protection_props_page.dart';
- import 'package:bbyyy/paegs/mine_page/referrer_page/referrer_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<GangInPage> {
- 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<RedEnvelopeWallBeanDataData> redEnvelopes = [];
- _GangInPageState();
- List<GoodsBeanDataData> goods = [];
- List<SmartOrderBeanDataData> 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<String>(
- 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;
- default:
- break;
- }
- },
- itemBuilder: (context) {
- return <PopupMenuEntry<String>>[
- if (canSendGood)
- PopupMenuItem<String>(
- 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<String>(
- 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<String>(
- 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<String>(
- 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<String>(
- 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<String>(
- // 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<String>(
- // 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: 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: MyCookie().getUID() == widget.data.ownerUid ||
- !hideMember
- ? 1
- : 0,
- child: Visibility(
- visible: MyCookie().getUID() == widget.data.ownerUid ||
- !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) {});
- }
- },
- 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),
- actionExtentRatio: 0.25,
- secondaryActions: <Widget>[
- 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(),
- actionExtentRatio: 0.25,
- secondaryActions: <Widget>[
- 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 == $orderStateUnpaid');
- conditions.add('shop_uid == ${widget.data.shopUid}');
- } else {
- conditions.add('state == $orderStateUnpaid');
- 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 == $orderStateUnpaid');
- 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<MyShopBeanDataData> member = [];
- List<MyShopBeanDataData> 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<void>(
- 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;
- }
- }
|