Commit 2f1c0d647b388d72c3452878b33f7219075b8cd8

Authored by weixin_45529955
1 parent 0a8bad06

过期优惠券点击进入详情,可复用

... ... @@ -31,7 +31,9 @@ import '../online_check/photo_view_wiget.dart';
class CouponDetailPage extends StatefulWidget {
final CouponSunModel? couponSunModel;
final String? idstr;
CouponDetailPage({Key? key, this.couponSunModel, this.idstr})
final bool isHistory;
CouponDetailPage(
{Key? key, this.couponSunModel, this.idstr, this.isHistory = false})
: super(key: key);
@override
... ... @@ -79,8 +81,8 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
"uid": Provider.of<UserModel>(context, listen: false).user!.openid,
};
bool success =
await _baseIndoProvider.getCustomerActivityBaseinfo(context, params,isShowLoading: false);
bool success = await _baseIndoProvider
.getCustomerActivityBaseinfo(context, params, isShowLoading: false);
if (success) {
managerName = _baseIndoProvider.baseInfoSunModel!.name;
}
... ... @@ -109,7 +111,8 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
}
///时间选择
Widget _select(String title, String hintText, GestureTapCallback onTap,{bool canEdit = false}) {
Widget _select(String title, String hintText, GestureTapCallback onTap,
{bool canEdit = false}) {
return InkWell(
onTap: onTap,
child: Container(
... ... @@ -140,7 +143,8 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
))),
HEmptyView(20),
Image.asset(
Utils.getImgPath(canEdit ? 'enter_store_arrow_r':'arrow_right_new'),
Utils.getImgPath(
canEdit ? 'enter_store_arrow_r' : 'arrow_right_new'),
width: ScreenUtil().setWidth(20),
),
// HEmptyView(32),
... ... @@ -800,9 +804,11 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
Utils.getAuthority(context, '优惠券详情-编辑发放人')
? _select('谁可以发放', nickNameShow,canEdit: true,
() async {
Utils.getAuthority(
context, '优惠券详情-编辑发放人') &&
!widget.isHistory
? _select('谁可以发放', nickNameShow,
canEdit: true, () async {
Map? temp = await NavigatorUtil
.goCouponToPersonnalPage(
context,
... ... @@ -921,7 +927,8 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (couponProvider.couponSunModel!.liteQrcode != null)
if (couponProvider.couponSunModel!.liteQrcode != null &&
!widget.isHistory)
RoundButton(
text: '生成海报',
width: w(100),
... ... @@ -986,6 +993,7 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
//复用,跳转至编辑页面
dynamic needRefresh =
await NavigatorUtil.goCouponEditPage(context,
replace: widget.isHistory ? true : false,
isMine: couponProvider
.couponSunModel!.isType ==
'1'
... ... @@ -995,7 +1003,7 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
couponProvider.couponSunModel);
if (needRefresh != null && needRefresh) {
if (Navigator.canPop(context)) {
Navigator.pop(context);
Navigator.pop(context, true);
}
}
} else {
... ... @@ -1011,47 +1019,36 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
couponSunModel:
couponProvider.couponSunModel);
if (needRefresh != null && needRefresh) {
if (Navigator.canPop(context)) {
Navigator.pop(context);
if (mounted) {
if (Navigator.canPop(context)) {
Navigator.pop(context, true);
}
}
}
}
},
),
HEmptyView(30),
Expanded(
child: RoundButton(
text: '分享给客户',
height: ScreenUtil().setWidth(80),
radius: ScreenUtil().setWidth(14),
gradientStart: MyColours.color_438E93,
gradientEnd: MyColours.color_438E93,
isBold: false,
fontSize: 28,
onPressed: () {
if (couponProvider.couponSunModel!.status != '1') {
Utils.showToast('请先启用优惠券后再进行操作!');
return;
}
if (couponProvider.couponSunModel!.status == '1') {
if (couponProvider.couponSunModel!.isType ==
'3') {
Utils.goShareBuyCouponToWeChat(
context,
widget.idstr,
couponProvider.couponSunModel!.isType,
couponProvider.couponSunModel!.use,
couponProvider.couponSunModel);
} else {
// 谁可以发放
// 可以发放的才能分享
if (couponProvider.couponSunModel!.uidList!
.split(',')
.contains(Provider.of<UserModel>(context,
listen: false)
.user!
.openid)) {
//包含当前登录人
if (!widget.isHistory)
Expanded(
child: RoundButton(
text: '分享给客户',
height: ScreenUtil().setWidth(80),
radius: ScreenUtil().setWidth(14),
gradientStart: MyColours.color_438E93,
gradientEnd: MyColours.color_438E93,
isBold: false,
fontSize: 28,
onPressed: () {
if (couponProvider.couponSunModel!.status !=
'1') {
Utils.showToast('请先启用优惠券后再进行操作!');
return;
}
if (couponProvider.couponSunModel!.status ==
'1') {
if (couponProvider.couponSunModel!.isType ==
'3') {
Utils.goShareBuyCouponToWeChat(
context,
widget.idstr,
... ... @@ -1059,23 +1056,39 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
couponProvider.couponSunModel!.use,
couponProvider.couponSunModel);
} else {
Utils.showToast('您没有此权限');
// 谁可以发放
// 可以发放的才能分享
if (couponProvider.couponSunModel!.uidList!
.split(',')
.contains(Provider.of<UserModel>(context,
listen: false)
.user!
.openid)) {
//包含当前登录人
Utils.goShareBuyCouponToWeChat(
context,
widget.idstr,
couponProvider.couponSunModel!.isType,
couponProvider.couponSunModel!.use,
couponProvider.couponSunModel);
} else {
Utils.showToast('您没有此权限');
}
}
}
}
// else if (couponProvider.couponSunModel.isType ==
// '2' &&
// couponProvider.couponSunModel.status == '1') {
// // 我的优惠券
// Utils.goShareBuyCouponToWeChatMy(
// context,
// widget.idstr,
// managerName,
// couponProvider.couponSunModel);
// }
},
),
)
// else if (couponProvider.couponSunModel.isType ==
// '2' &&
// couponProvider.couponSunModel.status == '1') {
// // 我的优惠券
// Utils.goShareBuyCouponToWeChatMy(
// context,
// widget.idstr,
// managerName,
// couponProvider.couponSunModel);
// }
},
),
)
],
))
]);
... ...
... ... @@ -256,12 +256,16 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(int.parse(
widget.couponSunModel!.expirationDate!.etime.toString()) *
1000);
fromDate = '${dateTimes.year}' +
'-${Utils.addZeroNumber(dateTimes.month)}' +
'-${Utils.addZeroNumber(dateTimes.day)}'; //活动有效期开始时间
endDate = '${dateTimee.year}' +
'-${Utils.addZeroNumber(dateTimee.month)}' +
'-${Utils.addZeroNumber(dateTimee.day)}';
int comparison = dateTimes.compareTo(
DateTime.now()); // 返回0表示相等,负数表示date1小于date2,正数表示date1大于date2
if (comparison > 0) {
fromDate = '${dateTimes.year}' +
'-${Utils.addZeroNumber(dateTimes.month)}' +
'-${Utils.addZeroNumber(dateTimes.day)}'; //活动有效期开始时间
endDate = '${dateTimee.year}' +
'-${Utils.addZeroNumber(dateTimee.month)}' +
'-${Utils.addZeroNumber(dateTimee.day)}';
}
}
}
if (widget.couponSunModel!.aexpiration != null) {
... ... @@ -281,12 +285,16 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(
int.parse(widget.couponSunModel!.aexpiration!.etime.toString()) *
1000);
fromDateCus = '${dateTimes.year}' +
'-${Utils.addZeroNumber(dateTimes.month)}' +
'-${Utils.addZeroNumber(dateTimes.day)}'; //领取后有效期开始时间
endDateCus = '${dateTimee.year}' +
'-${Utils.addZeroNumber(dateTimee.month)}' +
'-${Utils.addZeroNumber(dateTimee.day)}';
int comparison = dateTimes.compareTo(
DateTime.now()); // 返回0表示相等,负数表示date1小于date2,正数表示date1大于date2
if (comparison > 0) {
fromDateCus = '${dateTimes.year}' +
'-${Utils.addZeroNumber(dateTimes.month)}' +
'-${Utils.addZeroNumber(dateTimes.day)}'; //领取后有效期开始时间
endDateCus = '${dateTimee.year}' +
'-${Utils.addZeroNumber(dateTimee.month)}' +
'-${Utils.addZeroNumber(dateTimee.day)}';
}
}
if (widget.couponSunModel!.aexpiration!.today != null &&
widget.couponSunModel!.aexpiration!.today != '') {
... ...
... ... @@ -198,10 +198,14 @@ class _CouponEidtPayPageState extends State<CouponEidtPayPage> {
_couponExplainEditControl.text = widget.couponSunModel!.explain ?? '';
DateTime dateTimes = DateTime.fromMillisecondsSinceEpoch(
int.parse(widget.couponSunModel!.stime.toString()) * 1000);
fromDate = DateUtil.formatDate(dateTimes, format: DateFormats.y_mo_d);
DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(
int.parse(widget.couponSunModel!.etime.toString()) * 1000);
endDate = DateUtil.formatDate(dateTimee, format: DateFormats.y_mo_d);
int comparison = dateTimes.compareTo(
DateTime.now()); // 返回0表示相等,负数表示date1小于date2,正数表示date1大于date2
if (comparison > 0) {
fromDate = DateUtil.formatDate(dateTimes, format: DateFormats.y_mo_d);
DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(
int.parse(widget.couponSunModel!.etime.toString()) * 1000);
endDate = DateUtil.formatDate(dateTimee, format: DateFormats.y_mo_d);
}
swichState = widget.couponSunModel!.status == '1' ? true : false;
... ...
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:one_key/constant/state.dart';
... ... @@ -6,6 +5,7 @@ import 'package:one_key/pages/coupon/coupon_item_f.dart';
import 'package:one_key/provider/coupon_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
... ... @@ -117,16 +117,29 @@ class _CouponHistoryPageState extends State<CouponHistoryPage> {
// );
return CouponItemF(
from: 'history',
couponSonModel: couponProvider.couponListHistory![index],
couponSonModel:
couponProvider.couponListHistory![index],
showBtn: true,
onPressedSwich: () {
// couponProvider.couponList[index].isOpenBool =
// !couponProvider.couponList[index].isOpenBool;
// _setCustomerActivity(index);
},
onPressed: () {
// NavigatorUtil.goCouponDetailPage(
// context, couponProvider.couponList[index]);
onPressed: () async {
//复用,跳转至编辑页面
dynamic needRefresh =
await NavigatorUtil.goCouponDetailPage(context,
couponProvider.couponListHistory![index],
idStr: couponProvider
.couponListHistory![index].id,
isHistory: true);
if (needRefresh != null && needRefresh) {
if (mounted) {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
}
}
},
);
}, childCount: couponProvider.couponListHistory!.length),
... ...
... ... @@ -55,7 +55,7 @@ class _GrantPageState extends State<GrantPage> {
}
}
_createConsumeQrcode(String amounts) async {
_createConsumeQrcode(String amounts) async {
Map<String, String> pramas = {
'sellerid':
Provider.of<UserModel>(context, listen: false).user!.sellerid!,
... ...
... ... @@ -399,9 +399,9 @@ class NavigatorUtil {
/// 优惠券详情页
static Future<dynamic> goCouponDetailPage(
BuildContext context, CouponSunModel? couponSunModel,
{replace = false, String? idStr}) {
{replace = false, String? idStr, bool isHistory = false}) {
return _navigateTo(context,
"${Routes.coupon_detail}?couponSunModel=${FluroConvertUtils.object2string(couponSunModel)}&idStr=$idStr",
"${Routes.coupon_detail}?couponSunModel=${FluroConvertUtils.object2string(couponSunModel)}&idStr=$idStr&isHistory=${isHistory}",
replace: replace);
}
... ...
... ... @@ -935,6 +935,9 @@ var handleCouponSelectPageHandler = new Handler(
var handleCouponDetailPageHandler = new Handler(
handlerFunc: (BuildContext? context, Map<String, List<Object>> params) {
String idStr = params["idStr"]!.first as String;
bool isHistory =
FluroConvertUtils.string2bool(params["isHistory"]!.first as String);
CouponSunModel? couponSunModel;
if (idStr == null || idStr == 'null') {
couponSunModel = CouponSunModel.fromJson(json.decode(
... ... @@ -944,7 +947,7 @@ var handleCouponDetailPageHandler = new Handler(
return ChangeNotifierProvider<BaseIndoProvider>(
create: (_) => BaseIndoProvider(),
child: CouponDetailPage(couponSunModel: couponSunModel, idstr: idStr));
child: CouponDetailPage(couponSunModel: couponSunModel, idstr: idStr,isHistory:isHistory));
});
///个人资料页面
... ...