import 'dart:convert'; import 'package:bbyyy/beans/my_shop_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/my_colors.dart'; import 'package:bbyyy/my_tools/my_cookie.dart'; import 'package:bbyyy/my_tools/my_views.dart'; import 'package:flutter/material.dart'; import 'package:lpinyin/lpinyin.dart'; class AssociatedStorePage extends StatefulWidget { @override _AssociatedStorePageState createState() => _AssociatedStorePageState(); } class _AssociatedStorePageState extends State { List data = []; @override void initState() { super.initState(); findAStore(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: MyColors.cF7F7F7, body: Column( children: [ MyViews().myAppBar('关联货帮', context, []), Container(height: 10,color: MyColors.cF7F7F7,), Expanded( child: ListView.builder( padding: EdgeInsets.all(0), itemBuilder: (context, index) { return GestureDetector( onTap: (){ Navigator.pop(context,data[index]); }, behavior: HitTestBehavior.translucent, child: Container( height: 73, color: Colors.white, child: Column( children: [ Expanded( child: Row( children: [ Container( margin: EdgeInsets.only(left: 14, right: 14), child: ClipRRect( child: MyViews().netImg( imgURL(data[index].shopPic), 45, 45, placeholder: 'images/svg/占位图.svg'), borderRadius: BorderRadius.all(Radius.circular(4)), ), ), Expanded( child: Container( height: 45, padding: EdgeInsets.only(right: 14), child: Column( children: [ Row( children: [ Expanded( child: Text( data[index].shopName, style: TextStyle( color: MyColors.c333333, fontSize: 15), )), Visibility( child: Container( decoration: BoxDecoration( color: MyColors.cFFCD00, borderRadius: BorderRadius.only( topLeft: Radius.circular(6), bottomRight: Radius.circular(6))), height: 18, width: 30, child: Text( '自建', style: TextStyle( color: Colors.white, fontSize: 10), ), alignment: Alignment.center, padding: EdgeInsets.only(bottom: 2), ), visible: data[index].role == shopUserOwner, ), ], ), Row( children: [ Expanded( child: Text( 'ID:${data[index].shopUid}', style: TextStyle( color: MyColors.c888888, fontSize: 12), ), ), Visibility( child: Container( decoration: BoxDecoration( color: MyColors.cFF4233, borderRadius: BorderRadius.only( topLeft: Radius.circular(6), bottomRight: Radius.circular(6))), height: 18, width: 30, child: Text( '欠费', style: TextStyle( color: Colors.white, fontSize: 10), ), alignment: Alignment.center, padding: EdgeInsets.only(bottom: 2), ), visible: data[index].shopState == shopStateArrearage, ), ], ) ], mainAxisAlignment: MainAxisAlignment.spaceBetween, ), ), ) ], ), ), Container( margin: EdgeInsets.only(left: 73, right: 14), height: 0.5, color: MyColors.cE7E7E7, ) ], mainAxisAlignment: MainAxisAlignment.spaceBetween, ), ), ); }, itemCount: data.length, ), ), ], ), ); } void findAStore() { MyDio().query({ "key": "shop_user", "filters": { "or": true, "conditions": [ "role!=$shopUserOwner", "user_uid==${MyCookie().getUID()}", "review_state==1" ], "filters": [ { "conditions": [ "role==$shopUserOwner", "user_uid==${MyCookie().getUID()}" ] } ] }, "dims": shopUserDims, "paging": [1, 5000], "order_by": ["shop_name,DESC"] }, (response, hasError) { MyShopBeanEntity entity = MyShopBeanEntity.fromJson(json.decode(response.data.toString())); data.clear(); entity.data.data.forEach((element) { //自己创建的店铺,允许顾客间交易的私有店铺 if (element.ownerUid == MyCookie().getUID()) { data.add(element); } else if (element.privateShop && element.innerTrade) { data.add(element); } }); data.sort((a, b) { String aT = PinyinHelper.getShortPinyin(a.shopName); String bT = PinyinHelper.getShortPinyin(b.shopName); return aT.compareTo(bT); }); setState(() {}); }, (error) {}); } }