Commit 2da1398eaab23f8bc0be9c9ea189f4c626b21f96

Authored by weixin_45529955
1 parent 1809c4d0

生日和纪念日改版

import 'package:common_utils/common_utils.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:lunar/calendar/Lunar.dart';
import 'package:lunar/calendar/Solar.dart';
import 'dart:convert' as convert;
import 'package:one_key/models/table_list.dart' as t;
import '../utils/pick_date_nonli_gongli/lunar_calendar_util.dart';
part 'guest_info_model.g.dart';
@JsonSerializable()
... ... @@ -106,6 +110,9 @@ class Guest extends Object {
@JsonKey(name: 'c_day_self')
String? cDaySelf;
@JsonKey(name: 'n_day')
String? nDaySelf;
String? get rnameStr {
if (rname == null || rname == '' || rname == ' ') return "";
return rname;
... ... @@ -115,7 +122,27 @@ class Guest extends Object {
if (cDaySelf == null || cDaySelf == '') return '';
return DateUtil.formatDate(
DateTime.fromMillisecondsSinceEpoch(int.parse(cDaySelf!) * 1000),
format: DateFormats.y_mo_d);
format: DateFormats.zh_y_mo_d);
}
String get ndaySelfStr {
if (nDaySelf == null || nDaySelf == '') return '';
DateTime time =
DateTime.fromMillisecondsSinceEpoch(int.parse(nDaySelf!) * 1000);
// 获取当前阴历
Lunar currentLunarTime = Solar.fromDate(time).getLunar();
String yearStr = currentLunarTime.getYear().toString();
String monthStr = currentLunarTime.getMonth().abs().toString();
String dayStr = currentLunarTime.getDay().toString();
//转换成农历
String show = (yearStr) +
'年' +
LunarCalendarUtil.formatLunarDate(
int.parse(monthStr), int.parse(dayStr));
return show;
}
String get sexStr {
... ... @@ -159,7 +186,8 @@ class Guest extends Object {
this.label,
this.nickName,
this.isMember,
this.cDaySelf);
this.cDaySelf,
this.nDaySelf);
factory Guest.fromJson(Map<String, dynamic> srcJson) =>
_$GuestFromJson(srcJson);
... ...
... ... @@ -77,6 +77,7 @@ Guest _$GuestFromJson(Map<String, dynamic> json) {
json['nick_name'] as String?,
json['is_member'] as String?,
json['c_day_self'] as String?,
json['n_day'] as String?,
);
}
... ... @@ -99,7 +100,8 @@ Map<String, dynamic> _$GuestToJson(Guest instance) => <String, dynamic>{
'label': instance.label,
'nick_name': instance.nickName,
'is_member': instance.isMember,
'c_day_self': instance.cDaySelf
'c_day_self': instance.cDaySelf,
'n_day':instance.nDaySelf
};
Cday _$CdayFromJson(Map<String, dynamic> json) {
... ...
... ... @@ -176,7 +176,7 @@ class _MyCustomerDetailEditPageState extends State<MyCustomerDetailEditPage> {
await customerProvider.setGuestInfo(context, params, showLoading: true);
if (sucess) {
Utils.showToast('保存成功');
bus.emit('refresh_guest_info');
bus.emit('refresh_guest_info_my');
bus.emit('refresh_guest_list_my');
if (Navigator.canPop(context)) {
Navigator.pop(context);
... ...
... ... @@ -21,6 +21,7 @@ import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import '../../../../utils/pick_date_nonli_gongli/lunar_calendar_util.dart';
import '../../../../utils/screen_util.dart';
/**
*
... ... @@ -52,14 +53,14 @@ class _MyCustomerDetailPageState extends State<MyCustomerDetailPage> {
WidgetsBinding.instance.addPostFrameCallback((_) async {
_getGuestInfo();
});
bus.on("refresh_guest_info", (arg) {
bus.on("refresh_guest_info_my", (arg) {
_getGuestInfo();
});
}
@override
void dispose() {
bus.off('refresh_guest_info');
bus.off('refresh_guest_info_my');
super.dispose();
}
... ... @@ -968,77 +969,101 @@ class _MyCustomerDetailPageState extends State<MyCustomerDetailPage> {
_lineItemWidget('服务',
'${customerProvider.guestInfoSunModel!.guest!.serve == null ? '' : customerProvider.guestInfoSunModel!.guest!.serve}'),
VEmptyView(20),
Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(30)),
color: MyColours.color_ffffff,
child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'生日',
style: TextStyle(
fontSize: ScreenUtil().setSp(36),
color: MyColours.color_333333),
),
Spacer(),
Text(
birthday,
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_333333),
),
HEmptyView(20),
RoundButton(
text: '编辑',
radius: ScreenUtil().setWidth(20),
width: ScreenUtil().setWidth(90),
height: ScreenUtil().setWidth(50),
fontSize: 26,
isBold: false,
onPressed: () {
DialogUtil.showPickerDateTime24(
context,
scaffoldKey,
(value) async {
// {'text': picker.adapter.text, 'select': selecteds}
if (value != null) {
setState(() {
print(value);
birthday = DateUtil.formatDateStr(value,
format: DateFormats.y_mo_d);
});
// 请求接口,设置生日
String from = birthday + ' 00:00:00';
Map<String, String?> params = {
'id': widget.userHistoryEntity!.id,
'c_day':
'${(DateUtil.getDateMsByTimeStr(from)! / 1000).floor()}',
};
bool sucess = await customerProvider
.setGuestInfo(context, params,
showLoading: true);
if (sucess) {
Utils.showToast('保存成功');
}
}
// showDateSelWidget = false;
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(30)),
color: MyColours.color_ffffff,
child: Column(
children: [
Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'生日',
style: TextStyle(
fontSize: ScreenUtil().setSp(36),
color: MyColours.color_333333),
),
Spacer(),
// Text(
// birthday,
// style: TextStyle(
// fontSize: ScreenUtil().setSp(26),
// color: MyColours.color_333333),
// ),
// HEmptyView(20),
RoundButton(
text: '编辑',
radius: ScreenUtil().setWidth(20),
width: ScreenUtil().setWidth(90),
height: ScreenUtil().setWidth(50),
fontSize: 26,
isBold: false,
onPressed: () {
NavigatorUtil.goSetBirthdayPage(
context,
widget.userHistoryEntity!.id,
customerProvider
.guestInfoSunModel!.guest!.nDaySelf,
customerProvider
.guestInfoSunModel!.guest!.cDaySelf,
from: 'my');
},
yearBegin: 1925,
minValue: DateTime(1925),
dateTime: birthday == ''
? DateTime.now()
: DateUtil.getDateTime(birthday),
pickerDateTimeType: PickerDateTimeType.kYMD,
onCancel: () {
// showDateSelWidget = false;
});
},
),
],
),
),
),
],
),
if (customerProvider
.guestInfoSunModel!.guest!.cdaySelfStr !=
'')
Padding(
padding: EdgeInsets.only(top: w(12)),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
'公历',
style: TextStyle(
fontSize: font(16),
color: MyColours.color_438E93),
),
Text(
customerProvider.guestInfoSunModel!
.guest!.cdaySelfStr,
style: TextStyle(
fontSize: font(14),
color: MyColours.color_000000),
),
],
)),
if (customerProvider
.guestInfoSunModel!.guest!.ndaySelfStr !=
'')
Padding(
padding: EdgeInsets.only(top: w(12)),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
'农历',
style: TextStyle(
fontSize: font(16),
color: MyColours.color_438E93),
),
Text(
customerProvider.guestInfoSunModel!
.guest!.ndaySelfStr,
style: TextStyle(
fontSize: font(14),
color: MyColours.color_000000),
),
],
))
],
)),
VEmptyView(20),
Container(
padding: EdgeInsets.symmetric(
... ... @@ -1090,27 +1115,62 @@ class _MyCustomerDetailPageState extends State<MyCustomerDetailPage> {
//最新的数据
if (cday.year == null) {
show = cday.desc! +
':' +
cday.month! +
'-' +
cday.day! +
(cday.type == '1' ? '(公历)' : '(农历)');
if (cday.type == '1') {
show = '(公历)' +
Utils.addZeroNumber(
int.parse(cday.month!)) +
'月' +
Utils.addZeroNumber(
int.parse(cday.day!)) +
'日';
} else {
show = '(农历)' +
LunarCalendarUtil.formatLunarDate(
int.parse(cday.month!),
int.parse(cday.day!));
}
} else {
show = cday.desc! +
':' +
cday.year! +
'-' +
cday.month! +
'-' +
cday.day! +
(cday.type == '1' ? '(公历)' : '(农历)');
if (cday.type == '1') {
show = '(公历)' +
cday.year! +
'年' +
Utils.addZeroNumber(
int.parse(cday.month!)) +
'月' +
Utils.addZeroNumber(
int.parse(cday.day!)) +
'日';
} else {
show = '(农历)' +
cday.year! +
'年' +
LunarCalendarUtil.formatLunarDate(
int.parse(cday.month!),
int.parse(cday.day!));
}
}
} else {
show = cday.desc! +
':' +
cday.dtime! +
(cday.type == '1' ? '(公历)' : '(农历)');
show = (cday.type == '1' ? '(公历)' : '(农历)') +
cday.dtime!;
List data = cday.dtime!.split('-');
if (cday.type == '1') {
show = '(公历)' +
data[0] +
'年' +
Utils.addZeroNumber(
int.parse(data[1])) +
'月' +
Utils.addZeroNumber(
int.parse(data[2])) +
'日';
} else {
show = '(农历)' +
data[0] +
'年' +
LunarCalendarUtil.formatLunarDate(
int.parse(data[1]),
int.parse(data[2]));
}
}
}
return Padding(
... ...
... ... @@ -69,7 +69,7 @@ class _MyFestivalEditPageState extends State<MyFestivalEditPage> {
//刷新当前页
_getGuestInfoCday();
// 刷新
bus.emit('refresh_guest_info');
bus.emit('refresh_guest_info_my');
bus.emit('refresh_guest_list_my');
// Navigator.pop(context);
}
... ... @@ -84,8 +84,8 @@ class _MyFestivalEditPageState extends State<MyFestivalEditPage> {
//刷新当前页
_getGuestInfoCday();
// 刷新
bus.emit('refresh_guest_info');
bus.emit('refresh_guest_list');
bus.emit('refresh_guest_info_my');
bus.emit('refresh_guest_list_my');
// Navigator.pop(context);
}
}
... ... @@ -197,7 +197,11 @@ class _MyFestivalEditPageState extends State<MyFestivalEditPage> {
if (cday.year == null) {
if (cday.type == '1') {
show = '(公历)' + cday.month! + '月' + cday.day! + '日';
show = '(公历)' +
Utils.addZeroNumber(int.parse(cday.month!)) +
'月' +
Utils.addZeroNumber(int.parse(cday.day!)) +
'日';
} else {
show = '(农历)' +
LunarCalendarUtil.formatLunarDate(
... ... @@ -209,9 +213,9 @@ class _MyFestivalEditPageState extends State<MyFestivalEditPage> {
show = '(公历)' +
cday.year! +
'年' +
cday.month! +
Utils.addZeroNumber(int.parse(cday.month!)) +
'月' +
cday.day! +
Utils.addZeroNumber(int.parse(cday.day!)) +
'日';
} else {
show = '(农历)' +
... ... @@ -223,16 +227,16 @@ class _MyFestivalEditPageState extends State<MyFestivalEditPage> {
}
}
} else {
show =
(cday.type == '1' ? '(公历)' : '(农历)') + cday.dtime!;
// show =
// (cday.type == '1' ? '(公历)' : '(农历)') + cday.dtime!;
List data = cday.dtime!.split('-');
if (cday.type == '1') {
show = '(公历)' +
data[0] +
'年' +
data[1] +
Utils.addZeroNumber(int.parse(data[1])) +
'月' +
data[2] +
Utils.addZeroNumber(int.parse(data[2])) +
'日';
} else {
show = '(农历)' +
... ... @@ -251,7 +255,6 @@ class _MyFestivalEditPageState extends State<MyFestivalEditPage> {
title: "",
content: "是否删除该纪念日",
rTitle: "删除", rCallback: () {
_delGuestInfocDay(model.cday![index].id);
});
}, onTapEdit: () {
... ...
... ... @@ -979,42 +979,98 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> {
'${customerProvider.guestInfoSunModel!.guest!.serve == null ? '' : customerProvider.guestInfoSunModel!.guest!.serve}'),
VEmptyView(20),
Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(30)),
color: MyColours.color_ffffff,
child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'生日',
style: TextStyle(
fontSize: ScreenUtil().setSp(36),
color: MyColours.color_333333),
),
Spacer(),
// Text(
// birthday,
// style: TextStyle(
// fontSize: ScreenUtil().setSp(26),
// color: MyColours.color_333333),
// ),
// HEmptyView(20),
RoundButton(
text: '编辑',
radius: ScreenUtil().setWidth(20),
width: ScreenUtil().setWidth(90),
height: ScreenUtil().setWidth(50),
fontSize: 26,
isBold: false,
onPressed: () {
NavigatorUtil.goSetBirthdayPage(
context, widget.userHistoryEntity!.gid);
},
),
],
),
),
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(30)),
color: MyColours.color_ffffff,
child: Column(
children: [
Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'生日',
style: TextStyle(
fontSize: ScreenUtil().setSp(36),
color: MyColours.color_333333),
),
Spacer(),
// Text(
// birthday,
// style: TextStyle(
// fontSize: ScreenUtil().setSp(26),
// color: MyColours.color_333333),
// ),
// HEmptyView(20),
RoundButton(
text: '编辑',
radius: ScreenUtil().setWidth(20),
width: ScreenUtil().setWidth(90),
height: ScreenUtil().setWidth(50),
fontSize: 26,
isBold: false,
onPressed: () {
NavigatorUtil.goSetBirthdayPage(
context,
widget.userHistoryEntity!.gid,
customerProvider
.guestInfoSunModel!.guest!.nDaySelf,
customerProvider.guestInfoSunModel!
.guest!.cDaySelf);
},
),
],
),
if (customerProvider
.guestInfoSunModel!.guest!.cdaySelfStr !=
'')
Padding(
padding: EdgeInsets.only(top: w(12)),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
'公历',
style: TextStyle(
fontSize: font(16),
color: MyColours.color_438E93),
),
Text(
customerProvider.guestInfoSunModel!
.guest!.cdaySelfStr,
style: TextStyle(
fontSize: font(14),
color: MyColours.color_000000),
),
],
)),
if (customerProvider
.guestInfoSunModel!.guest!.ndaySelfStr !=
'')
Padding(
padding: EdgeInsets.only(top: w(12)),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
'农历',
style: TextStyle(
fontSize: font(16),
color: MyColours.color_438E93),
),
Text(
customerProvider.guestInfoSunModel!
.guest!.ndaySelfStr,
style: TextStyle(
fontSize: font(14),
color: MyColours.color_000000),
),
],
))
],
)),
VEmptyView(20),
Container(
padding: EdgeInsets.symmetric(
... ... @@ -1068,9 +1124,11 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> {
if (cday.year == null) {
if (cday.type == '1') {
show = '(公历)' +
cday.month! +
Utils.addZeroNumber(
int.parse(cday.month!)) +
'月' +
cday.day! +
Utils.addZeroNumber(
int.parse(cday.day!)) +
'日';
} else {
show = '(农历)' +
... ... @@ -1083,9 +1141,11 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> {
show = '(公历)' +
cday.year! +
'年' +
cday.month! +
Utils.addZeroNumber(
int.parse(cday.month!)) +
'月' +
cday.day! +
Utils.addZeroNumber(
int.parse(cday.day!)) +
'日';
} else {
show = '(农历)' +
... ... @@ -1104,10 +1164,12 @@ class _CustomerDetailPageState extends State<CustomerDetailPage> {
show = '(公历)' +
data[0] +
'年' +
data[1] +
'月' +
data[2] +
'日';
Utils.addZeroNumber(
int.parse( data[1])) +
'月' +
Utils.addZeroNumber(
int.parse( data[2])) +
'日';
} else {
show = '(农历)' +
data[0] +
... ...
... ... @@ -199,7 +199,10 @@ class _FestivalEditPageState extends State<FestivalEditPage> {
if (cday.year == null) {
if (cday.type == '1') {
show = '(公历)' + cday.month! + '月' + cday.day! + '日';
show = '(公历)' + Utils.addZeroNumber(int.parse(cday.month!)) +
'月' +
Utils.addZeroNumber(int.parse(cday.day!)) +
'日';
} else {
show = '(农历)' +
LunarCalendarUtil.formatLunarDate(
... ... @@ -211,9 +214,9 @@ class _FestivalEditPageState extends State<FestivalEditPage> {
show = '(公历)' +
cday.year! +
'年' +
cday.month! +
Utils.addZeroNumber(int.parse(cday.month!)) +
'月' +
cday.day! +
Utils.addZeroNumber(int.parse(cday.day!)) +
'日';
} else {
show = '(农历)' +
... ... @@ -232,9 +235,9 @@ class _FestivalEditPageState extends State<FestivalEditPage> {
show = '(公历)' +
data[0] +
'年' +
data[1] +
Utils.addZeroNumber(int.parse(data[1])) +
'月' +
data[2] +
Utils.addZeroNumber(int.parse(data[2])) +
'日';
} else {
show = '(农历)' +
... ...
... ... @@ -2,9 +2,13 @@ import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_lunar_datetime_picker/date_init.dart';
import 'package:flutter_picker_plus/picker.dart';
import 'package:lunar/calendar/Lunar.dart';
import 'package:lunar/calendar/Solar.dart';
import 'package:one_key/provider/customer_provider.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/pick_date_nonli_gongli/lunar_calendar_util.dart';
import 'package:one_key/utils/screen_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/MyDivider.dart';
... ... @@ -22,7 +26,16 @@ import 'package:flutter_lunar_datetime_picker/datetime_picker_theme.dart'
*/
class SetBirthdayPage extends StatefulWidget {
final String? gid;
const SetBirthdayPage({super.key, required this.gid});
final String from;
final String birthdayLunar;
final String birthdaySolar;
const SetBirthdayPage(
{super.key,
required this.gid,
this.from = 'store',
required this.birthdayLunar,
required this.birthdaySolar});
@override
State<SetBirthdayPage> createState() => _SetBirthdayPageState();
... ... @@ -31,7 +44,42 @@ class SetBirthdayPage extends StatefulWidget {
class _SetBirthdayPageState extends State<SetBirthdayPage> {
late CustomerProvider customerProvider;
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
String birthday = '';
String birthdayLunar = ''; //农历生日
String birthdaySolar = ''; //阳历生日
@override
void initState() {
// TODO: implement initState
super.initState();
if (widget.birthdaySolar == 'null' || widget.birthdaySolar == '') {
birthdaySolar = '';
} else {
birthdaySolar = DateUtil.formatDate(
DateTime.fromMillisecondsSinceEpoch(
int.parse(widget.birthdaySolar) * 1000),
format: DateFormats.zh_y_mo_d);
}
if (widget.birthdayLunar == 'null' || widget.birthdayLunar == '') {
birthdayLunar = '';
} else {
DateTime time = DateTime.fromMillisecondsSinceEpoch(
int.parse(widget.birthdayLunar) * 1000);
// 获取当前阴历
Lunar currentLunarTime = Solar.fromDate(time).getLunar();
String yearStr = currentLunarTime.getYear().toString();
String monthStr = currentLunarTime.getMonth().abs().toString();
String dayStr = currentLunarTime.getDay().toString();
//转换成农历
birthdayLunar = (yearStr) +
'年' +
LunarCalendarUtil.formatLunarDate(
int.parse(monthStr), int.parse(dayStr));
}
}
_item(
String title,
... ... @@ -53,15 +101,16 @@ class _SetBirthdayPageState extends State<SetBirthdayPage> {
fontSize: font(16), color: MyColours.color_438E93),
),
Spacer(),
InkWell(
onTap: onTapDel,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: w(10)),
child: Image.asset(
Utils.getImgPath('f_delete_red'),
width: w(20),
),
)),
if (subTitle != '')
InkWell(
onTap: onTapDel,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: w(10)),
child: Image.asset(
Utils.getImgPath('f_delete_red'),
width: w(20),
),
)),
InkWell(
onTap: onTapEdit,
child: Padding(
... ... @@ -73,11 +122,13 @@ class _SetBirthdayPageState extends State<SetBirthdayPage> {
)),
],
),
VEmptyView(40),
Text(
'(${title})${subTitle}',
style: TextStyle(fontSize: font(16), color: MyColours.color_000000),
),
if (subTitle != '') VEmptyView(40),
if (subTitle != '')
Text(
'(${title})${subTitle}',
style:
TextStyle(fontSize: font(16), color: MyColours.color_000000),
),
VEmptyView(20),
Padding(
padding: EdgeInsets.symmetric(horizontal: w(10)),
... ... @@ -92,6 +143,35 @@ class _SetBirthdayPageState extends State<SetBirthdayPage> {
);
}
_del(String field) async {
Map<String, String?> params = {
'id': widget.gid,
'${field}': null,
};
bool sucess =
await customerProvider.setGuestInfo(context, params, showLoading: true);
if (sucess) {
Utils.showToast('删除成功');
if (field == 'n_day') {
//农历
birthdayLunar = '';
} else {
//阳历
birthdaySolar = '';
}
setState(() {});
if (widget.from == 'store') {
//刷新全店客情详情页
bus.emit('refresh_guest_info');
} else {
//刷新我的客情详情页
bus.emit('refresh_guest_info_my');
}
}
}
@override
Widget build(BuildContext context) {
customerProvider = Provider.of<CustomerProvider>(context, listen: true);
... ... @@ -103,7 +183,26 @@ class _SetBirthdayPageState extends State<SetBirthdayPage> {
child: Column(
children: [
VEmptyView(40),
_item('公历', '1993年1月3日', onTapDel: () {}, onTapEdit: () {
_item('公历', birthdaySolar, onTapDel: () {
//删除生日
//弹框确认是否删除
DialogUtil.cupertinoAlertDialog(context,
title: "",
content: "是否删除公历生日",
rTitle: "删除", rCallback: () {
// if (Navigator.canPop(context)) {
// Navigator.pop(context);
// }
_del('c_day');
});
}, onTapEdit: () {
DateTime now = DateTime.now();
if (widget.birthdaySolar != 'null' &&
widget.birthdaySolar != '') {
now = DateTime.fromMillisecondsSinceEpoch(
int.parse(widget.birthdaySolar) * 1000);
}
DatePicker.showDatePicker(
context,
lunarPicker: false,
... ... @@ -120,11 +219,37 @@ class _SetBirthdayPageState extends State<SetBirthdayPage> {
doneStyle: TextStyle(
color: MyColours.color_438E93, fontSize: font(16))),
dateInitTime: DateInitTime(
currentTime: DateTime.now(),
currentTime: now,
maxTime: DateTime(2050, 12, 12),
minTime: DateTime(1900, 1, 1)),
onConfirm: (time, lunar) {
onConfirm: (time, lunar) async {
debugPrint(time.toString());
//保存
print(time.millisecondsSinceEpoch);
// 请求接口,设置生日
String from =
'${time.year}-${Utils.addZeroNumber(time.month)}-${Utils.addZeroNumber(time.day)}' +
' 00:00:00';
Map<String, String?> params = {
'id': widget.gid,
'c_day':
'${(DateUtil.getDateMsByTimeStr(from)! / 1000).floor()}',
};
bool sucess = await customerProvider
.setGuestInfo(context, params, showLoading: true);
if (sucess) {
Utils.showToast('保存成功');
birthdaySolar = '${time.year}年${time.month}月${time.day}日';
setState(() {});
if (widget.from == 'store') {
//刷新全店客情详情页
bus.emit('refresh_guest_info');
} else {
//刷新我的客情详情页
bus.emit('refresh_guest_info_my');
}
}
},
onChanged: (time, lunar) {
debugPrint("change:${time.toString()}");
... ... @@ -168,7 +293,26 @@ class _SetBirthdayPageState extends State<SetBirthdayPage> {
// });
}),
VEmptyView(40),
_item('农历', '1969年三月廿五', onTapDel: () {}, onTapEdit: () {
_item('农历', birthdayLunar, onTapDel: () {
//删除生日
//弹框确认是否删除
DialogUtil.cupertinoAlertDialog(context,
title: "",
content: "是否删除农历生日",
rTitle: "删除", rCallback: () {
// if (Navigator.canPop(context)) {
// Navigator.pop(context);
// }
_del('n_day');
});
}, onTapEdit: () {
DateTime now = DateTime.now();
if (widget.birthdayLunar != 'null' &&
widget.birthdayLunar != '') {
now = DateTime.fromMillisecondsSinceEpoch(
int.parse(widget.birthdayLunar) * 1000);
}
DatePicker.showDatePicker(
context,
lunarPicker: true,
... ... @@ -185,11 +329,49 @@ class _SetBirthdayPageState extends State<SetBirthdayPage> {
doneStyle: TextStyle(
color: MyColours.color_438E93, fontSize: font(16))),
dateInitTime: DateInitTime(
currentTime: DateTime.now(),
currentTime: now,
maxTime: DateTime(2050, 12, 12),
minTime: DateTime(1900, 1, 1)),
onConfirm: (time, lunar) {
onConfirm: (time, lunar) async {
debugPrint(time.toString());
print(time.millisecondsSinceEpoch);
// 请求接口,设置生日
String from =
'${time.year}-${Utils.addZeroNumber(time.month)}-${Utils.addZeroNumber(time.day)}' +
' 00:00:00';
Map<String, String?> params = {
'id': widget.gid,
'n_day':
'${(DateUtil.getDateMsByTimeStr(from)! / 1000).floor()}',
};
bool sucess = await customerProvider
.setGuestInfo(context, params, showLoading: true);
if (sucess) {
Utils.showToast('保存成功');
// 获取当前阴历
Lunar currentLunarTime = Solar.fromDate(time).getLunar();
String yearStr = currentLunarTime.getYear().toString();
String monthStr =
currentLunarTime.getMonth().abs().toString();
String dayStr = currentLunarTime.getDay().toString();
//转换成农历
birthdayLunar = (yearStr) +
'年' +
LunarCalendarUtil.formatLunarDate(
int.parse(monthStr), int.parse(dayStr));
setState(() {});
if (widget.from == 'store') {
//刷新全店客情详情页
bus.emit('refresh_guest_info');
} else {
//刷新我的客情详情页
bus.emit('refresh_guest_info_my');
}
}
},
onChanged: (time, lunar) {
debugPrint("change:${time.toString()}");
... ...
... ... @@ -3583,7 +3583,7 @@ class TableManagerPageState extends State<TableManagerPage> {
}
*/
Guest guest = Guest(null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null);
null, null, null, null, null, null, null, null, null, null,null);
// if (widget.guest == null) {
guest.phone =
... ...
... ... @@ -176,7 +176,7 @@ class _MyCustomerDetailEditPageSimState extends State<MyCustomerDetailEditPageSi
await customerProvider.setGuestInfo(context, params, showLoading: true);
if (sucess) {
Utils.showToast('保存成功');
bus.emit('refresh_guest_info');
bus.emit('refresh_guest_info_my');
bus.emit('refresh_guest_list_my');
if (Navigator.canPop(context)) {
Navigator.pop(context);
... ...
... ... @@ -49,14 +49,14 @@ class _MyCustomerDetailPageSimState extends State<MyCustomerDetailPageSim> {
WidgetsBinding.instance.addPostFrameCallback((_) async {
_getGuestInfo();
});
bus.on("refresh_guest_info", (arg) {
bus.on("refresh_guest_info_my", (arg) {
_getGuestInfo();
});
}
@override
void dispose() {
bus.off('refresh_guest_info');
bus.off('refresh_guest_info_my');
super.dispose();
}
... ...
... ... @@ -3239,7 +3239,7 @@ class TableManagerPageSimState extends State<TableManagerPageSim> {
}
*/
Guest guest = Guest(null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null);
null, null, null, null, null, null, null, null, null, null,null);
// if (widget.guest == null) {
guest.phone =
... ...
... ... @@ -2459,12 +2459,12 @@ class NavigatorUtil {
///客户生日
static Future<dynamic> goSetBirthdayPage(
BuildContext context,String? gid, {
BuildContext context,String? gid, String? lunar, String? solar, {
replace = false,
String from = 'store'
}) {
return _navigateTo(context, "${Routes.set_birthday_page}?gid=$gid",
return _navigateTo(context, "${Routes.set_birthday_page}?gid=$gid&lunar=$lunar&solar=$solar&from=$from",
replace: replace);
}
... ...
... ... @@ -4262,6 +4262,11 @@ var vipRecordDetailPageHandle = new Handler(
var setBirthdayPageHandle = new Handler(
handlerFunc: (BuildContext? context, Map<String, List<Object>> params) {
String? gid = params["gid"]!.first as String;
String? solar = params["solar"]!.first as String;
String? lunar = params["lunar"]!.first as String;
String? from = params["from"]!.first as String;
// String status = params["status"]!.first as String;
// bool isMine =
// FluroConvertUtils.string2bool(params["isMine"]!.first as String);
... ... @@ -4273,7 +4278,13 @@ var setBirthdayPageHandle = new Handler(
// }
return ChangeNotifierProvider<CustomerProvider>(
create: (_) => CustomerProvider(), child: SetBirthdayPage(gid:gid));
create: (_) => CustomerProvider(),
child: SetBirthdayPage(
gid: gid,
birthdayLunar: lunar,
birthdaySolar: solar,
from:from
));
});
///支付返券
... ...