Showing
14 changed files
with
712 additions
and
139 deletions
| @@ -8,6 +8,14 @@ enum PageState { | @@ -8,6 +8,14 @@ enum PageState { | ||
| 8 | Empty, //空页面 | 8 | Empty, //空页面 |
| 9 | NoPermission, //没有权限 | 9 | NoPermission, //没有权限 |
| 10 | First, | 10 | First, |
| 11 | - Statics,//统计页 | 11 | + Statics, //统计页 |
| 12 | Success //成功 | 12 | Success //成功 |
| 13 | } | 13 | } |
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * 来自那个页面 | ||
| 17 | + */ | ||
| 18 | +enum FromPage { | ||
| 19 | + FromPageMyCustomer, //我的客情 | ||
| 20 | + FromPageStoreCustomer, //全店客情 | ||
| 21 | +} |
lib/models/customer_list_model.dart
0 → 100644
| 1 | +import 'package:azlistview/azlistview.dart'; | ||
| 2 | +import 'package:json_annotation/json_annotation.dart'; | ||
| 3 | + | ||
| 4 | +part 'customer_list_model.g.dart'; | ||
| 5 | + | ||
| 6 | +@JsonSerializable() | ||
| 7 | +class CustomerListModel extends Object { | ||
| 8 | + @JsonKey(name: 'ret') | ||
| 9 | + int ret; | ||
| 10 | + | ||
| 11 | + @JsonKey(name: 'data') | ||
| 12 | + List<CustomerListSunModel> data; | ||
| 13 | + | ||
| 14 | + @JsonKey(name: 'msg') | ||
| 15 | + String msg; | ||
| 16 | + | ||
| 17 | + CustomerListModel( | ||
| 18 | + this.ret, | ||
| 19 | + this.data, | ||
| 20 | + this.msg, | ||
| 21 | + ); | ||
| 22 | + | ||
| 23 | + factory CustomerListModel.fromJson(Map<String, dynamic> srcJson) => | ||
| 24 | + _$CustomerListModelFromJson(srcJson); | ||
| 25 | + | ||
| 26 | + Map<String, dynamic> toJson() => _$CustomerListModelToJson(this); | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +@JsonSerializable() | ||
| 30 | +class CustomerListSunModel extends Object with ISuspensionBean { | ||
| 31 | + @JsonKey(name: 'id') | ||
| 32 | + String id; | ||
| 33 | + | ||
| 34 | + @JsonKey(name: 'sellerid') | ||
| 35 | + String sellerid; | ||
| 36 | + | ||
| 37 | + @JsonKey(name: 'uid') | ||
| 38 | + String uid; | ||
| 39 | + | ||
| 40 | + @JsonKey(name: 'rname') | ||
| 41 | + String rname; | ||
| 42 | + | ||
| 43 | + @JsonKey(name: 'sex') | ||
| 44 | + String sex; | ||
| 45 | + | ||
| 46 | + @JsonKey(name: 'phone') | ||
| 47 | + String phone; | ||
| 48 | + | ||
| 49 | + @JsonKey(name: 'cdate') | ||
| 50 | + String cdate; | ||
| 51 | + | ||
| 52 | + @JsonKey(name: 'leiji') | ||
| 53 | + String leiji; | ||
| 54 | + | ||
| 55 | + @JsonKey(name: 'attr') | ||
| 56 | + String attr; | ||
| 57 | + | ||
| 58 | + @JsonKey(name: 'ddate') | ||
| 59 | + String ddate; | ||
| 60 | + | ||
| 61 | + @JsonKey(name: 'ddate_solt') | ||
| 62 | + String ddateSolt; | ||
| 63 | + | ||
| 64 | + @JsonKey(name: 'company') | ||
| 65 | + String company; | ||
| 66 | + | ||
| 67 | + @JsonKey(name: 'section') | ||
| 68 | + String section; | ||
| 69 | + | ||
| 70 | + @JsonKey(name: 'position') | ||
| 71 | + String position; | ||
| 72 | + @JsonKey(name: 'taboos') | ||
| 73 | + String taboos; | ||
| 74 | + @JsonKey(name: 'like') | ||
| 75 | + String like; | ||
| 76 | + @JsonKey(name: 'serve') | ||
| 77 | + String serve; | ||
| 78 | + @JsonKey(name: 'c_day') | ||
| 79 | + String cDay; | ||
| 80 | + @JsonKey(name: 'udate') | ||
| 81 | + String udate; | ||
| 82 | + @JsonKey(name: 'month_count') | ||
| 83 | + String monthCount; | ||
| 84 | + @JsonKey(name: 'label') | ||
| 85 | + String label; | ||
| 86 | + | ||
| 87 | + List<String> pinyinList; //全拼数组 | ||
| 88 | + String pinyin; //全拼字母 | ||
| 89 | + String pinyinFirst; //首字母 | ||
| 90 | + String tagIndex; //abcdefg | ||
| 91 | + String get rnameStr { | ||
| 92 | + if (rname == null || rname == '') return ""; | ||
| 93 | + return rname; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + String get sexStr { | ||
| 97 | + if (sex == null || sex == '') return ""; | ||
| 98 | + switch (sex.toString()) { | ||
| 99 | + case "1": //先生 | ||
| 100 | + case "男": | ||
| 101 | + case "先生": | ||
| 102 | + return "先生"; | ||
| 103 | + case "2": //女士 | ||
| 104 | + case "女": | ||
| 105 | + case "女士": | ||
| 106 | + return "女士"; | ||
| 107 | + case "3": //公司 | ||
| 108 | + case "公司": | ||
| 109 | + return "公司"; | ||
| 110 | + } | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + CustomerListSunModel( | ||
| 114 | + this.id, | ||
| 115 | + this.sellerid, | ||
| 116 | + this.uid, | ||
| 117 | + this.rname, | ||
| 118 | + this.sex, | ||
| 119 | + this.phone, | ||
| 120 | + this.cdate, | ||
| 121 | + this.leiji, | ||
| 122 | + this.attr, | ||
| 123 | + this.ddate, | ||
| 124 | + this.ddateSolt, | ||
| 125 | + this.company, | ||
| 126 | + this.section, | ||
| 127 | + this.position, | ||
| 128 | + this.taboos, | ||
| 129 | + this.like, | ||
| 130 | + this.serve, | ||
| 131 | + this.cDay, | ||
| 132 | + this.udate, | ||
| 133 | + this.monthCount, | ||
| 134 | + this.label); | ||
| 135 | + | ||
| 136 | + factory CustomerListSunModel.fromJson(Map<String, dynamic> srcJson) => | ||
| 137 | + _$CustomerListSunModelFromJson(srcJson); | ||
| 138 | + | ||
| 139 | + Map<String, dynamic> toJson() => _$CustomerListSunModelToJson(this); | ||
| 140 | + | ||
| 141 | + @override | ||
| 142 | + String getSuspensionTag() => tagIndex; | ||
| 143 | +} |
lib/models/customer_list_model.g.dart
0 → 100644
| 1 | +// GENERATED CODE - DO NOT MODIFY BY HAND | ||
| 2 | + | ||
| 3 | +part of 'customer_list_model.dart'; | ||
| 4 | + | ||
| 5 | +// ************************************************************************** | ||
| 6 | +// JsonSerializableGenerator | ||
| 7 | +// ************************************************************************** | ||
| 8 | + | ||
| 9 | +CustomerListModel _$CustomerListModelFromJson(Map<String, dynamic> json) { | ||
| 10 | + return CustomerListModel( | ||
| 11 | + json['ret'] as int, | ||
| 12 | + (json['data'] as List) | ||
| 13 | + ?.map((e) => e == null | ||
| 14 | + ? null | ||
| 15 | + : CustomerListSunModel.fromJson(e as Map<String, dynamic>)) | ||
| 16 | + ?.toList(), | ||
| 17 | + json['msg'] as String, | ||
| 18 | + ); | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +Map<String, dynamic> _$CustomerListModelToJson(CustomerListModel instance) => | ||
| 22 | + <String, dynamic>{ | ||
| 23 | + 'ret': instance.ret, | ||
| 24 | + 'data': instance.data, | ||
| 25 | + 'msg': instance.msg, | ||
| 26 | + }; | ||
| 27 | + | ||
| 28 | +CustomerListSunModel _$CustomerListSunModelFromJson(Map<String, dynamic> json) { | ||
| 29 | + return CustomerListSunModel( | ||
| 30 | + json['id'] as String, | ||
| 31 | + json['sellerid'] as String, | ||
| 32 | + json['uid'] as String, | ||
| 33 | + json['rname'] as String, | ||
| 34 | + json['sex'] as String, | ||
| 35 | + json['phone'] as String, | ||
| 36 | + json['cdate'] as String, | ||
| 37 | + json['leiji'] as String, | ||
| 38 | + json['attr'] as String, | ||
| 39 | + json['ddate'] as String, | ||
| 40 | + json['ddate_solt'] as String, | ||
| 41 | + json['company'] as String, | ||
| 42 | + json['section'] as String, | ||
| 43 | + json['position'] as String, | ||
| 44 | + json['taboos'] as String, | ||
| 45 | + json['like'] as String, | ||
| 46 | + json['serve'] as String, | ||
| 47 | + json['c_day'] as String, | ||
| 48 | + json['udate'] as String, | ||
| 49 | + json['month_count'] as String, | ||
| 50 | + json['label'] as String, | ||
| 51 | + ); | ||
| 52 | +} | ||
| 53 | + | ||
| 54 | +Map<String, dynamic> _$CustomerListSunModelToJson( | ||
| 55 | + CustomerListSunModel instance) => | ||
| 56 | + <String, dynamic>{ | ||
| 57 | + 'id': instance.id, | ||
| 58 | + 'sellerid': instance.sellerid, | ||
| 59 | + 'uid': instance.uid, | ||
| 60 | + 'rname': instance.rname, | ||
| 61 | + 'sex': instance.sex, | ||
| 62 | + 'phone': instance.phone, | ||
| 63 | + 'cdate': instance.cdate, | ||
| 64 | + 'leiji': instance.leiji, | ||
| 65 | + 'attr': instance.attr, | ||
| 66 | + 'ddate': instance.ddate, | ||
| 67 | + 'ddate_solt': instance.ddateSolt, | ||
| 68 | + 'company': instance.company, | ||
| 69 | + 'section': instance.section, | ||
| 70 | + 'position': instance.position, | ||
| 71 | + 'taboos': instance.taboos, | ||
| 72 | + 'like': instance.like, | ||
| 73 | + 'serve': instance.serve, | ||
| 74 | + 'c_day': instance.cDay, | ||
| 75 | + 'udate': instance.udate, | ||
| 76 | + 'month_count': instance.monthCount, | ||
| 77 | + 'label': instance.label | ||
| 78 | + }; |
| @@ -172,4 +172,7 @@ class HttpUrl { | @@ -172,4 +172,7 @@ class HttpUrl { | ||
| 172 | static const String guest_manage = | 172 | static const String guest_manage = |
| 173 | "?service=App.GuestManage.GuestManage"; //我的客户首页 | 173 | "?service=App.GuestManage.GuestManage"; //我的客户首页 |
| 174 | 174 | ||
| 175 | + static const String get_customer_list = | ||
| 176 | + "?service=App.GuestManage.GetCustomerList"; //用来获取客户列表 | ||
| 177 | + | ||
| 175 | } | 178 | } |
| 1 | import 'package:azlistview/azlistview.dart'; | 1 | import 'package:azlistview/azlistview.dart'; |
| 2 | import 'package:flutter/material.dart'; | 2 | import 'package:flutter/material.dart'; |
| 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 4 | +import 'package:one_key/constant/state.dart'; | ||
| 5 | +import 'package:one_key/models/customer_list_model.dart'; | ||
| 4 | 6 | ||
| 5 | import 'package:one_key/models/user_history_entity.dart'; | 7 | import 'package:one_key/models/user_history_entity.dart'; |
| 6 | import 'package:one_key/provider/customer_provider.dart'; | 8 | import 'package:one_key/provider/customer_provider.dart'; |
| @@ -11,10 +13,11 @@ import 'package:one_key/widgets/h_empty_view.dart'; | @@ -11,10 +13,11 @@ import 'package:one_key/widgets/h_empty_view.dart'; | ||
| 11 | import 'package:one_key/widgets/v_empty_view.dart'; | 13 | import 'package:one_key/widgets/v_empty_view.dart'; |
| 12 | 14 | ||
| 13 | class ContactListPage extends StatefulWidget { | 15 | class ContactListPage extends StatefulWidget { |
| 14 | - final List<UserHistoryEntity> contacts; | 16 | + final List<CustomerListSunModel> contacts; |
| 15 | final CustomerProvider provider; | 17 | final CustomerProvider provider; |
| 18 | + final FromPage fromPage; | ||
| 16 | 19 | ||
| 17 | - const ContactListPage({Key key, this.contacts, this.provider}) | 20 | + const ContactListPage({Key key, this.contacts, this.provider, this.fromPage}) |
| 18 | : super(key: key); | 21 | : super(key: key); |
| 19 | @override | 22 | @override |
| 20 | State<StatefulWidget> createState() { | 23 | State<StatefulWidget> createState() { |
| @@ -86,8 +89,9 @@ class _ContactListPageState extends State<ContactListPage> { | @@ -86,8 +89,9 @@ class _ContactListPageState extends State<ContactListPage> { | ||
| 86 | ); | 89 | ); |
| 87 | } | 90 | } |
| 88 | 91 | ||
| 89 | - Widget _buildListItem(UserHistoryEntity model) { | 92 | + Widget _buildListItem(CustomerListSunModel model) { |
| 90 | String susTag = model.getSuspensionTag(); | 93 | String susTag = model.getSuspensionTag(); |
| 94 | + | ||
| 91 | return Column( | 95 | return Column( |
| 92 | children: <Widget>[ | 96 | children: <Widget>[ |
| 93 | Offstage( | 97 | Offstage( |
| @@ -143,12 +147,23 @@ class _ContactListPageState extends State<ContactListPage> { | @@ -143,12 +147,23 @@ class _ContactListPageState extends State<ContactListPage> { | ||
| 143 | vertical: ScreenUtil().setWidth(2), | 147 | vertical: ScreenUtil().setWidth(2), |
| 144 | ), | 148 | ), |
| 145 | decoration: BoxDecoration( | 149 | decoration: BoxDecoration( |
| 146 | - color: Color.fromRGBO(223, 33, 81, 1), | 150 | + color: model.attr != null && model.attr != '' |
| 151 | + ? model.attr == '沉睡' | ||
| 152 | + ? Color.fromRGBO(223, 33, 81, 1) | ||
| 153 | + : model.attr == '活跃' | ||
| 154 | + ? Color.fromRGBO(81, 170, 94, 1) | ||
| 155 | + : model.attr == '流失' | ||
| 156 | + ? Color.fromRGBO(109, 101, 248, 1) | ||
| 157 | + : Color.fromRGBO(239, 143, 49, 1) | ||
| 158 | + : Colors.transparent, | ||
| 147 | borderRadius: BorderRadius.circular( | 159 | borderRadius: BorderRadius.circular( |
| 148 | ScreenUtil().setWidth(10), | 160 | ScreenUtil().setWidth(10), |
| 149 | ), | 161 | ), |
| 150 | ), | 162 | ), |
| 151 | - child: Text('沉睡', | 163 | + child: Text( |
| 164 | + model.attr == null || model.attr == '' | ||
| 165 | + ? '' | ||
| 166 | + : model.attr, | ||
| 152 | style: TextStyle( | 167 | style: TextStyle( |
| 153 | color: MyColours.color_ffffff, | 168 | color: MyColours.color_ffffff, |
| 154 | fontSize: ScreenUtil().setSp(28))))) | 169 | fontSize: ScreenUtil().setSp(28))))) |
| @@ -162,45 +177,88 @@ class _ContactListPageState extends State<ContactListPage> { | @@ -162,45 +177,88 @@ class _ContactListPageState extends State<ContactListPage> { | ||
| 162 | Row( | 177 | Row( |
| 163 | crossAxisAlignment: CrossAxisAlignment.end, | 178 | crossAxisAlignment: CrossAxisAlignment.end, |
| 164 | children: [ | 179 | children: [ |
| 165 | - Container( | ||
| 166 | - constraints: BoxConstraints( | ||
| 167 | - maxWidth: ScreenUtil().setWidth(200)), | ||
| 168 | - child: Text( | ||
| 169 | - model.rnameStr, | ||
| 170 | - overflow: TextOverflow.ellipsis, | ||
| 171 | - style: TextStyle( | ||
| 172 | - color: MyColours.color_333333, | ||
| 173 | - fontSize: ScreenUtil().setSp(36), | ||
| 174 | - fontWeight: FontWeight.bold), | ||
| 175 | - )), | ||
| 176 | - HEmptyView(10), | ||
| 177 | - Text( | ||
| 178 | - model.sexStr != '' ? '[${model.sexStr}]' : '', | ||
| 179 | - style: TextStyle( | ||
| 180 | - color: MyColours.color_333333, | ||
| 181 | - fontSize: ScreenUtil().setSp(22), | ||
| 182 | - ), | ||
| 183 | - ), | ||
| 184 | - HEmptyView(10), | ||
| 185 | - Container( | ||
| 186 | - constraints: BoxConstraints( | ||
| 187 | - maxWidth: ScreenUtil().setWidth(150)), | ||
| 188 | - child: Text( | ||
| 189 | - '低频高消费', | ||
| 190 | - overflow: TextOverflow.ellipsis, | ||
| 191 | - style: TextStyle( | ||
| 192 | - color: Color.fromRGBO(193, 194, 63, 1), | ||
| 193 | - fontSize: ScreenUtil().setSp(22), | ||
| 194 | - ), | ||
| 195 | - )) | 180 | + model.rnameStr != null && model.rnameStr != '' |
| 181 | + ? Row( | ||
| 182 | + children: [ | ||
| 183 | + Container( | ||
| 184 | + constraints: BoxConstraints( | ||
| 185 | + maxWidth: ScreenUtil().setWidth(200)), | ||
| 186 | + child: Text( | ||
| 187 | + model.rnameStr, | ||
| 188 | + overflow: TextOverflow.ellipsis, | ||
| 189 | + style: TextStyle( | ||
| 190 | + color: MyColours.color_333333, | ||
| 191 | + fontSize: ScreenUtil().setSp(36), | ||
| 192 | + fontWeight: FontWeight.bold), | ||
| 193 | + )), | ||
| 194 | + HEmptyView(10), | ||
| 195 | + Text( | ||
| 196 | + model.sexStr != '' ? '[${model.sexStr}]' : '', | ||
| 197 | + style: TextStyle( | ||
| 198 | + color: MyColours.color_333333, | ||
| 199 | + fontSize: ScreenUtil().setSp(22), | ||
| 200 | + ), | ||
| 201 | + ), | ||
| 202 | + HEmptyView(10), | ||
| 203 | + ], | ||
| 204 | + ) | ||
| 205 | + : SizedBox(), | ||
| 206 | + model.label != null | ||
| 207 | + ? Container( | ||
| 208 | + constraints: BoxConstraints( | ||
| 209 | + maxWidth: ScreenUtil().setWidth(150)), | ||
| 210 | + child: Text( | ||
| 211 | + model.label, | ||
| 212 | + overflow: TextOverflow.ellipsis, | ||
| 213 | + style: TextStyle( | ||
| 214 | + color: Color.fromRGBO(193, 194, 63, 1), | ||
| 215 | + fontSize: ScreenUtil().setSp(22), | ||
| 216 | + ), | ||
| 217 | + )) | ||
| 218 | + : SizedBox() | ||
| 196 | ], | 219 | ], |
| 197 | ), | 220 | ), |
| 198 | VEmptyView(10), | 221 | VEmptyView(10), |
| 222 | + widget.fromPage == FromPage.FromPageMyCustomer && | ||
| 223 | + ((model.company != null && model.company != '') || | ||
| 224 | + (model.phone != null && model.phone != '')) | ||
| 225 | + ? Padding( | ||
| 226 | + padding: EdgeInsets.only( | ||
| 227 | + bottom: ScreenUtil().setWidth(10)), | ||
| 228 | + child: Row( | ||
| 229 | + crossAxisAlignment: CrossAxisAlignment.end, | ||
| 230 | + children: [ | ||
| 231 | + model.company != null && model.company != '' | ||
| 232 | + ? Container( | ||
| 233 | + padding: EdgeInsets.only( | ||
| 234 | + right: ScreenUtil().setWidth(10)), | ||
| 235 | + constraints: BoxConstraints( | ||
| 236 | + maxWidth: ScreenUtil().setWidth(200)), | ||
| 237 | + child: Text( | ||
| 238 | + '[${model.company}]', | ||
| 239 | + overflow: TextOverflow.ellipsis, | ||
| 240 | + style: TextStyle( | ||
| 241 | + color: MyColours.color_999999, | ||
| 242 | + fontSize: ScreenUtil().setSp(30)), | ||
| 243 | + )) | ||
| 244 | + : SizedBox(), | ||
| 245 | + model.phone != null && model.phone != '' | ||
| 246 | + ? Text( | ||
| 247 | + model.phone, | ||
| 248 | + overflow: TextOverflow.ellipsis, | ||
| 249 | + style: TextStyle( | ||
| 250 | + color: MyColours.color_999999, | ||
| 251 | + fontSize: ScreenUtil().setSp(30)), | ||
| 252 | + ) | ||
| 253 | + : SizedBox(), | ||
| 254 | + ], | ||
| 255 | + )) | ||
| 256 | + : SizedBox(), | ||
| 199 | Row( | 257 | Row( |
| 200 | // crossAxisAlignment: CrossAxisAlignment.end, | 258 | // crossAxisAlignment: CrossAxisAlignment.end, |
| 201 | children: [ | 259 | children: [ |
| 202 | Text( | 260 | Text( |
| 203 | - '28天前', | 261 | + Utils.format(model.ddate), |
| 204 | style: TextStyle( | 262 | style: TextStyle( |
| 205 | color: Color.fromRGBO(208, 31, 37, 1), | 263 | color: Color.fromRGBO(208, 31, 37, 1), |
| 206 | fontSize: ScreenUtil().setSp(24), | 264 | fontSize: ScreenUtil().setSp(24), |
| @@ -208,15 +266,28 @@ class _ContactListPageState extends State<ContactListPage> { | @@ -208,15 +266,28 @@ class _ContactListPageState extends State<ContactListPage> { | ||
| 208 | ), | 266 | ), |
| 209 | HEmptyView(10), | 267 | HEmptyView(10), |
| 210 | Text( | 268 | Text( |
| 211 | - '午餐', | 269 | + model.ddateSolt != null ? model.ddateSolt : '', |
| 212 | style: TextStyle( | 270 | style: TextStyle( |
| 213 | color: Color.fromRGBO(208, 31, 37, 1), | 271 | color: Color.fromRGBO(208, 31, 37, 1), |
| 214 | fontSize: ScreenUtil().setSp(24), | 272 | fontSize: ScreenUtil().setSp(24), |
| 215 | ), | 273 | ), |
| 216 | ), | 274 | ), |
| 275 | + model.monthCount == '0' || model.monthCount == null | ||
| 276 | + ? SizedBox() | ||
| 277 | + : Padding( | ||
| 278 | + padding: EdgeInsets.only( | ||
| 279 | + left: ScreenUtil().setWidth(10)), | ||
| 280 | + child: Text( | ||
| 281 | + '30天内${model.monthCount}单', | ||
| 282 | + style: TextStyle( | ||
| 283 | + color: MyColours.color_199095, | ||
| 284 | + fontSize: ScreenUtil().setSp(24), | ||
| 285 | + ), | ||
| 286 | + ), | ||
| 287 | + ), | ||
| 217 | HEmptyView(10), | 288 | HEmptyView(10), |
| 218 | Text( | 289 | Text( |
| 219 | - '累计80单', | 290 | + '累计${model.leiji}单', |
| 220 | style: TextStyle( | 291 | style: TextStyle( |
| 221 | color: MyColours.color_199095, | 292 | color: MyColours.color_199095, |
| 222 | fontSize: ScreenUtil().setSp(24), | 293 | fontSize: ScreenUtil().setSp(24), |
| @@ -224,24 +295,27 @@ class _ContactListPageState extends State<ContactListPage> { | @@ -224,24 +295,27 @@ class _ContactListPageState extends State<ContactListPage> { | ||
| 224 | ) | 295 | ) |
| 225 | ], | 296 | ], |
| 226 | ), | 297 | ), |
| 227 | - VEmptyView(10), | ||
| 228 | - Container( | ||
| 229 | - padding: EdgeInsets.symmetric( | ||
| 230 | - horizontal: ScreenUtil().setWidth(12), | ||
| 231 | - ), | ||
| 232 | - decoration: BoxDecoration( | ||
| 233 | - border: Border.all( | ||
| 234 | - color: MyColours.color_199095, | ||
| 235 | - width: ScreenUtil().setWidth(2)), | ||
| 236 | - borderRadius: | ||
| 237 | - BorderRadius.circular(ScreenUtil().setWidth(10))), | ||
| 238 | - child: Text( | ||
| 239 | - 'xx经理', | ||
| 240 | - style: TextStyle( | ||
| 241 | - fontSize: ScreenUtil().setSp(24), | ||
| 242 | - color: MyColours.color_333333), | ||
| 243 | - ), | ||
| 244 | - ) | 298 | + widget.fromPage == FromPage.FromPageStoreCustomer |
| 299 | + ? Container( | ||
| 300 | + padding: EdgeInsets.only( | ||
| 301 | + left: ScreenUtil().setWidth(12), | ||
| 302 | + right: ScreenUtil().setWidth(12), | ||
| 303 | + top: ScreenUtil().setWidth(10), | ||
| 304 | + ), | ||
| 305 | + decoration: BoxDecoration( | ||
| 306 | + border: Border.all( | ||
| 307 | + color: MyColours.color_199095, | ||
| 308 | + width: ScreenUtil().setWidth(2)), | ||
| 309 | + borderRadius: BorderRadius.circular( | ||
| 310 | + ScreenUtil().setWidth(10))), | ||
| 311 | + child: Text( | ||
| 312 | + 'xx经理', | ||
| 313 | + style: TextStyle( | ||
| 314 | + fontSize: ScreenUtil().setSp(24), | ||
| 315 | + color: MyColours.color_333333), | ||
| 316 | + ), | ||
| 317 | + ) | ||
| 318 | + : SizedBox() | ||
| 245 | ], | 319 | ], |
| 246 | )) | 320 | )) |
| 247 | ], | 321 | ], |
| @@ -273,7 +347,7 @@ class _ContactListPageState extends State<ContactListPage> { | @@ -273,7 +347,7 @@ class _ContactListPageState extends State<ContactListPage> { | ||
| 273 | itemCount: widget.contacts.length, | 347 | itemCount: widget.contacts.length, |
| 274 | itemBuilder: (BuildContext context, int index) { | 348 | itemBuilder: (BuildContext context, int index) { |
| 275 | // if (index == 0) return _buildHeader(); | 349 | // if (index == 0) return _buildHeader(); |
| 276 | - UserHistoryEntity model = widget.contacts[index]; | 350 | + CustomerListSunModel model = widget.contacts[index]; |
| 277 | return InkWell( | 351 | return InkWell( |
| 278 | onTap: () { | 352 | onTap: () { |
| 279 | NavigatorUtil.goCustomerDetailPage(context, model); | 353 | NavigatorUtil.goCustomerDetailPage(context, model); |
| 1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
| 2 | import 'package:flutter_screenutil/screenutil.dart'; | 2 | import 'package:flutter_screenutil/screenutil.dart'; |
| 3 | +import 'package:one_key/models/customer_list_model.dart'; | ||
| 3 | import 'package:one_key/models/user_history_entity.dart'; | 4 | import 'package:one_key/models/user_history_entity.dart'; |
| 4 | import 'package:one_key/res/colors.dart'; | 5 | import 'package:one_key/res/colors.dart'; |
| 5 | import 'package:one_key/route/navigator_util.dart'; | 6 | import 'package:one_key/route/navigator_util.dart'; |
| @@ -11,7 +12,7 @@ import 'package:one_key/widgets/system_app_bar.dart'; | @@ -11,7 +12,7 @@ import 'package:one_key/widgets/system_app_bar.dart'; | ||
| 11 | import 'package:one_key/widgets/v_empty_view.dart'; | 12 | import 'package:one_key/widgets/v_empty_view.dart'; |
| 12 | 13 | ||
| 13 | class CustomerDetailPage extends StatefulWidget { | 14 | class CustomerDetailPage extends StatefulWidget { |
| 14 | - final UserHistoryEntity userHistoryEntity; | 15 | + final CustomerListSunModel userHistoryEntity; |
| 15 | CustomerDetailPage({Key key, this.userHistoryEntity}) : super(key: key); | 16 | CustomerDetailPage({Key key, this.userHistoryEntity}) : super(key: key); |
| 16 | 17 | ||
| 17 | @override | 18 | @override |
| @@ -26,6 +26,9 @@ import 'package:provider/provider.dart'; | @@ -26,6 +26,9 @@ import 'package:provider/provider.dart'; | ||
| 26 | typedef ClickCallback = void Function(dynamic value); | 26 | typedef ClickCallback = void Function(dynamic value); |
| 27 | 27 | ||
| 28 | class CustomerListPage extends StatefulWidget { | 28 | class CustomerListPage extends StatefulWidget { |
| 29 | + final FromPage fromPage; | ||
| 30 | + | ||
| 31 | + const CustomerListPage({Key key, this.fromPage}) : super(key: key); | ||
| 29 | @override | 32 | @override |
| 30 | _CustomerListPageState createState() => _CustomerListPageState(); | 33 | _CustomerListPageState createState() => _CustomerListPageState(); |
| 31 | } | 34 | } |
| @@ -55,10 +58,10 @@ class _CustomerListPageState extends State<CustomerListPage> | @@ -55,10 +58,10 @@ class _CustomerListPageState extends State<CustomerListPage> | ||
| 55 | 58 | ||
| 56 | _getContantData() async { | 59 | _getContantData() async { |
| 57 | Map<String, String> params = { | 60 | Map<String, String> params = { |
| 58 | - "sid": Provider.of<UserModel>(context, listen: false).user.sellerid, | 61 | + "uid": Provider.of<UserModel>(context, listen: false).user.openid, |
| 59 | }; | 62 | }; |
| 60 | - await customerProvider.getUserHistorys(context, params); | ||
| 61 | - await customerProvider.searchData(customerProvider.controller.text); | 63 | + await customerProvider.getCustomerList(context, params); |
| 64 | + // await customerProvider.searchData(customerProvider.controller.text); | ||
| 62 | } | 65 | } |
| 63 | 66 | ||
| 64 | ///选中的联系人widget | 67 | ///选中的联系人widget |
| @@ -1025,7 +1028,7 @@ class _CustomerListPageState extends State<CustomerListPage> | @@ -1025,7 +1028,7 @@ class _CustomerListPageState extends State<CustomerListPage> | ||
| 1025 | model.notifyListeners(); | 1028 | model.notifyListeners(); |
| 1026 | _getContantData(); | 1029 | _getContantData(); |
| 1027 | }, | 1030 | }, |
| 1028 | - emptyMsg: "暂时没有联系人哦", | 1031 | + emptyMsg: "暂时没有客户哦", |
| 1029 | emptyImg: "empty_search", | 1032 | emptyImg: "empty_search", |
| 1030 | showMsg: "加载中,请稍后...", | 1033 | showMsg: "加载中,请稍后...", |
| 1031 | ); | 1034 | ); |
| @@ -1038,16 +1041,80 @@ class _CustomerListPageState extends State<CustomerListPage> | @@ -1038,16 +1041,80 @@ class _CustomerListPageState extends State<CustomerListPage> | ||
| 1038 | children: <Widget>[ | 1041 | children: <Widget>[ |
| 1039 | ContactListPage( | 1042 | ContactListPage( |
| 1040 | contacts: model.userHistorysShow, | 1043 | contacts: model.userHistorysShow, |
| 1041 | - provider: customerProvider), | ||
| 1042 | - ContactListPage( | ||
| 1043 | - contacts: model.userHistorysShow, | ||
| 1044 | - provider: customerProvider), | ||
| 1045 | - ContactListPage( | ||
| 1046 | - contacts: model.userHistorysShow, | ||
| 1047 | - provider: customerProvider), | ||
| 1048 | - ContactListPage( | ||
| 1049 | - contacts: model.userHistorysShow, | ||
| 1050 | - provider: customerProvider), | 1044 | + provider: customerProvider, |
| 1045 | + fromPage: widget.fromPage), | ||
| 1046 | + Consumer<CustomerProvider>( | ||
| 1047 | + builder: (context, model, _) { | ||
| 1048 | + if (model.pageStateHuoyue != PageState.Success) { | ||
| 1049 | + return ExceptionPage( | ||
| 1050 | + pageState: model.pageStateHuoyue, | ||
| 1051 | + callback: () { | ||
| 1052 | + model.pageStateHuoyue = PageState.Loading; | ||
| 1053 | + model.notifyListeners(); | ||
| 1054 | + _getContantData(); | ||
| 1055 | + }, | ||
| 1056 | + emptyMsg: "暂时没有客户哦", | ||
| 1057 | + emptyImg: "empty_search", | ||
| 1058 | + showMsg: "加载中,请稍后...", | ||
| 1059 | + ); | ||
| 1060 | + } else { | ||
| 1061 | + return ContactListPage( | ||
| 1062 | + contacts: model.userHistorysShowHuoyue, | ||
| 1063 | + provider: customerProvider, | ||
| 1064 | + fromPage: widget.fromPage); | ||
| 1065 | + } | ||
| 1066 | + }), | ||
| 1067 | + Consumer<CustomerProvider>( | ||
| 1068 | + builder: (context, model, _) { | ||
| 1069 | + if (model.pageStateChenshui != | ||
| 1070 | + PageState.Success) { | ||
| 1071 | + return ExceptionPage( | ||
| 1072 | + pageState: model.pageStateChenshui, | ||
| 1073 | + callback: () { | ||
| 1074 | + model.pageStateChenshui = PageState.Loading; | ||
| 1075 | + model.notifyListeners(); | ||
| 1076 | + _getContantData(); | ||
| 1077 | + }, | ||
| 1078 | + emptyMsg: "暂时没有客户哦", | ||
| 1079 | + emptyImg: "empty_search", | ||
| 1080 | + showMsg: "加载中,请稍后...", | ||
| 1081 | + ); | ||
| 1082 | + } else { | ||
| 1083 | + return ContactListPage( | ||
| 1084 | + contacts: model.userHistorysShowChenshui, | ||
| 1085 | + provider: customerProvider, | ||
| 1086 | + fromPage: widget.fromPage); | ||
| 1087 | + } | ||
| 1088 | + }), | ||
| 1089 | + Consumer<CustomerProvider>( | ||
| 1090 | + builder: (context, model, _) { | ||
| 1091 | + if (model.pageStateLiushi != PageState.Success) { | ||
| 1092 | + return ExceptionPage( | ||
| 1093 | + pageState: model.pageStateLiushi, | ||
| 1094 | + callback: () { | ||
| 1095 | + model.pageStateLiushi = PageState.Loading; | ||
| 1096 | + model.notifyListeners(); | ||
| 1097 | + _getContantData(); | ||
| 1098 | + }, | ||
| 1099 | + emptyMsg: "暂时没有客户哦", | ||
| 1100 | + emptyImg: "empty_search", | ||
| 1101 | + showMsg: "加载中,请稍后...", | ||
| 1102 | + ); | ||
| 1103 | + } else { | ||
| 1104 | + return ContactListPage( | ||
| 1105 | + contacts: model.userHistorysShowLiushi, | ||
| 1106 | + provider: customerProvider, | ||
| 1107 | + fromPage: widget.fromPage); | ||
| 1108 | + } | ||
| 1109 | + }), | ||
| 1110 | + // ContactListPage( | ||
| 1111 | + // contacts: model.userHistorysShowChenshui, | ||
| 1112 | + // provider: customerProvider, | ||
| 1113 | + // fromPage: widget.fromPage), | ||
| 1114 | + // ContactListPage( | ||
| 1115 | + // contacts: model.userHistorysShowLiushi, | ||
| 1116 | + // provider: customerProvider, | ||
| 1117 | + // fromPage: widget.fromPage), | ||
| 1051 | ])), | 1118 | ])), |
| 1052 | customerProvider.pageState == PageState.Success | 1119 | customerProvider.pageState == PageState.Success |
| 1053 | ? _selectContantWidget() | 1120 | ? _selectContantWidget() |
| @@ -150,7 +150,7 @@ class _MyCustomerPageState extends State<MyCustomerPage> { | @@ -150,7 +150,7 @@ class _MyCustomerPageState extends State<MyCustomerPage> { | ||
| 150 | VEmptyView(10), | 150 | VEmptyView(10), |
| 151 | RoundButton( | 151 | RoundButton( |
| 152 | onPressed: () async { | 152 | onPressed: () async { |
| 153 | - NavigatorUtil.goCustomerListPage(context); | 153 | + NavigatorUtil.goCustomerListPage(context,FromPage.FromPageMyCustomer); |
| 154 | }, | 154 | }, |
| 155 | text: '我的客户', | 155 | text: '我的客户', |
| 156 | fontSize: 24, | 156 | fontSize: 24, |
| 1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
| 2 | import 'package:flutter_screenutil/screenutil.dart'; | 2 | import 'package:flutter_screenutil/screenutil.dart'; |
| 3 | +import 'package:one_key/constant/state.dart'; | ||
| 3 | import 'package:one_key/res/colors.dart'; | 4 | import 'package:one_key/res/colors.dart'; |
| 4 | import 'package:one_key/route/navigator_util.dart'; | 5 | import 'package:one_key/route/navigator_util.dart'; |
| 5 | import 'package:one_key/utils/event_bus.dart'; | 6 | import 'package:one_key/utils/event_bus.dart'; |
| @@ -119,7 +120,8 @@ class _StoreCustomerPageState extends State<StoreCustomerPage> { | @@ -119,7 +120,8 @@ class _StoreCustomerPageState extends State<StoreCustomerPage> { | ||
| 119 | VEmptyView(10), | 120 | VEmptyView(10), |
| 120 | RoundButton( | 121 | RoundButton( |
| 121 | onPressed: () async { | 122 | onPressed: () async { |
| 122 | - NavigatorUtil.goCustomerListPage(context); | 123 | + NavigatorUtil.goCustomerListPage( |
| 124 | + context, FromPage.FromPageStoreCustomer); | ||
| 123 | }, | 125 | }, |
| 124 | text: '全店客户', | 126 | text: '全店客户', |
| 125 | fontSize: 24, | 127 | fontSize: 24, |
| @@ -4,6 +4,7 @@ import 'package:lpinyin/lpinyin.dart'; | @@ -4,6 +4,7 @@ import 'package:lpinyin/lpinyin.dart'; | ||
| 4 | import 'package:one_key/constant/constant.dart'; | 4 | import 'package:one_key/constant/constant.dart'; |
| 5 | import 'package:one_key/constant/error.dart'; | 5 | import 'package:one_key/constant/error.dart'; |
| 6 | import 'package:one_key/constant/state.dart'; | 6 | import 'package:one_key/constant/state.dart'; |
| 7 | +import 'package:one_key/models/customer_list_model.dart'; | ||
| 7 | import 'package:one_key/models/guest_manage_model.dart'; | 8 | import 'package:one_key/models/guest_manage_model.dart'; |
| 8 | import 'package:one_key/models/user_history_entity.dart'; | 9 | import 'package:one_key/models/user_history_entity.dart'; |
| 9 | import 'package:one_key/net/base_resp.dart'; | 10 | import 'package:one_key/net/base_resp.dart'; |
| @@ -16,17 +17,24 @@ import 'package:provider/provider.dart'; | @@ -16,17 +17,24 @@ import 'package:provider/provider.dart'; | ||
| 16 | 17 | ||
| 17 | class CustomerProvider extends ChangeNotifier { | 18 | class CustomerProvider extends ChangeNotifier { |
| 18 | PageState pageState = PageState.Loading; | 19 | PageState pageState = PageState.Loading; |
| 19 | - List<UserHistoryEntity> userHistorys = []; //历史录入(总) | ||
| 20 | - List<UserHistoryEntity> userHistorysShow = []; //历史录入展示 | 20 | + List<CustomerListSunModel> userHistorys = []; //客户列表(总) |
| 21 | + List<CustomerListSunModel> userHistorysShow = []; //全部展示 | ||
| 22 | + List<CustomerListSunModel> userHistorysShowHuoyue = []; //活跃展示 | ||
| 23 | + List<CustomerListSunModel> userHistorysShowChenshui = []; //沉睡展示 | ||
| 24 | + List<CustomerListSunModel> userHistorysShowLiushi = []; //流失展示 | ||
| 25 | + | ||
| 21 | TextEditingController controller = TextEditingController(); //搜索框 | 26 | TextEditingController controller = TextEditingController(); //搜索框 |
| 22 | 27 | ||
| 23 | PageState pageStateMyHome = PageState.Loading; | 28 | PageState pageStateMyHome = PageState.Loading; |
| 29 | + PageState pageStateHuoyue = PageState.Loading; | ||
| 30 | + PageState pageStateChenshui = PageState.Loading; | ||
| 31 | + PageState pageStateLiushi = PageState.Loading; | ||
| 24 | GuestManageSunModel guestSunmodel; | 32 | GuestManageSunModel guestSunmodel; |
| 25 | 33 | ||
| 26 | - //获取历史录入 | ||
| 27 | - getUserHistorys(BuildContext context, Map<String, String> params) async { | 34 | + //用来获取客户列表 |
| 35 | + getCustomerList(BuildContext context, Map<String, String> params) async { | ||
| 28 | BaseResp<List> baseResp = await DioUtil() | 36 | BaseResp<List> baseResp = await DioUtil() |
| 29 | - .request<List>(context, Method.get, HttpUrl.get_reserve_user, | 37 | + .request<List>(context, Method.get, HttpUrl.get_customer_list, |
| 30 | data: params, showLoading: false) | 38 | data: params, showLoading: false) |
| 31 | .catchError((error) { | 39 | .catchError((error) { |
| 32 | print(error.toString()); | 40 | print(error.toString()); |
| @@ -46,14 +54,14 @@ class CustomerProvider extends ChangeNotifier { | @@ -46,14 +54,14 @@ class CustomerProvider extends ChangeNotifier { | ||
| 46 | notifyListeners(); | 54 | notifyListeners(); |
| 47 | }); | 55 | }); |
| 48 | if (baseResp != null && baseResp.code == Constant.status_success) { | 56 | if (baseResp != null && baseResp.code == Constant.status_success) { |
| 49 | - userHistorys = baseResp.data.map<UserHistoryEntity>((value) { | ||
| 50 | - return UserHistoryEntity.fromJson(value); | 57 | + userHistorys = baseResp.data.map<CustomerListSunModel>((value) { |
| 58 | + return CustomerListSunModel.fromJson(value); | ||
| 51 | }).toList(); | 59 | }).toList(); |
| 52 | if (userHistorys.length == 0) { | 60 | if (userHistorys.length == 0) { |
| 53 | pageState = PageState.Empty; | 61 | pageState = PageState.Empty; |
| 54 | } else { | 62 | } else { |
| 55 | for (int i = 0; i < userHistorys.length; i++) { | 63 | for (int i = 0; i < userHistorys.length; i++) { |
| 56 | - UserHistoryEntity item = userHistorys[i]; | 64 | + CustomerListSunModel item = userHistorys[i]; |
| 57 | item.pinyinFirst = ''; | 65 | item.pinyinFirst = ''; |
| 58 | item.pinyinList = []; | 66 | item.pinyinList = []; |
| 59 | item.pinyinList = []; | 67 | item.pinyinList = []; |
| @@ -78,63 +86,154 @@ class CustomerProvider extends ChangeNotifier { | @@ -78,63 +86,154 @@ class CustomerProvider extends ChangeNotifier { | ||
| 78 | 86 | ||
| 79 | userHistorys[i] = item; | 87 | userHistorys[i] = item; |
| 80 | } | 88 | } |
| 81 | - userHistorysShow = userHistorys; | 89 | + userHistorysShow = userHistorys; //全部客户列表信息 |
| 90 | + userHistorysShowHuoyue = []; | ||
| 91 | + userHistorysShowChenshui = []; | ||
| 92 | + userHistorysShowLiushi = []; | ||
| 93 | + for (CustomerListSunModel item in userHistorysShow) { | ||
| 94 | + if (item.attr == '活跃') { | ||
| 95 | + userHistorysShowHuoyue.add(item); | ||
| 96 | + } else if (item.attr == '沉睡') { | ||
| 97 | + userHistorysShowChenshui.add(item); | ||
| 98 | + } else if (item.attr == '流失') { | ||
| 99 | + userHistorysShowLiushi.add(item); | ||
| 100 | + } | ||
| 101 | + } | ||
| 102 | + if (userHistorysShowHuoyue.length > 0) { | ||
| 103 | + pageStateHuoyue = PageState.Success; | ||
| 104 | + } else { | ||
| 105 | + pageStateHuoyue = PageState.Empty; | ||
| 106 | + } | ||
| 107 | + if (userHistorysShowChenshui.length > 0) { | ||
| 108 | + pageStateChenshui = PageState.Success; | ||
| 109 | + } else { | ||
| 110 | + pageStateChenshui = PageState.Empty; | ||
| 111 | + } | ||
| 112 | + if (userHistorysShowLiushi.length > 0) { | ||
| 113 | + pageStateLiushi = PageState.Success; | ||
| 114 | + } else { | ||
| 115 | + pageStateLiushi = PageState.Empty; | ||
| 116 | + } | ||
| 82 | pageState = PageState.Success; | 117 | pageState = PageState.Success; |
| 83 | } | 118 | } |
| 84 | notifyListeners(); | 119 | notifyListeners(); |
| 85 | } | 120 | } |
| 86 | } | 121 | } |
| 87 | 122 | ||
| 123 | + // //获取历史录入 | ||
| 124 | + // getUserHistorys(BuildContext context, Map<String, String> params) async { | ||
| 125 | + // BaseResp<List> baseResp = await DioUtil() | ||
| 126 | + // .request<List>(context, Method.get, HttpUrl.get_reserve_user, | ||
| 127 | + // data: params, showLoading: false) | ||
| 128 | + // .catchError((error) { | ||
| 129 | + // print(error.toString()); | ||
| 130 | + // if (error is MyError) { | ||
| 131 | + // switch (error.type) { | ||
| 132 | + // case 1: | ||
| 133 | + // pageState = PageState.ConnectivityError; | ||
| 134 | + // break; | ||
| 135 | + // case 2: | ||
| 136 | + // pageState = PageState.ConnectivityTimeOut; | ||
| 137 | + // break; | ||
| 138 | + // default: | ||
| 139 | + // pageState = PageState.ConnectivityError; | ||
| 140 | + // break; | ||
| 141 | + // } | ||
| 142 | + // } | ||
| 143 | + // notifyListeners(); | ||
| 144 | + // }); | ||
| 145 | + // if (baseResp != null && baseResp.code == Constant.status_success) { | ||
| 146 | + // userHistorys = baseResp.data.map<UserHistoryEntity>((value) { | ||
| 147 | + // return UserHistoryEntity.fromJson(value); | ||
| 148 | + // }).toList(); | ||
| 149 | + // if (userHistorys.length == 0) { | ||
| 150 | + // pageState = PageState.Empty; | ||
| 151 | + // } else { | ||
| 152 | + // for (int i = 0; i < userHistorys.length; i++) { | ||
| 153 | + // UserHistoryEntity item = userHistorys[i]; | ||
| 154 | + // item.pinyinFirst = ''; | ||
| 155 | + // item.pinyinList = []; | ||
| 156 | + // item.pinyinList = []; | ||
| 157 | + // if (item.rname != null) { | ||
| 158 | + // item.pinyin = | ||
| 159 | + // PinyinHelper.getPinyin(item.rname).replaceAll(' ', ''); | ||
| 160 | + // List<String> pinyinList = | ||
| 161 | + // PinyinHelper.getPinyin(item.rname).split(' '); | ||
| 162 | + | ||
| 163 | + // String pinyinAll = ''; //组装全拼组合 | ||
| 164 | + // for (int j = 0; j < pinyinList.length; j++) { | ||
| 165 | + // String letter = pinyinList[j]; | ||
| 166 | + // pinyinAll += pinyinList[j]; | ||
| 167 | + // item.pinyinList.add(pinyinAll); | ||
| 168 | + // if (letter.length > 0) { | ||
| 169 | + // item.pinyinFirst += pinyinList[j].substring(0, 1); | ||
| 170 | + // } else { | ||
| 171 | + // item.pinyinFirst += ''; | ||
| 172 | + // } | ||
| 173 | + // } | ||
| 174 | + // } | ||
| 175 | + | ||
| 176 | + // userHistorys[i] = item; | ||
| 177 | + // } | ||
| 178 | + // userHistorysShow = userHistorys; | ||
| 179 | + // pageState = PageState.Success; | ||
| 180 | + // } | ||
| 181 | + // notifyListeners(); | ||
| 182 | + // } | ||
| 183 | + // } | ||
| 184 | + | ||
| 88 | searchData(String key) { | 185 | searchData(String key) { |
| 89 | - if (key == '') { | ||
| 90 | - userHistorysShow = userHistorys; | ||
| 91 | - pageState = PageState.Success; | ||
| 92 | - } else { | ||
| 93 | - userHistorysShow = []; | ||
| 94 | - | ||
| 95 | - for (int i = 0; i < userHistorys.length; i++) { | ||
| 96 | - String name = userHistorys[i].rname; | ||
| 97 | - String pinyinFirst = userHistorys[i].pinyinFirst; | ||
| 98 | - // String pinyin = userHistorys[i].pinyin; | ||
| 99 | - String phone = userHistorys[i].phone; | ||
| 100 | - List<String> pinyinList = userHistorys[i].pinyinList; | ||
| 101 | - if ((name != null && name.contains(key)) || | ||
| 102 | - (pinyinFirst != null && pinyinFirst.contains(key)) || | ||
| 103 | - (phone != null && phone.contains(key)) || | ||
| 104 | - (pinyinList != null && pinyinList.contains(key))) { | ||
| 105 | - userHistorysShow.add(userHistorys[i]); | ||
| 106 | - } | ||
| 107 | - } | ||
| 108 | - // for (int i = 0; i < contacts.length; i++) { | ||
| 109 | - // String name = contacts[i].rname; | ||
| 110 | - // String pinyinFirst = contacts[i].pinyinFirst; | ||
| 111 | - // List<String> pinyinList = contacts[i].pinyinList; | ||
| 112 | - // // String pinyin = contacts[i].pinyin; | ||
| 113 | - // String phone = contacts[i].phone; | ||
| 114 | - // if ((name != null && name.contains(key)) || | ||
| 115 | - // (pinyinFirst != null && pinyinFirst.contains(key)) || | ||
| 116 | - // (phone != null && phone.contains(key)) || | ||
| 117 | - // (pinyinList != null && pinyinList.contains(key))) { | ||
| 118 | - // contactsShow.add(contacts[i]); | ||
| 119 | - // } | ||
| 120 | - // } | ||
| 121 | - if (userHistorysShow.length == 0) { | ||
| 122 | - pageState = PageState.Empty; | ||
| 123 | - notifyListeners(); | ||
| 124 | - } else { | 186 | + if (userHistorys.length > 0) { |
| 187 | + if (key == '') { | ||
| 188 | + userHistorysShow = userHistorys; | ||
| 125 | pageState = PageState.Success; | 189 | pageState = PageState.Success; |
| 190 | + } else { | ||
| 191 | + userHistorysShow = []; | ||
| 192 | + | ||
| 193 | + for (int i = 0; i < userHistorys.length; i++) { | ||
| 194 | + String name = userHistorys[i].rname; | ||
| 195 | + String pinyinFirst = userHistorys[i].pinyinFirst; | ||
| 196 | + // String pinyin = userHistorys[i].pinyin; | ||
| 197 | + String phone = userHistorys[i].phone; | ||
| 198 | + List<String> pinyinList = userHistorys[i].pinyinList; | ||
| 199 | + if ((name != null && name.contains(key)) || | ||
| 200 | + (pinyinFirst != null && pinyinFirst.contains(key)) || | ||
| 201 | + (phone != null && phone.contains(key)) || | ||
| 202 | + (pinyinList != null && pinyinList.contains(key))) { | ||
| 203 | + userHistorysShow.add(userHistorys[i]); | ||
| 204 | + } | ||
| 205 | + } | ||
| 206 | + // for (int i = 0; i < contacts.length; i++) { | ||
| 207 | + // String name = contacts[i].rname; | ||
| 208 | + // String pinyinFirst = contacts[i].pinyinFirst; | ||
| 209 | + // List<String> pinyinList = contacts[i].pinyinList; | ||
| 210 | + // // String pinyin = contacts[i].pinyin; | ||
| 211 | + // String phone = contacts[i].phone; | ||
| 212 | + // if ((name != null && name.contains(key)) || | ||
| 213 | + // (pinyinFirst != null && pinyinFirst.contains(key)) || | ||
| 214 | + // (phone != null && phone.contains(key)) || | ||
| 215 | + // (pinyinList != null && pinyinList.contains(key))) { | ||
| 216 | + // contactsShow.add(contacts[i]); | ||
| 217 | + // } | ||
| 218 | + // } | ||
| 219 | + if (userHistorysShow.length == 0) { | ||
| 220 | + pageState = PageState.Empty; | ||
| 221 | + notifyListeners(); | ||
| 222 | + } else { | ||
| 223 | + pageState = PageState.Success; | ||
| 224 | + } | ||
| 225 | + // if (contactsShow.length == 0) { | ||
| 226 | + // pageStateRight = PageState.Empty; | ||
| 227 | + // } else { | ||
| 228 | + // pageStateRight = PageState.Success; | ||
| 229 | + // } | ||
| 126 | } | 230 | } |
| 127 | - // if (contactsShow.length == 0) { | ||
| 128 | - // pageStateRight = PageState.Empty; | ||
| 129 | - // } else { | ||
| 130 | - // pageStateRight = PageState.Success; | ||
| 131 | - // } | ||
| 132 | - } | ||
| 133 | 231 | ||
| 134 | - handleList(userHistorysShow, needRefresh: true); | 232 | + handleList(userHistorysShow, needRefresh: true); |
| 233 | + } | ||
| 135 | } | 234 | } |
| 136 | 235 | ||
| 137 | - handleList(List<UserHistoryEntity> list, {bool needRefresh = false}) { | 236 | + handleList(List<CustomerListSunModel> list, {bool needRefresh = false}) { |
| 138 | if (list == null || list.isEmpty) return; | 237 | if (list == null || list.isEmpty) return; |
| 139 | for (int i = 0, length = list.length; i < length; i++) { | 238 | for (int i = 0, length = list.length; i < length; i++) { |
| 140 | String pinyin = ''; | 239 | String pinyin = ''; |
| @@ -173,7 +272,7 @@ class CustomerProvider extends ChangeNotifier { | @@ -173,7 +272,7 @@ class CustomerProvider extends ChangeNotifier { | ||
| 173 | notifyListeners(); | 272 | notifyListeners(); |
| 174 | } | 273 | } |
| 175 | Map<String, String> params = { | 274 | Map<String, String> params = { |
| 176 | - 'uid': Provider.of<UserModel>(context, listen: false).user.openid | 275 | + 'uid': Provider.of<UserModel>(context, listen: false).user.openid |
| 177 | }; | 276 | }; |
| 178 | BaseResp<dynamic> baseResp = await DioUtil() | 277 | BaseResp<dynamic> baseResp = await DioUtil() |
| 179 | .request<dynamic>(context, Method.get, HttpUrl.guest_manage, | 278 | .request<dynamic>(context, Method.get, HttpUrl.guest_manage, |
| 1 | import 'package:fluro/fluro.dart'; | 1 | import 'package:fluro/fluro.dart'; |
| 2 | import 'package:flutter/material.dart'; | 2 | import 'package:flutter/material.dart'; |
| 3 | +import 'package:one_key/constant/state.dart'; | ||
| 3 | import 'package:one_key/models/cookbook_model.dart'; | 4 | import 'package:one_key/models/cookbook_model.dart'; |
| 4 | import 'package:one_key/models/coupon_model.dart'; | 5 | import 'package:one_key/models/coupon_model.dart'; |
| 6 | +import 'package:one_key/models/customer_list_model.dart'; | ||
| 5 | import 'package:one_key/models/integral_model.dart'; | 7 | import 'package:one_key/models/integral_model.dart'; |
| 6 | import 'package:one_key/models/notebook.dart'; | 8 | import 'package:one_key/models/notebook.dart'; |
| 7 | import 'package:one_key/models/notebook_detail.dart'; | 9 | import 'package:one_key/models/notebook_detail.dart'; |
| @@ -529,9 +531,11 @@ class NavigatorUtil { | @@ -529,9 +531,11 @@ class NavigatorUtil { | ||
| 529 | } | 531 | } |
| 530 | 532 | ||
| 531 | /// 客情列表 | 533 | /// 客情列表 |
| 532 | - static Future<dynamic> goCustomerListPage(BuildContext context, | 534 | + static Future<dynamic> goCustomerListPage( |
| 535 | + BuildContext context, FromPage fromPage, | ||
| 533 | {replace = false, bool needBtn = false}) { | 536 | {replace = false, bool needBtn = false}) { |
| 534 | - return _navigateTo(context, "${Routes.customer_list_page}", | 537 | + return _navigateTo(context, |
| 538 | + "${Routes.customer_list_page}?fromPage=${FluroConvertUtils.enumToString(fromPage)}", | ||
| 535 | replace: replace); | 539 | replace: replace); |
| 536 | } | 540 | } |
| 537 | 541 | ||
| @@ -566,7 +570,7 @@ class NavigatorUtil { | @@ -566,7 +570,7 @@ class NavigatorUtil { | ||
| 566 | /// 客户详情 | 570 | /// 客户详情 |
| 567 | static Future<dynamic> goCustomerDetailPage( | 571 | static Future<dynamic> goCustomerDetailPage( |
| 568 | BuildContext context, | 572 | BuildContext context, |
| 569 | - UserHistoryEntity userHistoryEntity, { | 573 | + CustomerListSunModel userHistoryEntity, { |
| 570 | replace = false, | 574 | replace = false, |
| 571 | }) { | 575 | }) { |
| 572 | return _navigateTo(context, | 576 | return _navigateTo(context, |
| @@ -2,8 +2,10 @@ import 'dart:convert'; | @@ -2,8 +2,10 @@ import 'dart:convert'; | ||
| 2 | 2 | ||
| 3 | import 'package:fluro/fluro.dart'; | 3 | import 'package:fluro/fluro.dart'; |
| 4 | import 'package:flutter/material.dart'; | 4 | import 'package:flutter/material.dart'; |
| 5 | +import 'package:one_key/constant/state.dart'; | ||
| 5 | import 'package:one_key/models/cookbook_model.dart'; | 6 | import 'package:one_key/models/cookbook_model.dart'; |
| 6 | import 'package:one_key/models/coupon_model.dart'; | 7 | import 'package:one_key/models/coupon_model.dart'; |
| 8 | +import 'package:one_key/models/customer_list_model.dart'; | ||
| 7 | import 'package:one_key/models/integral_model.dart'; | 9 | import 'package:one_key/models/integral_model.dart'; |
| 8 | import 'package:one_key/models/notebook_detail.dart'; | 10 | import 'package:one_key/models/notebook_detail.dart'; |
| 9 | import 'package:one_key/models/personnel_manage_model.dart'; | 11 | import 'package:one_key/models/personnel_manage_model.dart'; |
| @@ -848,9 +850,12 @@ var myCustomerPageHandle = new Handler( | @@ -848,9 +850,12 @@ var myCustomerPageHandle = new Handler( | ||
| 848 | ///客情列表 | 850 | ///客情列表 |
| 849 | var customerListPageHandle = new Handler( | 851 | var customerListPageHandle = new Handler( |
| 850 | handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) { | 852 | handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) { |
| 851 | - // String idstr = params["idstr"].first; | 853 | + FromPage fromPage = FluroConvertUtils.enumFromString<FromPage>( |
| 854 | + FromPage.values, params["fromPage"].first); | ||
| 855 | + print(fromPage); | ||
| 852 | return ChangeNotifierProvider<CustomerProvider>( | 856 | return ChangeNotifierProvider<CustomerProvider>( |
| 853 | - create: (_) => CustomerProvider(), child: CustomerListPage()); | 857 | + create: (_) => CustomerProvider(), |
| 858 | + child: CustomerListPage(fromPage: fromPage)); | ||
| 854 | }); | 859 | }); |
| 855 | 860 | ||
| 856 | ///客情设置 | 861 | ///客情设置 |
| @@ -889,8 +894,8 @@ var makeMarkingPageHandle = new Handler( | @@ -889,8 +894,8 @@ var makeMarkingPageHandle = new Handler( | ||
| 889 | var customerDetailPageHandle = new Handler( | 894 | var customerDetailPageHandle = new Handler( |
| 890 | handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) { | 895 | handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) { |
| 891 | // String idstr = params["idstr"].first; | 896 | // String idstr = params["idstr"].first; |
| 892 | - UserHistoryEntity userHistoryEntity = UserHistoryEntity.fromJson(json.decode( | ||
| 893 | - FluroConvertUtils.fluroCnParamsDecode( | 897 | + CustomerListSunModel userHistoryEntity = CustomerListSunModel.fromJson( |
| 898 | + json.decode(FluroConvertUtils.fluroCnParamsDecode( | ||
| 894 | params["userHistoryEntity"].first))); | 899 | params["userHistoryEntity"].first))); |
| 895 | return ChangeNotifierProvider<CustomerProvider>( | 900 | return ChangeNotifierProvider<CustomerProvider>( |
| 896 | create: (_) => CustomerProvider(), | 901 | create: (_) => CustomerProvider(), |
| @@ -49,10 +49,17 @@ class FluroConvertUtils { | @@ -49,10 +49,17 @@ class FluroConvertUtils { | ||
| 49 | return json.decode(fluroCnParamsDecode(str)); | 49 | return json.decode(fluroCnParamsDecode(str)); |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | - | ||
| 53 | - | ||
| 54 | /// string json 转为 map | 52 | /// string json 转为 map |
| 55 | static Map<String, List<TableList>> string2mapTableList(String str) { | 53 | static Map<String, List<TableList>> string2mapTableList(String str) { |
| 56 | return json.decode(fluroCnParamsDecode(str)); | 54 | return json.decode(fluroCnParamsDecode(str)); |
| 57 | } | 55 | } |
| 56 | + | ||
| 57 | + ///枚举类型转string | ||
| 58 | + static String enumToString(o) => o.toString().split('.').last; | ||
| 59 | + | ||
| 60 | + ///string转枚举类型 | ||
| 61 | + static T enumFromString<T>(Iterable<T> values, String value) { | ||
| 62 | + return values.firstWhere((type) => type.toString().split('.').last == value, | ||
| 63 | + orElse: () => null); | ||
| 64 | + } | ||
| 58 | } | 65 | } |
| @@ -483,6 +483,88 @@ const List gLunarHolDay = [ | @@ -483,6 +483,88 @@ const List gLunarHolDay = [ | ||
| 483 | ]; | 483 | ]; |
| 484 | 484 | ||
| 485 | class Utils { | 485 | class Utils { |
| 486 | + // | ||
| 487 | + | ||
| 488 | + //时间转换 | ||
| 489 | + static String format(String datestr) { | ||
| 490 | + String date = ''; | ||
| 491 | + String _str = | ||
| 492 | + datestr.replaceAll('年', '-').replaceAll('月', '-').replaceAll('日', ''); | ||
| 493 | + String _time = "${_str} 16:00:00"; //注意格式否则在DateTime.parse()时会报错 | ||
| 494 | + DateTime _strtimes = DateTime.parse( | ||
| 495 | + _time); //首先先将字符串格式的时间转为DateTime类型,因为millisecondsSinceEpoch方法转换要求为该格式 | ||
| 496 | + int _intendtime = _strtimes.millisecondsSinceEpoch; //方法一 | ||
| 497 | + // var _intendtime = DateTime.fromMillisecondsSinceEpoch(_strtimes );//方法二 | ||
| 498 | + // //_intendtime 为以及转换好的时间戳 | ||
| 499 | + DateTime dateNow = DateTime.now(); | ||
| 500 | + // String ymd = "${day.year}-" + | ||
| 501 | + // Utils.addZeroNumber(day.month) + | ||
| 502 | + // "-" + | ||
| 503 | + // Utils.addZeroNumber(day.day); | ||
| 504 | + | ||
| 505 | + if (Utils.isOneDay(_strtimes, dateNow)) { | ||
| 506 | + date = "今天 "; | ||
| 507 | + } else if (Utils.isOneDay(_strtimes, dateNow.add(Duration(days: 1)))) { | ||
| 508 | + date = "明天 "; | ||
| 509 | + } else if (Utils.isOneDay(_strtimes, dateNow.add(Duration(days: 2)))) { | ||
| 510 | + date = "后天 "; | ||
| 511 | + } else { | ||
| 512 | + final num ONE_HOUR = 3600000; | ||
| 513 | + final num ONE_DAY = 86400000; | ||
| 514 | + final String ONE_DAY_AGO = "天前"; | ||
| 515 | + num delta = DateTime.now().millisecondsSinceEpoch - | ||
| 516 | + _strtimes.millisecondsSinceEpoch; | ||
| 517 | + // if (delta < 1 * ONE_MINUTE) { | ||
| 518 | + // num seconds = toSeconds(delta); | ||
| 519 | + // return (seconds <= 0 ? 1 : seconds).toInt().toString() + ONE_SECOND_AGO; | ||
| 520 | + // } | ||
| 521 | + // if (delta < 45 * ONE_MINUTE) { | ||
| 522 | + // num minutes = toMinutes(delta); | ||
| 523 | + // return (minutes <= 0 ? 1 : minutes).toInt().toString() + ONE_MINUTE_AGO; | ||
| 524 | + // } | ||
| 525 | + // if (delta < 24 * ONE_HOUR) { | ||
| 526 | + // num hours = toHours(delta); | ||
| 527 | + // return (hours <= 0 ? 1 : hours).toInt().toString() + ONE_HOUR_AGO; | ||
| 528 | + // } | ||
| 529 | + // if (delta < 48 * ONE_HOUR) { | ||
| 530 | + // return "昨天"; | ||
| 531 | + // } | ||
| 532 | + if (delta > 0) { | ||
| 533 | + // if (delta < 30 * ONE_DAY) { | ||
| 534 | + num days = toDays(delta); | ||
| 535 | + date = (days <= 0 ? 1 : days).toInt().toString() + ONE_DAY_AGO; | ||
| 536 | + // } | ||
| 537 | + } else { | ||
| 538 | + date = datestr; | ||
| 539 | + } | ||
| 540 | + return date; | ||
| 541 | + | ||
| 542 | + // if (delta < 12 * 4 * ONE_WEEK) { | ||
| 543 | + // num months = toMonths(delta); | ||
| 544 | + // return (months <= 0 ? 1 : months).toInt().toString() + ONE_MONTH_AGO; | ||
| 545 | + // } else { | ||
| 546 | + // num years = toYears(delta); | ||
| 547 | + // return (years <= 0 ? 1 : years).toInt().toString() + ONE_YEAR_AGO; | ||
| 548 | + // } | ||
| 549 | + } | ||
| 550 | + } | ||
| 551 | + | ||
| 552 | + static num toSeconds(num date) { | ||
| 553 | + return date / 1000; | ||
| 554 | + } | ||
| 555 | + | ||
| 556 | + static num toMinutes(num date) { | ||
| 557 | + return toSeconds(date) / 60; | ||
| 558 | + } | ||
| 559 | + | ||
| 560 | + static num toHours(num date) { | ||
| 561 | + return toMinutes(date) / 60; | ||
| 562 | + } | ||
| 563 | + | ||
| 564 | + static num toDays(num date) { | ||
| 565 | + return toHours(date) / 24; | ||
| 566 | + } | ||
| 567 | + | ||
| 486 | static String getLunarSpecialDate(DateTime dateTime) { | 568 | static String getLunarSpecialDate(DateTime dateTime) { |
| 487 | String _day = ''; | 569 | String _day = ''; |
| 488 | int iYear = dateTime.year; | 570 | int iYear = dateTime.year; |
-
Please register or login to post a comment