query_gang_page.dart 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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_tools.dart';
  10. import 'package:bbyyy/my_tools/my_views.dart';
  11. import 'package:bbyyy/paegs/gang_page/gang_in_page/gang_in_page.dart';
  12. import 'package:flutter/material.dart';
  13. import 'package:flutter/services.dart';
  14. import 'package:pull_to_refresh/pull_to_refresh.dart';
  15. class QueryGangPage extends StatefulWidget {
  16. @override
  17. _QueryGangPageState createState() => _QueryGangPageState();
  18. }
  19. class _QueryGangPageState extends State<QueryGangPage> {
  20. TextEditingController _textEditingController = TextEditingController();
  21. RefreshController _refreshController = RefreshController();
  22. List<MyShopBeanDataData> data = [];
  23. @override
  24. Widget build(BuildContext context) {
  25. return GestureDetector(
  26. onTap: () {
  27. MyTools().hideKeyboard(context);
  28. },
  29. behavior: HitTestBehavior.translucent,
  30. child: Scaffold(
  31. body: Column(
  32. children: [
  33. MyViews().myAppBar('货帮查询', context, []),
  34. Container(
  35. height: 0.5,
  36. color: MyColors.cF0F0F0,
  37. ),
  38. Container(
  39. color: Colors.white,
  40. padding: EdgeInsets.symmetric(horizontal: 16, vertical: 12),
  41. child: Container(
  42. decoration: BoxDecoration(
  43. color: Colors.white,
  44. borderRadius: BorderRadius.circular(20),
  45. border: Border.all(color: Colors.grey, width: 1),
  46. ),
  47. height: 40,
  48. width: double.infinity,
  49. child: Row(
  50. children: [
  51. Expanded(
  52. child: TextField(
  53. controller: _textEditingController,
  54. cursorColor: MyColors.cFF4233,
  55. cursorWidth: 1.0,
  56. onTap: () {},
  57. decoration: InputDecoration(
  58. border: InputBorder.none,
  59. disabledBorder: InputBorder.none,
  60. enabledBorder: InputBorder.none,
  61. focusedBorder: InputBorder.none,
  62. isDense: true,
  63. hintText: '请输入货帮名称',
  64. hintStyle:
  65. TextStyle(color: MyColors.c999999, fontSize: 16),
  66. contentPadding:
  67. const EdgeInsets.fromLTRB(14, 4.5, 8, 4.5),
  68. ),
  69. maxLines: 1,
  70. style: TextStyle(
  71. color: MyColors.c333333,
  72. fontSize: 16,
  73. height: 1.3,
  74. letterSpacing: 0.2),
  75. keyboardType: TextInputType.text,
  76. onChanged: (t) {},
  77. )),
  78. GestureDetector(
  79. onTap: () {
  80. if (_textEditingController.text.isEmpty) {
  81. return;
  82. } else {
  83. _refreshController.requestRefresh();
  84. }
  85. },
  86. behavior: HitTestBehavior.translucent,
  87. child: Container(
  88. decoration: BoxDecoration(
  89. color: MyColors.cFF4233,
  90. borderRadius: BorderRadius.circular(20)),
  91. height: 40,
  92. width: 70,
  93. child: Text(
  94. '搜索',
  95. style: TextStyle(color: Colors.white, fontSize: 14),
  96. ),
  97. alignment: Alignment.center,
  98. ),
  99. )
  100. ],
  101. ),
  102. ),
  103. ),
  104. Expanded(
  105. flex: 1,
  106. child: SmartRefresher(
  107. controller: _refreshController,
  108. onRefresh: onRefresh,
  109. child:data.length == 0
  110. ? SingleChildScrollView(child: noData())
  111. : ListView.builder(
  112. itemBuilder: (BuildContext context, int index) {
  113. return gangItem(context, index);
  114. },
  115. itemCount: data.length,
  116. ),
  117. ),
  118. )
  119. ],
  120. ),
  121. ),
  122. );
  123. }
  124. GestureDetector gangItem(BuildContext context, int index) {
  125. return GestureDetector(
  126. onTap: () {
  127. MyTools().toPage(context, GangInPage(data[index], null), (then) {});
  128. },
  129. behavior: HitTestBehavior.translucent,
  130. child: Container(
  131. height: 73,
  132. child: Column(
  133. children: [
  134. Expanded(
  135. child: Row(
  136. children: [
  137. Container(
  138. margin: EdgeInsets.only(left: 14, right: 14),
  139. child: ClipRRect(
  140. child: MyViews().netImg(
  141. imgURL(data[index].shopPic), 45, 45,
  142. placeholder: 'images/svg/占位图.svg'),
  143. borderRadius: BorderRadius.all(Radius.circular(4)),
  144. ),
  145. ),
  146. Expanded(
  147. child: Container(
  148. height: 45,
  149. padding: EdgeInsets.only(right: 14),
  150. child: Column(
  151. children: [
  152. Row(
  153. children: [
  154. Expanded(
  155. child: Text(
  156. data[index].shopName,
  157. style: TextStyle(
  158. color: MyColors.c333333, fontSize: 15),
  159. )),
  160. Visibility(
  161. child: Container(
  162. decoration: BoxDecoration(
  163. color: MyColors.cFFCD00,
  164. borderRadius: BorderRadius.only(
  165. topLeft: Radius.circular(6),
  166. bottomRight: Radius.circular(6))),
  167. height: 18,
  168. width: 30,
  169. child: Text(
  170. '自建',
  171. style: TextStyle(
  172. color: Colors.white, fontSize: 10),
  173. ),
  174. alignment: Alignment.center,
  175. padding: EdgeInsets.only(bottom: 2),
  176. ),
  177. visible:
  178. data[index].ownerUid == MyCookie().getUID(),
  179. ),
  180. ],
  181. ),
  182. Row(
  183. children: [
  184. Expanded(
  185. child: Text(
  186. 'ID:${data[index].shopUid}',
  187. style: TextStyle(
  188. color: MyColors.c888888, fontSize: 12),
  189. ),
  190. ),
  191. Visibility(
  192. child: Container(
  193. decoration: BoxDecoration(
  194. color: MyColors.cFF4233,
  195. borderRadius: BorderRadius.only(
  196. topLeft: Radius.circular(6),
  197. bottomRight: Radius.circular(6))),
  198. height: 18,
  199. width: 30,
  200. child: Text(
  201. '欠费',
  202. style: TextStyle(
  203. color: Colors.white, fontSize: 10),
  204. ),
  205. alignment: Alignment.center,
  206. padding: EdgeInsets.only(bottom: 2),
  207. ),
  208. visible:
  209. data[index].shopState == shopStateArrearage,
  210. ),
  211. ],
  212. )
  213. ],
  214. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  215. ),
  216. ),
  217. )
  218. ],
  219. ),
  220. ),
  221. Container(
  222. margin: EdgeInsets.only(left: 73, right: 14),
  223. height: 0.5,
  224. color: MyColors.cE7E7E7,
  225. )
  226. ],
  227. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  228. ),
  229. ),
  230. );
  231. }
  232. void onRefresh() {
  233. MyDio().query({
  234. "key": "shop_user",
  235. "filters": {
  236. "conditions": [
  237. "user_uid==${MyCookie().getUID()}",
  238. "review_state==1",
  239. "shop_name LIKE ${_textEditingController.text.toString()}"
  240. ]
  241. },
  242. "dims": shopUserDims,
  243. "paging": [1, 1000],
  244. "order_by": ["shop_name,DESC"]
  245. }, (response, hasError) {
  246. if (!hasError) {
  247. MyShopBeanEntity entity =
  248. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  249. data.clear();
  250. data.addAll(entity.data.data);
  251. setState(() {
  252. _refreshController.refreshCompleted();
  253. });
  254. }
  255. }, (error) {});
  256. }
  257. }