Showing
8 changed files
with
689 additions
and
98 deletions
lib/models/CouponDataExpirationDate.dart
0 → 100644
| 1 | +/* | ||
| 2 | + Flutter3.x完全开发手册 https://www.flutterschool.cn/ | ||
| 3 | +*/ | ||
| 4 | +import 'dart:convert'; | ||
| 5 | + | ||
| 6 | +class ADataExpirationDate { | ||
| 7 | +/* | ||
| 8 | +{ | ||
| 9 | + "valid_forever": "0", | ||
| 10 | + "stime": "1741536000", | ||
| 11 | + "etime": "1742486399" | ||
| 12 | +} | ||
| 13 | +*/ | ||
| 14 | + | ||
| 15 | + String? validForever; | ||
| 16 | + String? stime; | ||
| 17 | + String? etime; | ||
| 18 | + | ||
| 19 | + ADataExpirationDate({ | ||
| 20 | + this.validForever, | ||
| 21 | + this.stime, | ||
| 22 | + this.etime, | ||
| 23 | + }); | ||
| 24 | + ADataExpirationDate.fromJson(Map<String, dynamic> json) { | ||
| 25 | + validForever = json['valid_forever']?.toString(); | ||
| 26 | + stime = json['stime']?.toString(); | ||
| 27 | + etime = json['etime']?.toString(); | ||
| 28 | + } | ||
| 29 | + Map<String, dynamic> toJson() { | ||
| 30 | + final data = <String, dynamic>{}; | ||
| 31 | + data['valid_forever'] = validForever; | ||
| 32 | + data['stime'] = stime; | ||
| 33 | + data['etime'] = etime; | ||
| 34 | + return data; | ||
| 35 | + } | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +class ADataAexpiration { | ||
| 39 | +/* | ||
| 40 | +{ | ||
| 41 | + "valid_forever": "0", | ||
| 42 | + "stime": "1741536000", | ||
| 43 | + "etime": "1742659199", | ||
| 44 | + "today": null, | ||
| 45 | + "tomorrow": null, | ||
| 46 | + "sday": null, | ||
| 47 | + "eday": null | ||
| 48 | +} | ||
| 49 | +*/ | ||
| 50 | + | ||
| 51 | + String? validForever; | ||
| 52 | + String? stime; | ||
| 53 | + String? etime; | ||
| 54 | + String? today; | ||
| 55 | + String? tomorrow; | ||
| 56 | + String? sday; | ||
| 57 | + String? eday; | ||
| 58 | + | ||
| 59 | + ADataAexpiration({ | ||
| 60 | + this.validForever, | ||
| 61 | + this.stime, | ||
| 62 | + this.etime, | ||
| 63 | + this.today, | ||
| 64 | + this.tomorrow, | ||
| 65 | + this.sday, | ||
| 66 | + this.eday, | ||
| 67 | + }); | ||
| 68 | + ADataAexpiration.fromJson(Map<String, dynamic> json) { | ||
| 69 | + validForever = json['valid_forever']?.toString(); | ||
| 70 | + stime = json['stime']?.toString(); | ||
| 71 | + etime = json['etime']?.toString(); | ||
| 72 | + today = json['today']?.toString(); | ||
| 73 | + tomorrow = json['tomorrow']?.toString(); | ||
| 74 | + sday = json['sday']?.toString(); | ||
| 75 | + eday = json['eday']?.toString(); | ||
| 76 | + } | ||
| 77 | + Map<String, dynamic> toJson() { | ||
| 78 | + final data = <String, dynamic>{}; | ||
| 79 | + data['valid_forever'] = validForever; | ||
| 80 | + data['stime'] = stime; | ||
| 81 | + data['etime'] = etime; | ||
| 82 | + data['today'] = today; | ||
| 83 | + data['tomorrow'] = tomorrow; | ||
| 84 | + data['sday'] = sday; | ||
| 85 | + data['eday'] = eday; | ||
| 86 | + return data; | ||
| 87 | + } | ||
| 88 | +} | ||
| 89 | + | ||
| 90 | +class ADataArule { | ||
| 91 | +/* | ||
| 92 | +{ | ||
| 93 | + "is_same_day": "1", | ||
| 94 | + "is_accumulation": "1", | ||
| 95 | + "is_compartment": "1", | ||
| 96 | + "is_eatin": "1", | ||
| 97 | + "is_takeout": "1", | ||
| 98 | + "is_appointment": "1", | ||
| 99 | + "is_share_lose": "1", | ||
| 100 | + "is_share_have": "1" | ||
| 101 | +} | ||
| 102 | +*/ | ||
| 103 | + | ||
| 104 | + String? isSameDay; | ||
| 105 | + String? isAccumulation; | ||
| 106 | + String? isCompartment; | ||
| 107 | + String? isEatin; | ||
| 108 | + String? isTakeout; | ||
| 109 | + String? isAppointment; | ||
| 110 | + String? isShareLose; | ||
| 111 | + String? isShareHave; | ||
| 112 | + | ||
| 113 | + ADataArule({ | ||
| 114 | + this.isSameDay, | ||
| 115 | + this.isAccumulation, | ||
| 116 | + this.isCompartment, | ||
| 117 | + this.isEatin, | ||
| 118 | + this.isTakeout, | ||
| 119 | + this.isAppointment, | ||
| 120 | + this.isShareLose, | ||
| 121 | + this.isShareHave, | ||
| 122 | + }); | ||
| 123 | + ADataArule.fromJson(Map<String, dynamic> json) { | ||
| 124 | + isSameDay = json['is_same_day']?.toString(); | ||
| 125 | + isAccumulation = json['is_accumulation']?.toString(); | ||
| 126 | + isCompartment = json['is_compartment']?.toString(); | ||
| 127 | + isEatin = json['is_eatin']?.toString(); | ||
| 128 | + isTakeout = json['is_takeout']?.toString(); | ||
| 129 | + isAppointment = json['is_appointment']?.toString(); | ||
| 130 | + isShareLose = json['is_share_lose']?.toString(); | ||
| 131 | + isShareHave = json['is_share_have']?.toString(); | ||
| 132 | + } | ||
| 133 | + Map<String, dynamic> toJson() { | ||
| 134 | + final data = <String, dynamic>{}; | ||
| 135 | + data['is_same_day'] = isSameDay; | ||
| 136 | + data['is_accumulation'] = isAccumulation; | ||
| 137 | + data['is_compartment'] = isCompartment; | ||
| 138 | + data['is_eatin'] = isEatin; | ||
| 139 | + data['is_takeout'] = isTakeout; | ||
| 140 | + data['is_appointment'] = isAppointment; | ||
| 141 | + data['is_share_lose'] = isShareLose; | ||
| 142 | + data['is_share_have'] = isShareHave; | ||
| 143 | + return data; | ||
| 144 | + } | ||
| 145 | +} | ||
| 146 | + | ||
| 147 | +class AData { | ||
| 148 | +/* | ||
| 149 | +{ | ||
| 150 | + "id": "1088", | ||
| 151 | + "uid": "7035", | ||
| 152 | + "sellerid": "4352", | ||
| 153 | + "uid_list": null, | ||
| 154 | + "is_type": "3", | ||
| 155 | + "is_examine": "1", | ||
| 156 | + "aname": "名称测试", | ||
| 157 | + "desc": "200", | ||
| 158 | + "stime": null, | ||
| 159 | + "etime": null, | ||
| 160 | + "explain": "", | ||
| 161 | + "is_open": "1", | ||
| 162 | + "price": "200", | ||
| 163 | + "use": null, | ||
| 164 | + "status": "1", | ||
| 165 | + "grant_num": "100", | ||
| 166 | + "grant_last": "100", | ||
| 167 | + "urllink": "https://wxaurl.cn/7Dg2wrL8K2p", | ||
| 168 | + "lite_qrcode": "https://xt04.colorcun.com/activity/LiteQRcode/activity_1088.jpeg", | ||
| 169 | + "arule": { | ||
| 170 | + "is_same_day": "1", | ||
| 171 | + "is_accumulation": "1", | ||
| 172 | + "is_compartment": "1", | ||
| 173 | + "is_eatin": "1", | ||
| 174 | + "is_takeout": "1", | ||
| 175 | + "is_appointment": "1", | ||
| 176 | + "is_share_lose": "1", | ||
| 177 | + "is_share_have": "1" | ||
| 178 | + }, | ||
| 179 | + "aexpiration": { | ||
| 180 | + "valid_forever": "0", | ||
| 181 | + "stime": "1741536000", | ||
| 182 | + "etime": "1742659199", | ||
| 183 | + "today": null, | ||
| 184 | + "tomorrow": null, | ||
| 185 | + "sday": null, | ||
| 186 | + "eday": null | ||
| 187 | + }, | ||
| 188 | + "expiration_date": { | ||
| 189 | + "valid_forever": "0", | ||
| 190 | + "stime": "1741536000", | ||
| 191 | + "etime": "1742486399" | ||
| 192 | + }, | ||
| 193 | + "cdate": "1741594601" | ||
| 194 | +} | ||
| 195 | +*/ | ||
| 196 | + | ||
| 197 | + String? id; | ||
| 198 | + String? uid; | ||
| 199 | + String? sellerid; | ||
| 200 | + String? uidList; | ||
| 201 | + String? isType; | ||
| 202 | + String? isExamine; | ||
| 203 | + String? aname; | ||
| 204 | + String? desc; | ||
| 205 | + String? stime; | ||
| 206 | + String? etime; | ||
| 207 | + String? explain; | ||
| 208 | + String? isOpen; | ||
| 209 | + String? price; | ||
| 210 | + String? use; | ||
| 211 | + String? status; | ||
| 212 | + String? grantNum; | ||
| 213 | + String? grantLast; | ||
| 214 | + String? urllink; | ||
| 215 | + String? liteQrcode; | ||
| 216 | + ADataArule? arule; | ||
| 217 | + ADataAexpiration? aexpiration; | ||
| 218 | + ADataExpirationDate? expirationDate; | ||
| 219 | + String? cdate; | ||
| 220 | + | ||
| 221 | + AData({ | ||
| 222 | + this.id, | ||
| 223 | + this.uid, | ||
| 224 | + this.sellerid, | ||
| 225 | + this.uidList, | ||
| 226 | + this.isType, | ||
| 227 | + this.isExamine, | ||
| 228 | + this.aname, | ||
| 229 | + this.desc, | ||
| 230 | + this.stime, | ||
| 231 | + this.etime, | ||
| 232 | + this.explain, | ||
| 233 | + this.isOpen, | ||
| 234 | + this.price, | ||
| 235 | + this.use, | ||
| 236 | + this.status, | ||
| 237 | + this.grantNum, | ||
| 238 | + this.grantLast, | ||
| 239 | + this.urllink, | ||
| 240 | + this.liteQrcode, | ||
| 241 | + this.arule, | ||
| 242 | + this.aexpiration, | ||
| 243 | + this.expirationDate, | ||
| 244 | + this.cdate, | ||
| 245 | + }); | ||
| 246 | + AData.fromJson(Map<String, dynamic> json) { | ||
| 247 | + id = json['id']?.toString(); | ||
| 248 | + uid = json['uid']?.toString(); | ||
| 249 | + sellerid = json['sellerid']?.toString(); | ||
| 250 | + uidList = json['uid_list']?.toString(); | ||
| 251 | + isType = json['is_type']?.toString(); | ||
| 252 | + isExamine = json['is_examine']?.toString(); | ||
| 253 | + aname = json['aname']?.toString(); | ||
| 254 | + desc = json['desc']?.toString(); | ||
| 255 | + stime = json['stime']?.toString(); | ||
| 256 | + etime = json['etime']?.toString(); | ||
| 257 | + explain = json['explain']?.toString(); | ||
| 258 | + isOpen = json['is_open']?.toString(); | ||
| 259 | + price = json['price']?.toString(); | ||
| 260 | + use = json['use']?.toString(); | ||
| 261 | + status = json['status']?.toString(); | ||
| 262 | + grantNum = json['grant_num']?.toString(); | ||
| 263 | + grantLast = json['grant_last']?.toString(); | ||
| 264 | + urllink = json['urllink']?.toString(); | ||
| 265 | + liteQrcode = json['lite_qrcode']?.toString(); | ||
| 266 | + arule = (json['arule'] != null) ? ADataArule.fromJson(json['arule']) : null; | ||
| 267 | + aexpiration = (json['aexpiration'] != null) ? (json['aexpiration'] is Map)? ADataAexpiration.fromJson(json['aexpiration']):ADataAexpiration.fromJson(jsonDecode(json['aexpiration'])) : null; | ||
| 268 | + expirationDate = (json['expiration_date'] != null) ?(json['expiration_date'] is Map)? ADataExpirationDate.fromJson(json['expiration_date']): ADataExpirationDate.fromJson(jsonDecode(json['expiration_date'])) : null; | ||
| 269 | + cdate = json['cdate']?.toString(); | ||
| 270 | + } | ||
| 271 | + Map<String, dynamic> toJson() { | ||
| 272 | + final data = <String, dynamic>{}; | ||
| 273 | + data['id'] = id; | ||
| 274 | + data['uid'] = uid; | ||
| 275 | + data['sellerid'] = sellerid; | ||
| 276 | + data['uid_list'] = uidList; | ||
| 277 | + data['is_type'] = isType; | ||
| 278 | + data['is_examine'] = isExamine; | ||
| 279 | + data['aname'] = aname; | ||
| 280 | + data['desc'] = desc; | ||
| 281 | + data['stime'] = stime; | ||
| 282 | + data['etime'] = etime; | ||
| 283 | + data['explain'] = explain; | ||
| 284 | + data['is_open'] = isOpen; | ||
| 285 | + data['price'] = price; | ||
| 286 | + data['use'] = use; | ||
| 287 | + data['status'] = status; | ||
| 288 | + data['grant_num'] = grantNum; | ||
| 289 | + data['grant_last'] = grantLast; | ||
| 290 | + data['urllink'] = urllink; | ||
| 291 | + data['lite_qrcode'] = liteQrcode; | ||
| 292 | + if (arule != null) { | ||
| 293 | + data['arule'] = arule!.toJson(); | ||
| 294 | + } | ||
| 295 | + if (aexpiration != null) { | ||
| 296 | + data['aexpiration'] = aexpiration!.toJson(); | ||
| 297 | + } | ||
| 298 | + if (expirationDate != null) { | ||
| 299 | + data['expiration_date'] = expirationDate!.toJson(); | ||
| 300 | + } | ||
| 301 | + data['cdate'] = cdate; | ||
| 302 | + return data; | ||
| 303 | + } | ||
| 304 | +} | ||
| 305 | + | ||
| 306 | +class A { | ||
| 307 | +/* | ||
| 308 | +{ | ||
| 309 | + "ret": 200, | ||
| 310 | + "data": [ | ||
| 311 | + { | ||
| 312 | + "id": "1088", | ||
| 313 | + "uid": "7035", | ||
| 314 | + "sellerid": "4352", | ||
| 315 | + "uid_list": null, | ||
| 316 | + "is_type": "3", | ||
| 317 | + "is_examine": "1", | ||
| 318 | + "aname": "名称测试", | ||
| 319 | + "desc": "200", | ||
| 320 | + "stime": null, | ||
| 321 | + "etime": null, | ||
| 322 | + "explain": "", | ||
| 323 | + "is_open": "1", | ||
| 324 | + "price": "200", | ||
| 325 | + "use": null, | ||
| 326 | + "status": "1", | ||
| 327 | + "grant_num": "100", | ||
| 328 | + "grant_last": "100", | ||
| 329 | + "urllink": "https://wxaurl.cn/7Dg2wrL8K2p", | ||
| 330 | + "lite_qrcode": "https://xt04.colorcun.com/activity/LiteQRcode/activity_1088.jpeg", | ||
| 331 | + "arule": { | ||
| 332 | + "is_same_day": "1", | ||
| 333 | + "is_accumulation": "1", | ||
| 334 | + "is_compartment": "1", | ||
| 335 | + "is_eatin": "1", | ||
| 336 | + "is_takeout": "1", | ||
| 337 | + "is_appointment": "1", | ||
| 338 | + "is_share_lose": "1", | ||
| 339 | + "is_share_have": "1" | ||
| 340 | + }, | ||
| 341 | + "aexpiration": { | ||
| 342 | + "valid_forever": "0", | ||
| 343 | + "stime": "1741536000", | ||
| 344 | + "etime": "1742659199", | ||
| 345 | + "today": null, | ||
| 346 | + "tomorrow": null, | ||
| 347 | + "sday": null, | ||
| 348 | + "eday": null | ||
| 349 | + }, | ||
| 350 | + "expiration_date": { | ||
| 351 | + "valid_forever": "0", | ||
| 352 | + "stime": "1741536000", | ||
| 353 | + "etime": "1742486399" | ||
| 354 | + }, | ||
| 355 | + "cdate": "1741594601" | ||
| 356 | + } | ||
| 357 | + ], | ||
| 358 | + "msg": "" | ||
| 359 | +} | ||
| 360 | +*/ | ||
| 361 | + | ||
| 362 | + int? ret; | ||
| 363 | + List<AData?>? data; | ||
| 364 | + String? msg; | ||
| 365 | + | ||
| 366 | + A({ | ||
| 367 | + this.ret, | ||
| 368 | + this.data, | ||
| 369 | + this.msg, | ||
| 370 | + }); | ||
| 371 | + A.fromJson(Map<String, dynamic> json) { | ||
| 372 | + ret = json['ret']?.toInt(); | ||
| 373 | + if (json['data'] != null) { | ||
| 374 | + final v = json['data']; | ||
| 375 | + final arr0 = <AData>[]; | ||
| 376 | + v.forEach((v) { | ||
| 377 | + arr0.add(AData.fromJson(v)); | ||
| 378 | + }); | ||
| 379 | + this.data = arr0; | ||
| 380 | + } | ||
| 381 | + msg = json['msg']?.toString(); | ||
| 382 | + } | ||
| 383 | + Map<String, dynamic> toJson() { | ||
| 384 | + final data = <String, dynamic>{}; | ||
| 385 | + data['ret'] = ret; | ||
| 386 | + if (this.data != null) { | ||
| 387 | + final v = this.data; | ||
| 388 | + final arr0 = []; | ||
| 389 | + v!.forEach((v) { | ||
| 390 | + arr0.add(v!.toJson()); | ||
| 391 | + }); | ||
| 392 | + data['data'] = arr0; | ||
| 393 | + } | ||
| 394 | + data['msg'] = msg; | ||
| 395 | + return data; | ||
| 396 | + } | ||
| 397 | +} |
| @@ -2,6 +2,7 @@ import 'dart:convert'; | @@ -2,6 +2,7 @@ import 'dart:convert'; | ||
| 2 | 2 | ||
| 3 | import 'package:flutter/material.dart'; | 3 | import 'package:flutter/material.dart'; |
| 4 | import 'package:json_annotation/json_annotation.dart'; | 4 | import 'package:json_annotation/json_annotation.dart'; |
| 5 | +import 'package:one_key/models/CouponDataExpirationDate.dart'; | ||
| 5 | import 'package:one_key/models/filter_btn_model.dart'; | 6 | import 'package:one_key/models/filter_btn_model.dart'; |
| 6 | 7 | ||
| 7 | 8 | ||
| @@ -107,12 +108,15 @@ class CouponSunModel extends Object { | @@ -107,12 +108,15 @@ class CouponSunModel extends Object { | ||
| 107 | @JsonKey(name: 'lite_qrcode') | 108 | @JsonKey(name: 'lite_qrcode') |
| 108 | String? liteQrcode; | 109 | String? liteQrcode; |
| 109 | 110 | ||
| 110 | - @JsonKey(name: 'aexpiration') | ||
| 111 | - String? aexpiration; | 111 | + // @JsonKey(name: 'aexpiration') |
| 112 | + // String? aexpiration; | ||
| 112 | 113 | ||
| 113 | @JsonKey(name: 'number') | 114 | @JsonKey(name: 'number') |
| 114 | int number; | 115 | int number; |
| 115 | 116 | ||
| 117 | + ADataAexpiration? aexpiration; | ||
| 118 | + ADataExpirationDate? expirationDate; | ||
| 119 | + | ||
| 116 | // arule 券使用和分享规则 领取后有效天数 | 120 | // arule 券使用和分享规则 领取后有效天数 |
| 117 | 121 | ||
| 118 | bool isCheck = false; | 122 | bool isCheck = false; |
| @@ -147,8 +151,11 @@ class CouponSunModel extends Object { | @@ -147,8 +151,11 @@ class CouponSunModel extends Object { | ||
| 147 | this.grantNum, | 151 | this.grantNum, |
| 148 | this.urllink, | 152 | this.urllink, |
| 149 | this.liteQrcode, | 153 | this.liteQrcode, |
| 154 | + // this.aexpiration, | ||
| 155 | + this.number, | ||
| 150 | this.aexpiration, | 156 | this.aexpiration, |
| 151 | - this.number); | 157 | + this.expirationDate, |
| 158 | + ); | ||
| 152 | 159 | ||
| 153 | factory CouponSunModel.fromJson(Map<String, dynamic> srcJson) => | 160 | factory CouponSunModel.fromJson(Map<String, dynamic> srcJson) => |
| 154 | _$CouponSunModelFromJson(srcJson); | 161 | _$CouponSunModelFromJson(srcJson); |
| @@ -25,6 +25,27 @@ Map<String, dynamic> _$CouponModelToJson(CouponModel instance) => | @@ -25,6 +25,27 @@ Map<String, dynamic> _$CouponModelToJson(CouponModel instance) => | ||
| 25 | }; | 25 | }; |
| 26 | 26 | ||
| 27 | CouponSunModel _$CouponSunModelFromJson(Map<String, dynamic> json) { | 27 | CouponSunModel _$CouponSunModelFromJson(Map<String, dynamic> json) { |
| 28 | + ADataExpirationDate? date; | ||
| 29 | + if (json['expiration_date'] == null) { | ||
| 30 | + date = ADataExpirationDate( | ||
| 31 | + stime: json['stime'], etime: json['etime'], validForever: '0'); | ||
| 32 | + } | ||
| 33 | + ADataAexpiration? aexpiration; | ||
| 34 | + if (json['aexpiration'] != null) { | ||
| 35 | + if ((json['aexpiration'] is Map)) { | ||
| 36 | + aexpiration = ADataAexpiration.fromJson(json['aexpiration']); | ||
| 37 | + } else if (json['aexpiration'] is String) { | ||
| 38 | + if (json['aexpiration'].contains('stime')) { | ||
| 39 | + aexpiration = | ||
| 40 | + ADataAexpiration.fromJson(jsonDecode(json['aexpiration'])); | ||
| 41 | + } else { | ||
| 42 | + aexpiration = json['aexpiration'] == '0' | ||
| 43 | + ? ADataAexpiration(etime: json['etime'] ?? '') | ||
| 44 | + : ADataAexpiration(today: json['aexpiration']); | ||
| 45 | + } | ||
| 46 | + } | ||
| 47 | + } | ||
| 48 | + | ||
| 28 | return CouponSunModel( | 49 | return CouponSunModel( |
| 29 | json['id'] as String?, | 50 | json['id'] as String?, |
| 30 | json['uid'] as String?, | 51 | json['uid'] as String?, |
| @@ -69,8 +90,15 @@ CouponSunModel _$CouponSunModelFromJson(Map<String, dynamic> json) { | @@ -69,8 +90,15 @@ CouponSunModel _$CouponSunModelFromJson(Map<String, dynamic> json) { | ||
| 69 | json['grant_num'] as String?, | 90 | json['grant_num'] as String?, |
| 70 | json['urllink'] as String?, | 91 | json['urllink'] as String?, |
| 71 | json['lite_qrcode'] as String?, | 92 | json['lite_qrcode'] as String?, |
| 72 | - json['aexpiration'] as String?, | ||
| 73 | - (json['number'] ?? 1) as int); | 93 | + // json['aexpiration'] as String?, |
| 94 | + (json['number'] ?? 1) as int, | ||
| 95 | + aexpiration, | ||
| 96 | + (json['expiration_date'] != null) | ||
| 97 | + ? (json['expiration_date'] is Map) | ||
| 98 | + ? ADataExpirationDate.fromJson(json['expiration_date']) | ||
| 99 | + : ADataExpirationDate.fromJson( | ||
| 100 | + jsonDecode(json['expiration_date'])) | ||
| 101 | + : date); | ||
| 74 | } | 102 | } |
| 75 | 103 | ||
| 76 | Map<String, dynamic> _$CouponSunModelToJson(CouponSunModel instance) => | 104 | Map<String, dynamic> _$CouponSunModelToJson(CouponSunModel instance) => |
| @@ -100,8 +128,9 @@ Map<String, dynamic> _$CouponSunModelToJson(CouponSunModel instance) => | @@ -100,8 +128,9 @@ Map<String, dynamic> _$CouponSunModelToJson(CouponSunModel instance) => | ||
| 100 | 'grant_num': instance.grantNum, | 128 | 'grant_num': instance.grantNum, |
| 101 | 'urllink': instance.urllink, | 129 | 'urllink': instance.urllink, |
| 102 | 'lite_qrcode': instance.liteQrcode, | 130 | 'lite_qrcode': instance.liteQrcode, |
| 131 | + 'number': instance.number, | ||
| 103 | 'aexpiration': instance.aexpiration, | 132 | 'aexpiration': instance.aexpiration, |
| 104 | - 'number': instance.number | 133 | + 'expiration_date': instance.expirationDate, |
| 105 | }; | 134 | }; |
| 106 | 135 | ||
| 107 | CouponUse _$CouponUseFromJson(Map<String, dynamic> json) { | 136 | CouponUse _$CouponUseFromJson(Map<String, dynamic> json) { |
| @@ -223,17 +252,17 @@ Arule _$AruleFromJson(Map<String, dynamic> json) { | @@ -223,17 +252,17 @@ Arule _$AruleFromJson(Map<String, dynamic> json) { | ||
| 223 | // } | 252 | // } |
| 224 | 253 | ||
| 225 | return Arule( | 254 | return Arule( |
| 226 | - isSameDay, | ||
| 227 | - isAccumulation, | ||
| 228 | - isCompartment, | ||
| 229 | - isEatin, | ||
| 230 | - isTakeout, | ||
| 231 | - isAppointment, | ||
| 232 | - isShareLose, | ||
| 233 | - isShareHave, | ||
| 234 | - // isCommission, | ||
| 235 | - // json['commission'] | ||
| 236 | - ); | 255 | + isSameDay, |
| 256 | + isAccumulation, | ||
| 257 | + isCompartment, | ||
| 258 | + isEatin, | ||
| 259 | + isTakeout, | ||
| 260 | + isAppointment, | ||
| 261 | + isShareLose, | ||
| 262 | + isShareHave, | ||
| 263 | + // isCommission, | ||
| 264 | + // json['commission'] | ||
| 265 | + ); | ||
| 237 | } | 266 | } |
| 238 | 267 | ||
| 239 | Map<String, dynamic> _$AruleToJson(Arule instance) => <String, dynamic>{ | 268 | Map<String, dynamic> _$AruleToJson(Arule instance) => <String, dynamic>{ |
| @@ -144,7 +144,7 @@ class _CouponDetailPageState extends State<CouponDetailPage> { | @@ -144,7 +144,7 @@ class _CouponDetailPageState extends State<CouponDetailPage> { | ||
| 144 | fontSize: ScreenUtil().setSp(32)), | 144 | fontSize: ScreenUtil().setSp(32)), |
| 145 | ), | 145 | ), |
| 146 | ), | 146 | ), |
| 147 | - HEmptyView(60), | 147 | + HEmptyView(10), |
| 148 | Expanded( | 148 | Expanded( |
| 149 | child: Text( | 149 | child: Text( |
| 150 | subTitle, | 150 | subTitle, |
| @@ -326,6 +326,49 @@ class _CouponDetailPageState extends State<CouponDetailPage> { | @@ -326,6 +326,49 @@ class _CouponDetailPageState extends State<CouponDetailPage> { | ||
| 326 | @override | 326 | @override |
| 327 | Widget build(BuildContext context) { | 327 | Widget build(BuildContext context) { |
| 328 | couponProvider = Provider.of<CouponProvider>(context, listen: true); | 328 | couponProvider = Provider.of<CouponProvider>(context, listen: true); |
| 329 | + | ||
| 330 | + String aexpirationStr = ''; | ||
| 331 | + if (couponProvider.couponSunModel?.aexpiration != null) { | ||
| 332 | + if (couponProvider.couponSunModel!.aexpiration!.validForever == '1') { | ||
| 333 | + aexpirationStr = '永久有效'; | ||
| 334 | + } else if (couponProvider.couponSunModel!.aexpiration!.stime != null) { | ||
| 335 | + DateTime dateTimes = DateTime.fromMillisecondsSinceEpoch(int.parse( | ||
| 336 | + couponProvider.couponSunModel!.aexpiration!.stime.toString()) * | ||
| 337 | + 1000); | ||
| 338 | + DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(int.parse( | ||
| 339 | + couponProvider.couponSunModel!.aexpiration!.etime.toString()) * | ||
| 340 | + 1000); | ||
| 341 | + String fromDate = '${dateTimes.year}' + | ||
| 342 | + '-${Utils.addZeroNumber(dateTimes.month)}' + | ||
| 343 | + '-${Utils.addZeroNumber(dateTimes.day)}'; //活动有效期开始时间 | ||
| 344 | + String endDate = '${dateTimee.year}' + | ||
| 345 | + '-${Utils.addZeroNumber(dateTimee.month)}' + | ||
| 346 | + '-${Utils.addZeroNumber(dateTimee.day)}'; | ||
| 347 | + aexpirationStr = fromDate + '至' + endDate; | ||
| 348 | + } else if (couponProvider.couponSunModel!.aexpiration!.stime == null && | ||
| 349 | + couponProvider.couponSunModel!.aexpiration!.etime != null) { | ||
| 350 | + DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(int.parse( | ||
| 351 | + couponProvider.couponSunModel!.aexpiration!.etime.toString()) * | ||
| 352 | + 1000); | ||
| 353 | + String endDate = '${dateTimee.year}' + | ||
| 354 | + '-${Utils.addZeroNumber(dateTimee.month)}' + | ||
| 355 | + '-${Utils.addZeroNumber(dateTimee.day)}'; | ||
| 356 | + aexpirationStr = '领取日起' + '至' + endDate; | ||
| 357 | + } else if (couponProvider.couponSunModel!.aexpiration!.today != null && | ||
| 358 | + couponProvider.couponSunModel!.aexpiration!.today != '') { | ||
| 359 | + aexpirationStr = | ||
| 360 | + '领券当日起${couponProvider.couponSunModel!.aexpiration!.today}天内可用'; | ||
| 361 | + } else if (couponProvider.couponSunModel!.aexpiration!.tomorrow != null && | ||
| 362 | + couponProvider.couponSunModel!.aexpiration!.tomorrow != '') { | ||
| 363 | + aexpirationStr = | ||
| 364 | + '领券次日起${couponProvider.couponSunModel!.aexpiration!.tomorrow}天内可用'; | ||
| 365 | + } else if (couponProvider.couponSunModel!.aexpiration!.sday != null && | ||
| 366 | + couponProvider.couponSunModel!.aexpiration!.sday != '') { | ||
| 367 | + aexpirationStr = | ||
| 368 | + '领券后第${couponProvider.couponSunModel!.aexpiration!.sday}天至${couponProvider.couponSunModel!.aexpiration!.eday}天可用'; | ||
| 369 | + } | ||
| 370 | + } | ||
| 371 | + | ||
| 329 | return Scaffold( | 372 | return Scaffold( |
| 330 | backgroundColor: MyColours.color_ffffff, | 373 | backgroundColor: MyColours.color_ffffff, |
| 331 | appBar: SystemAppBar( | 374 | appBar: SystemAppBar( |
| @@ -515,18 +558,12 @@ class _CouponDetailPageState extends State<CouponDetailPage> { | @@ -515,18 +558,12 @@ class _CouponDetailPageState extends State<CouponDetailPage> { | ||
| 515 | ), | 558 | ), |
| 516 | VEmptyView(24), | 559 | VEmptyView(24), |
| 517 | _item( | 560 | _item( |
| 518 | - '活动开始于', | ||
| 519 | - Utils.getDateStrFromJiekou( | ||
| 520 | - couponProvider.couponSunModel!.stime)), | ||
| 521 | - Container( | ||
| 522 | - height: ScreenUtil().setWidth(2), | ||
| 523 | - color: MyColours.color_E7E7E7, | ||
| 524 | - ), | ||
| 525 | - VEmptyView(24), | ||
| 526 | - _item( | ||
| 527 | - '活动结束于', | ||
| 528 | - Utils.getDateStrFromJiekou( | ||
| 529 | - couponProvider.couponSunModel!.etime)), | 561 | + '活动有效期', |
| 562 | + couponProvider.couponSunModel!.expirationDate | ||
| 563 | + ?.validForever == | ||
| 564 | + '1' | ||
| 565 | + ? '永久有效' | ||
| 566 | + : '${Utils.getDateStrFromJiekou(couponProvider.couponSunModel!.expirationDate?.stime)}至${Utils.getDateStrFromJiekou(couponProvider.couponSunModel!.expirationDate?.etime)}'), | ||
| 530 | Container( | 567 | Container( |
| 531 | height: ScreenUtil().setWidth(2), | 568 | height: ScreenUtil().setWidth(2), |
| 532 | color: MyColours.color_E7E7E7, | 569 | color: MyColours.color_E7E7E7, |
| @@ -535,10 +572,7 @@ class _CouponDetailPageState extends State<CouponDetailPage> { | @@ -535,10 +572,7 @@ class _CouponDetailPageState extends State<CouponDetailPage> { | ||
| 535 | VEmptyView(24), | 572 | VEmptyView(24), |
| 536 | if (couponProvider.couponSunModel!.isType == '3' || | 573 | if (couponProvider.couponSunModel!.isType == '3' || |
| 537 | couponProvider.couponSunModel!.isType == '4') | 574 | couponProvider.couponSunModel!.isType == '4') |
| 538 | - _item( | ||
| 539 | - '领取后有效天数', | ||
| 540 | - couponProvider.couponSunModel!.aexpiration ?? | ||
| 541 | - ''), | 575 | + _item('用户领取后有效期', aexpirationStr), |
| 542 | 576 | ||
| 543 | if ((couponProvider.couponSunModel!.isType == '3' || | 577 | if ((couponProvider.couponSunModel!.isType == '3' || |
| 544 | couponProvider.couponSunModel!.isType == | 578 | couponProvider.couponSunModel!.isType == |
| @@ -229,16 +229,93 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | @@ -229,16 +229,93 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | ||
| 229 | _couponNameEditControl.text = widget.couponSunModel!.aname ?? ""; | 229 | _couponNameEditControl.text = widget.couponSunModel!.aname ?? ""; |
| 230 | _couponRequireEditControl.text = widget.couponSunModel!.desc ?? ""; | 230 | _couponRequireEditControl.text = widget.couponSunModel!.desc ?? ""; |
| 231 | _couponExplainEditControl.text = widget.couponSunModel!.explain ?? ""; | 231 | _couponExplainEditControl.text = widget.couponSunModel!.explain ?? ""; |
| 232 | - DateTime dateTimes = DateTime.fromMillisecondsSinceEpoch( | ||
| 233 | - int.parse(widget.couponSunModel!.stime.toString()) * 1000); | ||
| 234 | - fromDate = DateUtil.formatDate(dateTimes, format: DateFormats.y_mo_d); | ||
| 235 | - DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch( | ||
| 236 | - int.parse(widget.couponSunModel!.etime.toString()) * 1000); | ||
| 237 | - endDate = DateUtil.formatDate(dateTimee, format: DateFormats.y_mo_d); | 232 | + |
| 233 | + // DateTime dateTimes = DateTime.fromMillisecondsSinceEpoch( | ||
| 234 | + // int.parse(widget.couponSunModel!.expirationDate!.stime.toString()) * 1000); | ||
| 235 | + // fromDate = DateUtil.formatDate(dateTimes, format: DateFormats.y_mo_d); | ||
| 236 | + // DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch( | ||
| 237 | + // int.parse(widget.couponSunModel!.etime.toString()) * 1000); | ||
| 238 | + // endDate = DateUtil.formatDate(dateTimee, format: DateFormats.y_mo_d); | ||
| 238 | 239 | ||
| 239 | swichState = widget.couponSunModel!.status == '1' ? true : false; | 240 | swichState = widget.couponSunModel!.status == '1' ? true : false; |
| 240 | _priceControl.text = widget.couponSunModel!.price; | 241 | _priceControl.text = widget.couponSunModel!.price; |
| 241 | - _limitDay.text = widget.couponSunModel!.aexpiration ?? ''; | 242 | + if (widget.couponSunModel!.expirationDate != null) { |
| 243 | + validForever = | ||
| 244 | + widget.couponSunModel!.expirationDate!.validForever == '1' | ||
| 245 | + ? true | ||
| 246 | + : false; | ||
| 247 | + DateTime dateTimes = DateTime.fromMillisecondsSinceEpoch( | ||
| 248 | + int.parse(widget.couponSunModel!.expirationDate!.stime.toString()) * | ||
| 249 | + 1000); | ||
| 250 | + DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch( | ||
| 251 | + int.parse(widget.couponSunModel!.expirationDate!.etime.toString()) * | ||
| 252 | + 1000); | ||
| 253 | + fromDate = '${dateTimes.year}' + | ||
| 254 | + '-${Utils.addZeroNumber(dateTimes.month)}' + | ||
| 255 | + '-${Utils.addZeroNumber(dateTimes.day)}'; //活动有效期开始时间 | ||
| 256 | + endDate = '${dateTimee.year}' + | ||
| 257 | + '-${Utils.addZeroNumber(dateTimee.month)}' + | ||
| 258 | + '-${Utils.addZeroNumber(dateTimee.day)}'; | ||
| 259 | + } | ||
| 260 | + if (widget.couponSunModel!.aexpiration != null) { | ||
| 261 | + validForeverCus = | ||
| 262 | + widget.couponSunModel!.aexpiration!.validForever == '1' | ||
| 263 | + ? true | ||
| 264 | + : false; | ||
| 265 | + if (widget.couponSunModel!.aexpiration!.stime != null) { | ||
| 266 | + fromToEndDateCus = true; | ||
| 267 | + DateTime dateTimes = DateTime.fromMillisecondsSinceEpoch( | ||
| 268 | + int.parse(widget.couponSunModel!.aexpiration!.stime.toString()) * | ||
| 269 | + 1000); | ||
| 270 | + DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch( | ||
| 271 | + int.parse(widget.couponSunModel!.aexpiration!.etime.toString()) * | ||
| 272 | + 1000); | ||
| 273 | + fromDateCus = '${dateTimes.year}' + | ||
| 274 | + '-${Utils.addZeroNumber(dateTimes.month)}' + | ||
| 275 | + '-${Utils.addZeroNumber(dateTimes.day)}'; //领取后有效期开始时间 | ||
| 276 | + endDateCus = '${dateTimee.year}' + | ||
| 277 | + '-${Utils.addZeroNumber(dateTimee.month)}' + | ||
| 278 | + '-${Utils.addZeroNumber(dateTimee.day)}'; | ||
| 279 | + } | ||
| 280 | + if (widget.couponSunModel!.aexpiration!.today != null && | ||
| 281 | + widget.couponSunModel!.aexpiration!.today != '') { | ||
| 282 | + todayCus = true; | ||
| 283 | + todayC.text = widget.couponSunModel!.aexpiration!.today ?? ''; | ||
| 284 | + } | ||
| 285 | + if (widget.couponSunModel!.aexpiration!.tomorrow != null && | ||
| 286 | + widget.couponSunModel!.aexpiration!.tomorrow != '') { | ||
| 287 | + tomorrowCus = true; | ||
| 288 | + tomorrowC.text = widget.couponSunModel!.aexpiration!.tomorrow ?? ''; | ||
| 289 | + } | ||
| 290 | + if (widget.couponSunModel!.aexpiration!.sday != null && | ||
| 291 | + widget.couponSunModel!.aexpiration!.sday != '') { | ||
| 292 | + fromToEndDayCus = true; | ||
| 293 | + fromDayC.text = widget.couponSunModel!.aexpiration!.sday ?? ''; | ||
| 294 | + endDayC.text = widget.couponSunModel!.aexpiration!.eday ?? ''; | ||
| 295 | + } | ||
| 296 | + } | ||
| 297 | + | ||
| 298 | +// bool validForever = false; | ||
| 299 | +// bool validForeverCus = false; | ||
| 300 | +// bool fromToEndDateCus = true; | ||
| 301 | +// bool todayCus = false; | ||
| 302 | +// bool tomorrowCus = false; | ||
| 303 | +// bool fromToEndDayCus = false; | ||
| 304 | +// String fromDateCus = '点击选择开始日期'; //领取后有效期开始时间 | ||
| 305 | +// String endDateCus = '点击选择结束日期'; //领取后有效期结束时间 | ||
| 306 | + | ||
| 307 | +// TextEditingController todayC = TextEditingController(); | ||
| 308 | +// TextEditingController tomorrowC = TextEditingController(); | ||
| 309 | + | ||
| 310 | +// TextEditingController fromDayC = TextEditingController(); | ||
| 311 | +// TextEditingController endDayC = TextEditingController(); | ||
| 312 | + | ||
| 313 | +// stime 开始日期 | ||
| 314 | +// etime 结束日期 | ||
| 315 | +// today 领券当日起天数 | ||
| 316 | +// tomorrow 领券次日起天数 | ||
| 317 | +// sday 领券后第几天的开始天数 | ||
| 318 | +// eday 领券后第几天的结束天数 | ||
| 242 | 319 | ||
| 243 | isSameDay = widget.couponSunModel!.arule!.isSameDay; | 320 | isSameDay = widget.couponSunModel!.arule!.isSameDay; |
| 244 | isAccumulation = widget.couponSunModel!.arule!.isAccumulation; | 321 | isAccumulation = widget.couponSunModel!.arule!.isAccumulation; |
| @@ -361,25 +438,61 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | @@ -361,25 +438,61 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | ||
| 361 | _createNewCoupon() async { | 438 | _createNewCoupon() async { |
| 362 | FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | 439 | FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 |
| 363 | 440 | ||
| 364 | - String from = fromDate + ' 00:00:00'; | ||
| 365 | - String end = endDate + ' 23:59:59'; | ||
| 366 | Map<String, String?> params = { | 441 | Map<String, String?> params = { |
| 367 | "uid": Provider.of<UserModel>(context, listen: false).user!.openid, | 442 | "uid": Provider.of<UserModel>(context, listen: false).user!.openid, |
| 368 | "aname": _couponNameEditControl.text.trim(), | 443 | "aname": _couponNameEditControl.text.trim(), |
| 369 | "desc": _couponRequireEditControl.text.trim(), | 444 | "desc": _couponRequireEditControl.text.trim(), |
| 370 | - "stime": fromDate == '点击选择' | ||
| 371 | - ? "" | ||
| 372 | - : '${(DateUtil.getDateMsByTimeStr(from)! / 1000).floor()}', | ||
| 373 | - "etime": endDate == '点击选择' | ||
| 374 | - ? '' | ||
| 375 | - : '${(DateUtil.getDateMsByTimeStr(end)! / 1000).floor()}', | 445 | + // 'stime': fromDate == '点击选择开始日期' |
| 446 | + // ? "" | ||
| 447 | + // : '${(DateUtil.getDateMsByTimeStr('${fromDate} 00:00:00')! / 1000).floor()}', | ||
| 448 | + // 'etime': endDate == '点击选择结束日期' | ||
| 449 | + // ? '' | ||
| 450 | + // : '${(DateUtil.getDateMsByTimeStr('${endDate} 23:59:59')! / 1000).floor()}', | ||
| 376 | "explain": _couponExplainEditControl.text, | 451 | "explain": _couponExplainEditControl.text, |
| 377 | "is_open": swichState ? "1" : "0", | 452 | "is_open": swichState ? "1" : "0", |
| 378 | "status": swichState ? "1" : "0", | 453 | "status": swichState ? "1" : "0", |
| 379 | 'is_type': widget.isMine ? "3" : "4" | 454 | 'is_type': widget.isMine ? "3" : "4" |
| 380 | }; | 455 | }; |
| 381 | 456 | ||
| 382 | - params['aexpiration'] = _limitDay.text; | 457 | + Map<String, String?> aexpiration = { |
| 458 | + 'valid_forever': validForeverCus ? '1' : '0', | ||
| 459 | + 'stime': fromToEndDateCus | ||
| 460 | + ? fromDateCus == '点击选择开始日期' | ||
| 461 | + ? "" | ||
| 462 | + : '${(DateUtil.getDateMsByTimeStr('${fromDateCus} 00:00:00')! / 1000).floor()}' | ||
| 463 | + : null, | ||
| 464 | + 'etime': fromToEndDateCus | ||
| 465 | + ? fromDate == '点击选择结束日期' | ||
| 466 | + ? "" | ||
| 467 | + : '${(DateUtil.getDateMsByTimeStr('${endDateCus} 23:59:59')! / 1000).floor()}' | ||
| 468 | + : null, | ||
| 469 | + 'today': todayCus ? todayC.text : null, | ||
| 470 | + 'tomorrow': tomorrowCus ? tomorrowC.text : null, | ||
| 471 | + 'sday': fromToEndDayCus ? fromDayC.text : null, | ||
| 472 | + 'eday': fromToEndDayCus ? endDayC.text : null | ||
| 473 | + }; | ||
| 474 | + | ||
| 475 | + params['aexpiration'] = jsonEncode(aexpiration); | ||
| 476 | + | ||
| 477 | + if (!validForever) { | ||
| 478 | + params['stime'] = | ||
| 479 | + '${(DateUtil.getDateMsByTimeStr('${fromDate} 00:00:00')! / 1000).floor()}'; | ||
| 480 | + params['etime'] = | ||
| 481 | + '${(DateUtil.getDateMsByTimeStr('${endDate} 23:59:59')! / 1000).floor()}'; | ||
| 482 | + } | ||
| 483 | + | ||
| 484 | + // aexpiration | ||
| 485 | + //活动有效期 | ||
| 486 | + Map<String, String> expirationDate = { | ||
| 487 | + 'valid_forever': validForever ? '1' : '0', | ||
| 488 | + 'stime': fromDate == '点击选择开始日期' | ||
| 489 | + ? "" | ||
| 490 | + : '${(DateUtil.getDateMsByTimeStr('${fromDate} 00:00:00')! / 1000).floor()}', | ||
| 491 | + 'etime': endDate == '点击选择结束日期' | ||
| 492 | + ? '' | ||
| 493 | + : '${(DateUtil.getDateMsByTimeStr('${endDate} 23:59:59')! / 1000).floor()}', | ||
| 494 | + }; | ||
| 495 | + params['expiration_date'] = jsonEncode(expirationDate); | ||
| 383 | 496 | ||
| 384 | // params['arule'] = ; | 497 | // params['arule'] = ; |
| 385 | params['price'] = | 498 | params['price'] = |
| @@ -1803,8 +1916,12 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | @@ -1803,8 +1916,12 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | ||
| 1803 | child: Text(fromDateCus, | 1916 | child: Text(fromDateCus, |
| 1804 | style: TextStyle( | 1917 | style: TextStyle( |
| 1805 | fontSize: font(14), | 1918 | fontSize: font(14), |
| 1806 | - color: MyColours | ||
| 1807 | - .color_999999)), | 1919 | + color: fromDateCus == |
| 1920 | + '点击选择开始日期' | ||
| 1921 | + ? MyColours | ||
| 1922 | + .color_999999 | ||
| 1923 | + : MyColours | ||
| 1924 | + .color_515151)), | ||
| 1808 | )), | 1925 | )), |
| 1809 | HEmptyView(10), | 1926 | HEmptyView(10), |
| 1810 | Text('至', | 1927 | Text('至', |
| @@ -1871,8 +1988,12 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | @@ -1871,8 +1988,12 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | ||
| 1871 | child: Text(endDateCus, | 1988 | child: Text(endDateCus, |
| 1872 | style: TextStyle( | 1989 | style: TextStyle( |
| 1873 | fontSize: font(14), | 1990 | fontSize: font(14), |
| 1874 | - color: MyColours | ||
| 1875 | - .color_999999)), | 1991 | + color: endDateCus == |
| 1992 | + '点击选择结束日期' | ||
| 1993 | + ? MyColours | ||
| 1994 | + .color_999999 | ||
| 1995 | + : MyColours | ||
| 1996 | + .color_515151)), | ||
| 1876 | )), | 1997 | )), |
| 1877 | ], | 1998 | ], |
| 1878 | )), | 1999 | )), |
| @@ -2647,11 +2768,11 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | @@ -2647,11 +2768,11 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | ||
| 2647 | Utils.showToast('请输入领券后第几天至第几天可用的结束天数!'); | 2768 | Utils.showToast('请输入领券后第几天至第几天可用的结束天数!'); |
| 2648 | return; | 2769 | return; |
| 2649 | } | 2770 | } |
| 2650 | - if(int.parse(endDayC.text.trim()) < int.parse(fromDayC.text.trim())){ | ||
| 2651 | - Utils.showToast('领券后第几天至第几天可用的结束天数须大于开始天数!'); | 2771 | + if (int.parse(endDayC.text.trim()) < |
| 2772 | + int.parse(fromDayC.text.trim())) { | ||
| 2773 | + Utils.showToast('领券后第几天至第几天可用的结束天数须大于开始天数!'); | ||
| 2652 | return; | 2774 | return; |
| 2653 | } | 2775 | } |
| 2654 | - | ||
| 2655 | } | 2776 | } |
| 2656 | 2777 | ||
| 2657 | // if (_limitDay.text.trim().length == 0) { | 2778 | // if (_limitDay.text.trim().length == 0) { |
| @@ -60,7 +60,7 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver { | @@ -60,7 +60,7 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver { | ||
| 60 | late CreateStoreModel createStoreModel; | 60 | late CreateStoreModel createStoreModel; |
| 61 | Fluwx fluwx = Fluwx(); | 61 | Fluwx fluwx = Fluwx(); |
| 62 | 62 | ||
| 63 | - late Function(WeChatResponse) responseListener; | 63 | + Function(WeChatResponse)? responseListener; |
| 64 | 64 | ||
| 65 | @override | 65 | @override |
| 66 | void initState() { | 66 | void initState() { |
| @@ -88,7 +88,10 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver { | @@ -88,7 +88,10 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver { | ||
| 88 | @override | 88 | @override |
| 89 | void dispose() { | 89 | void dispose() { |
| 90 | super.dispose(); | 90 | super.dispose(); |
| 91 | - fluwx.removeSubscriber(responseListener); | 91 | + if(responseListener != null){ |
| 92 | + fluwx.removeSubscriber(responseListener!); | ||
| 93 | + } | ||
| 94 | + | ||
| 92 | 95 | ||
| 93 | WidgetsBinding.instance.removeObserver(this); | 96 | WidgetsBinding.instance.removeObserver(this); |
| 94 | } | 97 | } |
| @@ -193,7 +196,7 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver { | @@ -193,7 +196,7 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver { | ||
| 193 | // Utils.showToast(res.errStr??"登录失败,请稍后重试"); | 196 | // Utils.showToast(res.errStr??"登录失败,请稍后重试"); |
| 194 | } | 197 | } |
| 195 | }; | 198 | }; |
| 196 | - fluwx.addSubscriber(responseListener); | 199 | + fluwx.addSubscriber(responseListener!); |
| 197 | } | 200 | } |
| 198 | 201 | ||
| 199 | //获取用户信息 | 202 | //获取用户信息 |
| 1 | - | ||
| 2 | import 'dart:async'; | 1 | import 'dart:async'; |
| 3 | 2 | ||
| 4 | import 'package:flutter/material.dart'; | 3 | import 'package:flutter/material.dart'; |
| @@ -74,14 +73,14 @@ class _SmsTemplateSettingPageState extends State<SmsTemplateSettingPage> { | @@ -74,14 +73,14 @@ class _SmsTemplateSettingPageState extends State<SmsTemplateSettingPage> { | ||
| 74 | marketingCenterProvider.saiYouYunFixedData!.forEach((element) { | 73 | marketingCenterProvider.saiYouYunFixedData!.forEach((element) { |
| 75 | if (element.temp == widget.smsTemplate) { | 74 | if (element.temp == widget.smsTemplate) { |
| 76 | element.select = true; | 75 | element.select = true; |
| 77 | - controller.text = element.content??""; | 76 | + controller.text = element.content ?? ""; |
| 78 | } | 77 | } |
| 79 | }); | 78 | }); |
| 80 | } | 79 | } |
| 81 | marketingCenterProvider.notifyListeners(); | 80 | marketingCenterProvider.notifyListeners(); |
| 82 | } | 81 | } |
| 83 | 82 | ||
| 84 | - Future<bool> _getSaiYouYunChangeList() async { | 83 | + Future<bool> _getSaiYouYunChangeList() async { |
| 85 | bool sucess = await marketingCenterProvider.getSaiYouYunChangeList(context); | 84 | bool sucess = await marketingCenterProvider.getSaiYouYunChangeList(context); |
| 86 | if (sucess) { | 85 | if (sucess) { |
| 87 | if (widget.smsTemplate != null && widget.smsTemplate!.length > 0) { | 86 | if (widget.smsTemplate != null && widget.smsTemplate!.length > 0) { |
| @@ -106,38 +105,36 @@ class _SmsTemplateSettingPageState extends State<SmsTemplateSettingPage> { | @@ -106,38 +105,36 @@ class _SmsTemplateSettingPageState extends State<SmsTemplateSettingPage> { | ||
| 106 | } | 105 | } |
| 107 | 106 | ||
| 108 | _getData() async { | 107 | _getData() async { |
| 109 | - | ||
| 110 | - (bool, bool) result = await ( | ||
| 111 | - _getSmsChangeField(), _getSaiYouYunChangeList() | ||
| 112 | - ).wait; | 108 | + (bool, bool) result = |
| 109 | + await (_getSmsChangeField(), _getSaiYouYunChangeList()).wait; | ||
| 113 | 110 | ||
| 114 | if (result.$1 && result.$2) { | 111 | if (result.$1 && result.$2) { |
| 115 | - //成功 | ||
| 116 | - String? temp = widget.bookinginfo; | ||
| 117 | - marketingCenterProvider.smsChangeFieldData!.forEach((element) { | ||
| 118 | - int count = widget.bookinginfo!.split(element.code!).length - 1; | ||
| 119 | - | ||
| 120 | - element.times = count; | ||
| 121 | - if (temp!.contains(element.code!)) { | ||
| 122 | - temp = temp!.replaceAll(element.code!, element.show!); | ||
| 123 | - } | ||
| 124 | - }); | ||
| 125 | - // if (contentChangeStart.endsWith('\n')) { | ||
| 126 | - // print(temp); | ||
| 127 | - // String result = temp.substring(1, temp.length); | ||
| 128 | - // print(result); | ||
| 129 | - | ||
| 130 | - // controller.text = | ||
| 131 | - // temp.startsWith('\n') ? temp.substring(1, temp.length) : temp; | ||
| 132 | - // } | ||
| 133 | - controller.text = temp??""; | ||
| 134 | - print(controller.text); | ||
| 135 | - setState(() {}); | 112 | + //成功 |
| 113 | + String? temp = widget.bookinginfo; | ||
| 114 | + marketingCenterProvider.smsChangeFieldData!.forEach((element) { | ||
| 115 | + int count = widget.bookinginfo!.split(element.code!).length - 1; | ||
| 116 | + | ||
| 117 | + element.times = count; | ||
| 118 | + if (temp!.contains(element.code!)) { | ||
| 119 | + temp = temp!.replaceAll(element.code!, element.show!); | ||
| 120 | + } | ||
| 121 | + }); | ||
| 122 | + // if (contentChangeStart.endsWith('\n')) { | ||
| 123 | + // print(temp); | ||
| 124 | + // String result = temp.substring(1, temp.length); | ||
| 125 | + // print(result); | ||
| 126 | + | ||
| 127 | + // controller.text = | ||
| 128 | + // temp.startsWith('\n') ? temp.substring(1, temp.length) : temp; | ||
| 129 | + // } | ||
| 130 | + controller.text = temp ?? ""; | ||
| 131 | + print(controller.text); | ||
| 132 | + setState(() {}); | ||
| 136 | } | 133 | } |
| 137 | } | 134 | } |
| 138 | 135 | ||
| 139 | /// 获取可变模板允许配置字段 | 136 | /// 获取可变模板允许配置字段 |
| 140 | - Future<bool> _getSmsChangeField() async { | 137 | + Future<bool> _getSmsChangeField() async { |
| 141 | bool suceess = await marketingCenterProvider.getSmsChangeField(context); | 138 | bool suceess = await marketingCenterProvider.getSmsChangeField(context); |
| 142 | if (suceess) { | 139 | if (suceess) { |
| 143 | return true; | 140 | return true; |
| @@ -147,8 +144,7 @@ class _SmsTemplateSettingPageState extends State<SmsTemplateSettingPage> { | @@ -147,8 +144,7 @@ class _SmsTemplateSettingPageState extends State<SmsTemplateSettingPage> { | ||
| 147 | } | 144 | } |
| 148 | 145 | ||
| 149 | ///设置店铺短信可变模版 | 146 | ///设置店铺短信可变模版 |
| 150 | - _saveSaiYouYunChange(String text, | ||
| 151 | - {bool isShowLoading = true}) async { | 147 | + _saveSaiYouYunChange(String text, {bool isShowLoading = true}) async { |
| 152 | Map<String, String?> params = { | 148 | Map<String, String?> params = { |
| 153 | 'sid': Provider.of<UserModel>(context, listen: false).user!.sellerid, | 149 | 'sid': Provider.of<UserModel>(context, listen: false).user!.sellerid, |
| 154 | 'sms_code': smsSelectValue, | 150 | 'sms_code': smsSelectValue, |
| @@ -173,7 +169,7 @@ class _SmsTemplateSettingPageState extends State<SmsTemplateSettingPage> { | @@ -173,7 +169,7 @@ class _SmsTemplateSettingPageState extends State<SmsTemplateSettingPage> { | ||
| 173 | } | 169 | } |
| 174 | 170 | ||
| 175 | ///设置店铺短信固定模版 | 171 | ///设置店铺短信固定模版 |
| 176 | - Future <bool> _setTempleteSMS({bool isShowLoading = true}) async { | 172 | + Future<bool> _setTempleteSMS({bool isShowLoading = true}) async { |
| 177 | Map<String, String?> params = { | 173 | Map<String, String?> params = { |
| 178 | 'sid': Provider.of<UserModel>(context, listen: false).user!.sellerid, | 174 | 'sid': Provider.of<UserModel>(context, listen: false).user!.sellerid, |
| 179 | 'key': 'saiyouyun', | 175 | 'key': 'saiyouyun', |
| @@ -198,7 +194,7 @@ class _SmsTemplateSettingPageState extends State<SmsTemplateSettingPage> { | @@ -198,7 +194,7 @@ class _SmsTemplateSettingPageState extends State<SmsTemplateSettingPage> { | ||
| 198 | List<Widget> templateWidgets(String title, List<SaiYouYunSunModel> temData) { | 194 | List<Widget> templateWidgets(String title, List<SaiYouYunSunModel> temData) { |
| 199 | List<Widget> data = []; | 195 | List<Widget> data = []; |
| 200 | for (var i = 0; i < temData.length; i++) { | 196 | for (var i = 0; i < temData.length; i++) { |
| 201 | - data.add(btnItem(temData[i].temp!, temData[i].select, onTap: () { | 197 | + data.add(btnItem('固定${i + 1}', temData[i].select, onTap: () { |
| 202 | // if (title == '固定模版') { | 198 | // if (title == '固定模版') { |
| 203 | canChange = false; | 199 | canChange = false; |
| 204 | marketingCenterProvider.saiYouYunFixedData!.forEach((element) { | 200 | marketingCenterProvider.saiYouYunFixedData!.forEach((element) { |
| @@ -239,7 +235,7 @@ class _SmsTemplateSettingPageState extends State<SmsTemplateSettingPage> { | @@ -239,7 +235,7 @@ class _SmsTemplateSettingPageState extends State<SmsTemplateSettingPage> { | ||
| 239 | String title, List<SaiYouYunChangeSunModel> temData) { | 235 | String title, List<SaiYouYunChangeSunModel> temData) { |
| 240 | List<Widget> data = []; | 236 | List<Widget> data = []; |
| 241 | for (var i = 0; i < temData.length; i++) { | 237 | for (var i = 0; i < temData.length; i++) { |
| 242 | - data.add(btnItem(temData[i].temp!, temData[i].select, onTap: () { | 238 | + data.add(btnItem('自定义${i + 1}', temData[i].select, onTap: () { |
| 243 | // if (!canChange) { | 239 | // if (!canChange) { |
| 244 | //从固定模版变更过来的,清空文本框内容 | 240 | //从固定模版变更过来的,清空文本框内容 |
| 245 | controller.text = temData[i].now == null | 241 | controller.text = temData[i].now == null |
| @@ -284,8 +280,9 @@ class _SmsTemplateSettingPageState extends State<SmsTemplateSettingPage> { | @@ -284,8 +280,9 @@ class _SmsTemplateSettingPageState extends State<SmsTemplateSettingPage> { | ||
| 284 | for (var i = 0; | 280 | for (var i = 0; |
| 285 | i < marketingCenterProvider.smsChangeFieldData!.length; | 281 | i < marketingCenterProvider.smsChangeFieldData!.length; |
| 286 | i++) { | 282 | i++) { |
| 287 | - data.add(btnItem(marketingCenterProvider.smsChangeFieldData![i].name!, true, | ||
| 288 | - onTap: () { | 283 | + data.add( |
| 284 | + btnItem(marketingCenterProvider.smsChangeFieldData![i].name!, true, | ||
| 285 | + onTap: () { | ||
| 289 | marketingCenterProvider.smsChangeFieldData![i].times++; | 286 | marketingCenterProvider.smsChangeFieldData![i].times++; |
| 290 | print(controller.text); | 287 | print(controller.text); |
| 291 | 288 | ||
| @@ -295,7 +292,7 @@ class _SmsTemplateSettingPageState extends State<SmsTemplateSettingPage> { | @@ -295,7 +292,7 @@ class _SmsTemplateSettingPageState extends State<SmsTemplateSettingPage> { | ||
| 295 | if (cursorPosition != -1) { | 292 | if (cursorPosition != -1) { |
| 296 | // 插入文本 | 293 | // 插入文本 |
| 297 | controller.text = controller.text.substring(0, cursorPosition) + | 294 | controller.text = controller.text.substring(0, cursorPosition) + |
| 298 | - (marketingCenterProvider.smsChangeFieldData![i].show??"") + | 295 | + (marketingCenterProvider.smsChangeFieldData![i].show ?? "") + |
| 299 | controller.text.substring(cursorPosition); | 296 | controller.text.substring(cursorPosition); |
| 300 | 297 | ||
| 301 | print(controller.text); | 298 | print(controller.text); |
| @@ -310,7 +307,8 @@ class _SmsTemplateSettingPageState extends State<SmsTemplateSettingPage> { | @@ -310,7 +307,8 @@ class _SmsTemplateSettingPageState extends State<SmsTemplateSettingPage> { | ||
| 310 | // cursorPosition = _cursorPosition; | 307 | // cursorPosition = _cursorPosition; |
| 311 | }); | 308 | }); |
| 312 | } else { | 309 | } else { |
| 313 | - controller.text += marketingCenterProvider.smsChangeFieldData![i].show!; | 310 | + controller.text += |
| 311 | + marketingCenterProvider.smsChangeFieldData![i].show!; | ||
| 314 | } | 312 | } |
| 315 | })); | 313 | })); |
| 316 | } | 314 | } |
| @@ -135,6 +135,8 @@ class MarketingCenterProvider extends ChangeNotifier { | @@ -135,6 +135,8 @@ class MarketingCenterProvider extends ChangeNotifier { | ||
| 135 | saiYouYunFixedData = SaiYouYunModel.fromJson( | 135 | saiYouYunFixedData = SaiYouYunModel.fromJson( |
| 136 | baseResp.responseData as Map<String, dynamic>) | 136 | baseResp.responseData as Map<String, dynamic>) |
| 137 | .data; | 137 | .data; |
| 138 | + | ||
| 139 | + | ||
| 138 | // if (saiYouYunFixedData.length > 0) { | 140 | // if (saiYouYunFixedData.length > 0) { |
| 139 | // saiYouYunFixedData[0].select = true; | 141 | // saiYouYunFixedData[0].select = true; |
| 140 | // } | 142 | // } |
-
Please register or login to post a comment