|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:one_key/constant/state.dart';
|
|
|
|
import 'package:one_key/models/coupon_model.dart';
|
|
|
|
import 'package:one_key/models/store_customer_home_model.dart'
|
|
|
|
as storeCustomerHomeModel;
|
|
|
|
import 'package:one_key/provider/customer_making_provider.dart';
|
|
|
|
import 'package:one_key/provider/customer_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/utils/dialog_util.dart';
|
|
|
|
import 'package:one_key/utils/utils.dart';
|
|
|
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
import '../../../utils/screen_util.dart';
|
|
|
|
|
|
|
|
class CreateMarketingPlanPage extends StatefulWidget {
|
|
|
|
final bool isSeller;
|
|
|
|
final String? uid;
|
|
|
|
final List<storeCustomerHomeModel.SellerUser>? sellerUser;
|
|
|
|
|
|
|
|
const CreateMarketingPlanPage({
|
|
|
|
Key? key,
|
|
|
|
required this.isSeller,
|
|
|
|
this.uid,
|
|
|
|
this.sellerUser,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<CreateMarketingPlanPage> createState() =>
|
|
|
|
_CreateMarketingPlanPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _CreateMarketingPlanPageState extends State<CreateMarketingPlanPage> {
|
|
|
|
late CustomerProvider customerProvider;
|
|
|
|
late CustomerMakingProvider customerMakingProvider;
|
|
|
|
|
|
|
|
final TextEditingController _greetingController =
|
|
|
|
TextEditingController(text: '好久不见!甚是想念,为了表达我们的思念之情');
|
|
|
|
final TextEditingController _amountController = TextEditingController();
|
|
|
|
|
|
|
|
List<String> couponNames = [];
|
|
|
|
int? _selectedCouponIndex;
|
|
|
|
String? _selectedCouponName;
|
|
|
|
|
|
|
|
/// 0:发放消费金;1:赠送优惠券
|
|
|
|
int _giftType = 0;
|
|
|
|
|
|
|
|
String gid = '';
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_greetingController.addListener(_onFormChanged);
|
|
|
|
_amountController.addListener(_onFormChanged);
|
|
|
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
if (!mounted) return;
|
|
|
|
_computeGid();
|
|
|
|
_loadCoupons();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
_greetingController.removeListener(_onFormChanged);
|
|
|
|
_amountController.removeListener(_onFormChanged);
|
|
|
|
_greetingController.dispose();
|
|
|
|
_amountController.dispose();
|
|
|
|
super.dispose();
|
|
|
|
customerMakingProvider.clearData();
|
|
|
|
}
|
|
|
|
|
|
|
|
void _onFormChanged() {
|
|
|
|
if (mounted) {
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void _computeGid() {
|
|
|
|
gid = '';
|
|
|
|
if (widget.isSeller) {
|
|
|
|
for (final item in customerMakingProvider.selectCustomerSeller) {
|
|
|
|
gid += '${item.gid},';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (final item in customerMakingProvider.selectCustomer) {
|
|
|
|
gid += '${item.id},';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (gid.endsWith(',')) {
|
|
|
|
gid = gid.substring(0, gid.length - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _loadCoupons() async {
|
|
|
|
final userModel = Provider.of<UserModel>(context, listen: false);
|
|
|
|
final uid = widget.isSeller ? userModel.user!.openid : widget.uid;
|
|
|
|
final params = <String, String?>{
|
|
|
|
'uid': uid,
|
|
|
|
'status': '1',
|
|
|
|
};
|
|
|
|
|
|
|
|
await customerProvider.getCustomerSelectActivityNew(context, params,
|
|
|
|
isShowLoading: false);
|
|
|
|
|
|
|
|
if (!mounted) return;
|
|
|
|
if (customerProvider.couponListSelect == null ||
|
|
|
|
customerProvider.couponListSelect!.isEmpty) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
couponNames = customerProvider.couponListSelect!
|
|
|
|
.map((e) => e.aname)
|
|
|
|
.whereType<String>()
|
|
|
|
.toList();
|
|
|
|
_selectedCouponIndex = 0;
|
|
|
|
_selectedCouponName = couponNames.isNotEmpty ? couponNames.first : null;
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
|
|
|
|
String get _labels {
|
|
|
|
final labels = customerMakingProvider.labels;
|
|
|
|
if (labels == null || labels.trim().isEmpty) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
return '[$labels] ';
|
|
|
|
}
|
|
|
|
|
|
|
|
int get _selectedCount => widget.isSeller
|
|
|
|
? customerMakingProvider.selectCustomerSeller.length
|
|
|
|
: customerMakingProvider.selectCustomer.length;
|
|
|
|
|
|
|
|
String get _selectedSummary => '已选 $_labels${_selectedCount}位顾客';
|
|
|
|
|
|
|
|
String get _giftText {
|
|
|
|
if (_giftType == 0) {
|
|
|
|
final amount = _amountController.text.trim();
|
|
|
|
return amount.isEmpty ? '赠送您消费金' : '赠送您$amount消费金';
|
|
|
|
}
|
|
|
|
return '赠送您${_selectedCouponName ?? '优惠券'}';
|
|
|
|
}
|
|
|
|
|
|
|
|
String _buildPreview() {
|
|
|
|
final userModel = Provider.of<UserModel>(context, listen: false);
|
|
|
|
final storeName = userModel.user?.sellername ?? '';
|
|
|
|
final greeting = _greetingController.text.trim();
|
|
|
|
|
|
|
|
if (_giftType == 1 && _selectedCouponIndex != null) {
|
|
|
|
final coupon = customerProvider.couponListSelect![_selectedCouponIndex!];
|
|
|
|
final requirement = coupon.desc?.trim();
|
|
|
|
final validity = _buildCouponValidity(coupon);
|
|
|
|
final couponContent = <String>[
|
|
|
|
_giftText,
|
|
|
|
if (requirement != null && requirement.isNotEmpty) requirement,
|
|
|
|
'凭手机号核销',
|
|
|
|
if (validity.isNotEmpty) validity,
|
|
|
|
].join(',');
|
|
|
|
return '--$storeName--\n嘿,老朋友! $greeting, $couponContent。 '
|
|
|
|
'欢迎提前预订,拒收请回复R';
|
|
|
|
}
|
|
|
|
|
|
|
|
return '--$storeName--\n嘿,老朋友! $greeting, '
|
|
|
|
'$_giftText,到店凭手机号核销。 欢迎提前预订,拒收请回复R';
|
|
|
|
}
|
|
|
|
|
|
|
|
String _buildCouponValidity(CouponSunModel coupon) {
|
|
|
|
String? validForever;
|
|
|
|
String? stime;
|
|
|
|
String? etime;
|
|
|
|
if (coupon.expirationDate != null) {
|
|
|
|
validForever = coupon.expirationDate!.validForever;
|
|
|
|
stime = coupon.expirationDate!.stime;
|
|
|
|
etime = coupon.expirationDate!.etime;
|
|
|
|
} else if (coupon.aexpiration != null) {
|
|
|
|
validForever = coupon.aexpiration!.validForever;
|
|
|
|
stime = coupon.aexpiration!.stime;
|
|
|
|
etime = coupon.aexpiration!.etime;
|
|
|
|
}
|
|
|
|
if (validForever == '1') {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
final startDate = _formatCouponTimestamp(stime);
|
|
|
|
final endDate = _formatCouponTimestamp(etime);
|
|
|
|
if (startDate.isNotEmpty && endDate.isNotEmpty) {
|
|
|
|
return '有效期自$startDate到$endDate';
|
|
|
|
}
|
|
|
|
if (startDate.isNotEmpty) {
|
|
|
|
return '有效期自$startDate起';
|
|
|
|
}
|
|
|
|
if (endDate.isNotEmpty) {
|
|
|
|
return '有效期至$endDate';
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
String _formatCouponTimestamp(String? timestamp) {
|
|
|
|
if (timestamp == null || timestamp.isEmpty) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
final seconds = int.tryParse(timestamp);
|
|
|
|
if (seconds == null || seconds <= 0) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
final date = DateTime.fromMillisecondsSinceEpoch(seconds * 1000);
|
|
|
|
final month = date.month.toString().padLeft(2, '0');
|
|
|
|
final day = date.day.toString().padLeft(2, '0');
|
|
|
|
return '${date.year}-$month-$day';
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _viewCustomers() async {
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
|
|
if (widget.isSeller) {
|
|
|
|
await NavigatorUtil.goCustomerListPage(context,
|
|
|
|
FromPage.FromPageMakeRecord, '', {'object': widget.sellerUser});
|
|
|
|
|
|
|
|
if (!mounted) return;
|
|
|
|
_computeGid();
|
|
|
|
setState(() {});
|
|
|
|
} else {
|
|
|
|
await NavigatorUtil.goMyCustomerListPage(
|
|
|
|
context,
|
|
|
|
FromPage.FromPageMakeRecord,
|
|
|
|
widget.uid,
|
|
|
|
labels: customerMakingProvider.labels ?? '',
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!mounted) return;
|
|
|
|
_computeGid();
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void _selectCoupon() {
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
|
|
if (couponNames.isEmpty) {
|
|
|
|
Utils.showToast('暂无优惠券,请创建新优惠');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DialogUtil.showSelectCusmanDialog(context, couponNames, (value) {
|
|
|
|
if (value != null && value is List && value.isNotEmpty) {
|
|
|
|
setState(() {
|
|
|
|
_selectedCouponIndex = value.first as int;
|
|
|
|
_selectedCouponName = couponNames[_selectedCouponIndex!];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}, selecteds: _selectedCouponIndex == null ? [] : [_selectedCouponIndex!]);
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _confirm() async {
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
|
|
if (_selectedCount == 0) {
|
|
|
|
Utils.showToast('请至少选择1名顾客');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (_giftType == 0 && _amountController.text.trim().isEmpty) {
|
|
|
|
Utils.showToast('请输入发放消费金金额');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (_giftType == 1 && _selectedCouponIndex == null) {
|
|
|
|
Utils.showToast('请选择优惠券');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
final userModel = Provider.of<UserModel>(context, listen: false);
|
|
|
|
final greeting = _greetingController.text.trim();
|
|
|
|
if (greeting.isEmpty) {
|
|
|
|
Utils.showToast('请输入问候语');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
final phones = <String>[];
|
|
|
|
if (widget.isSeller) {
|
|
|
|
for (final item in customerMakingProvider.selectCustomerSeller) {
|
|
|
|
final phone = item.phone?.trim();
|
|
|
|
if (phone != null && phone.isNotEmpty) {
|
|
|
|
phones.add(phone);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (final item in customerMakingProvider.selectCustomer) {
|
|
|
|
final phone = item.phone?.trim();
|
|
|
|
if (phone != null && phone.isNotEmpty) {
|
|
|
|
phones.add(phone);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (phones.isEmpty) {
|
|
|
|
Utils.showToast('所选顾客暂无手机号');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
final labels = customerMakingProvider.labels ?? '';
|
|
|
|
final targetGroupNames = labels
|
|
|
|
.split(',')
|
|
|
|
.map((e) => e.trim())
|
|
|
|
.where((e) => e.isNotEmpty)
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
final params = <String, dynamic>{
|
|
|
|
'sellerid': userModel.user!.sellerid,
|
|
|
|
'phones': json.encode(phones.toSet().toList()),
|
|
|
|
'benefit_type': _giftType == 0 ? 1 : 2,
|
|
|
|
'greeting': greeting,
|
|
|
|
};
|
|
|
|
if (targetGroupNames.isNotEmpty) {
|
|
|
|
params['target_group_names'] = json.encode(targetGroupNames);
|
|
|
|
}
|
|
|
|
|
|
|
|
final uidValue = widget.isSeller ? userModel.user!.openid : widget.uid;
|
|
|
|
final uidInt = int.tryParse(uidValue ?? '');
|
|
|
|
if (uidInt != null && uidInt > 0) {
|
|
|
|
params['uid'] = uidInt;
|
|
|
|
} else if (uidValue != null && uidValue.isNotEmpty) {
|
|
|
|
params['uid'] = uidValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_giftType == 0) {
|
|
|
|
params['consume_amount'] =
|
|
|
|
double.tryParse(_amountController.text.trim()) ?? 0;
|
|
|
|
} else if (_selectedCouponIndex != null) {
|
|
|
|
params['aid'] = int.tryParse(
|
|
|
|
customerProvider.couponListSelect![_selectedCouponIndex!].id ??
|
|
|
|
'') ??
|
|
|
|
0;
|
|
|
|
}
|
|
|
|
|
|
|
|
final importResult = await customerProvider
|
|
|
|
.importActivityPhoneCoupon(context, params, showLoading: true);
|
|
|
|
if (!mounted) return;
|
|
|
|
if (importResult == null) return;
|
|
|
|
|
|
|
|
final marketingId = _extractMarketingId(importResult);
|
|
|
|
if (marketingId == null || marketingId <= 0) {
|
|
|
|
Utils.showToast('创建营销活动失败');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
final success = await customerProvider.sendPhoneMarketingSms(
|
|
|
|
context,
|
|
|
|
<String, dynamic>{
|
|
|
|
'sellerid': userModel.user!.sellerid,
|
|
|
|
'marketing_id': marketingId,
|
|
|
|
},
|
|
|
|
showLoading: true);
|
|
|
|
if (!mounted) return;
|
|
|
|
if (!success) return;
|
|
|
|
|
|
|
|
Utils.showToast('执行成功');
|
|
|
|
if (Navigator.canPop(context)) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int? _extractMarketingId(dynamic data) {
|
|
|
|
if (data is Map) {
|
|
|
|
for (final key in ['marketing_id', 'id']) {
|
|
|
|
if (data.containsKey(key)) {
|
|
|
|
final value = data[key];
|
|
|
|
final parsed = _extractMarketingId(value);
|
|
|
|
if (parsed != null) return parsed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (final value in data.values) {
|
|
|
|
final parsed = _extractMarketingId(value);
|
|
|
|
if (parsed != null) return parsed;
|
|
|
|
}
|
|
|
|
} else if (data is List) {
|
|
|
|
for (final value in data) {
|
|
|
|
final parsed = _extractMarketingId(value);
|
|
|
|
if (parsed != null) return parsed;
|
|
|
|
}
|
|
|
|
} else if (data is num) {
|
|
|
|
return data.toInt();
|
|
|
|
} else if (data is String) {
|
|
|
|
return int.tryParse(data);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
customerProvider = Provider.of<CustomerProvider>(context, listen: true);
|
|
|
|
customerMakingProvider =
|
|
|
|
Provider.of<CustomerMakingProvider>(context, listen: true);
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: MyColours.color_ffffff,
|
|
|
|
appBar: SystemAppBar(
|
|
|
|
'创建营销活动',
|
|
|
|
),
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: [
|
|
|
|
_buildSelectedBar(),
|
|
|
|
_buildSectionRow('赠送优惠选择'),
|
|
|
|
_buildGiftMoneyRow(),
|
|
|
|
_buildGiftCouponRow(),
|
|
|
|
_buildSectionRow('问候语(点击可以编写)'),
|
|
|
|
_buildGreetingInput(),
|
|
|
|
_buildSectionRow('短信内容预览'),
|
|
|
|
_buildPreviewBox(),
|
|
|
|
SizedBox(height: w(3)),
|
|
|
|
_buildBottomButton(),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildSelectedBar() {
|
|
|
|
return Container(
|
|
|
|
color: MyColours.app_main,
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: w(16), vertical: w(16)),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Text(
|
|
|
|
_selectedSummary,
|
|
|
|
maxLines: 1,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
fontSize: font(14),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
InkWell(
|
|
|
|
onTap: _viewCustomers,
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.only(left: w(16)),
|
|
|
|
child: Text(
|
|
|
|
'查看',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
fontSize: font(14),
|
|
|
|
decoration: TextDecoration.underline,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildSectionRow(String title) {
|
|
|
|
return Container(
|
|
|
|
height: w(48),
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: w(16)),
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
border: Border(
|
|
|
|
bottom: BorderSide(
|
|
|
|
color: MyColours.color_E4E4E4,
|
|
|
|
width: w(1),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_27262B,
|
|
|
|
fontSize: font(16),
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildGiftMoneyRow() {
|
|
|
|
return _buildGiftOptionRow(
|
|
|
|
type: 0,
|
|
|
|
title: '发放消费金',
|
|
|
|
trailing: Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
_buildAmountInput(),
|
|
|
|
SizedBox(width: w(6)),
|
|
|
|
Text(
|
|
|
|
'元',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_27262B,
|
|
|
|
fontSize: font(14),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
alignTrailingRight: false,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildGiftCouponRow() {
|
|
|
|
return _buildGiftOptionRow(
|
|
|
|
type: 1,
|
|
|
|
title: '赠送优惠券',
|
|
|
|
trailing: _buildCouponSelect(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildGiftOptionRow({
|
|
|
|
required int type,
|
|
|
|
required String title,
|
|
|
|
required Widget trailing,
|
|
|
|
bool alignTrailingRight = true,
|
|
|
|
}) {
|
|
|
|
final selected = _giftType == type;
|
|
|
|
return InkWell(
|
|
|
|
onTap: () {
|
|
|
|
setState(() {
|
|
|
|
_giftType = type;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
height: w(40),
|
|
|
|
padding: EdgeInsets.only(left: w(16), right: w(16)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
border: Border(
|
|
|
|
bottom: BorderSide(
|
|
|
|
color: MyColours.color_E4E4E4,
|
|
|
|
width: w(1),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath(selected ? 'f_select' : 'f_select_not'),
|
|
|
|
width: w(18),
|
|
|
|
height: w(18),
|
|
|
|
),
|
|
|
|
SizedBox(width: w(8)),
|
|
|
|
Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_27262B,
|
|
|
|
fontSize: font(14),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (alignTrailingRight) const Spacer(),
|
|
|
|
if (!alignTrailingRight) SizedBox(width: w(10)),
|
|
|
|
trailing,
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildAmountInput() {
|
|
|
|
return Container(
|
|
|
|
width: w(150),
|
|
|
|
height: w(30),
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: w(8)),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
border: Border.all(
|
|
|
|
color: MyColours.color_B7B7B7,
|
|
|
|
width: w(1),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: TextField(
|
|
|
|
controller: _amountController,
|
|
|
|
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
|
|
|
maxLines: 1,
|
|
|
|
textAlignVertical: TextAlignVertical.center,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_27262B,
|
|
|
|
fontSize: font(10),
|
|
|
|
),
|
|
|
|
decoration: InputDecoration(
|
|
|
|
isCollapsed: true,
|
|
|
|
border: InputBorder.none,
|
|
|
|
hintText: '请输入数字',
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: font(10),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildCouponSelect() {
|
|
|
|
return InkWell(
|
|
|
|
onTap: _selectCoupon,
|
|
|
|
child: Container(
|
|
|
|
height: w(30),
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: w(10), vertical: w(4)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: MyColours.color_E4E4E4,
|
|
|
|
borderRadius: BorderRadius.circular(r(5)),
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
_selectedCouponName ?? '请选择优惠券',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.app_main,
|
|
|
|
fontSize: font(12),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(width: w(6)),
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath('down_c'),
|
|
|
|
width: w(22),
|
|
|
|
height: w(22),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildGreetingInput() {
|
|
|
|
return Container(
|
|
|
|
height: w(116),
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: w(16), vertical: w(3)),
|
|
|
|
padding: EdgeInsets.all(w(10)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
borderRadius: BorderRadius.circular(r(8)),
|
|
|
|
border: Border.all(
|
|
|
|
color: MyColours.color_B7B7B7,
|
|
|
|
width: w(1),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: TextField(
|
|
|
|
controller: _greetingController,
|
|
|
|
keyboardType: TextInputType.multiline,
|
|
|
|
maxLines: 4,
|
|
|
|
minLines: 4,
|
|
|
|
textAlignVertical: TextAlignVertical.top,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_27262B,
|
|
|
|
fontSize: font(14),
|
|
|
|
),
|
|
|
|
decoration: InputDecoration(
|
|
|
|
border: InputBorder.none,
|
|
|
|
isCollapsed: true,
|
|
|
|
hintText: '请输入问候语',
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: font(14),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildPreviewBox() {
|
|
|
|
return Container(
|
|
|
|
height: w(220),
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: w(16), vertical: w(3)),
|
|
|
|
padding: EdgeInsets.all(w(10)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
borderRadius: BorderRadius.circular(r(8)),
|
|
|
|
border: Border.all(
|
|
|
|
color: MyColours.color_B7B7B7,
|
|
|
|
width: w(1),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
_buildPreview(),
|
|
|
|
maxLines: 9,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
fontSize: font(14),
|
|
|
|
height: 1.4,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildBottomButton() {
|
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: w(45),
|
|
|
|
right: w(45),
|
|
|
|
top: w(12),
|
|
|
|
bottom: w(26),
|
|
|
|
),
|
|
|
|
child: SizedBox(
|
|
|
|
width: double.infinity,
|
|
|
|
height: w(42),
|
|
|
|
child: ElevatedButton(
|
|
|
|
onPressed: _confirm,
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
backgroundColor: MyColours.app_main,
|
|
|
|
foregroundColor: MyColours.color_ffffff,
|
|
|
|
elevation: 0,
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(r(5)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
'确认执行',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
fontSize: font(16),
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|