Pārlūkot izejas kodu

粉丝群弹窗

Steven 10 mēneši atpakaļ
vecāks
revīzija
a2030b6978

+ 41 - 1
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/MinePage/Controller/MinePageViewController.m

@@ -20,6 +20,9 @@
 #import "MinePageVideoCourseView.h"
 #import "MinePageMusicView.h"
 #import "MinePageLiveCourseView.h"
+#import "MinePageGroupModel.h"
+#import "FansGroupAlertView.h"
+#import "KSGroupConversationController.h"
 
 #define HEADER_HEIGHT (50)
 
@@ -39,6 +42,8 @@
 
 @property (nonatomic, strong) BadgeIntroduceView *intruduceAlert;
 
+@property (nonatomic, strong) NSMutableArray *fansGroupArray;
+
 @end
 
 @implementation MinePageViewController
@@ -56,6 +61,25 @@
     [USER_MANAGER sendUMEvent:@"klx_minePage"];
 }
 
+- (void)requestTeacherGroup {
+    [KSNetworkingManager queryTeacherGroupRequest:KS_POST success:^(NSDictionary * _Nonnull dic) {
+        if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
+            NSArray *sourceArray = [dic ks_arrayValueForKey:@"data"];
+            NSMutableArray *groupArray = [NSMutableArray array];
+            for (NSDictionary *parm in sourceArray) {
+                MinePageGroupModel *model = [[MinePageGroupModel alloc] initWithDictionary:parm];
+                [groupArray addObject:model];
+            }
+            self.fansGroupArray = [NSMutableArray arrayWithArray:groupArray];
+        }
+        else {
+            [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
+        }
+        
+    } faliure:^(NSError * _Nonnull error) {
+        
+    }];
+}
 
 - (void)configUI {
     
@@ -131,6 +155,7 @@
     self.navigationController.interactivePopGestureRecognizer.enabled = YES;
     [self requestTeachMessage];
     [self requestSubjectList];
+    [self requestTeacherGroup];
     if (self.listViewArray.count > self.categoryView.selectedIndex) {
         id value = self.listViewArray[self.categoryView.selectedIndex];
         if ([value isKindOfClass:[KSJXBodyView class]]) {
@@ -388,8 +413,23 @@
 }
 
 - (void)showFansGroup {
-    
+    FansGroupAlertView *alert = [FansGroupAlertView sharedInstance];
+    [alert configWithSource:self.fansGroupArray];
+    [alert displayInView:self.view];
+    MJWeakSelf;
+    [alert groupChatConversation:^(NSString * _Nonnull imGroupId) {
+        [weakSelf chatAction:imGroupId];
+    }];
+}
+
+- (void)chatAction:(NSString *)imGroupId {
+    TUIChatConversationModel *model = [[TUIChatConversationModel alloc] init];
+    model.groupID = imGroupId;
+    KSGroupConversationController *ctrl = [[KSGroupConversationController alloc] init];
+    ctrl.conversation = model;
+    [self.navigationController pushViewController:ctrl animated:YES];
 }
+
 - (void)editAction {
     MyStyleViewController *style = [[MyStyleViewController alloc] init];
     [self.navigationController pushViewController:style animated:YES];

+ 3 - 0
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/MinePage/View/FansGroupAlert/FansGroupAlertCell.h

@@ -6,11 +6,14 @@
 //
 
 #import <UIKit/UIKit.h>
+#import "MinePageGroupModel.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
 @interface FansGroupAlertCell : UITableViewCell
 
+- (void)configWithSource:(MinePageGroupModel *)sourceModel;
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 19 - 1
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/MinePage/View/FansGroupAlert/FansGroupAlertCell.m

@@ -7,6 +7,16 @@
 
 #import "FansGroupAlertCell.h"
 
+@interface FansGroupAlertCell ()
+
+@property (weak, nonatomic) IBOutlet UIImageView *groupLogo;
+
+@property (weak, nonatomic) IBOutlet UILabel *groupName;
+
+@property (weak, nonatomic) IBOutlet UILabel *groupDesc;
+
+@end
+
 @implementation FansGroupAlertCell
 
 - (void)awakeFromNib {
@@ -15,7 +25,15 @@
     self.selectionStyle = UITableViewCellSelectionStyleNone;
 }
 
-
+- (void)configWithSource:(MinePageGroupModel *)sourceModel {
+    [self.groupLogo sd_setImageWithURL:[NSURL URLWithString:[sourceModel.img getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:GROUP_FAN_LOGO]];
+    self.groupName.text = [NSString returnNoNullStringWithString:sourceModel.name];
+    NSString *groupDesc = sourceModel.introduce;
+    if ([NSString isEmptyString:sourceModel.introduce]) {
+        groupDesc = @"暂无简介";
+    }
+    self.groupDesc.text = groupDesc;
+}
 
 - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
     [super setSelected:selected animated:animated];

+ 67 - 0
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/MinePage/View/FansGroupAlert/FansGroupAlertCell.xib

@@ -16,10 +16,77 @@
             <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
                 <rect key="frame" x="0.0" y="0.0" width="320" height="83"/>
                 <autoresizingMask key="autoresizingMask"/>
+                <subviews>
+                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="76n-GO-SJx">
+                        <rect key="frame" x="0.0" y="0.0" width="320" height="83"/>
+                        <subviews>
+                            <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="chat_fansGroup_logo" translatesAutoresizingMaskIntoConstraints="NO" id="cOU-Gd-KLn">
+                                <rect key="frame" x="20" y="20.666666666666671" width="42" height="42"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="42" id="GO6-9I-49O"/>
+                                    <constraint firstAttribute="width" constant="42" id="UbU-XM-x44"/>
+                                </constraints>
+                            </imageView>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="长笛群" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="u61-Cw-ZNy">
+                                <rect key="frame" x="72" y="21.666666666666671" width="211" height="21"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="21" id="uoW-G1-qle"/>
+                                </constraints>
+                                <fontDescription key="fontDescription" type="system" pointSize="15"/>
+                                <color key="textColor" red="0.10196078431372549" green="0.10196078431372549" blue="0.10196078431372549" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="setting_next" translatesAutoresizingMaskIntoConstraints="NO" id="WIW-Z6-7Kf">
+                                <rect key="frame" x="293" y="36" width="6" height="11"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="11" id="gr9-85-q6L"/>
+                                    <constraint firstAttribute="width" constant="6" id="q2R-yv-rq7"/>
+                                </constraints>
+                            </imageView>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="张老师长笛交流群" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9Qg-fN-QGW">
+                                <rect key="frame" x="72" y="45" width="211" height="17"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="17" id="hPL-vc-xSY"/>
+                                </constraints>
+                                <fontDescription key="fontDescription" type="system" pointSize="12"/>
+                                <color key="textColor" red="0.59999999999999998" green="0.59999999999999998" blue="0.59999999999999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                        </subviews>
+                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                        <constraints>
+                            <constraint firstItem="u61-Cw-ZNy" firstAttribute="leading" secondItem="cOU-Gd-KLn" secondAttribute="trailing" constant="10" id="FGn-kw-FXi"/>
+                            <constraint firstItem="9Qg-fN-QGW" firstAttribute="bottom" secondItem="cOU-Gd-KLn" secondAttribute="bottom" constant="-1" id="O3I-sa-7iJ"/>
+                            <constraint firstItem="cOU-Gd-KLn" firstAttribute="centerY" secondItem="76n-GO-SJx" secondAttribute="centerY" id="X5d-hf-hQb"/>
+                            <constraint firstItem="WIW-Z6-7Kf" firstAttribute="centerY" secondItem="76n-GO-SJx" secondAttribute="centerY" id="XHL-SD-xco"/>
+                            <constraint firstItem="u61-Cw-ZNy" firstAttribute="top" secondItem="cOU-Gd-KLn" secondAttribute="top" constant="1" id="b0j-bs-mKs"/>
+                            <constraint firstItem="WIW-Z6-7Kf" firstAttribute="leading" secondItem="9Qg-fN-QGW" secondAttribute="trailing" constant="10" id="cl8-cA-pNX"/>
+                            <constraint firstItem="cOU-Gd-KLn" firstAttribute="leading" secondItem="76n-GO-SJx" secondAttribute="leading" constant="20" id="e4v-ae-tFn"/>
+                            <constraint firstItem="9Qg-fN-QGW" firstAttribute="leading" secondItem="u61-Cw-ZNy" secondAttribute="leading" id="mW7-nW-7xE"/>
+                            <constraint firstAttribute="trailing" secondItem="WIW-Z6-7Kf" secondAttribute="trailing" constant="21" id="o4O-Bb-3DY"/>
+                            <constraint firstItem="WIW-Z6-7Kf" firstAttribute="leading" secondItem="u61-Cw-ZNy" secondAttribute="trailing" constant="10" id="ov2-kc-UrK"/>
+                        </constraints>
+                    </view>
+                </subviews>
+                <constraints>
+                    <constraint firstAttribute="trailing" secondItem="76n-GO-SJx" secondAttribute="trailing" id="6hE-Rl-Wxq"/>
+                    <constraint firstItem="76n-GO-SJx" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="La4-FW-6ag"/>
+                    <constraint firstItem="76n-GO-SJx" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="caU-el-hi7"/>
+                    <constraint firstAttribute="bottom" secondItem="76n-GO-SJx" secondAttribute="bottom" id="dei-xP-eEf"/>
+                </constraints>
             </tableViewCellContentView>
             <viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
             <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+            <connections>
+                <outlet property="groupDesc" destination="9Qg-fN-QGW" id="VBl-GQ-cV1"/>
+                <outlet property="groupLogo" destination="cOU-Gd-KLn" id="vJI-3X-j2g"/>
+                <outlet property="groupName" destination="u61-Cw-ZNy" id="UnG-bS-gWT"/>
+            </connections>
             <point key="canvasLocation" x="39.694656488549619" y="33.450704225352112"/>
         </tableViewCell>
     </objects>
+    <resources>
+        <image name="chat_fansGroup_logo" width="300" height="300"/>
+        <image name="setting_next" width="6" height="11"/>
+    </resources>
 </document>

+ 3 - 1
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/MinePage/View/FansGroupAlert/FansGroupAlertView.h

@@ -7,7 +7,7 @@
 
 #import <UIKit/UIKit.h>
 
-typedef void(^FansGroupChatCallback)(NSString *imGroupId);
+typedef void(^FansGroupChatCallback)(NSString * _Nonnull imGroupId);
 
 NS_ASSUME_NONNULL_BEGIN
 
@@ -17,6 +17,8 @@ NS_ASSUME_NONNULL_BEGIN
 
 - (void)configWithSource:(NSMutableArray *)fansGroupArray;
 
+- (void)displayInView:(UIView *)displayView;
+
 - (void)groupChatConversation:(FansGroupChatCallback)callback;
 
 @end

+ 67 - 1
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/MinePage/View/FansGroupAlert/FansGroupAlertView.m

@@ -6,16 +6,31 @@
 //
 
 #import "FansGroupAlertView.h"
+#import "FansGroupAlertCell.h"
+
+#define ROW_HEIGHT (62)
 
 @interface FansGroupAlertView ()<UITableViewDelegate, UITableViewDataSource>
 
+@property (weak, nonatomic) IBOutlet UIView *tableContainer;
+@property (weak, nonatomic) IBOutlet NSLayoutConstraint *tableHeight;
+
 @property (nonatomic, copy) FansGroupChatCallback callback;
 
 @property (nonatomic, copy) UITableView *tableView;
 
+@property (nonatomic, strong) NSMutableArray *dataArray;
+
 @end
 
 @implementation FansGroupAlertView
+- (void)awakeFromNib {
+    [super awakeFromNib];
+    [self.tableContainer addSubview:self.tableView];
+    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.right.top.bottom.mas_equalTo(self.tableContainer);
+    }];
+}
 
 + (instancetype)sharedInstance {
     FansGroupAlertView *view = [[[NSBundle mainBundle] loadNibNamed:@"FansGroupAlertView" owner:nil options:nil] firstObject];
@@ -24,6 +39,35 @@
 
 - (void)configWithSource:(NSMutableArray *)fansGroupArray {
     
+    if (fansGroupArray.count > 3) {
+        self.tableHeight.constant = ROW_HEIGHT * 3.5;
+    }
+    else {
+        self.tableHeight.constant = ROW_HEIGHT * fansGroupArray.count;
+    }
+    self.dataArray = [NSMutableArray arrayWithArray:fansGroupArray];
+    [self.tableView reloadData];
+}
+
+- (void)displayInView:(UIView *)displayView {
+    if (!displayView) {
+        displayView = [NSObject getKeyWindow];
+    }
+    if ([displayView.subviews containsObject:self]) {
+        return;
+    }
+    [displayView addSubview:self];
+    [self mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.right.top.bottom.mas_equalTo(displayView);
+    }];
+}
+
+- (IBAction)canceAction:(id)sender {
+    [self removeView];
+}
+
+- (void)removeView {
+    [self removeFromSuperview];
 }
 
 - (void)groupChatConversation:(FansGroupChatCallback)callback {
@@ -32,7 +76,27 @@
     }
 }
 
+#pragma mark ------ table data source
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    return self.dataArray.count;
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+    MinePageGroupModel *model = self.dataArray[indexPath.row];
+    FansGroupAlertCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FansGroupAlertCell"];
+    [cell configWithSource:model];
+    return cell;
+}
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+    MinePageGroupModel *model = self.dataArray[indexPath.row];
+    if (self.callback) {
+        self.callback(model.internalBaseClassIdentifier);
+        [self removeView];
+    }
+}
 
+#pragma mark --- lazying
 - (UITableView *)tableView {
     if (!_tableView) {
         if (!_tableView) {
@@ -42,8 +106,10 @@
             _tableView.dataSource = self;
             _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
             _tableView.rowHeight = 62.0f;
+            _tableView.showsVerticalScrollIndicator = NO;
+            _tableView.bounces = NO;
             // cell
-            [_tableView registerNib:[UINib nibWithNibName:@"DownloadStatusCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"DownloadStatusCell"];
+            [_tableView registerNib:[UINib nibWithNibName:@"FansGroupAlertCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"FansGroupAlertCell"];
         }
         return _tableView;
     }

+ 13 - 5
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/MinePage/View/FansGroupAlert/FansGroupAlertView.xib

@@ -4,7 +4,6 @@
     <dependencies>
         <deployment identifier="iOS"/>
         <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>
     <objects>
@@ -22,7 +21,7 @@
                         </imageView>
                         <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Yue-SE-dsU">
                             <rect key="frame" x="0.0" y="113" width="300" height="62"/>
-                            <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+                            <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                             <constraints>
                                 <constraint firstAttribute="height" constant="62" id="rff-qF-IJm"/>
                             </constraints>
@@ -41,6 +40,9 @@
                                 <constraint firstAttribute="width" constant="40" id="xRK-5e-qqV"/>
                             </constraints>
                             <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
+                            <connections>
+                                <action selector="canceAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="Ezb-fs-TCy"/>
+                            </connections>
                         </button>
                     </subviews>
                     <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
@@ -58,6 +60,11 @@
                         <constraint firstItem="DIk-4o-f6z" firstAttribute="top" secondItem="sqT-l2-2xZ" secondAttribute="top" id="iLk-H4-NuC"/>
                         <constraint firstAttribute="bottom" secondItem="Yue-SE-dsU" secondAttribute="bottom" id="sRl-Is-9HK"/>
                     </constraints>
+                    <userDefinedRuntimeAttributes>
+                        <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                            <real key="value" value="10"/>
+                        </userDefinedRuntimeAttribute>
+                    </userDefinedRuntimeAttributes>
                 </view>
             </subviews>
             <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.5" colorSpace="custom" customColorSpace="sRGB"/>
@@ -68,14 +75,15 @@
             <nil key="simulatedTopBarMetrics"/>
             <nil key="simulatedBottomBarMetrics"/>
             <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
+            <connections>
+                <outlet property="tableContainer" destination="Yue-SE-dsU" id="O2o-dC-Fh8"/>
+                <outlet property="tableHeight" destination="rff-qF-IJm" id="AKK-bE-SD1"/>
+            </connections>
             <point key="canvasLocation" x="55.725190839694655" y="19.718309859154932"/>
         </view>
     </objects>
     <resources>
         <image name="cancle_button" width="20" height="20"/>
         <image name="fansGroup_alert_top" width="300" height="113"/>
-        <systemColor name="systemBackgroundColor">
-            <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-        </systemColor>
     </resources>
 </document>

+ 4 - 4
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/MinePage/View/HeadView/MinePageTopView.m

@@ -227,15 +227,15 @@
     }];
 }
 
-- (IBAction)topCallback:(id)sender {
+- (IBAction)showStyleback:(id)sender {
     if (self.callback) {
-        self.callback(YES);
+        self.callback(MINEPAGE_TOP_STYLEVIDEO);
     }
 }
 
-- (IBAction)editAction:(id)sender {
+- (IBAction)showFansGroup:(id)sender {
     if (self.callback) {
-        self.callback(NO);
+        self.callback(MINEPAGE_TOP_FANSGROUP);
     }
 }
 

+ 6 - 0
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/MinePage/View/HeadView/MinePageTopView.xib

@@ -127,6 +127,9 @@
                                         <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="BC8-rm-1MC">
                                             <rect key="frame" x="0.0" y="0.0" width="167.5" height="36"/>
                                             <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
+                                            <connections>
+                                                <action selector="showStyleback:" destination="iN0-l3-epB" eventType="touchUpInside" id="APh-XI-XNY"/>
+                                            </connections>
                                         </button>
                                     </subviews>
                                     <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
@@ -175,6 +178,9 @@
                                         <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8yh-P7-C7q">
                                             <rect key="frame" x="0.0" y="0.0" width="167.5" height="36"/>
                                             <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
+                                            <connections>
+                                                <action selector="showFansGroup:" destination="iN0-l3-epB" eventType="touchUpInside" id="pnR-kg-8ih"/>
+                                            </connections>
                                         </button>
                                     </subviews>
                                     <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>