Showing
18 changed files
with
1012 additions
and
150 deletions
assets/edit.png
0 → 100644
769 Bytes
assets/erweima.png
0 → 100644
1.64 KB
assets/touxiang.png
0 → 100644
7.15 KB
| @@ -10,6 +10,7 @@ import 'package:flutter_easyrefresh/easy_refresh.dart'; | @@ -10,6 +10,7 @@ import 'package:flutter_easyrefresh/easy_refresh.dart'; | ||
| 10 | import 'package:flutter_easyrefresh/material_header.dart'; | 10 | import 'package:flutter_easyrefresh/material_header.dart'; |
| 11 | import 'package:fluwx/fluwx.dart'; | 11 | import 'package:fluwx/fluwx.dart'; |
| 12 | import 'package:one_key/pages/detail/handle_online_page.dart'; | 12 | import 'package:one_key/pages/detail/handle_online_page.dart'; |
| 13 | +import 'package:one_key/provider/base_info_provider.dart'; | ||
| 13 | import 'package:one_key/provider/coupon_provider.dart'; | 14 | import 'package:one_key/provider/coupon_provider.dart'; |
| 14 | import 'package:one_key/provider/message_dialog_model.dart'; | 15 | import 'package:one_key/provider/message_dialog_model.dart'; |
| 15 | import 'package:intl/date_symbol_data_local.dart'; | 16 | import 'package:intl/date_symbol_data_local.dart'; |
| @@ -69,6 +70,9 @@ Future<void> main() async { | @@ -69,6 +70,9 @@ Future<void> main() async { | ||
| 69 | ChangeNotifierProvider<UploadImageProvider>( | 70 | ChangeNotifierProvider<UploadImageProvider>( |
| 70 | create: (_) => UploadImageProvider(), | 71 | create: (_) => UploadImageProvider(), |
| 71 | ), | 72 | ), |
| 73 | + ChangeNotifierProvider<BaseIndoProvider>( | ||
| 74 | + create: (_) => BaseIndoProvider(), | ||
| 75 | + ), | ||
| 72 | ], | 76 | ], |
| 73 | child: MyApp(), | 77 | child: MyApp(), |
| 74 | )); | 78 | )); |
lib/models/base_info_model.dart
0 → 100644
| 1 | +import 'package:json_annotation/json_annotation.dart'; | ||
| 2 | + | ||
| 3 | +part 'base_info_model.g.dart'; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +@JsonSerializable() | ||
| 7 | + class BaseInfoModel extends Object { | ||
| 8 | + | ||
| 9 | + @JsonKey(name: 'ret') | ||
| 10 | + int ret; | ||
| 11 | + | ||
| 12 | + @JsonKey(name: 'data') | ||
| 13 | + BaseInfoSunModel data; | ||
| 14 | + | ||
| 15 | + @JsonKey(name: 'msg') | ||
| 16 | + String msg; | ||
| 17 | + | ||
| 18 | + BaseInfoModel(this.ret,this.data,this.msg,); | ||
| 19 | + | ||
| 20 | + factory BaseInfoModel.fromJson(Map<String, dynamic> srcJson) => _$BaseInfoModelFromJson(srcJson); | ||
| 21 | + | ||
| 22 | + Map<String, dynamic> toJson() => _$BaseInfoModelToJson(this); | ||
| 23 | + | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +@JsonSerializable() | ||
| 28 | + class BaseInfoSunModel extends Object { | ||
| 29 | + | ||
| 30 | + @JsonKey(name: 'id') | ||
| 31 | + String id; | ||
| 32 | + | ||
| 33 | + @JsonKey(name: 'sellerid') | ||
| 34 | + String sellerid; | ||
| 35 | + | ||
| 36 | + @JsonKey(name: 'uid') | ||
| 37 | + String uid; | ||
| 38 | + | ||
| 39 | + @JsonKey(name: 'photo') | ||
| 40 | + String photo; | ||
| 41 | + | ||
| 42 | + @JsonKey(name: 'name') | ||
| 43 | + String name; | ||
| 44 | + | ||
| 45 | + @JsonKey(name: 'phone') | ||
| 46 | + String phone; | ||
| 47 | + | ||
| 48 | + @JsonKey(name: 'position') | ||
| 49 | + String position; | ||
| 50 | + | ||
| 51 | + @JsonKey(name: 'qrcode') | ||
| 52 | + String qrcode; | ||
| 53 | + | ||
| 54 | + BaseInfoSunModel(this.id,this.sellerid,this.uid,this.photo,this.name,this.phone,this.position,this.qrcode,); | ||
| 55 | + | ||
| 56 | + factory BaseInfoSunModel.fromJson(Map<String, dynamic> srcJson) => _$BaseInfoSunModelFromJson(srcJson); | ||
| 57 | + | ||
| 58 | + Map<String, dynamic> toJson() => _$BaseInfoSunModelToJson(this); | ||
| 59 | + | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | + |
lib/models/base_info_model.g.dart
0 → 100644
| 1 | +// GENERATED CODE - DO NOT MODIFY BY HAND | ||
| 2 | + | ||
| 3 | +part of 'base_info_model.dart'; | ||
| 4 | + | ||
| 5 | +// ************************************************************************** | ||
| 6 | +// JsonSerializableGenerator | ||
| 7 | +// ************************************************************************** | ||
| 8 | + | ||
| 9 | +BaseInfoModel _$BaseInfoModelFromJson(Map<String, dynamic> json) { | ||
| 10 | + return BaseInfoModel( | ||
| 11 | + json['ret'] as int, | ||
| 12 | + json['data'] == null | ||
| 13 | + ? null | ||
| 14 | + : BaseInfoSunModel.fromJson(json['data'] as Map<String, dynamic>), | ||
| 15 | + json['msg'] as String); | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +Map<String, dynamic> _$BaseInfoModelToJson(BaseInfoModel instance) => | ||
| 19 | + <String, dynamic>{ | ||
| 20 | + 'ret': instance.ret, | ||
| 21 | + 'data': instance.data, | ||
| 22 | + 'msg': instance.msg | ||
| 23 | + }; | ||
| 24 | + | ||
| 25 | +BaseInfoSunModel _$BaseInfoSunModelFromJson(Map<String, dynamic> json) { | ||
| 26 | + return BaseInfoSunModel( | ||
| 27 | + json['id'] as String, | ||
| 28 | + json['sellerid'] as String, | ||
| 29 | + json['uid'] as String, | ||
| 30 | + json['photo'] as String, | ||
| 31 | + json['name'] as String, | ||
| 32 | + json['phone'] as String, | ||
| 33 | + json['position'] as String, | ||
| 34 | + json['qrcode'] as String); | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +Map<String, dynamic> _$BaseInfoSunModelToJson(BaseInfoSunModel instance) => | ||
| 38 | + <String, dynamic>{ | ||
| 39 | + 'id': instance.id, | ||
| 40 | + 'sellerid': instance.sellerid, | ||
| 41 | + 'uid': instance.uid, | ||
| 42 | + 'photo': instance.photo, | ||
| 43 | + 'name': instance.name, | ||
| 44 | + 'phone': instance.phone, | ||
| 45 | + 'position': instance.position, | ||
| 46 | + 'qrcode': instance.qrcode | ||
| 47 | + }; |
| @@ -81,5 +81,9 @@ class HttpUrl { | @@ -81,5 +81,9 @@ class HttpUrl { | ||
| 81 | "?service=App.Activity.SetActivityAsReserve"; //设置预定绑定活动ID | 81 | "?service=App.Activity.SetActivityAsReserve"; //设置预定绑定活动ID |
| 82 | static const String get_activity_by_rid = | 82 | static const String get_activity_by_rid = |
| 83 | "?service=App.Activity.GetActivityByRid"; //获取预定绑定活动 | 83 | "?service=App.Activity.GetActivityByRid"; //获取预定绑定活动 |
| 84 | + static const String set_customer_activity_baseinfo = | ||
| 85 | + "?service=App.Activity.SetCustomerActivityBaseinfo"; //客户经理添加/修改基本信息 | ||
| 86 | + static const String get_customer_activity_baseinfo = | ||
| 87 | + "?service=App.Activity.GetCustomerActivityBaseinfo"; //客户经理获取基本信息 | ||
| 84 | 88 | ||
| 85 | } | 89 | } |
lib/pages/my/base_info.dart
0 → 100644
| 1 | +import 'dart:io'; | ||
| 2 | + | ||
| 3 | +import 'package:cached_network_image/cached_network_image.dart'; | ||
| 4 | +import 'package:flutter/material.dart'; | ||
| 5 | +import 'package:flutter_screenutil/screenutil.dart'; | ||
| 6 | +import 'package:one_key/models/upload_img_model.dart'; | ||
| 7 | +import 'package:one_key/pages/online_check/progress.dart'; | ||
| 8 | +import 'package:one_key/provider/base_info_provider.dart'; | ||
| 9 | +import 'package:one_key/provider/upload_img_provider.dart'; | ||
| 10 | +import 'package:one_key/provider/user_model.dart'; | ||
| 11 | +import 'package:one_key/res/colors.dart'; | ||
| 12 | +import 'package:one_key/utils/event_bus.dart'; | ||
| 13 | +import 'package:one_key/utils/upload_image_util.dart'; | ||
| 14 | +import 'package:one_key/utils/utils.dart'; | ||
| 15 | +import 'package:one_key/widgets/h_empty_view.dart'; | ||
| 16 | +import 'package:one_key/widgets/round_button.dart'; | ||
| 17 | +import 'package:one_key/widgets/system_app_bar.dart'; | ||
| 18 | +import 'package:one_key/widgets/v_empty_view.dart'; | ||
| 19 | +import 'package:image_picker/image_picker.dart'; | ||
| 20 | +import 'package:permission_handler/permission_handler.dart'; | ||
| 21 | +import 'package:provider/provider.dart'; | ||
| 22 | + | ||
| 23 | +class BaseInfoPage extends StatefulWidget { | ||
| 24 | + BaseInfoPage({Key key}) : super(key: key); | ||
| 25 | + | ||
| 26 | + @override | ||
| 27 | + _BaseInfoPageState createState() => _BaseInfoPageState(); | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +class _BaseInfoPageState extends State<BaseInfoPage> { | ||
| 31 | + ScrollController _scrollController; | ||
| 32 | + TextEditingController _nameController = TextEditingController(); | ||
| 33 | + TextEditingController _phoneController = TextEditingController(); | ||
| 34 | + TextEditingController _positionController = TextEditingController(); | ||
| 35 | + | ||
| 36 | + FocusNode _nameFocusNode = FocusNode(); | ||
| 37 | + FocusNode _phoneFocusNode = FocusNode(); | ||
| 38 | + FocusNode _positionFocusNode = FocusNode(); | ||
| 39 | + | ||
| 40 | + final picker = ImagePicker(); | ||
| 41 | + // OnlineCheckEditProvider _onlineCheckEditProvider; | ||
| 42 | + UploadImageProvider _uploadImageProvider; | ||
| 43 | + BaseIndoProvider _baseIndoProvider; | ||
| 44 | + | ||
| 45 | + @override | ||
| 46 | + void initState() { | ||
| 47 | + super.initState(); | ||
| 48 | + _scrollController = ScrollController(); | ||
| 49 | + WidgetsBinding.instance.addPostFrameCallback((_) { | ||
| 50 | + _uploadImageProvider.touxiang.process = 0.01; | ||
| 51 | + _uploadImageProvider.touxiang.qiniuUrl = ''; | ||
| 52 | + _uploadImageProvider.erweima.process = 0.01; | ||
| 53 | + _uploadImageProvider.erweima.qiniuUrl = ''; | ||
| 54 | + _uploadImageProvider.imgSizeTouxiang = 64; | ||
| 55 | + _uploadImageProvider.imgSizeErweima = 22; | ||
| 56 | + _getQiniuInfo(); | ||
| 57 | + _getCustomerActivityBaseinfo(); | ||
| 58 | + }); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + _getCustomerActivityBaseinfo() async { | ||
| 62 | + Map<String, String> params = { | ||
| 63 | + 'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid, | ||
| 64 | + "uid": Provider.of<UserModel>(context, listen: false).user.openid, | ||
| 65 | + }; | ||
| 66 | + bool success = | ||
| 67 | + await _baseIndoProvider.getCustomerActivityBaseinfo(context, params); | ||
| 68 | + if (success) { | ||
| 69 | + _nameController.text = _baseIndoProvider.baseInfoSunModel.name; | ||
| 70 | + _uploadImageProvider.touxiang.qiniuUrl = | ||
| 71 | + _baseIndoProvider.baseInfoSunModel.photo; | ||
| 72 | + _uploadImageProvider.erweima.qiniuUrl = | ||
| 73 | + _baseIndoProvider.baseInfoSunModel.qrcode; | ||
| 74 | + _phoneController.text = _baseIndoProvider.baseInfoSunModel.phone; | ||
| 75 | + _positionController.text = _baseIndoProvider.baseInfoSunModel.position; | ||
| 76 | + _uploadImageProvider.imgSizeErweima = 64; | ||
| 77 | + setState(() {}); | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + ///获取七牛云token | ||
| 82 | + /// | ||
| 83 | + _getQiniuInfo() async { | ||
| 84 | + await _uploadImageProvider.getQiniuInfo(context, {}); | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + //客户经理添加/修改基本信息 | ||
| 88 | + _setCustomerActivityBaseinfo() async { | ||
| 89 | + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 90 | + Map<String, String> params = { | ||
| 91 | + 'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid, | ||
| 92 | + "uid": Provider.of<UserModel>(context, listen: false).user.openid, | ||
| 93 | + "name": _nameController.text.trim(), | ||
| 94 | + "photo": _uploadImageProvider.touxiang.qiniuUrl, | ||
| 95 | + "phone": _phoneController.text.trim(), | ||
| 96 | + "position": _positionController.text, | ||
| 97 | + "qrcode": _uploadImageProvider.erweima.qiniuUrl, | ||
| 98 | + }; | ||
| 99 | + bool isSuccess = | ||
| 100 | + await _baseIndoProvider.setCustomerActivityBaseinfo(context, params); | ||
| 101 | + if (isSuccess) { | ||
| 102 | + //成功之后跳回前一个页面 | ||
| 103 | + // bus.emit('refresh_coupon_list'); | ||
| 104 | + Utils.showToast('保存成功'); | ||
| 105 | + EventBus().emit('changeStatusColor'); | ||
| 106 | + Navigator.pop(context, true); | ||
| 107 | + } | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + ///输入框 | ||
| 111 | + Widget _textfield(String title, String hintText, | ||
| 112 | + TextEditingController editingController, FocusNode focusNode) { | ||
| 113 | + return Container( | ||
| 114 | + child: Row( | ||
| 115 | + mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
| 116 | + children: [ | ||
| 117 | + Container( | ||
| 118 | + child: Text( | ||
| 119 | + title, | ||
| 120 | + style: TextStyle( | ||
| 121 | + color: MyColours.color_333333, | ||
| 122 | + fontWeight: FontWeight.bold, | ||
| 123 | + fontSize: ScreenUtil().setSp(34)), | ||
| 124 | + ), | ||
| 125 | + ), | ||
| 126 | + HEmptyView(80), | ||
| 127 | + Container( | ||
| 128 | + width: ScreenUtil().setWidth(231 * 2), | ||
| 129 | + child: TextField( | ||
| 130 | + controller: editingController, | ||
| 131 | + textAlign: TextAlign.right, | ||
| 132 | + textAlignVertical: TextAlignVertical.bottom, | ||
| 133 | + maxLines: 1, | ||
| 134 | + // //光标颜色 | ||
| 135 | + // cursorColor: | ||
| 136 | + // widget.isSelect ? Colors.white : MyColours.color_199095, | ||
| 137 | + //输入文本的样式 | ||
| 138 | + style: TextStyle( | ||
| 139 | + fontSize: ScreenUtil().setSp(32), | ||
| 140 | + ), | ||
| 141 | + focusNode: focusNode, | ||
| 142 | + decoration: InputDecoration( | ||
| 143 | + border: OutlineInputBorder(borderSide: BorderSide.none), | ||
| 144 | + hintText: hintText, | ||
| 145 | + hintStyle: TextStyle( | ||
| 146 | + color: MyColours.color_999999, | ||
| 147 | + fontSize: ScreenUtil().setSp(32), | ||
| 148 | + ), | ||
| 149 | + enabledBorder: new UnderlineInputBorder( | ||
| 150 | + borderSide: BorderSide.none, | ||
| 151 | + ), | ||
| 152 | + focusedBorder: new UnderlineInputBorder( | ||
| 153 | + borderSide: BorderSide.none, | ||
| 154 | + ), | ||
| 155 | + ), | ||
| 156 | + onChanged: (value) {}, | ||
| 157 | + onEditingComplete: () { | ||
| 158 | + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 159 | + }, | ||
| 160 | + keyboardType: TextInputType.text, | ||
| 161 | + ), | ||
| 162 | + ) | ||
| 163 | + ], | ||
| 164 | + ), | ||
| 165 | + ); | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + ///#相机拍照,单图选择 | ||
| 169 | + Future _getFromPictureOrCamera( | ||
| 170 | + String title, UploadImgModel imgModel, imageSource) async { | ||
| 171 | + final pickedFile = await picker.getImage(source: imageSource); | ||
| 172 | + setState(() { | ||
| 173 | + if (pickedFile != null) { | ||
| 174 | + imgModel.file = File(pickedFile.path); | ||
| 175 | + imgModel.process = 0.01; | ||
| 176 | + } else { | ||
| 177 | + print('No image selected.'); | ||
| 178 | + } | ||
| 179 | + }); | ||
| 180 | + if (pickedFile != null) { | ||
| 181 | + title == '头像' | ||
| 182 | + ? _uploadImageProvider.imgSizeTouxiang = 64 | ||
| 183 | + : _uploadImageProvider.imgSizeErweima = 64; | ||
| 184 | + UploadImageUtil().startUploadOnly(context, File(pickedFile.path), | ||
| 185 | + title == '头像' ? 0 : 1, true, _uploadImageProvider); | ||
| 186 | + } | ||
| 187 | + } | ||
| 188 | + | ||
| 189 | + ///图片 头像和二维码 | ||
| 190 | + Widget _imageWidget( | ||
| 191 | + String title, UploadImgModel model, double imgSize, double radius) { | ||
| 192 | + return InkWell( | ||
| 193 | + onTap: () { | ||
| 194 | + Utils.getPickPermission(context, () { | ||
| 195 | + _getFromPictureOrCamera(title, model, ImageSource.gallery); | ||
| 196 | + }, PermissionGroup.photos); | ||
| 197 | + }, | ||
| 198 | + child: Container( | ||
| 199 | + height: ScreenUtil().setWidth(imgSize * 2), | ||
| 200 | + child: Row( | ||
| 201 | + mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
| 202 | + children: [ | ||
| 203 | + Text( | ||
| 204 | + title, | ||
| 205 | + textAlign: TextAlign.left, | ||
| 206 | + style: TextStyle( | ||
| 207 | + color: MyColours.color_333333, | ||
| 208 | + fontWeight: FontWeight.bold, | ||
| 209 | + fontSize: ScreenUtil().setSp(34)), | ||
| 210 | + ), | ||
| 211 | + Spacer(), | ||
| 212 | + Stack( | ||
| 213 | + children: [ | ||
| 214 | + ClipRRect( | ||
| 215 | + borderRadius: | ||
| 216 | + BorderRadius.circular(ScreenUtil().setWidth(radius)), | ||
| 217 | + child: model.file == null | ||
| 218 | + ? model.qiniuUrl != null | ||
| 219 | + ? CachedNetworkImage( | ||
| 220 | + imageUrl: model.qiniuUrl, | ||
| 221 | + fit: BoxFit.cover, | ||
| 222 | + width: ScreenUtil().setWidth(imgSize * 2), | ||
| 223 | + height: ScreenUtil().setWidth(imgSize * 2), | ||
| 224 | + ) | ||
| 225 | + : Image.asset( | ||
| 226 | + Utils.getImgPath( | ||
| 227 | + title == '头像' ? 'touxiang' : 'erweima'), | ||
| 228 | + fit: BoxFit.cover, | ||
| 229 | + width: ScreenUtil().setWidth(imgSize * 2), | ||
| 230 | + height: ScreenUtil().setWidth(imgSize * 2), | ||
| 231 | + ) | ||
| 232 | + : Image.file( | ||
| 233 | + model.file, | ||
| 234 | + fit: BoxFit.cover, | ||
| 235 | + width: ScreenUtil().setWidth(imgSize * 2), | ||
| 236 | + height: ScreenUtil().setWidth(imgSize * 2), | ||
| 237 | + ), | ||
| 238 | + ), | ||
| 239 | + model.file == null && model.qiniuUrl == null | ||
| 240 | + ? Offstage( | ||
| 241 | + offstage: model.process == 1, | ||
| 242 | + child: Container( | ||
| 243 | + width: ScreenUtil().setWidth(imgSize * 2), | ||
| 244 | + height: ScreenUtil().setWidth(imgSize * 2), | ||
| 245 | + decoration: BoxDecoration( | ||
| 246 | + borderRadius: BorderRadius.circular(radius), | ||
| 247 | + color: Color.fromRGBO(0, 0, 0, 0.2)), | ||
| 248 | + child: Center( | ||
| 249 | + child: Text('上传中', | ||
| 250 | + style: | ||
| 251 | + TextStyle(color: MyColours.color_333333)), | ||
| 252 | + ), | ||
| 253 | + ), | ||
| 254 | + ) | ||
| 255 | + : Container(), | ||
| 256 | + ], | ||
| 257 | + ), | ||
| 258 | + HEmptyView(30), | ||
| 259 | + Image.asset( | ||
| 260 | + "assets/arr_right_gray.png", | ||
| 261 | + width: ScreenUtil().setWidth(14), | ||
| 262 | + height: ScreenUtil().setWidth(22), | ||
| 263 | + ) | ||
| 264 | + ], | ||
| 265 | + ), | ||
| 266 | + )); | ||
| 267 | + } | ||
| 268 | + | ||
| 269 | + @override | ||
| 270 | + Widget build(BuildContext context) { | ||
| 271 | + _uploadImageProvider = | ||
| 272 | + Provider.of<UploadImageProvider>(context, listen: true); | ||
| 273 | + _baseIndoProvider = Provider.of<BaseIndoProvider>(context, listen: true); | ||
| 274 | + return Scaffold( | ||
| 275 | + backgroundColor: MyColours.color_fefefe, | ||
| 276 | + appBar: SystemAppBar( | ||
| 277 | + '填写信息', | ||
| 278 | + onTap: () { | ||
| 279 | + EventBus().emit('changeStatusColor'); | ||
| 280 | + Navigator.of(context).pop(); | ||
| 281 | + }, | ||
| 282 | + ), | ||
| 283 | + body: InkWell( | ||
| 284 | + onTap: () { | ||
| 285 | + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 286 | + }, | ||
| 287 | + child: Column(children: [ | ||
| 288 | + Expanded( | ||
| 289 | + child: SingleChildScrollView( | ||
| 290 | + controller: _scrollController, | ||
| 291 | + physics: BouncingScrollPhysics(), | ||
| 292 | + child: Padding( | ||
| 293 | + padding: EdgeInsets.all(ScreenUtil().setWidth(40)), | ||
| 294 | + child: Column( | ||
| 295 | + children: [ | ||
| 296 | + _imageWidget('头像', _uploadImageProvider.touxiang, | ||
| 297 | + _uploadImageProvider.imgSizeTouxiang, 64), | ||
| 298 | + VEmptyView(30), | ||
| 299 | + Container( | ||
| 300 | + height: ScreenUtil().setWidth(2), | ||
| 301 | + color: MyColours.color_efefef, | ||
| 302 | + margin: EdgeInsets.only( | ||
| 303 | + left: ScreenUtil().setWidth(108 * 2)), | ||
| 304 | + ), | ||
| 305 | + VEmptyView(10), | ||
| 306 | + _textfield('姓名', '请填写您的姓名', _nameController, | ||
| 307 | + _nameFocusNode), | ||
| 308 | + VEmptyView(10), | ||
| 309 | + Container( | ||
| 310 | + height: ScreenUtil().setWidth(2), | ||
| 311 | + color: MyColours.color_efefef, | ||
| 312 | + margin: EdgeInsets.only( | ||
| 313 | + left: ScreenUtil().setWidth(108 * 2)), | ||
| 314 | + ), | ||
| 315 | + VEmptyView(10), | ||
| 316 | + _textfield('电话', '请填写您的联系电话', _phoneController, | ||
| 317 | + _phoneFocusNode), | ||
| 318 | + VEmptyView(10), | ||
| 319 | + Container( | ||
| 320 | + height: ScreenUtil().setWidth(2), | ||
| 321 | + color: MyColours.color_efefef, | ||
| 322 | + margin: EdgeInsets.only( | ||
| 323 | + left: ScreenUtil().setWidth(108 * 2)), | ||
| 324 | + ), | ||
| 325 | + VEmptyView(10), | ||
| 326 | + _textfield('职位', '请填写您在餐厅中担任的职位', | ||
| 327 | + _positionController, _positionFocusNode), | ||
| 328 | + VEmptyView(10), | ||
| 329 | + Container( | ||
| 330 | + height: ScreenUtil().setWidth(2), | ||
| 331 | + color: MyColours.color_efefef, | ||
| 332 | + margin: EdgeInsets.only( | ||
| 333 | + left: ScreenUtil().setWidth(108 * 2)), | ||
| 334 | + ), | ||
| 335 | + VEmptyView(40), | ||
| 336 | + _imageWidget('微信二维码', _uploadImageProvider.erweima, | ||
| 337 | + _uploadImageProvider.imgSizeErweima, 0), | ||
| 338 | + VEmptyView(30), | ||
| 339 | + ], | ||
| 340 | + ))), | ||
| 341 | + ), | ||
| 342 | + VEmptyView(20), | ||
| 343 | + Padding( | ||
| 344 | + padding: EdgeInsets.fromLTRB(ScreenUtil().setWidth(40), 0, | ||
| 345 | + ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)), | ||
| 346 | + child: RoundButton( | ||
| 347 | + onPressed: () { | ||
| 348 | + if (_uploadImageProvider.touxiang.qiniuUrl | ||
| 349 | + .trim() | ||
| 350 | + .length == | ||
| 351 | + 0) { | ||
| 352 | + Utils.showToast('请上传头像'); | ||
| 353 | + return; | ||
| 354 | + } | ||
| 355 | + if (_nameController.text.trim().length == 0) { | ||
| 356 | + Utils.showToast('请填写您的姓名'); | ||
| 357 | + return; | ||
| 358 | + } | ||
| 359 | + if (_phoneController.text.trim().length == 0) { | ||
| 360 | + Utils.showToast('请填写您的联系电话'); | ||
| 361 | + return; | ||
| 362 | + } | ||
| 363 | + if (_positionController.text.trim().length == 0) { | ||
| 364 | + Utils.showToast('请填写您在餐厅中担任的职位'); | ||
| 365 | + return; | ||
| 366 | + } | ||
| 367 | + if (_uploadImageProvider.erweima.qiniuUrl.trim().length == | ||
| 368 | + 0) { | ||
| 369 | + Utils.showToast('请上传头像'); | ||
| 370 | + return; | ||
| 371 | + } | ||
| 372 | + | ||
| 373 | + //接口 | ||
| 374 | + _setCustomerActivityBaseinfo(); | ||
| 375 | + }, | ||
| 376 | + text: '保存', | ||
| 377 | + fontSize: 34, | ||
| 378 | + isBold: false, | ||
| 379 | + height: ScreenUtil().setWidth(80), | ||
| 380 | + width: double.infinity, | ||
| 381 | + radius: ScreenUtil().setWidth(10), | ||
| 382 | + )) | ||
| 383 | + ]))); | ||
| 384 | + } | ||
| 385 | +} |
| @@ -13,6 +13,7 @@ import 'package:one_key/widgets/MyDivider.dart'; | @@ -13,6 +13,7 @@ import 'package:one_key/widgets/MyDivider.dart'; | ||
| 13 | import 'package:one_key/widgets/app_bar.dart'; | 13 | import 'package:one_key/widgets/app_bar.dart'; |
| 14 | import 'package:one_key/widgets/h_empty_view.dart'; | 14 | import 'package:one_key/widgets/h_empty_view.dart'; |
| 15 | import 'package:one_key/widgets/my_item.dart'; | 15 | import 'package:one_key/widgets/my_item.dart'; |
| 16 | +import 'package:one_key/widgets/round_button.dart'; | ||
| 16 | import 'package:one_key/widgets/v_empty_view.dart'; | 17 | import 'package:one_key/widgets/v_empty_view.dart'; |
| 17 | import 'package:provider/provider.dart'; | 18 | import 'package:provider/provider.dart'; |
| 18 | 19 | ||
| @@ -109,7 +110,7 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { | @@ -109,7 +110,7 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { | ||
| 109 | elevation: 0, //appbar的阴影 | 110 | elevation: 0, //appbar的阴影 |
| 110 | centerTitle: true, // 标题居中 | 111 | centerTitle: true, // 标题居中 |
| 111 | title: Text( | 112 | title: Text( |
| 112 | - '我的', | 113 | + '一键订', |
| 113 | style: TextStyle( | 114 | style: TextStyle( |
| 114 | color: MyColours.color_fefefe, | 115 | color: MyColours.color_fefefe, |
| 115 | fontSize: ScreenUtil().setSp(34), | 116 | fontSize: ScreenUtil().setSp(34), |
| @@ -123,7 +124,7 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { | @@ -123,7 +124,7 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { | ||
| 123 | SliverAppBar( | 124 | SliverAppBar( |
| 124 | pinned: false, | 125 | pinned: false, |
| 125 | floating: false, | 126 | floating: false, |
| 126 | - expandedHeight: ScreenUtil().setWidth(200), | 127 | + expandedHeight: ScreenUtil().setWidth(260), |
| 127 | flexibleSpace: FlexibleSpaceBar( | 128 | flexibleSpace: FlexibleSpaceBar( |
| 128 | collapseMode: CollapseMode.pin, | 129 | collapseMode: CollapseMode.pin, |
| 129 | background: Consumer<UserModel>(builder: | 130 | background: Consumer<UserModel>(builder: |
| @@ -132,7 +133,7 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { | @@ -132,7 +133,7 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { | ||
| 132 | children: [ | 133 | children: [ |
| 133 | Container( | 134 | Container( |
| 134 | width: double.infinity, | 135 | width: double.infinity, |
| 135 | - height: ScreenUtil().setHeight(200), | 136 | + height: ScreenUtil().setHeight(260), |
| 136 | alignment: Alignment.centerLeft, | 137 | alignment: Alignment.centerLeft, |
| 137 | color: MyColours.color_199095, | 138 | color: MyColours.color_199095, |
| 138 | ), | 139 | ), |
| @@ -142,14 +143,14 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { | @@ -142,14 +143,14 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { | ||
| 142 | child: Column( | 143 | child: Column( |
| 143 | crossAxisAlignment: CrossAxisAlignment.start, | 144 | crossAxisAlignment: CrossAxisAlignment.start, |
| 144 | children: [ | 145 | children: [ |
| 145 | - VEmptyView(38), | 146 | + VEmptyView(58), |
| 146 | Text( | 147 | Text( |
| 147 | model.user.sellername, | 148 | model.user.sellername, |
| 148 | style: TextStyle( | 149 | style: TextStyle( |
| 149 | color: MyColours.color_ffffff, | 150 | color: MyColours.color_ffffff, |
| 150 | fontSize: ScreenUtil().setSp(36)), | 151 | fontSize: ScreenUtil().setSp(36)), |
| 151 | ), | 152 | ), |
| 152 | - VEmptyView(38), | 153 | + VEmptyView(28), |
| 153 | Text( | 154 | Text( |
| 154 | model.user.account + | 155 | model.user.account + |
| 155 | " | " + | 156 | " | " + |
| @@ -159,6 +160,24 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { | @@ -159,6 +160,24 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { | ||
| 159 | fontSize: ScreenUtil().setSp(30)), | 160 | fontSize: ScreenUtil().setSp(30)), |
| 160 | ), | 161 | ), |
| 161 | ], | 162 | ], |
| 163 | + )), | ||
| 164 | + Positioned( | ||
| 165 | + right: ScreenUtil().setWidth(40), | ||
| 166 | + bottom: ScreenUtil().setWidth(70), | ||
| 167 | + child: RoundButton( | ||
| 168 | + image: Utils.getImgPath('edit'), | ||
| 169 | + text: '编辑', | ||
| 170 | + gradientStart: Color.fromRGBO(255, 255, 255, 0.1), | ||
| 171 | + gradientEnd: Color.fromRGBO(255, 255, 255, 0.1), | ||
| 172 | + borderColor: Color.fromRGBO(255, 255, 255, 0.2), | ||
| 173 | + width: ScreenUtil().setWidth(160), | ||
| 174 | + height: ScreenUtil().setWidth(60), | ||
| 175 | + fontSize: 28, | ||
| 176 | + isBold: false, | ||
| 177 | + imgWidth: 26, | ||
| 178 | + onPressed: () { | ||
| 179 | + NavigatorUtil.goBaseInfoPage(context); | ||
| 180 | + }, | ||
| 162 | )) | 181 | )) |
| 163 | ], | 182 | ], |
| 164 | ); | 183 | ); |
| @@ -208,6 +227,7 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { | @@ -208,6 +227,7 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { | ||
| 208 | // ], | 227 | // ], |
| 209 | // ), | 228 | // ), |
| 210 | VEmptyView(40), | 229 | VEmptyView(40), |
| 230 | + | ||
| 211 | MyItem( | 231 | MyItem( |
| 212 | title: "线上券创建", | 232 | title: "线上券创建", |
| 213 | content: '', | 233 | content: '', |
| @@ -15,6 +15,7 @@ import 'package:one_key/provider/upload_img_provider.dart'; | @@ -15,6 +15,7 @@ import 'package:one_key/provider/upload_img_provider.dart'; | ||
| 15 | import 'package:one_key/res/colors.dart'; | 15 | import 'package:one_key/res/colors.dart'; |
| 16 | import 'package:one_key/utils/dialog_util.dart'; | 16 | import 'package:one_key/utils/dialog_util.dart'; |
| 17 | import 'package:one_key/utils/misc.dart'; | 17 | import 'package:one_key/utils/misc.dart'; |
| 18 | +import 'package:one_key/utils/upload_image_util.dart'; | ||
| 18 | import 'package:one_key/utils/utils.dart'; | 19 | import 'package:one_key/utils/utils.dart'; |
| 19 | import 'package:one_key/widgets/MyDivider.dart'; | 20 | import 'package:one_key/widgets/MyDivider.dart'; |
| 20 | import 'package:one_key/widgets/v_empty_view.dart'; | 21 | import 'package:one_key/widgets/v_empty_view.dart'; |
| @@ -91,8 +92,12 @@ class _ImgPickerWidgetState extends DisposableState<ImgPickerWidget> { | @@ -91,8 +92,12 @@ class _ImgPickerWidgetState extends DisposableState<ImgPickerWidget> { | ||
| 91 | } | 92 | } |
| 92 | }); | 93 | }); |
| 93 | if (pickedFile != null) { | 94 | if (pickedFile != null) { |
| 94 | - startUpload(File(pickedFile.path), | ||
| 95 | - _uploadImageProvider.imageList.length - 1, true); | 95 | + UploadImageUtil().startUpload( |
| 96 | + context, | ||
| 97 | + File(pickedFile.path), | ||
| 98 | + _uploadImageProvider.imageList.length - 1, | ||
| 99 | + true, | ||
| 100 | + _uploadImageProvider); | ||
| 96 | } | 101 | } |
| 97 | } | 102 | } |
| 98 | 103 | ||
| @@ -153,99 +158,105 @@ class _ImgPickerWidgetState extends DisposableState<ImgPickerWidget> { | @@ -153,99 +158,105 @@ class _ImgPickerWidgetState extends DisposableState<ImgPickerWidget> { | ||
| 153 | imgModel.process = 0.01; | 158 | imgModel.process = 0.01; |
| 154 | _uploadImageProvider.imageList.add(imgModel); | 159 | _uploadImageProvider.imageList.add(imgModel); |
| 155 | }); | 160 | }); |
| 156 | - startUpload(File(file.absolute.path), | ||
| 157 | - _uploadImageProvider.imageList.length - 1, false); | 161 | + UploadImageUtil().startUpload( |
| 162 | + context, | ||
| 163 | + File(file.absolute.path), | ||
| 164 | + _uploadImageProvider.imageList.length - 1, | ||
| 165 | + false, | ||
| 166 | + _uploadImageProvider); | ||
| 167 | + // startUpload(File(file.absolute.path), | ||
| 168 | + // _uploadImageProvider.imageList.length - 1, false); | ||
| 158 | } | 169 | } |
| 159 | } | 170 | } |
| 160 | } | 171 | } |
| 161 | 172 | ||
| 162 | - ///上传到七牛云 | ||
| 163 | - void startUpload(File selectedFile, int index, bool needInit) async { | ||
| 164 | - final PutController putController = PutController(); | ||
| 165 | - print(index); | 173 | + // ///上传到七牛云 |
| 174 | + // void startUpload(File selectedFile, int index, bool needInit) async { | ||
| 175 | + // final PutController putController = PutController(); | ||
| 176 | + // print(index); | ||
| 166 | 177 | ||
| 167 | - // 添加状态监听 | ||
| 168 | - putController.addStatusListener((StorageStatus status) { | ||
| 169 | - print('状态变化: 当前任务状态:${status.toString()}'); | ||
| 170 | - }); | ||
| 171 | - // 添加整体进度监听 | ||
| 172 | - putController.addProgressListener((percent) { | ||
| 173 | - print('${index}任务进度变化:进度:${percent.toStringAsFixed(4)}'); | ||
| 174 | - _uploadImageProvider.imageList[index].process = percent; | ||
| 175 | - _uploadImageProvider.notifyListeners(); | ||
| 176 | - }); | ||
| 177 | - // 添加实际发送进度订阅 | ||
| 178 | - putController.addSendProgressListener((percent) { | ||
| 179 | - // _onlineCheckEditProvider.imageList[index].process = percent; | ||
| 180 | - // setState(() {}); | ||
| 181 | - print('${index}实际发送变化:进度:${percent.toStringAsFixed(4)}'); | ||
| 182 | - }); | ||
| 183 | - if (token == null || token == '') { | ||
| 184 | - await _uploadImageProvider.getQiniuInfo(context, {}); | ||
| 185 | - } | ||
| 186 | - var usedToken = _uploadImageProvider.qiniuInfoSunModel.token; | ||
| 187 | - if (usedToken == null || usedToken == '') { | ||
| 188 | - print('token 不能为空'); | ||
| 189 | - return; | ||
| 190 | - } | ||
| 191 | - print('开始上传文件'); | ||
| 192 | - storage.putFile( | ||
| 193 | - selectedFile, | ||
| 194 | - usedToken, | ||
| 195 | - options: PutOptions( | ||
| 196 | - key: key, | ||
| 197 | - partSize: partSize, | ||
| 198 | - controller: putController, | ||
| 199 | - ), | ||
| 200 | - ) | ||
| 201 | - ..then((PutResponse response) { | ||
| 202 | - print('${index}上传已完成: 原始响应数据: ${jsonEncode(response.rawData)}'); | ||
| 203 | - print('------------------------'); | ||
| 204 | - String imgUrl = _uploadImageProvider.qiniuInfoSunModel.domain + | ||
| 205 | - '/' + | ||
| 206 | - response.rawData['key']; | ||
| 207 | - _uploadImageProvider.imageList[index].process = 1; | ||
| 208 | - _uploadImageProvider.imageList[index].qiniuUrl = imgUrl; | ||
| 209 | - // 取消当前任务 | ||
| 210 | - putController.cancel(); | ||
| 211 | - // _image | ||
| 212 | - _uploadImageProvider.notifyListeners(); | ||
| 213 | - }) | ||
| 214 | - ..catchError((dynamic error) { | ||
| 215 | - if (error is StorageError) { | ||
| 216 | - switch (error.type) { | ||
| 217 | - case StorageErrorType.CONNECT_TIMEOUT: | ||
| 218 | - print('发生错误: 连接超时'); | ||
| 219 | - break; | ||
| 220 | - case StorageErrorType.SEND_TIMEOUT: | ||
| 221 | - print('发生错误: 发送数据超时'); | ||
| 222 | - break; | ||
| 223 | - case StorageErrorType.RECEIVE_TIMEOUT: | ||
| 224 | - print('发生错误: 响应数据超时'); | ||
| 225 | - break; | ||
| 226 | - case StorageErrorType.RESPONSE: | ||
| 227 | - print('发生错误: ${error.message}'); | ||
| 228 | - break; | ||
| 229 | - case StorageErrorType.CANCEL: | ||
| 230 | - print('发生错误: 请求取消'); | ||
| 231 | - break; | ||
| 232 | - case StorageErrorType.UNKNOWN: | ||
| 233 | - print('发生错误: 未知错误'); | ||
| 234 | - break; | ||
| 235 | - case StorageErrorType.NO_AVAILABLE_HOST: | ||
| 236 | - print('发生错误: 无可用 Host'); | ||
| 237 | - break; | ||
| 238 | - case StorageErrorType.IN_PROGRESS: | ||
| 239 | - print('发生错误: 已在队列中'); | ||
| 240 | - break; | ||
| 241 | - } | ||
| 242 | - } else { | ||
| 243 | - print('发生错误: ${error.toString()}'); | ||
| 244 | - } | 178 | + // // 添加状态监听 |
| 179 | + // putController.addStatusListener((StorageStatus status) { | ||
| 180 | + // print('状态变化: 当前任务状态:${status.toString()}'); | ||
| 181 | + // }); | ||
| 182 | + // // 添加整体进度监听 | ||
| 183 | + // putController.addProgressListener((percent) { | ||
| 184 | + // print('${index}任务进度变化:进度:${percent.toStringAsFixed(4)}'); | ||
| 185 | + // _uploadImageProvider.imageList[index].process = percent; | ||
| 186 | + // _uploadImageProvider.notifyListeners(); | ||
| 187 | + // }); | ||
| 188 | + // // 添加实际发送进度订阅 | ||
| 189 | + // putController.addSendProgressListener((percent) { | ||
| 190 | + // // _onlineCheckEditProvider.imageList[index].process = percent; | ||
| 191 | + // // setState(() {}); | ||
| 192 | + // print('${index}实际发送变化:进度:${percent.toStringAsFixed(4)}'); | ||
| 193 | + // }); | ||
| 194 | + // if (token == null || token == '') { | ||
| 195 | + // await _uploadImageProvider.getQiniuInfo(context, {}); | ||
| 196 | + // } | ||
| 197 | + // var usedToken = _uploadImageProvider.qiniuInfoSunModel.token; | ||
| 198 | + // if (usedToken == null || usedToken == '') { | ||
| 199 | + // print('token 不能为空'); | ||
| 200 | + // return; | ||
| 201 | + // } | ||
| 202 | + // print('开始上传文件'); | ||
| 203 | + // storage.putFile( | ||
| 204 | + // selectedFile, | ||
| 205 | + // usedToken, | ||
| 206 | + // options: PutOptions( | ||
| 207 | + // key: key, | ||
| 208 | + // partSize: partSize, | ||
| 209 | + // controller: putController, | ||
| 210 | + // ), | ||
| 211 | + // ) | ||
| 212 | + // ..then((PutResponse response) { | ||
| 213 | + // print('${index}上传已完成: 原始响应数据: ${jsonEncode(response.rawData)}'); | ||
| 214 | + // print('------------------------'); | ||
| 215 | + // String imgUrl = _uploadImageProvider.qiniuInfoSunModel.domain + | ||
| 216 | + // '/' + | ||
| 217 | + // response.rawData['key']; | ||
| 218 | + // _uploadImageProvider.imageList[index].process = 1; | ||
| 219 | + // _uploadImageProvider.imageList[index].qiniuUrl = imgUrl; | ||
| 220 | + // // 取消当前任务 | ||
| 221 | + // putController.cancel(); | ||
| 222 | + // // _image | ||
| 223 | + // _uploadImageProvider.notifyListeners(); | ||
| 224 | + // }) | ||
| 225 | + // ..catchError((dynamic error) { | ||
| 226 | + // if (error is StorageError) { | ||
| 227 | + // switch (error.type) { | ||
| 228 | + // case StorageErrorType.CONNECT_TIMEOUT: | ||
| 229 | + // print('发生错误: 连接超时'); | ||
| 230 | + // break; | ||
| 231 | + // case StorageErrorType.SEND_TIMEOUT: | ||
| 232 | + // print('发生错误: 发送数据超时'); | ||
| 233 | + // break; | ||
| 234 | + // case StorageErrorType.RECEIVE_TIMEOUT: | ||
| 235 | + // print('发生错误: 响应数据超时'); | ||
| 236 | + // break; | ||
| 237 | + // case StorageErrorType.RESPONSE: | ||
| 238 | + // print('发生错误: ${error.message}'); | ||
| 239 | + // break; | ||
| 240 | + // case StorageErrorType.CANCEL: | ||
| 241 | + // print('发生错误: 请求取消'); | ||
| 242 | + // break; | ||
| 243 | + // case StorageErrorType.UNKNOWN: | ||
| 244 | + // print('发生错误: 未知错误'); | ||
| 245 | + // break; | ||
| 246 | + // case StorageErrorType.NO_AVAILABLE_HOST: | ||
| 247 | + // print('发生错误: 无可用 Host'); | ||
| 248 | + // break; | ||
| 249 | + // case StorageErrorType.IN_PROGRESS: | ||
| 250 | + // print('发生错误: 已在队列中'); | ||
| 251 | + // break; | ||
| 252 | + // } | ||
| 253 | + // } else { | ||
| 254 | + // print('发生错误: ${error.toString()}'); | ||
| 255 | + // } | ||
| 245 | 256 | ||
| 246 | - print('------------------------'); | ||
| 247 | - }); | ||
| 248 | - } | 257 | + // print('------------------------'); |
| 258 | + // }); | ||
| 259 | + // } | ||
| 249 | 260 | ||
| 250 | ///添加图片UI弹出 | 261 | ///添加图片UI弹出 |
| 251 | Future _openModalBottomSheet(context) async { | 262 | Future _openModalBottomSheet(context) async { |
| @@ -266,7 +277,7 @@ class _ImgPickerWidgetState extends DisposableState<ImgPickerWidget> { | @@ -266,7 +277,7 @@ class _ImgPickerWidgetState extends DisposableState<ImgPickerWidget> { | ||
| 266 | children: <Widget>[ | 277 | children: <Widget>[ |
| 267 | InkWell( | 278 | InkWell( |
| 268 | onTap: () { | 279 | onTap: () { |
| 269 | - _getPickPermission(() { | 280 | + Utils.getPickPermission(context, () { |
| 270 | _getFromPictureOrCamera(ImageSource.camera); | 281 | _getFromPictureOrCamera(ImageSource.camera); |
| 271 | Navigator.pop(context); | 282 | Navigator.pop(context); |
| 272 | }, PermissionGroup.camera); | 283 | }, PermissionGroup.camera); |
| @@ -291,7 +302,7 @@ class _ImgPickerWidgetState extends DisposableState<ImgPickerWidget> { | @@ -291,7 +302,7 @@ class _ImgPickerWidgetState extends DisposableState<ImgPickerWidget> { | ||
| 291 | ), | 302 | ), |
| 292 | InkWell( | 303 | InkWell( |
| 293 | onTap: () { | 304 | onTap: () { |
| 294 | - _getPickPermission(() { | 305 | + Utils.getPickPermission(context, () { |
| 295 | pickAsset(PickType.onlyImage); | 306 | pickAsset(PickType.onlyImage); |
| 296 | // _getFromPictureOrCamera(ImageSource.gallery); | 307 | // _getFromPictureOrCamera(ImageSource.gallery); |
| 297 | Navigator.pop(context); | 308 | Navigator.pop(context); |
| @@ -337,45 +348,6 @@ class _ImgPickerWidgetState extends DisposableState<ImgPickerWidget> { | @@ -337,45 +348,6 @@ class _ImgPickerWidgetState extends DisposableState<ImgPickerWidget> { | ||
| 337 | }); | 348 | }); |
| 338 | } | 349 | } |
| 339 | 350 | ||
| 340 | - ///检测是否有相机或者相册权限 | ||
| 341 | - _getPickPermission( | ||
| 342 | - VoidCallback callback, PermissionGroup permissionGroup) async { | ||
| 343 | - if (!(await checkPermission(permissionGroup))) { | ||
| 344 | - String title = '相册'; | ||
| 345 | - if (permissionGroup == PermissionGroup.camera) { | ||
| 346 | - title = '相机'; | ||
| 347 | - } | ||
| 348 | - PermissionStatus status = await permissionStatus(permissionGroup); | ||
| 349 | - if (status == PermissionStatus.neverAskAgain) { | ||
| 350 | - //用户选择不在弹出权限提示框 | ||
| 351 | - print('never'); | ||
| 352 | - Navigator.pop(context); | ||
| 353 | - DialogUtil.openAlertDialog( | ||
| 354 | - context, '未获得${title}权限', "请在手机的权限管理里,将${title}权限开启", '去设置', 340.0, | ||
| 355 | - onTap: () { | ||
| 356 | - openSetting(); | ||
| 357 | - Navigator.pop(context, ''); | ||
| 358 | - }); | ||
| 359 | - } else { | ||
| 360 | - // 申请权限 | ||
| 361 | - bool canContacts = await requestPermission(permissionGroup); | ||
| 362 | - if (canContacts) { | ||
| 363 | - callback(); | ||
| 364 | - } else { | ||
| 365 | - Navigator.pop(context); | ||
| 366 | - //拒绝通讯录权限 , 苹果拒绝权限后,不再提示权限框,进入此处 | ||
| 367 | - DialogUtil.openAlertDialog(context, '未获得${title}权限', | ||
| 368 | - "请在手机的权限管理里,将${title}权限开启。", '去设置', 340.0, onTap: () { | ||
| 369 | - openSetting(); | ||
| 370 | - Navigator.pop(context, ''); | ||
| 371 | - }); | ||
| 372 | - } | ||
| 373 | - } | ||
| 374 | - } else { | ||
| 375 | - callback(); | ||
| 376 | - } | ||
| 377 | - } | ||
| 378 | - | ||
| 379 | //查看大图 | 351 | //查看大图 |
| 380 | _showPhotoView(BuildContext context, int index, List imgs, | 352 | _showPhotoView(BuildContext context, int index, List imgs, |
| 381 | {isShow = false, List dashName}) async { | 353 | {isShow = false, List dashName}) async { |
lib/provider/base_info_provider.dart
0 → 100644
| 1 | +import 'package:flutter/material.dart'; | ||
| 2 | +import 'package:one_key/constant/constant.dart'; | ||
| 3 | +import 'package:one_key/constant/error.dart'; | ||
| 4 | +import 'package:one_key/models/base_info_model.dart'; | ||
| 5 | +import 'package:one_key/net/base_resp.dart'; | ||
| 6 | +import 'package:one_key/net/dio_util.dart'; | ||
| 7 | +import 'package:one_key/net/http_url.dart'; | ||
| 8 | +import 'package:one_key/utils/utils.dart'; | ||
| 9 | + | ||
| 10 | +class BaseIndoProvider with ChangeNotifier { | ||
| 11 | + BaseInfoSunModel baseInfoSunModel; //客户经理基础信息 | ||
| 12 | + | ||
| 13 | + ///客户经理添加/修改基本信息 | ||
| 14 | + Future<dynamic> setCustomerActivityBaseinfo( | ||
| 15 | + BuildContext context, Map<String, String> params, | ||
| 16 | + {isShowLoading = true}) async { | ||
| 17 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 18 | + .request<dynamic>( | ||
| 19 | + context, Method.get, HttpUrl.set_customer_activity_baseinfo, | ||
| 20 | + data: params, showLoading: isShowLoading) | ||
| 21 | + .catchError((error) { | ||
| 22 | + print(error.toString()); | ||
| 23 | + if (error is MyError) {} | ||
| 24 | + return false; | ||
| 25 | + }); | ||
| 26 | + if (baseResp.code == Constant.status_success) { | ||
| 27 | + if (baseResp.data != null) { | ||
| 28 | + // coupons = baseResp.data['aid'].split(''); | ||
| 29 | + return true; | ||
| 30 | + } else { | ||
| 31 | + // Utils.showToast(baseResp.msg ?? "修改失败"); | ||
| 32 | + return false; | ||
| 33 | + } | ||
| 34 | + } else { | ||
| 35 | + if (baseResp != null) { | ||
| 36 | + // Utils.showToast(baseResp.msg ?? ""); | ||
| 37 | + } | ||
| 38 | + return false; | ||
| 39 | + } | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + ///客户经理获取基本信息 | ||
| 43 | + Future<bool> getCustomerActivityBaseinfo( | ||
| 44 | + BuildContext context, Map<String, String> params, | ||
| 45 | + {isShowLoading = true}) async { | ||
| 46 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 47 | + .request<dynamic>( | ||
| 48 | + context, Method.get, HttpUrl.get_customer_activity_baseinfo, | ||
| 49 | + data: params, showLoading: isShowLoading) | ||
| 50 | + .catchError((error) { | ||
| 51 | + print(error.toString()); | ||
| 52 | + if (error is MyError) {} | ||
| 53 | + }); | ||
| 54 | + if (baseResp.code == Constant.status_success) { | ||
| 55 | + if (baseResp.data == null || baseResp.data == false) { | ||
| 56 | + return false; | ||
| 57 | + } else { | ||
| 58 | + baseInfoSunModel = BaseInfoModel.fromJson(baseResp.responseData).data; | ||
| 59 | + // for (int i = 0; i < couponListSelect.length; i++) { | ||
| 60 | + // coupons.add(couponListSelect[i].id); | ||
| 61 | + // // couponsShow.add(couponTemp[i].id); | ||
| 62 | + // } | ||
| 63 | + // hasModify = true; | ||
| 64 | + | ||
| 65 | + return true; | ||
| 66 | + } | ||
| 67 | + } else { | ||
| 68 | + if (baseResp != null) { | ||
| 69 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 70 | + } | ||
| 71 | + return false; | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | +} |
| 1 | - | ||
| 2 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
| 3 | import 'package:one_key/constant/constant.dart'; | 2 | import 'package:one_key/constant/constant.dart'; |
| 4 | import 'package:one_key/models/qiniu_info_model.dart'; | 3 | import 'package:one_key/models/qiniu_info_model.dart'; |
| @@ -12,7 +11,10 @@ class UploadImageProvider extends ChangeNotifier { | @@ -12,7 +11,10 @@ class UploadImageProvider extends ChangeNotifier { | ||
| 12 | List<UploadImgModel> imageList = []; //图片信息列表 | 11 | List<UploadImgModel> imageList = []; //图片信息列表 |
| 13 | List<String> imageQiniuUrlList = []; //七牛云地址列表 | 12 | List<String> imageQiniuUrlList = []; //七牛云地址列表 |
| 14 | QiniuInfoSunModel qiniuInfoSunModel; | 13 | QiniuInfoSunModel qiniuInfoSunModel; |
| 15 | - | 14 | + UploadImgModel touxiang = UploadImgModel(); //头像 |
| 15 | + UploadImgModel erweima = UploadImgModel(); //二维码 | ||
| 16 | + double imgSizeTouxiang = 64; | ||
| 17 | + double imgSizeErweima = 22; | ||
| 16 | 18 | ||
| 17 | /// 获取七牛上传token信息 | 19 | /// 获取七牛上传token信息 |
| 18 | Future<QiniuInfoSunModel> getQiniuInfo( | 20 | Future<QiniuInfoSunModel> getQiniuInfo( |
| @@ -36,5 +38,4 @@ class UploadImageProvider extends ChangeNotifier { | @@ -36,5 +38,4 @@ class UploadImageProvider extends ChangeNotifier { | ||
| 36 | } | 38 | } |
| 37 | } | 39 | } |
| 38 | } | 40 | } |
| 39 | - | ||
| 40 | } | 41 | } |
| @@ -19,6 +19,7 @@ import 'package:one_key/pages/detail/handle_online_page.dart'; | @@ -19,6 +19,7 @@ import 'package:one_key/pages/detail/handle_online_page.dart'; | ||
| 19 | import 'package:one_key/pages/detail/notebook_detail_page.dart'; | 19 | import 'package:one_key/pages/detail/notebook_detail_page.dart'; |
| 20 | import 'package:one_key/pages/login/web_page.dart'; | 20 | import 'package:one_key/pages/login/web_page.dart'; |
| 21 | import 'package:one_key/pages/message/message_order_menu.dart'; | 21 | import 'package:one_key/pages/message/message_order_menu.dart'; |
| 22 | +import 'package:one_key/pages/my/base_info.dart'; | ||
| 22 | import 'package:one_key/pages/my/book_time_set.dart'; | 23 | import 'package:one_key/pages/my/book_time_set.dart'; |
| 23 | import 'package:one_key/pages/my/receive_orders_time_set.dart'; | 24 | import 'package:one_key/pages/my/receive_orders_time_set.dart'; |
| 24 | import 'package:one_key/pages/my/remark_manager_page.dart'; | 25 | import 'package:one_key/pages/my/remark_manager_page.dart'; |
| @@ -248,7 +249,7 @@ var handleCouponSelectPageHandler = new Handler( | @@ -248,7 +249,7 @@ var handleCouponSelectPageHandler = new Handler( | ||
| 248 | handlerFunc: (BuildContext context, Map<String, List<Object>> params) { | 249 | handlerFunc: (BuildContext context, Map<String, List<Object>> params) { |
| 249 | String rid = params["rid"].first; | 250 | String rid = params["rid"].first; |
| 250 | bool hasModify = FluroConvertUtils.string2bool(params["hasModify"].first); | 251 | bool hasModify = FluroConvertUtils.string2bool(params["hasModify"].first); |
| 251 | - return CouponSelectPage(rid: rid,hasModify:hasModify); | 252 | + return CouponSelectPage(rid: rid, hasModify: hasModify); |
| 252 | }); | 253 | }); |
| 253 | 254 | ||
| 254 | ///优惠券详情页 | 255 | ///优惠券详情页 |
| @@ -259,3 +260,12 @@ var handleCouponDetailPageHandler = new Handler( | @@ -259,3 +260,12 @@ var handleCouponDetailPageHandler = new Handler( | ||
| 259 | 260 | ||
| 260 | return CouponDetailPage(couponSunModel: couponSunModel); | 261 | return CouponDetailPage(couponSunModel: couponSunModel); |
| 261 | }); | 262 | }); |
| 263 | + | ||
| 264 | +///个人资料页面 | ||
| 265 | +var baseInfoPageHandler = new Handler( | ||
| 266 | + handlerFunc: (BuildContext context, Map<String, List<Object>> params) { | ||
| 267 | + // CouponSunModel couponSunModel = CouponSunModel.fromJson(json.decode( | ||
| 268 | + // FluroConvertUtils.fluroCnParamsDecode(params["couponSunModel"].first))); | ||
| 269 | + | ||
| 270 | + return BaseInfoPage(); | ||
| 271 | +}); |
| @@ -27,6 +27,7 @@ class Routes { | @@ -27,6 +27,7 @@ class Routes { | ||
| 27 | static String coupon_edit = "/coupon_edit"; //创建优惠券 | 27 | static String coupon_edit = "/coupon_edit"; //创建优惠券 |
| 28 | static String coupon_select = "/coupon_select"; //优惠券选择 | 28 | static String coupon_select = "/coupon_select"; //优惠券选择 |
| 29 | static String coupon_detail = "/coupon_detail"; //优惠券详情页 | 29 | static String coupon_detail = "/coupon_detail"; //优惠券详情页 |
| 30 | + static String base_info = "/base_info"; //个人资料页面 | ||
| 30 | 31 | ||
| 31 | static void configureRoutes(FluroRouter router) { | 32 | static void configureRoutes(FluroRouter router) { |
| 32 | router.notFoundHandler = new Handler( | 33 | router.notFoundHandler = new Handler( |
| @@ -58,5 +59,6 @@ class Routes { | @@ -58,5 +59,6 @@ class Routes { | ||
| 58 | router.define(coupon_edit, handler: handleCouponEditPageHandler); | 59 | router.define(coupon_edit, handler: handleCouponEditPageHandler); |
| 59 | router.define(coupon_select, handler: handleCouponSelectPageHandler); | 60 | router.define(coupon_select, handler: handleCouponSelectPageHandler); |
| 60 | router.define(coupon_detail, handler: handleCouponDetailPageHandler); | 61 | router.define(coupon_detail, handler: handleCouponDetailPageHandler); |
| 62 | + router.define(base_info, handler: baseInfoPageHandler); | ||
| 61 | } | 63 | } |
| 62 | } | 64 | } |
| @@ -186,4 +186,9 @@ class NavigatorUtil { | @@ -186,4 +186,9 @@ class NavigatorUtil { | ||
| 186 | "${Routes.coupon_detail}?couponSunModel=${FluroConvertUtils.object2string(couponSunModel)}", | 186 | "${Routes.coupon_detail}?couponSunModel=${FluroConvertUtils.object2string(couponSunModel)}", |
| 187 | replace: replace); | 187 | replace: replace); |
| 188 | } | 188 | } |
| 189 | + | ||
| 190 | + /// 个人资料页面 | ||
| 191 | + static void goBaseInfoPage(BuildContext context, {replace = false}) { | ||
| 192 | + _navigateTo(context, "${Routes.base_info}", replace: replace); | ||
| 193 | + } | ||
| 189 | } | 194 | } |
lib/utils/upload_image_util.dart
0 → 100644
| 1 | +import 'dart:convert'; | ||
| 2 | +import 'dart:io'; | ||
| 3 | + | ||
| 4 | +import 'package:flutter/material.dart'; | ||
| 5 | +import 'package:image_picker/image_picker.dart'; | ||
| 6 | +import 'package:one_key/models/upload_img_model.dart'; | ||
| 7 | +import 'package:one_key/provider/upload_img_provider.dart'; | ||
| 8 | +import 'package:one_key/res/colors.dart'; | ||
| 9 | +import 'package:one_key/utils/dialog_util.dart'; | ||
| 10 | +import 'package:photo/photo.dart'; | ||
| 11 | +import 'package:qiniu_flutter_sdk/qiniu_flutter_sdk.dart'; | ||
| 12 | +import 'package:photo_manager/photo_manager.dart'; | ||
| 13 | + | ||
| 14 | +class UploadImageUtil { | ||
| 15 | + final picker = ImagePicker(); | ||
| 16 | + | ||
| 17 | + // 用户输入的文件名 | ||
| 18 | + String key; | ||
| 19 | + // 用户输入的 partSize | ||
| 20 | + int partSize = 4; | ||
| 21 | + // 用户输入的 token | ||
| 22 | + String token; | ||
| 23 | + | ||
| 24 | + /// storage 实例 | ||
| 25 | + final Storage storage = Storage(); | ||
| 26 | + // 控制器,可以用于取消任务、获取上述的状态,进度等信息 | ||
| 27 | + // PutController putController = PutController(); | ||
| 28 | + // 当前的任务状态 | ||
| 29 | + | ||
| 30 | + ///上传到七牛云 | ||
| 31 | + void startUpload(BuildContext context, File selectedFile, int index, | ||
| 32 | + bool needInit, UploadImageProvider uploadImageProvider) async { | ||
| 33 | + final PutController putController = PutController(); | ||
| 34 | + print(index); | ||
| 35 | + | ||
| 36 | + // 添加状态监听 | ||
| 37 | + putController.addStatusListener((StorageStatus status) { | ||
| 38 | + print('状态变化: 当前任务状态:${status.toString()}'); | ||
| 39 | + }); | ||
| 40 | + // 添加整体进度监听 | ||
| 41 | + putController.addProgressListener((percent) { | ||
| 42 | + print('${index}任务进度变化:进度:${percent.toStringAsFixed(4)}'); | ||
| 43 | + uploadImageProvider.imageList[index].process = percent; | ||
| 44 | + uploadImageProvider.notifyListeners(); | ||
| 45 | + }); | ||
| 46 | + // 添加实际发送进度订阅 | ||
| 47 | + putController.addSendProgressListener((percent) { | ||
| 48 | + // _onlineCheckEditProvider.imageList[index].process = percent; | ||
| 49 | + // setState(() {}); | ||
| 50 | + print('${index}实际发送变化:进度:${percent.toStringAsFixed(4)}'); | ||
| 51 | + }); | ||
| 52 | + if (token == null || token == '') { | ||
| 53 | + await uploadImageProvider.getQiniuInfo(context, {}); | ||
| 54 | + } | ||
| 55 | + var usedToken = uploadImageProvider.qiniuInfoSunModel.token; | ||
| 56 | + if (usedToken == null || usedToken == '') { | ||
| 57 | + print('token 不能为空'); | ||
| 58 | + return; | ||
| 59 | + } | ||
| 60 | + print('开始上传文件'); | ||
| 61 | + storage.putFile( | ||
| 62 | + selectedFile, | ||
| 63 | + usedToken, | ||
| 64 | + options: PutOptions( | ||
| 65 | + key: key, | ||
| 66 | + partSize: partSize, | ||
| 67 | + controller: putController, | ||
| 68 | + ), | ||
| 69 | + ) | ||
| 70 | + ..then((PutResponse response) { | ||
| 71 | + print('${index}上传已完成: 原始响应数据: ${jsonEncode(response.rawData)}'); | ||
| 72 | + print('------------------------'); | ||
| 73 | + String imgUrl = uploadImageProvider.qiniuInfoSunModel.domain + | ||
| 74 | + '/' + | ||
| 75 | + response.rawData['key']; | ||
| 76 | + uploadImageProvider.imageList[index].process = 1; | ||
| 77 | + uploadImageProvider.imageList[index].qiniuUrl = imgUrl; | ||
| 78 | + // 取消当前任务 | ||
| 79 | + putController.cancel(); | ||
| 80 | + // _image | ||
| 81 | + uploadImageProvider.notifyListeners(); | ||
| 82 | + }) | ||
| 83 | + ..catchError((dynamic error) { | ||
| 84 | + if (error is StorageError) { | ||
| 85 | + switch (error.type) { | ||
| 86 | + case StorageErrorType.CONNECT_TIMEOUT: | ||
| 87 | + print('发生错误: 连接超时'); | ||
| 88 | + break; | ||
| 89 | + case StorageErrorType.SEND_TIMEOUT: | ||
| 90 | + print('发生错误: 发送数据超时'); | ||
| 91 | + break; | ||
| 92 | + case StorageErrorType.RECEIVE_TIMEOUT: | ||
| 93 | + print('发生错误: 响应数据超时'); | ||
| 94 | + break; | ||
| 95 | + case StorageErrorType.RESPONSE: | ||
| 96 | + print('发生错误: ${error.message}'); | ||
| 97 | + break; | ||
| 98 | + case StorageErrorType.CANCEL: | ||
| 99 | + print('发生错误: 请求取消'); | ||
| 100 | + break; | ||
| 101 | + case StorageErrorType.UNKNOWN: | ||
| 102 | + print('发生错误: 未知错误'); | ||
| 103 | + break; | ||
| 104 | + case StorageErrorType.NO_AVAILABLE_HOST: | ||
| 105 | + print('发生错误: 无可用 Host'); | ||
| 106 | + break; | ||
| 107 | + case StorageErrorType.IN_PROGRESS: | ||
| 108 | + print('发生错误: 已在队列中'); | ||
| 109 | + break; | ||
| 110 | + } | ||
| 111 | + } else { | ||
| 112 | + print('发生错误: ${error.toString()}'); | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + print('------------------------'); | ||
| 116 | + }); | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + ///上传到七牛云 | ||
| 120 | + void startUploadOnly( | ||
| 121 | + BuildContext context, | ||
| 122 | + File selectedFile, | ||
| 123 | + int index, | ||
| 124 | + bool needInit, | ||
| 125 | + UploadImageProvider uploadImageProvider, | ||
| 126 | + ) async { | ||
| 127 | + final PutController putController = PutController(); | ||
| 128 | + print(index); | ||
| 129 | + | ||
| 130 | + // 添加状态监听 | ||
| 131 | + putController.addStatusListener((StorageStatus status) { | ||
| 132 | + print('状态变化: 当前任务状态:${status.toString()}'); | ||
| 133 | + }); | ||
| 134 | + // 添加整体进度监听 | ||
| 135 | + putController.addProgressListener((percent) { | ||
| 136 | + print('${index}任务进度变化:进度:${percent.toStringAsFixed(4)}'); | ||
| 137 | + if (index == 0) { | ||
| 138 | + uploadImageProvider.touxiang.process = percent; | ||
| 139 | + } else { | ||
| 140 | + uploadImageProvider.erweima.process = percent; | ||
| 141 | + } | ||
| 142 | + uploadImageProvider.notifyListeners(); | ||
| 143 | + }); | ||
| 144 | + // 添加实际发送进度订阅 | ||
| 145 | + putController.addSendProgressListener((percent) { | ||
| 146 | + // _onlineCheckEditProvider.imageList[index].process = percent; | ||
| 147 | + // setState(() {}); | ||
| 148 | + print('${index}实际发送变化:进度:${percent.toStringAsFixed(4)}'); | ||
| 149 | + }); | ||
| 150 | + if (token == null || token == '') { | ||
| 151 | + await uploadImageProvider.getQiniuInfo(context, {}); | ||
| 152 | + } | ||
| 153 | + var usedToken = uploadImageProvider.qiniuInfoSunModel.token; | ||
| 154 | + if (usedToken == null || usedToken == '') { | ||
| 155 | + print('token 不能为空'); | ||
| 156 | + return; | ||
| 157 | + } | ||
| 158 | + print('开始上传文件'); | ||
| 159 | + storage.putFile( | ||
| 160 | + selectedFile, | ||
| 161 | + usedToken, | ||
| 162 | + options: PutOptions( | ||
| 163 | + key: key, | ||
| 164 | + partSize: partSize, | ||
| 165 | + controller: putController, | ||
| 166 | + ), | ||
| 167 | + ) | ||
| 168 | + ..then((PutResponse response) { | ||
| 169 | + print('${index}上传已完成: 原始响应数据: ${jsonEncode(response.rawData)}'); | ||
| 170 | + print('------------------------'); | ||
| 171 | + String imgUrl = uploadImageProvider.qiniuInfoSunModel.domain + | ||
| 172 | + '/' + | ||
| 173 | + response.rawData['key']; | ||
| 174 | + | ||
| 175 | + // 取消当前任务 | ||
| 176 | + putController.cancel(); | ||
| 177 | + if (index == 0) { | ||
| 178 | + uploadImageProvider.touxiang.process = 1; | ||
| 179 | + uploadImageProvider.touxiang.qiniuUrl = imgUrl; | ||
| 180 | + uploadImageProvider.notifyListeners(); | ||
| 181 | + } else if (index == 1) { | ||
| 182 | + uploadImageProvider.erweima.process = 1; | ||
| 183 | + uploadImageProvider.erweima.qiniuUrl = imgUrl; | ||
| 184 | + uploadImageProvider.notifyListeners(); | ||
| 185 | + } | ||
| 186 | + }) | ||
| 187 | + ..catchError((dynamic error) { | ||
| 188 | + if (error is StorageError) { | ||
| 189 | + switch (error.type) { | ||
| 190 | + case StorageErrorType.CONNECT_TIMEOUT: | ||
| 191 | + print('发生错误: 连接超时'); | ||
| 192 | + break; | ||
| 193 | + case StorageErrorType.SEND_TIMEOUT: | ||
| 194 | + print('发生错误: 发送数据超时'); | ||
| 195 | + break; | ||
| 196 | + case StorageErrorType.RECEIVE_TIMEOUT: | ||
| 197 | + print('发生错误: 响应数据超时'); | ||
| 198 | + break; | ||
| 199 | + case StorageErrorType.RESPONSE: | ||
| 200 | + print('发生错误: ${error.message}'); | ||
| 201 | + break; | ||
| 202 | + case StorageErrorType.CANCEL: | ||
| 203 | + print('发生错误: 请求取消'); | ||
| 204 | + break; | ||
| 205 | + case StorageErrorType.UNKNOWN: | ||
| 206 | + print('发生错误: 未知错误'); | ||
| 207 | + break; | ||
| 208 | + case StorageErrorType.NO_AVAILABLE_HOST: | ||
| 209 | + print('发生错误: 无可用 Host'); | ||
| 210 | + break; | ||
| 211 | + case StorageErrorType.IN_PROGRESS: | ||
| 212 | + print('发生错误: 已在队列中'); | ||
| 213 | + break; | ||
| 214 | + } | ||
| 215 | + } else { | ||
| 216 | + print('发生错误: ${error.toString()}'); | ||
| 217 | + } | ||
| 218 | + | ||
| 219 | + print('------------------------'); | ||
| 220 | + }); | ||
| 221 | + } | ||
| 222 | +} |
| @@ -11,9 +11,12 @@ import 'package:flutter/services.dart'; | @@ -11,9 +11,12 @@ import 'package:flutter/services.dart'; | ||
| 11 | import 'package:fluwx/fluwx.dart'; | 11 | import 'package:fluwx/fluwx.dart'; |
| 12 | import 'package:one_key/pages/login/web_page.dart'; | 12 | import 'package:one_key/pages/login/web_page.dart'; |
| 13 | import 'package:one_key/provider/user_model.dart'; | 13 | import 'package:one_key/provider/user_model.dart'; |
| 14 | +import 'package:one_key/utils/dialog_util.dart'; | ||
| 15 | +import 'package:one_key/utils/misc.dart'; | ||
| 14 | import 'package:one_key/utils/navigator_util.dart'; | 16 | import 'package:one_key/utils/navigator_util.dart'; |
| 15 | import 'package:one_key/widgets/loading.dart'; | 17 | import 'package:one_key/widgets/loading.dart'; |
| 16 | import 'package:package_info/package_info.dart'; | 18 | import 'package:package_info/package_info.dart'; |
| 19 | +import 'package:permission_handler/permission_handler.dart'; | ||
| 17 | import 'package:provider/provider.dart'; | 20 | import 'package:provider/provider.dart'; |
| 18 | import 'package:url_launcher/url_launcher.dart'; | 21 | import 'package:url_launcher/url_launcher.dart'; |
| 19 | import 'package:webview_flutter/webview_flutter.dart'; | 22 | import 'package:webview_flutter/webview_flutter.dart'; |
| @@ -23,6 +26,45 @@ import '../app.dart'; | @@ -23,6 +26,45 @@ import '../app.dart'; | ||
| 23 | typedef BookTimeSetCallback = void Function(bool needChange); | 26 | typedef BookTimeSetCallback = void Function(bool needChange); |
| 24 | 27 | ||
| 25 | class Utils { | 28 | class Utils { |
| 29 | + ///检测是否有相机或者相册权限 | ||
| 30 | + static getPickPermission(BuildContext context, VoidCallback callback, | ||
| 31 | + PermissionGroup permissionGroup) async { | ||
| 32 | + if (!(await checkPermission(permissionGroup))) { | ||
| 33 | + String title = '相册'; | ||
| 34 | + if (permissionGroup == PermissionGroup.camera) { | ||
| 35 | + title = '相机'; | ||
| 36 | + } | ||
| 37 | + PermissionStatus status = await permissionStatus(permissionGroup); | ||
| 38 | + if (status == PermissionStatus.neverAskAgain) { | ||
| 39 | + //用户选择不在弹出权限提示框 | ||
| 40 | + print('never'); | ||
| 41 | + Navigator.pop(context); | ||
| 42 | + DialogUtil.openAlertDialog( | ||
| 43 | + context, '未获得${title}权限', "请在手机的权限管理里,将${title}权限开启", '去设置', 340.0, | ||
| 44 | + onTap: () { | ||
| 45 | + openSetting(); | ||
| 46 | + Navigator.pop(context, ''); | ||
| 47 | + }); | ||
| 48 | + } else { | ||
| 49 | + // 申请权限 | ||
| 50 | + bool canContacts = await requestPermission(permissionGroup); | ||
| 51 | + if (canContacts) { | ||
| 52 | + callback(); | ||
| 53 | + } else { | ||
| 54 | + Navigator.pop(context); | ||
| 55 | + //拒绝通讯录权限 , 苹果拒绝权限后,不再提示权限框,进入此处 | ||
| 56 | + DialogUtil.openAlertDialog(context, '未获得${title}权限', | ||
| 57 | + "请在手机的权限管理里,将${title}权限开启。", '去设置', 340.0, onTap: () { | ||
| 58 | + openSetting(); | ||
| 59 | + Navigator.pop(context, ''); | ||
| 60 | + }); | ||
| 61 | + } | ||
| 62 | + } | ||
| 63 | + } else { | ||
| 64 | + callback(); | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + | ||
| 26 | ///value: 文本内容;fontSize : 文字的大小;fontWeight:文字权重;maxWidth:文本框的最大宽度;maxLines:文本支持最大多少行 | 68 | ///value: 文本内容;fontSize : 文字的大小;fontWeight:文字权重;maxWidth:文本框的最大宽度;maxLines:文本支持最大多少行 |
| 27 | static double calculateTextHeight( | 69 | static double calculateTextHeight( |
| 28 | String value, | 70 | String value, |
| @@ -3,14 +3,14 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -3,14 +3,14 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 3 | import 'package:one_key/res/colors.dart'; | 3 | import 'package:one_key/res/colors.dart'; |
| 4 | import 'package:one_key/widgets/h_empty_view.dart'; | 4 | import 'package:one_key/widgets/h_empty_view.dart'; |
| 5 | 5 | ||
| 6 | -class MyItem extends StatefulWidget{ | ||
| 7 | - | 6 | +class MyItem extends StatefulWidget { |
| 8 | final String title; | 7 | final String title; |
| 9 | final String content; | 8 | final String content; |
| 10 | final VoidCallback callback; | 9 | final VoidCallback callback; |
| 11 | 10 | ||
| 12 | - const MyItem({Key key, this.title, this.content, this.callback}) : super(key: key); | ||
| 13 | - | 11 | + const MyItem({Key key, this.title, this.content, this.callback}) |
| 12 | + : super(key: key); | ||
| 13 | + | ||
| 14 | @override | 14 | @override |
| 15 | State<StatefulWidget> createState() { | 15 | State<StatefulWidget> createState() { |
| 16 | // TODO: implement createState | 16 | // TODO: implement createState |
| @@ -18,8 +18,7 @@ class MyItem extends StatefulWidget{ | @@ -18,8 +18,7 @@ class MyItem extends StatefulWidget{ | ||
| 18 | } | 18 | } |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | -class MyItemState extends State<MyItem>{ | ||
| 22 | - | 21 | +class MyItemState extends State<MyItem> { |
| 23 | @override | 22 | @override |
| 24 | Widget build(BuildContext context) { | 23 | Widget build(BuildContext context) { |
| 25 | // TODO: implement build | 24 | // TODO: implement build |
| @@ -33,15 +32,28 @@ class MyItemState extends State<MyItem>{ | @@ -33,15 +32,28 @@ class MyItemState extends State<MyItem>{ | ||
| 33 | alignment: Alignment.center, | 32 | alignment: Alignment.center, |
| 34 | child: Row( | 33 | child: Row( |
| 35 | children: <Widget>[ | 34 | children: <Widget>[ |
| 36 | - Text(widget.title,style: TextStyle(fontSize: ScreenUtil().setSp(30),color: MyColours.color_353535),), | 35 | + Text( |
| 36 | + widget.title, | ||
| 37 | + style: TextStyle( | ||
| 38 | + fontSize: ScreenUtil().setSp(30), | ||
| 39 | + color: MyColours.color_353535), | ||
| 40 | + ), | ||
| 37 | Spacer(), | 41 | Spacer(), |
| 38 | - Text(widget.content,style: TextStyle(fontSize: ScreenUtil().setSp(28),color: MyColours.color_666666),), | 42 | + Text( |
| 43 | + widget.content, | ||
| 44 | + style: TextStyle( | ||
| 45 | + fontSize: ScreenUtil().setSp(28), | ||
| 46 | + color: MyColours.color_666666), | ||
| 47 | + ), | ||
| 39 | HEmptyView(20), | 48 | HEmptyView(20), |
| 40 | - Image.asset("assets/arr_right_gray.png",width: ScreenUtil().setWidth(14),height: ScreenUtil().setWidth(22),) | 49 | + Image.asset( |
| 50 | + "assets/arr_right_gray.png", | ||
| 51 | + width: ScreenUtil().setWidth(14), | ||
| 52 | + height: ScreenUtil().setWidth(22), | ||
| 53 | + ) | ||
| 41 | ], | 54 | ], |
| 42 | ), | 55 | ), |
| 43 | ), | 56 | ), |
| 44 | ); | 57 | ); |
| 45 | } | 58 | } |
| 46 | - | ||
| 47 | -} | ||
| 59 | +} |
-
Please register or login to post a comment