diff --git a/lib/home/EditData.dart b/lib/home/EditData.dart index 12869dd..c978fd6 100644 --- a/lib/home/EditData.dart +++ b/lib/home/EditData.dart @@ -346,10 +346,6 @@ class _EditPageState extends State { showToast(I18n.of(context).choose_career); return; } - // if (dateItemId.length == 0) { - // showToast(I18n.of(context).select_program); - // return; - // } if (countryId.length == 0) { showToast(I18n.of(context).select_program); @@ -368,7 +364,6 @@ class _EditPageState extends State { } var program = ''; - //dateItemId.forEach((f) => program += program == '' ? f : ',$f'); var hopeObject = ''; lovePeopleId.forEach((f) => hopeObject += hopeObject == '' ? f : ',$f'); var dateRangeStr = ''; @@ -386,7 +381,7 @@ class _EditPageState extends State { data["height"] = heightId; data['Country'] = countryId.first.split('-')[1]; data["weight"] = weightId; - data["ownMsg"] = mymsgController.text; + data["ownMsg"] = mymsgController.text.trim(); data["meetPlace"] = dateRangeStr; data['wxAccount'] = wechat; data['fbAccount'] = facebook; @@ -742,7 +737,7 @@ class _EditPageState extends State { widget.isEditPage ? idItem : Container(), _buildDivider(), _bottomBorderBox(I18n.of(context).nickname, I18n.of(context).fill_out, - true, nickNameController, true, (str) => nickname = str, + true, nickNameController, true, (str) => nickname = str.trim(), inputFormatters: [ LengthLimitingTextInputFormatter(Constants.NameLength) ]), @@ -798,16 +793,16 @@ class _EditPageState extends State { true, wechatController, true, - (str) => wechat = str, + (str) => wechat = str.trim(), inputFormatters: [ - //WhitelistingTextInputFormatter(RegExp("^[A-Za-z0-9]+\$")), + WhitelistingTextInputFormatter(RegExp("^[A-Za-z0-9]+\$")), LengthLimitingTextInputFormatter(20) ]), _buildDivider(), _bottomBorderBox(I18n.of(context).facebook, I18n.of(context).fill_out, - true, fbController, true, (str) => facebook = str, + true, fbController, true, (str) => facebook = str.trm(), inputFormatters: [ - //WhitelistingTextInputFormatter(RegExp("^[A-Za-z0-9]+\$")), + WhitelistingTextInputFormatter(RegExp("^[A-Za-z0-9]+\$")), LengthLimitingTextInputFormatter(20) ]), ]; diff --git a/lib/home/ProfilePage.dart b/lib/home/ProfilePage.dart index a8bf531..f9970c8 100644 --- a/lib/home/ProfilePage.dart +++ b/lib/home/ProfilePage.dart @@ -1,10 +1,8 @@ import 'dart:convert'; -import 'dart:io'; import 'package:chat/home/fans_page.dart'; import 'package:chat/home/goddess_hot.dart'; import 'package:chat/home/my_headview.dart'; import 'package:chat/home/photo_page.dart'; -import 'package:chat/home/rich_title.dart'; import 'package:chat/models/ChatMsg.dart'; import 'package:chat/models/money_change.dart'; import 'package:chat/models/ref_name_provider.dart'; @@ -14,7 +12,6 @@ import 'package:chat/utils/ChargeMoney.dart'; import 'package:chat/utils/app_navigator.dart'; import 'package:chat/utils/blacklist_mgr.dart'; import 'package:chat/utils/conversation_table.dart'; -import 'package:chat/utils/file_cache_mgr.dart'; import 'package:chat/utils/friend_list_mgr.dart'; import 'package:chat/utils/msgHandler.dart'; import 'package:chat/utils/screen.dart'; @@ -34,10 +31,8 @@ import 'package:chat/utils/CustomUI.dart'; import 'package:chat/utils/MessageMgr.dart'; import 'package:chat/utils/TutorialOverlay.dart'; import 'package:cached_network_image/cached_network_image.dart'; -import 'package:flutter/services.dart'; import 'package:image_picker/image_picker.dart'; -import 'package:multi_image_picker/multi_image_picker.dart'; import 'package:oktoast/oktoast.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:provider/provider.dart'; @@ -56,7 +51,6 @@ import "package:chat/utils/PicSwiper.dart"; import 'add_friend.dart'; import 'apply_content_view.dart'; import 'daily_bonus_page.dart'; -import 'money_picture_view.dart'; import 'dart:math' as math; var cardWidth; @@ -176,7 +170,6 @@ class _ProfilePageState extends State }); } }); - getImg(); if (isMyself) { HttpUtil().getWealth(context, (data) { wealthData = data; @@ -296,10 +289,6 @@ class _ProfilePageState extends State }); } - msgRefreshPhoto(data) { - getImg(); - } - msgUpdateData(data) { print('msgUpdateData $data'); getUserInfo(mymsg: data); @@ -326,7 +315,6 @@ class _ProfilePageState extends State void messageOn() { MessageMgr().on('inform_sucess', msgInformSucess); MessageMgr().on('refresh_money', msgBuyVip); - MessageMgr().on('refresh_photo', msgRefreshPhoto); MessageMgr().on('update_data', msgUpdateData); MessageMgr().on('delete_program', msgListDelete); MessageMgr().on('post_add_friend', msgAddFriend); @@ -338,7 +326,6 @@ class _ProfilePageState extends State void messageOff() { MessageMgr().off('inform_sucess', msgInformSucess); MessageMgr().off('refresh_money', msgBuyVip); - MessageMgr().off('refresh_photo', msgRefreshPhoto); MessageMgr().off('update_data', msgUpdateData); MessageMgr().off('delete_program', msgListDelete); MessageMgr().off('post_add_friend', msgAddFriend); @@ -386,97 +373,6 @@ class _ProfilePageState extends State super.dispose(); } - void getImg() async { - var data = { - "visitUserId": UserData().basicInfo.userId, - "userId": widget.userId, - }; - data['sign'] = TokenMgr().getSign(data); - - Response res = await HttpUtil().post('user/personal/album', data: data); - if (res == null) { - return; - } - Map resData = res.data; - if (resData['code'] == 0) { - imgList = resData['data'] == null ? [] : resData['data']; - if (isMyself) { - UserData().picNum = 0; - for (int i = 0; i < imgList.length; i++) { - if (imgList[i]['Status'] == 1) { - UserData().picNum++; - } - if (imgList[i]['Status'] == 0 || imgList[i]['Status'] == 2) { - UserData().haveReview = true; - } - } - } - if (mounted) { - setState(() {}); - } - } - } - -//上传相册 - void _uploadPhoto() async { - int leftLength = MaxImgSize - imgList.length; - if (leftLength <= 0) { - showToast(I18n.of(context) - .max_upload_size - .replaceFirst('/s1', MaxImgSize.toString())); - return; - } - List resultList = List(); - - resultList = await MultiImagePicker.pickImages( - maxImages: leftLength > 9 ? 9 : leftLength, - enableCamera: false, - selectedAssets: [], - cupertinoOptions: CupertinoOptions(takePhotoIcon: "chat"), - materialOptions: MaterialOptions( - actionBarColor: "#50A7F9", - actionBarTitle: "Hibok", - allViewTitle: "", - useDetailsView: true, - selectCircleStrokeColor: "#000000", - ), - ); - - if (resultList != null && resultList.length > 0) { - List fileList = []; - for (var i = 0; i < resultList.length; i++) { - Asset photoEntity = resultList[i]; - print('名字:${photoEntity.name}'); - ByteData byteData = await photoEntity.getByteData(); - File file = await FileCacheMgr().writeFile( - 'temp-photo-${DateTime.now().millisecondsSinceEpoch}.png', - byteData.buffer.asInt8List(0)); - - fileList.add(file); - } - print('文件列表${fileList.length}'); - Map data = {"type": 2, "userId": UserData().basicInfo.userId}; - data['sign'] = TokenMgr().getSign(data); - data['sex'] = UserData().basicInfo.sex; - data['isBurn'] = 0; - Response res = await HttpUtil().uploadFiles( - fileList, data, 'upload/post/postfiles', 'image', - isShowLoading: true); - var resData = res.data; - if (resData['code'] == 0) { - if (resData['data']['msg'] != '' && resData['data']['msg'] != null) { - showToast(resData['data']['msg']); - } - if (resData['msg'].split('|').length != fileList.length) { - showToast(I18n.of(context).hava_error_photo); - } - MessageMgr().emit('refresh_photo'); - } else { - showToast(resData['msg']); - } - } - } - showHeadView() { Navigator.of(context).push( new MaterialPageRoute( @@ -796,7 +692,7 @@ class _ProfilePageState extends State return InkWell( onTap: callback, child: Container( - width: (Screen.width - 130) / 3, + width: (Screen.width - 105) / 3, child: Column( children: [ Stack( @@ -808,7 +704,7 @@ class _ProfilePageState extends State style: TextStyle( fontSize: 15, color: Constants.BlackTextColor, - fontWeight: FontWeight.bold), + fontWeight: FontWeight.w400), )), isShowDot ? Positioned( @@ -996,241 +892,6 @@ class _ProfilePageState extends State ); } - Widget _buildMyPicture() { - var pisc = imgList - .map((f) => PicSwiperItem( - f['ImgUrl'], - id: f['Id'], - type: f['Type'], - isWatch: f['IsCheck'] == 1, - userId: userInfo.userId, - isBuy: f['PayStatus'] == 1, - isCheck: f['Status'] == 0, - )) - .toList(); - var list = imgList.map((data) { - var width = MediaQuery.of(context).size.width / 4 - 15; - bool isWatch = data['IsCheck'] == 1; - double raduis = 10; - return CustomUI.buildImgCover(data['Id'], pisc, data['ImgUrl'], width, - raduis, isWatch, context, data['Type'], - isMyself: isMyself, - payStatus: data['PayStatus'], - state: isMan ? 1 : data['Status']); - }).toList(); - if (!isBuyPicture && list.length > 4) { - list.length = 4; - } - - TitleItem title; - if (!isMan) { - title = UserData().isVip - ? TitleItem( - title: I18n.of(context).unlock_user, - name: Provider.of(context) - .getRefName(userInfo.userId, userInfo.nickName), - ) - : TitleItem( - title: I18n.of(context).free_unlock, - name: userInfo.price.toString() + I18n.of(context).mask_coin); - } else { - title = TitleItem( - title: I18n.of(context).pay_unlock, name: userInfo.price.toString()); - } - //我的相册 - return Container( - alignment: Alignment.center, - margin: EdgeInsets.only(top: Separate_Size), - padding: EdgeInsets.symmetric(horizontal: 10), - width: isMyself ? Screen.width : cardWidth, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FullWidthButton( - title: (isMyself - ? I18n.of(context).my_album - : (isMan - ? I18n.of(context).his_photo - : I18n.of(context).her_photo)), - description: isMyself - ? '${I18n.of(context).upload}(${imgList.length}/$MaxImgSize)' - : '', - descriptionColor: Constants.BlueTextColor, - showDivider: true, - showRightIcon: false, - onPressed: isMyself ? _uploadPhoto : () {}, - ), - list.length == 0 - ? (isMyself - ? InkWell( - onTap: _uploadPhoto, - child: Container( - height: 100, - alignment: Alignment.center, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text(I18n.of(context).first_photo, - textScaleFactor: 1.0), - Text( - isMan - ? I18n.of(context).have_picture - : I18n.of(context).no_photo, - textScaleFactor: 1.0, - style: TextStyle( - fontSize: 12, color: Colors.grey)) - ], - ))) - : Container( - alignment: Alignment.center, - height: 120, - child: Text( - isMan - ? I18n.of(context).not_up_man - : I18n.of(context).not_up_women, - textScaleFactor: 1.0, - style: TextStyle(fontSize: 14), - ), - )) - : (isBuyPicture - ? Container( - //alignment: Alignment.center, - child: Wrap( - crossAxisAlignment: WrapCrossAlignment.start, - children: list, - )) - : Container( - alignment: Alignment.center, - child: Stack( - //alignment: Alignment.center, - children: [ - Wrap( - crossAxisAlignment: WrapCrossAlignment.start, - children: list, - ), - Opacity( - opacity: 0.96, - child: Container( - decoration: BoxDecoration(color: Colors.white), - height: 200, - ), - ), - Container( - height: 200, - alignment: Alignment.center, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Image.asset( - 'assets/images/suo.png', - width: 35, - color: Colors.grey[700], - ), - Container( - margin: EdgeInsets.only(top: 10), - alignment: Alignment.center, - child: Text( - isMan - ? I18n.of(context).set_lock - : I18n.of(context).set_lock2, - textScaleFactor: 1.0, - style: TextStyle( - color: Colors.grey[700], - fontSize: 15), - ), - ), - Container( - margin: EdgeInsets.only(top: 8), - alignment: Alignment.center, - child: RichText( - text: TextSpan( - children: RichTitle.getRichText(title, - titleStyle: TextStyle( - color: Colors.grey[700], - fontSize: 13), - nameStyle: TextStyle( - color: Colors.red, - fontSize: 13))), - ), - ), - InkWell( - onTap: buyPhoto, - child: Container( - margin: EdgeInsets.only(top: 10), - padding: - EdgeInsets.only(top: 6, bottom: 6), - width: 100, - alignment: Alignment.center, - decoration: Constants - .ConfirmBUttonBoxDecoration, - child: Text( - I18n.of(context).unlock, - textScaleFactor: 1.0, - style: TextStyle(color: Colors.white), - ), - )), - ], - )) - ], - ))), - !isMan && isMyself - ? InkWell( - onTap: () { - if (!userInfo.isAttestation) { - _buildNotTrue(); - return; - } - if (imgList.length == 0) { - showToast(I18n.of(context).no_photos); - return; - } - var moneyList = []; - for (int i = 0; i < imgList.length; i++) { - if (imgList[i]['Status'] == 1) { - moneyList.add(imgList[i]); - } - } - Navigator.of(context) - .push(new MaterialPageRoute(builder: (context) { - return MoneyPicture( - imageList: moneyList, - ); - })); - }, - child: Container( - alignment: Alignment.centerRight, - margin: EdgeInsets.only(top: 10, right: 10, bottom: 10), - padding: EdgeInsets.only(top: 10), - child: Text( - I18n.of(context).set_photo, - textScaleFactor: 1.0, - style: TextStyle(color: Colors.red), - ), - )) - : Container(), - ], - ), - decoration: BoxDecoration( - color: Colors.white, - border: Border( - top: Constants.GreyBorderSide, bottom: Constants.GreyBorderSide)), - ); - } - - void _buildNotTrue() { - CustomUI.buildOneConfirm(context, I18n.of(context).moneyPageTip, - I18n.of(context).authenticate_now, () { - Navigator.pop(context); - Navigator.of(context).push( - new MaterialPageRoute( - builder: (context) { - return VerificationCenterPage(); - }, - ), - ); - }); - } - void _buildConfirmBlack() { Navigator.of(context).pop(); CustomUI.buildOneConfirm( @@ -1448,7 +1109,7 @@ class _ProfilePageState extends State 'UserName': userInfo.nickName }); FriendListMgr().addFriend(friendModel); - FriendListMgr().deleteLocalUserId(); + FriendListMgr().deleteLocalUserIdById(userInfo.userId); MessageMgr().emit('do_friend_apply', {'userId': userInfo.userId, 'state': 1}); MessageMgr().emit('Add friend'); @@ -1482,6 +1143,7 @@ class _ProfilePageState extends State doFriendApply(2, (msg) { showToast(msg); Navigator.of(context).pop(); + FriendListMgr().deleteLocalUserIdById(userInfo.userId); MessageMgr().emit('do_friend_apply', {'userId': userInfo.userId, 'state': 2}); }); diff --git a/lib/home/photo_page.dart b/lib/home/photo_page.dart index eb1d987..01ca53e 100644 --- a/lib/home/photo_page.dart +++ b/lib/home/photo_page.dart @@ -165,7 +165,8 @@ class _PhotoPageState extends State { child: new Text( I18n.of(context).set_photo, textScaleFactor: 1.0, - style: TextStyle(color: Constants.BlueTextColor,fontSize: 12), + style: TextStyle( + color: Constants.BlueTextColor, fontSize: 12), ), ), onTap: () { @@ -442,10 +443,10 @@ class _PhotoPageState extends State { if (resData['data']['msg'] != '' && resData['data']['msg'] != null) { showToast(resData['data']['msg']); } - if (resData['msg'].split('|').length != fileList.length) { + if (resData['msg'] == '' || + resData['msg'].split('|').length != fileList.length) { showToast(I18n.of(context).hava_error_photo); } - //MessageMgr().emit('refresh_photo'); getImg(); } else { showToast(resData['msg']); diff --git a/lib/utils/friend_list_mgr.dart b/lib/utils/friend_list_mgr.dart index 7e6cc26..0617276 100644 --- a/lib/utils/friend_list_mgr.dart +++ b/lib/utils/friend_list_mgr.dart @@ -59,6 +59,14 @@ class FriendListMgr { deleteLocalUserId(); } + deleteLocalUserIdById(int userId) async { +//删除本地新加好友记录 + SharedPreferences prefs = await SharedPreferences.getInstance(); + List list = prefs.getStringList(Constants.NewFriendsList); + list.remove(userId.toString()); + prefs.setStringList(Constants.NewFriendsList, list); + } + deleteLocalUserId() async { //删除本地新加好友记录 SharedPreferences prefs = await SharedPreferences.getInstance(); diff --git a/lib/utils/local_notification_util.dart b/lib/utils/local_notification_util.dart index 2ec28e5..1ea3828 100644 --- a/lib/utils/local_notification_util.dart +++ b/lib/utils/local_notification_util.dart @@ -67,6 +67,23 @@ class LocalNotificationUtil { // 接收通知回调方法。 onReceiveNotification: (Map message) async { print("flutter onReceiveNotification: $message"); + Map jExtra = message['extras']; + print('onOpenNotification jExtra:$jExtra'); + if (jExtra.containsKey('cn.jpush.android.EXTRA')) { + ///android + Map map = json.decode(jExtra['cn.jpush.android.EXTRA']); + //申请好友推送 + if (map['Type'] == 6) { + MessageMgr().emit('do_friend_apply'); + } + return; + } else { + ///ios + //申请好友推送 + if (jExtra['Type'] == 6) { + MessageMgr().emit('do_friend_apply'); + } + } }, // 点击通知回调方法。 onOpenNotification: (Map message) async { @@ -207,8 +224,8 @@ class LocalNotificationUtil { var initializationSettings = InitializationSettings( initializationSettingsAndroid, initializationSettingsIOS); print('点击事件初始化'); - bool isOK =await flutterLocalNotificationsPlugin.initialize(initializationSettings, - onSelectNotification: (String payload) async { + bool isOK = await flutterLocalNotificationsPlugin.initialize( + initializationSettings, onSelectNotification: (String payload) async { print('AAA这里---推送点击'); selectNotificationSubject.add(payload); }); @@ -304,12 +321,12 @@ class LocalNotificationUtil { } } - Future show(String title, String content,{int id}) async { + Future show(String title, String content, {int id}) async { if (!isBackground || !UserData().privatyMsgPushSwitch) { // print('程序在前台,不发生推送通知 || 用户关闭推送'); return; } - showNotification(title, content,id: id); + showNotification(title, content, id: id); } Future showOtherNotification( @@ -355,28 +372,26 @@ class LocalNotificationUtil { } print('showOtherNotification payload $payload'); - if(selectNotificationSubject==null){ + if (selectNotificationSubject == null) { print('selectNotificationSubject == null'); - }else{ + } else { print('selectNotificationSubject 不空'); } - if(flutterLocalNotificationsPlugin==null){ + if (flutterLocalNotificationsPlugin == null) { print('flutterLocalNotificationsPlugin == null'); - }else{ + } else { print('flutterLocalNotificationsPlugin 不空'); } - - if (needPush) { showNotification(defaultTitle, defaultContent, payload: payload); } } void showNotification(String title, String content, - {payload = 'default',int id}) async { - if(id == null){ + {payload = 'default', int id}) async { + if (id == null) { id = Random().nextInt(1000); } var androidPlatformChannelSpecifics = AndroidNotificationDetails( @@ -386,13 +401,12 @@ class LocalNotificationUtil { var platformChannelSpecifics = NotificationDetails( androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics); print('payload- $payload'); - await flutterLocalNotificationsPlugin.show( - id, title, content, platformChannelSpecifics, - payload: payload); + await flutterLocalNotificationsPlugin + .show(id, title, content, platformChannelSpecifics, payload: payload); badgerCount++; FlutterAppBadger.updateBadgeCount(badgerCount); - ///等极光修复了iOS本地推送点击事件后改为下面的方法 + ///等极光修复了iOS本地推送点击事件后改为下面的方法 // var fireDate = DateTime.fromMillisecondsSinceEpoch( // DateTime.now().millisecondsSinceEpoch + 3000); // var localNotification = LocalNotification( @@ -406,7 +420,6 @@ class LocalNotificationUtil { // extra: {"fa": "0"}); // JPush jpush = new JPush(); // jpush.sendLocalNotification(localNotification); - } Future cleanAllNotifications() async { @@ -420,18 +433,16 @@ class LocalNotificationUtil { FlutterAppBadger.updateBadgeCount(badgerCount); } - - void startPush(){ + void startPush() { JPush jpush = new JPush(); jpush.resumePush(); } - void pausePush(){ + void pausePush() { JPush jpush = new JPush(); jpush.stopPush(); } - void dispose() { // if(didReceiveLocalNotificationSubject !=null && selectNotificationSubject !=null){ // didReceiveLocalNotificationSubject.close();