Commit 7c161ef9c6a9a14aa2fdf5f06fdf5294da8766b7

Authored by wdn127929
1 parent df3b7056

免费付费

import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:one_key/models/filter_btn_model.dart';
import 'package:one_key/models/upload_img_model.dart';
... ... @@ -88,9 +89,8 @@ class CouponSunModel extends Object {
@JsonKey(name: 'use')
CouponUse use;
@JsonKey(name: 'arule')
Arule arule;
@JsonKey(name: 'arule')
Arule arule;
@JsonKey(name: 'exp_date')
ExpDate expDate;
... ... @@ -110,12 +110,17 @@ class CouponSunModel extends Object {
@JsonKey(name: 'aexpiration')
String aexpiration;
@JsonKey(name: 'number')
int number;
// arule 券使用和分享规则 领取后有效天数
bool isCheck = false;
bool showText = false;
bool isMarking = false;
TextEditingController numberC = TextEditingController(text: '0');
CouponSunModel(
this.id,
this.uid,
... ... @@ -142,7 +147,8 @@ class CouponSunModel extends Object {
this.grantNum,
this.urllink,
this.liteQrcode,
this.aexpiration);
this.aexpiration,
this.number);
factory CouponSunModel.fromJson(Map<String, dynamic> srcJson) =>
_$CouponSunModelFromJson(srcJson);
... ...
... ... @@ -26,51 +26,51 @@ Map<String, dynamic> _$CouponModelToJson(CouponModel instance) =>
CouponSunModel _$CouponSunModelFromJson(Map<String, dynamic> json) {
return CouponSunModel(
json['id'] as String,
json['uid'] as String,
json['aname'] as String,
json['desc'] as String,
json['stime'] as String,
json['etime'] as String,
json['explain'] as String,
json['status'] as String,
json['cdate'] as String,
json['receive_num'] as String,
json['use_num'] as String,
json['nickname'] as String,
json['uid_list'] as String,
json['is_examine'] as String,
json['is_type'] as String,
json['is_open'] as String,
json['is_open'] == "1" ? true : false,
json['price'] as String,
json['use'] == null
? null
: (json['use'] is String)
? CouponUse.fromJson(jsonDecode(json['use']))
: (json['use'] is Map)
? CouponUse.fromJson(json['use'])
: null,
json['arule'] == null
? null
: (json['arule'] is String)
? Arule.fromJson(jsonDecode(json['arule']))
: (json['arule'] is Map)
? Arule.fromJson(json['arule'])
: null,
json['exp_date'] == null
? null
: (json['exp_date'] is String)
? ExpDate.fromJson(jsonDecode(json['exp_date']))
: (json['exp_date'] is Map)
? ExpDate.fromJson(json['exp_date'])
: null,
json['nick_name'] as String,
json['grant_num'] as String,
json['urllink'] as String,
json['lite_qrcode'] as String,
json['aexpiration'] as String,
);
json['id'] as String,
json['uid'] as String,
json['aname'] as String,
json['desc'] as String,
json['stime'] as String,
json['etime'] as String,
json['explain'] as String,
json['status'] as String,
json['cdate'] as String,
json['receive_num'] as String,
json['use_num'] as String,
json['nickname'] as String,
json['uid_list'] as String,
json['is_examine'] as String,
json['is_type'] as String,
json['is_open'] as String,
json['is_open'] == "1" ? true : false,
json['price'] as String,
json['use'] == null
? null
: (json['use'] is String)
? CouponUse.fromJson(jsonDecode(json['use']))
: (json['use'] is Map)
? CouponUse.fromJson(json['use'])
: null,
json['arule'] == null
? null
: (json['arule'] is String)
? Arule.fromJson(jsonDecode(json['arule']))
: (json['arule'] is Map)
? Arule.fromJson(json['arule'])
: null,
json['exp_date'] == null
? null
: (json['exp_date'] is String)
? ExpDate.fromJson(jsonDecode(json['exp_date']))
: (json['exp_date'] is Map)
? ExpDate.fromJson(json['exp_date'])
: null,
json['nick_name'] as String,
json['grant_num'] as String,
json['urllink'] as String,
json['lite_qrcode'] as String,
json['aexpiration'] as String,
json['number'] ?? 0 as int);
}
Map<String, dynamic> _$CouponSunModelToJson(CouponSunModel instance) =>
... ... @@ -100,7 +100,8 @@ Map<String, dynamic> _$CouponSunModelToJson(CouponSunModel instance) =>
'grant_num': instance.grantNum,
'urllink': instance.urllink,
'lite_qrcode': instance.liteQrcode,
'aexpiration': instance.aexpiration
'aexpiration': instance.aexpiration,
'number': instance.number
};
CouponUse _$CouponUseFromJson(Map<String, dynamic> json) {
... ...
... ... @@ -5,11 +5,14 @@ import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:one_key/app.dart';
import 'package:one_key/constant/error.dart';
import 'package:one_key/net/http_url.dart';
import 'package:one_key/pages/my/contant_item_page.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/loading.dart';
import 'package:provider/provider.dart';
import '../constant/constant.dart';
import 'base_resp.dart';
/**
... ... @@ -378,7 +381,7 @@ class DioUtil {
// };
}
_dio.options.method = method;
_dio.options.baseUrl = 'http://xt04.colorcun.com/';
_dio.options.baseUrl = HttpUrl.server_address;
_dio.options.contentType = Headers.multipartFormDataContentType;
return options;
... ...
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/coupon_model.dart';
import 'package:one_key/provider/coupon_provider.dart';
... ... @@ -19,16 +20,17 @@ class CouponItemF extends StatefulWidget {
final bool showBtn;
final bool showCheck;
final bool radio;
CouponItemF(
{Key key,
this.from,
this.onPressed,
this.onPressedSwich,
this.couponSonModel,
this.showBtn = false,
this.showCheck = false,
this.radio = false})
: super(key: key);
CouponItemF({
Key key,
this.from,
this.onPressed,
this.onPressedSwich,
this.couponSonModel,
this.showBtn = false,
this.showCheck = false,
this.radio = false,
}) : super(key: key);
@override
_CouponItemFState createState() => _CouponItemFState();
... ... @@ -68,138 +70,141 @@ class _CouponItemFState extends State<CouponItemF> {
children: [
HEmptyView(20),
widget.from == 'select'
? Image.asset(
Utils.getImgPath(sunModel.isCheck
? widget.radio
? 'select_f'
: 'c_mul_select'
: widget.radio
? 'show_select_f'
: 'c_not_edit'),
width: w(20),
)
? InkWell(
onTap: widget.onPressed,
child: Image.asset(
Utils.getImgPath(sunModel.isCheck
? widget.radio
? 'c_mul_select'
: 'select_f'
: widget.radio
? 'c_not_edit'
: 'show_select_f'),
width: w(20),
))
: Container(),
Expanded(
child: InkWell(
onTap: widget.onPressed,
child: Container(
// width: ScreenUtil().setWidth(610),
margin: EdgeInsets.fromLTRB(
ScreenUtil().setWidth(20),
ScreenUtil().setWidth(0),
ScreenUtil().setWidth(40),
ScreenUtil().setWidth(0)),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
boxShadow: [
BoxShadow(
spreadRadius: ScreenUtil().setWidth(2),
color: Color.fromRGBO(0, 0, 0, 0.25),
offset: Offset(0, ScreenUtil().setWidth(8)),
blurRadius: ScreenUtil().setWidth(8))
],
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(16)),
child: Container(
// width: ScreenUtil().setWidth(610),
margin: EdgeInsets.fromLTRB(
ScreenUtil().setWidth(20),
ScreenUtil().setWidth(0),
ScreenUtil().setWidth(40),
ScreenUtil().setWidth(0)),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
boxShadow: [
BoxShadow(
spreadRadius: ScreenUtil().setWidth(2),
color: Color.fromRGBO(0, 0, 0, 0.25),
offset: Offset(0, ScreenUtil().setWidth(8)),
blurRadius: ScreenUtil().setWidth(8))
],
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(16)),
),
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: ScreenUtil().setWidth(40),
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(24)),
decoration: BoxDecoration(
color: widget.from == 'history'
? MyColours.color_BFC4D4
: widget.from == 'setting'
? MyColours.color_00A870
: notSelect
? sunModel.isType == '1' ||
sunModel.isType == '3' ||
sunModel.isType == '4'
? sunModel.isMarking
? MyColours.color_00A870
: MyColours.color_438E93
: MyColours.color_ED7B2F
: MyColours.color_999999,
borderRadius: BorderRadius.only(
topLeft:
Radius.circular(ScreenUtil().setWidth(16)),
topRight: Radius.circular(
ScreenUtil().setWidth(16)))),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
sunModel.isType == '1'
? sunModel.isExamine == '1'
? '店铺优惠券(核销)'
: '店铺优惠券'
: sunModel.isType == '2'
? '我的优惠券'
: sunModel.isType == '3'
? '免费代金券'
: '付费优惠券',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(24)),
),
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: ScreenUtil().setWidth(40),
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(24)),
decoration: BoxDecoration(
color: widget.from == 'history'
? MyColours.color_BFC4D4
: widget.from == 'setting'
? MyColours.color_00A870
: notSelect
? sunModel.isType == '1' ||
sunModel.isType ==
'3' ||
sunModel.isType == '4'
? sunModel.isMarking
? MyColours.color_00A870
: MyColours.color_438E93
: MyColours.color_ED7B2F
: MyColours.color_999999,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(
ScreenUtil().setWidth(16)),
topRight: Radius.circular(
ScreenUtil().setWidth(16)))),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
sunModel.isType == '1'
? sunModel.isExamine == '1'
? '店铺优惠券(核销)'
: '店铺优惠券'
: sunModel.isType == '2'
? '我的优惠券'
: sunModel.isType == '3'
? '免费代金券'
: '付费优惠券',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(24)),
),
InkWell(
onTap: widget.onPressedSwich,
child: Text(
sunModel.isType == '1'
? sunModel.isExamine == '1'
? '被领取:${sunModel.receiveNum}张 已核销:${sunModel.useNum}张'
: '创建人:${sunModel.nickname ?? sunModel.uid} 被领取:${sunModel.receiveNum}张'
: sunModel.isType == '2'
? '被领取:${sunModel.receiveNum}张'
: '被领取:${sunModel.receiveNum}张 已核销:${sunModel.useNum}张',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_ffffff,
fontSize:
ScreenUtil().setSp(20))),
),
],
),
),
Container(
padding: EdgeInsets.fromLTRB(
ScreenUtil().setWidth(24 * 2),
ScreenUtil().setWidth(9 * 2),
ScreenUtil().setWidth(10),
ScreenUtil().setWidth(20)),
child: Column(
InkWell(
onTap: widget.onPressedSwich,
child: Text(
sunModel.isType == '1'
? sunModel.isExamine == '1'
? '被领取:${sunModel.receiveNum}张 已核销:${sunModel.useNum}张'
: '创建人:${sunModel.nickname ?? sunModel.uid} 被领取:${sunModel.receiveNum}张'
: sunModel.isType == '2'
? '被领取:${sunModel.receiveNum}张'
: sunModel.receiveNum == null
? ''
: '被领取:${sunModel.receiveNum}张 已核销:${sunModel.useNum}张',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(20))),
),
],
),
),
Container(
padding: EdgeInsets.fromLTRB(
ScreenUtil().setWidth(24 * 2),
ScreenUtil().setWidth(9 * 2),
ScreenUtil().setWidth(10),
ScreenUtil().setWidth(20)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: ScreenUtil().setWidth(232 * 2),
// width: ScreenUtil()
// .setWidth(232 * 2),
child: Container(
height: ScreenUtil().setWidth(25 * 2),
constraints: BoxConstraints(
maxWidth:
ScreenUtil().setWidth(190)),
child: Text(
sunModel.aname,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: widget.from == 'history'
? MyColours.color_BFC4D4
: notSelect
? MyColours.color_515151
: MyColours
.color_999999,
fontSize:
ScreenUtil().setSp(36),
fontWeight: FontWeight.bold),
),
)),
height: ScreenUtil().setWidth(25 * 2),
constraints: BoxConstraints(
maxWidth: ScreenUtil().setWidth(190)),
child: Text(
sunModel.aname,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: widget.from == 'history'
? MyColours.color_BFC4D4
: notSelect
? MyColours.color_515151
: MyColours.color_999999,
fontSize: ScreenUtil().setSp(36),
fontWeight: FontWeight.bold),
),
)),
Container(
height: ScreenUtil().setWidth(14 * 2),
width: ScreenUtil().setWidth(232 * 2),
... ... @@ -221,177 +226,298 @@ class _CouponItemFState extends State<CouponItemF> {
fontSize: ScreenUtil().setSp(20),
)),
),
VEmptyView(16),
(ObjectUtil.isNotEmpty(sunModel.stime) &&
sunModel.stime != '0') ||
(ObjectUtil.isNotEmpty(
sunModel.etime) &&
sunModel.etime != '0')
? Container(
child: Text(
'使用时间:${ObjectUtil.isNotEmpty(sunModel.stime) ? Utils.getDateStrFromJiekou(sunModel.stime) : '--'} 至 ${ObjectUtil.isNotEmpty(sunModel.etime) ? Utils.getDateStrFromJiekou(sunModel.etime) : '--'}',
style: TextStyle(
color: widget.from ==
'history'
? MyColours.color_BFC4D4
: MyColours
.color_999999,
fontSize: ScreenUtil()
.setSp(20))),
)
: Container(),
],
),
// widget.from == 'select'
// ? widget.showCheck
// ? Positioned(
// right: 0,
// top: ScreenUtil().setWidth(20),
// child: Image.asset(
// Utils.getImgPath(widget.couponSonModel.isCheck
// ? 'check_r'
// : 'check_un'),
// width: ScreenUtil().setWidth(40),
// height: ScreenUtil().setWidth(40),
// ))
// : Container()
// :
),
ObjectUtil.isNotEmpty(sunModel.explain)
? const MySeparator(
width: 3, color: MyColours.color_f3f3f3)
: SizedBox(),
ObjectUtil.isNotEmpty(sunModel.explain)
? InkWell(
onTap: () {
if (explainH > 19) {
setState(() {
widget.couponSonModel.showText =
!widget.couponSonModel.showText;
});
}
},
child: Container(
width: double.infinity,
)),
if (widget.from == 'select' &&
sunModel.isType == '3' &&
widget.radio)
Row(
children: [
InkWell(
onTap: () {
if (sunModel.number == 0) {
return;
}
sunModel.number--;
sunModel.numberC.text =
'${sunModel.number}';
},
child: Container(
height: w(40),
padding: EdgeInsets.symmetric(
horizontal: w(10)),
child: Image.asset(
Utils.getImgPath('plan_dish_minus'),
width: w(8),
),
),
),
Container(
// constraints: BoxConstraints(
// minWidth: w(34),
// ),
width: w(30),
decoration: BoxDecoration(
color: widget.from == 'history'
? MyColours.color_ffffff
: notSelect
? MyColours.color_ffffff
: MyColours.color_FAFAFA,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(
ScreenUtil()
.setWidth(20)),
bottomRight: Radius.circular(
ScreenUtil()
.setWidth(20)))),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
widget.couponSonModel.showText
? Container(
padding:
EdgeInsets.fromLTRB(
ScreenUtil()
.setWidth(
24 * 2),
ScreenUtil()
.setWidth(14),
ScreenUtil()
.setWidth(0),
ScreenUtil()
.setWidth(
14)),
width: ScreenUtil()
.screenWidth -
ScreenUtil()
.setWidth(92 * 2),
child: Text(
'说明:${sunModel.explain}',
maxLines: 5,
style: TextStyle(
color: widget
.from ==
'history'
? MyColours
.color_BFC4D4
: MyColours
.color_999999,
fontSize:
ScreenUtil()
.setSp(
20))),
)
: Container(
padding:
EdgeInsets.fromLTRB(
ScreenUtil()
.setWidth(
24 * 2),
ScreenUtil()
.setWidth(14),
ScreenUtil()
.setWidth(0),
ScreenUtil()
.setWidth(
14)),
width: ScreenUtil()
.screenWidth -
ScreenUtil().setWidth(
92 * 2) +
ScreenUtil()
.setWidth(20),
child: Text(
'说明:${sunModel.explain}',
maxLines: 1,
overflow:
TextOverflow.fade,
softWrap: false,
style: TextStyle(
color: widget
.from ==
'history'
? MyColours
.color_BFC4D4
: MyColours
.color_999999,
fontSize:
ScreenUtil()
.setSp(
20))),
),
Spacer(),
explainH > 19
? Container(
margin: EdgeInsets.only(
top: ScreenUtil()
.setWidth(10),
right: ScreenUtil()
.setWidth(16)),
child: Image.asset(
!widget.couponSonModel
.showText
? Utils.getImgPath(
'quan_down_f')
: Utils.getImgPath(
'quan_up_f'),
width: ScreenUtil()
.setWidth(28),
height: ScreenUtil()
.setWidth(28)),
)
: Container(),
HEmptyView(14)
borderRadius:
BorderRadius.circular(r(5)),
border: Border.all(
width: w(1),
color:
MyColours.color_438E93)),
// constraints: BoxConstraints(minWidth: w(20)),
child: TextField(
maxLines: 1,
controller: sunModel.numberC,
// focusNode: _focusNode,
// autofocus: true,
inputFormatters: [
FilteringTextInputFormatter.allow(
RegExp(r'[0-9]')),
],
style: TextStyle(
color: MyColours.color_438E93,
fontSize: font(11)),
textAlign: TextAlign.center,
// textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration(
hintText: "数量",
isCollapsed: true,
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: font(11),
),
// isCollapsed:
// true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
border: OutlineInputBorder(
borderSide: BorderSide.none),
contentPadding: EdgeInsets.only(
top: w(2), bottom: w(2)),
),
keyboardType:
TextInputType.numberWithOptions(
decimal: true),
textInputAction:
TextInputAction.done,
onChanged: (value) {
// bool isNumber = Utils.isNumeric(
// value); //判断输入的内容是否是数字
// if (!isNumber) {
// Utils.showToast('请输入数字');
// pNumC.text = '';
// return;
// } else {
if (value != null &&
value != '') {
if (int.parse(value) >
int.parse(
sunModel.grantNum)) {
Utils.showToast(
'最大数量限制为${sunModel.grantNum}');
sunModel.numberC.text =
sunModel.grantNum;
sunModel.number = int.parse(
sunModel.grantNum);
return;
}
sunModel.number =
int.parse(value);
}
// }
// setState(() {});
// _searchSellerLocation();
// customerProvider.searchData(value);
},
onEditingComplete: () {
FocusScope.of(context)
.requestFocus(
FocusNode()); //点击空白处隐藏键盘
// contantShowModel.searchData(
// contantShowModel.controller.text);
// _searchSellerLocation();
// _focusNode.unfocus();
},
)),
)
: Container(),
VEmptyView(32),
],
),
))),
InkWell(
onTap: () {
if (sunModel.number ==
int.parse(sunModel.grantNum)) {
Utils.showToast('已达到最大数量限制');
return;
}
sunModel.number++;
sunModel.numberC.text =
'${sunModel.number}';
},
child: Container(
height: w(40),
padding: EdgeInsets.only(
left: w(10), right: w(10)),
child: Image.asset(
Utils.getImgPath('plan_dish_add'),
width: w(8),
),
),
),
],
),
if (widget.from == 'setting' &&
sunModel.isType == '3')
Padding(
padding: EdgeInsets.only(right: w(20)),
child: Text(
'${sunModel.number}张',
style: TextStyle(
fontSize: font(12),
fontWeight: FontWeight.bold,
color: MyColours.color_438E93),
))
],
),
VEmptyView(16),
(ObjectUtil.isNotEmpty(sunModel.stime) &&
sunModel.stime != '0') ||
(ObjectUtil.isNotEmpty(sunModel.etime) &&
sunModel.etime != '0')
? Container(
child: Text(
'使用时间:${ObjectUtil.isNotEmpty(sunModel.stime) ? Utils.getDateStrFromJiekou(sunModel.stime) : '--'} 至 ${ObjectUtil.isNotEmpty(sunModel.etime) ? Utils.getDateStrFromJiekou(sunModel.etime) : '--'}',
style: TextStyle(
color: widget.from == 'history'
? MyColours.color_BFC4D4
: MyColours.color_999999,
fontSize: ScreenUtil().setSp(20))),
)
: Container(),
],
),
// widget.from == 'select'
// ? widget.showCheck
// ? Positioned(
// right: 0,
// top: ScreenUtil().setWidth(20),
// child: Image.asset(
// Utils.getImgPath(widget.couponSonModel.isCheck
// ? 'check_r'
// : 'check_un'),
// width: ScreenUtil().setWidth(40),
// height: ScreenUtil().setWidth(40),
// ))
// : Container()
// :
),
ObjectUtil.isNotEmpty(sunModel.explain)
? const MySeparator(
width: 3, color: MyColours.color_f3f3f3)
: SizedBox(),
ObjectUtil.isNotEmpty(sunModel.explain)
? InkWell(
onTap: () {
if (explainH > 19) {
setState(() {
widget.couponSonModel.showText =
!widget.couponSonModel.showText;
});
}
},
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: widget.from == 'history'
? MyColours.color_ffffff
: notSelect
? MyColours.color_ffffff
: MyColours.color_FAFAFA,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(
ScreenUtil().setWidth(20)),
bottomRight: Radius.circular(
ScreenUtil().setWidth(20)))),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
widget.couponSonModel.showText
? Container(
padding: EdgeInsets.fromLTRB(
ScreenUtil().setWidth(24 * 2),
ScreenUtil().setWidth(14),
ScreenUtil().setWidth(0),
ScreenUtil().setWidth(14)),
width: ScreenUtil().screenWidth -
ScreenUtil().setWidth(92 * 2),
child: Text(
'说明:${sunModel.explain}',
maxLines: 5,
style: TextStyle(
color: widget.from ==
'history'
? MyColours
.color_BFC4D4
: MyColours
.color_999999,
fontSize: ScreenUtil()
.setSp(20))),
)
: Container(
padding: EdgeInsets.fromLTRB(
ScreenUtil().setWidth(24 * 2),
ScreenUtil().setWidth(14),
ScreenUtil().setWidth(0),
ScreenUtil().setWidth(14)),
width: ScreenUtil().screenWidth -
ScreenUtil()
.setWidth(92 * 2) +
ScreenUtil().setWidth(20),
child: Text(
'说明:${sunModel.explain}',
maxLines: 1,
overflow: TextOverflow.fade,
softWrap: false,
style: TextStyle(
color: widget.from ==
'history'
? MyColours
.color_BFC4D4
: MyColours
.color_999999,
fontSize: ScreenUtil()
.setSp(20))),
),
Spacer(),
explainH > 19
? Container(
margin: EdgeInsets.only(
top:
ScreenUtil().setWidth(10),
right: ScreenUtil()
.setWidth(16)),
child: Image.asset(
!widget.couponSonModel
.showText
? Utils.getImgPath(
'quan_down_f')
: Utils.getImgPath(
'quan_up_f'),
width:
ScreenUtil().setWidth(28),
height: ScreenUtil()
.setWidth(28)),
)
: Container(),
HEmptyView(14)
],
)),
)
: Container(),
VEmptyView(32),
],
),
)),
],
),
Positioned(
... ...
... ... @@ -136,6 +136,10 @@ class _CouponSettingPageState extends State<CouponSettingPage> {
///优惠券设置
_setCouponShow() async {
List couponSelectFreeTemp = [];
couponSelectFree.forEach((element) {
couponSelectFreeTemp.add(element.toJson());
});
//接口
Map marketingData = {
// 'isTranspond': isTranspond ? '1' : '0', //转发同行客人
... ... @@ -150,7 +154,7 @@ class _CouponSettingPageState extends State<CouponSettingPage> {
'wecomle': welcome ?? '',
'logo': qiniuUrl,
'recharge_data': rechargeData,
// 'coupon_data_free': json.encode(couponDataList),
'coupon_data_free': couponSelectFreeTemp,
'coupon_data_pay': json.encode(couponSelectPay),
'is_comments': isComments ? '1' : '0',
'is_comments_coupon': isCommentsCoupon ? '1' : '0',
... ... @@ -226,6 +230,7 @@ class _CouponSettingPageState extends State<CouponSettingPage> {
///优惠券
Widget _markingCupon({
List<CouponSunModel> coupon,
VoidCallback onPressed,
bool select = false,
VoidCallback onPressedSelect,
... ... @@ -268,9 +273,9 @@ class _CouponSettingPageState extends State<CouponSettingPage> {
ListView.builder(
shrinkWrap: true,
controller: controller,
itemCount: couponSelectPay.length,
itemCount: coupon.length,
itemBuilder: (BuildContext context, int index) {
CouponSunModel couponData = couponSelectPay[index];
CouponSunModel couponData = coupon[index];
return CouponItemF(
from: 'setting',
couponSonModel: couponData,
... ... @@ -475,6 +480,7 @@ class _CouponSettingPageState extends State<CouponSettingPage> {
VEmptyView(24),
couponDataListPay != null && couponDataListPay.length > 0
? _markingCupon(
coupon: couponSelectPay,
select: isCouponPay,
onPressedSelect: () {
setState(() {
... ... @@ -502,6 +508,37 @@ class _CouponSettingPageState extends State<CouponSettingPage> {
select: false,
)
: SizedBox(),
VEmptyView(24),
couponDataListFree != null && couponDataListFree.length > 0
? _markingCupon(
coupon: couponSelectFree,
select: isCouponFree,
onPressedSelect: () {
setState(() {
isCouponFree = !isCouponFree;
});
},
onPressed: () async {
//切换活动
Map temp =
await NavigatorUtil.goMarkingCouponSelectPage(
context,
'3',
{'object': couponSelectFree});
if (temp != null && temp['coupon'] != null) {
couponSelectFree = temp['coupon'];
setState(() {});
}
})
: (couponDataListFree == null ||
couponDataListFree.length == 0)
? _markingItem(
'预订安排中免费赠送代金券',
'当前没有可用优惠券,请创建优惠券后再来尝试。',
select: false,
)
: SizedBox(),
],
),
),
... ...
... ... @@ -49,6 +49,26 @@ class _MarkingCouponSelectPageState extends State<MarkingCouponSelectPage> {
CouponProvider couponProvider;
List<CouponSunModel> selectDataList = [];
bool all = false;
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
// if (!couponProvider.hasModify) {
_couponNetworkData();
// } else {
// couponProvider.pageStateSelect = PageState.Success;
// // couponProvider.notifyListeners();
// }
});
}
@override
void dispose() {
super.dispose();
}
///获取优惠券列表数据(status == 1)
... ... @@ -74,145 +94,81 @@ class _MarkingCouponSelectPageState extends State<MarkingCouponSelectPage> {
for (var itemselect in widget.couponList) {
if (itemselect.id == item.id) {
item.isCheck = true;
item.number = itemselect.number;
item.numberC.text = item.number.toString();
selectDataList.add(item);
// break outerloop;
}
}
}
if (selectDataList.length == couponProvider.couponListSelect.length) {
all = true;
}
setState(() {});
}
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
// if (!couponProvider.hasModify) {
_couponNetworkData();
// } else {
// couponProvider.pageStateSelect = PageState.Success;
// // couponProvider.notifyListeners();
// }
});
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
couponProvider = Provider.of<CouponProvider>(context, listen: true);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
'选择优惠券',
onTap: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
},
),
body: Column(
children: [
Expanded(child: Consumer<CouponProvider>(
builder: (context, model, _) {
if (model.pageStateSelect != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateSelect,
callback: () {
_couponNetworkData();
// offset = 0;
// getMessage(showLoading: true);
},
emptyMsg: "暂时没有列表信息哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return EasyRefresh.custom(
controller: _controller,
shrinkWrap: true,
slivers: [
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return VEmptyView(40);
}, childCount: 1),
),
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return InkWell(
onTap: () {
//改这里 ******8
if (widget.mulSelect) {
couponProvider.couponListSelect[index].isCheck =
!couponProvider
.couponListSelect[index].isCheck;
if (couponProvider
.couponListSelect[index].isCheck) {
selectDataList.add(
couponProvider.couponListSelect[index]);
} else {
selectDataList.remove(
couponProvider.couponListSelect[index]);
}
} else {
couponProvider.couponListSelect
.forEach((element) {
element.isCheck = false;
});
selectDataList = [];
selectDataList.add(
couponProvider.couponListSelect[index]);
couponProvider.couponListSelect[index].isCheck =
true;
}
setState(() {});
},
// child: Row(
// children: [
// HEmptyView(30),
// !widget.hasModify
// ? Checkbox(
// value: couponProvider
// .couponListSelect[index].isCheck,
// checkColor: MyColours.color_ffffff,
// activeColor: MyColours.app_main,
// onChanged: (bool value) {},
// )
// : Container(),
// Image.asset(
// couponProvider.listData[index]['checked']
// ? 'assets/select.png'
// : 'assets/unselect.png',
// width: ScreenUtil().setWidth(44)),
child: CouponItemF(
from: 'select',
showCheck: true,
radio: false,
couponSonModel:
couponProvider.couponListSelect[index],
onPressed: () {
// bool old = couponProvider
// .couponListSelect[index].isCheck;
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
'选择优惠券',
onTap: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
},
),
body: Column(
children: [
Expanded(child: Consumer<CouponProvider>(
builder: (context, model, _) {
if (model.pageStateSelect != PageState.Success) {
return ExceptionPage(
pageState: model.pageStateSelect,
callback: () {
_couponNetworkData();
// offset = 0;
// getMessage(showLoading: true);
},
emptyMsg: "暂时没有列表信息哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return EasyRefresh.custom(
controller: _controller,
shrinkWrap: true,
slivers: [
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return VEmptyView(40);
}, childCount: 1),
),
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
CouponSunModel sunModel =
couponProvider.couponListSelect[index];
return InkWell(
onTap: () {
if (sunModel.isType != '3') {
//改这里 ******8
if (widget.mulSelect) {
couponProvider
.couponListSelect[index].isCheck =
!couponProvider
.couponListSelect[index].isCheck;
if (couponProvider
.couponListSelect[index].isCheck) {
selectDataList.add(couponProvider
.couponListSelect[index]);
sunModel.isCheck = !sunModel.isCheck;
if (sunModel.isCheck) {
selectDataList.add(sunModel);
} else {
selectDataList.remove(couponProvider
.couponListSelect[index]);
selectDataList.remove(sunModel);
}
if (couponProvider.couponListSelect
.every((element) => element.isCheck)) {
all = true;
} else {
all = false;
}
} else {
couponProvider.couponListSelect
... ... @@ -220,51 +176,156 @@ class _MarkingCouponSelectPageState extends State<MarkingCouponSelectPage> {
element.isCheck = false;
});
selectDataList = [];
selectDataList.add(
couponProvider.couponListSelect[index]);
couponProvider
.couponListSelect[index].isCheck = true;
selectDataList.add(sunModel);
sunModel.isCheck = true;
}
setState(() {});
}));
}, childCount: couponProvider.couponListSelect.length),
)
],
// onRefresh: () async {
// // offset = 0;
// // getMessage(showLoading: false);
// },
// onLoad: () async {
// // offset++;
// // getMessage(showLoading: false);
// },
);
}
},
)),
VEmptyView(20),
couponProvider.pageStateSelect == PageState.Success
? Container(
padding: EdgeInsets.only(
left: w(20), top: w(12), right: w(20), bottom: w(25)),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
Utils.getImgPath(true ? 'c_mul_select' : 'c_not_edit'),
width: ScreenUtil().setWidth(40),
),
HEmptyView(10),
Text(
'全选',
style: TextStyle(
fontSize: ScreenUtil().setWidth(32),
fontWeight: FontWeight.bold,
color: MyColours.color_000000),
),
HEmptyView(20),
Expanded(
child: RoundButton(
}
},
// child: Row(
// children: [
// HEmptyView(30),
// !widget.hasModify
// ? Checkbox(
// value: couponProvider
// .couponListSelect[index].isCheck,
// checkColor: MyColours.color_ffffff,
// activeColor: MyColours.app_main,
// onChanged: (bool value) {},
// )
// : Container(),
// Image.asset(
// couponProvider.listData[index]['checked']
// ? 'assets/select.png'
// : 'assets/unselect.png',
// width: ScreenUtil().setWidth(44)),
child: CouponItemF(
from: 'select',
showCheck: true,
radio: widget.mulSelect,
couponSonModel:
couponProvider.couponListSelect[index],
onPressed: () {
// bool old = couponProvider
// .couponListSelect[index].isCheck;
//改这里 ******8
if (widget.mulSelect) {
couponProvider
.couponListSelect[index].isCheck =
!couponProvider
.couponListSelect[index].isCheck;
if (couponProvider
.couponListSelect[index].isCheck) {
selectDataList.add(couponProvider
.couponListSelect[index]);
} else {
selectDataList.remove(couponProvider
.couponListSelect[index]);
}
if (couponProvider.couponListSelect.every(
(element) => element.isCheck)) {
all = true;
} else {
all = false;
}
} else {
couponProvider.couponListSelect
.forEach((element) {
element.isCheck = false;
});
selectDataList = [];
selectDataList.add(couponProvider
.couponListSelect[index]);
couponProvider.couponListSelect[index]
.isCheck = true;
}
setState(() {});
}));
}, childCount: couponProvider.couponListSelect.length),
)
],
// onRefresh: () async {
// // offset = 0;
// // getMessage(showLoading: false);
// },
// onLoad: () async {
// // offset++;
// // getMessage(showLoading: false);
// },
);
}
},
)),
VEmptyView(20),
if (couponProvider.pageStateSelect == PageState.Success)
widget.mulSelect
? Container(
padding: EdgeInsets.only(
left: w(20), top: w(12), right: w(20), bottom: w(25)),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
InkWell(
onTap: () {
all = !all;
if (all) {
selectDataList = [];
for (var item
in couponProvider.couponListSelect) {
item.isCheck = true;
selectDataList.add(item);
}
} else {
selectDataList = [];
for (var item
in couponProvider.couponListSelect) {
item.isCheck = false;
}
}
setState(() {});
},
child: Row(
children: [
Image.asset(
Utils.getImgPath(
all ? 'c_mul_select' : 'c_not_edit'),
width: ScreenUtil().setWidth(40),
),
HEmptyView(10),
Text(
'全选',
style: TextStyle(
fontSize: ScreenUtil().setWidth(32),
fontWeight: FontWeight.bold,
color: MyColours.color_000000),
),
HEmptyView(20),
],
)),
Expanded(
child: RoundButton(
onPressed: () async {
Map temp = {
'coupon': selectDataList,
};
if (Navigator.canPop(context)) {
Navigator.pop(context, temp);
}
},
text: '确定选择${selectDataList.length}个优惠券',
fontSize: 34,
isBold: false,
height: ScreenUtil().setWidth(80),
// width: double.infinity,
radius: ScreenUtil().setWidth(10),
)),
],
))
: Container(
padding: EdgeInsets.only(
left: w(20), top: w(12), right: w(20), bottom: w(25)),
child: RoundButton(
onPressed: () async {
Map temp = {
'coupon': selectDataList,
... ... @@ -273,18 +334,14 @@ class _MarkingCouponSelectPageState extends State<MarkingCouponSelectPage> {
Navigator.pop(context, temp);
}
},
text: '确定选择${selectDataList.length}个优惠券',
text: '确定',
fontSize: 34,
isBold: false,
height: ScreenUtil().setWidth(80),
// width: double.infinity,
width: double.infinity,
radius: ScreenUtil().setWidth(10),
)),
],
))
: Container()
],
),
);
))
],
));
}
}
... ...
import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/recharge_list_model.dart';
... ... @@ -22,6 +23,7 @@ import '../net/base_resp.dart';
import '../net/dio_util.dart';
import '../net/http_url.dart';
import '../utils/utils.dart';
import '../widgets/loading.dart';
import 'choose_table_model.dart';
class MarketingCenterProvider extends ChangeNotifier {
... ... @@ -33,7 +35,7 @@ class MarketingCenterProvider extends ChangeNotifier {
PageState pageStateBookInfo = PageState.Loading;
PageState pageStateThemeHome = PageState.Loading;
PageState pageStateSetting = PageState.Loading;
PageState pageStateSettingMini = PageState.Loading;
List<RechargeListSunModel> rechargeList = [];
... ... @@ -60,7 +62,7 @@ class MarketingCenterProvider extends ChangeNotifier {
List<ColorListModel> colors = [];
bool isThemeColor = true; //当前颜色不可用
bool isThemeTitle = true; //当前主题不可用
List<TitlteTypeSunModel> titleTypeS = [];
List<TitlteTypeSunModel> titleTypeS = [];
// 获取预订详情自定义图文
... ... @@ -172,70 +174,31 @@ class MarketingCenterProvider extends ChangeNotifier {
return false;
}
///模版标题样式可选数据
///模版标题样式可选数据
Future<bool> getTitleTypeData(BuildContext context,
{bool showLoading = true}) async {
// Map<String, String> params = {
// 'sid': Provider.of<UserModel>(context, listen: false).user.sellerid
// };
Map <String,dynamic>data = {
"ret": 200,
"data": [
{
"id": "1",
"url": "https://nosqn.colorcun.com/module_title_1.png"
},
{
"id": "2",
"url": "https://nosqn.colorcun.com/module_title_2.png"
},
{
"id": "3",
"url": "https://nosqn.colorcun.com/module_title_3.png"
},
{
"id": "4",
"url": "https://nosqn.colorcun.com/module_title_4.png"
},
{
"id": "5",
"url": "https://nosqn.colorcun.com/module_title_5.png"
},
{
"id": "6",
"url": "https://nosqn.colorcun.com/module_title_6.png"
},
{
"id": "7",
"url": "https://nosqn.colorcun.com/module_title_7.png"
},
{
"id": "8",
"url": "https://nosqn.colorcun.com/module_title_8.png"
},
{
"id": "9",
"url": "https://nosqn.colorcun.com/module_title_9.png"
},
{
"id": "10",
"url": "https://nosqn.colorcun.com/module_title_10.png"
},
{
"id": "11",
"url": "https://nosqn.colorcun.com/module_title_11.png"
},
{
"id": "12",
"url": "https://nosqn.colorcun.com/module_title_12.png"
},
{
"id": "13",
"url": "https://nosqn.colorcun.com/module_title_13.png"
}
],
"msg": ""
};
Map<String, dynamic> data = {
"ret": 200,
"data": [
{"id": "1", "url": "https://nosqn.colorcun.com/module_title_1.png"},
{"id": "2", "url": "https://nosqn.colorcun.com/module_title_2.png"},
{"id": "3", "url": "https://nosqn.colorcun.com/module_title_3.png"},
{"id": "4", "url": "https://nosqn.colorcun.com/module_title_4.png"},
{"id": "5", "url": "https://nosqn.colorcun.com/module_title_5.png"},
{"id": "6", "url": "https://nosqn.colorcun.com/module_title_6.png"},
{"id": "7", "url": "https://nosqn.colorcun.com/module_title_7.png"},
{"id": "8", "url": "https://nosqn.colorcun.com/module_title_8.png"},
{"id": "9", "url": "https://nosqn.colorcun.com/module_title_9.png"},
{"id": "10", "url": "https://nosqn.colorcun.com/module_title_10.png"},
{"id": "11", "url": "https://nosqn.colorcun.com/module_title_11.png"},
{"id": "12", "url": "https://nosqn.colorcun.com/module_title_12.png"},
{"id": "13", "url": "https://nosqn.colorcun.com/module_title_13.png"}
],
"msg": ""
};
titleTypeS = TitlteTypeModel.fromJson(data).data;
// BaseResp<dynamic> baseResp = await DioUtil()
// .request<dynamic>(context, Method.post, HttpUrl.get_colors_data,
... ... @@ -346,13 +309,13 @@ class MarketingCenterProvider extends ChangeNotifier {
// 获取商家订座配置
Future<bool> getDzSellerConf(BuildContext context,
{bool showLoading = true,bool selfDismiss = false}) async {
{bool showLoading = true, bool selfDismiss = false}) async {
Map<String, String> params = {
'sid': Provider.of<UserModel>(context, listen: false).user.sellerid
};
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.post, HttpUrl.get_dz_seller_conf,
data: params, showLoading: showLoading,selfDismiss: selfDismiss)
data: params, showLoading: showLoading, selfDismiss: selfDismiss)
.catchError((error) {
print(error.toString());
Utils.showToast('请求失败,请重试');
... ... @@ -411,24 +374,31 @@ class MarketingCenterProvider extends ChangeNotifier {
Future<bool> setSellerTemplateConf(
BuildContext context, Map<String, String> params,
{bool showLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(
context, Method.post, HttpUrl.set_seller_template_conf,
data: params, showLoading: showLoading)
.catchError((error) {
print(error.toString());
Utils.showToast('商家设置预订安排模板页面失败,请重试');
return false;
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data == 0 || baseResp.data == 1) {
Loading.showLoading(context);
FormData formData = FormData.fromMap(params);
Response response = await DioUtil.getInstance().getDio().post(
'${HttpUrl.server_address}${HttpUrl.set_seller_template_conf}',
data: formData);
Loading.hideLoading(context);
// BaseResp<dynamic> baseResp = await DioUtil()
// .request<dynamic>(
// context, Method.post, HttpUrl.set_seller_template_conf,
// data: params, showLoading: showLoading)
// .catchError((error) {
// print(error.toString());
// Utils.showToast('商家设置预订安排模板页面失败,请重试');
// return false;
// });
if (response.data['ret'] == 200) {
if (response.data['data'] == 0 || response.data['data'] == 1) {
return true;
} else {
Utils.showToast('商家设置预订安排模板页面失败,请重试');
}
} else {
Utils.showToast(baseResp.msg ?? '商家设置预订安排模板页面失败,请重试');
Utils.showToast('商家设置预订安排模板页面失败,请重试');
}
return false;
}
... ... @@ -456,7 +426,7 @@ class MarketingCenterProvider extends ChangeNotifier {
return false;
}
// 设置订座商家配置信息
// 设置订座商家配置信息
Future<bool> setConfings(BuildContext context, Map<String, String> params,
{bool showLoading = true, bool needToast = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
... ...
... ... @@ -206,7 +206,7 @@ class PlanDishProvider extends ChangeNotifier {
Loading.showLoading(context);
FormData formData = FormData.fromMap(params);
Response response = await DioUtil.getInstance().getDio().post(
'http://xt04.colorcun.com/${HttpUrl.set_plan_cook}',
'${HttpUrl.server_address}${HttpUrl.set_plan_cook}',
data: formData);
Loading.hideLoading(context);
... ... @@ -242,7 +242,7 @@ class PlanDishProvider extends ChangeNotifier {
Loading.showLoading(context);
FormData formData = FormData.fromMap(params);
Response response = await DioUtil.getInstance().getDio().post(
'http://xt04.colorcun.com/${HttpUrl.set_plan_cook_by_reserve}',
'${HttpUrl.server_address}${HttpUrl.set_plan_cook_by_reserve}',
data: formData);
Loading.hideLoading(context);
... ...