import 'dart:convert'; 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/models/ChatMsg.dart'; import 'package:chat/models/money_change.dart'; import 'package:chat/models/ref_name_provider.dart'; import 'package:chat/models/voucher_change.dart'; import 'package:chat/proto/all.pbserver.dart'; 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/friend_list_mgr.dart'; import 'package:chat/utils/msgHandler.dart'; import 'package:chat/utils/screen.dart'; import 'package:chat/utils/sp_utils.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:chat/data/WebData.dart'; import 'package:chat/data/constants.dart'; import 'package:chat/generated/i18n.dart'; import 'package:chat/home/InformUser.dart'; import 'package:chat/home/MoneyPage.dart'; import 'package:chat/home/Myprogram.dart'; import 'package:chat/home/VideoPage.dart'; import 'package:chat/home/VipPage.dart'; import 'package:chat/models/UserInfo.dart'; 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:image_picker/image_picker.dart'; import 'package:oktoast/oktoast.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:provider/provider.dart'; import 'package:share/share.dart'; import '../utils/FullWithButton.dart'; import '../home/EditData.dart'; import '../home/SystemEditPage.dart'; import '../data/UserData.dart'; import '../utils/TokenMgr.dart'; import 'package:dio/dio.dart'; import 'package:chat/utils/HttpUtil.dart'; import 'VerificationCenter.dart'; import 'WhiteAndBlackList.dart'; import "package:chat/utils/PicSwiper.dart"; import 'add_friend.dart'; import 'apply_content_view.dart'; import 'daily_bonus_page.dart'; import 'dart:math' as math; var cardWidth; var greyColor = const Color(0xFFB2B2B2); const MaxImgSize = 20; class ProfilePage extends StatefulWidget { @required final userId; final int fromWhere; final int addMode; final int applyId; //好友申请id ProfilePage( {Key key, this.userId, this.fromWhere, this.addMode = 0, this.applyId = 0}) : super(key: key); _ProfilePageState createState() => _ProfilePageState(); } class _ProfilePageState extends State with TickerProviderStateMixin { static const Separate_Size = 10.0; GlobalKey registKey = new GlobalKey(); UserInfo userInfo = new UserInfo(); TextEditingController nickNameController = new TextEditingController(); bool isMyself = false; List imgList = []; bool isCanWatch = false; bool isMan = true; bool isAttestation = false; bool isBuyPicture = false; bool isVip = false; bool isSvip = false; bool isApplying = false; //是否申请中 //约会节目 String dateItem = ''; //期待对象 String lovePeople = ''; //约会范围 String dateRange = ''; //生日 String birthday = ''; //身高数据 String heightStr = ''; //体重数据 String weightStr = ''; //个人介绍 String myMsg = ''; Map wealthData = { 'CoinValue': 0, 'IsMember': 0, }; int myselfImg = 0; String endTime = ''; bool isLoadingFish = false; String firstDyImg = ''; //第一条动态的图片 int programId = 0; //是否有一条活跃的节目 bool isblack = false; bool isAuthority = false; //是否有聊天和查看用户资料的权限 bool isShowAll = false; double fansWidth = Screen.width - 105; getUserInfo({mymsg = ''}) async { if (mymsg != '' && mymsg != null) { UserData().basicInfo.ownMsg = mymsg; } HttpUtil().getUserInfo( widget.userId, (data) async { print('getUserInfo $data'); if (isMyself) { saveLocalData(data); } userInfo = UserInfo.fromJson(data); initValues(); isLoadingFish = true; showMyMsgDialog(); if (mounted) { setState(() {}); } }, _buildJoinVip, () { if (!isMyself) { Future.delayed(Duration(milliseconds: 500), () { Navigator.of(context).pop(); }); } }); if (isMyself) { HttpUtil().getWealth(context, (data) { wealthData = data; endTime = data['MemberEnd']; if (mounted) { Provider.of(context) .initMoney(data['CoinValue']); Provider.of(context) .initVoucher(data['Voucher']); } }); } } saveLocalData(data) { UserData().basicInfo = UserInfo.fromJson(data); SPUtils.saveString( Constants.LocalUsrInfo, jsonEncode(UserData().toJson()).toString()); } initLocalData() async { if (isMyself && await SPUtils.get(Constants.LocalUsrInfo) != null) { isLoadingFish = true; userInfo = UserData().basicInfo; initValues(); showMyMsgDialog(); } } showMyMsgDialog() { if (!UserData().isFirstTip && (UserData().basicInfo.ownMsg == '' || UserData().basicInfo.ownMsg == null) && UserData().homemainIndex == 4) { UserData().isFirstTip = true; CustomUI.buildOneConfirm( context, I18n.of(context).personal, I18n.of(context).white_now, () { Navigator.pop(context); Navigator.of(context).push( new MaterialPageRoute( builder: (context) { return EditPage( isEditPage: true, ); }, ), ); }); } } initValues() { isMan = userInfo.sex == 1; isAttestation = userInfo.isAttestation == null || userInfo.isAttestation; isVip = userInfo.isMember > 0; isSvip = userInfo.isMember == 2; isCanWatch = userInfo.infoAut == 0 || userInfo.applyStatus == 1; isApplying = userInfo.applyStatus == 0; isblack = userInfo.isBlackList; isBuyPicture = (isMyself || userInfo.photoAut == 0 || userInfo.payStatus == 1); dateItem = userInfo.program == null ? "" : WebData().getProgram(userInfo.program); lovePeople = userInfo.hopeObject == null ? "" : WebData().getLovePeople(userInfo.hopeObject); dateRange = WebData().getDateRange(userInfo.meetPlace); birthday = userInfo.birthday == null ? '' : userInfo.birthday; isAuthority = userInfo.isAuthority || (!UserData().isMan() && UserData().basicInfo.isAttestation) || userInfo.distince < 200; myMsg = userInfo.ownMsg; } @override void initState() { super.initState(); print('ProfilePage initState'); isMyself = widget.userId == UserData().basicInfo.userId; messageOn(); initLocalData(); getUserInfo(); } void initMyController() {} void _buildJoinVip() { isLoadingFish = true; CustomUI.buildOneConfirm( context, I18n.of(context).only_see, I18n.of(context).joinvip, () { Navigator.of(context).push( new MaterialPageRoute( builder: (context) { return VipPage(); }, ), ); }, failcallbak: () { Navigator.of(context).pop(); }); } msgBuyVip(data) { HttpUtil().getWealth(context, (data) { wealthData = data; endTime = data['MemberEnd']; if (mounted) { Provider.of(context).initMoney(data['CoinValue']); } }); } msgUpdateData(data) { print('msgUpdateData $data'); getUserInfo(mymsg: data); } msgInformSucess(data) { if (!isMyself) CustomUI.buildOneConfirm( context, I18n.of(context).waiting_results, I18n.of(context).ok, () { Navigator.of(context).pop(); }); } msgListDelete(data) { if (userInfo.dynamicNum > 0) { if (mounted) { setState(() { userInfo.dynamicNum--; }); } } } addProgramCallback(data) { if (mounted) { setState(() { userInfo.dynamicNum++; }); } } void messageOn() { MessageMgr().on('inform_sucess', msgInformSucess); MessageMgr().on('refresh_money', msgBuyVip); MessageMgr().on('update_data', msgUpdateData); MessageMgr().on('delete_program', msgListDelete); MessageMgr().on('post_add_friend', msgAddFriend); MessageMgr().on('refresh_love_list', msgRefreshLoveList); MessageMgr().on('refresh_fans_num', msgRefreshFansNum); MessageMgr().on('change_my_headview', msgChangeMyHeadView); MessageMgr().on('Add_program', addProgramCallback); } void messageOff() { MessageMgr().off('inform_sucess', msgInformSucess); MessageMgr().off('refresh_money', msgBuyVip); MessageMgr().off('update_data', msgUpdateData); MessageMgr().off('delete_program', msgListDelete); MessageMgr().off('post_add_friend', msgAddFriend); MessageMgr().off('refresh_love_list', msgRefreshLoveList); MessageMgr().off('refresh_fans_num', msgRefreshFansNum); MessageMgr().off('change_my_headview', msgChangeMyHeadView); MessageMgr().off('Add_program', addProgramCallback); } msgChangeMyHeadView(data) { if (isMyself) { userInfo.headimgurl = UserData().basicInfo.headimgurl; setState(() {}); } } msgRefreshFansNum(data) { setState(() { if (data['UserId'] == userInfo.userId && userInfo.fans < data['nums']) { userInfo.fans = data['nums']; } }); } msgRefreshLoveList(data) { setState(() { if (data['flag'] == 0) { isMyself ? userInfo.followNum++ : userInfo.fans++; } else { isMyself ? userInfo.followNum-- : userInfo.fans--; } }); } msgAddFriend(data) { setState(() { userInfo.isAddFriends = 0; }); } @override void dispose() { messageOff(); registKey = null; nickNameController.dispose(); super.dispose(); } showHeadView() { Navigator.of(context).push( new MaterialPageRoute( builder: (context) { return MyHeadViewPage(); }, ), ); } Widget _buildSignIn() { return Container( margin: EdgeInsets.only(top: 19, bottom: 19), padding: EdgeInsets.symmetric(horizontal: 10), child: FullWidthButton( iconCode: 0xe65c, iconColor: 0xFFAF60F8, showRightIcon: true, title: I18n.of(context).sign_in, showDivider: false, onPressed: () { if (UserData().sign <= 0) { showToast(I18n.of(context).system_not_open); return; } Navigator.of(context).push(MaterialPageRoute( builder: (context) { return DailyBonusPage(); }, )); }, ), decoration: BoxDecoration( color: Colors.white, border: Border( top: Constants.GreyBorderSide, bottom: Constants.GreyBorderSide)), ); } Widget _buildPicture() { return FullWidthButton( iconCode: 0xe689, iconColor: 0xFFE3AA10, title: (isMyself ? I18n.of(context).my_album : (isMan ? I18n.of(context).his_photo : I18n.of(context).her_photo)), descriptionColor: Constants.BlueTextColor, showDivider: false, showRightIcon: true, onPressed: () { Navigator.of(context).push( new MaterialPageRoute( builder: (context) { return PhotoPage( userInfo: userInfo, ); }, ), ); }, ); } Widget _buildHeadView() { cardWidth = MediaQuery.of(context).size.width; return Container( decoration: BoxDecoration( color: Colors.white, border: Border(bottom: Constants.GreyBorderSide)), child: Container( decoration: BoxDecoration( color: Colors.white, ), width: MediaQuery.of(context).size.width, padding: EdgeInsets.only(top: 19), child: Column( children: [ Container( child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ _buildHeadImg(), Column(children: [ _buildFans(), _buildButtonList(), ]) ], )), _buildUserChips(), _buildAttestation(), _buildMyMsg(), ], ), ), ); } Widget _buildMyMsg() { double width = Screen.width - 80; var textStyle = TextStyle(fontSize: 12, color: Color(0xFF333333)); // userInfo.ownMsg = // '哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈'; bool showAllContent = isExpansion(userInfo.ownMsg, width); return Container( padding: EdgeInsets.only(left: 25.5, bottom: isMyself ? 20 : 20, right: 10), child: userInfo.ownMsg == null || userInfo.ownMsg == '' ? (isMyself ? InkWell( onTap: () { Navigator.of(context).push( new MaterialPageRoute( builder: (context) { return EditPage(isEditPage: true); }, ), ); }, child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( constraints: BoxConstraints(maxWidth: width), child: Text(I18n.of(context).msg_tips, style: textStyle)), Transform.rotate( angle: math.pi * 2, child: Icon( IconData(0xe68d, fontFamily: Constants.IconFontFamily), color: Color(0xFF717171), size: 16, )) ])) : Container()) : Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( width: width, child: Text( userInfo.ownMsg, style: textStyle, maxLines: isShowAll ? 10 : 1, overflow: TextOverflow.ellipsis, )), SizedBox(width: 4), showAllContent ? InkWell( onTap: () { setState(() { isShowAll = !isShowAll; }); }, child: Transform.rotate( angle: isShowAll ? math.pi : 0, child: Icon( IconData(0xe684, fontFamily: Constants.IconFontFamily), color: Color(0xFF717171), size: 13, ))) : Container(), ], )); } bool isExpansion(String text, double width) { TextPainter _textPainter = TextPainter( maxLines: 2, text: TextSpan( text: text, style: TextStyle(fontSize: 12.0, color: Colors.black)), textDirection: TextDirection.ltr) ..layout(maxWidth: width, minWidth: width); if (_textPainter.didExceedMaxLines) { //这里判断 文本是否截断 return true; } else { return false; } } Widget _buildBorderButton(String str, double width, callback, {IconData iconCode, int iconColor = 0xFF181818}) { return InkWell( onTap: callback, child: Container( alignment: Alignment.center, decoration: BoxDecoration( border: Border.all(color: Color(0xB5CCCCCC)), borderRadius: BorderRadius.circular(14)), height: 28, width: width, child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [ iconCode != null ? Container( margin: EdgeInsets.only(right: str == null ? 0 : 2), child: Icon( iconCode, size: 16, color: Color(iconColor), )) : Container(), Text( str, style: TextStyle(fontSize: 14), ) ]), )); } gotoEditPage() { Navigator.of(context).push( new MaterialPageRoute( builder: (context) { return EditPage(isEditPage: true); }, ), ); } gotoSystemEditPage() { Navigator.of(context).push( new MaterialPageRoute( builder: (context) { return SystemEditPage(); }, ), ); } loveOrCancele() { if (!userInfo.isLike) { HttpUtil().setLove(userInfo.userId, () { MessageMgr() .emit('refresh_love_list', {'UserId': userInfo.userId, 'flag': 0}); setState(() { userInfo.isLike = true; }); }); } else { HttpUtil().cancleLove(userInfo.userId, () { MessageMgr() .emit('refresh_love_list', {'UserId': userInfo.userId, 'flag': 2}); setState(() { userInfo.isLike = false; }); }); } } cannotWatchTips() { showToast(isMan ? I18n.of(context).view_user : I18n.of(context).view_user2); } Widget _buildButtonList() { List list = []; if (isMyself) { list = [ _buildBorderButton( I18n.of(context).edit_information, 140, gotoEditPage), SizedBox(width: 12.5), _buildBorderButton('', 54, gotoSystemEditPage, iconCode: Icons.settings), ]; } else if (userInfo.sex == UserData().basicInfo.sex) { list = [ _buildBorderButton(I18n.of(context).private_chat, fansWidth - 80, isCanWatch ? buyChatAccount : cannotWatchTips, iconCode: IconData(0xe68c, fontFamily: 'iconfont')), ]; } else { list = [ _buildBorderButton(I18n.of(context).like, 140, loveOrCancele, iconCode: IconData(userInfo.isLike ? 0xe623 : 0xe625, fontFamily: Constants.IconFontFamily), iconColor: userInfo.isLike ? 0xFFFF7777 : 0xFF181818), SizedBox(width: 12.5), _buildBorderButton( '', 53, isCanWatch ? buyChatAccount : cannotWatchTips, iconCode: IconData(0xe68c, fontFamily: 'iconfont')), ]; } return Container( margin: EdgeInsets.only(top: 13, bottom: 10), child: Row( children: list, )); } //认证相关 Widget _buildAttestation() { return Container( margin: EdgeInsets.only(top: 7, bottom: 7, left: 25.5), alignment: Alignment.centerLeft, child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ isAttestation ? Icon(Icons.check_circle_outline, size: 12, color: Constants.BlueTextColor) : Padding( padding: EdgeInsets.only(bottom: 0.5), child: Icon(IconData(0xe63a, fontFamily: 'iconfont'), size: 16, color: const Color(0xFFA9A9A9))), SizedBox(width: 3), Text( isAttestation ? isMyself ? (isMan ? (userInfo.isVipAttestation ? I18n.of(context).by_paying : I18n.of(context).incode_passed) : I18n.of(context).certified) : (isMan ? (userInfo.isVipAttestation ? I18n.of(context).pay_join : I18n.of(context).passed_review) : I18n.of(context).passed_video) : isMyself ? I18n.of(context).not_certified : (isMan ? '' : I18n.of(context).not_video), textScaleFactor: 1.0, style: TextStyle(fontSize: 11, color: Constants.GreyTextColor)) ], )); } Widget _buildFansButton(int nums, String text, callback, {bool isShowDot = false}) { return InkWell( onTap: callback, child: Container( width: fansWidth / 3, child: Column( children: [ Stack( children: [ Padding( padding: EdgeInsets.only(left: 4, right: 4), child: Text( nums > 99 ? "99+" : nums.toString(), style: TextStyle( fontSize: 15, color: Constants.BlackTextColor, fontWeight: FontWeight.w400), )), isShowDot ? Positioned( top: 2, right: 0, child: CircleAvatar( radius: 2, backgroundColor: const Color(0xFFE50000), ), ) : Container( width: 0, ) ], ), SizedBox(height: 4), Text( text, style: TextStyle(fontSize: 11, color: greyColor), ), ], )), ); } //关注列表 Widget _buildFans() { return Container( child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ _buildFansButton( userInfo.fans, I18n.of(context).fans, isMyself ? () { Navigator.of(context).push( new MaterialPageRoute( builder: (context) { return FansPage(); }, ), ); } : null), _buildFansButton( userInfo.followNum, I18n.of(context).attention, isMyself ? () { Navigator.of(context).push( new MaterialPageRoute( builder: (context) { return WhiteAndBlackPage( isWhite: true, ); }, ), ); } : null), _buildFansButton(userInfo.dynamicNum, I18n.of(context).dynamics, () { Navigator.of(context).push( new MaterialPageRoute( builder: (context) { return MyProgramPage( userId: userInfo.userId, isMan: isMan, ); }, ), ); }, isShowDot: userInfo.dynamicNum > 0), ], )); } Widget _buildDivder() { return Container( color: Color(0xFFE6E6E6), width: 1.5, height: 10, margin: EdgeInsets.only(left: 7.5, right: 7.5)); } //用户chips Widget _buildUserChips() { var age = 0; if (userInfo.birthday != null) { age = DateTime.now().year - int.parse(userInfo.birthday.split('-')[0]); } var textStyle = TextStyle(fontSize: 12); return Container( width: Screen.width, padding: EdgeInsets.only(left: 25.5), child: Wrap( crossAxisAlignment: WrapCrossAlignment.center, //mainAxisAlignment: MainAxisAlignment.start, children: [ isAttestation && !isMan ? Container( height: 13, width: 33, alignment: Alignment.center, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Constants.PurpleBackgroundColor, ), child: Text( 'Real', textScaleFactor: 1.0, style: TextStyle(fontSize: 9, color: Colors.white), )) : Container(width: 0), isVip && isMan ? Container( child: isSvip ? Constants.svipIcon : Constants.vipIcon) : Container(width: 0), (isAttestation && !isMan) || isVip && isMan ? _buildDivder() : Container(), Text( '${UserData().hasLocationPermission ? WebData().getDateRange(userInfo.meetPlace) : I18n.of(context).unknown}', style: textStyle, ), _buildDivder(), Text( '$age ${I18n.of(context).years_old}-${WebData().getConstellation(context, userInfo.constellation)}', style: textStyle, ), _buildDivder(), Text( userInfo.occupation == null ? '' : WebData().getProffesionName(userInfo.occupation), style: textStyle, ) ], )); } //用户头像 Widget _buildHeadImg() { double width = 85; return InkWell( onTap: isMyself ? showHeadView : () { Navigator.of(context).push( new MaterialPageRoute( builder: (context) { return PicSwiper( id: 0, pics: [PicSwiperItem(userInfo.headimgurl, id: 0)], ); }, ), ); }, child: Container( margin: EdgeInsets.only(left: 19, right: 0, bottom: 15), decoration: BoxDecoration(shape: BoxShape.circle, boxShadow: [ BoxShadow( color: Color(0xFFD9D9D9), offset: Offset(0, 0.5), blurRadius: 5, ) ]), width: width, height: width, child: ClipRRect( borderRadius: BorderRadius.circular(100), child: userInfo.headimgurl == null || userInfo.headimgurl == '' ? Image.asset(Constants.DefaultHeadImgUrl, height: width, width: width) : CachedNetworkImage( imageUrl: userInfo.headimgurl, placeholder: (context, url) => Image.asset( Constants.DefaultHeadImgUrl, height: width, width: width, ), fit: BoxFit.cover, ), )), ); } void _buildConfirmBlack() { Navigator.of(context).pop(); CustomUI.buildOneConfirm( context, I18n.of(context).blacklist_choose, I18n.of(context).determine, () async { Navigator.pop(context); HttpUtil().blackUser(userInfo.userId, () { isblack = true; }); }); } void _sendMySelfPicture() async { if (await CustomUI.showPhotoPermissionSetting(context)) { var tempFile = await ImagePicker.pickImage(source: ImageSource.gallery); if (tempFile != null) { Map data = {"type": 6, "userId": UserData().basicInfo.userId}; data['sign'] = TokenMgr().getSign(data); data['isBurn'] = 1; Response res = await HttpUtil().uploadFile( tempFile, data, 'upload/file/postflie', 'image', isShowLoading: true); var resData = res.data; if (resData['code'] == 0) { showToast(I18n.of(context).successfully_submit); myselfImg = resData['data']['photoId']; Navigator.of(context).pop(); _postApply(); } } } } void _postApply() async { Map data = { "userId": userInfo.userId, "imgUrl": myselfImg, "applyUserId": UserData().basicInfo.userId }; data['sign'] = TokenMgr().getSign(data); Response res = await HttpUtil() .post('user/apply/checkcords', data: data, isShowLoading: true); Map resData = res.data; if (resData['code'] == 0) { isApplying = true; setState(() {}); } } Widget _buildBody() { Widget hidden = Container( alignment: Alignment.center, width: Screen.width, height: Screen.height - 372, color: Colors.white, margin: EdgeInsets.only(top: 10), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( margin: EdgeInsets.only(bottom: 10), child: Image.asset('assets/images/login/lock.png', height: 45, width: 45), ), Text( isMan ? I18n.of(context).view_user : I18n.of(context).view_user2, textScaleFactor: 1.0, textAlign: TextAlign.center, style: TextStyle(color: Constants.GreyTextColor, fontSize: 13.5), ), InkWell( onTap: isApplying ? null : () async { CustomUI.buildOneConfirm( context, I18n.of(context).need_photo, I18n.of(context).choose_photo, _sendMySelfPicture); }, child: Container( margin: EdgeInsets.only(top: 10, left: 100, right: 100), padding: EdgeInsets.only(top: 10, bottom: 10), alignment: Alignment.center, decoration: BoxDecoration( color: Constants.ConfrimButtonColor, borderRadius: BorderRadius.all( Radius.circular(Constants.LittleButtonRadius))), child: Text( isApplying ? I18n.of(context).already_applied : I18n.of(context).apply_now, textScaleFactor: 1.0, style: TextStyle(color: Colors.white), ), )), ], ), ); List child = []; if (isMyself) { child.addAll([ _buildHeadView(), _buildSignIn(), _buildMoneyBox(), ]); } else if (isCanWatch) { child.addAll([ _buildHeadView(), Container( margin: EdgeInsets.only(top: 19, bottom: 19), padding: EdgeInsets.symmetric(horizontal: 10), child: _buildPicture(), decoration: BoxDecoration( color: Colors.white, border: Border( top: Constants.GreyBorderSide, bottom: Constants.GreyBorderSide)), ), _buildBasicInfo(), _buildBottomTips(), ]); } else if (userInfo.userId != null) { child.addAll([ _buildHeadView(), hidden, ]); } else { child.addAll([ _buildHeadView(), ]); } return Column( children: child, ); } _inviteFdBtn() { return Container( width: Screen.width, child: FlatButton( child: fixedText(I18n.of(context).add_friends, fontSize: 16, color: Colors.blueAccent, fontWeight: FontWeight.w500), onPressed: () async { //已经是好友 if (FriendListMgr().isMyFriend(userInfo.userId)) { showToast(I18n.of(context).added); return; } //已申请 if (userInfo.isAddFriends == 0) { showToast(I18n.of(context).add_friends_tips); return; } if (widget.addMode != 3 && UserData().addFdDistanceSwitch > 0 && userInfo.distince > 200) { showToast(I18n.of(context).distance_long); return; } Navigator.of(context).push( new MaterialPageRoute( builder: (context) { return AddFriendPage( userId: userInfo.userId, pageType: SendMessagePageType.AddFriends, originalName: I18n.of(context) .i_am .replaceFirst('/s1', UserData().basicInfo.nickName), ); }, ), ); }), ); } void doFriendApply(state, callback) async { Map data = { "id": widget.applyId, "userId": UserData().basicInfo.userId, "status": state, }; data['sign'] = TokenMgr().getSign(data); Response res = await HttpUtil().post('friendship/handler/apply', data: data); if (res == null) { return; } var resData = res.data; if (resData['code'] == 0) { callback(resData['msg']); } else {} } _dealInvite() { return Container( width: Screen.width, child: Row( children: [ Expanded( child: InkWell( onTap: () { doFriendApply(1, (msg) { showToast(msg); Navigator.of(context).pop(); var friendModel = FriendModel.fromServerJson({ 'UserId': userInfo.userId, 'ImgUrl': userInfo.headimgurl, 'UserName': userInfo.nickName }); FriendListMgr().addFriend(friendModel); FriendListMgr().deleteLocalUserIdById(userInfo.userId); MessageMgr().emit('do_friend_apply', {'userId': userInfo.userId, 'state': 1}); MessageMgr().emit('Add friend'); //同意好友后发送打招呼 MsgModel msgModel = MsgHandler.createSendMsg( ChatType.TextChatType, I18n.of(context).new_friends_tips, friendId: userInfo.userId, refMsg: null, refShortTxt: null, altUsers: null, channelType: ChatChannelType.Session); int sessionId = UserData().getSessionId(userInfo.userId); MsgHandler.updateActiveSesstion(sessionId); AppNavigator.pushChatPage(context, userInfo.userId, enterType: 3, enterContent: msgModel); }); }, child: Container( color: const Color(0xFF3875E9), alignment: Alignment.center, child: Text( I18n.of(context).agree, style: TextStyle(fontSize: 18, color: Colors.white), ), ), )), InkWell( onTap: () { doFriendApply(2, (msg) { showToast(msg); Navigator.of(context).pop(); FriendListMgr().deleteLocalUserIdById(userInfo.userId); MessageMgr().emit('do_friend_apply', {'userId': userInfo.userId, 'state': 2}); }); }, child: Container( alignment: Alignment.center, color: const Color(0xFFA8D3FF), width: Screen.width * 0.33, child: Text( I18n.of(context).refuse, style: TextStyle(fontSize: 18, color: const Color(0xFF007EFF)), ), )) ], )); } //自定义item Widget _bottomBorderBox( String textLeft, String textRight, bool showBorder, callback, {showIcon: false}) { Widget left = new Container( margin: EdgeInsets.only(right: 20), width: 90, child: new Text( textLeft, textScaleFactor: 1.0, style: TextStyle(fontSize: 14), )); Widget right = new Expanded( child: Text( textRight, textScaleFactor: 1.0, style: TextStyle(fontSize: 13, color: Constants.GreyTextColor), ), ); return InkWell( highlightColor: Colors.transparent, radius: 0.0, onTap: callback, child: Container( decoration: showBorder ? BoxDecoration(border: Border(bottom: Constants.GreyBorderSide)) : null, alignment: Alignment.center, padding: EdgeInsets.only( top: 17, bottom: 17, ), margin: EdgeInsets.only(left: 45, bottom: 0, right: 10), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ left, right, showIcon ? Padding( padding: EdgeInsets.only(right: 10), child: Icon( IconData(0xe63c, fontFamily: 'iconfont'), size: 22.0, color: Color(AppColors.TabIconNormal), )) : Container() ], ), )); } testChatPermission(callback) { becomeVip() { Navigator.of(context).push( new MaterialPageRoute( builder: (context) { return VipPage(); }, ), ); } payCallback() { if (Provider.of(context).money < UserData().accountPrice) { Navigator.of(context).pop(); CustomUI.buildOneConfirm(context, I18n.of(context).balance_insufficien, I18n.of(context).recharge, () { Navigator.of(context).pop(); ChargeMoney.showChargeSheet(context, () { setState(() {}); }); }); return; } Navigator.of(context).pop(); HttpUtil().buyChatAccount( UserData().accountPrice, userInfo.userId, context, () { setState(() { isAuthority = true; }); }); } freeTime() { HttpUtil().userFreeTime(context, userInfo.userId, 2, () { UserData().basicInfo.usedNum++; Navigator.of(context).pop(); setState(() { isAuthority = true; }); }); } //自己是女性,且未认证,提示去认证(好友除外) if (!UserData().isMan() && !UserData().basicInfo.isAttestation && !FriendListMgr().isMyFriend(userInfo.userId)) { CustomUI.buildNotTrue(context); return; } print('isAuthority $isAuthority'); var tipStr = ''; //没有解锁账号,并且对方禁止陌生人聊天 if (!isAuthority && !userInfo.isCanStrangerNews) { tipStr = I18n.of(context).stranger_close; } else { tipStr = I18n.of(context).unlock_information; if (userInfo.sex == 2 && !userInfo.isAttestation) { tipStr += '(${I18n.of(context).not_true_woman})'; } } if (isAuthority) { if (callback != null) callback(); } else { //如果自己是男性,vip提示免费次数,次数用完或者非vip提示购买 if (UserData().isMan()) { if (UserData().isVip) { UserData().basicInfo.freeNum < UserData().basicInfo.usedNum ? CustomUI.buildOneConfirm( context, tipStr, I18n.of(context) .pay_unlock .replaceFirst('/s1', UserData().accountPrice.toString()), payCallback) : CustomUI.buildOneConfirm( context, tipStr, I18n.of(context).unlock_choose, freeTime, ); } else { CustomUI.buildTowConfirm( context, tipStr, I18n.of(context).become_member, becomeVip, I18n.of(context) .pay_unlock .replaceFirst('/s1', UserData().accountPrice.toString()), payCallback); } } } } buyChatAccount() { if (widget.fromWhere != null && widget.fromWhere == 0) { ///如果是聊天界面跳转过来的,直接返回 Navigator.of(context).pop(); } else { testChatPermission(() { int fdId = userInfo.userId; int sessionId = UserData().getSessionId(fdId); MsgHandler.updateActiveSesstion(sessionId); AppNavigator.pushChatPage(context, fdId); }); } } clickChatAccout() { if (widget.fromWhere != null && widget.fromWhere == 0) { ///如果是聊天界面跳转过来的,直接返回 Navigator.of(context).pop(); } else { testChatPermission(() {}); } } buyPhoto() { //女性用户付费,男性用户会员的话免费解锁,非会员付费解锁 becomeVip() { Navigator.of(context).push( new MaterialPageRoute( builder: (context) { return VipPage(); }, ), ); } payCallback() { if (Provider.of(context).money < userInfo.price) { Navigator.of(context).pop(); CustomUI.buildOneConfirm(context, I18n.of(context).balance_insufficien, I18n.of(context).recharge, () { Navigator.of(context).pop(); ChargeMoney.showChargeSheet(context, () { setState(() {}); }); }); return; } Navigator.of(context).pop(); HttpUtil().buyPictures(userInfo.price, userInfo.userId, context, () { setState(() { isBuyPicture = true; }); }); } freeTime() { HttpUtil().userFreeTime(context, userInfo.userId, 1, () { UserData().basicInfo.usedNum++; Navigator.of(context).pop(); setState(() { isBuyPicture = true; }); }); } String title = I18n.of(context).unlock_user.replaceFirst( '/s1', Provider.of(context) .getRefName(userInfo.userId, userInfo.nickName), ); if (!UserData().isMan()) { CustomUI.buildOneConfirm( context, title, I18n.of(context) .pay_unlock .replaceFirst('/s1', userInfo.price.toString()), payCallback); } else if (UserData().isVip) { if (UserData().basicInfo.freeNum < UserData().basicInfo.usedNum) { CustomUI.buildOneConfirm( context, title, I18n.of(context) .pay_unlock .replaceFirst('/s1', userInfo.price.toString()), payCallback); } else { CustomUI.buildOneConfirm( context, title, I18n.of(context).unlock_choose, freeTime); } } else { CustomUI.buildTowConfirm( context, title, I18n.of(context).become_member, becomeVip, I18n.of(context) .pay_unlock .replaceFirst('/s1', userInfo.price.toString()), payCallback); } } Widget _buildBasicInfo() { String wechat = ''; String facebook = ''; bool isHidden = userInfo.accountStatus == 1; //隐藏社交账号 if (isHidden) { wechat = I18n.of(context).ask_me; facebook = I18n.of(context).ask_me; } else { wechat = isAuthority ? userInfo.wechat : I18n.of(context).filled_in; facebook = isAuthority ? userInfo.facebook : I18n.of(context).filled_in; } heightStr = (userInfo.height == 0.0 || userInfo.height == null) ? I18n.of(context).not_show : '${userInfo.height.toInt()}CM'; weightStr = (userInfo.weight == 0.0 || userInfo.weight == null) ? I18n.of(context).not_show : '${userInfo.weight.toInt()}KG'; List basicList = [ Container( padding: EdgeInsets.symmetric(horizontal: 10), child: FullWidthButton( iconCode: 0xe676, iconColor: 0xFF57BBFB, title: isMan ? I18n.of(context).his_profile : I18n.of(context).her_profile, showDivider: true, showRightIcon: false, onPressed: () {})), userInfo.height != null && userInfo.height != 0 ? _bottomBorderBox(I18n.of(context).height, heightStr, true, () {}) : Container(), userInfo.weight != null && userInfo.weight != 0 ? _bottomBorderBox(I18n.of(context).weight, weightStr, true, () {}) : Container(), _bottomBorderBox(I18n.of(context).Resident_city, dateRange, true, () {}), _bottomBorderBox(I18n.of(context).expect_lover, lovePeople, true, () {}), (userInfo.wechat != null && userInfo.wechat != '') ? _bottomBorderBox( I18n.of(context).wechat_number, wechat, true, clickChatAccout, showIcon: !isAuthority) : Container(), (userInfo.facebook != null && userInfo.facebook != '') ? _bottomBorderBox( I18n.of(context).facebook, facebook, true, clickChatAccout, showIcon: !isAuthority) : Container(), ]; return Container( width: cardWidth, decoration: BoxDecoration( color: Colors.white, border: Border( top: Constants.GreyBorderSide, bottom: Constants.GreyBorderSide)), child: new Column( children: basicList, )); } Widget _buildBottomTips() { return Container( margin: EdgeInsets.only(bottom: 10, left: 10, right: 10, top: 10), width: cardWidth, alignment: Alignment.center, child: Text(I18n.of(context).not_illage, textScaleFactor: 1.0, textAlign: TextAlign.center, style: TextStyle(fontSize: 12, color: Colors.grey)), ); } Widget _buildMoneyBox() { //认证、钱包、隐私连麦设置 return Container( decoration: BoxDecoration( color: Colors.white, border: Border( top: Constants.GreyBorderSide, bottom: Constants.GreyBorderSide)), padding: EdgeInsets.only(top: 4, bottom: 4, left: 10, right: 10), child: Column( children: [ isMan ? Container() : FullWidthButton( iconCode: 0xe687, iconColor: 0xFFFF7752, title: I18n.of(context).Goddess_heat, showDivider: true, showRightIcon: true, onPressed: () { Navigator.of(context).push( new MaterialPageRoute( builder: (context) { return GoddessHotPage( userId: userInfo.userId, ); }, ), ); }, ), isMan ? FullWidthButton( iconCode: 0xe68e, iconColor: 0xFF3D83E6, title: I18n.of(context).member, description: UserData().isVip ? I18n.of(context) .expires .replaceFirst('/s1', endTime.split(' ')[0]) : I18n.of(context).enjoy_privileges, showDivider: true, onPressed: () { Navigator.of(context).push( new MaterialPageRoute( builder: (context) { return VipPage(); }, ), ); }, ) : FullWidthButton( iconCode: 0xe688, iconColor: 0xFF3D83E6, title: isAttestation ? I18n.of(context).certified_video : I18n.of(context).authenticate, showDivider: true, onPressed: () { Navigator.of(context).push( new MaterialPageRoute( builder: (context) { return isAttestation ? VideoPage( userId: userInfo.userId, ) : VerificationCenterPage(); }, ), ); }, ), FullWidthButton( iconCode: 0xe68a, iconColor: 0xFF4CB871, title: I18n.of(context).wallet, description: '${Provider.of(context).money}${I18n.of(context).mask_coin}', showDivider: true, onPressed: () { Navigator.of(context).push( new MaterialPageRoute( builder: (context) { return MoneyPage(); }, ), ); }, ), _buildPicture(), ], ), ); } Widget _buildIcon(code, str, isCanHit, callback, {iconSize = 30.0}) { var color = isCanHit ? Constants.BlueTextColor : Constants.GreyTextColor; return InkWell( onTap: isCanHit ? callback : () { showToast(isMan ? I18n.of(context).view_user : I18n.of(context).view_user2); }, child: Row( children: [ Icon( IconData( code, fontFamily: 'iconfont', ), color: color, size: iconSize, ), Padding( child: Text( str, textScaleFactor: 1.0, style: TextStyle(color: color, fontSize: 14), ), padding: EdgeInsets.only(left: 5)) ], )); } @override Widget build(BuildContext context) { Size screenSize = MediaQuery.of(context).size; cardWidth = screenSize.width; Widget appBar = AppBar( leading: isMyself ? Container() : CustomUI.buildCustomLeading(context), titleSpacing: isMyself ? -40 : NavigationToolbar.kMiddleSpacing, title: isMyself ? Text( userInfo.nickName, //I18n.of(context).me, textScaleFactor: 1.0, style: Constants.MainTitleStyle, ) : Text( WebData().subUserName(Provider.of(context) .getRefName(userInfo.userId, userInfo.nickName)), textScaleFactor: 1.0, style: TextStyle(color: Constants.BlackTextColor)), centerTitle: !isMyself, elevation: 1, actions: [ isMyself ? Container( padding: EdgeInsets.only(right: 15), alignment: Alignment.center, child: new InkWell( child: CircleAvatar( backgroundColor: Constants.GreyBackgroundColor, radius: 15.75, child: Icon( IconData(0xe685, fontFamily: 'iconfont'), color: Constants.BlackTextColor, size: 20, )), onTap: () { Share.share('https://henho.jphgames.com/'); }, ), ) : Container(), isMyself ? Container() : Container( alignment: Alignment.center, child: new InkWell( child: new Padding( padding: EdgeInsets.only( right: 15, left: 15, top: 10, bottom: 10), child: Icon( IconData( 0xe621, fontFamily: 'iconfont', ), color: Constants.BlackTextColor, size: 20, ), ), onTap: () { showModalBottomSheet( context: registKey.currentContext, builder: (BuildContext context) { return SafeArea( child: Container( height: 137, child: Column( children: [ InkWell( onTap: () async { Navigator.of(context).pop(); Navigator.of(context).push( new MaterialPageRoute( builder: (context) { return AddFriendPage( userId: userInfo.userId, pageType: SendMessagePageType.Remark, originalName: Provider.of< RefNameProvider>( context) .getRefName(userInfo.userId, userInfo.nickName)); }, ), ); }, child: Container( alignment: Alignment.center, height: 45, child: Text(I18n.of(context).Remark, textScaleFactor: 1.0, style: TextStyle( fontSize: 18, color: Constants .BlackTextColor)))), Divider(height: 1), InkWell( child: Container( height: 45, alignment: Alignment.center, child: Text( isblack ? I18n.of(context).remove_blacklist : I18n.of(context).blacklist, textScaleFactor: 1.0, style: TextStyle( fontSize: 18, color: Constants.BlackTextColor), ), ), onTap: isblack ? () async { HttpUtil().cancleBlackUser( userInfo.userId, () { Navigator.of(context).pop(); isblack = false; }); } : _buildConfirmBlack, ), Divider(height: 1), InkWell( onTap: () async { Navigator.of(context).pop(); Navigator.of(context).push( new MaterialPageRoute( builder: (context) { return InformUserPage( isMan: isMan, userId: userInfo.userId, ); }, ), ); }, child: Container( alignment: Alignment.center, height: 45, child: Text( I18n.of(context).anonymous_report, textScaleFactor: 1.0, style: TextStyle( fontSize: 18, color: Constants .BlackTextColor)))), ], ), ), ); }, ).then((val) {}); }, ), ), ], ); var bottomWidget = Container( height: 55, decoration: BoxDecoration( border: Border(top: BorderSide(color: Color(0xffeaeaea))), color: Constants.LightGreyBackgroundColor, ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: widget.addMode == 1 || widget.addMode == 3 ? [_inviteFdBtn()] : (widget.addMode == 2 ? [_dealInvite()] : [ _buildIcon(0xe68b, I18n.of(context).evaluate, true, () async { Map data = { "userid": userInfo.userId, 'evaluateuserid': UserData().basicInfo.userId, }; data['sign'] = TokenMgr().getSign(data); Response res = await HttpUtil().post('evaluate/user/info', data: data, isShowLoading: true); Map resData = res.data; print(resData); if (resData['code'] == 0) { Navigator.of(context).push(TutorialOverlay( child: ApplyContent( userId: userInfo.userId, isMan: isMan, userInfo: resData['data']))); } else { showToast(resData['msg']); } }), _buildIcon( 0xe62f, I18n.of(context).chat, isCanWatch, onAudio) ]), ), ); Widget content = Container( color: Colors.white, child: SafeArea( child: Scaffold( bottomNavigationBar: !isMyself ? bottomWidget : null, appBar: appBar, key: registKey, body: SafeArea( child: Container( height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, color: AppColors.BackgroundColor, child: SingleChildScrollView( child: _buildBody(), ), )))), ); return CustomUI.buildPageLoading(context, content, !isLoadingFish); } //连麦 onAudio() async { testChatPermission(() async { if (userInfo.chatStatus == 0) { showToast(I18n.of(context).cantt_voice); return; } if (BlacklistMgr.isBlack(userInfo.userId)) { return; } //对方关闭陌生人消息,则提示 if (!userInfo.isCanStrangerNews) { showToast(I18n.of(context).stranger_close_tips); return; } if (await CustomUI.showPermissionSetting(context, PermissionGroup.microphone, I18n.of(context).video_permission)) { AppNavigator.pushAudioChatPage(context, userInfo); } else { showToast(I18n.of(context).need_record); } }); } }