Browse Source

群简介相关逻辑

Steven 3 months ago
parent
commit
7e753a0296

+ 9 - 0
KulexiuForTeacher/KulexiuForTeacher/Common/Base/KSNetworkingManager.h

@@ -534,6 +534,15 @@ NS_ASSUME_NONNULL_BEGIN
 /// @param faliure 失败
 + (void)groupMuteRequest:(NSString *)post groupId:(NSString *)groupId userIdArray:(NSMutableArray *)userIds groupMute:(BOOL)groupMute success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure;
 
+// /imGroup/update
+// 群简介修改
+/// @param post post json
+/// @param groupId 群ID
+/// @param introduce 简介
+/// @param success 成功
+/// @param faliure 失败
++ (void)imGroupIntroduceModifyRequest:(NSString *)post groupId:(NSString *)groupId introduce:(NSString *)introduce success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure;
+
 #pragma mark ---- 群公告
 // /api-teacher/imGroupNotice/queryPage
 

+ 16 - 0
KulexiuForTeacher/KulexiuForTeacher/Common/Base/KSNetworkingManager.m

@@ -1140,6 +1140,22 @@
     [self request:post andWithUrl:url and:parm success:success faliure:faliure];
 }
 
+// /imGroup/update
+// 群简介修改
+/// @param post post json
+/// @param groupId 群ID
+/// @param introduce 简介
+/// @param success 成功
+/// @param faliure 失败
++ (void)imGroupIntroduceModifyRequest:(NSString *)post groupId:(NSString *)groupId introduce:(NSString *)introduce success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
+    [self configRequestMethodJSON];
+    NSString *url = [NSString stringWithFormat:@"%@%@%@", hostURL, @"/api-teacher",@"/imGroup/update"];
+    NSMutableDictionary *parm = [NSMutableDictionary dictionary];
+    [parm setValue:groupId forKey:@"id"];
+    [parm setValue:introduce forKey:@"introduce"];
+    [self request:post andWithUrl:url and:parm success:success faliure:faliure];
+}
+
 #pragma mark ---- 群公告
 // /api-teacher/imGroupNotice/queryPage
 

+ 13 - 1
KulexiuForTeacher/KulexiuForTeacher/Module/Chat/Group/Controller/GroupIntroduceViewController.m

@@ -37,7 +37,19 @@
 
 - (void)updateIntroduce:(NSString *)introduce {
     [LOADING_MANAGER showCustomLoading:@"加载中..."];
-    
+    [KSNetworkingManager imGroupIntroduceModifyRequest:KS_POST groupId:self.groupId introduce:introduce success:^(NSDictionary * _Nonnull dic) {
+        [LOADING_MANAGER removeCustomLoading];
+        if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
+            [LOADING_MANAGER KSShowMsg:@"保存成功" promptCompletion:^{
+                [self backAction];
+            }];
+        }
+        else {
+            [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
+        }
+    } faliure:^(NSError * _Nonnull error) {
+        [LOADING_MANAGER removeCustomLoading];
+    }];
 }
 
 - (GroupIntroduceBodyView *)bodyView {

+ 6 - 6
KulexiuForTeacher/KulexiuForTeacher/Module/Chat/Group/View/ChatComplainBodyView.xib

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
     <device id="retina6_1" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23506"/>
         <capability name="System colors in document resources" minToolsVersion="11.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -38,10 +38,10 @@
                                     <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                     <color key="textColor" red="0.2666666667" green="0.2666666667" blue="0.2666666667" alpha="1" colorSpace="calibratedRGB"/>
                                     <fontDescription key="fontDescription" type="system" weight="medium" pointSize="15"/>
-                                    <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
+                                    <textInputTraits key="textInputTraits" autocapitalizationType="sentences" smartInsertDeleteType="no"/>
                                 </textView>
                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="请输入投诉理由" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="srl-cR-tfi">
-                                    <rect key="frame" x="10" y="9" width="107.5" height="18"/>
+                                    <rect key="frame" x="10" y="9" width="104.5" height="18"/>
                                     <fontDescription key="fontDescription" type="system" pointSize="15"/>
                                     <color key="textColor" red="0.66666666666666663" green="0.66666666666666663" blue="0.66666666666666663" alpha="1" colorSpace="calibratedRGB"/>
                                     <nil key="highlightedColor"/>
@@ -58,7 +58,7 @@
                             </constraints>
                         </view>
                         <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="投诉理由" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tN1-Iy-7ZO">
-                            <rect key="frame" x="40" y="16" width="65.5" height="22"/>
+                            <rect key="frame" x="40" y="16" width="64" height="22"/>
                             <constraints>
                                 <constraint firstAttribute="height" constant="22" id="brX-IC-SC3"/>
                             </constraints>
@@ -105,7 +105,7 @@
                             </constraints>
                         </view>
                         <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="上传聊天截图" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oi4-ac-uGd">
-                            <rect key="frame" x="40" y="16" width="98" height="22"/>
+                            <rect key="frame" x="40" y="16" width="95.5" height="22"/>
                             <constraints>
                                 <constraint firstAttribute="height" constant="22" id="4KB-xi-B4I"/>
                             </constraints>

+ 94 - 2
KulexiuForTeacher/KulexiuForTeacher/Module/Chat/Group/View/GroupIntroduceBodyView.m

@@ -17,6 +17,8 @@
 
 @property (nonatomic, copy) GroupIntroduceModifyCallback callback;
 
+@property (nonatomic, assign) NSInteger maxInputCount;
+
 
 @end
 
@@ -25,6 +27,13 @@
 - (void)awakeFromNib {
     [super awakeFromNib];
     self.inputView.delegate = self;
+    self.inputView.textContainer.lineFragmentPadding = 0;
+    self.inputView.textContainerInset = UIEdgeInsetsZero;
+    [self configDefault];
+}
+
+- (void)configDefault {
+    self.maxInputCount = 200;
 }
 
 + (instancetype)sharedInstance {
@@ -41,7 +50,7 @@
     
     NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
     paragraphStyle.lineSpacing = 4.0f;
-    UIFont *font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
+    UIFont *font = [UIFont systemFontOfSize:16 weight:UIFontWeightRegular];
     if (![NSString isEmptyString:introduceString]) {
         NSDictionary *attributes = @{NSFontAttributeName:font,NSParagraphStyleAttributeName:paragraphStyle,NSForegroundColorAttributeName:HexRGB(0x333333)};
         self.inputView.attributedText = [[NSAttributedString alloc] initWithString:introduceString attributes:attributes];
@@ -52,12 +61,95 @@
     [self endEditing:YES];
     if (self.callback) {
         if ([NSString isEmptyString:self.inputView.text]) {
-            [LOADING_MANAGER MBShowAUTOHidingInWindow:@"请输入标题"];
+            [LOADING_MANAGER MBShowAUTOHidingInWindow:self.tipsLabel.text];
             return;
         }
         self.callback(self.inputView.text);
     }
 }
+
+#pragma mark   ---- delegate
+
+- (void)textViewDidBeginEditing:(UITextView *)textView {
+    self.tipsLabel.hidden = YES;
+}
+
+
+- (void)textViewDidEndEditing:(UITextView *)textView {
+    if ([NSString isEmptyString:textView.text]) {
+        self.tipsLabel.hidden = NO;
+    }
+}
+
+- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
+    UITextRange *markedTextRange = textView.markedTextRange;
+    if (markedTextRange) {
+        // 当前处于拼音输入状态,暂不更新 attributedText
+        return YES;
+    }
+    NSInteger limitCount = self.maxInputCount;
+
+    NSString *newText = [[textView text] stringByReplacingCharactersInRange:range withString:text];
+    if (newText.length > limitCount) {
+        newText = [newText substringWithRange:NSMakeRange(0, limitCount)];
+        textView.text = newText;
+    }
+    return YES;
+}
+
+- (void)updateTextViewLineHeight:(UITextView *)textView {
+    UITextRange *markedTextRange = textView.markedTextRange;
+    if (markedTextRange) {
+        // 当前处于拼音输入状态,暂不更新 attributedText
+        return;
+    }
+    [UIView setAnimationsEnabled:NO];
+    NSRange selectedRange = textView.selectedRange;
+    NSMutableAttributedString *attrs = [[NSMutableAttributedString alloc] initWithString:textView.text attributes:[self getTypeAttributes]];
+    textView.attributedText = attrs;
+    textView.selectedRange = selectedRange;
+    [UIView setAnimationsEnabled:YES];
+}
+
+- (void)textViewDidChange:(UITextView *)textView {
+    // 获取当前高亮的部分(如果正在拼音输入状态)
+    UITextRange *selectedRange = [textView markedTextRange];
+    UITextPosition *position = [textView positionFromPosition:selectedRange.start offset:0];
+    
+    // 如果没有高亮选择的文本,说明不是拼音输入状态
+    if (!position) {
+        // 获取当前textView的内容
+        NSInteger limitCount = self.maxInputCount;
+        NSString *currentText = textView.text;
+        
+        // 如果文本超出最大长度,进行截取
+        if (currentText.length > limitCount) {
+            NSString *limitedText = [currentText substringToIndex:limitCount];
+            textView.text = limitedText;
+        }
+        
+        self.countLabel.text = [NSString stringWithFormat:@"%zd/%zd",textView.text.length,self.maxInputCount];
+    }
+    [self updateTextViewLineHeight:textView];
+}
+
+- (BOOL)textViewShouldEndEditing:(UITextView *)textView {
+    [self endEditing:YES];
+    return YES;
+}
+
+- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
+    [self endEditing:YES];
+}
+
+- (NSDictionary *)getTypeAttributes {
+    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
+    paragraphStyle.lineSpacing = 4.0f;
+    UIFont *font = [UIFont systemFontOfSize:16 weight:UIFontWeightRegular];
+    
+    NSDictionary *attributes = @{NSFontAttributeName:font,NSParagraphStyleAttributeName:paragraphStyle,NSForegroundColorAttributeName:HexRGB(0x333333)};
+    return attributes;
+}
 /*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.

+ 12 - 7
KulexiuForTeacher/KulexiuForTeacher/Module/Chat/Group/View/GroupIntroduceBodyView.xib

@@ -30,14 +30,14 @@
                             <nil key="highlightedColor"/>
                         </label>
                         <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="ojd-Ye-Vwu">
-                            <rect key="frame" x="12" y="48" width="341" height="236"/>
+                            <rect key="frame" x="12" y="45" width="341" height="239"/>
                             <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                             <color key="textColor" systemColor="labelColor"/>
                             <fontDescription key="fontDescription" type="system" pointSize="14"/>
-                            <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
+                            <textInputTraits key="textInputTraits" autocapitalizationType="sentences" smartInsertDeleteType="no"/>
                         </textView>
-                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="请输入投诉理由" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eX5-gT-ext">
-                            <rect key="frame" x="12" y="44" width="112" height="22"/>
+                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="请输入群简介" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eX5-gT-ext">
+                            <rect key="frame" x="12" y="44" width="95.333333333333329" height="22"/>
                             <constraints>
                                 <constraint firstAttribute="height" constant="22" id="BLH-Gt-f9F"/>
                             </constraints>
@@ -46,11 +46,11 @@
                             <nil key="highlightedColor"/>
                         </label>
                         <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0/200" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Rjf-ib-50h">
-                            <rect key="frame" x="307" y="12" width="46" height="22"/>
+                            <rect key="frame" x="314.33333333333331" y="12" width="38.666666666666686" height="22"/>
                             <constraints>
                                 <constraint firstAttribute="height" constant="22" id="Noz-AX-6hw"/>
                             </constraints>
-                            <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                            <fontDescription key="fontDescription" type="system" pointSize="14"/>
                             <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.29999999999999999" colorSpace="custom" customColorSpace="sRGB"/>
                             <nil key="highlightedColor"/>
                         </label>
@@ -58,7 +58,7 @@
                     <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                     <constraints>
                         <constraint firstItem="00i-pd-fVW" firstAttribute="leading" secondItem="l4Y-wY-IEl" secondAttribute="trailing" constant="3" id="3ph-YE-NzZ"/>
-                        <constraint firstItem="ojd-Ye-Vwu" firstAttribute="top" secondItem="l4Y-wY-IEl" secondAttribute="bottom" constant="12" id="4vj-gA-Ure"/>
+                        <constraint firstItem="ojd-Ye-Vwu" firstAttribute="top" secondItem="l4Y-wY-IEl" secondAttribute="bottom" constant="9" id="4vj-gA-Ure"/>
                         <constraint firstItem="l4Y-wY-IEl" firstAttribute="leading" secondItem="6Wf-NZ-RlI" secondAttribute="leading" constant="11" id="7V7-IT-uqm"/>
                         <constraint firstAttribute="height" constant="296" id="82l-ei-nCJ"/>
                         <constraint firstAttribute="trailing" secondItem="ojd-Ye-Vwu" secondAttribute="trailing" constant="12" id="BLP-4W-nDO"/>
@@ -89,6 +89,9 @@
                             <real key="value" value="22"/>
                         </userDefinedRuntimeAttribute>
                     </userDefinedRuntimeAttributes>
+                    <connections>
+                        <action selector="saveAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="SfW-vq-1Bz"/>
+                    </connections>
                 </button>
             </subviews>
             <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
@@ -104,7 +107,9 @@
             <nil key="simulatedBottomBarMetrics"/>
             <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
             <connections>
+                <outlet property="countLabel" destination="Rjf-ib-50h" id="ZsS-CC-wDP"/>
                 <outlet property="inputView" destination="ojd-Ye-Vwu" id="9KT-FR-eXz"/>
+                <outlet property="tipsLabel" destination="eX5-gT-ext" id="IAg-Sd-72T"/>
             </connections>
             <point key="canvasLocation" x="34" y="20"/>
         </view>

+ 4 - 4
KulexiuForTeacher/KulexiuForTeacher/Module/Chat/GroupNotice/View/NoticeEditBodyView.xib

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23094" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
     <device id="retina6_1" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23084"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23506"/>
         <capability name="System colors in document resources" minToolsVersion="11.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -83,7 +83,7 @@
                             <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                             <color key="textColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                             <fontDescription key="fontDescription" type="system" pointSize="15"/>
-                            <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
+                            <textInputTraits key="textInputTraits" autocapitalizationType="sentences" smartInsertDeleteType="no"/>
                         </textView>
                         <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="请输入标题" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6fi-W7-TxF">
                             <rect key="frame" x="12" y="47" width="74.5" height="18"/>
@@ -143,7 +143,7 @@
                             <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                             <color key="textColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                             <fontDescription key="fontDescription" type="system" pointSize="15"/>
-                            <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
+                            <textInputTraits key="textInputTraits" autocapitalizationType="sentences" smartInsertDeleteType="no"/>
                         </textView>
                         <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="请输入公告内容" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mUd-aN-ASn">
                             <rect key="frame" x="12" y="47" width="104.5" height="18"/>

+ 5 - 5
KulexiuForTeacher/KulexiuForTeacher/Module/Home/HomeStatistics/HomeStatisticsView.m

@@ -40,19 +40,19 @@
     _url = [NSString stringWithFormat:@"%@%@",WEBHOST,@"/#/home-statistics"];
     [self addSubview:self.myWebView];
     [self.myWebView mas_makeConstraints:^(MASConstraintMaker *make) {
-        make.left.right.mas_equalTo(self);
+        make.left.mas_equalTo(self.mas_left).offset(14.0f);
+        make.right.mas_equalTo(self.mas_right).offset(-14.0f);
         make.top.mas_equalTo(self.mas_top);
         make.bottom.mas_equalTo(self.mas_bottom);
     }];
     [self loadRequest];
 }
 
-// 刷新统计数据
+
+//  页面重现时刷新统计数据
 - (void)refreshStatistic {
     NSMutableDictionary *parm = [NSMutableDictionary dictionary];
-    [parm setValue:@"refreshStatistics" forKey:@"api"];
-    NSMutableDictionary *content = [NSMutableDictionary dictionary];
-    [parm setValue:content forKey:@"content"];
+    [parm setValue:@"webViewOnResume" forKey:@"api"];
     [self postMessage:parm];
 }