associated_store_page.dart 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. import 'dart:convert';
  2. import 'package:bbyyy/beans/my_shop_bean_entity.dart';
  3. import 'package:bbyyy/https/MyDio.dart';
  4. import 'package:bbyyy/https/url.dart';
  5. import 'package:bbyyy/my_tools/const.dart';
  6. import 'package:bbyyy/my_tools/dims.dart';
  7. import 'package:bbyyy/my_tools/my_colors.dart';
  8. import 'package:bbyyy/my_tools/my_cookie.dart';
  9. import 'package:bbyyy/my_tools/my_views.dart';
  10. import 'package:flutter/material.dart';
  11. import 'package:lpinyin/lpinyin.dart';
  12. class AssociatedStorePage extends StatefulWidget {
  13. @override
  14. _AssociatedStorePageState createState() => _AssociatedStorePageState();
  15. }
  16. class _AssociatedStorePageState extends State<AssociatedStorePage> {
  17. List<MyShopBeanDataData> data = [];
  18. @override
  19. void initState() {
  20. super.initState();
  21. findAStore();
  22. }
  23. @override
  24. Widget build(BuildContext context) {
  25. return Scaffold(
  26. backgroundColor: MyColors.cF7F7F7,
  27. body: Column(
  28. children: [
  29. MyViews().myAppBar('关联货帮', context, []),
  30. Container(height: 10,color: MyColors.cF7F7F7,),
  31. Expanded(
  32. child: ListView.builder(
  33. padding: EdgeInsets.all(0),
  34. itemBuilder: (context, index) {
  35. return GestureDetector(
  36. onTap: (){
  37. Navigator.pop(context,data[index]);
  38. },
  39. behavior: HitTestBehavior.translucent,
  40. child: Container(
  41. height: 73,
  42. color: Colors.white,
  43. child: Column(
  44. children: [
  45. Expanded(
  46. child: Row(
  47. children: [
  48. Container(
  49. margin: EdgeInsets.only(left: 14, right: 14),
  50. child: ClipRRect(
  51. child: MyViews().netImg(
  52. imgURL(data[index].shopPic), 45, 45,
  53. placeholder: 'images/svg/占位图.svg'),
  54. borderRadius:
  55. BorderRadius.all(Radius.circular(4)),
  56. ),
  57. ),
  58. Expanded(
  59. child: Container(
  60. height: 45,
  61. padding: EdgeInsets.only(right: 14),
  62. child: Column(
  63. children: [
  64. Row(
  65. children: [
  66. Expanded(
  67. child: Text(
  68. data[index].shopName,
  69. style: TextStyle(
  70. color: MyColors.c333333,
  71. fontSize: 15),
  72. )),
  73. Visibility(
  74. child: Container(
  75. decoration: BoxDecoration(
  76. color: MyColors.cFFCD00,
  77. borderRadius: BorderRadius.only(
  78. topLeft: Radius.circular(6),
  79. bottomRight:
  80. Radius.circular(6))),
  81. height: 18,
  82. width: 30,
  83. child: Text(
  84. '自建',
  85. style: TextStyle(
  86. color: Colors.white,
  87. fontSize: 10),
  88. ),
  89. alignment: Alignment.center,
  90. padding: EdgeInsets.only(bottom: 2),
  91. ),
  92. visible:
  93. data[index].role == shopUserOwner,
  94. ),
  95. ],
  96. ),
  97. Row(
  98. children: [
  99. Expanded(
  100. child: Text(
  101. 'ID:${data[index].shopUid}',
  102. style: TextStyle(
  103. color: MyColors.c888888,
  104. fontSize: 12),
  105. ),
  106. ),
  107. Visibility(
  108. child: Container(
  109. decoration: BoxDecoration(
  110. color: MyColors.cFF4233,
  111. borderRadius: BorderRadius.only(
  112. topLeft: Radius.circular(6),
  113. bottomRight:
  114. Radius.circular(6))),
  115. height: 18,
  116. width: 30,
  117. child: Text(
  118. '欠费',
  119. style: TextStyle(
  120. color: Colors.white,
  121. fontSize: 10),
  122. ),
  123. alignment: Alignment.center,
  124. padding: EdgeInsets.only(bottom: 2),
  125. ),
  126. visible: data[index].shopState ==
  127. shopStateArrearage,
  128. ),
  129. ],
  130. )
  131. ],
  132. mainAxisAlignment:
  133. MainAxisAlignment.spaceBetween,
  134. ),
  135. ),
  136. )
  137. ],
  138. ),
  139. ),
  140. Container(
  141. margin: EdgeInsets.only(left: 73, right: 14),
  142. height: 0.5,
  143. color: MyColors.cE7E7E7,
  144. )
  145. ],
  146. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  147. ),
  148. ),
  149. );
  150. },
  151. itemCount: data.length,
  152. ),
  153. ),
  154. ],
  155. ),
  156. );
  157. }
  158. void findAStore() {
  159. MyDio().query({
  160. "key": "shop_user",
  161. "filters": {
  162. "or": true,
  163. "conditions": [
  164. "role!=$shopUserOwner",
  165. "user_uid==${MyCookie().getUID()}",
  166. "review_state==1"
  167. ],
  168. "filters": [
  169. {
  170. "conditions": [
  171. "role==$shopUserOwner",
  172. "user_uid==${MyCookie().getUID()}"
  173. ]
  174. }
  175. ]
  176. },
  177. "dims": shopUserDims,
  178. "paging": [1, 5000],
  179. "order_by": ["shop_name,DESC"]
  180. }, (response, hasError) {
  181. MyShopBeanEntity entity =
  182. MyShopBeanEntity.fromJson(json.decode(response.data.toString()));
  183. data.clear();
  184. entity.data.data.forEach((element) {
  185. //自己创建的店铺,允许顾客间交易的私有店铺
  186. if (element.ownerUid == MyCookie().getUID()) {
  187. data.add(element);
  188. } else if (element.privateShop && element.innerTrade) {
  189. data.add(element);
  190. }
  191. });
  192. data.sort((a, b) {
  193. String aT = PinyinHelper.getShortPinyin(a.shopName);
  194. String bT = PinyinHelper.getShortPinyin(b.shopName);
  195. return aT.compareTo(bT);
  196. });
  197. setState(() {});
  198. }, (error) {});
  199. }
  200. }