base_info_old.dart
21.8 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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
// import 'dart:io';
// import 'package:cached_network_image/cached_network_image.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter_screenutil/screenutil.dart';
// import 'package:one_key/models/upload_img_model.dart';
// import 'package:one_key/models/user.dart';
// import 'package:one_key/pages/online_check/photo_view_wiget.dart';
// import 'package:one_key/pages/online_check/progress.dart';
// import 'package:one_key/provider/base_info_provider.dart';
// import 'package:one_key/provider/upload_img_provider.dart';
// import 'package:one_key/provider/user_model.dart';
// import 'package:one_key/res/colors.dart';
// import 'package:one_key/utils/event_bus.dart';
// import 'package:one_key/utils/upload_image_util.dart';
// import 'package:one_key/utils/utils.dart';
// import 'package:one_key/widgets/h_empty_view.dart';
// import 'package:one_key/widgets/round_button.dart';
// import 'package:one_key/widgets/system_app_bar.dart';
// import 'package:one_key/widgets/v_empty_view.dart';
// import 'package:image_picker/image_picker.dart';
// import 'package:permission_handler/permission_handler.dart';
// import 'package:provider/provider.dart';
// class BaseInfoPage extends StatefulWidget {
// BaseInfoPage({Key key}) : super(key: key);
// @override
// _BaseInfoPageState createState() => _BaseInfoPageState();
// }
// class _BaseInfoPageState extends State<BaseInfoPage> {
// ScrollController _scrollController;
// TextEditingController _nameController = TextEditingController();
// TextEditingController _phoneController = TextEditingController();
// TextEditingController _positionController = TextEditingController();
// TextEditingController _wechatController = TextEditingController();
// FocusNode _nameFocusNode = FocusNode();
// FocusNode _phoneFocusNode = FocusNode();
// FocusNode _positionFocusNode = FocusNode();
// FocusNode _wechatFocusNode = FocusNode();
// final picker = ImagePicker();
// UploadImageProvider _uploadImageProvider;
// BaseIndoProvider _baseIndoProvider;
// @override
// void initState() {
// super.initState();
// _scrollController = ScrollController();
// WidgetsBinding.instance.addPostFrameCallback((_) {
// _uploadImageProvider.touxiang.process = 0.01;
// _uploadImageProvider.touxiang.qiniuUrl = '';
// _uploadImageProvider.erweima.process = 0.01;
// _uploadImageProvider.erweima.qiniuUrl = '';
// _uploadImageProvider.imgSizeTouxiang = 64;
// _uploadImageProvider.imgSizeErweima = 22;
// _getQiniuInfo();
// _getCustomerActivityBaseinfo();
// });
// }
// _getCustomerActivityBaseinfo() async {
// Map<String, String> params = {
// 'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid,
// "uid": Provider.of<UserModel>(context, listen: false).user.openid,
// };
// bool success =
// await _baseIndoProvider.getCustomerActivityBaseinfo(context, params);
// if (success) {
// _nameController.text = _baseIndoProvider.baseInfoSunModel.name;
// _uploadImageProvider.touxiang.qiniuUrl =
// _baseIndoProvider.baseInfoSunModel.photo;
// _uploadImageProvider.erweima.qiniuUrl =
// _baseIndoProvider.baseInfoSunModel.qrcode;
// _phoneController.text = _baseIndoProvider.baseInfoSunModel.phone;
// _wechatController.text = _baseIndoProvider.baseInfoSunModel.wechat;
// _positionController.text = _baseIndoProvider.baseInfoSunModel.position;
// _uploadImageProvider.imgSizeErweima = 64;
// // setState(() {});
// _uploadImageProvider.notifyListeners();
// }
// }
// ///获取七牛云token
// ///
// _getQiniuInfo() async {
// await _uploadImageProvider.getQiniuInfo(context, {});
// }
// //客户经理添加/修改基本信息
// _setCustomerActivityBaseinfo() async {
// FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
// User user = Provider.of<UserModel>(context, listen: false).user;
// Map<String, String> params = {
// 'sellerid': user.sellerid,
// "uid": user.openid,
// "name": _nameController.text.trim().length == 0
// ? user.sellername
// : _nameController.text.trim(),
// "photo": _uploadImageProvider.touxiang.qiniuUrl.trim().length == 0
// ? 'http://nosqn.colorcun.com/yd_person.png'
// : _uploadImageProvider.touxiang.qiniuUrl,
// "position": _positionController.text.trim().length == 0
// ? '经理'
// : _positionController.text,
// };
// if (_phoneController.text.trim().length == 0) {
// if (user.userphone != null) {
// params['phone'] = user.userphone;
// }
// } else {
// params['phone'] = _phoneController.text.trim();
// }
// if (_wechatController.text.trim().length > 0) {
// params['wechat'] = _wechatController.text;
// }
// if (_uploadImageProvider.erweima.qiniuUrl != null &&
// _uploadImageProvider.erweima.qiniuUrl != '') {
// params['qrcode'] = _uploadImageProvider.erweima.qiniuUrl;
// }
// if (_baseIndoProvider.baseInfoSunModel != null) {
// params['id'] = _baseIndoProvider.baseInfoSunModel.id;
// }
// bool isSuccess =
// await _baseIndoProvider.setCustomerActivityBaseinfo(context, params);
// // _baseIndoProvider.baseInfoSunModel = null;
// if (isSuccess) {
// _uploadImageProvider.touxiang.file = null;
// _uploadImageProvider.erweima.file = null;
// //成功之后跳回前一个页面
// // bus.emit('refresh_coupon_list');
// Utils.showToast('保存成功');
// EventBus().emit('changeStatusColor');
// Navigator.pop(context, true);
// }
// }
// ///输入框
// Widget _textfield(String title, String hintText,
// TextEditingController editingController, FocusNode focusNode) {
// return Container(
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Container(
// child: Text(
// title,
// style: TextStyle(
// color: MyColours.color_333333,
// fontWeight: FontWeight.bold,
// fontSize: ScreenUtil().setSp(34)),
// ),
// ),
// HEmptyView(80),
// Container(
// width: ScreenUtil().setWidth(231 * 2),
// child: TextField(
// controller: editingController,
// textAlign: TextAlign.right,
// textAlignVertical: TextAlignVertical.bottom,
// maxLines: 1,
// // //光标颜色
// // cursorColor:
// // widget.isSelect ? Colors.white : MyColours.color_199095,
// //输入文本的样式
// style: TextStyle(
// fontSize: ScreenUtil().setSp(32),
// ),
// focusNode: focusNode,
// decoration: InputDecoration(
// border: OutlineInputBorder(borderSide: BorderSide.none),
// hintText: hintText,
// hintStyle: TextStyle(
// color: MyColours.color_999999,
// fontSize: ScreenUtil().setSp(32),
// ),
// enabledBorder: new UnderlineInputBorder(
// borderSide: BorderSide.none,
// ),
// focusedBorder: new UnderlineInputBorder(
// borderSide: BorderSide.none,
// ),
// ),
// onChanged: (value) {},
// onEditingComplete: () {
// FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
// },
// keyboardType: TextInputType.text,
// ),
// )
// ],
// ),
// );
// }
// //查看大图
// _showPhotoView(BuildContext context, int index, List imgs,
// {isShow = false, List dashName}) async {
// // if (imgs.length == 1 &&
// // imgs[0] ==
// // 'http://nosqn.colorcun.com/custom/lite-online/image/def-banner.png') {
// // imgs[0] = 'http://nosqn.colorcun.com/app/seller-hj-empty.png';
// // }
// Utils.setBarStatus(false, color: Colors.black);
// dynamic result = await showGeneralDialog(
// context: context,
// barrierDismissible: false,
// // barrierColor: Colors.red,
// barrierLabel:
// MaterialLocalizations.of(context).modalBarrierDismissLabel,
// transitionDuration: const Duration(milliseconds: 150),
// pageBuilder: (BuildContext context, Animation animation,
// Animation secondaryAnimation) {
// Widget child = Stack(
// children: <Widget>[
// PhotoPreview(
// initialIndex: index,
// photoList: imgs,
// isShow: isShow,
// dashName: dashName)
// ],
// );
// return child;
// });
// Utils.setBarStatus(true, color: Colors.white);
// }
// ///#相机拍照,单图选择
// Future _getFromPictureOrCamera(
// String title, UploadImgModel imgModel, imageSource) async {
// final pickedFile = await picker.getImage(source: imageSource);
// setState(() {
// if (pickedFile != null) {
// imgModel.file = File(pickedFile.path);
// imgModel.process = 0.01;
// } else {
// print('No image selected.');
// }
// });
// if (pickedFile != null) {
// if (title == '头像') {
// _uploadImageProvider.imgSizeTouxiang = 64;
// _uploadImageProvider.touxiang.qiniuUrl = null;
// } else {
// _uploadImageProvider.imgSizeErweima = 64;
// _uploadImageProvider.erweima.qiniuUrl = null;
// }
// UploadImageUtil().startUploadOnly(context, File(pickedFile.path),
// title == '头像' ? 0 : 1, true, _uploadImageProvider);
// }
// }
// ///图片 头像和二维码
// Widget _imageWidget(
// String title, UploadImgModel model, double imgSize, double radius) {
// return InkWell(
// onTap: () {
// Utils.getPickPermission(context, () {
// _getFromPictureOrCamera(title, model, ImageSource.gallery);
// }, Platform.isAndroid ? Permission.storage : Permission.photos);
// },
// child: Container(
// margin: EdgeInsets.only(
// top: ScreenUtil().setWidth(40),
// left: ScreenUtil().setWidth(40),
// right: ScreenUtil().setWidth(40)),
// height: ScreenUtil().setWidth(imgSize * 2),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Text(
// title,
// textAlign: TextAlign.left,
// style: TextStyle(
// color: MyColours.color_333333,
// fontWeight: FontWeight.bold,
// fontSize: ScreenUtil().setSp(34)),
// ),
// Spacer(),
// Stack(
// children: [
// InkWell(
// onTap: () {
// double process;
// String qiniuUrl;
// List<String> tempList = [];
// if (title == '头像') {
// process = _uploadImageProvider.touxiang.process;
// qiniuUrl = _uploadImageProvider.touxiang.qiniuUrl;
// } else {
// process = _uploadImageProvider.erweima.process;
// qiniuUrl = _uploadImageProvider.erweima.qiniuUrl;
// }
// if (qiniuUrl != null && qiniuUrl != '') {
// tempList.add(qiniuUrl);
// ///没有上传完成的不可以点击
// _showPhotoView(context, 0, tempList);
// } else {
// Utils.getPickPermission(context, () {
// _getFromPictureOrCamera(
// title, model, ImageSource.gallery);
// },
// Platform.isAndroid
// ? Permission.storage
// : Permission.photos);
// }
// },
// child: ClipRRect(
// borderRadius:
// BorderRadius.circular(ScreenUtil().setWidth(radius)),
// child: model.file == null
// ? model.qiniuUrl != null && model.qiniuUrl != ''
// ? Image.network(
// model.qiniuUrl,
// fit: BoxFit.cover,
// width: ScreenUtil().setWidth(imgSize * 2),
// height: ScreenUtil().setWidth(imgSize * 2),
// )
// : Image.asset(
// Utils.getImgPath(
// title == '头像' ? 'touxiang' : 'erweima'),
// fit: BoxFit.cover,
// width: ScreenUtil().setWidth(imgSize * 2),
// height: ScreenUtil().setWidth(imgSize * 2),
// )
// : Image.file(
// model.file,
// fit: BoxFit.cover,
// width: ScreenUtil().setWidth(imgSize * 2),
// height: ScreenUtil().setWidth(imgSize * 2),
// ),
// ),
// ),
// (model.file != null) &&
// model.process != 1 &&
// model.process != 0.01
// ? Container(
// width: ScreenUtil().setWidth(imgSize * 2),
// height: ScreenUtil().setWidth(imgSize * 2),
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(radius),
// color: Color.fromRGBO(0, 0, 0, 0.6)),
// child: Center(
// child: Text('上传中',
// style:
// TextStyle(color: MyColours.color_999999)),
// ),
// )
// : Container(),
// ],
// ),
// HEmptyView(30),
// Image.asset(
// "assets/arr_right_gray.png",
// width: ScreenUtil().setWidth(14),
// height: ScreenUtil().setWidth(22),
// )
// ],
// ),
// ));
// }
// @override
// Widget build(BuildContext context) {
// _uploadImageProvider =
// Provider.of<UploadImageProvider>(context, listen: true);
// _baseIndoProvider = Provider.of<BaseIndoProvider>(context, listen: true);
// return Scaffold(
// backgroundColor: MyColours.color_fefefe,
// appBar: SystemAppBar(
// '个人信息',
// onTap: () {
// EventBus().emit('changeStatusColor');
// Navigator.of(context).pop();
// },
// ),
// body: WillPopScope(
// onWillPop: () {
// EventBus().emit('changeStatusColor');
// Navigator.of(context).pop();
// },
// child: InkWell(
// onTap: () {
// FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
// },
// child: Container(
// color: MyColours.color_ffffff,
// child: Column(children: [
// Expanded(
// child: SingleChildScrollView(
// controller: _scrollController,
// physics: BouncingScrollPhysics(),
// child: Column(
// children: [
// _imageWidget(
// '头像',
// _uploadImageProvider.touxiang,
// _uploadImageProvider.imgSizeTouxiang,
// 64),
// VEmptyView(30),
// Container(
// height: ScreenUtil().setWidth(2),
// color: MyColours.color_efefef,
// margin: EdgeInsets.only(
// left: ScreenUtil().setWidth(108 * 2),
// right: ScreenUtil().setWidth(40)),
// ),
// VEmptyView(10),
// Padding(
// padding: EdgeInsets.symmetric(
// horizontal: ScreenUtil().setWidth(40),
// ),
// child: _textfield('姓名', '请填写您的姓名',
// _nameController, _nameFocusNode)),
// VEmptyView(10),
// Container(
// height: ScreenUtil().setWidth(2),
// color: MyColours.color_efefef,
// margin: EdgeInsets.only(
// left: ScreenUtil().setWidth(108 * 2),
// right: ScreenUtil().setWidth(40)),
// ),
// VEmptyView(10),
// Padding(
// padding: EdgeInsets.symmetric(
// horizontal: ScreenUtil().setWidth(40),
// ),
// child: _textfield('电话', '请填写您的联系电话',
// _phoneController, _phoneFocusNode)),
// VEmptyView(10),
// Container(
// height: ScreenUtil().setWidth(2),
// color: MyColours.color_efefef,
// margin: EdgeInsets.only(
// left: ScreenUtil().setWidth(108 * 2),
// right: ScreenUtil().setWidth(40)),
// ),
// VEmptyView(10),
// Padding(
// padding: EdgeInsets.symmetric(
// horizontal: ScreenUtil().setWidth(40),
// ),
// child: _textfield(
// '职位',
// '请填写您在餐厅中担任的职位',
// _positionController,
// _positionFocusNode)),
// VEmptyView(10),
// Container(
// height: ScreenUtil().setWidth(2),
// color: MyColours.color_efefef,
// margin: EdgeInsets.only(
// left: ScreenUtil().setWidth(108 * 2),
// right: ScreenUtil().setWidth(40)),
// ),
// VEmptyView(40),
// // _imageWidget('微信二维码', _uploadImageProvider.erweima,
// // _uploadImageProvider.imgSizeErweima, 0),
// Padding(
// padding: EdgeInsets.symmetric(
// horizontal: ScreenUtil().setWidth(40),
// ),
// child: _textfield('微信号', '请填写您的微信号',
// _wechatController, _wechatFocusNode)),
// VEmptyView(30),
// ],
// )),
// ),
// VEmptyView(20),
// Padding(
// padding: EdgeInsets.fromLTRB(
// ScreenUtil().setWidth(40),
// 0,
// ScreenUtil().setWidth(40),
// ScreenUtil().setWidth(40)),
// child: RoundButton(
// onPressed: () {
// //接口
// _setCustomerActivityBaseinfo();
// },
// text: '保存',
// fontSize: 34,
// isBold: false,
// height: ScreenUtil().setWidth(80),
// width: double.infinity,
// radius: ScreenUtil().setWidth(10),
// ))
// ])))));
// }
// }