Browse Source

新增客服入口

Steven 7 months ago
parent
commit
90d23e3a1a
16 changed files with 338 additions and 22 deletions
  1. 22 0
      KulexiuForStudent/KulexiuForStudent/Assets.xcassets/Institution/Mine/insititution_customService.imageset/Contents.json
  2. BIN
      KulexiuForStudent/KulexiuForStudent/Assets.xcassets/Institution/Mine/insititution_customService.imageset/insititution_customService@2x.png
  3. BIN
      KulexiuForStudent/KulexiuForStudent/Assets.xcassets/Institution/Mine/insititution_customService.imageset/insititution_customService@3x.png
  4. 9 0
      KulexiuForStudent/KulexiuForStudent/Common/Base/KSNetworkingManager.h
  5. 13 0
      KulexiuForStudent/KulexiuForStudent/Common/Base/KSNetworkingManager.m
  6. 47 0
      KulexiuForStudent/KulexiuForStudent/InstitutionModule/Mine/Controller/InsititutionMineViewController.m
  7. 3 0
      KulexiuForStudent/KulexiuForStudent/InstitutionModule/Mine/View/InstitutionMineBodyView.h
  8. 19 1
      KulexiuForStudent/KulexiuForStudent/InstitutionModule/Mine/View/InstitutionMineBodyView.m
  9. 56 3
      KulexiuForStudent/KulexiuForStudent/InstitutionModule/Mine/View/InstitutionMineBodyView.xib
  10. 2 0
      KulexiuForStudent/KulexiuForStudent/Module/Login/Model/UserInfo.h
  11. 14 0
      KulexiuForStudent/KulexiuForStudent/Module/Login/Model/UserInfo.m
  12. 70 8
      KulexiuForStudent/KulexiuForStudent/Module/Mine/Controller/MineViewController.m
  13. 3 0
      KulexiuForStudent/KulexiuForStudent/Module/Mine/View/MineBodyView.h
  14. 17 1
      KulexiuForStudent/KulexiuForStudent/Module/Mine/View/MineBodyView.m
  15. 61 7
      KulexiuForStudent/KulexiuForStudent/Module/Mine/View/MineBodyView.xib
  16. 2 2
      KulexiuForStudent/KulexiuForStudent/Module/Mine/Works/View/MineWorksBodyView.m

+ 22 - 0
KulexiuForStudent/KulexiuForStudent/Assets.xcassets/Institution/Mine/insititution_customService.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "insititution_customService@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "filename" : "insititution_customService@3x.png",
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
KulexiuForStudent/KulexiuForStudent/Assets.xcassets/Institution/Mine/insititution_customService.imageset/insititution_customService@2x.png


BIN
KulexiuForStudent/KulexiuForStudent/Assets.xcassets/Institution/Mine/insititution_customService.imageset/insititution_customService@3x.png


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

@@ -1027,6 +1027,15 @@ NS_ASSUME_NONNULL_BEGIN
 /// @param success 成功
 /// @param faliure 失败
 + (void)sysExceptionLogUpdate:(NSString *)post token:(NSString *)access_token logArray:(NSMutableArray *)logArray success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure;
+
+// 客服相关
+// GET /api-student/student/updateUserCustomerService
+
+/// 查询客服ID
+/// @param get get
+/// @param success 成功
+/// @param faliure 失败
++ (void)updateUserCustomerServiceRequest:(NSString *)get success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure;
 @end
 
 NS_ASSUME_NONNULL_END

+ 13 - 0
KulexiuForStudent/KulexiuForStudent/Common/Base/KSNetworkingManager.m

@@ -1966,4 +1966,17 @@
     NSString *url = [NSString stringWithFormat:@"%@%@%@", hostURL,@"/api-auth", @"/sysExceptionLog/save"];
     [self request:post andWithUrl:url and:logArray success:success faliure:faliure];
 }
+
+// 客服相关
+// GET /api-student/student/updateUserCustomerService
+
+/// 查询客服ID
+/// @param get get
+/// @param success 成功
+/// @param faliure 失败
++ (void)updateUserCustomerServiceRequest:(NSString *)get success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
+    NSString *url = [NSString stringWithFormat:@"%@%@", hostURL, @"/api-student/student/updateUserCustomerService"];
+    NSMutableDictionary *parm = [NSMutableDictionary dictionary];
+    [self request:get andWithUrl:url and:parm success:success faliure:faliure];
+}
 @end

+ 47 - 0
KulexiuForStudent/KulexiuForStudent/InstitutionModule/Mine/Controller/InsititutionMineViewController.m

@@ -15,6 +15,7 @@
 #import "FeedbackViewController.h"
 #import "TenantNotiferCenterController.h"
 #import "MineWorksViewController.h"
+#import "KSChatConversationViewController.h"
 
 @interface InsititutionMineViewController ()<UIScrollViewDelegate>
 
@@ -114,6 +115,7 @@
         
     }];
 }
+
 - (void)requsetUserMessage {
     [KSNetworkingManager queryStudentInfoRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
         if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
@@ -129,6 +131,13 @@
 }
 
 - (void)refreshView {
+    self.bodyView.hasCustomService = self.mineInfo.customerServiceNum > 0 ? YES : NO;
+    CGFloat contentMinHeight = [_bodyView getViewHeight];
+    CGFloat contentHeight = KPortraitHeight - kTabBarHeight;
+    CGFloat viewHeight = contentMinHeight > contentHeight ? contentMinHeight : contentHeight;
+    [self.bodyView mas_updateConstraints:^(MASConstraintMaker *make) {
+        make.height.mas_equalTo(viewHeight);
+    }];
     [self.bodyView configWithSource:self.mineInfo];
 }
 
@@ -222,11 +231,49 @@
             [self.navigationController pushViewController:ctrl animated:YES];
         }
             break;
+        case INSMINETYPE_CUSTOMSERVICE:
+        {
+            if (self.bodyView.hasCustomService) {
+                if ([NSString isEmptyString:self.mineInfo.imCustomerId]) {
+                    [self queryCustomService];
+                }
+                else {
+                    [self chatWithCustomService:self.mineInfo.imCustomerId];
+                }
+            }
+        }
+            break;
         default:
             break;
     }
 }
 
+- (void)queryCustomService {
+    [KSNetworkingManager updateUserCustomerServiceRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
+        if ([dic ks_integerValueForKey:@"code"] == 200) {
+            NSString *imCustomerId = [dic ks_stringValueForKey:@"data"];
+            if (![NSString isEmptyString:imCustomerId]) {
+                [self chatWithCustomService:imCustomerId];
+            }
+            else {
+                [LOADING_MANAGER MBShowAUTOHidingInWindow:@"未找到分配客服"];
+            }
+        }
+        else {
+            [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
+        }
+    } faliure:^(NSError * _Nonnull error) {
+        
+    }];
+}
+
+- (void)chatWithCustomService:(NSString *)imUserId {
+    TUIChatConversationModel *model = [[TUIChatConversationModel alloc] init];
+    model.userID = imUserId;
+    KSChatConversationViewController *ctrl = [[KSChatConversationViewController alloc] init];
+    ctrl.conversation = model;
+    [self.navigationController pushViewController:ctrl animated:YES];
+}
 #pragma mark --- lazying
 - (InstitutionMineNavView *)navView {
     if (!_navView) {

+ 3 - 0
KulexiuForStudent/KulexiuForStudent/InstitutionModule/Mine/View/InstitutionMineBodyView.h

@@ -22,6 +22,7 @@ typedef NS_ENUM(NSInteger, INSMINETYPE) {
     INSMINETYPE_PRIVACY,
     INSMINETYPE_ABOUT,
     INSMINETYPE_WORKS, // 我的作品
+    INSMINETYPE_CUSTOMSERVICE, // 客服
 };
 
 typedef void(^INSMineViewCallback)(INSMINETYPE type);
@@ -30,6 +31,8 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface InstitutionMineBodyView : UIView
 
+@property (nonatomic, assign) BOOL hasCustomService;
+
 + (instancetype)shareInstance;
 
 - (void)configWithSource:(UserInfo *)sourceModel;

+ 19 - 1
KulexiuForStudent/KulexiuForStudent/InstitutionModule/Mine/View/InstitutionMineBodyView.m

@@ -51,6 +51,10 @@
 
 @property (nonatomic, strong) NSMutableArray *tagArray;
 
+@property (weak, nonatomic) IBOutlet UIView *customServiceView;
+@property (weak, nonatomic) IBOutlet NSLayoutConstraint *customServiceHeight;
+@property (weak, nonatomic) IBOutlet UIView *bottomLine;
+
 @end
 
 @implementation InstitutionMineBodyView
@@ -203,8 +207,22 @@
 }
 */
 
+- (void)setHasCustomService:(BOOL)hasCustomService {
+    _hasCustomService = hasCustomService;
+    if (hasCustomService) {
+        self.customServiceView.hidden = NO;
+        self.customServiceHeight.constant  = 58.0f;
+        self.bottomLine.hidden = NO;
+    }
+    else {
+        self.customServiceView.hidden = YES;
+        self.customServiceHeight.constant  = 0.0f;
+        self.bottomLine.hidden = YES;
+    }
+}
+
 - (CGFloat)getViewHeight {
-    return 275 + 12 + 130 + 12 + 58 * 5;
+    return 275 + 12 + 130 + 12 + 58 * 5 + self.customServiceHeight.constant;
 }
 
 - (TYPageControl *)pageControl {

+ 56 - 3
KulexiuForStudent/KulexiuForStudent/InstitutionModule/Mine/View/InstitutionMineBodyView.xib

@@ -238,7 +238,7 @@
                     </userDefinedRuntimeAttributes>
                 </view>
                 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3KY-c7-2Hr">
-                    <rect key="frame" x="13" y="415.66666666666674" width="388" height="290"/>
+                    <rect key="frame" x="13" y="415.66666666666674" width="388" height="348"/>
                     <subviews>
                         <view tag="1008" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="YoI-Ul-U7N">
                             <rect key="frame" x="0.0" y="0.0" width="388" height="58"/>
@@ -419,7 +419,7 @@
                                 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="insititution_about" translatesAutoresizingMaskIntoConstraints="NO" id="VLa-B4-4Ht">
                                     <rect key="frame" x="20" y="18" width="22" height="22"/>
                                 </imageView>
-                                <view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dSf-QJ-hbD">
+                                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dSf-QJ-hbD">
                                     <rect key="frame" x="15" y="57" width="358" height="1"/>
                                     <color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                     <constraints>
@@ -445,13 +445,55 @@
                                 <outletCollection property="gestureRecognizers" destination="Oaj-2g-IyL" appends="YES" id="pAe-cm-4vC"/>
                             </connections>
                         </view>
+                        <view tag="1014" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="d2M-k7-crG">
+                            <rect key="frame" x="0.0" y="289.99999999999994" width="388" height="58"/>
+                            <subviews>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="在线客服" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Uzi-OH-vgU">
+                                    <rect key="frame" x="51.999999999999993" y="19.333333333333371" width="65.333333333333314" height="19"/>
+                                    <fontDescription key="fontDescription" type="system" pointSize="16"/>
+                                    <color key="textColor" red="0.1019607843" green="0.1019607843" blue="0.1019607843" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                    <nil key="highlightedColor"/>
+                                </label>
+                                <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="mine_next" translatesAutoresizingMaskIntoConstraints="NO" id="SPg-W7-Ne1">
+                                    <rect key="frame" x="367" y="21.333333333333371" width="8" height="15"/>
+                                </imageView>
+                                <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="insititution_customService" translatesAutoresizingMaskIntoConstraints="NO" id="8Xk-GG-r3b">
+                                    <rect key="frame" x="20" y="18" width="22" height="22"/>
+                                </imageView>
+                                <view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="4Ow-9F-SGT">
+                                    <rect key="frame" x="15" y="57" width="358" height="1"/>
+                                    <color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="1" id="UwA-HV-elJ"/>
+                                    </constraints>
+                                </view>
+                            </subviews>
+                            <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                            <gestureRecognizers/>
+                            <constraints>
+                                <constraint firstAttribute="trailing" secondItem="4Ow-9F-SGT" secondAttribute="trailing" constant="15" id="5kS-SI-4bx"/>
+                                <constraint firstItem="SPg-W7-Ne1" firstAttribute="centerY" secondItem="d2M-k7-crG" secondAttribute="centerY" id="6bb-x2-SSQ"/>
+                                <constraint firstAttribute="trailing" secondItem="SPg-W7-Ne1" secondAttribute="trailing" constant="13" id="Grf-LV-Mkh"/>
+                                <constraint firstItem="4Ow-9F-SGT" firstAttribute="leading" secondItem="d2M-k7-crG" secondAttribute="leading" constant="15" id="OW6-Dg-Mja"/>
+                                <constraint firstItem="8Xk-GG-r3b" firstAttribute="centerY" secondItem="d2M-k7-crG" secondAttribute="centerY" id="W96-OE-HMV"/>
+                                <constraint firstItem="Uzi-OH-vgU" firstAttribute="leading" secondItem="8Xk-GG-r3b" secondAttribute="trailing" constant="10" id="e5n-ch-jj4"/>
+                                <constraint firstItem="8Xk-GG-r3b" firstAttribute="leading" secondItem="d2M-k7-crG" secondAttribute="leading" constant="20" id="ejN-5U-Tcw"/>
+                                <constraint firstItem="Uzi-OH-vgU" firstAttribute="centerY" secondItem="d2M-k7-crG" secondAttribute="centerY" id="koo-RP-WZn"/>
+                                <constraint firstAttribute="height" constant="58" id="lJB-vz-5Ci"/>
+                                <constraint firstAttribute="bottom" secondItem="4Ow-9F-SGT" secondAttribute="bottom" id="oO7-Du-0kT"/>
+                            </constraints>
+                            <connections>
+                                <outletCollection property="gestureRecognizers" destination="mCC-K1-cUV" appends="YES" id="Ohm-P8-QYx"/>
+                            </connections>
+                        </view>
                     </subviews>
                     <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                     <constraints>
                         <constraint firstAttribute="trailing" secondItem="NTm-jn-Mpl" secondAttribute="trailing" id="6g2-dR-DfN"/>
-                        <constraint firstAttribute="bottom" secondItem="wt3-dk-1gA" secondAttribute="bottom" id="85N-38-2lA"/>
+                        <constraint firstAttribute="bottom" secondItem="d2M-k7-crG" secondAttribute="bottom" id="FyT-fU-fm3"/>
                         <constraint firstItem="92r-es-QMt" firstAttribute="top" secondItem="LNk-Hh-S11" secondAttribute="bottom" id="Gfx-mY-GWj"/>
                         <constraint firstItem="LNk-Hh-S11" firstAttribute="top" secondItem="YoI-Ul-U7N" secondAttribute="bottom" id="J3t-dd-vPq"/>
+                        <constraint firstAttribute="trailing" secondItem="d2M-k7-crG" secondAttribute="trailing" id="QPo-cq-OwW"/>
                         <constraint firstItem="NTm-jn-Mpl" firstAttribute="top" secondItem="92r-es-QMt" secondAttribute="bottom" id="SMW-Bs-YSm"/>
                         <constraint firstItem="wt3-dk-1gA" firstAttribute="leading" secondItem="3KY-c7-2Hr" secondAttribute="leading" id="a7e-Tg-kqF"/>
                         <constraint firstItem="YoI-Ul-U7N" firstAttribute="leading" secondItem="3KY-c7-2Hr" secondAttribute="leading" id="aE9-l9-b7R"/>
@@ -459,8 +501,10 @@
                         <constraint firstItem="92r-es-QMt" firstAttribute="leading" secondItem="3KY-c7-2Hr" secondAttribute="leading" id="blE-GG-GwB"/>
                         <constraint firstAttribute="trailing" secondItem="92r-es-QMt" secondAttribute="trailing" id="c4k-Mu-QAe"/>
                         <constraint firstItem="wt3-dk-1gA" firstAttribute="top" secondItem="NTm-jn-Mpl" secondAttribute="bottom" id="dFa-nZ-n5m"/>
+                        <constraint firstItem="d2M-k7-crG" firstAttribute="leading" secondItem="3KY-c7-2Hr" secondAttribute="leading" id="fdg-PE-bAw"/>
                         <constraint firstAttribute="trailing" secondItem="YoI-Ul-U7N" secondAttribute="trailing" id="iqW-ly-CSP"/>
                         <constraint firstItem="NTm-jn-Mpl" firstAttribute="leading" secondItem="3KY-c7-2Hr" secondAttribute="leading" id="n0b-ku-Neh"/>
+                        <constraint firstItem="d2M-k7-crG" firstAttribute="top" secondItem="wt3-dk-1gA" secondAttribute="bottom" id="pga-ca-SKv"/>
                         <constraint firstItem="YoI-Ul-U7N" firstAttribute="top" secondItem="3KY-c7-2Hr" secondAttribute="top" id="pjH-ZG-qdS"/>
                         <constraint firstAttribute="trailing" secondItem="wt3-dk-1gA" secondAttribute="trailing" id="rfa-OY-G8V"/>
                         <constraint firstItem="LNk-Hh-S11" firstAttribute="leading" secondItem="3KY-c7-2Hr" secondAttribute="leading" id="yG2-Ys-ASl"/>
@@ -491,6 +535,9 @@
                 <outlet property="bgImageHeight" destination="NsE-ha-gB2" id="tgE-6b-AmN"/>
                 <outlet property="bgImageView" destination="A30-6f-0Ca" id="AA9-Qa-ipk"/>
                 <outlet property="bgImageWidth" destination="HAe-7J-lwa" id="CWe-6R-yNH"/>
+                <outlet property="bottomLine" destination="dSf-QJ-hbD" id="Xjs-T3-Sgq"/>
+                <outlet property="customServiceHeight" destination="lJB-vz-5Ci" id="9Jk-mI-ORQ"/>
+                <outlet property="customServiceView" destination="d2M-k7-crG" id="lye-nL-GbD"/>
                 <outlet property="functionView" destination="Akl-gJ-5NJ" id="aPS-KN-edW"/>
                 <outlet property="memberImg" destination="j1E-FX-DSh" id="Qcd-Se-bsQ"/>
                 <outlet property="subjectLabel" destination="k3g-g1-liB" id="4om-GC-86Z"/>
@@ -563,10 +610,16 @@
                 <action selector="clickAction:" destination="iN0-l3-epB" id="NxX-ur-UXR"/>
             </connections>
         </tapGestureRecognizer>
+        <tapGestureRecognizer id="mCC-K1-cUV">
+            <connections>
+                <action selector="clickAction:" destination="iN0-l3-epB" id="wM0-2n-fR5"/>
+            </connections>
+        </tapGestureRecognizer>
     </objects>
     <resources>
         <image name="insititution_MineBg" width="375" height="375"/>
         <image name="insititution_about" width="22" height="22"/>
+        <image name="insititution_customService" width="22" height="22"/>
         <image name="insititution_feedback" width="22" height="22"/>
         <image name="insititution_help" width="22" height="22"/>
         <image name="insititution_mine_header" width="58" height="50"/>

+ 2 - 0
KulexiuForStudent/KulexiuForStudent/Module/Login/Model/UserInfo.h

@@ -57,6 +57,8 @@
 @property (nonatomic, strong) NSString *tenantGroupName;
 @property (nonatomic, strong) UserVip *userVip;
 
+@property (nonatomic, assign) NSInteger customerServiceNum; // 客服数量
+@property (nonatomic, strong) NSString *imCustomerId; // 客服
 
 + (instancetype)modelObjectWithDictionary:(NSDictionary *)dict;
 - (instancetype)initWithDictionary:(NSDictionary *)dict;

+ 14 - 0
KulexiuForStudent/KulexiuForStudent/Module/Login/Model/UserInfo.m

@@ -53,6 +53,8 @@ NSString *const kUserInfoLockFlag = @"lockFlag";
 NSString *const kUserInfoTenantGroupName = @"tenantGroupName";
 NSString *const kUserInfoUserVip = @"userVip";
 
+NSString *const kUserInfoUserCustomerServiceNum = @"customerServiceNum";
+NSString *const kUserInfoUserImCustomerId = @"imCustomerId";
 
 @interface UserInfo ()
 
@@ -106,6 +108,8 @@ NSString *const kUserInfoUserVip = @"userVip";
 @synthesize lockFlag = _lockFlag;
 @synthesize tenantGroupName = _tenantGroupName;
 @synthesize userVip = _userVip;
+@synthesize customerServiceNum = _customerServiceNum;
+@synthesize imCustomerId = _imCustomerId;
 
 + (instancetype)modelObjectWithDictionary:(NSDictionary *)dict
 {
@@ -163,6 +167,8 @@ NSString *const kUserInfoUserVip = @"userVip";
             self.lockFlag = [[self objectOrNilForKey:kUserInfoLockFlag fromDictionary:dict] doubleValue];
         self.tenantGroupName = [self objectOrNilForKey:kUserInfoTenantGroupName fromDictionary:dict];
         self.userVip = [UserVip modelObjectWithDictionary:[dict objectForKey:kUserInfoUserVip]];
+        self.customerServiceNum = [[self objectOrNilForKey:kUserInfoUserCustomerServiceNum fromDictionary:dict] integerValue];
+        self.imCustomerId = [self objectOrNilForKey:kUserInfoUserImCustomerId fromDictionary:dict];
 
     }
     
@@ -217,6 +223,8 @@ NSString *const kUserInfoUserVip = @"userVip";
     [mutableDict setValue:[NSNumber numberWithDouble:self.lockFlag] forKey:kUserInfoLockFlag];
     [mutableDict setValue:self.tenantGroupName forKey:kUserInfoTenantGroupName];
     [mutableDict setValue:[self.userVip dictionaryRepresentation] forKey:kUserInfoUserVip];
+    [mutableDict setValue:[NSNumber numberWithInteger:self.customerServiceNum] forKey:kUserInfoUserCustomerServiceNum];
+    [mutableDict setValue:self.imCustomerId forKey:kUserInfoUserImCustomerId];
     return [NSDictionary dictionaryWithDictionary:mutableDict];
 }
 
@@ -287,6 +295,8 @@ NSString *const kUserInfoUserVip = @"userVip";
     self.lockFlag = [aDecoder decodeDoubleForKey:kUserInfoLockFlag];
     self.tenantGroupName = [aDecoder decodeObjectForKey:kUserInfoTenantGroupName];
     self.userVip = [aDecoder decodeObjectForKey:kUserInfoUserVip];
+    self.customerServiceNum = [aDecoder decodeIntegerForKey:kUserInfoUserCustomerServiceNum];
+    self.imCustomerId = [aDecoder decodeObjectForKey:kUserInfoUserImCustomerId];
     return self;
 }
 
@@ -337,6 +347,8 @@ NSString *const kUserInfoUserVip = @"userVip";
     [aCoder encodeDouble:_lockFlag forKey:kUserInfoLockFlag];
     [aCoder encodeObject:_tenantGroupName forKey:kUserInfoTenantGroupName];
     [aCoder encodeObject:_userVip forKey:kUserInfoUserVip];
+    [aCoder encodeInteger:_customerServiceNum forKey:kUserInfoUserCustomerServiceNum];
+    [aCoder encodeObject:_imCustomerId forKey:kUserInfoUserImCustomerId];
 }
 
 - (id)copyWithZone:(NSZone *)zone
@@ -389,6 +401,8 @@ NSString *const kUserInfoUserVip = @"userVip";
         copy.lockFlag = self.lockFlag;
         copy.tenantGroupName = [self.tenantGroupName copyWithZone:zone];
         copy.userVip = [self.userVip copyWithZone:zone];
+        copy.customerServiceNum = self.customerServiceNum;
+        copy.imCustomerId = [self.imCustomerId copyWithZone:zone];
     }
     
     return copy;

+ 70 - 8
KulexiuForStudent/KulexiuForStudent/Module/Mine/Controller/MineViewController.m

@@ -24,6 +24,7 @@
 #import "FeedbackViewController.h"
 #import "UserInfoManager.h"
 #import "MineWorksViewController.h"
+#import "KSChatConversationViewController.h"
 
 @interface MineViewController ()<UIScrollViewDelegate>
 
@@ -35,6 +36,9 @@
 
 @property (nonatomic, strong) UserInfo *mineInfo;
 
+@property (nonatomic, strong) dispatch_group_t requestGroup;
+
+
 @end
 
 @implementation MineViewController
@@ -103,34 +107,48 @@
 - (void)viewWillAppear:(BOOL)animated {
     [super viewWillAppear:animated];
     if ([self checkIsLoginToLoginView:YES]) {
-        [self requsetUserMessage];
-        [self requestUserMemo];
+        [self requestData];
     }
 }
 
+- (void)requestData {
+    [LOADING_MANAGER showHUD];
+    [self requsetUserMessage];
+    [self requestUserMemo];
+    
+    dispatch_group_notify(self.requestGroup, dispatch_get_main_queue(), ^{
+        [LOADING_MANAGER removeHUD];
+        [self refreshView];
+    });
+}
+
 - (void)requsetUserMessage {
+    dispatch_group_enter(self.requestGroup);
     [USER_MANAGER queryUserInfoCallback:^(UserInfo * _Nonnull userInfo) {
         self.mineInfo = userInfo;
-        [self refreshView];
+        dispatch_group_leave(self.requestGroup);
     }];
 }
 
 - (void)requestUserMemo {
+    dispatch_group_enter(self.requestGroup);
     [[UserInfoManager shareInstance] requsetconfigCallback:^(BOOL success) {
         [self refreshBodyView:success];
+        dispatch_group_leave(self.requestGroup);
     }];
 }
 
 - (void)refreshBodyView:(BOOL)isMember {
     self.bodyView.isMember = isMember;
-    CGFloat contentMinHeight = [_bodyView getViewHeight];
-    [self.bodyView mas_updateConstraints:^(MASConstraintMaker *make) {
-        make.height.mas_equalTo(contentMinHeight);
-    }];
 }
 
 - (void)refreshView {
     [self.bodyView configWithSource:self.mineInfo];
+    self.bodyView.hasCustomService = self.mineInfo.customerServiceNum > 0 ? YES : NO;
+    CGFloat contentMinHeight = [_bodyView getViewHeight];
+    [self.bodyView mas_updateConstraints:^(MASConstraintMaker *make) {
+        make.height.mas_equalTo(contentMinHeight);
+    }];
 }
 
 - (void)operationAction:(MINEVIEWTYPE)type {
@@ -259,13 +277,57 @@
             [self.navigationController pushViewController:ctrl animated:YES];
         }
             break;
+        case MINEVIEWTAG_CUSTOMSERVICE:
+        {
+            if (self.bodyView.hasCustomService) {
+                if ([NSString isEmptyString:self.mineInfo.imCustomerId]) {
+                    [self queryCustomService];
+                }
+                else {
+                    [self chatWithCustomService:self.mineInfo.imCustomerId];
+                }
+            }
+        }
+            break;
         default:
             break;
     }
 }
 
-#pragma mark --- lazying
+- (void)queryCustomService {
+    [KSNetworkingManager updateUserCustomerServiceRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
+        if ([dic ks_integerValueForKey:@"code"] == 200) {
+            NSString *imCustomerId = [dic ks_stringValueForKey:@"data"];
+            if (![NSString isEmptyString:imCustomerId]) {
+                [self chatWithCustomService:imCustomerId];
+            }
+            else {
+                [LOADING_MANAGER MBShowAUTOHidingInWindow:@"未找到分配客服"];
+            }
+        }
+        else {
+            [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
+        }
+    } faliure:^(NSError * _Nonnull error) {
+        
+    }];
+}
+
+- (void)chatWithCustomService:(NSString *)imUserId {
+    TUIChatConversationModel *model = [[TUIChatConversationModel alloc] init];
+    model.userID = imUserId;
+    KSChatConversationViewController *ctrl = [[KSChatConversationViewController alloc] init];
+    ctrl.conversation = model;
+    [self.navigationController pushViewController:ctrl animated:YES];
+}
 
+#pragma mark --- lazying
+- (dispatch_group_t)requestGroup {
+    if (!_requestGroup) {
+        _requestGroup = dispatch_group_create();
+    }
+    return _requestGroup;
+}
 - (MineNavView *)navView {
     if (!_navView) {
         _navView = [MineNavView shareInstance];

+ 3 - 0
KulexiuForStudent/KulexiuForStudent/Module/Mine/View/MineBodyView.h

@@ -28,6 +28,7 @@ typedef NS_ENUM(NSInteger, MINEVIEWTYPE) {
     MINEVIEWTYPE_CONTACT = 1017, // 联系我们
     MINEVIEWTYPE_AWARD,   // 活动奖品
     MINEVIEWTAG_WORKS,    // 我的作品
+    MINEVIEWTAG_CUSTOMSERVICE = 1020, // 客服
 };
 typedef void(^MineViewCallback)(MINEVIEWTYPE type);
 
@@ -37,6 +38,8 @@ NS_ASSUME_NONNULL_BEGIN
 
 @property (nonatomic, assign) BOOL isMember;
 
+@property (nonatomic, assign) BOOL hasCustomService;
+
 + (instancetype)shareInstance;
 
 - (void)configWithSource:(UserInfo *)sourceModel;

+ 17 - 1
KulexiuForStudent/KulexiuForStudent/Module/Mine/View/MineBodyView.m

@@ -47,6 +47,9 @@
 @property (weak, nonatomic) IBOutlet UIImageView *memberLogoTag;
 @property (weak, nonatomic) IBOutlet NSLayoutConstraint *memberDescLeft;
 
+@property (weak, nonatomic) IBOutlet UIView *costomserviceView;
+@property (weak, nonatomic) IBOutlet NSLayoutConstraint *costomserviceViewHeight;
+
 @property (nonatomic, strong) UIImage *preDisplayImage;
 
 @end
@@ -221,7 +224,7 @@
 }
 
 - (CGFloat)getViewHeight {
-    return 80 + 15 + (self.memberViewHeight.constant) / 2 + 5 + 80 + 12 + (136 + 12) * 3 + (192 + 12);
+    return 80 + 15 + (self.memberViewHeight.constant) / 2 + 5 + 80 + 12 + (136 + 12) * 3 + (192 + 12) + self.costomserviceViewHeight.constant;
 }
 
 - (IBAction)modifyUser:(id)sender {
@@ -248,6 +251,19 @@
     }
 }
 
+
+- (void)setHasCustomService:(BOOL)hasCustomService {
+    _hasCustomService = hasCustomService;
+    if (hasCustomService) {
+        self.costomserviceView.hidden = NO;
+        self.costomserviceViewHeight.constant = 50.0f;
+    }
+    else {
+        self.costomserviceView.hidden = YES;
+        self.costomserviceViewHeight.constant = 0.0f;
+    }
+}
+
 /*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.

+ 61 - 7
KulexiuForStudent/KulexiuForStudent/Module/Mine/View/MineBodyView.xib

@@ -554,7 +554,10 @@
                             <rect key="frame" x="0.0" y="15" width="390" height="50"/>
                             <subviews>
                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="网络检测" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WVn-qJ-z6F">
-                                    <rect key="frame" x="15" y="15.5" width="65.5" height="19.5"/>
+                                    <rect key="frame" x="15" y="14" width="65.5" height="22"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="22" id="uCy-LY-6gU"/>
+                                    </constraints>
                                     <fontDescription key="fontDescription" type="system" pointSize="16"/>
                                     <color key="textColor" red="0.1019607843" green="0.1019607843" blue="0.1019607843" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                     <nil key="highlightedColor"/>
@@ -580,7 +583,10 @@
                             <rect key="frame" x="0.0" y="71" width="390" height="50"/>
                             <subviews>
                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="设备检测" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iBg-aO-J2p">
-                                    <rect key="frame" x="15" y="15.5" width="65.5" height="19.5"/>
+                                    <rect key="frame" x="15" y="14" width="65.5" height="22"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="22" id="pib-hp-4gO"/>
+                                    </constraints>
                                     <fontDescription key="fontDescription" type="system" pointSize="16"/>
                                     <color key="textColor" red="0.1019607843" green="0.1019607843" blue="0.1019607843" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                     <nil key="highlightedColor"/>
@@ -801,13 +807,16 @@
                     </userDefinedRuntimeAttributes>
                 </view>
                 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="qXK-bw-j5E">
-                    <rect key="frame" x="14" y="676" width="386" height="192"/>
+                    <rect key="frame" x="14" y="676" width="386" height="242"/>
                     <subviews>
                         <view tag="1010" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="iFf-ti-ghK">
                             <rect key="frame" x="0.0" y="15" width="386" height="50"/>
                             <subviews>
                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="帮助中心" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2MM-pc-66O">
-                                    <rect key="frame" x="15" y="15.5" width="65.5" height="19.5"/>
+                                    <rect key="frame" x="15" y="14" width="65.5" height="22"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="22" id="ic0-Kn-p6N"/>
+                                    </constraints>
                                     <fontDescription key="fontDescription" type="system" pointSize="16"/>
                                     <color key="textColor" red="0.1019607843" green="0.1019607843" blue="0.1019607843" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                     <nil key="highlightedColor"/>
@@ -833,7 +842,10 @@
                             <rect key="frame" x="0.0" y="71" width="386" height="50"/>
                             <subviews>
                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="意见反馈" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2Lb-1M-OO7">
-                                    <rect key="frame" x="15" y="15.5" width="65.5" height="19.5"/>
+                                    <rect key="frame" x="15" y="14" width="65.5" height="22"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="22" id="7np-2u-rkH"/>
+                                    </constraints>
                                     <fontDescription key="fontDescription" type="system" pointSize="16"/>
                                     <color key="textColor" red="0.1019607843" green="0.1019607843" blue="0.1019607843" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                     <nil key="highlightedColor"/>
@@ -859,7 +871,10 @@
                             <rect key="frame" x="0.0" y="127" width="386" height="50"/>
                             <subviews>
                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="联系我们" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="cZ0-wT-OCD">
-                                    <rect key="frame" x="15" y="15.5" width="65.5" height="19.5"/>
+                                    <rect key="frame" x="15" y="14" width="65.5" height="22"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="22" id="3oA-LQ-Wxh"/>
+                                    </constraints>
                                     <fontDescription key="fontDescription" type="system" pointSize="16"/>
                                     <color key="textColor" red="0.1019607843" green="0.1019607843" blue="0.1019607843" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                     <nil key="highlightedColor"/>
@@ -881,19 +896,51 @@
                                 <outletCollection property="gestureRecognizers" destination="JfQ-Ny-0H1" appends="YES" id="Znv-O3-wbH"/>
                             </connections>
                         </view>
+                        <view tag="1020" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="vX0-i6-N1E">
+                            <rect key="frame" x="0.0" y="177" width="386" height="50"/>
+                            <subviews>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="在线客服" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MMr-Ez-z1i">
+                                    <rect key="frame" x="15" y="14" width="65.5" height="22"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="22" id="1ok-Jp-d6s"/>
+                                    </constraints>
+                                    <fontDescription key="fontDescription" type="system" pointSize="16"/>
+                                    <color key="textColor" red="0.1019607843" green="0.1019607843" blue="0.1019607843" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                    <nil key="highlightedColor"/>
+                                </label>
+                                <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="mine_next" translatesAutoresizingMaskIntoConstraints="NO" id="hPk-EA-ZQB">
+                                    <rect key="frame" x="365" y="17.5" width="8" height="15"/>
+                                </imageView>
+                            </subviews>
+                            <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                            <gestureRecognizers/>
+                            <constraints>
+                                <constraint firstAttribute="trailing" secondItem="hPk-EA-ZQB" secondAttribute="trailing" constant="13" id="0mQ-O2-Qbb"/>
+                                <constraint firstItem="MMr-Ez-z1i" firstAttribute="leading" secondItem="vX0-i6-N1E" secondAttribute="leading" constant="15" id="6CM-9U-jzp"/>
+                                <constraint firstAttribute="height" constant="50" id="9TD-pb-bb5"/>
+                                <constraint firstItem="MMr-Ez-z1i" firstAttribute="centerY" secondItem="vX0-i6-N1E" secondAttribute="centerY" id="JNn-r6-JXd"/>
+                                <constraint firstItem="hPk-EA-ZQB" firstAttribute="centerY" secondItem="vX0-i6-N1E" secondAttribute="centerY" id="xzf-hB-0xB"/>
+                            </constraints>
+                            <connections>
+                                <outletCollection property="gestureRecognizers" destination="Idf-24-2ql" appends="YES" id="Dmn-g8-sX8"/>
+                            </connections>
+                        </view>
                     </subviews>
                     <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                     <constraints>
+                        <constraint firstAttribute="trailing" secondItem="vX0-i6-N1E" secondAttribute="trailing" id="3kY-WV-bWQ"/>
                         <constraint firstAttribute="trailing" secondItem="iFf-ti-ghK" secondAttribute="trailing" id="AN1-q6-Osl"/>
                         <constraint firstItem="iFf-ti-ghK" firstAttribute="top" secondItem="qXK-bw-j5E" secondAttribute="top" constant="15" id="Di9-N3-nAP"/>
                         <constraint firstItem="iFf-ti-ghK" firstAttribute="leading" secondItem="qXK-bw-j5E" secondAttribute="leading" id="EGu-bH-uwt"/>
                         <constraint firstItem="qjh-zg-Nt5" firstAttribute="leading" secondItem="qXK-bw-j5E" secondAttribute="leading" id="I4J-re-P3N"/>
                         <constraint firstAttribute="trailing" secondItem="DzF-lL-e7x" secondAttribute="trailing" id="MfX-mS-gFy"/>
                         <constraint firstItem="DzF-lL-e7x" firstAttribute="leading" secondItem="qXK-bw-j5E" secondAttribute="leading" id="Mia-Xj-XHx"/>
-                        <constraint firstAttribute="height" constant="192" id="dRC-An-6Mi"/>
+                        <constraint firstItem="vX0-i6-N1E" firstAttribute="leading" secondItem="qXK-bw-j5E" secondAttribute="leading" id="RH0-JF-ACH"/>
                         <constraint firstAttribute="trailing" secondItem="qjh-zg-Nt5" secondAttribute="trailing" id="hF6-gi-8iW"/>
                         <constraint firstItem="DzF-lL-e7x" firstAttribute="top" secondItem="qjh-zg-Nt5" secondAttribute="bottom" constant="6" id="tlj-W2-gUr"/>
+                        <constraint firstAttribute="bottom" secondItem="vX0-i6-N1E" secondAttribute="bottom" constant="15" id="unL-la-Ucy"/>
                         <constraint firstItem="qjh-zg-Nt5" firstAttribute="top" secondItem="iFf-ti-ghK" secondAttribute="bottom" constant="6" id="x3c-7Y-VGz"/>
+                        <constraint firstItem="vX0-i6-N1E" firstAttribute="top" secondItem="DzF-lL-e7x" secondAttribute="bottom" id="yFg-8j-ovu"/>
                     </constraints>
                     <userDefinedRuntimeAttributes>
                         <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
@@ -944,6 +991,8 @@
             <connections>
                 <outlet property="avatarWidth" destination="HpZ-zd-ch0" id="O5n-hf-POC"/>
                 <outlet property="awardView" destination="A9g-HO-Cfh" id="IKa-fq-2C9"/>
+                <outlet property="costomserviceView" destination="vX0-i6-N1E" id="W1I-k8-6Dn"/>
+                <outlet property="costomserviceViewHeight" destination="9TD-pb-bb5" id="NyB-8l-7zf"/>
                 <outlet property="finishCourseLabel" destination="lLR-pZ-jam" id="cVd-kH-5uJ"/>
                 <outlet property="followTeacherLabel" destination="gfo-ED-EEb" id="Fn2-TG-zkD"/>
                 <outlet property="memberCountLabel" destination="6qT-My-OUw" id="zH9-FK-BPX"/>
@@ -1049,6 +1098,11 @@
                 <action selector="clickAction:" destination="iN0-l3-epB" id="fxc-He-n31"/>
             </connections>
         </tapGestureRecognizer>
+        <tapGestureRecognizer id="Idf-24-2ql">
+            <connections>
+                <action selector="clickAction:" destination="iN0-l3-epB" id="8hh-wx-6c7"/>
+            </connections>
+        </tapGestureRecognizer>
     </objects>
     <resources>
         <image name="activity_award" width="42" height="42"/>

+ 2 - 2
KulexiuForStudent/KulexiuForStudent/Module/Mine/Works/View/MineWorksBodyView.m

@@ -244,9 +244,9 @@
 - (void)displayMergeView:(UserMusicFormalModel *)model {
     KSDraftMergeViewController *ctrl = [[KSDraftMergeViewController alloc] init];
     ctrl.sourceModel = model;
-    MJWeakSelf;
+    
     [ctrl editCallback:^{
-//        [weakSelf refreshAndRequestData];
+
     }];
     [self.naviController pushViewController:ctrl animated:YES];
 }