shop_setting_page.dart
8.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
import 'package:flutter/material.dart';
import 'package:one_poem/res/resources.dart';
import 'package:one_poem/routers/fluro_navigator.dart';
import 'package:one_poem/shop/widgets/pay_type_dialog.dart';
import 'package:one_poem/shop/widgets/price_input_dialog.dart';
import 'package:one_poem/shop/widgets/send_type_dialog.dart';
import 'package:one_poem/util/other_utils.dart';
import 'package:one_poem/widgets/click_item.dart';
import 'package:one_poem/widgets/my_app_bar.dart';
import 'package:one_poem/widgets/my_button.dart';
import 'package:one_poem/widgets/my_scroll_view.dart';
import '../shop_router.dart';
/// design/7店铺-店铺配置/index.html#artboard17
class ShopSettingPage extends StatefulWidget {
const ShopSettingPage({Key? key}) : super(key: key);
@override
_ShopSettingPageState createState() => _ShopSettingPageState();
}
class _ShopSettingPageState extends State<ShopSettingPage> {
bool _check = false;
List<int> _selectValue = [0];
int _sendType = 0;
String _sendPrice = '0.00';
String _freePrice = '0.00';
String _phone = '';
String _shopIntroduction = '零食铺子坚果饮料美酒佳肴…';
String _securityService = '假一赔十';
String _address = '陕西省 西安市 长安区 郭杜镇郭北村韩林路圣方医院斜对面';
@override
Widget build(BuildContext context) {
return Scaffold(
// 防止键盘弹出,提交按钮升起。。。
resizeToAvoidBottomInset: false,
appBar: const MyAppBar(),
body: MyScrollView(
padding: const EdgeInsets.symmetric(vertical: 16.0),
bottomButton: Padding(
padding: const EdgeInsets.only(left: 16.0, right: 16.0, bottom: 8.0),
child: MyButton(
text: '提交',
onPressed: () => NavigatorUtils.goBack(context),
),
),
children: <Widget>[
Gaps.vGap5,
Row(
children: <Widget>[
Gaps.hGap16,
Text(
_check ? '正在营业' : '暂停营业',
style: TextStyles.textBold24,
),
const Spacer(),
Semantics(
label: '店铺营业开关',
child: Switch.adaptive(
value: _check,
onChanged: (bool val) {
setState(() {
_check = val;
});
},
),
),
Gaps.hGap4,
],
),
Gaps.vGap32,
const Padding(
padding: EdgeInsets.only(left: 16.0),
child: Text('基础设置', style: TextStyles.textBold18),
),
Gaps.vGap16,
ClickItem(
title: '店铺简介',
content: _shopIntroduction,
onTap: () {
_goInputTextPage(context, '店铺简介', '这里有一段完美的简介…', _shopIntroduction, (result) {
setState(() {
_shopIntroduction = result.toString();
});
},);
},
),
ClickItem(
title: '保障服务',
content: _securityService,
onTap: () {
_goInputTextPage(context, '保障服务', '这里有一段完美的说明…', _securityService, (result) {
setState(() {
_securityService = result.toString();
});
},);
},
),
ClickItem(
title: '支付方式',
content: _getPayType(),
onTap: _showPayTypeDialog,
),
Gaps.vGap32,
const Padding(
padding: EdgeInsets.only(left: 16.0),
child: Text('运费设置', style: TextStyles.textBold18),
),
Gaps.vGap16,
ClickItem(
title: '运费配置',
content: _sendType == 0 ? '运费满免配置' : '运费比例配置',
onTap: _showSendTypeDialog,
),
Visibility(
visible: _sendType != 1,
child: ClickItem(
title: '运费满免',
content: _freePrice,
onTap: () {
_showInputDialog('配送费满免', (value) {
setState(() {
_freePrice = value;
});
});
},
),
),
Visibility(
visible: _sendType != 1,
child: ClickItem(
title: '配送费用',
content: _sendPrice,
onTap: () {
_showInputDialog('配送费用', (value) {
setState(() {
_sendPrice = value;
});
});
},
),
),
Visibility(
visible: _sendType != 0,
child: ClickItem(
maxLines: 10,
title: '运费比例',
content: '1、订单金额<20元,配送费为订单金额的1%\n2、订单金额≥20元,配送费为订单金额的1%',
onTap: () => NavigatorUtils.push(context, ShopRouter.freightConfigPage),
),
),
Gaps.vGap32,
const Padding(
padding: EdgeInsets.only(left: 16.0),
child: Text('联系信息', style: TextStyles.textBold18,),
),
Gaps.vGap16,
ClickItem(
title: '联系电话',
content: _phone,
onTap: () {
_goInputTextPage(context, '联系电话', '这里有一串神秘的数字…', _phone, (result) {
setState(() {
_phone = result.toString();
});
}, keyboardType: TextInputType.phone,);
},
),
ClickItem(
maxLines: 2,
title: '店铺地址',
content: _address,
onTap: () {
// NavigatorUtils.pushResult(context, ShopRouter.addressSelectPage, (result) {
// setState(() {
// final PoiSearch model = result as PoiSearch;
// _address = '${model.provinceName.nullSafe} ${model.cityName.nullSafe} ${model.adName.nullSafe} ${model.title.nullSafe}';
// });
// });
},
),
Gaps.vGap8,
],
)
);
}
String _getPayType() {
String payType = '';
for (final int s in _selectValue) {
if (s == 0) {
payType = '$payType在线支付+';
} else if (s == 1) {
payType = '$payType对公转账+';
} else if (s == 2) {
payType = '$payType货到付款+';
}
}
return payType.substring(0, payType.length - 1);
}
void _goInputTextPage(BuildContext context, String title,
String hintText, String content, Function(Object?) function,
{TextInputType? keyboardType}) {
NavigatorUtils.pushResult(context,
ShopRouter.inputTextPage, function,
arguments: InputTextPageArgumentsData(
title: title,
hintText: hintText,
content: content,
keyboardType: keyboardType,
)
);
}
void _showInputDialog(String title, Function(String) onPressed) {
showDialog<void>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return PriceInputDialog(
title: title,
onPressed: onPressed,
);
},
);
}
void _showPayTypeDialog() {
showElasticDialog<void>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return PayTypeDialog(
value: _selectValue,
onPressed: (value) {
setState(() {
_selectValue = value.cast<int>();
});
},
);
},
);
}
void _showSendTypeDialog() {
showElasticDialog<void>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return SendTypeDialog(
onPressed: (i, value) {
setState(() {
_sendType = i;
});
},
);
},
);
}
}
class InputTextPageArgumentsData {
InputTextPageArgumentsData({
required this.title,
this.content,
this.hintText,
this.keyboardType,
});
late String title;
late String? content;
late String? hintText;
late TextInputType? keyboardType;
}