Commit fa6dc8684b46b7f8409510661d1d3a0d5e135f65
1 parent
e36f3266
创建优惠券功能
Showing
15 changed files
with
1796 additions
and
6 deletions
metaCode.xcodeproj/project.pbxproj
| @@ -114,9 +114,12 @@ | @@ -114,9 +114,12 @@ | ||
| 114 | 79A68C4C2A26EA6000DC3B43 /* (null) in Sources */ = {isa = PBXBuildFile; }; | 114 | 79A68C4C2A26EA6000DC3B43 /* (null) in Sources */ = {isa = PBXBuildFile; }; |
| 115 | 79B2E3602AF39191002A8524 /* NSObject+CNLiveConfigModuleInline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79B2E35F2AF39191002A8524 /* NSObject+CNLiveConfigModuleInline.swift */; }; | 115 | 79B2E3602AF39191002A8524 /* NSObject+CNLiveConfigModuleInline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79B2E35F2AF39191002A8524 /* NSObject+CNLiveConfigModuleInline.swift */; }; |
| 116 | 79BA085D2AB18E8300D01875 /* CNLiveSaveAuthDB.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79BA085C2AB18E8300D01875 /* CNLiveSaveAuthDB.swift */; }; | 116 | 79BA085D2AB18E8300D01875 /* CNLiveSaveAuthDB.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79BA085C2AB18E8300D01875 /* CNLiveSaveAuthDB.swift */; }; |
| 117 | + 79BB1C142B05C51900C5720C /* CNLiveShopCouponViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79BB1C132B05C51900C5720C /* CNLiveShopCouponViewController.swift */; }; | ||
| 118 | + 79BB1C162B05C62900C5720C /* CNLiveShopBodyCouponView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79BB1C152B05C62900C5720C /* CNLiveShopBodyCouponView.swift */; }; | ||
| 117 | 79BB96A62AF21E2800AEA4AC /* CNLiveShopOrderDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79BB96A52AF21E2800AEA4AC /* CNLiveShopOrderDetailViewController.swift */; }; | 119 | 79BB96A62AF21E2800AEA4AC /* CNLiveShopOrderDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79BB96A52AF21E2800AEA4AC /* CNLiveShopOrderDetailViewController.swift */; }; |
| 118 | 79BB96A82AF223FB00AEA4AC /* CNLiveConfigAlertManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79BB96A72AF223FB00AEA4AC /* CNLiveConfigAlertManager.swift */; }; | 120 | 79BB96A82AF223FB00AEA4AC /* CNLiveConfigAlertManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79BB96A72AF223FB00AEA4AC /* CNLiveConfigAlertManager.swift */; }; |
| 119 | 79BB96AA2AF2330900AEA4AC /* CNLiveShopBodyDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79BB96A92AF2330900AEA4AC /* CNLiveShopBodyDetailView.swift */; }; | 121 | 79BB96AA2AF2330900AEA4AC /* CNLiveShopBodyDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79BB96A92AF2330900AEA4AC /* CNLiveShopBodyDetailView.swift */; }; |
| 122 | + 79D094DC2B0765DD008CB1F3 /* CNLiveShopBodyCouponGoodsListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79D094DB2B0765DD008CB1F3 /* CNLiveShopBodyCouponGoodsListView.swift */; }; | ||
| 120 | 79E496E32AB9357000127BF8 /* UITableViewCell+CNLiveExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79E496E22AB9357000127BF8 /* UITableViewCell+CNLiveExtension.swift */; }; | 123 | 79E496E32AB9357000127BF8 /* UITableViewCell+CNLiveExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79E496E22AB9357000127BF8 /* UITableViewCell+CNLiveExtension.swift */; }; |
| 121 | 79E496E82AB9674300127BF8 /* NSMutableAttributedString+CNLiveExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79E496E72AB9674300127BF8 /* NSMutableAttributedString+CNLiveExtensions.swift */; }; | 124 | 79E496E82AB9674300127BF8 /* NSMutableAttributedString+CNLiveExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79E496E72AB9674300127BF8 /* NSMutableAttributedString+CNLiveExtensions.swift */; }; |
| 122 | 79E672032AFDFA9C00F2F768 /* CNLiveMineSignOutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79E672022AFDFA9C00F2F768 /* CNLiveMineSignOutViewController.swift */; }; | 125 | 79E672032AFDFA9C00F2F768 /* CNLiveMineSignOutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79E672022AFDFA9C00F2F768 /* CNLiveMineSignOutViewController.swift */; }; |
| @@ -285,9 +288,12 @@ | @@ -285,9 +288,12 @@ | ||
| 285 | 79A68C512A26F59C00DC3B43 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = metaCode/Info.plist; sourceTree = "<group>"; }; | 288 | 79A68C512A26F59C00DC3B43 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = metaCode/Info.plist; sourceTree = "<group>"; }; |
| 286 | 79B2E35F2AF39191002A8524 /* NSObject+CNLiveConfigModuleInline.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSObject+CNLiveConfigModuleInline.swift"; sourceTree = "<group>"; }; | 289 | 79B2E35F2AF39191002A8524 /* NSObject+CNLiveConfigModuleInline.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSObject+CNLiveConfigModuleInline.swift"; sourceTree = "<group>"; }; |
| 287 | 79BA085C2AB18E8300D01875 /* CNLiveSaveAuthDB.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveSaveAuthDB.swift; sourceTree = "<group>"; }; | 290 | 79BA085C2AB18E8300D01875 /* CNLiveSaveAuthDB.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveSaveAuthDB.swift; sourceTree = "<group>"; }; |
| 291 | + 79BB1C132B05C51900C5720C /* CNLiveShopCouponViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopCouponViewController.swift; sourceTree = "<group>"; }; | ||
| 292 | + 79BB1C152B05C62900C5720C /* CNLiveShopBodyCouponView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopBodyCouponView.swift; sourceTree = "<group>"; }; | ||
| 288 | 79BB96A52AF21E2800AEA4AC /* CNLiveShopOrderDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopOrderDetailViewController.swift; sourceTree = "<group>"; }; | 293 | 79BB96A52AF21E2800AEA4AC /* CNLiveShopOrderDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopOrderDetailViewController.swift; sourceTree = "<group>"; }; |
| 289 | 79BB96A72AF223FB00AEA4AC /* CNLiveConfigAlertManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveConfigAlertManager.swift; sourceTree = "<group>"; }; | 294 | 79BB96A72AF223FB00AEA4AC /* CNLiveConfigAlertManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveConfigAlertManager.swift; sourceTree = "<group>"; }; |
| 290 | 79BB96A92AF2330900AEA4AC /* CNLiveShopBodyDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopBodyDetailView.swift; sourceTree = "<group>"; }; | 295 | 79BB96A92AF2330900AEA4AC /* CNLiveShopBodyDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopBodyDetailView.swift; sourceTree = "<group>"; }; |
| 296 | + 79D094DB2B0765DD008CB1F3 /* CNLiveShopBodyCouponGoodsListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopBodyCouponGoodsListView.swift; sourceTree = "<group>"; }; | ||
| 291 | 79E496E22AB9357000127BF8 /* UITableViewCell+CNLiveExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITableViewCell+CNLiveExtension.swift"; sourceTree = "<group>"; }; | 297 | 79E496E22AB9357000127BF8 /* UITableViewCell+CNLiveExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITableViewCell+CNLiveExtension.swift"; sourceTree = "<group>"; }; |
| 292 | 79E496E72AB9674300127BF8 /* NSMutableAttributedString+CNLiveExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSMutableAttributedString+CNLiveExtensions.swift"; sourceTree = "<group>"; }; | 298 | 79E496E72AB9674300127BF8 /* NSMutableAttributedString+CNLiveExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSMutableAttributedString+CNLiveExtensions.swift"; sourceTree = "<group>"; }; |
| 293 | 79E672022AFDFA9C00F2F768 /* CNLiveMineSignOutViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveMineSignOutViewController.swift; sourceTree = "<group>"; }; | 299 | 79E672022AFDFA9C00F2F768 /* CNLiveMineSignOutViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveMineSignOutViewController.swift; sourceTree = "<group>"; }; |
| @@ -727,6 +733,7 @@ | @@ -727,6 +733,7 @@ | ||
| 727 | 794FF1062B01FC9800385E85 /* CNLiveShopOrderSearchListViewController.swift */, | 733 | 794FF1062B01FC9800385E85 /* CNLiveShopOrderSearchListViewController.swift */, |
| 728 | 798916EC2B048E8200D08302 /* CNLiveShopTransViewController.swift */, | 734 | 798916EC2B048E8200D08302 /* CNLiveShopTransViewController.swift */, |
| 729 | 798916EE2B048EC800D08302 /* CNLiveShopTransListViewController.swift */, | 735 | 798916EE2B048EC800D08302 /* CNLiveShopTransListViewController.swift */, |
| 736 | + 79BB1C132B05C51900C5720C /* CNLiveShopCouponViewController.swift */, | ||
| 730 | ); | 737 | ); |
| 731 | path = Controller; | 738 | path = Controller; |
| 732 | sourceTree = "<group>"; | 739 | sourceTree = "<group>"; |
| @@ -747,6 +754,8 @@ | @@ -747,6 +754,8 @@ | ||
| 747 | 79A267822AF8D7BC0088D9F6 /* CNLiveShopBodyCustomView.swift */, | 754 | 79A267822AF8D7BC0088D9F6 /* CNLiveShopBodyCustomView.swift */, |
| 748 | 791C1C8B2AFB85F8003E6362 /* CNLiveShopBodyExpressView.swift */, | 755 | 791C1C8B2AFB85F8003E6362 /* CNLiveShopBodyExpressView.swift */, |
| 749 | 798916F02B0491A400D08302 /* CNLiveShopBodyTransListView.swift */, | 756 | 798916F02B0491A400D08302 /* CNLiveShopBodyTransListView.swift */, |
| 757 | + 79BB1C152B05C62900C5720C /* CNLiveShopBodyCouponView.swift */, | ||
| 758 | + 79D094DB2B0765DD008CB1F3 /* CNLiveShopBodyCouponGoodsListView.swift */, | ||
| 750 | ); | 759 | ); |
| 751 | path = View; | 760 | path = View; |
| 752 | sourceTree = "<group>"; | 761 | sourceTree = "<group>"; |
| @@ -1188,6 +1197,7 @@ | @@ -1188,6 +1197,7 @@ | ||
| 1188 | 19BB1FEA2AEF7B4A0094D962 /* CNLiveShopConsoleCell.swift in Sources */, | 1197 | 19BB1FEA2AEF7B4A0094D962 /* CNLiveShopConsoleCell.swift in Sources */, |
| 1189 | 790D019D2A2DCBD000C5978D /* UIView+CNLiveExtensions.swift in Sources */, | 1198 | 790D019D2A2DCBD000C5978D /* UIView+CNLiveExtensions.swift in Sources */, |
| 1190 | 790B1FB62A41938F0074CF00 /* UIImage+CNLiveExtensions.swift in Sources */, | 1199 | 790B1FB62A41938F0074CF00 /* UIImage+CNLiveExtensions.swift in Sources */, |
| 1200 | + 79BB1C162B05C62900C5720C /* CNLiveShopBodyCouponView.swift in Sources */, | ||
| 1191 | 798916E92B04532D00D08302 /* CNLiveSavePointDB.swift in Sources */, | 1201 | 798916E92B04532D00D08302 /* CNLiveSavePointDB.swift in Sources */, |
| 1192 | 19FA20172AE22D3C001F7186 /* CNLiveDownSlideRecommendCell.swift in Sources */, | 1202 | 19FA20172AE22D3C001F7186 /* CNLiveDownSlideRecommendCell.swift in Sources */, |
| 1193 | 19123FC12ABC11170075C883 /* CNWebViewController.swift in Sources */, | 1203 | 19123FC12ABC11170075C883 /* CNWebViewController.swift in Sources */, |
| @@ -1226,6 +1236,7 @@ | @@ -1226,6 +1236,7 @@ | ||
| 1226 | 79656E382AAEBA8E00119A61 /* CNLiveMineInputViewController.swift in Sources */, | 1236 | 79656E382AAEBA8E00119A61 /* CNLiveMineInputViewController.swift in Sources */, |
| 1227 | 19CC4D522ADD129800308E2A /* CNUpSlideAnimationTransition.swift in Sources */, | 1237 | 19CC4D522ADD129800308E2A /* CNUpSlideAnimationTransition.swift in Sources */, |
| 1228 | 7CD6754F2A2840B9008354C1 /* CNMetaCodeHomePageController.swift in Sources */, | 1238 | 7CD6754F2A2840B9008354C1 /* CNMetaCodeHomePageController.swift in Sources */, |
| 1239 | + 79D094DC2B0765DD008CB1F3 /* CNLiveShopBodyCouponGoodsListView.swift in Sources */, | ||
| 1229 | 798916EF2B048EC800D08302 /* CNLiveShopTransListViewController.swift in Sources */, | 1240 | 798916EF2B048EC800D08302 /* CNLiveShopTransListViewController.swift in Sources */, |
| 1230 | 7989B5C52A4BDC6000A19B10 /* CNLiveMineEarnViewController.swift in Sources */, | 1241 | 7989B5C52A4BDC6000A19B10 /* CNLiveMineEarnViewController.swift in Sources */, |
| 1231 | 792E57DB2A3AE9F4005834DB /* CNLiveCommonQiniuTool.swift in Sources */, | 1242 | 792E57DB2A3AE9F4005834DB /* CNLiveCommonQiniuTool.swift in Sources */, |
| @@ -1276,6 +1287,7 @@ | @@ -1276,6 +1287,7 @@ | ||
| 1276 | 19565ECF2AF8D8F6007D6727 /* CNLiveShopGoodsListCell.swift in Sources */, | 1287 | 19565ECF2AF8D8F6007D6727 /* CNLiveShopGoodsListCell.swift in Sources */, |
| 1277 | 1965FA3E2AFB176E00F0F435 /* CNLiveShopAddGoodsSingleView.swift in Sources */, | 1288 | 1965FA3E2AFB176E00F0F435 /* CNLiveShopAddGoodsSingleView.swift in Sources */, |
| 1278 | 7CD6753C2A2740B0008354C1 /* CNUpSlideViewRemindView.swift in Sources */, | 1289 | 7CD6753C2A2740B0008354C1 /* CNUpSlideViewRemindView.swift in Sources */, |
| 1290 | + 79BB1C142B05C51900C5720C /* CNLiveShopCouponViewController.swift in Sources */, | ||
| 1279 | 798916ED2B048E8200D08302 /* CNLiveShopTransViewController.swift in Sources */, | 1291 | 798916ED2B048E8200D08302 /* CNLiveShopTransViewController.swift in Sources */, |
| 1280 | 19BB1FEC2AF0AB8E0094D962 /* CNLiveDownShopDetailController.swift in Sources */, | 1292 | 19BB1FEC2AF0AB8E0094D962 /* CNLiveDownShopDetailController.swift in Sources */, |
| 1281 | 794FF1072B01FC9800385E85 /* CNLiveShopOrderSearchListViewController.swift in Sources */, | 1293 | 794FF1072B01FC9800385E85 /* CNLiveShopOrderSearchListViewController.swift in Sources */, |
metaCode/Classes/Main/MinePage/Controller/CNLiveMineViewController.swift
| @@ -46,7 +46,9 @@ class CNLiveMineViewController : CNLiveBaseViewController, UITableViewDelegate, | @@ -46,7 +46,9 @@ class CNLiveMineViewController : CNLiveBaseViewController, UITableViewDelegate, | ||
| 46 | dataArray.add(array03) | 46 | dataArray.add(array03) |
| 47 | 47 | ||
| 48 | // let array04 : [Dictionary] = [["name":"订单列表","icon":"mine_list_icon_help_feedback"], | 48 | // let array04 : [Dictionary] = [["name":"订单列表","icon":"mine_list_icon_help_feedback"], |
| 49 | -// ["name":"交易记录","icon":"mine_list_icon_help_feedback"]] | 49 | +// ["name":"交易记录","icon":"mine_list_icon_help_feedback"], |
| 50 | +// ["name":"新增优惠券","icon":"mine_list_icon_help_feedback"], | ||
| 51 | +// ["name":"优惠券管理","icon":"mine_list_icon_help_feedback"]] | ||
| 50 | // dataArray.add(array04) | 52 | // dataArray.add(array04) |
| 51 | 53 | ||
| 52 | return dataArray | 54 | return dataArray |
| @@ -183,6 +185,9 @@ extension CNLiveMineViewController { | @@ -183,6 +185,9 @@ extension CNLiveMineViewController { | ||
| 183 | if indexPath.row == 1 { | 185 | if indexPath.row == 1 { |
| 184 | self.navigationController?.pushViewController(CNLiveShopTransViewController.init(), animated: true) | 186 | self.navigationController?.pushViewController(CNLiveShopTransViewController.init(), animated: true) |
| 185 | } | 187 | } |
| 188 | + if indexPath.row == 2 { | ||
| 189 | + self.navigationController?.pushViewController(CNLiveShopCouponViewController.init(), animated: true) | ||
| 190 | + } | ||
| 186 | } | 191 | } |
| 187 | 192 | ||
| 188 | } | 193 | } |
metaCode/Classes/Main/MinePage/View/CNLiveMineInfoAlertView.swift
| @@ -547,7 +547,8 @@ enum CNLiveStandListAlertShowType { | @@ -547,7 +547,8 @@ enum CNLiveStandListAlertShowType { | ||
| 547 | case text | 547 | case text |
| 548 | case date | 548 | case date |
| 549 | case string | 549 | case string |
| 550 | - case custom_date | 550 | + case min_date//今天最小 |
| 551 | + case max_date//今天最大 | ||
| 551 | } | 552 | } |
| 552 | class MineStandListAlertView: UIView, UIPickerViewDelegate, UIPickerViewDataSource { | 553 | class MineStandListAlertView: UIView, UIPickerViewDelegate, UIPickerViewDataSource { |
| 553 | 554 | ||
| @@ -585,7 +586,7 @@ class MineStandListAlertView: UIView, UIPickerViewDelegate, UIPickerViewDataSour | @@ -585,7 +586,7 @@ class MineStandListAlertView: UIView, UIPickerViewDelegate, UIPickerViewDataSour | ||
| 585 | datePicker.locale = Locale(identifier: "zh_CN") | 586 | datePicker.locale = Locale(identifier: "zh_CN") |
| 586 | datePicker.setValue(HexColor("#3C3C3C"), forKey: "textColor") | 587 | datePicker.setValue(HexColor("#3C3C3C"), forKey: "textColor") |
| 587 | datePicker.datePickerMode = .date | 588 | datePicker.datePickerMode = .date |
| 588 | - datePicker.isHidden = !(_show_type == .date || _show_type == .custom_date) | 589 | + datePicker.isHidden = !(_show_type == .date || _show_type == .min_date || _show_type == .max_date) |
| 589 | if #available(iOS 13.4, *) { | 590 | if #available(iOS 13.4, *) { |
| 590 | datePicker.preferredDatePickerStyle = .wheels | 591 | datePicker.preferredDatePickerStyle = .wheels |
| 591 | } else { | 592 | } else { |
| @@ -652,13 +653,17 @@ class MineStandListAlertView: UIView, UIPickerViewDelegate, UIPickerViewDataSour | @@ -652,13 +653,17 @@ class MineStandListAlertView: UIView, UIPickerViewDelegate, UIPickerViewDataSour | ||
| 652 | text = infos.firstObject as? Dictionary<String, String> | 653 | text = infos.firstObject as? Dictionary<String, String> |
| 653 | } else if _show_type == .string { | 654 | } else if _show_type == .string { |
| 654 | text = infos.firstObject as? String | 655 | text = infos.firstObject as? String |
| 655 | - } else if _show_type == .custom_date { | 656 | + } else if (_show_type == .min_date || _show_type == .max_date) { |
| 656 | let current_date = infos.firstObject as! Date | 657 | let current_date = infos.firstObject as! Date |
| 657 | let formatter = DateFormatter() | 658 | let formatter = DateFormatter() |
| 658 | formatter.locale = Locale.init(identifier: "zh_CN") | 659 | formatter.locale = Locale.init(identifier: "zh_CN") |
| 659 | formatter.dateFormat = (infos.lastObject as! String) | 660 | formatter.dateFormat = (infos.lastObject as! String) |
| 660 | datePicker.setDate(current_date as Date, animated: true) | 661 | datePicker.setDate(current_date as Date, animated: true) |
| 661 | - datePicker.maximumDate = current_date | 662 | + if _show_type == .min_date { |
| 663 | + datePicker.minimumDate = Date(timeIntervalSinceNow: 0) | ||
| 664 | + } else { | ||
| 665 | + datePicker.maximumDate = Date(timeIntervalSinceNow: 0) | ||
| 666 | + } | ||
| 662 | text = formatter.string(from: datePicker.date) | 667 | text = formatter.string(from: datePicker.date) |
| 663 | }else{ | 668 | }else{ |
| 664 | let formatter = DateFormatter() | 669 | let formatter = DateFormatter() |
metaCode/Classes/Main/ShopPage/Controller/CNLiveShopCouponViewController.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveShopCouponViewController.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by open on 2023/11/16. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | +import EmptyDataSet_Swift | ||
| 10 | +import IQKeyboardManagerSwift | ||
| 11 | +import APButton | ||
| 12 | + | ||
| 13 | +enum CNLiveShopCouponShowType { | ||
| 14 | + case create //创建 | ||
| 15 | + case edit //编辑 | ||
| 16 | +} | ||
| 17 | +class CNLiveShopCouponViewController: CNLiveBaseViewController, UITableViewDelegate, UITableViewDataSource, EmptyDataSetSource, EmptyDataSetDelegate { | ||
| 18 | + | ||
| 19 | + let kShopBodyCouponCreateTableViewCellIdentifier = "kShopBodyCouponCreateTableViewCellIdentifier" | ||
| 20 | + let kUITableViewHeaderFooterViewIdentifier = "kUITableViewHeaderFooterViewIdentifier" | ||
| 21 | + lazy var tableView : UITableView = { | ||
| 22 | + let tableView = UITableView(frame: .zero, style: .plain) | ||
| 23 | + tableView.dataSource = self | ||
| 24 | + tableView.delegate = self | ||
| 25 | + tableView.emptyDataSetSource = self | ||
| 26 | + tableView.emptyDataSetDelegate = self | ||
| 27 | + tableView.backgroundColor = HexColor("#f6f6f6") | ||
| 28 | + tableView.tableFooterView = UIView.init() | ||
| 29 | + tableView.separatorStyle = .none | ||
| 30 | + tableView.register(ShopBodyCouponCreateTableViewCell.self, forCellReuseIdentifier: kShopBodyCouponCreateTableViewCellIdentifier) | ||
| 31 | + tableView.register(UITableViewHeaderFooterView.self, forHeaderFooterViewReuseIdentifier: kUITableViewHeaderFooterViewIdentifier) | ||
| 32 | + return tableView | ||
| 33 | + }() | ||
| 34 | + | ||
| 35 | + lazy var footerView: UIView = { | ||
| 36 | + let footerView = UIView.init(frame: CGRect(x: 0, y: KSreenHeight - get_system_tabbar_height(), width: KSreenWidth, height: get_system_tabbar_height())) | ||
| 37 | + footerView.backgroundColor = .white | ||
| 38 | + footerView.addSubview(cancelBtn) | ||
| 39 | + cancelBtn.snp.makeConstraints { make in | ||
| 40 | + make.width.equalTo(adapt_length(length: 130)) | ||
| 41 | + make.height.equalTo(get_system_tabbar_ui_height()) | ||
| 42 | + make.left.equalToSuperview() | ||
| 43 | + make.top.equalToSuperview() | ||
| 44 | + } | ||
| 45 | + footerView.addSubview(deliveryBtn) | ||
| 46 | + deliveryBtn.snp.makeConstraints { make in | ||
| 47 | + make.width.equalTo(KSreenWidth - adapt_length(length: 130)) | ||
| 48 | + make.height.equalTo(get_system_tabbar_ui_height()) | ||
| 49 | + make.right.equalToSuperview() | ||
| 50 | + make.top.equalToSuperview() | ||
| 51 | + } | ||
| 52 | + return footerView | ||
| 53 | + }() | ||
| 54 | + | ||
| 55 | + lazy var cancelBtn: UIButton = { | ||
| 56 | + let cancelBtn = UIButton.init(type: .custom) | ||
| 57 | + cancelBtn.backgroundColor = .white | ||
| 58 | + cancelBtn.setTitle("取消", for: .normal) | ||
| 59 | + cancelBtn.setTitleColor(HexColor("#3A3A3A"), for: .normal) | ||
| 60 | + cancelBtn.titleLabel?.font = medium_adapt_font(pointSize: 14) | ||
| 61 | + cancelBtn.addTarget(self, action: #selector(cancelBtnClick), for: .touchUpInside) | ||
| 62 | + return cancelBtn | ||
| 63 | + }() | ||
| 64 | + | ||
| 65 | + lazy var deliveryBtn: APButton = { | ||
| 66 | + let deliveryBtn = APButton.init() | ||
| 67 | + deliveryBtn.backgroundColor = HexColor("#65C368") | ||
| 68 | + deliveryBtn.setTitle("保存", for: .normal) | ||
| 69 | + deliveryBtn.activityIndicator.color = .white | ||
| 70 | + deliveryBtn.titleLabel?.font = regular_adapt_font(pointSize: 15) | ||
| 71 | + deliveryBtn.setTitleColor(HexColor("#FFFFFF"), for: .normal) | ||
| 72 | + deliveryBtn.addTarget(self, action: #selector(sendBtnClick), for: .touchUpInside) | ||
| 73 | + return deliveryBtn | ||
| 74 | + }() | ||
| 75 | + | ||
| 76 | + lazy var dataArray: NSMutableArray = { | ||
| 77 | + let dataArray = NSMutableArray.init() | ||
| 78 | + return dataArray | ||
| 79 | + }() | ||
| 80 | + | ||
| 81 | + | ||
| 82 | + | ||
| 83 | + var _listModel: ShopOrderCouponListModel! | ||
| 84 | + var _show_type: CNLiveShopCouponShowType! | ||
| 85 | + /// 创建优惠券使用的 | ||
| 86 | + init() { | ||
| 87 | + _show_type = .create | ||
| 88 | + _listModel = ShopOrderCouponListModel.init() | ||
| 89 | + super.init(nibName:nil, bundle:nil) | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + /// 编辑优惠券需要调用 | ||
| 93 | + /// - Parameters: | ||
| 94 | + /// - listModel: 数据源 | ||
| 95 | + /// - show_type: 显示类型 | ||
| 96 | + init(listModel: ShopOrderCouponListModel) { | ||
| 97 | + _show_type = .edit | ||
| 98 | + _listModel = listModel | ||
| 99 | + super.init(nibName:nil, bundle:nil) | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + | ||
| 103 | + required init?(coder: NSCoder) { | ||
| 104 | + fatalError("init(coder:) has not been implemented") | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + | ||
| 108 | + var hiddenGoodsLine: Bool! | ||
| 109 | + var network_type: CNLiveMineResponseType! | ||
| 110 | + override func viewDidLoad() { | ||
| 111 | + super.viewDidLoad() | ||
| 112 | + view.backgroundColor = HexColor("#f6f6f6") | ||
| 113 | + navigationBarHidden = false | ||
| 114 | + titleName = "发布优惠券" | ||
| 115 | + | ||
| 116 | + loadDataSourceAction() | ||
| 117 | + | ||
| 118 | + view.addSubview(tableView) | ||
| 119 | + tableView.snp.makeConstraints { make in | ||
| 120 | + make.top.equalTo(KNavigationHeight) | ||
| 121 | + make.left.right.equalToSuperview() | ||
| 122 | + make.bottom.equalToSuperview().offset(-get_system_tabbar_height()) | ||
| 123 | + } | ||
| 124 | + view.addSubview(footerView) | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + func loadDataSourceAction() { | ||
| 128 | + | ||
| 129 | + CNLiveShopViewModel.requestCoupon(model: _listModel) { [weak self] result, respStatue in | ||
| 130 | + if respStatue == .success { | ||
| 131 | + self!.dataArray = result as! NSMutableArray | ||
| 132 | + self!.tableView.reloadData() | ||
| 133 | + let model = (self!.dataArray[1] as! NSArray)[0] as! ShopOrderCouponDataModel | ||
| 134 | + self!.hiddenGoodsLine = model.section == "1" | ||
| 135 | + } | ||
| 136 | + } | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + @objc func cancelBtnClick() { | ||
| 140 | + self.navigationController?.popViewController(animated: true) | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + | ||
| 144 | + var couponTitle: String! = "" | ||
| 145 | + var totalNum: String! = "" | ||
| 146 | + var maxMoney: String! = "" | ||
| 147 | + var lessMoney: String! = "" | ||
| 148 | + var startTime: String! = "" | ||
| 149 | + var endTime: String! = "" | ||
| 150 | + var goodsId: String! = "" | ||
| 151 | + @objc func sendBtnClick(sender: APButton) { | ||
| 152 | + let model01 = (self.dataArray[1] as! NSArray)[0] as! ShopOrderCouponDataModel | ||
| 153 | + let model02 = (self.dataArray[1] as! NSArray)[2] as! ShopOrderCouponDataModel | ||
| 154 | + let model03 = (self.dataArray[1] as! NSArray)[3] as! ShopOrderCouponDataModel | ||
| 155 | + let model04 = (self.dataArray[1] as! NSArray)[4] as! ShopOrderCouponDataModel | ||
| 156 | + if _show_type == .create { | ||
| 157 | + showLoading(message: "提交中...") | ||
| 158 | + sender.startAnimating() | ||
| 159 | + CNLiveShopViewModel.requestCouponCreate(title: couponTitle, filled: maxMoney, discount: lessMoney, startTime: startTime, endTime: endTime, state: model02.section!, isShow: model04.section!, receiveNum: model03.section!, totalNum: totalNum, goodsType: model01.section!, goodsId: goodsId) { result, respStatue in | ||
| 160 | + sender.stopAnimating() | ||
| 161 | + if respStatue == .success { | ||
| 162 | + showMessage(message: result as! String) | ||
| 163 | + } | ||
| 164 | + } | ||
| 165 | + } else { | ||
| 166 | + showLoading(message: "提交中...") | ||
| 167 | + sender.startAnimating() | ||
| 168 | + CNLiveShopViewModel.requestCouponEdit(model: _listModel, title: (couponTitle.isNotBlank() ? couponTitle : _listModel.title)!, state: model02.section!, isShow: model04.section!, receiveNum: model03.section!) { result, respStatue in | ||
| 169 | + sender.stopAnimating() | ||
| 170 | + if respStatue == .success { | ||
| 171 | + showMessage(message: result as! String) | ||
| 172 | + } | ||
| 173 | + } | ||
| 174 | + } | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | +} | ||
| 178 | + | ||
| 179 | +extension CNLiveShopCouponViewController { | ||
| 180 | + func numberOfSections(in tableView: UITableView) -> Int { | ||
| 181 | + return dataArray.count | ||
| 182 | + } | ||
| 183 | + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
| 184 | + let temp_array = dataArray[section] as! NSArray | ||
| 185 | + return temp_array.count | ||
| 186 | + } | ||
| 187 | + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
| 188 | + guard let cell = tableView.dequeueReusableCell(withIdentifier: kShopBodyCouponCreateTableViewCellIdentifier) as? ShopBodyCouponCreateTableViewCell else { | ||
| 189 | + return ShopBodyCouponCreateTableViewCell() | ||
| 190 | + } | ||
| 191 | + if _show_type == .edit { | ||
| 192 | + if ((indexPath.section == 0 && indexPath.row == 0) || (indexPath.section == 1 && (indexPath.row == 2 || indexPath.row == 3 || indexPath.row == 4))) { | ||
| 193 | + cell.editEnabled = true | ||
| 194 | + } else { | ||
| 195 | + cell.editEnabled = false | ||
| 196 | + } | ||
| 197 | + } else { | ||
| 198 | + cell.editEnabled = true | ||
| 199 | + } | ||
| 200 | + cell.setupWithDataSource(couponModel: (dataArray[indexPath.section] as! NSArray)[indexPath.row] as! ShopOrderCouponDataModel) | ||
| 201 | + cell.textFieldCallBack = { [self] section, number in | ||
| 202 | + switch section { | ||
| 203 | + case "1": | ||
| 204 | + couponTitle = number | ||
| 205 | + break | ||
| 206 | + case "3": | ||
| 207 | + totalNum = number | ||
| 208 | + break | ||
| 209 | + case "1001": | ||
| 210 | + maxMoney = number | ||
| 211 | + break | ||
| 212 | + case "1002": | ||
| 213 | + lessMoney = number | ||
| 214 | + break | ||
| 215 | + default: | ||
| 216 | + break | ||
| 217 | + } | ||
| 218 | + } | ||
| 219 | + cell.dateSelectCallBack = { [self] id, date in | ||
| 220 | + let interval = date.timeIntervalSince1970 | ||
| 221 | + if id == "4" { | ||
| 222 | + startTime = "\(interval)" | ||
| 223 | + } else { | ||
| 224 | + endTime = "\(interval + 3600 * 24 - 1)" | ||
| 225 | + } | ||
| 226 | + } | ||
| 227 | + if (indexPath.row == 1 && indexPath.section == 1) { | ||
| 228 | + if goodsId.isNotBlank() && _listModel.goods_id!.isNotBlank() && _listModel.goods_id != "0" { | ||
| 229 | + cell.goodsLabel.text = "" | ||
| 230 | + } | ||
| 231 | + cell.isHidden = hiddenGoodsLine | ||
| 232 | + } | ||
| 233 | + cell.goodsHiddenCallBack = { [self] isHidden in | ||
| 234 | + hiddenGoodsLine = isHidden | ||
| 235 | + goodsId = "" | ||
| 236 | + let indexPath = IndexPath(row: 1, section: 1) | ||
| 237 | + tableView.reloadRows(at: [indexPath], with: .middle) | ||
| 238 | + } | ||
| 239 | + cell.goodsCallBack = { [weak self] goodsId in | ||
| 240 | + self!.goodsId = goodsId | ||
| 241 | + } | ||
| 242 | + return cell | ||
| 243 | + } | ||
| 244 | + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { | ||
| 245 | + if indexPath.section == 1 && indexPath.row == 1 && hiddenGoodsLine { | ||
| 246 | + return 0 | ||
| 247 | + } | ||
| 248 | + return adapt_length(length: 50) | ||
| 249 | + } | ||
| 250 | + func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { | ||
| 251 | + if section == 0 { | ||
| 252 | + return 0 | ||
| 253 | + } | ||
| 254 | + return adapt_length(length: 5) | ||
| 255 | + } | ||
| 256 | + func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { | ||
| 257 | + view.endEditing(true) | ||
| 258 | + } | ||
| 259 | + func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { | ||
| 260 | + let view = tableView.dequeueReusableHeaderFooterView(withIdentifier: kUITableViewHeaderFooterViewIdentifier) | ||
| 261 | + view?.contentView.backgroundColor = HexColor("#f6f6f6") | ||
| 262 | + return view | ||
| 263 | + } | ||
| 264 | + | ||
| 265 | +} | ||
| 266 | + | ||
| 267 | +extension CNLiveShopCouponViewController { | ||
| 268 | + | ||
| 269 | + func image(forEmptyDataSet scrollView: UIScrollView) -> UIImage? { | ||
| 270 | + if network_type == .failed || network_type == .unkonw { | ||
| 271 | + return UIImage(named: "mine_list_source_unusual_failed") | ||
| 272 | + } | ||
| 273 | + if dataArray.count == 0 { | ||
| 274 | + return UIImage(named: "mine_list_source_unusual_empty") | ||
| 275 | + } | ||
| 276 | + if network_type == .noNetwork { | ||
| 277 | + return UIImage(named: "mine_list_source_unusual_noNet") | ||
| 278 | + } | ||
| 279 | + return UIImage(named: "mine_list_source_unusual_empty") | ||
| 280 | + } | ||
| 281 | + | ||
| 282 | + func title(forEmptyDataSet scrollView: UIScrollView) -> NSAttributedString? { | ||
| 283 | + var defult_string = "" | ||
| 284 | + if network_type == .failed || network_type == .unkonw { | ||
| 285 | + defult_string = "接口请求错误,刷新试试~" | ||
| 286 | + } | ||
| 287 | + if network_type == .noNetwork { | ||
| 288 | + defult_string = "网络开小差了,刷新试试~" | ||
| 289 | + } | ||
| 290 | + if dataArray.count == 0 { | ||
| 291 | + defult_string = "暂时没有数据~" | ||
| 292 | + } | ||
| 293 | + return NSAttributedString(string: defult_string, attributes: [.font: Font_17,.foregroundColor: HexColor("#666666")!]) | ||
| 294 | + } | ||
| 295 | + | ||
| 296 | + func buttonTitle(forEmptyDataSet scrollView: UIScrollView, for state: UIControl.State) -> NSAttributedString? { | ||
| 297 | + if network_type == .failed || network_type == .noNetwork { | ||
| 298 | + let attributes = [NSAttributedString.Key.font:Font_16_Fit, | ||
| 299 | + NSAttributedString.Key.foregroundColor: HexColor("#609BFF")] | ||
| 300 | + return NSAttributedString(string: "刷一刷", attributes: attributes as [NSAttributedString.Key : Any]) | ||
| 301 | + } | ||
| 302 | + return nil | ||
| 303 | + } | ||
| 304 | + | ||
| 305 | + func emptyDataSet(_ scrollView: UIScrollView, didTapView view: UIView) { | ||
| 306 | + if network_type == .failed || network_type == .noNetwork { | ||
| 307 | + loadDataSourceAction() | ||
| 308 | + } | ||
| 309 | + } | ||
| 310 | +} |
metaCode/Classes/Main/ShopPage/Controller/CNLiveShopTransListViewController.swift
| @@ -44,7 +44,7 @@ class CNLiveShopTransListViewController: CNLiveBaseViewController, UITableViewDe | @@ -44,7 +44,7 @@ class CNLiveShopTransListViewController: CNLiveBaseViewController, UITableViewDe | ||
| 44 | lazy var headerView: ShopBodyTransListHeaderView = { | 44 | lazy var headerView: ShopBodyTransListHeaderView = { |
| 45 | let headerView = ShopBodyTransListHeaderView.init(frame: CGRect.zero) | 45 | let headerView = ShopBodyTransListHeaderView.init(frame: CGRect.zero) |
| 46 | headerView.clickBlcok = { [self] headerView in | 46 | headerView.clickBlcok = { [self] headerView in |
| 47 | - MineStandListAlertView.showStandListView(infos: [currentDate!,"YYYY年MM月"], name:"选择月份", show_type:.custom_date, result: { [self] text in | 47 | + MineStandListAlertView.showStandListView(infos: [currentDate!,"YYYY年MM月"], name:"选择月份", show_type:.max_date, result: { [self] text in |
| 48 | currentDate = (text as! NSString).timeStrChangeTotimedate("YYYY-MM-dd") | 48 | currentDate = (text as! NSString).timeStrChangeTotimedate("YYYY-MM-dd") |
| 49 | current_string = (text as! String) | 49 | current_string = (text as! String) |
| 50 | let array = (text as! NSString).components(separatedBy: "-") as NSArray | 50 | let array = (text as! NSString).components(separatedBy: "-") as NSArray |
metaCode/Classes/Main/ShopPage/Model/CNLiveShopBaseModel.swift
| @@ -285,3 +285,62 @@ class ShopOrderTransListDataModel: BaseModel { | @@ -285,3 +285,62 @@ class ShopOrderTransListDataModel: BaseModel { | ||
| 285 | } | 285 | } |
| 286 | } | 286 | } |
| 287 | 287 | ||
| 288 | +///优惠券相关数据 | ||
| 289 | +//!!!: | ||
| 290 | +class ShopOrderCouponDataModel: BaseModel { | ||
| 291 | + var id: String? = "" | ||
| 292 | + var type: String? = "" | ||
| 293 | + var title: String? = "" | ||
| 294 | + var subTitle: String? = "" | ||
| 295 | + var section: String? = "" | ||
| 296 | + var message: String? = "" | ||
| 297 | + var filled: String? = "" | ||
| 298 | + var disCount: String? = "" | ||
| 299 | +} | ||
| 300 | + | ||
| 301 | +class ShopOrderCouponListModel: BaseModel { | ||
| 302 | + var id: String? = ""//优惠券id | ||
| 303 | + var type: String? = ""// | ||
| 304 | + var sort: String? = ""//优惠券使用范围 1 店铺全场 3 单品券 | ||
| 305 | + var num: String? = ""//剩余数量 | ||
| 306 | + var goods_id: String? = ""//商品Id | ||
| 307 | + var goods_title: String? = ""// | ||
| 308 | + var filled: String? = ""//满 | ||
| 309 | + var discount: String? = ""//减 | ||
| 310 | + var starttime: String? = ""//开始时间 | ||
| 311 | + var endtime: String? = ""//结束时间 | ||
| 312 | + var addtime: String? = ""//发布时间 | ||
| 313 | + var store_id: String? = ""//店铺iD | ||
| 314 | + var genre: String? = ""// | ||
| 315 | + var day: String? = ""// | ||
| 316 | + var total: String? = ""//已领取数量 | ||
| 317 | + var state: String? = ""//优惠券状态 1 正常 2 冻结 | ||
| 318 | + var title: String? = ""//标题 | ||
| 319 | + var receive_number: String? = ""//领取次数 1 不限制 2 限制一次 | ||
| 320 | + var types: String? = ""// | ||
| 321 | + var is_show: String? = ""//是否显示 1 对外显示 2 不对外 | ||
| 322 | +} | ||
| 323 | + | ||
| 324 | +class ShopOrderCouponDataListModel: BaseModel { | ||
| 325 | + var list = [ShopOrderCouponListModel]()// 数据 | ||
| 326 | +} | ||
| 327 | + | ||
| 328 | +//!!!: 优惠券商品数据 | ||
| 329 | +class ShopOrderAssociatedGoodsModel: BaseModel { | ||
| 330 | + var id: String? = ""// 商品id | ||
| 331 | + var title: String? = ""// 商品名称 | ||
| 332 | + var simg: String? = ""// 商品图片 | ||
| 333 | + var img: String? = ""// | ||
| 334 | + var price: String? = ""//商品价格 | ||
| 335 | + var ads: String? = ""// 商品介绍 | ||
| 336 | + var groupid: String? = ""// 商品分类 | ||
| 337 | + var shopid: String? = ""// 店铺id | ||
| 338 | + var shop_id: String? = ""// | ||
| 339 | + var category_id: String? = ""// 店铺分类id | ||
| 340 | + var state: String? = ""// 1下架 2上架 | ||
| 341 | + var count: String? = ""// 库存 | ||
| 342 | + var shop_type: String? = ""// 1普通商品 2文创商品 | ||
| 343 | + var ord: String? = ""// 排序 | ||
| 344 | + var select: Bool = false// 商品是否被选中(本地标记) | ||
| 345 | +} | ||
| 346 | + |
metaCode/Classes/Main/ShopPage/View/CNLiveShopBodyCouponGoodsListView.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveShopBodyCouponGoodsListView.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by open on 2023/11/17. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | +import EmptyDataSet_Swift | ||
| 10 | +import Kingfisher | ||
| 11 | +import MJRefresh | ||
| 12 | +import IQKeyboardManagerSwift | ||
| 13 | + | ||
| 14 | +typealias clickCouponSearchTextFieldCallBack = (_ searchText: String) -> Void | ||
| 15 | +typealias clickCouponChooseGoodsCallBack = (_ model: ShopOrderAssociatedGoodsModel) -> Void | ||
| 16 | +//!!!: 商品搜索相关界面 | ||
| 17 | +class ShopBodyCouponGoodsListView: UIView, UITableViewDelegate, UITableViewDataSource, EmptyDataSetSource, EmptyDataSetDelegate { | ||
| 18 | + | ||
| 19 | + lazy var listBackView: UIView = { | ||
| 20 | + let listBackView = UIView.init() | ||
| 21 | + listBackView.backgroundColor = .white | ||
| 22 | + let path = UIBezierPath.init(roundedRect: CGRect(x: 0, y: 0, width: KSreenWidth, height: adapt_length(length: 390)), byRoundingCorners: [.bottomLeft,.bottomRight], cornerRadii: CGSizeMake(adapt_length(length: 9), adapt_length(length: 9))) | ||
| 23 | + let masklayer = CAShapeLayer() | ||
| 24 | + masklayer.path = path.cgPath | ||
| 25 | + listBackView.layer.mask = masklayer | ||
| 26 | + return listBackView | ||
| 27 | + }() | ||
| 28 | + | ||
| 29 | + let kShopBodyCouponGoodsListTableViewCellIdentifier = "kShopBodyCouponGoodsListTableViewCellIdentifier" | ||
| 30 | + lazy var tableView : UITableView = { | ||
| 31 | + let tableView = UITableView(frame: .zero, style: .plain) | ||
| 32 | + tableView.dataSource = self | ||
| 33 | + tableView.delegate = self | ||
| 34 | + tableView.emptyDataSetSource = self | ||
| 35 | + tableView.emptyDataSetDelegate = self | ||
| 36 | + tableView.backgroundColor = .white | ||
| 37 | + tableView.tableFooterView = UIView.init() | ||
| 38 | + tableView.separatorStyle = .none | ||
| 39 | + tableView.register(ShopBodyCouponGoodsListTableViewCell.self, forCellReuseIdentifier: kShopBodyCouponGoodsListTableViewCellIdentifier) | ||
| 40 | + return tableView | ||
| 41 | + }() | ||
| 42 | + | ||
| 43 | + lazy var closeBtn: UIButton = { | ||
| 44 | + let closeBtn = UIButton.init(type: .custom) | ||
| 45 | + closeBtn.setImage(UIImage(named: "mine_header_icon_close"), for: .normal) | ||
| 46 | + closeBtn.addTarget(self, action: #selector(closeClick), for: .touchUpInside) | ||
| 47 | + return closeBtn | ||
| 48 | + }() | ||
| 49 | + | ||
| 50 | + lazy var headerLabel: UILabel = { | ||
| 51 | + let headerLabel = UILabel.init() | ||
| 52 | + headerLabel.textColor = HexColor("#3a3a3a") | ||
| 53 | + headerLabel.font = regular_adapt_font(pointSize: 16) | ||
| 54 | + headerLabel.textAlignment = .left | ||
| 55 | + headerLabel.text = "请选择您要优惠的商品" | ||
| 56 | + return headerLabel | ||
| 57 | + }() | ||
| 58 | + | ||
| 59 | + lazy var searchView: ShopBodyCouponGoodsSearchView = { | ||
| 60 | + let searchView = ShopBodyCouponGoodsSearchView.init(frame: .zero) | ||
| 61 | + searchView.searchCallBack = {[weak self] searchText in | ||
| 62 | + if searchText.isNotBlank() { | ||
| 63 | + self!.pageNum = 1 | ||
| 64 | + self!.searchText = searchText | ||
| 65 | + self!.loadDataSourceAction(page: 1) | ||
| 66 | + } | ||
| 67 | + } | ||
| 68 | + return searchView | ||
| 69 | + }() | ||
| 70 | + | ||
| 71 | + lazy var dataArray: NSMutableArray = { | ||
| 72 | + let dataArray = NSMutableArray.init() | ||
| 73 | + return dataArray | ||
| 74 | + }() | ||
| 75 | + | ||
| 76 | + var searchText: String! | ||
| 77 | + var pageNum: NSInteger! | ||
| 78 | + var network_type: CNLiveMineResponseType! | ||
| 79 | + var clickGoodsCallBack: clickCouponChooseGoodsCallBack! | ||
| 80 | + override init(frame: CGRect) { | ||
| 81 | + super.init(frame: frame) | ||
| 82 | + pageNum = 1 | ||
| 83 | + searchText = "" | ||
| 84 | + backgroundColor = HexColor("#000000", alpha: 0.6) | ||
| 85 | + | ||
| 86 | + loadDataSourceAction(page: 1) | ||
| 87 | + | ||
| 88 | + addSubview(listBackView) | ||
| 89 | + listBackView.snp.makeConstraints { make in | ||
| 90 | + make.left.right.equalToSuperview() | ||
| 91 | + make.top.equalTo(self.snp.bottom) | ||
| 92 | + make.height.equalTo(adapt_length(length: 390)) | ||
| 93 | + } | ||
| 94 | + listBackView.addSubview(headerLabel) | ||
| 95 | + headerLabel.snp.makeConstraints { make in | ||
| 96 | + make.left.top.equalToSuperview().offset(adapt_length(length: 15)) | ||
| 97 | + } | ||
| 98 | + listBackView.addSubview(closeBtn) | ||
| 99 | + closeBtn.snp.makeConstraints { make in | ||
| 100 | + make.right.equalTo(listBackView).offset(-adapt_length(length: 15)) | ||
| 101 | + make.centerY.equalTo(headerLabel) | ||
| 102 | + } | ||
| 103 | + listBackView.addSubview(searchView) | ||
| 104 | + searchView.snp.makeConstraints { make in | ||
| 105 | + make.left.right.equalTo(listBackView) | ||
| 106 | + make.top.equalTo(headerLabel.snp.bottom).offset(adapt_length(length: 15)) | ||
| 107 | + make.height.equalTo(adapt_length(length: 52.5)) | ||
| 108 | + } | ||
| 109 | + listBackView.addSubview(tableView) | ||
| 110 | + tableView.snp.makeConstraints { make in | ||
| 111 | + make.left.right.bottom.equalTo(listBackView) | ||
| 112 | + make.top.equalTo(searchView.snp.bottom).offset(adapt_length(length: 10)) | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow), name: UIResponder.keyboardWillShowNotification, object: nil) | ||
| 116 | + NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name: UIResponder.keyboardWillHideNotification, object: nil) | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + func loadDataSourceAction(page: NSInteger) { | ||
| 120 | + showLoading(message: "") | ||
| 121 | + CNLiveShopViewModel.requestCouponSearchGoods(shopId: DSUserInfoManager.shared.dsUserInfo.id!, sortType: "1", state: "0", categoryId: "", keyword: searchText, page: pageNum) { [weak self] result, respStatue in | ||
| 122 | + if self == nil { | ||
| 123 | + return | ||
| 124 | + } | ||
| 125 | + if respStatue == .success { | ||
| 126 | + if self!.pageNum == 1 { | ||
| 127 | + self!.dataArray.removeAllObjects() | ||
| 128 | + self!.dataArray.addObjects(from: result as! [ShopOrderAssociatedGoodsModel]) | ||
| 129 | + if self!.dataArray.count > 0 && self!.tableView.mj_footer == nil { | ||
| 130 | + self!.addRefreshView() | ||
| 131 | + } | ||
| 132 | + if self!.dataArray.count == 0 && self!.tableView.mj_footer != nil { | ||
| 133 | + self!.tableView.mj_footer = nil | ||
| 134 | + } | ||
| 135 | + } | ||
| 136 | + if self!.pageNum > 1 { | ||
| 137 | + self!.dataArray.addObjects(from: result as! [ShopOrderAssociatedGoodsModel]) | ||
| 138 | + } | ||
| 139 | + self!.tableView.mj_footer?.endRefreshing() | ||
| 140 | + self!.tableView.reloadData() | ||
| 141 | + if (result as! Array<Any>).count == 0 { | ||
| 142 | + self!.tableView.mj_footer?.endRefreshingWithNoMoreData() | ||
| 143 | + self!.tableView.reloadData() | ||
| 144 | + } | ||
| 145 | + }else if (respStatue == .noNetwork) { | ||
| 146 | + self!.network_type = .noNetwork | ||
| 147 | + self!.tableView.reloadEmptyDataSet() | ||
| 148 | + } else { | ||
| 149 | + self!.network_type = .failed | ||
| 150 | + self!.tableView.reloadEmptyDataSet() | ||
| 151 | + } | ||
| 152 | + } | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + func addRefreshView() { | ||
| 156 | + tableView.mj_footer = MJRefreshAutoNormalFooter.init(refreshingBlock: {[weak self] in | ||
| 157 | + self!.pageNum = self!.pageNum + 1 | ||
| 158 | + self!.loadDataSourceAction(page: self!.pageNum) | ||
| 159 | + }) | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + @objc func closeClick() { | ||
| 163 | + self.endEditing(true) | ||
| 164 | + listBackView.snp.remakeConstraints { make in | ||
| 165 | + make.left.right.equalToSuperview() | ||
| 166 | + make.top.equalTo(self.snp.bottom) | ||
| 167 | + make.height.equalTo(adapt_length(length: 390)) | ||
| 168 | + } | ||
| 169 | + removeFromSuperview() | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + @objc func keyboardWillShow(notification: NSNotification) { | ||
| 173 | + let userInfo = notification.userInfo! as NSDictionary | ||
| 174 | + let rect = (userInfo[UIResponder.keyboardFrameEndUserInfoKey] as! NSValue).cgRectValue | ||
| 175 | + let height = rect.size.height | ||
| 176 | + UIView.animate(withDuration: 1) { [self] in | ||
| 177 | + listBackView.snp.remakeConstraints { make in | ||
| 178 | + make.left.right.equalToSuperview() | ||
| 179 | + make.top.equalTo(self.snp.bottom).offset(-adapt_length(length: 300) - height) | ||
| 180 | + make.height.equalTo(adapt_length(length: 390)) | ||
| 181 | + } | ||
| 182 | + } | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + @objc func keyboardWillHide(notification: NSNotification) { | ||
| 186 | + UIView.animate(withDuration: 1) { [self] in | ||
| 187 | + listBackView.snp.remakeConstraints { make in | ||
| 188 | + make.left.right.equalToSuperview() | ||
| 189 | + make.top.equalTo(self.snp.bottom).offset(-adapt_length(length: 390)) | ||
| 190 | + make.height.equalTo(adapt_length(length: 390)) | ||
| 191 | + } | ||
| 192 | + } | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + static func couponGoodsShow(_ clickGoodsCallBack: @escaping clickCouponChooseGoodsCallBack) { | ||
| 196 | + let goodsView = ShopBodyCouponGoodsListView.init(frame: CGRect(x: 0, y: 0, width: KSreenWidth, height: KSreenHeight)) | ||
| 197 | + goodsView.clickGoodsCallBack = clickGoodsCallBack | ||
| 198 | + UIApplication.shared.delegate?.window?!.addSubview(goodsView) | ||
| 199 | + UIView.animate(withDuration: 1) { | ||
| 200 | + goodsView.listBackView.snp.remakeConstraints { make in | ||
| 201 | + make.left.right.bottom.equalTo(goodsView) | ||
| 202 | + make.top.equalTo(goodsView.snp.bottom).offset(-adapt_length(length: 390)) | ||
| 203 | + } | ||
| 204 | + } | ||
| 205 | + } | ||
| 206 | + | ||
| 207 | + required init?(coder: NSCoder) { | ||
| 208 | + fatalError("init(coder:) has not been implemented") | ||
| 209 | + } | ||
| 210 | + | ||
| 211 | + func numberOfSections(in tableView: UITableView) -> Int { | ||
| 212 | + return 1 | ||
| 213 | + } | ||
| 214 | + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
| 215 | + return dataArray.count | ||
| 216 | + } | ||
| 217 | + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
| 218 | + guard let cell = tableView.dequeueReusableCell(withIdentifier: kShopBodyCouponGoodsListTableViewCellIdentifier) as? ShopBodyCouponGoodsListTableViewCell else { | ||
| 219 | + return ShopBodyCouponGoodsListTableViewCell() | ||
| 220 | + } | ||
| 221 | + cell.setupWithDataSource(goodsModel: dataArray[indexPath.row] as! ShopOrderAssociatedGoodsModel) | ||
| 222 | + return cell | ||
| 223 | + } | ||
| 224 | + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { | ||
| 225 | + return adapt_length(length: 90) | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | ||
| 229 | + let model = dataArray[indexPath.row] as! ShopOrderAssociatedGoodsModel | ||
| 230 | + if (clickGoodsCallBack != nil) { | ||
| 231 | + clickGoodsCallBack(model) | ||
| 232 | + } | ||
| 233 | + closeClick() | ||
| 234 | + } | ||
| 235 | + | ||
| 236 | + | ||
| 237 | + func image(forEmptyDataSet scrollView: UIScrollView) -> UIImage? { | ||
| 238 | + if network_type == .failed || network_type == .unkonw { | ||
| 239 | + return UIImage(named: "mine_list_source_unusual_failed") | ||
| 240 | + } | ||
| 241 | + if dataArray.count == 0 { | ||
| 242 | + return UIImage(named: "mine_list_source_unusual_empty") | ||
| 243 | + } | ||
| 244 | + if network_type == .noNetwork { | ||
| 245 | + return UIImage(named: "mine_list_source_unusual_noNet") | ||
| 246 | + } | ||
| 247 | + return UIImage(named: "mine_list_source_unusual_empty") | ||
| 248 | + } | ||
| 249 | + | ||
| 250 | + func title(forEmptyDataSet scrollView: UIScrollView) -> NSAttributedString? { | ||
| 251 | + var defult_string = "" | ||
| 252 | + if network_type == .failed || network_type == .unkonw { | ||
| 253 | + defult_string = "接口请求错误,刷新试试~" | ||
| 254 | + } | ||
| 255 | + if network_type == .noNetwork { | ||
| 256 | + defult_string = "网络开小差了,刷新试试~" | ||
| 257 | + } | ||
| 258 | + if dataArray.count == 0 { | ||
| 259 | + defult_string = "暂时没有数据~" | ||
| 260 | + } | ||
| 261 | + return NSAttributedString(string: defult_string, attributes: [.font: Font_17,.foregroundColor: HexColor("#666666")!]) | ||
| 262 | + } | ||
| 263 | + | ||
| 264 | + func buttonTitle(forEmptyDataSet scrollView: UIScrollView, for state: UIControl.State) -> NSAttributedString? { | ||
| 265 | + if network_type == .failed || network_type == .noNetwork { | ||
| 266 | + let attributes = [NSAttributedString.Key.font:Font_16_Fit, | ||
| 267 | + NSAttributedString.Key.foregroundColor: HexColor("#609BFF")] | ||
| 268 | + return NSAttributedString(string: "刷一刷", attributes: attributes as [NSAttributedString.Key : Any]) | ||
| 269 | + } | ||
| 270 | + return nil | ||
| 271 | + } | ||
| 272 | + | ||
| 273 | + func emptyDataSet(_ scrollView: UIScrollView, didTapView view: UIView) { | ||
| 274 | + if network_type == .failed || network_type == .noNetwork { | ||
| 275 | + loadDataSourceAction(page: 1) | ||
| 276 | + } | ||
| 277 | + } | ||
| 278 | + | ||
| 279 | +} | ||
| 280 | + | ||
| 281 | +class ShopBodyCouponGoodsListTableViewCell: UITableViewCell { | ||
| 282 | + | ||
| 283 | + lazy var backView: UIView = { | ||
| 284 | + let backView = UIView.init() | ||
| 285 | + backView.backgroundColor = HexColor("#f9f9f9") | ||
| 286 | + backView.layer.cornerRadius = adapt_length(length: 6) | ||
| 287 | + return backView | ||
| 288 | + }() | ||
| 289 | + | ||
| 290 | + lazy var singImageView: UIImageView = { | ||
| 291 | + let singImageView = UIImageView.init() | ||
| 292 | + singImageView.contentMode = .scaleAspectFit | ||
| 293 | + singImageView.layer.cornerRadius = adapt_length(length: 5) | ||
| 294 | + return singImageView | ||
| 295 | + }() | ||
| 296 | + | ||
| 297 | + lazy var titleLabel: UILabel = { | ||
| 298 | + let titleLabel = UILabel.init() | ||
| 299 | + titleLabel.textAlignment = .justified | ||
| 300 | + titleLabel.numberOfLines = 2 | ||
| 301 | + titleLabel.textColor = HexColor("#333333") | ||
| 302 | + titleLabel.font = regular_adapt_font(pointSize: 13) | ||
| 303 | + return titleLabel | ||
| 304 | + }() | ||
| 305 | + | ||
| 306 | + lazy var priceLabel: UILabel = { | ||
| 307 | + let priceLabel = UILabel.init() | ||
| 308 | + priceLabel.font = regular_adapt_font(pointSize: 12) | ||
| 309 | + priceLabel.textAlignment = .left | ||
| 310 | + priceLabel.textColor = HexColor("#333333") | ||
| 311 | + return priceLabel | ||
| 312 | + }() | ||
| 313 | + | ||
| 314 | + lazy var sendBtn: UIButton = { | ||
| 315 | + let sendBtn = UIButton.init(type: .custom) | ||
| 316 | + let layer = CAGradientLayer() | ||
| 317 | + layer.frame = CGRect(x: 0, y: 0, width: adapt_length(length: 65), height: adapt_length(length: 19)) | ||
| 318 | + layer.startPoint = CGPoint(x: 0, y: 0.5) | ||
| 319 | + layer.endPoint = CGPoint(x: 1, y: 0.5) | ||
| 320 | + layer.locations = [0,1] | ||
| 321 | + layer.colors = [HexColor("#fd9700")?.cgColor as Any,HexColor("#ff5907")?.cgColor as Any] | ||
| 322 | + sendBtn.layer.addSublayer(layer) | ||
| 323 | + sendBtn.right = backView.width - 10 | ||
| 324 | + sendBtn.bottom = backView.bottom - 10 | ||
| 325 | + sendBtn.isUserInteractionEnabled = false | ||
| 326 | + sendBtn.setTitle("选择商品", for: .normal) | ||
| 327 | + sendBtn.setTitleColor(.white, for: .normal) | ||
| 328 | + sendBtn.titleLabel?.font = regular_adapt_font(pointSize: 13) | ||
| 329 | + sendBtn.layer.cornerRadius = adapt_length(length: 6) | ||
| 330 | + sendBtn.clipsToBounds = true | ||
| 331 | + return sendBtn | ||
| 332 | + }() | ||
| 333 | + | ||
| 334 | + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
| 335 | + super.init(style: style, reuseIdentifier: reuseIdentifier) | ||
| 336 | + contentView.backgroundColor = .clear | ||
| 337 | + selectionStyle = .none | ||
| 338 | + | ||
| 339 | + addSubview(backView) | ||
| 340 | + backView.snp.makeConstraints { make in | ||
| 341 | + make.top.equalToSuperview().offset(adapt_length(length: 10)) | ||
| 342 | + make.left.equalToSuperview().offset(adapt_length(length: 15)) | ||
| 343 | + make.right.equalToSuperview().offset(-adapt_length(length: 15)) | ||
| 344 | + make.bottom.equalToSuperview() | ||
| 345 | + } | ||
| 346 | + addSubview(singImageView) | ||
| 347 | + singImageView.snp.makeConstraints { make in | ||
| 348 | + make.left.top.equalTo(backView).offset(adapt_length(length: 10)) | ||
| 349 | + make.size.equalTo(adapt_length(length: 60)) | ||
| 350 | + } | ||
| 351 | + addSubview(titleLabel) | ||
| 352 | + titleLabel.snp.makeConstraints { make in | ||
| 353 | + make.left.equalTo(singImageView.snp.right).offset(adapt_length(length: 10)) | ||
| 354 | + make.right.equalTo(backView).offset(-adapt_length(length: 10)) | ||
| 355 | + make.top.equalTo(singImageView) | ||
| 356 | + } | ||
| 357 | + addSubview(priceLabel) | ||
| 358 | + priceLabel.snp.makeConstraints { make in | ||
| 359 | + make.left.equalTo(titleLabel) | ||
| 360 | + make.bottom.equalTo(singImageView) | ||
| 361 | + } | ||
| 362 | + addSubview(sendBtn) | ||
| 363 | + sendBtn.snp.makeConstraints { make in | ||
| 364 | + make.right.equalTo(titleLabel) | ||
| 365 | + make.bottom.equalTo(singImageView) | ||
| 366 | + make.width.equalTo(adapt_length(length: 65)) | ||
| 367 | + make.height.equalTo(adapt_length(length: 19)) | ||
| 368 | + } | ||
| 369 | + } | ||
| 370 | + | ||
| 371 | + func setupWithDataSource(goodsModel: ShopOrderAssociatedGoodsModel) { | ||
| 372 | + singImageView.kf.setImage(with: URL(string: goodsModel.simg!), placeholder: UIImage.imageWithColor(color: HexColor("#f9f9f9")!, size: CGSize(width: adapt_length(length: 60), height: adapt_length(length: 60)))) | ||
| 373 | + titleLabel.text = goodsModel.title | ||
| 374 | + priceLabel.text = "¥\(goodsModel.price ?? "0.00")" | ||
| 375 | + } | ||
| 376 | + | ||
| 377 | + required init?(coder: NSCoder) { | ||
| 378 | + fatalError("init(coder:) has not been implemented") | ||
| 379 | + } | ||
| 380 | + | ||
| 381 | +} | ||
| 382 | + | ||
| 383 | +class ShopBodyCouponGoodsSearchView: UIView, UITextFieldDelegate { | ||
| 384 | + | ||
| 385 | + lazy var searchTextField: UITextField = { | ||
| 386 | + let searchTextField = UITextField.init() | ||
| 387 | + | ||
| 388 | + let view = UIView.init(frame: CGRectMake(0, 0, adapt_length(length: 30), adapt_length(length: 30))) | ||
| 389 | + | ||
| 390 | + let imageView = UIImageView.init(frame: CGRect(x: adapt_length(length: 7), y: adapt_length(length: 4), width: adapt_length(length: 22), height: adapt_length(length: 22))) | ||
| 391 | + imageView.image = UIImage(named: "DS_order_search") | ||
| 392 | + imageView.clipsToBounds = true | ||
| 393 | + imageView.contentMode = .scaleAspectFit | ||
| 394 | + view.addSubview(imageView) | ||
| 395 | + | ||
| 396 | + searchTextField.leftView = view | ||
| 397 | + searchTextField.delegate = self | ||
| 398 | + searchTextField.leftViewMode = .always | ||
| 399 | + searchTextField.placeholder = "请输入商品名称或商品货号" | ||
| 400 | + searchTextField.backgroundColor = HexColor("#f0f0f0") | ||
| 401 | + searchTextField.returnKeyType = .search | ||
| 402 | + searchTextField.layer.cornerRadius = adapt_length(length: 15) | ||
| 403 | + searchTextField.layer.masksToBounds = true | ||
| 404 | + searchTextField.font = regular_adapt_font(pointSize: 13) | ||
| 405 | + return searchTextField | ||
| 406 | + }() | ||
| 407 | + | ||
| 408 | + lazy var searchButton: UIButton = { | ||
| 409 | + let searchButton = UIButton.init(type: .custom) | ||
| 410 | + searchButton.setTitle("搜索", for: .normal) | ||
| 411 | + searchButton.titleLabel?.font = semibold_adapt_font(pointSize: 15) | ||
| 412 | + searchButton.setTitleColor(HexColor("#ff3355"), for: .normal) | ||
| 413 | + searchButton.backgroundColor = .clear | ||
| 414 | + searchButton.layer.masksToBounds = true | ||
| 415 | + searchButton.layer.cornerRadius = 5 | ||
| 416 | + searchButton.addTarget(self, action: #selector(searchBtnClick), for: .touchUpInside) | ||
| 417 | + return searchButton | ||
| 418 | + }() | ||
| 419 | + | ||
| 420 | + var searchCallBack: clickCouponSearchTextFieldCallBack! | ||
| 421 | + override init(frame: CGRect) { | ||
| 422 | + super.init(frame: frame) | ||
| 423 | + backgroundColor = .clear | ||
| 424 | + | ||
| 425 | + addSubview(searchButton) | ||
| 426 | + searchButton.snp.makeConstraints { make in | ||
| 427 | + make.centerY.equalToSuperview() | ||
| 428 | + make.right.equalToSuperview().offset(-adapt_length(length: 15)) | ||
| 429 | + make.width.equalTo(adapt_length(length: 60)) | ||
| 430 | + make.height.equalTo(adapt_length(length: 25)) | ||
| 431 | + } | ||
| 432 | + | ||
| 433 | + addSubview(searchTextField) | ||
| 434 | + searchTextField.snp.makeConstraints { make in | ||
| 435 | + make.left.equalToSuperview().offset(adapt_length(length: 15)) | ||
| 436 | + make.centerY.centerY.equalToSuperview() | ||
| 437 | + make.right.equalTo(searchButton.snp.left).offset(-adapt_length(length: 15)) | ||
| 438 | + make.height.equalTo(adapt_length(length: 30)) | ||
| 439 | + } | ||
| 440 | + | ||
| 441 | + | ||
| 442 | + } | ||
| 443 | + | ||
| 444 | + @objc func searchBtnClick() { | ||
| 445 | + if (searchCallBack != nil) { | ||
| 446 | + searchCallBack(searchTextField.text!) | ||
| 447 | + } | ||
| 448 | + self.endEditing(true) | ||
| 449 | + } | ||
| 450 | + | ||
| 451 | + required init?(coder: NSCoder) { | ||
| 452 | + fatalError("init(coder:) has not been implemented") | ||
| 453 | + } | ||
| 454 | + | ||
| 455 | + func textFieldDidEndEditing(_ textField: UITextField) { | ||
| 456 | + if (searchCallBack != nil) { | ||
| 457 | + searchCallBack(textField.text!) | ||
| 458 | + } | ||
| 459 | + } | ||
| 460 | + | ||
| 461 | + func textFieldShouldReturn(_ textField: UITextField) -> Bool { | ||
| 462 | + self.endEditing(true) | ||
| 463 | + return true | ||
| 464 | + } | ||
| 465 | +} | ||
| 466 | + | ||
| 467 | + |
metaCode/Classes/Main/ShopPage/View/CNLiveShopBodyCouponView.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveShopCouponView.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by open on 2023/11/16. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | + | ||
| 10 | + | ||
| 11 | +typealias clickCouponGoodsHiddenCallBack = (_ isHidden: Bool) -> Void | ||
| 12 | +typealias clickCouponTextFieldCallBack = (_ section: String,_ number: String) -> Void | ||
| 13 | +typealias clickCouponDateSelectCallBack = (_ id: NSString,_ date: NSDate) -> Void | ||
| 14 | +typealias clickCouponGoodsCallBack = (_ goodsId: String) -> Void | ||
| 15 | +typealias clickCouponSelectCallBack = (_ section: NSInteger) -> Void | ||
| 16 | +class ShopBodyCouponCreateTableViewCell: UITableViewCell, UITextFieldDelegate { | ||
| 17 | + | ||
| 18 | + lazy var leftLabel: UILabel = { | ||
| 19 | + let leftLabel = UILabel.init() | ||
| 20 | + leftLabel.textColor = .red | ||
| 21 | + leftLabel.textAlignment = .center | ||
| 22 | + leftLabel.font = semibold_adapt_font(pointSize: 18) | ||
| 23 | + leftLabel.text = "*" | ||
| 24 | + return leftLabel | ||
| 25 | + }() | ||
| 26 | + | ||
| 27 | + lazy var titleLabel: UILabel = { | ||
| 28 | + let titleLabel = UILabel.init() | ||
| 29 | + titleLabel.textColor = HexColor("#333333") | ||
| 30 | + titleLabel.font = medium_adapt_font(pointSize: 14) | ||
| 31 | + return titleLabel | ||
| 32 | + }() | ||
| 33 | + | ||
| 34 | + lazy var lineView: UILabel = { | ||
| 35 | + let lineLabel = UILabel.init() | ||
| 36 | + lineLabel.backgroundColor = HexColor("#f6f6f6") | ||
| 37 | + return lineLabel | ||
| 38 | + }() | ||
| 39 | + | ||
| 40 | + lazy var titleNumber: UITextField = { | ||
| 41 | + let titleNumber = UITextField.init() | ||
| 42 | + titleNumber.textColor = HexColor("#333333") | ||
| 43 | + titleNumber.font = regular_adapt_font(pointSize: 14) | ||
| 44 | + titleNumber.textAlignment = .right | ||
| 45 | + titleNumber.delegate = self | ||
| 46 | + return titleNumber | ||
| 47 | + }() | ||
| 48 | + | ||
| 49 | + lazy var moneyView: ShopBodyCreateCouponTypeMoneyView = { | ||
| 50 | + let moneyView = ShopBodyCreateCouponTypeMoneyView.init(frame: CGRect.zero) | ||
| 51 | + moneyView.textFieldCallBack = { [weak self] section, number in | ||
| 52 | + if self!.textFieldCallBack != nil { | ||
| 53 | + self!.textFieldCallBack(section, number) | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + return moneyView | ||
| 57 | + }() | ||
| 58 | + | ||
| 59 | + lazy var chooseView: ShopBodySelectCouponTapView = { | ||
| 60 | + let chooseView = ShopBodySelectCouponTapView.init(frame: .zero) | ||
| 61 | + chooseView.selectCallBack = { [weak self] section in | ||
| 62 | + self!._couponModel.section = "\(section)" | ||
| 63 | + if self!._couponModel.id == "6" { | ||
| 64 | + if (self!.goodsHiddenCallBack != nil) { | ||
| 65 | + self!.goodsHiddenCallBack(section == 1) | ||
| 66 | + } | ||
| 67 | + } | ||
| 68 | + } | ||
| 69 | + return chooseView | ||
| 70 | + }() | ||
| 71 | + | ||
| 72 | + lazy var rightView: UIImageView = { | ||
| 73 | + let rightView = UIImageView.init() | ||
| 74 | + rightView.contentMode = .scaleAspectFit | ||
| 75 | + rightView.image = UIImage(named: "mine_header_message_gray_more") | ||
| 76 | + return rightView | ||
| 77 | + }() | ||
| 78 | + | ||
| 79 | + lazy var goodsLabel: UITextField = { | ||
| 80 | + let goodsLabel = UITextField.init() | ||
| 81 | + goodsLabel.textColor = HexColor("#333333") | ||
| 82 | + goodsLabel.font = regular_adapt_font(pointSize: 14) | ||
| 83 | + goodsLabel.textAlignment = .right | ||
| 84 | + goodsLabel.delegate = self | ||
| 85 | + goodsLabel.isEnabled = false | ||
| 86 | + return goodsLabel | ||
| 87 | + }() | ||
| 88 | + | ||
| 89 | + lazy var showSwitch: UISwitch = { | ||
| 90 | + let showSwitch = UISwitch.init() | ||
| 91 | + showSwitch.addTarget(self, action: #selector(switchChange), for: .valueChanged) | ||
| 92 | + return showSwitch | ||
| 93 | + }() | ||
| 94 | + | ||
| 95 | + var textFieldCallBack: clickCouponTextFieldCallBack! | ||
| 96 | + var goodsHiddenCallBack: clickCouponGoodsHiddenCallBack! | ||
| 97 | + var dateSelectCallBack: clickCouponDateSelectCallBack! | ||
| 98 | + var goodsCallBack: clickCouponGoodsCallBack! | ||
| 99 | + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
| 100 | + super.init(style: style, reuseIdentifier: reuseIdentifier) | ||
| 101 | + contentView.backgroundColor = .clear | ||
| 102 | + selectionStyle = .none | ||
| 103 | + currentDate = Date() as NSDate | ||
| 104 | + | ||
| 105 | + addSubview(leftLabel) | ||
| 106 | + leftLabel.snp.makeConstraints { make in | ||
| 107 | + make.centerY.equalToSuperview() | ||
| 108 | + make.left.equalToSuperview().offset(adapt_length(length: 5.5)) | ||
| 109 | + make.width.equalTo(adapt_length(length: 10)) | ||
| 110 | + make.height.equalTo(adapt_length(length: 15)) | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + addSubview(titleLabel) | ||
| 114 | + titleLabel.snp.makeConstraints { make in | ||
| 115 | + make.left.equalTo(leftLabel.snp.right).offset(adapt_length(length: 2.5)) | ||
| 116 | + make.centerY.equalToSuperview() | ||
| 117 | + make.width.equalTo(adapt_length(length: 70)) | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + addSubview(lineView) | ||
| 121 | + lineView.snp.makeConstraints { make in | ||
| 122 | + make.left.equalToSuperview().offset(adapt_length(length: 15)) | ||
| 123 | + make.right.equalToSuperview().offset(-adapt_length(length: 15)) | ||
| 124 | + make.height.equalTo(adapt_length(length: 0.5)) | ||
| 125 | + make.bottom.equalToSuperview() | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + addSubview(titleNumber) | ||
| 129 | + titleNumber.snp.makeConstraints { make in | ||
| 130 | + make.right.equalToSuperview().offset(-adapt_length(length: 15)) | ||
| 131 | + make.left.equalTo(titleLabel.snp.right) | ||
| 132 | + make.centerY.equalToSuperview() | ||
| 133 | + } | ||
| 134 | + addSubview(moneyView) | ||
| 135 | + moneyView.snp.makeConstraints { make in | ||
| 136 | + make.right.equalTo(titleNumber) | ||
| 137 | + make.centerY.height.equalToSuperview() | ||
| 138 | + make.left.equalTo(titleLabel.snp.right) | ||
| 139 | + } | ||
| 140 | + addSubview(chooseView) | ||
| 141 | + chooseView.snp.makeConstraints { make in | ||
| 142 | + make.right.equalTo(titleNumber) | ||
| 143 | + make.centerY.height.equalToSuperview() | ||
| 144 | + make.left.equalTo(titleLabel.snp.right) | ||
| 145 | + } | ||
| 146 | + addSubview(rightView) | ||
| 147 | + rightView.snp.makeConstraints { make in | ||
| 148 | + make.right.equalTo(titleNumber) | ||
| 149 | + make.centerY.height.equalToSuperview() | ||
| 150 | + make.width.height.equalTo(adapt_length(length: 16)) | ||
| 151 | + } | ||
| 152 | + addSubview(goodsLabel) | ||
| 153 | + goodsLabel.snp.makeConstraints { make in | ||
| 154 | + make.right.equalTo(rightView.snp.left).offset(-adapt_length(length: 5)) | ||
| 155 | + make.centerY.equalToSuperview() | ||
| 156 | + } | ||
| 157 | + addSubview(showSwitch) | ||
| 158 | + showSwitch.snp.makeConstraints { make in | ||
| 159 | + make.right.equalTo(titleNumber) | ||
| 160 | + make.centerY.equalToSuperview() | ||
| 161 | + } | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + var editEnabled: Bool! | ||
| 165 | + var currentDate: NSDate! | ||
| 166 | + var _couponModel: ShopOrderCouponDataModel! | ||
| 167 | + func setupWithDataSource(couponModel: ShopOrderCouponDataModel) { | ||
| 168 | + _couponModel = couponModel | ||
| 169 | + titleLabel.text = couponModel.title | ||
| 170 | + leftLabel.isHidden = true | ||
| 171 | + titleNumber.isHidden = true | ||
| 172 | + moneyView.isHidden = true | ||
| 173 | + chooseView.isHidden = true | ||
| 174 | + goodsLabel.isHidden = true | ||
| 175 | + rightView.isHidden = true | ||
| 176 | + showSwitch.isHidden = true | ||
| 177 | + if Int(couponModel.id!)!%5 == 0 { | ||
| 178 | + lineView.isHidden = true | ||
| 179 | + } else { | ||
| 180 | + lineView.isHidden = false | ||
| 181 | + } | ||
| 182 | + switch couponModel.type { | ||
| 183 | + case "1": | ||
| 184 | + leftLabel.isHidden = false | ||
| 185 | + titleNumber.isHidden = false | ||
| 186 | + titleNumber.isEnabled = true | ||
| 187 | + titleNumber.placeholder = couponModel.subTitle | ||
| 188 | + titleNumber.text = couponModel.message | ||
| 189 | + if couponModel.id == "3" { | ||
| 190 | + titleNumber.keyboardType = .numberPad | ||
| 191 | + } else { | ||
| 192 | + titleNumber.keyboardType = .default | ||
| 193 | + } | ||
| 194 | + break | ||
| 195 | + case "2": | ||
| 196 | + leftLabel.isHidden = false | ||
| 197 | + moneyView.isHidden = false | ||
| 198 | + moneyView.editEnabled = editEnabled | ||
| 199 | + moneyView._couponModel = couponModel | ||
| 200 | + break | ||
| 201 | + case "3": | ||
| 202 | + leftLabel.isHidden = false | ||
| 203 | + titleNumber.isHidden = false | ||
| 204 | + titleNumber.placeholder = couponModel.subTitle | ||
| 205 | + titleNumber.isEnabled = false | ||
| 206 | + if couponModel.message!.isNotBlank() { | ||
| 207 | + let interval = Double(couponModel.message!)! | ||
| 208 | + let formatter = DateFormatter.init() | ||
| 209 | + formatter.dateFormat = "yyyy-MM-dd" | ||
| 210 | + let date = NSDate.init(timeIntervalSince1970: interval) | ||
| 211 | + let dateStr = formatter.string(from: date as Date) | ||
| 212 | + titleNumber.text = dateStr | ||
| 213 | + } | ||
| 214 | + break | ||
| 215 | + case "4": | ||
| 216 | + chooseView.isHidden = false | ||
| 217 | + chooseView.editEnabled = editEnabled | ||
| 218 | + chooseView.titles = selectTitles(id: _couponModel.id!) | ||
| 219 | + chooseView.selectIndex = Int(couponModel.section!) | ||
| 220 | + break | ||
| 221 | + case "5": | ||
| 222 | + rightView.isHidden = false | ||
| 223 | + goodsLabel.isHidden = false | ||
| 224 | + goodsLabel.placeholder = couponModel.subTitle | ||
| 225 | + goodsLabel.text = couponModel.message | ||
| 226 | + break | ||
| 227 | + case "6": | ||
| 228 | + showSwitch.isHidden = false | ||
| 229 | + if couponModel.section == "1" { | ||
| 230 | + showSwitch.isOn = true | ||
| 231 | + } else { | ||
| 232 | + showSwitch.isOn = false | ||
| 233 | + } | ||
| 234 | + break | ||
| 235 | + default: | ||
| 236 | + break | ||
| 237 | + } | ||
| 238 | + } | ||
| 239 | + | ||
| 240 | + override func setSelected(_ selected: Bool, animated: Bool) { | ||
| 241 | + if _couponModel.type == "3" && selected { | ||
| 242 | + if !editEnabled { | ||
| 243 | + showMessage(message: "该项不可编辑") | ||
| 244 | + return | ||
| 245 | + } | ||
| 246 | + MineStandListAlertView.showStandListView(infos: [currentDate!,"YYYY-MM-dd"], name:_couponModel.subTitle!, show_type:.min_date, result: { [self] text in | ||
| 247 | + currentDate = (text as! NSString).timeStrChangeTotimedate("YYYY-MM-dd") | ||
| 248 | + titleNumber.text = (text as! String) | ||
| 249 | + if (dateSelectCallBack != nil) { | ||
| 250 | + let formatter = DateFormatter.init() | ||
| 251 | + formatter.dateFormat = "yyyy-MM-dd" | ||
| 252 | + formatter.timeZone = NSTimeZone.local | ||
| 253 | + dateSelectCallBack(_couponModel.id! as NSString,formatter.date(from: text as! String)! as NSDate) | ||
| 254 | + } | ||
| 255 | + }) | ||
| 256 | + } else if _couponModel.type == "5" && selected { | ||
| 257 | + if !editEnabled { | ||
| 258 | + showMessage(message: "该项不可编辑") | ||
| 259 | + return | ||
| 260 | + } | ||
| 261 | + ShopBodyCouponGoodsListView.couponGoodsShow { [self] model in | ||
| 262 | + if (goodsCallBack != nil) { | ||
| 263 | + goodsCallBack(model.id ?? "") | ||
| 264 | + } | ||
| 265 | + if model.title!.count > 20 { | ||
| 266 | + goodsLabel.text = (model.title! as NSString).substring(with: NSRange(location: 0, length: 20)) | ||
| 267 | + } else { | ||
| 268 | + goodsLabel.text = model.title | ||
| 269 | + } | ||
| 270 | + } | ||
| 271 | + } | ||
| 272 | + } | ||
| 273 | + | ||
| 274 | + required init?(coder: NSCoder) { | ||
| 275 | + fatalError("init(coder:) has not been implemented") | ||
| 276 | + } | ||
| 277 | + | ||
| 278 | + @objc func switchChange(sender: UISwitch) { | ||
| 279 | + _couponModel.section = sender.isOn ? "1" : "2" | ||
| 280 | + } | ||
| 281 | + | ||
| 282 | + func selectTitles(id: String) -> NSArray { | ||
| 283 | + var selectTitles: NSArray = [] | ||
| 284 | + switch id { | ||
| 285 | + case "6": | ||
| 286 | + selectTitles = ["店铺全场","单个商品"] | ||
| 287 | + break | ||
| 288 | + case "8": | ||
| 289 | + selectTitles = ["正常","冻结"] | ||
| 290 | + break | ||
| 291 | + case "9": | ||
| 292 | + selectTitles = ["不限","限一次"] | ||
| 293 | + break | ||
| 294 | + default: | ||
| 295 | + break | ||
| 296 | + } | ||
| 297 | + return selectTitles | ||
| 298 | + } | ||
| 299 | + | ||
| 300 | + func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool { | ||
| 301 | + if _couponModel.id != "1" { | ||
| 302 | + if !editEnabled { | ||
| 303 | + showMessage(message: "该项不可编辑") | ||
| 304 | + return false | ||
| 305 | + } | ||
| 306 | + } | ||
| 307 | + return true | ||
| 308 | + } | ||
| 309 | + | ||
| 310 | + func textFieldDidEndEditing(_ textField: UITextField) { | ||
| 311 | + if (textFieldCallBack != nil) { | ||
| 312 | + if _couponModel.id == "1" { | ||
| 313 | + _couponModel.message = textField.text | ||
| 314 | + } | ||
| 315 | + textFieldCallBack(_couponModel.id!, textField.text!) | ||
| 316 | + } | ||
| 317 | + } | ||
| 318 | + | ||
| 319 | + func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { | ||
| 320 | + if _couponModel.id == "1" { | ||
| 321 | + if textField.text!.count + string.count > 20 { | ||
| 322 | + textField.text = textField.text! + (string as NSString).substring(with: NSMakeRange(0, 20-textField.text!.count)) | ||
| 323 | + return false | ||
| 324 | + } | ||
| 325 | + return true | ||
| 326 | + } | ||
| 327 | + return true | ||
| 328 | + } | ||
| 329 | +} | ||
| 330 | + | ||
| 331 | + | ||
| 332 | +class ShopBodyCreateCouponTypeMoneyView: UIView, UITextFieldDelegate { | ||
| 333 | + | ||
| 334 | + lazy var man1Label: UILabel = { | ||
| 335 | + let man1Label = UILabel.init() | ||
| 336 | + man1Label.textColor = HexColor("#999999") | ||
| 337 | + man1Label.font = regular_adapt_font(pointSize: 14) | ||
| 338 | + man1Label.text = "满" | ||
| 339 | + return man1Label | ||
| 340 | + }() | ||
| 341 | + | ||
| 342 | + lazy var maxPut: UITextField = { | ||
| 343 | + let maxPut = UITextField.init() | ||
| 344 | + maxPut.textColor = HexColor("#333333") | ||
| 345 | + maxPut.font = regular_adapt_font(pointSize: 14) | ||
| 346 | + maxPut.delegate = self | ||
| 347 | + maxPut.tag = 1001 | ||
| 348 | + maxPut.textAlignment = .center | ||
| 349 | + maxPut.backgroundColor = HexColor("#f9f9f9") | ||
| 350 | + maxPut.keyboardType = .numberPad | ||
| 351 | + let path = UIBezierPath.init(roundedRect: CGRectMake(0, 0, adapt_length(length: 60), adapt_length(length: 29)), byRoundingCorners: .allCorners, cornerRadii: CGSize(width: adapt_length(length: 4), height: adapt_length(length: 4))) | ||
| 352 | + let shapelayer = CAShapeLayer() | ||
| 353 | + shapelayer.path = path.cgPath | ||
| 354 | + maxPut.layer.mask = shapelayer | ||
| 355 | + return maxPut | ||
| 356 | + }() | ||
| 357 | + | ||
| 358 | + lazy var midLabel: UILabel = { | ||
| 359 | + let midLabel = UILabel.init() | ||
| 360 | + midLabel.textColor = HexColor("#999999") | ||
| 361 | + midLabel.font = regular_adapt_font(pointSize: 14) | ||
| 362 | + midLabel.text = "元减" | ||
| 363 | + return midLabel | ||
| 364 | + }() | ||
| 365 | + | ||
| 366 | + lazy var lessPut: UITextField = { | ||
| 367 | + let lessPut = UITextField.init() | ||
| 368 | + lessPut.textColor = HexColor("#333333") | ||
| 369 | + lessPut.font = regular_adapt_font(pointSize: 14) | ||
| 370 | + lessPut.delegate = self | ||
| 371 | + lessPut.tag = 1002 | ||
| 372 | + lessPut.textAlignment = .center | ||
| 373 | + lessPut.backgroundColor = HexColor("#f9f9f9") | ||
| 374 | + lessPut.keyboardType = .numberPad | ||
| 375 | + let path = UIBezierPath.init(roundedRect: CGRectMake(0, 0, adapt_length(length: 60), adapt_length(length: 29)), byRoundingCorners: .allCorners, cornerRadii: CGSize(width: adapt_length(length: 4), height: adapt_length(length: 4))) | ||
| 376 | + let shapelayer = CAShapeLayer() | ||
| 377 | + shapelayer.path = path.cgPath | ||
| 378 | + lessPut.layer.mask = shapelayer | ||
| 379 | + return lessPut | ||
| 380 | + }() | ||
| 381 | + | ||
| 382 | + lazy var lastLabel: UILabel = { | ||
| 383 | + let lastLabel = UILabel.init() | ||
| 384 | + lastLabel.textColor = HexColor("#999999") | ||
| 385 | + lastLabel.font = regular_adapt_font(pointSize: 14) | ||
| 386 | + lastLabel.text = "元" | ||
| 387 | + return lastLabel | ||
| 388 | + }() | ||
| 389 | + | ||
| 390 | + var editEnabled: Bool! | ||
| 391 | + var _couponModel: ShopOrderCouponDataModel! | ||
| 392 | + var textFieldCallBack: clickCouponTextFieldCallBack! | ||
| 393 | + override init(frame: CGRect) { | ||
| 394 | + super.init(frame: frame) | ||
| 395 | + addSubview(lastLabel) | ||
| 396 | + lastLabel.snp.makeConstraints { make in | ||
| 397 | + make.right.centerY.equalToSuperview() | ||
| 398 | + } | ||
| 399 | + addSubview(lessPut) | ||
| 400 | + lessPut.snp.makeConstraints { make in | ||
| 401 | + make.right.equalTo(lastLabel.snp.left).offset(-adapt_length(length: 10)) | ||
| 402 | + make.centerY.equalToSuperview() | ||
| 403 | + make.width.equalTo(adapt_length(length: 60)) | ||
| 404 | + make.height.equalTo(adapt_length(length: 29)) | ||
| 405 | + } | ||
| 406 | + addSubview(midLabel) | ||
| 407 | + midLabel.snp.makeConstraints { make in | ||
| 408 | + make.centerY.equalToSuperview() | ||
| 409 | + make.right.equalTo(lessPut.snp.left).offset(-adapt_length(length: 10)) | ||
| 410 | + } | ||
| 411 | + addSubview(maxPut) | ||
| 412 | + maxPut.snp.makeConstraints { make in | ||
| 413 | + make.right.equalTo(midLabel.snp.left).offset(-adapt_length(length: 10)) | ||
| 414 | + make.centerY.equalToSuperview() | ||
| 415 | + make.width.equalTo(adapt_length(length: 60)) | ||
| 416 | + make.height.equalTo(adapt_length(length: 29)) | ||
| 417 | + } | ||
| 418 | + addSubview(man1Label) | ||
| 419 | + man1Label.snp.makeConstraints { make in | ||
| 420 | + make.centerY.equalToSuperview() | ||
| 421 | + make.right.equalTo(maxPut.snp.left).offset(-adapt_length(length: 10)) | ||
| 422 | + } | ||
| 423 | + } | ||
| 424 | + | ||
| 425 | + func setupWithDataSource(couponModel: ShopOrderCouponDataModel) { | ||
| 426 | + _couponModel = couponModel | ||
| 427 | + | ||
| 428 | + maxPut.text = couponModel.filled | ||
| 429 | + lessPut.text = couponModel.disCount | ||
| 430 | + } | ||
| 431 | + | ||
| 432 | + required init?(coder: NSCoder) { | ||
| 433 | + fatalError("init(coder:) has not been implemented") | ||
| 434 | + } | ||
| 435 | + | ||
| 436 | + func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool { | ||
| 437 | + if !editEnabled { | ||
| 438 | + showMessage(message: "该项不可编辑") | ||
| 439 | + return false | ||
| 440 | + } | ||
| 441 | + return true | ||
| 442 | + } | ||
| 443 | + func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { | ||
| 444 | + if string == "" { | ||
| 445 | + return true | ||
| 446 | + } | ||
| 447 | + if !string.isNotBlank() { | ||
| 448 | + return false | ||
| 449 | + } | ||
| 450 | + let cs = NSCharacterSet.init(charactersIn: "0123456789.").inverted | ||
| 451 | + let filtered = (string.components(separatedBy: cs) as NSArray).componentsJoined(by: "") | ||
| 452 | + if string != filtered { | ||
| 453 | + return false | ||
| 454 | + } | ||
| 455 | + return true | ||
| 456 | + } | ||
| 457 | + func textFieldDidEndEditing(_ textField: UITextField) { | ||
| 458 | + if textFieldCallBack != nil { | ||
| 459 | + textFieldCallBack("\(textField.tag)",textField.text!) | ||
| 460 | + } | ||
| 461 | + } | ||
| 462 | +} | ||
| 463 | + | ||
| 464 | +class ShopBodySelectCouponTapView: UIView { | ||
| 465 | + | ||
| 466 | + var _titles: NSArray? | ||
| 467 | + var titles: NSArray? { | ||
| 468 | + get { | ||
| 469 | + return _titles | ||
| 470 | + } | ||
| 471 | + set { | ||
| 472 | + _titles = newValue | ||
| 473 | + titles?.enumerateObjects({ obj, idx, stop in | ||
| 474 | + let btn = UIButton.init(type: .custom) | ||
| 475 | + btn.setTitleColor(HexColor("#666666"), for: .normal) | ||
| 476 | + btn.setTitle(obj as? String, for: .normal) | ||
| 477 | + btn.setImage(UIImage(named: "DS_coupon_unSelect"), for: .normal) | ||
| 478 | + btn.titleLabel?.font = regular_adapt_font(pointSize: 15) | ||
| 479 | + btn.setImage(UIImage(named: "DS_coupon_select"), for: .selected) | ||
| 480 | + btn.tag = 1001+idx | ||
| 481 | + btn.addTarget(self, action: #selector(selectIndexClick), for: .touchUpInside) | ||
| 482 | + addSubview(btn) | ||
| 483 | + btnArray.add(btn) | ||
| 484 | + }) | ||
| 485 | + let btn1 = btnArray[1] as! UIButton | ||
| 486 | + let btn2 = btnArray[0] as! UIButton | ||
| 487 | + var width1: CGFloat = 0.0 | ||
| 488 | + if (titles![1] as! String).count == 4 { | ||
| 489 | + width1 = adapt_length(length: 83) | ||
| 490 | + } else if (titles![1] as! String).count == 3 { | ||
| 491 | + width1 = adapt_length(length: 68) | ||
| 492 | + } else if (titles![1] as! String).count == 2 { | ||
| 493 | + width1 = adapt_length(length: 53) | ||
| 494 | + } | ||
| 495 | + btn1.snp.makeConstraints { make in | ||
| 496 | + make.right.equalToSuperview() | ||
| 497 | + make.width.equalTo(width1) | ||
| 498 | + make.height.equalToSuperview() | ||
| 499 | + } | ||
| 500 | + var width2: CGFloat = 0.0 | ||
| 501 | + if (titles![0] as! String).count == 4 { | ||
| 502 | + width2 = adapt_length(length: 83) | ||
| 503 | + } else if (titles![0] as! String).count == 3 { | ||
| 504 | + width2 = adapt_length(length: 68) | ||
| 505 | + } else if (titles![0] as! String).count == 2 { | ||
| 506 | + width2 = adapt_length(length: 53) | ||
| 507 | + } | ||
| 508 | + btn2.snp.makeConstraints { make in | ||
| 509 | + make.right.equalTo(btn1.snp.left).offset(-adapt_length(length: 30)) | ||
| 510 | + make.width.equalTo(width2) | ||
| 511 | + make.height.equalToSuperview() | ||
| 512 | + } | ||
| 513 | + } | ||
| 514 | + } | ||
| 515 | + var _selectIndex: NSInteger? | ||
| 516 | + var selectIndex: NSInteger? { | ||
| 517 | + get { | ||
| 518 | + return _selectIndex | ||
| 519 | + } | ||
| 520 | + set { | ||
| 521 | + _selectIndex = newValue | ||
| 522 | + for item in btnArray { | ||
| 523 | + let btn = item as! UIButton | ||
| 524 | + if btn.tag - 1000 == selectIndex { | ||
| 525 | + btn.isSelected = true | ||
| 526 | + } else { | ||
| 527 | + btn.isSelected = false | ||
| 528 | + } | ||
| 529 | + } | ||
| 530 | + } | ||
| 531 | + } | ||
| 532 | + | ||
| 533 | + lazy var btnArray: NSMutableArray = { | ||
| 534 | + let btnArray = NSMutableArray.init() | ||
| 535 | + return btnArray | ||
| 536 | + }() | ||
| 537 | + | ||
| 538 | + var editEnabled: Bool! | ||
| 539 | + var selectCallBack: clickCouponSelectCallBack! | ||
| 540 | + override init(frame: CGRect) { | ||
| 541 | + super.init(frame: frame) | ||
| 542 | + | ||
| 543 | + } | ||
| 544 | + | ||
| 545 | + @objc func selectIndexClick(sender: UIButton) { | ||
| 546 | + if !editEnabled { | ||
| 547 | + showMessage(message: "该项不可编辑") | ||
| 548 | + return | ||
| 549 | + } | ||
| 550 | + for item in btnArray { | ||
| 551 | + let btn = item as! UIButton | ||
| 552 | + if btn.tag == sender.tag { | ||
| 553 | + btn.isSelected = true | ||
| 554 | + if (selectCallBack != nil) { | ||
| 555 | + selectCallBack(sender.tag - 1000) | ||
| 556 | + } | ||
| 557 | + } else { | ||
| 558 | + btn.isSelected = false | ||
| 559 | + } | ||
| 560 | + } | ||
| 561 | + } | ||
| 562 | + | ||
| 563 | + required init?(coder: NSCoder) { | ||
| 564 | + fatalError("init(coder:) has not been implemented") | ||
| 565 | + } | ||
| 566 | +} | ||
| 567 | + | ||
| 568 | + | ||
| 569 | + | ||
| 570 | + |
metaCode/Classes/Main/ShopPage/ViewModel/CNLiveShopViewModel.swift
| @@ -627,4 +627,322 @@ class CNLiveShopViewModel: NSObject { | @@ -627,4 +627,322 @@ class CNLiveShopViewModel: NSObject { | ||
| 627 | } | 627 | } |
| 628 | } | 628 | } |
| 629 | 629 | ||
| 630 | + /// 获取店铺商品列表 | ||
| 631 | + /// - Parameters: | ||
| 632 | + /// - shopId: 店铺id | ||
| 633 | + /// - sortType: 排序类型 | ||
| 634 | + /// - state: 类型 | ||
| 635 | + /// - categoryId: 类别id | ||
| 636 | + /// - keyword: 搜索关键词 | ||
| 637 | + /// - page: 页数 | ||
| 638 | + /// - resultBlock: 返回 | ||
| 639 | + static func requestCouponSearchGoods(shopId: String,sortType: String,state: String,categoryId: String,keyword: String,page: NSInteger,resultBlock: @escaping resultShopBlock) { | ||
| 640 | + let param = NSMutableDictionary() | ||
| 641 | + param.setValue(shopId, forKey: "shop_id") | ||
| 642 | + param.setValue(sortType, forKey: "type") | ||
| 643 | + param.setValue(state, forKey: "state") | ||
| 644 | + param.setValue(categoryId, forKey: "category_id") | ||
| 645 | + param.setValue(keyword, forKey: "keyword") | ||
| 646 | + param.setValue("\(page)", forKey: "page") | ||
| 647 | + let custom_param = NSMutableDictionary() | ||
| 648 | + custom_param.setValue(APPId_wjj, forKey: "appId") | ||
| 649 | + custom_param.setValue(APPKey_wjj, forKey: "appKey") | ||
| 650 | + CNLiveNetworking.setAllowRequestDefaultArgument(true) | ||
| 651 | + CNLiveNetworking.setupShowDataResult(false) | ||
| 652 | + CNLiveNetworking.setupDSRequest(true) | ||
| 653 | + CNLiveNetworking.setupCustomParam(custom_param as? [String : String]) | ||
| 654 | + CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseWjjBUrl+"/api/v1/getGoodsList", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in | ||
| 655 | + hiddenLoading() | ||
| 656 | + if (error == nil) { | ||
| 657 | + let resp = result as! NSDictionary | ||
| 658 | + let errorCode = "\(resp["code"] ?? "0")" | ||
| 659 | + if (errorCode == "200") { | ||
| 660 | + if resp["data"] is NSNull { | ||
| 661 | + resultBlock(NSNull(),.failed) | ||
| 662 | + } else { | ||
| 663 | + let array = resp["data"] as! NSArray | ||
| 664 | + let tempArray = NSMutableArray() | ||
| 665 | + for item in array { | ||
| 666 | + let listModel = dictionaryToModel(item as! [String : Any], ShopOrderAssociatedGoodsModel.self,"") as! ShopOrderAssociatedGoodsModel | ||
| 667 | + tempArray.add(listModel) | ||
| 668 | + } | ||
| 669 | + resultBlock(tempArray, .success) | ||
| 670 | + } | ||
| 671 | + } else { | ||
| 672 | + showMessage(message: resp["message"] as! String) | ||
| 673 | + resultBlock(NSNull(),.failed) | ||
| 674 | + } | ||
| 675 | + } else { | ||
| 676 | + if CNLiveNetworking.isNetworking() { | ||
| 677 | + showMessage(message: "请求失败") | ||
| 678 | + resultBlock(NSNull(),.failed) | ||
| 679 | + } else { | ||
| 680 | + showMessage(message: "似乎与网络断开链接") | ||
| 681 | + resultBlock(NSNull(),.noNetwork) | ||
| 682 | + } | ||
| 683 | + } | ||
| 684 | + } | ||
| 685 | + } | ||
| 686 | + | ||
| 687 | + | ||
| 688 | + /// 构建创建优惠券相关数据 | ||
| 689 | + /// - Parameter resultBlock: 返回 | ||
| 690 | + static func requestCoupon(model: ShopOrderCouponListModel ,resultBlock: @escaping resultShopBlock) { | ||
| 691 | + let array: NSMutableArray = NSMutableArray(array: [ | ||
| 692 | + [ | ||
| 693 | + [ | ||
| 694 | + "id":"1", | ||
| 695 | + "type":"1", | ||
| 696 | + "title":"名称", | ||
| 697 | + "subTitle":"请输入(20字以内)", | ||
| 698 | + "section":"1", | ||
| 699 | + "message":model.title ?? "" | ||
| 700 | + ], | ||
| 701 | + [ | ||
| 702 | + "id":"2", | ||
| 703 | + "type":"2", | ||
| 704 | + "title":"满减折扣", | ||
| 705 | + "subTitle":"", | ||
| 706 | + "section":"1", | ||
| 707 | + "filled":model.filled ?? "", | ||
| 708 | + "disCount":model.discount ?? "" | ||
| 709 | + ] as [String : Any], | ||
| 710 | + [ | ||
| 711 | + "id":"3", | ||
| 712 | + "type":"1", | ||
| 713 | + "title":"数量", | ||
| 714 | + "subTitle":"请输入数量", | ||
| 715 | + "section":"1", | ||
| 716 | + "message":model.num ?? "" | ||
| 717 | + ], | ||
| 718 | + [ | ||
| 719 | + "id":"4", | ||
| 720 | + "type":"3", | ||
| 721 | + "title":"开始时间", | ||
| 722 | + "subTitle":"请选择开始时间", | ||
| 723 | + "section":"1", | ||
| 724 | + "message":model.starttime ?? "" | ||
| 725 | + ], | ||
| 726 | + [ | ||
| 727 | + "id":"5", | ||
| 728 | + "type":"3", | ||
| 729 | + "title":"结束时间", | ||
| 730 | + "subTitle":"请选择结束时间", | ||
| 731 | + "section":"1", | ||
| 732 | + "message":model.endtime ?? "" | ||
| 733 | + ], | ||
| 734 | + ], | ||
| 735 | + [ | ||
| 736 | + [ | ||
| 737 | + "id":"6", | ||
| 738 | + "type":"4", | ||
| 739 | + "title":"所属类型", | ||
| 740 | + "subTitle":"", | ||
| 741 | + "section":(model.sort?.isNotBlank())! && model.sort != "1" ? "2":"1", | ||
| 742 | + ], | ||
| 743 | + [ | ||
| 744 | + "id":"7", | ||
| 745 | + "type":"5", | ||
| 746 | + "title":"优惠商品", | ||
| 747 | + "subTitle":"请选择", | ||
| 748 | + "section":"1", | ||
| 749 | + "message":model.goods_title ?? "" | ||
| 750 | + ], | ||
| 751 | + [ | ||
| 752 | + "id":"8", | ||
| 753 | + "type":"4", | ||
| 754 | + "title":"领取状态", | ||
| 755 | + "subTitle":"", | ||
| 756 | + "section":(model.state?.isNotBlank())! && model.state != "1" ? "2":"1", | ||
| 757 | + ], | ||
| 758 | + [ | ||
| 759 | + "id":"9", | ||
| 760 | + "type":"4", | ||
| 761 | + "title":"领取次数", | ||
| 762 | + "subTitle":"", | ||
| 763 | + "section":(model.receive_number?.isNotBlank())! && model.receive_number != "1" ? "2":"1", | ||
| 764 | + ] as [String : Any], | ||
| 765 | + [ | ||
| 766 | + "id":"10", | ||
| 767 | + "type":"6", | ||
| 768 | + "title":"显示状态", | ||
| 769 | + "subTitle":"", | ||
| 770 | + "section":(model.is_show?.isNotBlank())! && model.is_show != "1" ?"2":"1", | ||
| 771 | + ], | ||
| 772 | + ] | ||
| 773 | + ]) | ||
| 774 | + let dataArr = NSMutableArray.init() | ||
| 775 | + for subArr in array { | ||
| 776 | + let temp_array = subArr as! NSArray | ||
| 777 | + let dataSubArr = NSMutableArray.init() | ||
| 778 | + for dict in temp_array { | ||
| 779 | + let model = dictionaryToModel(dict as! [String : Any], ShopOrderCouponDataModel.self,"") as! ShopOrderCouponDataModel | ||
| 780 | + dataSubArr.add(model) | ||
| 781 | + } | ||
| 782 | + dataArr.add(dataSubArr) | ||
| 783 | + } | ||
| 784 | + resultBlock(dataArr,.success) | ||
| 785 | + } | ||
| 786 | + | ||
| 787 | + /// 发布优惠券 | ||
| 788 | + /// - Parameters: | ||
| 789 | + /// - title: 优惠券标题 | ||
| 790 | + /// - filled: 满多少 | ||
| 791 | + /// - discount: 减多少 | ||
| 792 | + /// - startTime: 开始时间戳 | ||
| 793 | + /// - endTime: 结束时间戳 | ||
| 794 | + /// - state: 是否开启 1 开启 2 关闭 | ||
| 795 | + /// - isShow: 是否显示 1 对外显示 2 不对外 | ||
| 796 | + /// - receiveNum: 领取次数 1 不限制 2 限领一次 | ||
| 797 | + /// - totalNum: 优惠券数量 -1 为不限量 | ||
| 798 | + /// - goodsType: 所属类型 1全场 2 单品,判断需要 | ||
| 799 | + /// - goodsId: 商品id 单品优惠券传此值 | ||
| 800 | + /// - resultBlock: 返回 | ||
| 801 | + static func requestCouponCreate(title: String,filled: String,discount: String, startTime: String,endTime: String,state: String,isShow: String, receiveNum: String,totalNum: String, goodsType: String,goodsId: String,resultBlock: @escaping resultShopBlock) { | ||
| 802 | + if !title.isNotBlank() { | ||
| 803 | + showMessage(message: "优惠券名称不能为空") | ||
| 804 | + return | ||
| 805 | + } | ||
| 806 | + if !filled.isNotBlank() || !discount.isNotBlank() { | ||
| 807 | + showMessage(message: "优惠券满减金额不能为空") | ||
| 808 | + return | ||
| 809 | + } | ||
| 810 | + if Float(discount)! > Float(filled)! { | ||
| 811 | + showMessage(message: "减免金额不可大于总金额") | ||
| 812 | + return | ||
| 813 | + } | ||
| 814 | + if !totalNum.isNotBlank() { | ||
| 815 | + showMessage(message: "优惠券总数量不能为空") | ||
| 816 | + return | ||
| 817 | + } | ||
| 818 | + if Int(totalNum)! <= 0 { | ||
| 819 | + showMessage(message: "优惠券总数量必须大于0") | ||
| 820 | + return | ||
| 821 | + } | ||
| 822 | + if !startTime.isNotBlank() { | ||
| 823 | + showMessage(message: "优惠券开始时间不能为空") | ||
| 824 | + return | ||
| 825 | + } | ||
| 826 | + if !endTime.isNotBlank() { | ||
| 827 | + showMessage(message: "优惠券结束时间不能为空") | ||
| 828 | + return | ||
| 829 | + } | ||
| 830 | + if Float(startTime)! >= Float(endTime)! { | ||
| 831 | + showMessage(message: "结束时间必须大于开始时间") | ||
| 832 | + return | ||
| 833 | + } | ||
| 834 | + if goodsType == "2" && !goodsId.isNotBlank() { | ||
| 835 | + showMessage(message: "请选择需要优惠的商品") | ||
| 836 | + return | ||
| 837 | + } | ||
| 838 | + let param = NSMutableDictionary() | ||
| 839 | + param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "uid") | ||
| 840 | + param.setValue(title, forKey: "title") | ||
| 841 | + param.setValue(filled, forKey: "filled") | ||
| 842 | + param.setValue(discount, forKey: "discount") | ||
| 843 | + param.setValue(startTime, forKey: "startTime") | ||
| 844 | + param.setValue(endTime, forKey: "endTime") | ||
| 845 | + param.setValue(state, forKey: "state") | ||
| 846 | + param.setValue(isShow, forKey: "is_show") | ||
| 847 | + param.setValue(receiveNum, forKey: "receive_number") | ||
| 848 | + param.setValue(totalNum, forKey: "num") | ||
| 849 | + param.setValue(goodsId, forKey: "goods_id") | ||
| 850 | + print("创建优惠券数据===>\(param)") | ||
| 851 | + let custom_param = NSMutableDictionary() | ||
| 852 | + custom_param.setValue(APPId_wjj, forKey: "appId") | ||
| 853 | + custom_param.setValue(APPKey_wjj, forKey: "appKey") | ||
| 854 | + CNLiveNetworking.setAllowRequestDefaultArgument(true) | ||
| 855 | + CNLiveNetworking.setupShowDataResult(false) | ||
| 856 | + CNLiveNetworking.setupDSRequest(true) | ||
| 857 | + CNLiveNetworking.setupCustomParam(custom_param as? [String : String]) | ||
| 858 | + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseWjjBUrl+"/api/v1/addCoupon", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in | ||
| 859 | + hiddenLoading() | ||
| 860 | + if (error == nil) { | ||
| 861 | + let resp = result as! NSDictionary | ||
| 862 | + let errorCode = "\(resp["code"] ?? "0")" | ||
| 863 | + if (errorCode == "200") { | ||
| 864 | + if resp["data"] is NSNull { | ||
| 865 | + resultBlock(NSNull(),.failed) | ||
| 866 | + } else { | ||
| 867 | + resultBlock("提交成功", .success) | ||
| 868 | + } | ||
| 869 | + } else { | ||
| 870 | + showMessage(message: resp["message"] as! String) | ||
| 871 | + resultBlock(NSNull(),.failed) | ||
| 872 | + } | ||
| 873 | + } else { | ||
| 874 | + if CNLiveNetworking.isNetworking() { | ||
| 875 | + showMessage(message: "提交失败") | ||
| 876 | + resultBlock(NSNull(),.failed) | ||
| 877 | + } else { | ||
| 878 | + showMessage(message: "似乎与网络断开链接") | ||
| 879 | + resultBlock(NSNull(),.noNetwork) | ||
| 880 | + } | ||
| 881 | + } | ||
| 882 | + } | ||
| 883 | + } | ||
| 884 | + | ||
| 885 | + /// 修改优惠券 | ||
| 886 | + /// - Parameters: | ||
| 887 | + /// - model: 优惠券数据 | ||
| 888 | + /// - title: 优惠券标题 | ||
| 889 | + /// - state: 是否开启 1 开启 2 关闭 | ||
| 890 | + /// - isShow: 是否显示 1 对外显示 2 不对外 | ||
| 891 | + /// - receiveNum: 领取次数 1 不限制 2 限领一次 | ||
| 892 | + /// - resultBlock: 返回 | ||
| 893 | + static func requestCouponEdit(model: ShopOrderCouponListModel,title: String,state: String,isShow: String, receiveNum: String,resultBlock: @escaping resultShopBlock) { | ||
| 894 | + if !title.isNotBlank() { | ||
| 895 | + showMessage(message: "优惠券名称不能为空") | ||
| 896 | + return | ||
| 897 | + } | ||
| 898 | + let param = NSMutableDictionary() | ||
| 899 | + param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "uid") | ||
| 900 | + param.setValue(model.id, forKey: "id") | ||
| 901 | + param.setValue(title, forKey: "title") | ||
| 902 | + param.setValue(model.filled, forKey: "filled") | ||
| 903 | + param.setValue(model.discount, forKey: "discount") | ||
| 904 | + param.setValue("\(Int(model.starttime!) ?? 0)", forKey: "startTime") | ||
| 905 | + param.setValue("\(Int(model.endtime!) ?? 0)", forKey: "endTime") | ||
| 906 | + param.setValue(state, forKey: "state") | ||
| 907 | + param.setValue(isShow, forKey: "is_show") | ||
| 908 | + param.setValue(receiveNum, forKey: "receive_number") | ||
| 909 | + param.setValue(model.num, forKey: "num") | ||
| 910 | + param.setValue(model.goods_id, forKey: "goods_id") | ||
| 911 | + print("修改优惠券数据===>\(param)") | ||
| 912 | + let custom_param = NSMutableDictionary() | ||
| 913 | + custom_param.setValue(APPId_wjj, forKey: "appId") | ||
| 914 | + custom_param.setValue(APPKey_wjj, forKey: "appKey") | ||
| 915 | + CNLiveNetworking.setAllowRequestDefaultArgument(true) | ||
| 916 | + CNLiveNetworking.setupShowDataResult(false) | ||
| 917 | + CNLiveNetworking.setupDSRequest(true) | ||
| 918 | + CNLiveNetworking.setupCustomParam(custom_param as? [String : String]) | ||
| 919 | + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseWjjBUrl+"/api/v1/editCoupon", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in | ||
| 920 | + hiddenLoading() | ||
| 921 | + if (error == nil) { | ||
| 922 | + let resp = result as! NSDictionary | ||
| 923 | + let errorCode = "\(resp["code"] ?? "0")" | ||
| 924 | + if (errorCode == "200") { | ||
| 925 | + if resp["data"] is NSNull { | ||
| 926 | + resultBlock(NSNull(),.failed) | ||
| 927 | + } else { | ||
| 928 | + resultBlock("修改成功", .success) | ||
| 929 | + } | ||
| 930 | + } else { | ||
| 931 | + showMessage(message: resp["message"] as! String) | ||
| 932 | + resultBlock(NSNull(),.failed) | ||
| 933 | + } | ||
| 934 | + } else { | ||
| 935 | + if CNLiveNetworking.isNetworking() { | ||
| 936 | + showMessage(message: "修改失败") | ||
| 937 | + resultBlock(NSNull(),.failed) | ||
| 938 | + } else { | ||
| 939 | + showMessage(message: "似乎与网络断开链接") | ||
| 940 | + resultBlock(NSNull(),.noNetwork) | ||
| 941 | + } | ||
| 942 | + } | ||
| 943 | + } | ||
| 944 | + } | ||
| 945 | + | ||
| 946 | + | ||
| 947 | + | ||
| 630 | } | 948 | } |
metaCode/Supporting Files/Assets.xcassets/Shop/DS_coupon_select.imageset/Contents.json
0 → 100644
| 1 | +{ | ||
| 2 | + "images" : [ | ||
| 3 | + { | ||
| 4 | + "idiom" : "universal", | ||
| 5 | + "scale" : "1x" | ||
| 6 | + }, | ||
| 7 | + { | ||
| 8 | + "filename" : "选中@2x.png", | ||
| 9 | + "idiom" : "universal", | ||
| 10 | + "scale" : "2x" | ||
| 11 | + }, | ||
| 12 | + { | ||
| 13 | + "filename" : "选中@3x.png", | ||
| 14 | + "idiom" : "universal", | ||
| 15 | + "scale" : "3x" | ||
| 16 | + } | ||
| 17 | + ], | ||
| 18 | + "info" : { | ||
| 19 | + "author" : "xcode", | ||
| 20 | + "version" : 1 | ||
| 21 | + } | ||
| 22 | +} |
metaCode/Supporting Files/Assets.xcassets/Shop/DS_coupon_select.imageset/选中@2x.png
0 → 100644
1.03 KB
metaCode/Supporting Files/Assets.xcassets/Shop/DS_coupon_select.imageset/选中@3x.png
0 → 100644
1.9 KB
metaCode/Supporting Files/Assets.xcassets/Shop/DS_coupon_unSelect.imageset/Contents.json
0 → 100644
| 1 | +{ | ||
| 2 | + "images" : [ | ||
| 3 | + { | ||
| 4 | + "idiom" : "universal", | ||
| 5 | + "scale" : "1x" | ||
| 6 | + }, | ||
| 7 | + { | ||
| 8 | + "filename" : "未选中@2x.png", | ||
| 9 | + "idiom" : "universal", | ||
| 10 | + "scale" : "2x" | ||
| 11 | + }, | ||
| 12 | + { | ||
| 13 | + "filename" : "未选中@3x.png", | ||
| 14 | + "idiom" : "universal", | ||
| 15 | + "scale" : "3x" | ||
| 16 | + } | ||
| 17 | + ], | ||
| 18 | + "info" : { | ||
| 19 | + "author" : "xcode", | ||
| 20 | + "version" : 1 | ||
| 21 | + } | ||
| 22 | +} |
metaCode/Supporting Files/Assets.xcassets/Shop/DS_coupon_unSelect.imageset/未选中@2x.png
0 → 100644
808 Bytes
metaCode/Supporting Files/Assets.xcassets/Shop/DS_coupon_unSelect.imageset/未选中@3x.png
0 → 100644
1.3 KB