Commit 9ad08da74553e2e5c64e4b3dc53d589b965cc87e
1 parent
eb9a911a
商品管理 , 新增商品 , 预览商品 ,店铺分类 , 商品分类等 (未完成)
Showing
26 changed files
with
4179 additions
and
332 deletions
Too many changes to show.
To preserve performance only 26 of 48 files are displayed.
metaCode.xcodeproj/project.pbxproj
| @@ -11,6 +11,23 @@ | @@ -11,6 +11,23 @@ | ||
| 11 | 19123FC12ABC11170075C883 /* CNWebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19123FC02ABC11170075C883 /* CNWebViewController.swift */; }; | 11 | 19123FC12ABC11170075C883 /* CNWebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19123FC02ABC11170075C883 /* CNWebViewController.swift */; }; |
| 12 | 1917328E2B032583007BCC04 /* CNLiveRoundedRectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1917328D2B032583007BCC04 /* CNLiveRoundedRectView.swift */; }; | 12 | 1917328E2B032583007BCC04 /* CNLiveRoundedRectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1917328D2B032583007BCC04 /* CNLiveRoundedRectView.swift */; }; |
| 13 | 191732902B0348F6007BCC04 /* CNLiveSwitchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1917328F2B0348F6007BCC04 /* CNLiveSwitchView.swift */; }; | 13 | 191732902B0348F6007BCC04 /* CNLiveSwitchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1917328F2B0348F6007BCC04 /* CNLiveSwitchView.swift */; }; |
| 14 | + 191732CE2B04AACD007BCC04 /* CNLiveShopTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191732CD2B04AACD007BCC04 /* CNLiveShopTextView.swift */; }; | ||
| 15 | + 191732E32B05F474007BCC04 /* CNLiveShopGoodsManageDetailsInputManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191732E22B05F474007BCC04 /* CNLiveShopGoodsManageDetailsInputManager.swift */; }; | ||
| 16 | + 191732E52B05FFE8007BCC04 /* CNLiveModalPresentationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191732E42B05FFE8007BCC04 /* CNLiveModalPresentationViewController.swift */; }; | ||
| 17 | + 191732E72B0615C1007BCC04 /* UIScrollView+CNLiveExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191732E62B0615C1007BCC04 /* UIScrollView+CNLiveExtensions.swift */; }; | ||
| 18 | + 191732E92B0706B3007BCC04 /* CNLiveShopClassifyCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191732E82B0706B3007BCC04 /* CNLiveShopClassifyCell.swift */; }; | ||
| 19 | + 191732EB2B070943007BCC04 /* CNLiveShopGoodsManageDetailsGoodsCategoryModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191732EA2B070943007BCC04 /* CNLiveShopGoodsManageDetailsGoodsCategoryModel.swift */; }; | ||
| 20 | + 191732ED2B073C52007BCC04 /* CNLiveShopClassifyListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191732EC2B073C52007BCC04 /* CNLiveShopClassifyListModel.swift */; }; | ||
| 21 | + 191732EF2B075C3A007BCC04 /* CNLiveCreateShopClassifyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191732EE2B075C3A007BCC04 /* CNLiveCreateShopClassifyViewController.swift */; }; | ||
| 22 | + 191732F12B084822007BCC04 /* CNLiveShopClassifyInputTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191732F02B084822007BCC04 /* CNLiveShopClassifyInputTableViewCell.swift */; }; | ||
| 23 | + 191732F32B084DBC007BCC04 /* CNLiveShopClassifySwitchTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191732F22B084DBC007BCC04 /* CNLiveShopClassifySwitchTableViewCell.swift */; }; | ||
| 24 | + 191732F52B085BAE007BCC04 /* CNLiveShopClassilyIconTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191732F42B085BAE007BCC04 /* CNLiveShopClassilyIconTableViewCell.swift */; }; | ||
| 25 | + 191732F82B08AB9D007BCC04 /* CNLiveShopClassilyViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191732F72B08AB9D007BCC04 /* CNLiveShopClassilyViewModel.swift */; }; | ||
| 26 | + 191732FB2B0AF34A007BCC04 /* CNLiveShopGoodsDetailsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191732FA2B0AF34A007BCC04 /* CNLiveShopGoodsDetailsModel.swift */; }; | ||
| 27 | + 191732FE2B0B3EBF007BCC04 /* CNLiveShopGoodsDetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191732FD2B0B3EBF007BCC04 /* CNLiveShopGoodsDetailsViewController.swift */; }; | ||
| 28 | + 191733002B0B58E5007BCC04 /* CNLiveSelectUploadImageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191732FF2B0B58E5007BCC04 /* CNLiveSelectUploadImageModel.swift */; }; | ||
| 29 | + 191733022B0C4EAB007BCC04 /* CNLiveSelUplSingleImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191733012B0C4EAB007BCC04 /* CNLiveSelUplSingleImageView.swift */; }; | ||
| 30 | + 191733042B0F216E007BCC04 /* NSDictionary+CNLiveExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191733032B0F216E007BCC04 /* NSDictionary+CNLiveExtensions.swift */; }; | ||
| 14 | 192336EB2AD9224300D47CD4 /* CNUpSlideViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 192336EA2AD9224300D47CD4 /* CNUpSlideViewController.swift */; }; | 31 | 192336EB2AD9224300D47CD4 /* CNUpSlideViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 192336EA2AD9224300D47CD4 /* CNUpSlideViewController.swift */; }; |
| 15 | 1926C28F2AE0D76C00C71DC3 /* CNLiveDownSlideViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1926C28E2AE0D76C00C71DC3 /* CNLiveDownSlideViewModel.swift */; }; | 32 | 1926C28F2AE0D76C00C71DC3 /* CNLiveDownSlideViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1926C28E2AE0D76C00C71DC3 /* CNLiveDownSlideViewModel.swift */; }; |
| 16 | 1926C2912AE0FD4500C71DC3 /* CNLiveDownSlideModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1926C2902AE0FD4500C71DC3 /* CNLiveDownSlideModel.swift */; }; | 33 | 1926C2912AE0FD4500C71DC3 /* CNLiveDownSlideModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1926C2902AE0FD4500C71DC3 /* CNLiveDownSlideModel.swift */; }; |
| @@ -178,6 +195,23 @@ | @@ -178,6 +195,23 @@ | ||
| 178 | 19123FC02ABC11170075C883 /* CNWebViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNWebViewController.swift; sourceTree = "<group>"; }; | 195 | 19123FC02ABC11170075C883 /* CNWebViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNWebViewController.swift; sourceTree = "<group>"; }; |
| 179 | 1917328D2B032583007BCC04 /* CNLiveRoundedRectView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveRoundedRectView.swift; sourceTree = "<group>"; }; | 196 | 1917328D2B032583007BCC04 /* CNLiveRoundedRectView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveRoundedRectView.swift; sourceTree = "<group>"; }; |
| 180 | 1917328F2B0348F6007BCC04 /* CNLiveSwitchView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveSwitchView.swift; sourceTree = "<group>"; }; | 197 | 1917328F2B0348F6007BCC04 /* CNLiveSwitchView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveSwitchView.swift; sourceTree = "<group>"; }; |
| 198 | + 191732CD2B04AACD007BCC04 /* CNLiveShopTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopTextView.swift; sourceTree = "<group>"; }; | ||
| 199 | + 191732E22B05F474007BCC04 /* CNLiveShopGoodsManageDetailsInputManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopGoodsManageDetailsInputManager.swift; sourceTree = "<group>"; }; | ||
| 200 | + 191732E42B05FFE8007BCC04 /* CNLiveModalPresentationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveModalPresentationViewController.swift; sourceTree = "<group>"; }; | ||
| 201 | + 191732E62B0615C1007BCC04 /* UIScrollView+CNLiveExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIScrollView+CNLiveExtensions.swift"; sourceTree = "<group>"; }; | ||
| 202 | + 191732E82B0706B3007BCC04 /* CNLiveShopClassifyCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopClassifyCell.swift; sourceTree = "<group>"; }; | ||
| 203 | + 191732EA2B070943007BCC04 /* CNLiveShopGoodsManageDetailsGoodsCategoryModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopGoodsManageDetailsGoodsCategoryModel.swift; sourceTree = "<group>"; }; | ||
| 204 | + 191732EC2B073C52007BCC04 /* CNLiveShopClassifyListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopClassifyListModel.swift; sourceTree = "<group>"; }; | ||
| 205 | + 191732EE2B075C3A007BCC04 /* CNLiveCreateShopClassifyViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveCreateShopClassifyViewController.swift; sourceTree = "<group>"; }; | ||
| 206 | + 191732F02B084822007BCC04 /* CNLiveShopClassifyInputTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopClassifyInputTableViewCell.swift; sourceTree = "<group>"; }; | ||
| 207 | + 191732F22B084DBC007BCC04 /* CNLiveShopClassifySwitchTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopClassifySwitchTableViewCell.swift; sourceTree = "<group>"; }; | ||
| 208 | + 191732F42B085BAE007BCC04 /* CNLiveShopClassilyIconTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopClassilyIconTableViewCell.swift; sourceTree = "<group>"; }; | ||
| 209 | + 191732F72B08AB9D007BCC04 /* CNLiveShopClassilyViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopClassilyViewModel.swift; sourceTree = "<group>"; }; | ||
| 210 | + 191732FA2B0AF34A007BCC04 /* CNLiveShopGoodsDetailsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopGoodsDetailsModel.swift; sourceTree = "<group>"; }; | ||
| 211 | + 191732FD2B0B3EBF007BCC04 /* CNLiveShopGoodsDetailsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopGoodsDetailsViewController.swift; sourceTree = "<group>"; }; | ||
| 212 | + 191732FF2B0B58E5007BCC04 /* CNLiveSelectUploadImageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveSelectUploadImageModel.swift; sourceTree = "<group>"; }; | ||
| 213 | + 191733012B0C4EAB007BCC04 /* CNLiveSelUplSingleImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveSelUplSingleImageView.swift; sourceTree = "<group>"; }; | ||
| 214 | + 191733032B0F216E007BCC04 /* NSDictionary+CNLiveExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSDictionary+CNLiveExtensions.swift"; sourceTree = "<group>"; }; | ||
| 181 | 192336EA2AD9224300D47CD4 /* CNUpSlideViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNUpSlideViewController.swift; sourceTree = "<group>"; }; | 215 | 192336EA2AD9224300D47CD4 /* CNUpSlideViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNUpSlideViewController.swift; sourceTree = "<group>"; }; |
| 182 | 1926C28E2AE0D76C00C71DC3 /* CNLiveDownSlideViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveDownSlideViewModel.swift; sourceTree = "<group>"; }; | 216 | 1926C28E2AE0D76C00C71DC3 /* CNLiveDownSlideViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveDownSlideViewModel.swift; sourceTree = "<group>"; }; |
| 183 | 1926C2902AE0FD4500C71DC3 /* CNLiveDownSlideModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveDownSlideModel.swift; sourceTree = "<group>"; }; | 217 | 1926C2902AE0FD4500C71DC3 /* CNLiveDownSlideModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveDownSlideModel.swift; sourceTree = "<group>"; }; |
| @@ -361,12 +395,39 @@ | @@ -361,12 +395,39 @@ | ||
| 361 | /* End PBXFrameworksBuildPhase section */ | 395 | /* End PBXFrameworksBuildPhase section */ |
| 362 | 396 | ||
| 363 | /* Begin PBXGroup section */ | 397 | /* Begin PBXGroup section */ |
| 398 | + 191732F62B08AAD4007BCC04 /* ShopClassify */ = { | ||
| 399 | + isa = PBXGroup; | ||
| 400 | + children = ( | ||
| 401 | + 191732F72B08AB9D007BCC04 /* CNLiveShopClassilyViewModel.swift */, | ||
| 402 | + ); | ||
| 403 | + path = ShopClassify; | ||
| 404 | + sourceTree = "<group>"; | ||
| 405 | + }; | ||
| 406 | + 191732F92B0AF329007BCC04 /* GoodsDetail */ = { | ||
| 407 | + isa = PBXGroup; | ||
| 408 | + children = ( | ||
| 409 | + 191732FA2B0AF34A007BCC04 /* CNLiveShopGoodsDetailsModel.swift */, | ||
| 410 | + 191732FF2B0B58E5007BCC04 /* CNLiveSelectUploadImageModel.swift */, | ||
| 411 | + ); | ||
| 412 | + path = GoodsDetail; | ||
| 413 | + sourceTree = "<group>"; | ||
| 414 | + }; | ||
| 415 | + 191732FC2B0B3EB4007BCC04 /* GoodsDetail */ = { | ||
| 416 | + isa = PBXGroup; | ||
| 417 | + children = ( | ||
| 418 | + 191732FD2B0B3EBF007BCC04 /* CNLiveShopGoodsDetailsViewController.swift */, | ||
| 419 | + ); | ||
| 420 | + path = GoodsDetail; | ||
| 421 | + sourceTree = "<group>"; | ||
| 422 | + }; | ||
| 364 | 19565EC32AF8ACC2007D6727 /* GoodsManager */ = { | 423 | 19565EC32AF8ACC2007D6727 /* GoodsManager */ = { |
| 365 | isa = PBXGroup; | 424 | isa = PBXGroup; |
| 366 | children = ( | 425 | children = ( |
| 367 | 19565EC42AF8AD1F007D6727 /* CNLiveShopProductManagerController.swift */, | 426 | 19565EC42AF8AD1F007D6727 /* CNLiveShopProductManagerController.swift */, |
| 368 | 19565EC62AF8AD38007D6727 /* CNLiveShopNewProductController.swift */, | 427 | 19565EC62AF8AD38007D6727 /* CNLiveShopNewProductController.swift */, |
| 428 | + 191732E42B05FFE8007BCC04 /* CNLiveModalPresentationViewController.swift */, | ||
| 369 | 1965FA412AFB79EA00F0F435 /* CNLiveGoodsCategoryController.swift */, | 429 | 1965FA412AFB79EA00F0F435 /* CNLiveGoodsCategoryController.swift */, |
| 430 | + 191732EE2B075C3A007BCC04 /* CNLiveCreateShopClassifyViewController.swift */, | ||
| 370 | ); | 431 | ); |
| 371 | path = GoodsManager; | 432 | path = GoodsManager; |
| 372 | sourceTree = "<group>"; | 433 | sourceTree = "<group>"; |
| @@ -378,8 +439,15 @@ | @@ -378,8 +439,15 @@ | ||
| 378 | 19565ECE2AF8D8F6007D6727 /* CNLiveShopGoodsListCell.swift */, | 439 | 19565ECE2AF8D8F6007D6727 /* CNLiveShopGoodsListCell.swift */, |
| 379 | 1965FA3D2AFB176E00F0F435 /* CNLiveShopAddGoodsSingleView.swift */, | 440 | 1965FA3D2AFB176E00F0F435 /* CNLiveShopAddGoodsSingleView.swift */, |
| 380 | 1965FA3F2AFB38AA00F0F435 /* CNLiveAddGoodsSelectUploadImageView.swift */, | 441 | 1965FA3F2AFB38AA00F0F435 /* CNLiveAddGoodsSelectUploadImageView.swift */, |
| 442 | + 191733012B0C4EAB007BCC04 /* CNLiveSelUplSingleImageView.swift */, | ||
| 381 | 1917328D2B032583007BCC04 /* CNLiveRoundedRectView.swift */, | 443 | 1917328D2B032583007BCC04 /* CNLiveRoundedRectView.swift */, |
| 382 | 1917328F2B0348F6007BCC04 /* CNLiveSwitchView.swift */, | 444 | 1917328F2B0348F6007BCC04 /* CNLiveSwitchView.swift */, |
| 445 | + 191732CD2B04AACD007BCC04 /* CNLiveShopTextView.swift */, | ||
| 446 | + 191732E22B05F474007BCC04 /* CNLiveShopGoodsManageDetailsInputManager.swift */, | ||
| 447 | + 191732E82B0706B3007BCC04 /* CNLiveShopClassifyCell.swift */, | ||
| 448 | + 191732F02B084822007BCC04 /* CNLiveShopClassifyInputTableViewCell.swift */, | ||
| 449 | + 191732F22B084DBC007BCC04 /* CNLiveShopClassifySwitchTableViewCell.swift */, | ||
| 450 | + 191732F42B085BAE007BCC04 /* CNLiveShopClassilyIconTableViewCell.swift */, | ||
| 383 | ); | 451 | ); |
| 384 | path = GoodsManager; | 452 | path = GoodsManager; |
| 385 | sourceTree = "<group>"; | 453 | sourceTree = "<group>"; |
| @@ -397,6 +465,8 @@ | @@ -397,6 +465,8 @@ | ||
| 397 | children = ( | 465 | children = ( |
| 398 | 19565ECA2AF8C59C007D6727 /* CNLiveShopGoodsListModel.swift */, | 466 | 19565ECA2AF8C59C007D6727 /* CNLiveShopGoodsListModel.swift */, |
| 399 | 19565ED32AF9FEB4007D6727 /* CNLiveShopAddEditGoodsModel.swift */, | 467 | 19565ED32AF9FEB4007D6727 /* CNLiveShopAddEditGoodsModel.swift */, |
| 468 | + 191732EA2B070943007BCC04 /* CNLiveShopGoodsManageDetailsGoodsCategoryModel.swift */, | ||
| 469 | + 191732EC2B073C52007BCC04 /* CNLiveShopClassifyListModel.swift */, | ||
| 400 | ); | 470 | ); |
| 401 | path = GoodsManager; | 471 | path = GoodsManager; |
| 402 | sourceTree = "<group>"; | 472 | sourceTree = "<group>"; |
| @@ -404,6 +474,7 @@ | @@ -404,6 +474,7 @@ | ||
| 404 | 19BB1FE42AEB93850094D962 /* Model */ = { | 474 | 19BB1FE42AEB93850094D962 /* Model */ = { |
| 405 | isa = PBXGroup; | 475 | isa = PBXGroup; |
| 406 | children = ( | 476 | children = ( |
| 477 | + 191732F92B0AF329007BCC04 /* GoodsDetail */, | ||
| 407 | 19565ED22AF9FE67007D6727 /* GoodsManager */, | 478 | 19565ED22AF9FE67007D6727 /* GoodsManager */, |
| 408 | 1926C2902AE0FD4500C71DC3 /* CNLiveDownSlideModel.swift */, | 479 | 1926C2902AE0FD4500C71DC3 /* CNLiveDownSlideModel.swift */, |
| 409 | 19BB1FE52AEB93B80094D962 /* CNLiveShopUserInfoModel.swift */, | 480 | 19BB1FE52AEB93B80094D962 /* CNLiveShopUserInfoModel.swift */, |
| @@ -453,6 +524,8 @@ | @@ -453,6 +524,8 @@ | ||
| 453 | 79E496E72AB9674300127BF8 /* NSMutableAttributedString+CNLiveExtensions.swift */, | 524 | 79E496E72AB9674300127BF8 /* NSMutableAttributedString+CNLiveExtensions.swift */, |
| 454 | 19CC4D482ADD06C500308E2A /* UITableView+Extension.swift */, | 525 | 19CC4D482ADD06C500308E2A /* UITableView+Extension.swift */, |
| 455 | 19CC4D552ADD19C200308E2A /* String+Extension.swift */, | 526 | 19CC4D552ADD19C200308E2A /* String+Extension.swift */, |
| 527 | + 191732E62B0615C1007BCC04 /* UIScrollView+CNLiveExtensions.swift */, | ||
| 528 | + 191733032B0F216E007BCC04 /* NSDictionary+CNLiveExtensions.swift */, | ||
| 456 | ); | 529 | ); |
| 457 | path = Extensions; | 530 | path = Extensions; |
| 458 | sourceTree = "<group>"; | 531 | sourceTree = "<group>"; |
| @@ -772,6 +845,7 @@ | @@ -772,6 +845,7 @@ | ||
| 772 | 7C83B43C2A52B899004BF4A4 /* ViewModel */ = { | 845 | 7C83B43C2A52B899004BF4A4 /* ViewModel */ = { |
| 773 | isa = PBXGroup; | 846 | isa = PBXGroup; |
| 774 | children = ( | 847 | children = ( |
| 848 | + 191732F62B08AAD4007BCC04 /* ShopClassify */, | ||
| 775 | 19565ED12AF9FE56007D6727 /* GoodsManager */, | 849 | 19565ED12AF9FE56007D6727 /* GoodsManager */, |
| 776 | 1926C28E2AE0D76C00C71DC3 /* CNLiveDownSlideViewModel.swift */, | 850 | 1926C28E2AE0D76C00C71DC3 /* CNLiveDownSlideViewModel.swift */, |
| 777 | 19BB1FE22AEB8B7C0094D962 /* CNLiveShopConsoleViewModel.swift */, | 851 | 19BB1FE22AEB8B7C0094D962 /* CNLiveShopConsoleViewModel.swift */, |
| @@ -823,6 +897,7 @@ | @@ -823,6 +897,7 @@ | ||
| 823 | 7CD6754D2A2840B9008354C1 /* Controller */ = { | 897 | 7CD6754D2A2840B9008354C1 /* Controller */ = { |
| 824 | isa = PBXGroup; | 898 | isa = PBXGroup; |
| 825 | children = ( | 899 | children = ( |
| 900 | + 191732FC2B0B3EB4007BCC04 /* GoodsDetail */, | ||
| 826 | 19565EC32AF8ACC2007D6727 /* GoodsManager */, | 901 | 19565EC32AF8ACC2007D6727 /* GoodsManager */, |
| 827 | 19BB1FDE2AEA3A450094D962 /* CNSlideBaseNavigationController.swift */, | 902 | 19BB1FDE2AEA3A450094D962 /* CNSlideBaseNavigationController.swift */, |
| 828 | 7CD6754E2A2840B9008354C1 /* CNMetaCodeHomePageController.swift */, | 903 | 7CD6754E2A2840B9008354C1 /* CNMetaCodeHomePageController.swift */, |
| @@ -1142,7 +1217,10 @@ | @@ -1142,7 +1217,10 @@ | ||
| 1142 | 19565EC92AF8BEC6007D6727 /* CNLiveShopGoodListViewModel.swift in Sources */, | 1217 | 19565EC92AF8BEC6007D6727 /* CNLiveShopGoodListViewModel.swift in Sources */, |
| 1143 | 19BB1FE82AECAD060094D962 /* CNLiveShopConsoleModel.swift in Sources */, | 1218 | 19BB1FE82AECAD060094D962 /* CNLiveShopConsoleModel.swift in Sources */, |
| 1144 | 19BB1FEE2AF0E1EC0094D962 /* CNLiveShopDetailViewModel.swift in Sources */, | 1219 | 19BB1FEE2AF0E1EC0094D962 /* CNLiveShopDetailViewModel.swift in Sources */, |
| 1220 | + 191733002B0B58E5007BCC04 /* CNLiveSelectUploadImageModel.swift in Sources */, | ||
| 1145 | 19F1C2332AB5728B0083D06C /* CNIDCardView.swift in Sources */, | 1221 | 19F1C2332AB5728B0083D06C /* CNIDCardView.swift in Sources */, |
| 1222 | + 191732F32B084DBC007BCC04 /* CNLiveShopClassifySwitchTableViewCell.swift in Sources */, | ||
| 1223 | + 191732E72B0615C1007BCC04 /* UIScrollView+CNLiveExtensions.swift in Sources */, | ||
| 1146 | 1917328E2B032583007BCC04 /* CNLiveRoundedRectView.swift in Sources */, | 1224 | 1917328E2B032583007BCC04 /* CNLiveRoundedRectView.swift in Sources */, |
| 1147 | 7CD675292A270F6A008354C1 /* WJColorChange.m in Sources */, | 1225 | 7CD675292A270F6A008354C1 /* WJColorChange.m in Sources */, |
| 1148 | 79F4B11C2A33036E00993C03 /* CNLiveMineInfoAlertView.swift in Sources */, | 1226 | 79F4B11C2A33036E00993C03 /* CNLiveMineInfoAlertView.swift in Sources */, |
| @@ -1157,8 +1235,11 @@ | @@ -1157,8 +1235,11 @@ | ||
| 1157 | 19565ECB2AF8C59C007D6727 /* CNLiveShopGoodsListModel.swift in Sources */, | 1235 | 19565ECB2AF8C59C007D6727 /* CNLiveShopGoodsListModel.swift in Sources */, |
| 1158 | 7963989D2A260E6200D045EB /* CNLiveBaseViewController.swift in Sources */, | 1236 | 7963989D2A260E6200D045EB /* CNLiveBaseViewController.swift in Sources */, |
| 1159 | 798A44FB2A30999900815935 /* CNLiveAlertTool.swift in Sources */, | 1237 | 798A44FB2A30999900815935 /* CNLiveAlertTool.swift in Sources */, |
| 1238 | + 191732EB2B070943007BCC04 /* CNLiveShopGoodsManageDetailsGoodsCategoryModel.swift in Sources */, | ||
| 1160 | 19565EC02AF4DE0E007D6727 /* CNLiveShopDetailBtnsCell.swift in Sources */, | 1239 | 19565EC02AF4DE0E007D6727 /* CNLiveShopDetailBtnsCell.swift in Sources */, |
| 1240 | + 191732E92B0706B3007BCC04 /* CNLiveShopClassifyCell.swift in Sources */, | ||
| 1161 | 790D01A52A2DF65E00C5978D /* CNLiveLoginPickerView.swift in Sources */, | 1241 | 790D01A52A2DF65E00C5978D /* CNLiveLoginPickerView.swift in Sources */, |
| 1242 | + 191733042B0F216E007BCC04 /* NSDictionary+CNLiveExtensions.swift in Sources */, | ||
| 1162 | 79BA085D2AB18E8300D01875 /* CNLiveSaveAuthDB.swift in Sources */, | 1243 | 79BA085D2AB18E8300D01875 /* CNLiveSaveAuthDB.swift in Sources */, |
| 1163 | 79282A3C2A2EDC2500B5F8CF /* NSString+CNLiveExtensions.swift in Sources */, | 1244 | 79282A3C2A2EDC2500B5F8CF /* NSString+CNLiveExtensions.swift in Sources */, |
| 1164 | 19D2CE632AE8B65D00691757 /* CNLiveDownSlideTool.swift in Sources */, | 1245 | 19D2CE632AE8B65D00691757 /* CNLiveDownSlideTool.swift in Sources */, |
| @@ -1166,6 +1247,7 @@ | @@ -1166,6 +1247,7 @@ | ||
| 1166 | 19BB202B2AF382150094D962 /* CNLiveAdaptTool.swift in Sources */, | 1247 | 19BB202B2AF382150094D962 /* CNLiveAdaptTool.swift in Sources */, |
| 1167 | 79E672032AFDFA9C00F2F768 /* CNLiveMineSignOutViewController.swift in Sources */, | 1248 | 79E672032AFDFA9C00F2F768 /* CNLiveMineSignOutViewController.swift in Sources */, |
| 1168 | 19565ECD2AF8D256007D6727 /* CNLiveShopGoodsListClassifyView.swift in Sources */, | 1249 | 19565ECD2AF8D256007D6727 /* CNLiveShopGoodsListClassifyView.swift in Sources */, |
| 1250 | + 191732EF2B075C3A007BCC04 /* CNLiveCreateShopClassifyViewController.swift in Sources */, | ||
| 1169 | 798A44F22A30674200815935 /* CNLiveMineSubBodyListView.swift in Sources */, | 1251 | 798A44F22A30674200815935 /* CNLiveMineSubBodyListView.swift in Sources */, |
| 1170 | 799172382AF090CD00DC01A8 /* CNLiveShopBodyListView.swift in Sources */, | 1252 | 799172382AF090CD00DC01A8 /* CNLiveShopBodyListView.swift in Sources */, |
| 1171 | 19565ED42AF9FEB4007D6727 /* CNLiveShopAddEditGoodsModel.swift in Sources */, | 1253 | 19565ED42AF9FEB4007D6727 /* CNLiveShopAddEditGoodsModel.swift in Sources */, |
| @@ -1183,17 +1265,20 @@ | @@ -1183,17 +1265,20 @@ | ||
| 1183 | 19BB1FEA2AEF7B4A0094D962 /* CNLiveShopConsoleCell.swift in Sources */, | 1265 | 19BB1FEA2AEF7B4A0094D962 /* CNLiveShopConsoleCell.swift in Sources */, |
| 1184 | 790D019D2A2DCBD000C5978D /* UIView+CNLiveExtensions.swift in Sources */, | 1266 | 790D019D2A2DCBD000C5978D /* UIView+CNLiveExtensions.swift in Sources */, |
| 1185 | 790B1FB62A41938F0074CF00 /* UIImage+CNLiveExtensions.swift in Sources */, | 1267 | 790B1FB62A41938F0074CF00 /* UIImage+CNLiveExtensions.swift in Sources */, |
| 1268 | + 191732F82B08AB9D007BCC04 /* CNLiveShopClassilyViewModel.swift in Sources */, | ||
| 1186 | 19FA20172AE22D3C001F7186 /* CNLiveDownSlideRecommendCell.swift in Sources */, | 1269 | 19FA20172AE22D3C001F7186 /* CNLiveDownSlideRecommendCell.swift in Sources */, |
| 1187 | 19123FC12ABC11170075C883 /* CNWebViewController.swift in Sources */, | 1270 | 19123FC12ABC11170075C883 /* CNWebViewController.swift in Sources */, |
| 1188 | 1926C28F2AE0D76C00C71DC3 /* CNLiveDownSlideViewModel.swift in Sources */, | 1271 | 1926C28F2AE0D76C00C71DC3 /* CNLiveDownSlideViewModel.swift in Sources */, |
| 1189 | 790D019D2A2DCBD000C5978D /* UIView+CNLiveExtensions.swift in Sources */, | 1272 | 790D019D2A2DCBD000C5978D /* UIView+CNLiveExtensions.swift in Sources */, |
| 1190 | 7C7C62F62A4D72E9007A912E /* CNLiveIdentityDB.swift in Sources */, | 1273 | 7C7C62F62A4D72E9007A912E /* CNLiveIdentityDB.swift in Sources */, |
| 1274 | + 191732E52B05FFE8007BCC04 /* CNLiveModalPresentationViewController.swift in Sources */, | ||
| 1191 | 799172342AF08D3200DC01A8 /* CNLiveShopViewModel.swift in Sources */, | 1275 | 799172342AF08D3200DC01A8 /* CNLiveShopViewModel.swift in Sources */, |
| 1192 | 799172362AF08D4500DC01A8 /* CNLiveShopBaseModel.swift in Sources */, | 1276 | 799172362AF08D4500DC01A8 /* CNLiveShopBaseModel.swift in Sources */, |
| 1193 | 790B1FB62A41938F0074CF00 /* UIImage+CNLiveExtensions.swift in Sources */, | 1277 | 790B1FB62A41938F0074CF00 /* UIImage+CNLiveExtensions.swift in Sources */, |
| 1194 | 790D019D2A2DCBD000C5978D /* UIView+CNLiveExtensions.swift in Sources */, | 1278 | 790D019D2A2DCBD000C5978D /* UIView+CNLiveExtensions.swift in Sources */, |
| 1195 | 79E496E82AB9674300127BF8 /* NSMutableAttributedString+CNLiveExtensions.swift in Sources */, | 1279 | 79E496E82AB9674300127BF8 /* NSMutableAttributedString+CNLiveExtensions.swift in Sources */, |
| 1196 | 19CC4D472ADD006600308E2A /* CNDownSlideSingleCourseCell.swift in Sources */, | 1280 | 19CC4D472ADD006600308E2A /* CNDownSlideSingleCourseCell.swift in Sources */, |
| 1281 | + 191732FE2B0B3EBF007BCC04 /* CNLiveShopGoodsDetailsViewController.swift in Sources */, | ||
| 1197 | 79E496E32AB9357000127BF8 /* UITableViewCell+CNLiveExtension.swift in Sources */, | 1282 | 79E496E32AB9357000127BF8 /* UITableViewCell+CNLiveExtension.swift in Sources */, |
| 1198 | 7C83B4422A541EBF004BF4A4 /* CALayer+CNLiveExtensions.swift in Sources */, | 1283 | 7C83B4422A541EBF004BF4A4 /* CALayer+CNLiveExtensions.swift in Sources */, |
| 1199 | 19565EC72AF8AD38007D6727 /* CNLiveShopNewProductController.swift in Sources */, | 1284 | 19565EC72AF8AD38007D6727 /* CNLiveShopNewProductController.swift in Sources */, |
| @@ -1214,6 +1299,8 @@ | @@ -1214,6 +1299,8 @@ | ||
| 1214 | 791C1C862AFB2EB4003E6362 /* CNLiveShopOrderExpressViewController.swift in Sources */, | 1299 | 791C1C862AFB2EB4003E6362 /* CNLiveShopOrderExpressViewController.swift in Sources */, |
| 1215 | 7CD6753E2A2740B0008354C1 /* CNUpSlideView.swift in Sources */, | 1300 | 7CD6753E2A2740B0008354C1 /* CNUpSlideView.swift in Sources */, |
| 1216 | 7CD675402A2740B0008354C1 /* CNDownSlideView.swift in Sources */, | 1301 | 7CD675402A2740B0008354C1 /* CNDownSlideView.swift in Sources */, |
| 1302 | + 191732F52B085BAE007BCC04 /* CNLiveShopClassilyIconTableViewCell.swift in Sources */, | ||
| 1303 | + 191732E32B05F474007BCC04 /* CNLiveShopGoodsManageDetailsInputManager.swift in Sources */, | ||
| 1217 | 79B2E3602AF39191002A8524 /* NSObject+CNLiveConfigModuleInline.swift in Sources */, | 1304 | 79B2E3602AF39191002A8524 /* NSObject+CNLiveConfigModuleInline.swift in Sources */, |
| 1218 | 7C2703362A3AFD3A0061EC50 /* CNLiveEnvironment.swift in Sources */, | 1305 | 7C2703362A3AFD3A0061EC50 /* CNLiveEnvironment.swift in Sources */, |
| 1219 | 798A44FD2A309EBA00815935 /* CNLiveTypeFeedBackViewController.swift in Sources */, | 1306 | 798A44FD2A309EBA00815935 /* CNLiveTypeFeedBackViewController.swift in Sources */, |
| @@ -1222,8 +1309,10 @@ | @@ -1222,8 +1309,10 @@ | ||
| 1222 | 7CD6754F2A2840B9008354C1 /* CNMetaCodeHomePageController.swift in Sources */, | 1309 | 7CD6754F2A2840B9008354C1 /* CNMetaCodeHomePageController.swift in Sources */, |
| 1223 | 7989B5C52A4BDC6000A19B10 /* CNLiveMineEarnViewController.swift in Sources */, | 1310 | 7989B5C52A4BDC6000A19B10 /* CNLiveMineEarnViewController.swift in Sources */, |
| 1224 | 792E57DB2A3AE9F4005834DB /* CNLiveCommonQiniuTool.swift in Sources */, | 1311 | 792E57DB2A3AE9F4005834DB /* CNLiveCommonQiniuTool.swift in Sources */, |
| 1312 | + 191732F12B084822007BCC04 /* CNLiveShopClassifyInputTableViewCell.swift in Sources */, | ||
| 1225 | 19BB1FE62AEB93B80094D962 /* CNLiveShopUserInfoModel.swift in Sources */, | 1313 | 19BB1FE62AEB93B80094D962 /* CNLiveShopUserInfoModel.swift in Sources */, |
| 1226 | 7CD675472A274167008354C1 /* NewPagedFlowView.m in Sources */, | 1314 | 7CD675472A274167008354C1 /* NewPagedFlowView.m in Sources */, |
| 1315 | + 191732ED2B073C52007BCC04 /* CNLiveShopClassifyListModel.swift in Sources */, | ||
| 1227 | 79F4B11A2A32F21400993C03 /* CNLiveMineNickViewController.swift in Sources */, | 1316 | 79F4B11A2A32F21400993C03 /* CNLiveMineNickViewController.swift in Sources */, |
| 1228 | 798A44FF2A30A0A800815935 /* CNLiveInputFeedBackViewController.swift in Sources */, | 1317 | 798A44FF2A30A0A800815935 /* CNLiveInputFeedBackViewController.swift in Sources */, |
| 1229 | 79282A442A2F1C1E00B5F8CF /* CNLiveLoginAuthView.swift in Sources */, | 1318 | 79282A442A2F1C1E00B5F8CF /* CNLiveLoginAuthView.swift in Sources */, |
| @@ -1233,6 +1322,7 @@ | @@ -1233,6 +1322,7 @@ | ||
| 1233 | 790D01A32A2DDBA300C5978D /* CNLiveConfigManager.swift in Sources */, | 1322 | 790D01A32A2DDBA300C5978D /* CNLiveConfigManager.swift in Sources */, |
| 1234 | 19565EC52AF8AD1F007D6727 /* CNLiveShopProductManagerController.swift in Sources */, | 1323 | 19565EC52AF8AD1F007D6727 /* CNLiveShopProductManagerController.swift in Sources */, |
| 1235 | 19CC4D492ADD06C500308E2A /* UITableView+Extension.swift in Sources */, | 1324 | 19CC4D492ADD06C500308E2A /* UITableView+Extension.swift in Sources */, |
| 1325 | + 191732CE2B04AACD007BCC04 /* CNLiveShopTextView.swift in Sources */, | ||
| 1236 | 7C2703332A36CC660061EC50 /* CNLiveGlobalBlock.swift in Sources */, | 1326 | 7C2703332A36CC660061EC50 /* CNLiveGlobalBlock.swift in Sources */, |
| 1237 | 7987BF3D2A497644000A1ABC /* CNLiveMineQuestViewController.swift in Sources */, | 1327 | 7987BF3D2A497644000A1ABC /* CNLiveMineQuestViewController.swift in Sources */, |
| 1238 | 798A44EA2A30135D00815935 /* CNLiveMineBodyListView.swift in Sources */, | 1328 | 798A44EA2A30135D00815935 /* CNLiveMineBodyListView.swift in Sources */, |
| @@ -1249,6 +1339,7 @@ | @@ -1249,6 +1339,7 @@ | ||
| 1249 | 19CC4D562ADD19C200308E2A /* String+Extension.swift in Sources */, | 1339 | 19CC4D562ADD19C200308E2A /* String+Extension.swift in Sources */, |
| 1250 | 7905BB492AB0588B0089BC50 /* CNLiveMineAuthResultViewController.swift in Sources */, | 1340 | 7905BB492AB0588B0089BC50 /* CNLiveMineAuthResultViewController.swift in Sources */, |
| 1251 | 19565EC22AF616CA007D6727 /* CNLiveShopDetailOrderAssetCell.swift in Sources */, | 1341 | 19565EC22AF616CA007D6727 /* CNLiveShopDetailOrderAssetCell.swift in Sources */, |
| 1342 | + 191732FB2B0AF34A007BCC04 /* CNLiveShopGoodsDetailsModel.swift in Sources */, | ||
| 1252 | 794FF1052B01FC8800385E85 /* CNLiveShopOrderSearchViewController.swift in Sources */, | 1343 | 794FF1052B01FC8800385E85 /* CNLiveShopOrderSearchViewController.swift in Sources */, |
| 1253 | 798A44EC2A302DBE00815935 /* CNLiveMineAddInfoViewController.swift in Sources */, | 1344 | 798A44EC2A302DBE00815935 /* CNLiveMineAddInfoViewController.swift in Sources */, |
| 1254 | 791C1C882AFB6FD7003E6362 /* CNLiveShopOrderExpressFirmViewController.swift in Sources */, | 1345 | 791C1C882AFB6FD7003E6362 /* CNLiveShopOrderExpressFirmViewController.swift in Sources */, |
| @@ -1260,6 +1351,7 @@ | @@ -1260,6 +1351,7 @@ | ||
| 1260 | 19FA20192AE22D98001F7186 /* CNLiveDownSlideTodayRecommendCell.swift in Sources */, | 1351 | 19FA20192AE22D98001F7186 /* CNLiveDownSlideTodayRecommendCell.swift in Sources */, |
| 1261 | 790B1FB42A4153E90074CF00 /* CNLiveMineBaseModel.swift in Sources */, | 1352 | 790B1FB42A4153E90074CF00 /* CNLiveMineBaseModel.swift in Sources */, |
| 1262 | 7978A8432A396632007C86B8 /* CNLiveMineViewModel.swift in Sources */, | 1353 | 7978A8432A396632007C86B8 /* CNLiveMineViewModel.swift in Sources */, |
| 1354 | + 191733022B0C4EAB007BCC04 /* CNLiveSelUplSingleImageView.swift in Sources */, | ||
| 1263 | 798A44EE2A305AAC00815935 /* CNLiveBaseNavigationController.swift in Sources */, | 1355 | 798A44EE2A305AAC00815935 /* CNLiveBaseNavigationController.swift in Sources */, |
| 1264 | 7CD675422A2740F8008354C1 /* CNCustomIndexView.swift in Sources */, | 1356 | 7CD675422A2740F8008354C1 /* CNCustomIndexView.swift in Sources */, |
| 1265 | 7C4931292A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift in Sources */, | 1357 | 7C4931292A2D8BA8000E44B4 /* CNLiveBaseTabBarViewController.swift in Sources */, |
metaCode/Classes/Extensions/NSDictionary+CNLiveExtensions.swift
0 → 100644
| 1 | +// | ||
| 2 | +// NSDictionary+CNLiveExtensions.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by zx on 2023/11/23. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | + | ||
| 10 | +extension NSDictionary { | ||
| 11 | + func stringValueForKey(key:NSString) -> NSString { | ||
| 12 | + let value = self[key] | ||
| 13 | + if value == nil || value as! NSObject == NSNull(){ | ||
| 14 | + return "" | ||
| 15 | + } | ||
| 16 | + if let newValue = value as? NSString { | ||
| 17 | + return newValue | ||
| 18 | + } else if let newValue = value as? NSNumber { | ||
| 19 | + return newValue.description as NSString | ||
| 20 | + } else { | ||
| 21 | + return "" | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + } | ||
| 25 | +} |
metaCode/Classes/Extensions/NSString+CNLiveExtensions.swift
| @@ -6,6 +6,7 @@ | @@ -6,6 +6,7 @@ | ||
| 6 | // | 6 | // |
| 7 | 7 | ||
| 8 | import Foundation | 8 | import Foundation |
| 9 | +import UIKit | ||
| 9 | 10 | ||
| 10 | extension NSString { | 11 | extension NSString { |
| 11 | 12 | ||
| @@ -90,4 +91,29 @@ extension NSString { | @@ -90,4 +91,29 @@ extension NSString { | ||
| 90 | let filtered = filtered_array.componentsJoined(by: "") | 91 | let filtered = filtered_array.componentsJoined(by: "") |
| 91 | return self as String == filtered | 92 | return self as String == filtered |
| 92 | } | 93 | } |
| 94 | + | ||
| 95 | + /** | ||
| 96 | + 保留2位小数 | ||
| 97 | + */ | ||
| 98 | + func keepTwoDecimalPlaces() -> NSString{ | ||
| 99 | + var mSelf = NSMutableString(string: self) | ||
| 100 | + if self.contains("."){ | ||
| 101 | + let decimalLocation = mSelf.range(of: ".").location | ||
| 102 | + var lastDecimalLocationLength = mSelf.length - decimalLocation - 1 | ||
| 103 | + if lastDecimalLocationLength > 2{ | ||
| 104 | + while lastDecimalLocationLength != 2 { | ||
| 105 | + mSelf.deleteCharacters(in: NSRange(location: mSelf.length-1, length: 1)) | ||
| 106 | + lastDecimalLocationLength -= lastDecimalLocationLength | ||
| 107 | + } | ||
| 108 | + }else if (lastDecimalLocationLength < 2) { | ||
| 109 | + while (lastDecimalLocationLength != 0) { | ||
| 110 | + mSelf.append("0") | ||
| 111 | + lastDecimalLocationLength -= 1 | ||
| 112 | + } | ||
| 113 | + } | ||
| 114 | + }else { | ||
| 115 | + mSelf.append(".00") | ||
| 116 | + } | ||
| 117 | + return mSelf | ||
| 118 | + } | ||
| 93 | } | 119 | } |
metaCode/Classes/Extensions/String+Extension.swift
| @@ -17,4 +17,13 @@ extension String { | @@ -17,4 +17,13 @@ extension String { | ||
| 17 | let option = NSStringDrawingOptions.usesLineFragmentOrigin | 17 | let option = NSStringDrawingOptions.usesLineFragmentOrigin |
| 18 | return self.boundingRect(with: (maxSize), options: option, attributes: attr, context: nil).size.height | 18 | return self.boundingRect(with: (maxSize), options: option, attributes: attr, context: nil).size.height |
| 19 | } | 19 | } |
| 20 | + | ||
| 21 | + //截取子字符串,eg "123456" start:2为第三位,length:3为长度是3,substring:345 | ||
| 22 | + func subString(start: Int, length: Int) -> String { | ||
| 23 | + let startIndex = self.index(self.startIndex, offsetBy: start) | ||
| 24 | + let endIndex = self.index(startIndex, offsetBy: length) | ||
| 25 | + let substring = self[startIndex..<endIndex] | ||
| 26 | + return String(substring) | ||
| 27 | + } | ||
| 28 | + | ||
| 20 | } | 29 | } |
metaCode/Classes/Extensions/UIScrollView+CNLiveExtensions.swift
0 → 100644
| 1 | +// | ||
| 2 | +// UIScrollView+CNLiveExtensions.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by zx on 2023/11/16. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | + | ||
| 10 | +extension UIScrollView { | ||
| 11 | + func scrollToBottom() { | ||
| 12 | + let bottomOffset = CGPoint(x: 0, y: contentSize.height - bounds.size.height + contentInset.bottom) | ||
| 13 | + setContentOffset(bottomOffset, animated: true) | ||
| 14 | + } | ||
| 15 | +} |
metaCode/Classes/Main/HomePage/Controller/GoodsDetail/CNLiveShopGoodsDetailsViewController.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveShopGoodsDetailsViewController.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by zx on 2023/11/20. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | + | ||
| 10 | +///分类类型 | ||
| 11 | +enum CNLiveShopGoodsDetailsVCType:Int { | ||
| 12 | + ///正常 | ||
| 13 | + case normal | ||
| 14 | + ///预览 | ||
| 15 | + case preview | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +class CNLiveShopGoodsDetailsViewController:CNLiveBaseViewController{ | ||
| 19 | + /// 格式 | ||
| 20 | + var type:CNLiveShopGoodsDetailsVCType? | ||
| 21 | + /// 商品id | ||
| 22 | + var goodsId:String? | ||
| 23 | + /// 编辑商品预览使用 | ||
| 24 | + var detailsModel:CNLiveShopGoodsDetailsModel? | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + override func viewDidLoad() { | ||
| 28 | + super.viewDidLoad() | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + | ||
| 32 | +} |
metaCode/Classes/Main/HomePage/Controller/GoodsManager/CNLiveCreateShopClassifyViewController.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveCreateShopClassifyViewController.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by zx on 2023/11/17. | ||
| 6 | +// 创建/编辑 店铺分类控制器 | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | + | ||
| 10 | +///分类类型 | ||
| 11 | +enum CNLiveCreateType:Int { | ||
| 12 | + ///一级分类 | ||
| 13 | + case oneLevelClassify | ||
| 14 | + ///二级分类 | ||
| 15 | + case twoLevelClassify | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +class CNLiveCreateShopClassifyViewController:CNLiveBaseViewController, UITableViewDataSource, UITableViewDelegate{ | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + /// 分类类型,是一级还是二级 | ||
| 22 | + var classifyType:CNLiveCreateType? | ||
| 23 | + /// 当创建二级分类时,需要传上一级分类的id | ||
| 24 | + var superClassifyId:String = "" | ||
| 25 | + /// 添加/编辑/删除 成功回调 | ||
| 26 | + var successCompleteBlock:successComplete? | ||
| 27 | + | ||
| 28 | + let kCNLiveShopClassifyInputTitelCellID = "kCNLiveShopClassifyInputTitelCellID" | ||
| 29 | + let kCNLiveShopClassifyInputSortCellID = "kCNLiveShopClassifyInputSortCellID" | ||
| 30 | + let kCNLiveShopClassifySwitchTableViewCellID = "kCNLiveShopClassifySwitchTableViewCellID" | ||
| 31 | + let kCNLiveShopClassilyIconTableViewCellID = "kCNLiveShopClassilyIconTableViewCellID" | ||
| 32 | + | ||
| 33 | + /// 编辑状态 | ||
| 34 | + var isEdite:Bool? | ||
| 35 | + /// 编辑的数据 | ||
| 36 | + var shopClassifyModel:CNLiveShopClassifyModel? | ||
| 37 | + /// 表 | ||
| 38 | + // MARK: - lazy | ||
| 39 | + lazy var tableView : UITableView = { | ||
| 40 | + let tableView = UITableView(frame: CGRect(x: 0, y: KNavigationHeight, width: KSreenWidth, height: KSreenHeight-KNavigationHeight-KTabBarHeight), style: .plain) | ||
| 41 | + tableView.backgroundColor = HexColor("#F6F6F6") | ||
| 42 | + tableView.dataSource = self | ||
| 43 | + tableView.delegate = self | ||
| 44 | + tableView.tableFooterView = UIView() | ||
| 45 | + tableView.separatorStyle = .none | ||
| 46 | + tableView.tableFooterView = UIView.init() | ||
| 47 | + tableView.register(CNLiveShopClassifyInputTitleCell.self, forCellReuseIdentifier:kCNLiveShopClassifyInputTitelCellID ) | ||
| 48 | + tableView.register(CNLiveShopClassifyInputSortCell.self, forCellReuseIdentifier:kCNLiveShopClassifyInputSortCellID ) | ||
| 49 | + tableView.register(CNLiveShopClassifySwitchTableViewCell.self, forCellReuseIdentifier: kCNLiveShopClassifySwitchTableViewCellID) | ||
| 50 | + tableView.register(CNLiveShopClassilyIconTableViewCell.self, forCellReuseIdentifier: kCNLiveShopClassilyIconTableViewCellID) | ||
| 51 | + return tableView | ||
| 52 | + }() | ||
| 53 | + lazy var bottomNavView :UIView = { | ||
| 54 | + let bottomNavView = UIView(frame: CGRect(x: 0, y: 0, width: self.view.width, height: self.view.height - KTabBarHeight)) | ||
| 55 | + bottomNavView.backgroundColor = HexColor("F2F2F2") | ||
| 56 | + return bottomNavView | ||
| 57 | + }() | ||
| 58 | + | ||
| 59 | + | ||
| 60 | + var titleField:UITextField? | ||
| 61 | + var sortField:UITextField? | ||
| 62 | + var uploadImageView:CNLiveAddGoodsSelectUploadImageView? | ||
| 63 | + | ||
| 64 | + override func viewDidLoad() { | ||
| 65 | + super.viewDidLoad() | ||
| 66 | + self.initUI() | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + /// 初始化方法 | ||
| 70 | + /// @param model 要编辑的分类数据,当isEdite为YES,才需要传 | ||
| 71 | + /// @param isEdite 是否是编辑 YES:是 NO:不是 | ||
| 72 | + func initWithModel(model:CNLiveShopClassifyModel,isEdite:Bool){ | ||
| 73 | + self.shopClassifyModel = model | ||
| 74 | + //设置店铺id | ||
| 75 | + self.shopClassifyModel?.shop_id = DSUserInfoManager.shared.dsUserInfo.id | ||
| 76 | + self.isEdite = isEdite | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + required init?(coder: NSCoder) { | ||
| 80 | + fatalError("init(coder:) has not been implemented") | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + // MARK: - 初始化UI | ||
| 84 | + func initUI(){ | ||
| 85 | + self.view.addSubview(self.tableView) | ||
| 86 | + self.initTopNav() | ||
| 87 | + self.initBottomNav() | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + func initTopNav(){ | ||
| 91 | + if self.isEdite == true{ | ||
| 92 | + self.title = "编辑店铺分类" | ||
| 93 | + let deleteNavBtn = UIButton(type: .custom) | ||
| 94 | + deleteNavBtn.frame = CGRect(x: 0, y: KStatusBarHeight, width: KNavigationHeight-KStatusBarHeight, height: KNavigationHeight-KStatusBarHeight) | ||
| 95 | + deleteNavBtn.backgroundColor = .clear | ||
| 96 | + deleteNavBtn.setTitle("删除", for: .normal) | ||
| 97 | + deleteNavBtn.setTitleColor(HexColor("#666666"), for: .normal) | ||
| 98 | + deleteNavBtn.addTarget(self, action: #selector(deleteNavBtnClick), for: .touchUpInside) | ||
| 99 | + self.rightNavBtns = [deleteNavBtn] | ||
| 100 | + }else{ | ||
| 101 | + self.title = "创建店铺分类" | ||
| 102 | + | ||
| 103 | + //初始化model,赋值一些默认数据 | ||
| 104 | + self.shopClassifyModel = CNLiveShopClassifyModel() | ||
| 105 | + self.shopClassifyModel?.title = "" | ||
| 106 | + self.shopClassifyModel?.simg = "" | ||
| 107 | + self.shopClassifyModel?.shop_id = DSUserInfoManager.shared.dsUserInfo.id | ||
| 108 | + self.shopClassifyModel?.state = "2" | ||
| 109 | + self.shopClassifyModel?.isnav = "2" | ||
| 110 | + if self.classifyType == .twoLevelClassify{ | ||
| 111 | + self.shopClassifyModel?.pid = self.superClassifyId | ||
| 112 | + } | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + func initBottomNav(){ | ||
| 117 | + self.bottomNavView.backgroundColor = .white | ||
| 118 | + | ||
| 119 | + let cancelBtn = UIButton(type: .custom) | ||
| 120 | + cancelBtn.frame = CGRect(x: 0, y: 0, width: 130, height: KTabBarHeight) | ||
| 121 | + cancelBtn.setTitle("取消", for: .normal) | ||
| 122 | + cancelBtn.setTitleColor(HexColor("#3A3A3A"), for: .normal) | ||
| 123 | + cancelBtn.titleLabel?.font = Font_15 | ||
| 124 | + cancelBtn.addTarget(self, action: #selector(cancelBtnClick), for: .touchUpInside) | ||
| 125 | + self.bottomNavView.addSubview(cancelBtn) | ||
| 126 | + | ||
| 127 | + let saveBtn = UIButton(type: .custom) | ||
| 128 | + saveBtn.frame = CGRect(x: cancelBtn.right, y: 0, width: self.view.width - cancelBtn.right, height: KTabBarHeight) | ||
| 129 | + saveBtn.setTitle("保存", for: .normal) | ||
| 130 | + saveBtn.setTitleColor(HexColor("#FFFFFF"), for: .normal) | ||
| 131 | + saveBtn.titleLabel?.font = Font_15 | ||
| 132 | + saveBtn.addTarget(self, action: #selector(saveBtnClick), for: .touchUpInside) | ||
| 133 | + saveBtn.backgroundColor = UIColor(hue:0.31, saturation:0.39, brightness:0.77, alpha:1.00) | ||
| 134 | + self.bottomNavView.addSubview(saveBtn) | ||
| 135 | + | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + // MARK: - UITableViewDelegate | ||
| 139 | + | ||
| 140 | + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
| 141 | + return 1 | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + func numberOfSections(in tableView: UITableView) -> Int { | ||
| 145 | + return 5 | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
| 149 | + if indexPath.section == 0{ | ||
| 150 | + | ||
| 151 | + guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveShopClassifyInputTitelCellID) as? CNLiveShopClassifyInputTitleCell | ||
| 152 | + else { | ||
| 153 | + let cell = CNLiveShopClassifyInputTitleCell() | ||
| 154 | + return cell | ||
| 155 | + } | ||
| 156 | + self.titleField = cell.textFiled | ||
| 157 | + if self.isEdite!{ | ||
| 158 | + cell.textFiled.text = self.shopClassifyModel?.title | ||
| 159 | + } | ||
| 160 | + return cell | ||
| 161 | + }else if (indexPath.section == 1){ | ||
| 162 | + guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveShopClassilyIconTableViewCellID) as? CNLiveShopClassilyIconTableViewCell | ||
| 163 | + else { | ||
| 164 | + let cell = CNLiveShopClassifyInputTitleCell() | ||
| 165 | + return cell | ||
| 166 | + } | ||
| 167 | + self.uploadImageView = cell.selectUploadImageView | ||
| 168 | + cell.uploadImageSuceessBlock = {imageUrl in | ||
| 169 | + self.shopClassifyModel?.simg = imageUrl | ||
| 170 | + } | ||
| 171 | + if self.isEdite!{ | ||
| 172 | + if self.shopClassifyModel?.simg?.count ?? 0 > 0{ | ||
| 173 | + cell.selectUploadImageView?.networkImageArr = [self.shopClassifyModel?.simg ?? ""] | ||
| 174 | + } | ||
| 175 | + } | ||
| 176 | + return cell | ||
| 177 | + }else if (indexPath.section == 2){ | ||
| 178 | + guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveShopClassifyInputSortCellID) as? CNLiveShopClassifyInputSortCell | ||
| 179 | + else { | ||
| 180 | + let cell = CNLiveShopClassifyInputSortCell() | ||
| 181 | + return cell | ||
| 182 | + } | ||
| 183 | + self.sortField = cell.textFiled | ||
| 184 | + if (self.isEdite ?? false) { | ||
| 185 | + cell.textFiled.text = self.shopClassifyModel?.ord | ||
| 186 | + } | ||
| 187 | + return cell | ||
| 188 | + }else if (indexPath.section == 3){ | ||
| 189 | + guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveShopClassifySwitchTableViewCellID) as? CNLiveShopClassifySwitchTableViewCell | ||
| 190 | + else { | ||
| 191 | + let cell = CNLiveShopClassifySwitchTableViewCell() | ||
| 192 | + return cell | ||
| 193 | + } | ||
| 194 | + cell.titlelab.text = "是否显示" | ||
| 195 | + cell.switchType = .classify | ||
| 196 | + if self.shopClassifyModel?.state == "2"{ | ||
| 197 | + cell.rightSwitch.isOn = true | ||
| 198 | + }else{ | ||
| 199 | + cell.rightSwitch.isOn = false | ||
| 200 | + } | ||
| 201 | + cell.switchClickBlock = {on,type in | ||
| 202 | + self.shopClassifyModel?.state = on ? "2" : "1" | ||
| 203 | + let idxPath = IndexPath(row: 0, section: 3) | ||
| 204 | + self.tableView.reloadRows(at: [idxPath], with: .none) | ||
| 205 | + } | ||
| 206 | + return cell | ||
| 207 | + }else if (indexPath.section == 4){ | ||
| 208 | + guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveShopClassifySwitchTableViewCellID) as? CNLiveShopClassifySwitchTableViewCell | ||
| 209 | + else { | ||
| 210 | + let cell = CNLiveShopClassifySwitchTableViewCell() | ||
| 211 | + return cell | ||
| 212 | + } | ||
| 213 | + cell.titlelab.text = "是否显示店铺导航栏" | ||
| 214 | + cell.switchType = .nav | ||
| 215 | + if self.shopClassifyModel?.isnav == "2"{ | ||
| 216 | + cell.rightSwitch.isOn = true | ||
| 217 | + }else{ | ||
| 218 | + cell.rightSwitch.isOn = false | ||
| 219 | + } | ||
| 220 | + cell.switchClickBlock = {on,type in | ||
| 221 | + self.shopClassifyModel?.isnav = on ? "2" : "1" | ||
| 222 | + let idxPath = IndexPath(row: 0, section: 4) | ||
| 223 | + self.tableView.reloadRows(at: [idxPath], with: .none) | ||
| 224 | + } | ||
| 225 | + return cell | ||
| 226 | + } | ||
| 227 | + return UITableViewCell() | ||
| 228 | + } | ||
| 229 | + | ||
| 230 | + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { | ||
| 231 | + if indexPath.section == 0 || indexPath.section == 2{ | ||
| 232 | + return 50 | ||
| 233 | + }else if (indexPath.section == 1){ | ||
| 234 | + return 155 | ||
| 235 | + }else if (indexPath.section == 3 || indexPath.section == 4){ | ||
| 236 | + return 50 | ||
| 237 | + } | ||
| 238 | + return 44 | ||
| 239 | + } | ||
| 240 | + | ||
| 241 | + func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { | ||
| 242 | + self.view.endEditing(true) | ||
| 243 | + } | ||
| 244 | + // MARK: - response method | ||
| 245 | + ///删除 | ||
| 246 | + @objc func deleteNavBtnClick(){ | ||
| 247 | + if self.shopClassifyModel?.id?.isEmpty == true{ | ||
| 248 | + showMessage(message: "分类id不存在") | ||
| 249 | + return | ||
| 250 | + } | ||
| 251 | + AlertTool.showSystemAlert(title: "是否要删除该分类?", message: nil, actionTitles: ["取消","确定"], style: .alert, actionStyles:[.cancel,.default] ) { index in | ||
| 252 | + if index == 2{ | ||
| 253 | + self.deleteClassify() | ||
| 254 | + } | ||
| 255 | + } | ||
| 256 | + } | ||
| 257 | + | ||
| 258 | + ///取消 | ||
| 259 | + @objc func cancelBtnClick(){ | ||
| 260 | + self.navigationController?.popViewController(animated: true) | ||
| 261 | + } | ||
| 262 | + | ||
| 263 | + /// 保存 | ||
| 264 | + @objc func saveBtnClick(){ | ||
| 265 | + self.view.endEditing(true) | ||
| 266 | + if self.uploadImageView?.getCurrentSelectImageUrls().count ?? 0 > 0{ | ||
| 267 | + self.shopClassifyModel?.simg = self.uploadImageView?.getCurrentSelectImageUrls().first | ||
| 268 | + }else{ | ||
| 269 | + self.shopClassifyModel?.simg = "" | ||
| 270 | + } | ||
| 271 | + | ||
| 272 | + if self.titleField?.text?.isEmpty == true{ | ||
| 273 | + showMessage(message: "请输入分类名称") | ||
| 274 | + return | ||
| 275 | + } | ||
| 276 | + if self.titleField?.text?.count ?? 0 > 8{ | ||
| 277 | + showMessage(message: "分类名称最多只能输入8个字,请重新输入") | ||
| 278 | + return | ||
| 279 | + } | ||
| 280 | + if self.shopClassifyModel?.simg?.isEmpty == true{ | ||
| 281 | + showMessage(message: "请选择图标") | ||
| 282 | + return | ||
| 283 | + } | ||
| 284 | + if self.sortField?.text?.isEmpty == true { | ||
| 285 | + showMessage(message: "请输入排序") | ||
| 286 | + return | ||
| 287 | + } | ||
| 288 | + if self.sortField?.text?.isPurnInt() == false{ | ||
| 289 | + showMessage(message: "排序内容只能输入数字") | ||
| 290 | + return | ||
| 291 | + } | ||
| 292 | + | ||
| 293 | + if Int(self.sortField?.text ?? "0") ?? 0 >= 10000{ | ||
| 294 | + showMessage(message: "排序不能大于等于10000") | ||
| 295 | + return | ||
| 296 | + } | ||
| 297 | + if Int(self.sortField?.text ?? "0") ?? 0 == 0{ | ||
| 298 | + showMessage(message: "排序不能等于0") | ||
| 299 | + return | ||
| 300 | + } | ||
| 301 | + self.shopClassifyModel?.title = self.titleField?.text | ||
| 302 | + self.shopClassifyModel?.ord = self.sortField?.text | ||
| 303 | + if self.isEdite == true{ | ||
| 304 | + self.editClassify() | ||
| 305 | + }else{ | ||
| 306 | + self.addClassify() | ||
| 307 | + } | ||
| 308 | + | ||
| 309 | + } | ||
| 310 | + | ||
| 311 | + // MARK: - 网络请求 | ||
| 312 | + ///添加分类 | ||
| 313 | + func addClassify(){ | ||
| 314 | + showLoading(message: "") | ||
| 315 | + CNLiveShopClassilyViewModel.postAddCateRequestWithModel(model: self.shopClassifyModel!) { result, status in | ||
| 316 | + hiddenLoading() | ||
| 317 | + if status == .success{ | ||
| 318 | + showMessage(message: "保存成功") | ||
| 319 | + self.navigationController?.popViewController(animated: true) | ||
| 320 | + self.successCompleteBlock!() | ||
| 321 | + }else{ | ||
| 322 | + showMessage(message: "保存失败") | ||
| 323 | + } | ||
| 324 | + } | ||
| 325 | + } | ||
| 326 | + ///编辑分类 | ||
| 327 | + func editClassify(){ | ||
| 328 | + showLoading(message: "") | ||
| 329 | + CNLiveShopClassilyViewModel.postEditCateRequestWithModel(model: self.shopClassifyModel!) { result, status in | ||
| 330 | + hiddenLoading() | ||
| 331 | + if status == .success{ | ||
| 332 | + showMessage(message: "保存成功") | ||
| 333 | + self.navigationController?.popViewController(animated: true) | ||
| 334 | + self.successCompleteBlock!() | ||
| 335 | + }else{ | ||
| 336 | + showMessage(message: "保存失败") | ||
| 337 | + } | ||
| 338 | + } | ||
| 339 | + } | ||
| 340 | + ///删除分类 | ||
| 341 | + func deleteClassify(){ | ||
| 342 | + showLoading(message: "") | ||
| 343 | + CNLiveShopClassilyViewModel.postDeleteCateRequestWithModel(model: self.shopClassifyModel!) { result, status in | ||
| 344 | + hiddenLoading() | ||
| 345 | + if status == .success{ | ||
| 346 | + showMessage(message: "删除成功") | ||
| 347 | + self.navigationController?.popViewController(animated: true) | ||
| 348 | + self.successCompleteBlock!() | ||
| 349 | + }else{ | ||
| 350 | + showMessage(message: "删除失败") | ||
| 351 | + } | ||
| 352 | + } | ||
| 353 | + } | ||
| 354 | +} |
metaCode/Classes/Main/HomePage/Controller/GoodsManager/CNLiveGoodsCategoryController.swift
| @@ -3,14 +3,583 @@ | @@ -3,14 +3,583 @@ | ||
| 3 | // metaCode | 3 | // metaCode |
| 4 | // | 4 | // |
| 5 | // Created by zx on 2023/11/8. | 5 | // Created by zx on 2023/11/8. |
| 6 | -// | 6 | +// 商品分类/店铺分类 |
| 7 | 7 | ||
| 8 | import Foundation | 8 | import Foundation |
| 9 | 9 | ||
| 10 | -class CNLiveGoodsCategoryController: CNLiveBaseViewController { | 10 | +///分类类型 |
| 11 | +enum CNLiveGoodsCategoryType:Int { | ||
| 12 | + ///商品分类 | ||
| 13 | + case goods | ||
| 14 | + ///店铺分类 | ||
| 15 | + case shop | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +typealias finishSelectCategoryCallBack = ()->Void | ||
| 19 | + | ||
| 20 | +typealias successComplete = ()->Void | ||
| 11 | 21 | ||
| 22 | +class CNLiveGoodsCategoryController: CNLiveBaseViewController, UITableViewDataSource, UITableViewDelegate { | ||
| 23 | + | ||
| 24 | + let kCNLiveShopClassifyCellIdentifier = "kCNLiveShopClassifyCellIdentifier" | ||
| 25 | + | ||
| 26 | + // | ||
| 27 | + var successCompleteBlock:successComplete? | ||
| 28 | + // MARK: - 属性 | ||
| 29 | + //开始输入前的文本 | ||
| 30 | + var firCategoryId:String? | ||
| 31 | + var secCategoryId:String? | ||
| 32 | + var thiCategoryId:String? | ||
| 33 | + var firCategoryName:String? | ||
| 34 | + var secCategoryName:String? | ||
| 35 | + var thiCategoryName:String? | ||
| 36 | + ///分类类型,现在有商品分类,店铺分类 | ||
| 37 | + var categoryType:CNLiveGoodsCategoryType? | ||
| 38 | + //完成回调 | ||
| 39 | + var finishBlock:finishSelectCategoryCallBack? | ||
| 40 | + | ||
| 41 | + var shadowView:UIView? | ||
| 42 | + var contentView:UIView? | ||
| 43 | + var line:UIImageView?//DSImageView | ||
| 44 | + var firCategoryBtn:UIButton? | ||
| 45 | + var secCategoryBtn:UIButton? | ||
| 46 | + var thiCategoryBtn:UIButton? | ||
| 47 | + var selectImageView:UIImageView?//DSImageView | ||
| 48 | + lazy var tableView : UITableView = { | ||
| 49 | + let tableView = UITableView(frame:CGRect(x: 0, y: self.line!.bottom, width: self.contentView!.width, height: self.contentView!.height - self.line!.bottom), style: .plain) | ||
| 50 | + tableView.dataSource = self | ||
| 51 | + tableView.delegate = self | ||
| 52 | + tableView.rowHeight = 40 | ||
| 53 | + tableView.showsVerticalScrollIndicator = false | ||
| 54 | + tableView.backgroundColor = .white | ||
| 55 | + tableView.separatorStyle = .none | ||
| 56 | + let headerView = UIView(frame: CGRect(x: 0, y: 0, width: self.contentView!.width, height: 5)) | ||
| 57 | + tableView.tableHeaderView = headerView | ||
| 58 | + tableView.register(CNLiveShopClassifyCell.self, forCellReuseIdentifier: kCNLiveShopClassifyCellIdentifier) | ||
| 59 | + return tableView | ||
| 60 | + }() | ||
| 61 | + | ||
| 62 | + lazy var firCategoryDataArr: NSMutableArray = { | ||
| 63 | + var firCategoryDataArr = NSMutableArray() | ||
| 64 | + return firCategoryDataArr | ||
| 65 | + }() | ||
| 66 | + lazy var secCategoryDataArr: NSMutableArray = { | ||
| 67 | + var secCategoryDataArr = NSMutableArray() | ||
| 68 | + return secCategoryDataArr | ||
| 69 | + }() | ||
| 70 | + lazy var thiCategoryDataArr: NSMutableArray = { | ||
| 71 | + var thiCategoryDataArr = NSMutableArray() | ||
| 72 | + return thiCategoryDataArr | ||
| 73 | + }() | ||
| 74 | + | ||
| 75 | + /// 创建店铺分类按钮,没创建过店铺分类时展示 | ||
| 76 | + lazy var addShopCalssifyBtn: UIButton = { | ||
| 77 | + let addShopCalssifyBtn = UIButton(type: .custom) | ||
| 78 | + addShopCalssifyBtn.frame = CGRect(x: 0, y: self.contentView!.height/2, width: KSreenWidth, height: 40) | ||
| 79 | + addShopCalssifyBtn.setTitle("创建店铺分类", for: .normal) | ||
| 80 | + addShopCalssifyBtn.setImage(UIImage(named: "DS_WB_CJDP"), for: .normal) | ||
| 81 | + addShopCalssifyBtn.setupButtonImageAndTitlePossitionWith(padding: 8, style: .left) | ||
| 82 | + addShopCalssifyBtn.setTitleColor(HexColor("FD862E"), for: .normal) | ||
| 83 | + addShopCalssifyBtn.titleLabel?.font = Font_15 | ||
| 84 | + addShopCalssifyBtn.addTarget(self, action: #selector(createBtnClick), for: .touchUpInside) | ||
| 85 | + return addShopCalssifyBtn | ||
| 86 | + }() | ||
| 87 | + | ||
| 88 | + var _displayLevel:Int = 0 | ||
| 89 | + var displayLevel:Int { | ||
| 90 | + get{ | ||
| 91 | + _displayLevel | ||
| 92 | + } | ||
| 93 | + set{ | ||
| 94 | + _displayLevel = newValue | ||
| 95 | + UIView.animate(withDuration: 0.2) { | ||
| 96 | + if self.displayLevel == 2{ | ||
| 97 | + self.selectImageView?.centerX = self.secCategoryBtn!.centerX | ||
| 98 | + self.secCategoryBtn?.setTitleColor(HexColor("333333"), for: .normal) | ||
| 99 | + }else if self.displayLevel == 3{ | ||
| 100 | + self.selectImageView?.centerX = self.thiCategoryBtn!.centerX | ||
| 101 | + self.thiCategoryBtn?.setTitleColor(HexColor("333333"), for: .normal) | ||
| 102 | + }else{ | ||
| 103 | + self.selectImageView?.centerX = self.firCategoryBtn!.centerX | ||
| 104 | + } | ||
| 105 | + } | ||
| 106 | + } | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + //临时选中一级分类 | ||
| 110 | + var _temp_selectFirCategoryModel : CNLiveShopGoodsManageDetailsGoodsCategoryModel? | ||
| 111 | + var temp_selectFirCategoryModel : CNLiveShopGoodsManageDetailsGoodsCategoryModel? { | ||
| 112 | + get{ | ||
| 113 | + _temp_selectFirCategoryModel | ||
| 114 | + } | ||
| 115 | + set{ | ||
| 116 | + _temp_selectFirCategoryModel = newValue! | ||
| 117 | + if (_temp_selectFirCategoryModel?.id!.count)! > 0{ | ||
| 118 | + self.firCategoryBtn?.setTitle(_temp_selectFirCategoryModel?.title, for: .normal) | ||
| 119 | + }else{ | ||
| 120 | + self.firCategoryBtn?.setTitle("请选择", for: .normal) | ||
| 121 | + } | ||
| 122 | + } | ||
| 123 | + } | ||
| 124 | + //临时选中二级分类 | ||
| 125 | + var _temp_selectSecCategoryModel : CNLiveShopGoodsManageDetailsGoodsCategoryModel? | ||
| 126 | + var temp_selectSecCategoryModel : CNLiveShopGoodsManageDetailsGoodsCategoryModel? { | ||
| 127 | + get{ | ||
| 128 | + _temp_selectSecCategoryModel | ||
| 129 | + } | ||
| 130 | + set{ | ||
| 131 | + _temp_selectSecCategoryModel = newValue! | ||
| 132 | + if (_temp_selectSecCategoryModel?.id?.count)! > 0{ | ||
| 133 | + self.secCategoryBtn?.setTitle(_temp_selectSecCategoryModel?.title, for: .normal) | ||
| 134 | + self.secCategoryBtn?.setTitleColor(HexColor("#333333"), for: .normal) | ||
| 135 | + }else{ | ||
| 136 | + self.secCategoryBtn?.setTitle("请选择", for: .normal) | ||
| 137 | + if self.displayLevel == 2{ | ||
| 138 | + self.secCategoryBtn?.setTitleColor(HexColor("#333333"), for: .normal) | ||
| 139 | + }else{ | ||
| 140 | + self.secCategoryBtn?.setTitleColor(HexColor("#999999"), for: .normal) | ||
| 141 | + } | ||
| 142 | + } | ||
| 143 | + } | ||
| 144 | + } | ||
| 145 | + //临时选中三级分类 | ||
| 146 | + var _temp_selectThiCategoryModel : CNLiveShopGoodsManageDetailsGoodsCategoryModel? | ||
| 147 | + var temp_selectThiCategoryModel : CNLiveShopGoodsManageDetailsGoodsCategoryModel? { | ||
| 148 | + get{ | ||
| 149 | + _temp_selectThiCategoryModel | ||
| 150 | + } | ||
| 151 | + set{ | ||
| 152 | + _temp_selectThiCategoryModel = newValue! | ||
| 153 | + | ||
| 154 | + if _temp_selectThiCategoryModel!.id!.count > 0{ | ||
| 155 | + self.thiCategoryBtn?.setTitle(_temp_selectThiCategoryModel?.title, for: .normal) | ||
| 156 | + self.thiCategoryBtn?.setTitleColor(HexColor("#333333"), for: .normal) | ||
| 157 | + }else{ | ||
| 158 | + self.thiCategoryBtn?.setTitle("请选择", for: .normal) | ||
| 159 | + if self.displayLevel == 3{ | ||
| 160 | + self.thiCategoryBtn?.setTitleColor(HexColor("#333333"), for: .normal) | ||
| 161 | + }else{ | ||
| 162 | + self.thiCategoryBtn?.setTitleColor(HexColor("#999999"), for: .normal) | ||
| 163 | + } | ||
| 164 | + } | ||
| 165 | + } | ||
| 166 | + } | ||
| 167 | + | ||
| 12 | override func viewDidLoad() { | 168 | override func viewDidLoad() { |
| 13 | super.viewDidLoad() | 169 | super.viewDidLoad() |
| 14 | 170 | ||
| 171 | + self.view.backgroundColor = .clear | ||
| 172 | + self.topNavView.removeFromSuperview() | ||
| 173 | + self.initUI() | ||
| 174 | + if self.firCategoryId == "0" || self.firCategoryId?.count == 0{ | ||
| 175 | + self.secCategoryId = "0" | ||
| 176 | + self.thiCategoryId = "0" | ||
| 177 | + }else if self.secCategoryId == "0" || self.secCategoryId?.count == 0{ | ||
| 178 | + self.thiCategoryId = "0" | ||
| 179 | + } | ||
| 180 | + if self.categoryType == .goods{ | ||
| 181 | + self.postDataWithPid(pid: "0", level: 1) { | ||
| 182 | + if self.secCategoryId?.count ?? 0 > 0 && self.secCategoryId != "0"{ | ||
| 183 | + self.postDataWithPid(pid: self.firCategoryId ?? "", level: 2) { | ||
| 184 | + if self.thiCategoryId?.count ?? 0 > 0 && self.thiCategoryId != "0"{ | ||
| 185 | + self.postDataWithPid(pid: self.secCategoryId ?? "", level: 3) { | ||
| 186 | + } | ||
| 187 | + } | ||
| 188 | + } | ||
| 189 | + } | ||
| 190 | + } | ||
| 191 | + }else if self.categoryType == .shop{ | ||
| 192 | + self.postShopClassify() | ||
| 193 | + } | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + | ||
| 197 | + // MARK: - initUI | ||
| 198 | + func initUI(){ | ||
| 199 | + self.shadowView = UIView(frame: self.view.bounds) | ||
| 200 | + self.shadowView?.backgroundColor = UIColor(white: 0, alpha: 0.26) | ||
| 201 | + self.shadowView?.alpha = 0 | ||
| 202 | + self.view.addSubview(self.shadowView!) | ||
| 203 | + let shadowViewTap = UITapGestureRecognizer(target: self, action: #selector(shadowViewTap)) | ||
| 204 | + self.shadowView?.addGestureRecognizer(shadowViewTap) | ||
| 205 | + | ||
| 206 | + self.contentView = UIView(frame: CGRect(x: 0, y: self.view.height, width: self.view.width, height: 400)) | ||
| 207 | + self.contentView?.backgroundColor = .white | ||
| 208 | + self.view.addSubview(self.contentView!) | ||
| 209 | + | ||
| 210 | + self.line = UIImageView(frame: CGRect(x: 0, y: 49-DS_RRV_ONE_PIXEL, width: self.view.width, height: DS_RRV_ONE_PIXEL)) | ||
| 211 | + self.line!.clipsToBounds = true | ||
| 212 | + self.line!.contentMode = .scaleAspectFit | ||
| 213 | + self.line!.backgroundColor = HexColor("#EBE9EA") | ||
| 214 | + self.contentView?.addSubview(self.line!) | ||
| 215 | + | ||
| 216 | + self.firCategoryBtn = UIButton(type: .custom) | ||
| 217 | + self.firCategoryBtn?.frame = CGRect(x: 5, y: 0, width: 59, height: 49) | ||
| 218 | + self.firCategoryBtn?.setTitle("请选择", for: .normal) | ||
| 219 | + self.firCategoryBtn?.setTitleColor(HexColor("#333333"), for: .normal) | ||
| 220 | + self.firCategoryBtn?.clipsToBounds = true | ||
| 221 | + self.firCategoryBtn?.titleLabel?.font = Font_13 | ||
| 222 | + self.firCategoryBtn?.titleLabel?.lineBreakMode = .byTruncatingTail | ||
| 223 | + self.firCategoryBtn?.addTarget(self, action: #selector(firCategoryBtnClick), for: .touchUpInside) | ||
| 224 | + self.contentView?.addSubview(self.firCategoryBtn!) | ||
| 225 | + | ||
| 226 | + self.secCategoryBtn = UIButton(type: .custom) | ||
| 227 | + self.secCategoryBtn?.frame = CGRect(x: self.firCategoryBtn!.right+5, y: 0, width: 59, height: 49) | ||
| 228 | + self.secCategoryBtn?.setTitle("请选择", for: .normal) | ||
| 229 | + self.secCategoryBtn?.setTitleColor(HexColor("#999999"), for: .normal) | ||
| 230 | + self.secCategoryBtn?.clipsToBounds = true | ||
| 231 | + self.secCategoryBtn?.titleLabel?.font = Font_13 | ||
| 232 | + self.secCategoryBtn?.titleLabel?.lineBreakMode = .byTruncatingTail | ||
| 233 | + self.secCategoryBtn?.addTarget(self, action: #selector(secCategoryBtnClick), for: .touchUpInside) | ||
| 234 | + self.contentView?.addSubview(self.secCategoryBtn!) | ||
| 235 | + | ||
| 236 | + self.thiCategoryBtn = UIButton(type: .custom) | ||
| 237 | + self.thiCategoryBtn?.frame = CGRect(x: self.secCategoryBtn!.right+5, y: 0, width: 59, height: 49) | ||
| 238 | + self.thiCategoryBtn?.setTitle("请选择", for: .normal) | ||
| 239 | + self.thiCategoryBtn?.setTitleColor(HexColor("#999999"), for: .normal) | ||
| 240 | + self.thiCategoryBtn?.clipsToBounds = true | ||
| 241 | + self.thiCategoryBtn?.titleLabel?.font = Font_13 | ||
| 242 | + self.thiCategoryBtn?.titleLabel?.lineBreakMode = .byTruncatingTail | ||
| 243 | + self.thiCategoryBtn?.addTarget(self, action: #selector(thiCategoryBtnClick), for: .touchUpInside) | ||
| 244 | + self.contentView?.addSubview(self.thiCategoryBtn!) | ||
| 245 | + | ||
| 246 | + if self.categoryType == .goods{ | ||
| 247 | + ///商品分类三级 | ||
| 248 | + self.thiCategoryBtn?.isHidden = false | ||
| 249 | + }else if self.categoryType == .shop{ | ||
| 250 | + ///店铺分类二级 | ||
| 251 | + self.thiCategoryBtn?.isHidden = true | ||
| 252 | + } | ||
| 253 | + self.selectImageView = UIImageView(frame: CGRect(x: 0, y: self.line!.bottom - 2, width: 39, height: 2)) | ||
| 254 | + self.selectImageView!.clipsToBounds = true | ||
| 255 | + self.selectImageView!.contentMode = .scaleAspectFit | ||
| 256 | + self.selectImageView!.backgroundColor = HexColor("#FC1541") | ||
| 257 | + self.contentView?.addSubview(self.selectImageView!) | ||
| 258 | + self.selectImageView!.centerX = self.firCategoryBtn!.centerX | ||
| 259 | + | ||
| 260 | + | ||
| 261 | + let confirmBtn = UIButton(type: .custom) | ||
| 262 | + confirmBtn.frame = CGRect(x: self.contentView!.width-49, y: 0, width: 49, height: 49) | ||
| 263 | + confirmBtn.setTitle("确定", for: .normal) | ||
| 264 | + confirmBtn.setTitleColor(HexColor("#333333"), for: .normal) | ||
| 265 | + confirmBtn.titleLabel?.font = Font_13 | ||
| 266 | + confirmBtn.addTarget(self, action: #selector(confirmBtnClick), for: .touchUpInside) | ||
| 267 | + self.contentView?.addSubview(confirmBtn) | ||
| 268 | + | ||
| 269 | + self.contentView?.addSubview(self.tableView) | ||
| 15 | } | 270 | } |
| 271 | + | ||
| 272 | + // MARK: - 显示/隐藏方法 | ||
| 273 | + public func display(){ | ||
| 274 | + self.view.isUserInteractionEnabled = true | ||
| 275 | + UIView.animate(withDuration: 0.2) { | ||
| 276 | + self.shadowView?.alpha = 1 | ||
| 277 | + self.contentView!.top = self.view.height-400 | ||
| 278 | + } | ||
| 279 | + } | ||
| 280 | + public func hide(){ | ||
| 281 | + UIView.animate(withDuration: 0.2) { | ||
| 282 | + self.shadowView?.alpha = 0 | ||
| 283 | + self.contentView!.top = self.view.height | ||
| 284 | + }completion: { finished in | ||
| 285 | + self.view.isUserInteractionEnabled = false | ||
| 286 | + } | ||
| 287 | + } | ||
| 288 | + public func hideView(){ | ||
| 289 | + self.shadowView?.alpha = 0 | ||
| 290 | + self.contentView!.top = self.view.height | ||
| 291 | + self.view.isUserInteractionEnabled = false | ||
| 292 | + } | ||
| 293 | + | ||
| 294 | + // MARK: - UITableViewDelegate | ||
| 295 | + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
| 296 | + if (self.displayLevel == 1) { | ||
| 297 | + return self.firCategoryDataArr.count | ||
| 298 | + }else if (self.displayLevel == 2) { | ||
| 299 | + return self.secCategoryDataArr.count | ||
| 300 | + }else if (self.displayLevel == 3) { | ||
| 301 | + return self.thiCategoryDataArr.count | ||
| 302 | + }else { | ||
| 303 | + return 0 | ||
| 304 | + } | ||
| 305 | + } | ||
| 306 | + | ||
| 307 | + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
| 308 | + guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveShopClassifyCellIdentifier) as? CNLiveShopClassifyCell | ||
| 309 | + else { | ||
| 310 | + let cell = CNLiveShopClassifyCell() | ||
| 311 | + return cell | ||
| 312 | + } | ||
| 313 | + if self.displayLevel == 1{ | ||
| 314 | + let model = self.firCategoryDataArr[indexPath.row] as! CNLiveShopGoodsManageDetailsGoodsCategoryModel | ||
| 315 | + cell.titleLabel.text = model.title | ||
| 316 | + if model.id == self.temp_selectFirCategoryModel?.id{ | ||
| 317 | + cell.titleLabel.textColor = HexColor("#FC1541") | ||
| 318 | + }else{ | ||
| 319 | + cell.titleLabel.textColor = HexColor("#666666") | ||
| 320 | + } | ||
| 321 | + }else if (self.displayLevel == 2) { | ||
| 322 | + let model = self.secCategoryDataArr[indexPath.row] as! CNLiveShopGoodsManageDetailsGoodsCategoryModel | ||
| 323 | + cell.titleLabel.text = model.title | ||
| 324 | + if model.id == self.temp_selectSecCategoryModel?.id{ | ||
| 325 | + cell.titleLabel.textColor = HexColor("#FC1541") | ||
| 326 | + }else{ | ||
| 327 | + cell.titleLabel.textColor = HexColor("#666666") | ||
| 328 | + } | ||
| 329 | + }else if (self.displayLevel == 3) { | ||
| 330 | + let model = self.thiCategoryDataArr[indexPath.row] as! CNLiveShopGoodsManageDetailsGoodsCategoryModel | ||
| 331 | + cell.titleLabel.text = model.title | ||
| 332 | + if model.id == self.temp_selectThiCategoryModel?.id{ | ||
| 333 | + cell.titleLabel.textColor = HexColor("#FC1541") | ||
| 334 | + }else{ | ||
| 335 | + cell.titleLabel.textColor = HexColor("#666666") | ||
| 336 | + } | ||
| 337 | + }else{ | ||
| 338 | + cell.titleLabel.text = "" | ||
| 339 | + } | ||
| 340 | + return cell | ||
| 341 | + } | ||
| 342 | + | ||
| 343 | + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | ||
| 344 | + if self.categoryType == .goods{ | ||
| 345 | + if self.displayLevel == 1{ | ||
| 346 | + let model = self.firCategoryDataArr[indexPath.row] as! CNLiveShopGoodsManageDetailsGoodsCategoryModel | ||
| 347 | + self.postDataWithPid(pid: model.id!, level: 2) { | ||
| 348 | + self.temp_selectFirCategoryModel = model | ||
| 349 | + self.temp_selectSecCategoryModel = nil | ||
| 350 | + self.temp_selectThiCategoryModel = nil | ||
| 351 | + } | ||
| 352 | + }else if (self.displayLevel == 2) { | ||
| 353 | + let model = self.secCategoryDataArr[indexPath.row] as! CNLiveShopGoodsManageDetailsGoodsCategoryModel | ||
| 354 | + self.postDataWithPid(pid: model.id!, level: 3) { | ||
| 355 | + self.temp_selectSecCategoryModel = model | ||
| 356 | + self.temp_selectThiCategoryModel = nil | ||
| 357 | + } | ||
| 358 | + }else if (self.displayLevel == 3) { | ||
| 359 | + let model = self.thiCategoryDataArr[indexPath.row] as! CNLiveShopGoodsManageDetailsGoodsCategoryModel | ||
| 360 | + self.temp_selectThiCategoryModel = model | ||
| 361 | + self.tableView.reloadData() | ||
| 362 | + } | ||
| 363 | + }else if self.categoryType == .shop{ | ||
| 364 | + if (self.displayLevel == 1) { | ||
| 365 | + let model = self.firCategoryDataArr[indexPath.row] as! CNLiveShopClassifyModel | ||
| 366 | + let tempFirMdl = CNLiveShopGoodsManageDetailsGoodsCategoryModel() | ||
| 367 | + tempFirMdl.id = model.id | ||
| 368 | + tempFirMdl.title = model.title | ||
| 369 | + self.temp_selectFirCategoryModel = tempFirMdl | ||
| 370 | + self.temp_selectSecCategoryModel = nil | ||
| 371 | + if (model.child.count == 0) { | ||
| 372 | + self.tableView.reloadData() | ||
| 373 | + return | ||
| 374 | + } | ||
| 375 | + self.displayLevel = 2 | ||
| 376 | + self.secCategoryDataArr = NSMutableArray(array: model.child) | ||
| 377 | + self.tableView.reloadData() | ||
| 378 | + }else if (self.displayLevel == 2){ | ||
| 379 | + let model = self.secCategoryDataArr[indexPath.row] as! CNLiveShopClassifyModel | ||
| 380 | + let tempFirMdl = CNLiveShopGoodsManageDetailsGoodsCategoryModel() | ||
| 381 | + tempFirMdl.id = model.id | ||
| 382 | + tempFirMdl.title = model.title | ||
| 383 | + self.temp_selectSecCategoryModel = tempFirMdl | ||
| 384 | + self.tableView.reloadData() | ||
| 385 | + } | ||
| 386 | + } | ||
| 387 | + } | ||
| 388 | + | ||
| 389 | + // MARK: - 触发事件 | ||
| 390 | + @objc func shadowViewTap(){ | ||
| 391 | + self.hide() | ||
| 392 | + } | ||
| 393 | + | ||
| 394 | + @objc func confirmBtnClick(){ | ||
| 395 | + if self.categoryType == .goods{ | ||
| 396 | + if (self.temp_selectFirCategoryModel == nil) || (self.temp_selectSecCategoryModel == nil) || (self.temp_selectThiCategoryModel == nil){ | ||
| 397 | + showMessage(message: "未选择三级分类") | ||
| 398 | + return | ||
| 399 | + } | ||
| 400 | + }else if self.categoryType == .shop{ | ||
| 401 | + if (self.temp_selectFirCategoryModel == nil && self.temp_selectSecCategoryModel == nil){ | ||
| 402 | + showMessage(message: "请选择级分类") | ||
| 403 | + return | ||
| 404 | + } | ||
| 405 | + //需要看能不能转成功 | ||
| 406 | + let classModel = self.temp_selectFirCategoryModel as? CNLiveShopClassifyModel | ||
| 407 | + //DSShopClassifyModel *classModel = (DSShopClassifyModel *)self.temp_selectFirCategoryModel; | ||
| 408 | + if classModel!.child.count > 0 && self.temp_selectSecCategoryModel == nil{ | ||
| 409 | + showMessage(message: "未选择二级分类") | ||
| 410 | + return | ||
| 411 | + } | ||
| 412 | + } | ||
| 413 | + | ||
| 414 | + self.firCategoryId = self.temp_selectFirCategoryModel?.id | ||
| 415 | + self.firCategoryName = self.temp_selectFirCategoryModel?.title | ||
| 416 | + self.secCategoryId = self.temp_selectSecCategoryModel?.id | ||
| 417 | + self.secCategoryName = self.temp_selectSecCategoryModel?.title | ||
| 418 | + self.thiCategoryId = self.temp_selectThiCategoryModel?.id | ||
| 419 | + self.thiCategoryName = self.temp_selectThiCategoryModel?.title | ||
| 420 | + self.finishBlock!() | ||
| 421 | + self.hide() | ||
| 422 | + } | ||
| 423 | + | ||
| 424 | + @objc func firCategoryBtnClick(){ | ||
| 425 | + self.displayLevel = 1 | ||
| 426 | + self.tableView.reloadData() | ||
| 427 | + self.tableView.setContentOffset(CGPointZero, animated: true) | ||
| 428 | + if self.temp_selectSecCategoryModel != nil{ | ||
| 429 | + self.secCategoryBtn?.setTitleColor(HexColor("#333333"), for: .normal) | ||
| 430 | + if self.temp_selectThiCategoryModel != nil{ | ||
| 431 | + self.thiCategoryBtn?.setTitleColor(HexColor("#333333"), for: .normal) | ||
| 432 | + }else{ | ||
| 433 | + self.thiCategoryBtn?.setTitleColor(HexColor("#999999"), for: .normal) | ||
| 434 | + } | ||
| 435 | + }else{ | ||
| 436 | + self.secCategoryBtn?.setTitleColor(HexColor("#999999"), for: .normal) | ||
| 437 | + self.thiCategoryBtn?.setTitleColor(HexColor("#999999"), for: .normal) | ||
| 438 | + } | ||
| 439 | + } | ||
| 440 | + | ||
| 441 | + @objc func secCategoryBtnClick(){ | ||
| 442 | + if self.categoryType == .shop{ | ||
| 443 | + //需要看能不能转成功 | ||
| 444 | + let model = self.temp_selectFirCategoryModel as? CNLiveShopClassifyModel | ||
| 445 | + if model?.child.count == 0 { | ||
| 446 | + showMessage(message: "该分类暂没有添加子分类") | ||
| 447 | + return | ||
| 448 | + } | ||
| 449 | + } | ||
| 450 | + if self.temp_selectFirCategoryModel == nil{ | ||
| 451 | + return | ||
| 452 | + } | ||
| 453 | + self.displayLevel = 2 | ||
| 454 | + self.tableView.reloadData() | ||
| 455 | + self.tableView.setContentOffset(CGPointZero, animated: true) | ||
| 456 | + if self.temp_selectThiCategoryModel != nil{ | ||
| 457 | + self.thiCategoryBtn?.setTitleColor(HexColor("#333333"), for: .normal) | ||
| 458 | + }else{ | ||
| 459 | + self.thiCategoryBtn?.setTitleColor(HexColor("#999999"), for: .normal) | ||
| 460 | + } | ||
| 461 | + } | ||
| 462 | + @objc func thiCategoryBtnClick(){ | ||
| 463 | + if self.temp_selectSecCategoryModel == nil{ | ||
| 464 | + return | ||
| 465 | + } | ||
| 466 | + self.displayLevel = 3 | ||
| 467 | + self.tableView.reloadData() | ||
| 468 | + self.tableView.setContentOffset(CGPointZero, animated: true) | ||
| 469 | + } | ||
| 470 | + | ||
| 471 | + ///创建店铺分类 | ||
| 472 | + @objc func createBtnClick(){ | ||
| 473 | + let vc = CNLiveCreateShopClassifyViewController() | ||
| 474 | + vc.classifyType = .oneLevelClassify | ||
| 475 | + vc.successCompleteBlock = { | ||
| 476 | + self.postShopClassify() | ||
| 477 | + } | ||
| 478 | + self.navigationController?.pushViewController(vc, animated: false) | ||
| 479 | + } | ||
| 480 | + | ||
| 481 | + | ||
| 482 | + // MARK: - 数据请求 | ||
| 483 | + /** | ||
| 484 | + 商品分类数据请求 | ||
| 485 | + | ||
| 486 | + @param pid 父级id | ||
| 487 | + @param level 第几级 | ||
| 488 | + */ | ||
| 489 | + func postDataWithPid(pid:String,level:Int,successCompleteBlock:successComplete){ | ||
| 490 | + showLoading(message: "") | ||
| 491 | + CNLiveShopGoodListViewModel.getGetGroupWithUid(uid: DSUserInfoManager.shared.dsUserInfo.uid!, pid: pid) { result, status in | ||
| 492 | + hiddenLoading() | ||
| 493 | + if status == .success{ | ||
| 494 | + | ||
| 495 | + let dataArr = result as! [CNLiveShopGoodsManageDetailsGoodsCategoryModel] | ||
| 496 | + self.displayLevel = level | ||
| 497 | + if level == 1{ | ||
| 498 | + self.firCategoryDataArr = NSMutableArray(array: dataArr) | ||
| 499 | + self.temp_selectSecCategoryModel = nil | ||
| 500 | + self.temp_selectThiCategoryModel = nil | ||
| 501 | + self.secCategoryDataArr.removeAllObjects() | ||
| 502 | + self.thiCategoryDataArr.removeAllObjects() | ||
| 503 | + if self.firCategoryId?.count ?? 0 > 0 && self.firCategoryId != "0"{ | ||
| 504 | + | ||
| 505 | + let tempDataArr = Array(self.firCategoryDataArr) | ||
| 506 | + for (_,mdl) in tempDataArr.enumerated() { | ||
| 507 | + let model = mdl as! CNLiveShopGoodsManageDetailsGoodsCategoryModel | ||
| 508 | + if model.id == self.firCategoryId{ | ||
| 509 | + self.temp_selectFirCategoryModel = model | ||
| 510 | + break | ||
| 511 | + } | ||
| 512 | + } | ||
| 513 | + } | ||
| 514 | + }else if (level == 2){ | ||
| 515 | + self.secCategoryDataArr = NSMutableArray(array: dataArr) | ||
| 516 | + self.temp_selectSecCategoryModel = nil | ||
| 517 | + self.temp_selectThiCategoryModel = nil | ||
| 518 | + self.thiCategoryDataArr.removeAllObjects() | ||
| 519 | + if self.secCategoryId?.count ?? 0 > 0 && self.secCategoryId != "0"{ | ||
| 520 | + let tempDataArr = Array(self.thiCategoryDataArr) | ||
| 521 | + for (_,mdl) in tempDataArr.enumerated() { | ||
| 522 | + let model = mdl as! CNLiveShopGoodsManageDetailsGoodsCategoryModel | ||
| 523 | + if model.id == self.secCategoryId{ | ||
| 524 | + self.temp_selectSecCategoryModel = model | ||
| 525 | + break | ||
| 526 | + } | ||
| 527 | + } | ||
| 528 | + }else { | ||
| 529 | + self.secCategoryBtn?.setTitle("请选择", for: .normal) | ||
| 530 | + } | ||
| 531 | + }else if (level == 3) { | ||
| 532 | + self.thiCategoryDataArr = NSMutableArray(array: dataArr) | ||
| 533 | + self.temp_selectThiCategoryModel = nil | ||
| 534 | + if self.thiCategoryId?.count ?? 0 > 0 && self.thiCategoryId != "0"{ | ||
| 535 | + let tempDataArr = Array(self.thiCategoryDataArr) | ||
| 536 | + for (_,mdl) in tempDataArr.enumerated() { | ||
| 537 | + let model = mdl as! CNLiveShopGoodsManageDetailsGoodsCategoryModel | ||
| 538 | + if model.id == self.thiCategoryId{ | ||
| 539 | + self.temp_selectThiCategoryModel = model | ||
| 540 | + break | ||
| 541 | + } | ||
| 542 | + } | ||
| 543 | + }else { | ||
| 544 | + self.thiCategoryBtn?.setTitle("请选择", for: .normal) | ||
| 545 | + } | ||
| 546 | + } | ||
| 547 | + self.tableView.reloadData() | ||
| 548 | + self.tableView.setContentOffset(CGPointZero, animated: true) | ||
| 549 | + self.successCompleteBlock!() | ||
| 550 | + | ||
| 551 | + }else if (status == .failed){ | ||
| 552 | +// self.network_type = .failed | ||
| 553 | + }else if (status == .noNetwork){ | ||
| 554 | +// self.network_type = .noNetwork | ||
| 555 | + } | ||
| 556 | + } | ||
| 557 | + } | ||
| 558 | + | ||
| 559 | + ///店铺分类数据请求 | ||
| 560 | + func postShopClassify(){ | ||
| 561 | + showLoading(message: "") | ||
| 562 | + CNLiveShopGoodListViewModel.getCateListWithShopId(shopId: DSUserInfoManager.shared.dsUserInfo.id!) { result, status in | ||
| 563 | + hiddenLoading() | ||
| 564 | + if status == .success{ | ||
| 565 | + let classifyListModel = result as! CNLiveShopClassifyListModel | ||
| 566 | + self.firCategoryDataArr = NSMutableArray(array: classifyListModel.list) | ||
| 567 | + self.displayLevel = 1 | ||
| 568 | + self.tableView.reloadData() | ||
| 569 | + | ||
| 570 | + if (self.firCategoryDataArr.count == 0) { | ||
| 571 | + self.contentView?.addSubview(self.addShopCalssifyBtn) | ||
| 572 | + } | ||
| 573 | + else{ | ||
| 574 | + self.addShopCalssifyBtn.removeFromSuperview() | ||
| 575 | + } | ||
| 576 | + }else if (status == .failed){ | ||
| 577 | + //self.network_type = .failed | ||
| 578 | + | ||
| 579 | + }else if (status == .noNetwork){ | ||
| 580 | + //self.network_type = .noNetwork | ||
| 581 | + } | ||
| 582 | + } | ||
| 583 | + } | ||
| 584 | + | ||
| 16 | } | 585 | } |
metaCode/Classes/Main/HomePage/Controller/GoodsManager/CNLiveModalPresentationViewController.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveModalPresentationViewController.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by zx on 2023/11/16. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | + | ||
| 10 | +typealias completionBlock = (_ finished:Bool)->Void | ||
| 11 | + | ||
| 12 | +class CNLiveModalPresentationViewController:UIViewController{ | ||
| 13 | + | ||
| 14 | + var _contentView:UIView? | ||
| 15 | + var contentView:UIView?{ | ||
| 16 | + get{ | ||
| 17 | + _contentView | ||
| 18 | + } | ||
| 19 | + set{ | ||
| 20 | + _contentView = newValue | ||
| 21 | + | ||
| 22 | + } | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + override func viewDidLoad() { | ||
| 26 | + super.viewDidLoad() | ||
| 27 | + self.view.backgroundColor = .clear | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + func showingAnimationWithCompletion(completion:completionBlock){ | ||
| 31 | + | ||
| 32 | + self.contentView?.transform = CGAffineTransformMakeTranslation(0, self.view.height-(self.contentView?.top)!) | ||
| 33 | + UIView.animate(withDuration: 0.3, delay: 0.0, options: .curveEaseOut) { | ||
| 34 | + self.contentView?.transform = CGAffineTransformIdentity | ||
| 35 | + } completion: { finished in | ||
| 36 | + completion(finished) | ||
| 37 | + } | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + func hidingAnimationWithCompletion(completion:completionBlock){ | ||
| 41 | + UIView.animate(withDuration: 0.3, delay: 0.0, options: .curveEaseOut) { | ||
| 42 | + self.contentView?.transform = CGAffineTransformMakeTranslation(0, self.view.height-self.contentView!.top) | ||
| 43 | + } completion: { finished in | ||
| 44 | + self.contentView?.transform = CGAffineTransformIdentity | ||
| 45 | + completion(finished) | ||
| 46 | + } | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + | ||
| 50 | + | ||
| 51 | +} |
metaCode/Classes/Main/HomePage/Controller/GoodsManager/CNLiveShopNewProductController.swift
| @@ -19,7 +19,12 @@ enum CNLiveShopGoodsAddEditType{ | @@ -19,7 +19,12 @@ enum CNLiveShopGoodsAddEditType{ | ||
| 19 | class CNLiveShopNewProductController:CNLiveBaseViewController{ | 19 | class CNLiveShopNewProductController:CNLiveBaseViewController{ |
| 20 | 20 | ||
| 21 | var type:CNLiveShopGoodsAddEditType = .add | 21 | var type:CNLiveShopGoodsAddEditType = .add |
| 22 | + | ||
| 23 | + ///最大价格 | ||
| 24 | + let kCNLiveShopMaxPrice = 10000000 | ||
| 22 | var goodsId = "" | 25 | var goodsId = "" |
| 26 | + var isRequestAdd:Bool = false | ||
| 27 | + | ||
| 23 | lazy var bgScrollView :UIScrollView = { | 28 | lazy var bgScrollView :UIScrollView = { |
| 24 | let bgScrollView = UIScrollView(frame: CGRect(x: 0, y: KNavigationHeight, width: KSreenWidth, height: KSreenHeight-KNavigationHeight-KTabBarHeight)) | 29 | let bgScrollView = UIScrollView(frame: CGRect(x: 0, y: KNavigationHeight, width: KSreenWidth, height: KSreenHeight-KNavigationHeight-KTabBarHeight)) |
| 25 | bgScrollView.showsVerticalScrollIndicator = false | 30 | bgScrollView.showsVerticalScrollIndicator = false |
| @@ -30,8 +35,36 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | @@ -30,8 +35,36 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | ||
| 30 | let dataModel = CNLiveShopAddEditGoodsModel() | 35 | let dataModel = CNLiveShopAddEditGoodsModel() |
| 31 | return dataModel | 36 | return dataModel |
| 32 | }() | 37 | }() |
| 38 | + lazy var shopGoodsDetailsModel: CNLiveShopGoodsDetailsModel = { | ||
| 39 | + let shopGoodsDetailsModel = CNLiveShopGoodsDetailsModel() | ||
| 40 | + return shopGoodsDetailsModel | ||
| 41 | + }() | ||
| 42 | + var selectCategoryVC:CNLiveGoodsCategoryController? | ||
| 43 | + | ||
| 44 | + lazy var selectShopClassifyVC:CNLiveGoodsCategoryController = { | ||
| 45 | + let vc = CNLiveGoodsCategoryController() | ||
| 46 | + | ||
| 47 | + vc.categoryType = .shop | ||
| 48 | + if self.shopGoodsDetailsModel.id!.count > 0{ | ||
| 49 | + vc.firCategoryId = self.shopGoodsDetailsModel.category_id | ||
| 50 | + vc.secCategoryId = self.shopGoodsDetailsModel.category_id2 | ||
| 51 | + } | ||
| 52 | + vc.finishBlock = { | ||
| 53 | + var singleView = self.getShopClassifyView() | ||
| 54 | + singleView.contentTextField.text = "\(self.selectShopClassifyVC.firCategoryName ?? "") \(self.selectShopClassifyVC.secCategoryName ?? "")" | ||
| 55 | + singleView.layoutSubviews() | ||
| 56 | + } | ||
| 57 | + self.addChild(vc) | ||
| 58 | + vc.view.frame = CGRect(x: 0, y: 0, width: self.view.width, height: self.view.height) | ||
| 59 | + self.view.addSubview(vc.view) | ||
| 60 | + vc.didMove(toParent: self) | ||
| 61 | + self.selectShopClassifyVC = vc | ||
| 62 | + self.selectShopClassifyVC.hideView() | ||
| 63 | + return self.selectShopClassifyVC | ||
| 64 | + | ||
| 65 | + }() | ||
| 66 | + | ||
| 33 | 67 | ||
| 34 | - var selectCategoryVC = CNLiveGoodsCategoryController() | ||
| 35 | lazy var bottomNavView :UIView = { | 68 | lazy var bottomNavView :UIView = { |
| 36 | let bottomNavView = UIView(frame: CGRect(x: 0, y: KSreenHeight-KTabBarHeight, width: self.view.width, height: KTabBarHeight)) | 69 | let bottomNavView = UIView(frame: CGRect(x: 0, y: KSreenHeight-KTabBarHeight, width: self.view.width, height: KTabBarHeight)) |
| 37 | bottomNavView.backgroundColor = HexColor("F2F2F2") | 70 | bottomNavView.backgroundColor = HexColor("F2F2F2") |
| @@ -44,6 +77,9 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | @@ -44,6 +77,9 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | ||
| 44 | self.bgScrollView.backgroundColor = .white | 77 | self.bgScrollView.backgroundColor = .white |
| 45 | self.view.addSubview(self.bgScrollView) | 78 | self.view.addSubview(self.bgScrollView) |
| 46 | self.initBgScrollViewContentView() | 79 | self.initBgScrollViewContentView() |
| 80 | + if (self.type == .edit) { | ||
| 81 | + self.requestGoodsData() | ||
| 82 | + } | ||
| 47 | } | 83 | } |
| 48 | 84 | ||
| 49 | override func viewWillLayoutSubviews() { | 85 | override func viewWillLayoutSubviews() { |
| @@ -59,12 +95,34 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | @@ -59,12 +95,34 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | ||
| 59 | lastView = singleView | 95 | lastView = singleView |
| 60 | } | 96 | } |
| 61 | self.bgScrollView.contentSize = CGSize(width: self.bgScrollView.width, height: lastView?.bottom ?? 0) | 97 | self.bgScrollView.contentSize = CGSize(width: self.bgScrollView.width, height: lastView?.bottom ?? 0) |
| 62 | - self.selectCategoryVC.view.frame = CGRect(x: 0, y: 0, width: self.view.width, height: self.view.height) | 98 | + self.selectCategoryVC!.view.frame = CGRect(x: 0, y: 0, width: self.view.width, height: self.view.height) |
| 63 | } | 99 | } |
| 64 | 100 | ||
| 101 | + deinit { | ||
| 102 | + for i in 0..<self.dataModel.list.count{ | ||
| 103 | + let singleView = self.view.viewWithTag(i+1) as! CNLiveShopAddGoodsSingleView | ||
| 104 | + if singleView.addEditGoodsListModel?.style == "3"{ | ||
| 105 | + singleView.uploadImageView.deleteUploadImageUrlAfterCancelUploadThings() | ||
| 106 | + } | ||
| 107 | + } | ||
| 108 | + } | ||
| 65 | func setUI(){ | 109 | func setUI(){ |
| 66 | navigationBarHidden = false | 110 | navigationBarHidden = false |
| 67 | titleName = "新增商品" | 111 | titleName = "新增商品" |
| 112 | + if (self.type == .add) { | ||
| 113 | + titleName = "新增商品" | ||
| 114 | + }else { | ||
| 115 | + titleName = "编辑商品" | ||
| 116 | + let deleteNavBtn = UIButton(type: .custom) | ||
| 117 | + deleteNavBtn.frame = CGRect(x: 0, y: KStatusBarHeight, width: KNavigationHeight-KStatusBarHeight, height: KNavigationHeight-KStatusBarHeight) | ||
| 118 | + deleteNavBtn.backgroundColor = .clear | ||
| 119 | + deleteNavBtn.setTitle("删除", for: .normal) | ||
| 120 | + deleteNavBtn.setTitleColor(HexColor("#FC1541"), for: .normal) | ||
| 121 | + deleteNavBtn.addTarget(self, action: #selector(deleteNavBtnClick), for: .touchUpInside) | ||
| 122 | + self.rightNavBtns = [deleteNavBtn] | ||
| 123 | + | ||
| 124 | + } | ||
| 125 | + | ||
| 68 | self.initBottomView() | 126 | self.initBottomView() |
| 69 | } | 127 | } |
| 70 | func initBottomView(){ | 128 | func initBottomView(){ |
| @@ -90,7 +148,9 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | @@ -90,7 +148,9 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | ||
| 90 | 148 | ||
| 91 | func initBgScrollViewContentView(){ | 149 | func initBgScrollViewContentView(){ |
| 92 | if self.type == .edit{ | 150 | if self.type == .edit{ |
| 93 | - | 151 | + var tempArray = Array(self.dataModel.list) |
| 152 | + tempArray.removeSubrange(self.dataModel.list.count - 3..<3) | ||
| 153 | + self.dataModel.list = tempArray | ||
| 94 | } | 154 | } |
| 95 | self.dataModel.initDataSource() | 155 | self.dataModel.initDataSource() |
| 96 | for i in 0..<self.dataModel.list.count { | 156 | for i in 0..<self.dataModel.list.count { |
| @@ -104,29 +164,173 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | @@ -104,29 +164,173 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | ||
| 104 | } | 164 | } |
| 105 | singleView.tapBlock = { single in | 165 | singleView.tapBlock = { single in |
| 106 | // TODO: | 166 | // TODO: |
| 107 | -// if (single.tag == 1) { | ||
| 108 | -// //点击了商品分类 | ||
| 109 | -// | ||
| 110 | -// if (self.type == DSShopGoodsManageDetailsVCTypeEdit) { | ||
| 111 | -// DS_showMessage(@"商品分类不能修改"); | ||
| 112 | -// return; | ||
| 113 | -// } | ||
| 114 | -// [weakSelf displaySelectCategoryVC]; | ||
| 115 | -// } | ||
| 116 | -// else if([single.addEditGoodsListModel.title isEqualToString:@"店铺分类"]) | ||
| 117 | -// { | ||
| 118 | -// //点击了店铺分类 | ||
| 119 | -// [weakSelf displaySelectShopClassifyVC]; | ||
| 120 | -// } | 167 | + if (single.tag == 1) { |
| 168 | + //点击了商品分类 | ||
| 169 | + | ||
| 170 | + if (self.type == .edit) { | ||
| 171 | + showMessage(message: "商品分类不能修改") | ||
| 172 | + return | ||
| 173 | + } | ||
| 174 | + self.displaySelectCategoryVC() | ||
| 175 | + } | ||
| 176 | + else if single.addEditGoodsListModel!.title == "店铺分类" | ||
| 177 | + { | ||
| 178 | + //点击了店铺分类 | ||
| 179 | + self.displaySelectShopClassifyVC() | ||
| 180 | + } | ||
| 181 | + } | ||
| 182 | + singleView.changeFrameBlock = { | ||
| 183 | + isDelect,model,singleView in | ||
| 184 | + if isDelect{ | ||
| 185 | + let tempArray = NSMutableArray(array: self.dataModel.list) | ||
| 186 | + tempArray.remove(model) | ||
| 187 | + self.dataModel.list = tempArray as! [CNLiveShopAddEditGoodsListModel] | ||
| 188 | + self.reloadRemoveBgScrollViewContentView(singleView: singleView) | ||
| 189 | + }else{ | ||
| 190 | + CNLiveShopGoodsManageDetailsInputManager().showCustomParamAlertWithCompleterBlock { k, v in | ||
| 191 | + let paramDict = ["style":1,"isHaveTo":false,"title":k,"contentTextFieldkeyboardType":1,"isDisplayLine":true,"contentType":1,"isDelect":true,"content":v] | ||
| 192 | + let listModel = newDictionaryToModel(paramDict, CNLiveShopAddEditGoodsListModel.self) as! CNLiveShopAddEditGoodsListModel | ||
| 193 | + self.reloadBgScrollViewContentViewModel(model: listModel, index: self.dataModel.list.count+1, isScrollToBottom: true) | ||
| 194 | + self.dataModel.list.append(listModel) | ||
| 195 | + } | ||
| 196 | + } | ||
| 121 | } | 197 | } |
| 122 | - | ||
| 123 | self.bgScrollView.addSubview(singleView) | 198 | self.bgScrollView.addSubview(singleView) |
| 124 | } | 199 | } |
| 125 | } | 200 | } |
| 126 | 201 | ||
| 202 | + func reloadBgScrollViewContentViewModel(model:CNLiveShopAddEditGoodsListModel,index:Int,isScrollToBottom:Bool){ | ||
| 203 | + let singleView = CNLiveShopAddGoodsSingleView() | ||
| 204 | + singleView.addEditGoodsListModel = model | ||
| 205 | + singleView.tag = index | ||
| 206 | + singleView.updateFrameBlock = { | ||
| 207 | + self.viewWillLayoutSubviews() | ||
| 208 | + } | ||
| 209 | + singleView.tapBlock = {singleView in | ||
| 210 | + if singleView.tag == 1{ | ||
| 211 | + if self.type == .edit{ | ||
| 212 | + showMessage(message: "商品分类不能修改") | ||
| 213 | + return | ||
| 214 | + } | ||
| 215 | + self.displaySelectCategoryVC() | ||
| 216 | + }else if singleView.addEditGoodsListModel?.title == "店铺分类"{ | ||
| 217 | + //点击了店铺分类 | ||
| 218 | + self.displaySelectShopClassifyVC() | ||
| 219 | + } | ||
| 220 | + } | ||
| 221 | + singleView.changeFrameBlock = {isDelect,model,singleView in | ||
| 222 | + | ||
| 223 | + if (isDelect) { | ||
| 224 | + | ||
| 225 | + let tempArray = NSMutableArray(array: self.dataModel.list) | ||
| 226 | + tempArray.remove(model) | ||
| 227 | + self.dataModel.list = tempArray as! [CNLiveShopAddEditGoodsListModel] | ||
| 228 | + self.reloadRemoveBgScrollViewContentView(singleView: singleView) | ||
| 229 | + } | ||
| 230 | + } | ||
| 231 | + self.bgScrollView.addSubview(singleView) | ||
| 232 | + singleView.frame = CGRect(x: 0, y: self.bgScrollView.height, width: self.bgScrollView.width, height: singleView.height) | ||
| 233 | + self.bgScrollView.contentSize = CGSize(width: self.bgScrollView.width, height: self.bgScrollView.contentSize.height+50) | ||
| 234 | + if (isScrollToBottom) { | ||
| 235 | + self.bgScrollView.scrollToBottom() | ||
| 236 | + } | ||
| 237 | + } | ||
| 238 | + | ||
| 239 | + func reloadRemoveBgScrollViewContentView(singleView:CNLiveShopAddGoodsSingleView){ | ||
| 240 | + var tempViews = Array(self.bgScrollView.subviews) | ||
| 241 | + if (tempViews.firstIndex(of: singleView) == tempViews.count - 1){ | ||
| 242 | + //是最后一个 直接移除 | ||
| 243 | + let singView = self.view.viewWithTag(singleView.tag-1) as! CNLiveShopAddGoodsSingleView | ||
| 244 | + singleView.removeFromSuperview() | ||
| 245 | + self.bgScrollView.contentSize = CGSize(width: self.bgScrollView.width, height: singView.bottom) | ||
| 246 | + }else | ||
| 247 | + { | ||
| 248 | + let i = tempViews.firstIndex(of: singleView) | ||
| 249 | + tempViews.removeSubrange(0...i!) | ||
| 250 | + singleView.removeFromSuperview() | ||
| 251 | + if (tempViews.last!.isKind(of: UIImage.self)){ | ||
| 252 | + tempViews.removeLast() | ||
| 253 | + } | ||
| 254 | + for subView in tempViews { | ||
| 255 | + subView.top = subView.top - 50 | ||
| 256 | + } | ||
| 257 | + let lastView = tempViews.last | ||
| 258 | + self.bgScrollView.contentSize = CGSize(width: self.bgScrollView.width, height: lastView!.bottom) | ||
| 259 | + | ||
| 260 | + } | ||
| 261 | + self.bgScrollView.scrollToBottom() | ||
| 262 | + } | ||
| 263 | + | ||
| 264 | + // MARK: - 显示选取分类界面 | ||
| 265 | + func displaySelectCategoryVC(){ | ||
| 266 | + if self.selectCategoryVC == nil{ | ||
| 267 | + let vc = CNLiveGoodsCategoryController() | ||
| 268 | + vc.categoryType = .goods | ||
| 269 | + if self.shopGoodsDetailsModel.id!.count > 0{ | ||
| 270 | + vc.firCategoryId = self.shopGoodsDetailsModel.groupid | ||
| 271 | + vc.secCategoryId = self.shopGoodsDetailsModel.groupid2 | ||
| 272 | + vc.thiCategoryId = self.shopGoodsDetailsModel.groupid3 | ||
| 273 | + } | ||
| 274 | + vc.finishBlock = { | ||
| 275 | + //商品分类 | ||
| 276 | + let singleView1 = self.bgScrollView.viewWithTag(1) as! CNLiveShopAddGoodsSingleView | ||
| 277 | + singleView1.contentTextField.text = "\(self.selectCategoryVC?.firCategoryName ?? "") \(self.selectCategoryVC?.secCategoryName ?? "")" | ||
| 278 | + singleView1.layoutSubviews() | ||
| 279 | + } | ||
| 280 | + self.addChild(vc) | ||
| 281 | + vc.view.frame = CGRect(x: 0, y: 0, width: self.view.width, height: self.view.height) | ||
| 282 | + vc.didMove(toParent: self) | ||
| 283 | + self.selectCategoryVC = vc | ||
| 284 | + } | ||
| 285 | + self.selectCategoryVC?.display() | ||
| 286 | + } | ||
| 287 | + | ||
| 288 | + // MARK: - 获取店铺分类view | ||
| 289 | + func getShopClassifyView()->CNLiveShopAddGoodsSingleView{ | ||
| 290 | + for singleView in self.bgScrollView.subviews { | ||
| 291 | + if singleView.isKind(of: CNLiveShopAddGoodsSingleView.self){ | ||
| 292 | + let single = singleView as! CNLiveShopAddGoodsSingleView | ||
| 293 | + if single.addEditGoodsListModel?.title == "店铺分类"{ | ||
| 294 | + return single | ||
| 295 | + } | ||
| 296 | + } | ||
| 297 | + } | ||
| 298 | + return CNLiveShopAddGoodsSingleView() | ||
| 299 | + } | ||
| 300 | + // MARK: - 显示选取店铺分类界面 | ||
| 301 | + func displaySelectShopClassifyVC(){ | ||
| 302 | + self.selectShopClassifyVC.display() | ||
| 303 | + } | ||
| 304 | + | ||
| 305 | + // MARK: - 字符串trim处理 | ||
| 306 | + func strimStr(str:String)->String{ | ||
| 307 | + var strimStr = str | ||
| 308 | + strimStr = strimStr.replacingOccurrences(of: " ", with: "") | ||
| 309 | + strimStr = strimStr.replacingOccurrences(of: "\n", with: "") | ||
| 310 | + return strimStr | ||
| 311 | + } | ||
| 312 | + | ||
| 127 | // MARK: - BtnAction | 313 | // MARK: - BtnAction |
| 314 | + @objc func deleteNavBtnClick(){ | ||
| 315 | + AlertTool.showSystemAlert(title: "确认删除?", message: nil, actionTitles: ["取消","确定"], style: .alert, actionStyles:[.cancel,.default] ) { index in | ||
| 316 | + if (index == 1) { | ||
| 317 | + showLoading(message: "") | ||
| 318 | + CNLiveShopGoodListViewModel.postChangeGoodsStateWithGoodsId(goodsId: self.goodsId, state: "3") { result, status in | ||
| 319 | + hiddenLoading() | ||
| 320 | + if status == .success{ | ||
| 321 | + showMessage(message: "删除成功") | ||
| 322 | + NotificationCenter.default.post(name: Notification.Name.ShopGoodsManage.kDSGoodsManageDeleteNotification, object: nil, userInfo: ["goodsId":self.goodsId ]) | ||
| 323 | + self.navigationController?.popViewController(animated: true) | ||
| 324 | + }else{ | ||
| 325 | + showMessage(message: "删除失败") | ||
| 326 | + } | ||
| 327 | + } | ||
| 328 | + } | ||
| 329 | + } | ||
| 330 | + } | ||
| 331 | + | ||
| 128 | @objc func previewBtnClick(){ | 332 | @objc func previewBtnClick(){ |
| 129 | - /* | 333 | + |
| 130 | //商品轮播 | 334 | //商品轮播 |
| 131 | let singleView4 = self.bgScrollView.viewWithTag(4) as! CNLiveShopAddGoodsSingleView | 335 | let singleView4 = self.bgScrollView.viewWithTag(4) as! CNLiveShopAddGoodsSingleView |
| 132 | //商品名称 | 336 | //商品名称 |
| @@ -147,10 +351,10 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | @@ -147,10 +351,10 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | ||
| 147 | let singleView20 = self.bgScrollView.viewWithTag(20) as! CNLiveShopAddGoodsSingleView | 351 | let singleView20 = self.bgScrollView.viewWithTag(20) as! CNLiveShopAddGoodsSingleView |
| 148 | //发货时效 | 352 | //发货时效 |
| 149 | let singleView21 = self.bgScrollView.viewWithTag(21) as! CNLiveShopAddGoodsSingleView | 353 | let singleView21 = self.bgScrollView.viewWithTag(21) as! CNLiveShopAddGoodsSingleView |
| 150 | -// let bannersSelectImageUrls = singleView4.uploadImageView.getCurrentSelectImageUrls | ||
| 151 | -// let bannersSelectImageUrls = singleView4.uploadImageView.getCurrentSelectVideoUrl | ||
| 152 | -// let bannerSelectVideoImage = singleView4.uploadImageView.getCurrentSelectLocalVideoUrlFirstImage | ||
| 153 | -// let contentDetailsSelectImageUrls = singleView13.uploadImageView.getCurrentSelectImageUrls | 354 | + let bannersSelectImageUrls = singleView4.uploadImageView.getCurrentSelectImageUrls() |
| 355 | + let bannerSelectVideoUrl = singleView4.uploadImageView.getCurrentSelectVideoUrl() | ||
| 356 | + let bannerSelectVideoImage = singleView4.uploadImageView.getCurrentSelectLocalVideoUrlFirstImage() | ||
| 357 | + let contentDetailsSelectImageUrls = singleView13.uploadImageView.getCurrentSelectImageUrls() | ||
| 154 | 358 | ||
| 155 | if (bannersSelectImageUrls.count == 0 && bannerSelectVideoUrl.count == 0) { | 359 | if (bannersSelectImageUrls.count == 0 && bannerSelectVideoUrl.count == 0) { |
| 156 | showMessage(message: "请选择商品轮播") | 360 | showMessage(message: "请选择商品轮播") |
| @@ -165,299 +369,431 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | @@ -165,299 +369,431 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | ||
| 165 | showMessage(message: "请选择商品详情图") | 369 | showMessage(message: "请选择商品详情图") |
| 166 | return | 370 | return |
| 167 | } | 371 | } |
| 168 | - else if (self.selectShopClassifyVC.firCategoryId.count == 0) { | 372 | + else if (self.selectShopClassifyVC.firCategoryId!.count == 0) { |
| 169 | showMessage(message: "请选择店铺分类") | 373 | showMessage(message: "请选择店铺分类") |
| 170 | return | 374 | return |
| 171 | } | 375 | } |
| 172 | 376 | ||
| 173 | - BKShopGoodsDetailsModel * goodsDetailsModel = [[BKShopGoodsDetailsModel alloc] init]; | ||
| 174 | - NSMutableArray * bannerImage = [NSMutableArray array]; | ||
| 175 | - for (NSString * imageUrl in bannersSelectImageUrls) { | ||
| 176 | - BKGoodsDetailsImageModel * model = [[BKGoodsDetailsImageModel alloc] init]; | ||
| 177 | - model.simg = imageUrl; | ||
| 178 | - [bannerImage addObject:model]; | ||
| 179 | - } | ||
| 180 | - goodsDetailsModel.image = [bannerImage copy]; | ||
| 181 | - DSGoodsDetailsBannerVideosModel * banner_video = [[DSGoodsDetailsBannerVideosModel alloc] init]; | ||
| 182 | - if (bannerSelectVideoImage) { | ||
| 183 | - banner_video.video_image = bannerSelectVideoImage; | ||
| 184 | - }else { | ||
| 185 | - banner_video.video_img = self.shopGoodsDetailsModel.video.video_img; | ||
| 186 | - } | ||
| 187 | - banner_video.video_url = bannerSelectVideoUrl; | ||
| 188 | - goodsDetailsModel.video = banner_video; | ||
| 189 | - goodsDetailsModel.title = singleView5.contentTextField.text; | ||
| 190 | - goodsDetailsModel.ads = singleView6.contentTextView.text; | ||
| 191 | - goodsDetailsModel.price = singleView7.contentTextField.text; | ||
| 192 | - goodsDetailsModel.prices = singleView8.contentTextField.text; | ||
| 193 | - goodsDetailsModel.category_id = self.selectShopClassifyVC.firCategoryId; | ||
| 194 | - goodsDetailsModel.category_id2 = self.selectShopClassifyVC.secCategoryId; | ||
| 195 | - | ||
| 196 | - NSMutableArray * contentDetailsImage = [NSMutableArray array]; | ||
| 197 | - for (NSString * imageUrl in contentDetailsSelectImageUrls) { | ||
| 198 | - BKGoodsDetailsContentModel * model = [[BKGoodsDetailsContentModel alloc] init]; | ||
| 199 | - model.simg = imageUrl; | ||
| 200 | - [contentDetailsImage addObject:model]; | 377 | + let goodsDetailsModel = CNLiveShopGoodsDetailsModel() |
| 378 | + var bannerImage = NSMutableArray() | ||
| 379 | + for imageUrl in bannersSelectImageUrls { | ||
| 380 | + let model = CNLiveShopGoodsDetailsModel() | ||
| 381 | + model.simg = imageUrl | ||
| 382 | + bannerImage.add(model) | ||
| 201 | } | 383 | } |
| 202 | - goodsDetailsModel.detail_img = [contentDetailsImage copy]; | ||
| 203 | - | ||
| 204 | - NSMutableArray * kvArray = [[NSMutableArray alloc] init]; | ||
| 205 | - [kvArray addObject:@{@"k":@"品名",@"v":singleView18.contentTextField.text}]; | ||
| 206 | - [kvArray addObject:@{@"k":@"规格",@"v":singleView19.contentTextField.text}]; | ||
| 207 | - [kvArray addObject:@{@"k":@"寄送区域",@"v":singleView20.contentTextView.text}]; | ||
| 208 | - [kvArray addObject:@{@"k":@"发货时效",@"v":singleView21.contentTextField.text}]; | 384 | + goodsDetailsModel.image = Array(bannerImage) as! [CNLiveGoodsDetailsImageModel] |
| 385 | + let banner_video = CNLiveGoodsDetailsBannerVideosModel() | ||
| 386 | + if (bannerSelectVideoImage != nil){ | ||
| 387 | + banner_video.video_image = bannerSelectVideoImage | ||
| 388 | + }else{ | ||
| 389 | + banner_video.video_img = self.shopGoodsDetailsModel.video?.video_img | ||
| 390 | + } | ||
| 391 | + banner_video.video_url = bannerSelectVideoUrl | ||
| 392 | + goodsDetailsModel.video = banner_video | ||
| 393 | + goodsDetailsModel.title = singleView5.contentTextField.text | ||
| 394 | + goodsDetailsModel.ads = singleView6.contentTextView.text | ||
| 395 | + goodsDetailsModel.price = singleView7.contentTextField.text | ||
| 396 | + goodsDetailsModel.prices = singleView8.contentTextField.text | ||
| 397 | + goodsDetailsModel.category_id = self.selectShopClassifyVC.firCategoryId | ||
| 398 | + goodsDetailsModel.category_id2 = self.selectShopClassifyVC.secCategoryId | ||
| 399 | + var contentDetailsImage = NSMutableArray() | ||
| 400 | + for imageUrl in contentDetailsSelectImageUrls{ | ||
| 401 | + let model = CNLiveGoodsDetailsContentModel() | ||
| 402 | + model.simg = imageUrl | ||
| 403 | + contentDetailsImage.add(model) | ||
| 404 | + } | ||
| 405 | + goodsDetailsModel.detail_img = Array(contentDetailsImage) as! [CNLiveGoodsDetailsContentModel] | ||
| 406 | + var kvArray = NSMutableArray() | ||
| 407 | + kvArray.add(["k":"品名","v":singleView18.contentTextField.text]) | ||
| 408 | + kvArray.add(["k":"规格","v":singleView19.contentTextField.text]) | ||
| 409 | + kvArray.add(["k":"寄送区域","v":singleView20.contentTextField.text]) | ||
| 410 | + kvArray.add(["k":"发货时效","v":singleView21.contentTextField.text]) | ||
| 411 | + var tempArray = NSMutableArray(array: self.bgScrollView.subviews) | ||
| 209 | 412 | ||
| 210 | - NSMutableArray * tempArray = [self.bgScrollView.subviews mutableCopy]; | ||
| 211 | - [tempArray removeObjectsInRange:NSMakeRange(0, [tempArray indexOfObject:singleView19])]; | ||
| 212 | - if (tempArray.count > 2) { | ||
| 213 | - for (DSShopGoodsManageDetailsSingleView * singleView in tempArray) { | ||
| 214 | - if ([singleView isKindOfClass:DSShopGoodsManageDetailsSingleView.class]) { | ||
| 215 | - if (singleView.contentTextField.text.length > 0 && ![kvArray containsObject:@{@"k":singleView.model.title,@"v":singleView.contentTextField.text}]) { | ||
| 216 | - [kvArray addObject:@{@"k":singleView.model.title,@"v":singleView.contentTextField.text}]; | 413 | + let subArr = tempArray.subarray(with: NSRange(location: 0, length: tempArray.index(of: singleView19))) |
| 414 | + tempArray.removeObjects(in: subArr) | ||
| 415 | + if tempArray.count > 2{ | ||
| 416 | + for singleView in tempArray{ | ||
| 417 | + if (singleView as AnyObject).isKind(of: CNLiveShopAddGoodsSingleView.self){ | ||
| 418 | + let single = singleView as! CNLiveShopAddGoodsSingleView | ||
| 419 | + if single.contentTextField.text!.count > 0 && kvArray.contains(["k":single.addEditGoodsListModel!.title,"v":single.contentTextField.text]){ | ||
| 420 | + kvArray.add(["k":single.addEditGoodsListModel!.title,"v":single.contentTextField.text]) | ||
| 217 | } | 421 | } |
| 218 | } | 422 | } |
| 219 | } | 423 | } |
| 220 | } | 424 | } |
| 221 | - goodsDetailsModel.attrArray = kvArray; | ||
| 222 | - | ||
| 223 | - BKShopGoodsDetailsViewController * vc = [[BKShopGoodsDetailsViewController alloc] init]; | ||
| 224 | - vc.type = BKShopGoodsDetailsVCTypePreview; | ||
| 225 | - vc.detailsModel = goodsDetailsModel; | ||
| 226 | - vc.goodsId = self.goodsId; | ||
| 227 | - [self dsPushViewController:vc animated:YES]; | ||
| 228 | - */ | 425 | + goodsDetailsModel.attrArray = kvArray as! [Dictionary<String, Any>] |
| 426 | + let vc = CNLiveShopGoodsDetailsViewController() | ||
| 427 | + vc.type = .preview | ||
| 428 | + vc.detailsModel = goodsDetailsModel | ||
| 429 | + vc.goodsId = self.goodsId | ||
| 430 | + self.navigationController?.pushViewController(vc, animated: false) | ||
| 229 | } | 431 | } |
| 230 | @objc func saveBtnClick(){ | 432 | @objc func saveBtnClick(){ |
| 231 | - /* | ||
| 232 | - DSShopGoodsManageDetailsSingleView * singleView4 = [self.bgScrollView viewWithTag:4];//商品轮播 | ||
| 233 | - DSShopGoodsManageDetailsSingleView * singleView5 = [self.bgScrollView viewWithTag:5];//商品名称 | ||
| 234 | - DSShopGoodsManageDetailsSingleView * singleView6 = [self.bgScrollView viewWithTag:6];//商品副标题 | ||
| 235 | - DSShopGoodsManageDetailsSingleView * singleView7 = [self.bgScrollView viewWithTag:7];//本店售价 | ||
| 236 | - DSShopGoodsManageDetailsSingleView * singleView8 = [self.bgScrollView viewWithTag:8];//市场售价 | ||
| 237 | - DSShopGoodsManageDetailsSingleView * singleView9 = [self.bgScrollView viewWithTag:9];//商品重量 | ||
| 238 | - DSShopGoodsManageDetailsSingleView * singleView10 = [self.bgScrollView viewWithTag:10];//最低起售 | ||
| 239 | - DSShopGoodsManageDetailsSingleView * singleView11 = [self.bgScrollView viewWithTag:11];//上架 | ||
| 240 | - | ||
| 241 | - DSShopGoodsManageDetailsSingleView * singleView13 = [self.bgScrollView viewWithTag:13];//商品详情图 | ||
| 242 | - DSShopGoodsManageDetailsSingleView * singleView14 = [self.bgScrollView viewWithTag:14];//商品运费 | ||
| 243 | - DSShopGoodsManageDetailsSingleView * singleView15 = [self.bgScrollView viewWithTag:15];//是否支持退货 | ||
| 244 | - DSShopGoodsManageDetailsSingleView * singleView16 = [self.bgScrollView viewWithTag:16];//商品单位 | ||
| 245 | - | ||
| 246 | - DSShopGoodsManageDetailsSingleView * singleView18 = [self.bgScrollView viewWithTag:18];//品名 | ||
| 247 | - DSShopGoodsManageDetailsSingleView * singleView19 = [self.bgScrollView viewWithTag:19];//规格 | ||
| 248 | - DSShopGoodsManageDetailsSingleView * singleView20 = [self.bgScrollView viewWithTag:20];//寄送区域 | ||
| 249 | - DSShopGoodsManageDetailsSingleView * singleView21 = [self.bgScrollView viewWithTag:21];//发货时效 | ||
| 250 | - | ||
| 251 | - | ||
| 252 | - NSArray * bannersSelectImageUrls = [singleView4.uploadImageView getCurrentSelectImageUrls]; | ||
| 253 | - NSMutableArray * bannerImage = [NSMutableArray array]; | ||
| 254 | - for (NSString * imageUrl in bannersSelectImageUrls) { | ||
| 255 | - [bannerImage addObject:@{@"img":imageUrl, @"ord":@"99"}]; | ||
| 256 | - } | ||
| 257 | - NSData * bannerImageData = [NSJSONSerialization dataWithJSONObject:bannerImage options:NSJSONWritingPrettyPrinted error:nil]; | ||
| 258 | - NSString * bannerImageStr = [[NSString alloc] initWithData:bannerImageData encoding:NSUTF8StringEncoding]; | ||
| 259 | - bannerImageStr = [bannerImageStr stringByReplacingOccurrencesOfString:@"\\n" withString:@""]; | ||
| 260 | - bannerImageStr = [bannerImageStr stringByReplacingOccurrencesOfString:@"\n" withString:@""]; | ||
| 261 | - bannerImageStr = [bannerImageStr stringByReplacingOccurrencesOfString:@"\\" withString:@""]; | ||
| 262 | - bannerImageStr = [bannerImageStr stringByReplacingOccurrencesOfString:@" " withString:@""]; | ||
| 263 | - | ||
| 264 | - NSString * bannerSelectVideoUrl = [singleView4.uploadImageView getCurrentSelectVideoUrl]; | ||
| 265 | - | ||
| 266 | - NSArray * contentDetailsSelectImageUrls = [singleView13.uploadImageView getCurrentSelectImageUrls]; | ||
| 267 | - NSMutableArray * contentDetailsImage = [NSMutableArray array]; | ||
| 268 | - for (NSString * imageUrl in contentDetailsSelectImageUrls) { | ||
| 269 | - [contentDetailsImage addObject:@{@"img":imageUrl, @"ord":@"99"}]; | ||
| 270 | - } | ||
| 271 | - NSData * contentDetailsImageData = [NSJSONSerialization dataWithJSONObject:contentDetailsImage options:NSJSONWritingPrettyPrinted error:nil]; | ||
| 272 | - NSString * contentDetailsImageStr = [[NSString alloc] initWithData:contentDetailsImageData encoding:NSUTF8StringEncoding]; | ||
| 273 | - contentDetailsImageStr = [contentDetailsImageStr stringByReplacingOccurrencesOfString:@"\\n" withString:@""]; | ||
| 274 | - contentDetailsImageStr = [contentDetailsImageStr stringByReplacingOccurrencesOfString:@"\n" withString:@""]; | ||
| 275 | - contentDetailsImageStr = [contentDetailsImageStr stringByReplacingOccurrencesOfString:@"\\" withString:@""]; | ||
| 276 | - contentDetailsImageStr = [contentDetailsImageStr stringByReplacingOccurrencesOfString:@" " withString:@""]; | 433 | + //商品轮播 |
| 434 | + let singleView4 = self.bgScrollView.viewWithTag(4) as! CNLiveShopAddGoodsSingleView | ||
| 435 | + //商品名称 | ||
| 436 | + let singleView5 = self.bgScrollView.viewWithTag(5) as! CNLiveShopAddGoodsSingleView | ||
| 437 | + //商品副标题 | ||
| 438 | + let singleView6 = self.bgScrollView.viewWithTag(6) as! CNLiveShopAddGoodsSingleView | ||
| 439 | + //本店售价 | ||
| 440 | + let singleView7 = self.bgScrollView.viewWithTag(7) as! CNLiveShopAddGoodsSingleView | ||
| 441 | + //市场售价 | ||
| 442 | + let singleView8 = self.bgScrollView.viewWithTag(8) as! CNLiveShopAddGoodsSingleView | ||
| 443 | + //商品重量 | ||
| 444 | + let singleView9 = self.bgScrollView.viewWithTag(9) as! CNLiveShopAddGoodsSingleView | ||
| 445 | + //最低起售 | ||
| 446 | + let singleView10 = self.bgScrollView.viewWithTag(10) as! CNLiveShopAddGoodsSingleView | ||
| 447 | + //上架 | ||
| 448 | + let singleView11 = self.bgScrollView.viewWithTag(11) as! CNLiveShopAddGoodsSingleView | ||
| 449 | + //商品详情图 | ||
| 450 | + let singleView13 = self.bgScrollView.viewWithTag(13) as! CNLiveShopAddGoodsSingleView | ||
| 451 | + //商品运费 | ||
| 452 | + let singleView14 = self.bgScrollView.viewWithTag(14) as! CNLiveShopAddGoodsSingleView | ||
| 453 | + //是否支持退货 | ||
| 454 | + let singleView15 = self.bgScrollView.viewWithTag(15) as! CNLiveShopAddGoodsSingleView | ||
| 455 | + //商品单位 | ||
| 456 | + let singleView16 = self.bgScrollView.viewWithTag(16) as! CNLiveShopAddGoodsSingleView | ||
| 457 | + //品名 | ||
| 458 | + let singleView18 = self.bgScrollView.viewWithTag(18) as! CNLiveShopAddGoodsSingleView | ||
| 459 | + //规格 | ||
| 460 | + let singleView19 = self.bgScrollView.viewWithTag(19) as! CNLiveShopAddGoodsSingleView | ||
| 461 | + //寄送区域 | ||
| 462 | + let singleView20 = self.bgScrollView.viewWithTag(20) as! CNLiveShopAddGoodsSingleView | ||
| 463 | + //发货时效 | ||
| 464 | + let singleView21 = self.bgScrollView.viewWithTag(21) as! CNLiveShopAddGoodsSingleView | ||
| 465 | + let bannersSelectImageUrls = singleView4.uploadImageView.getCurrentSelectImageUrls() | ||
| 277 | 466 | ||
| 278 | - if (self.type == DSShopGoodsManageDetailsVCTypeAdd && [self.selectCategoryVC.thiCategoryId length] == 0) { | ||
| 279 | - DS_showMessage(@"请选择商品分类"); | ||
| 280 | - return; | ||
| 281 | - } | ||
| 282 | - else if (!self.selectShopClassifyVC.firCategoryId ||[DS_ToString(self.selectShopClassifyVC.firCategoryId) length] == 0 | ||
| 283 | - || [DS_ToString(self.selectShopClassifyVC.firCategoryId) isEqualToString:@"0"]) { | ||
| 284 | - DS_showMessage(@"请选择店铺分类"); | ||
| 285 | - return; | ||
| 286 | - } | ||
| 287 | - else if ([bannersSelectImageUrls count] == 0 && [bannerSelectVideoUrl length] == 0) { | ||
| 288 | - DS_showMessage(@"请选择商品轮播"); | ||
| 289 | - return; | ||
| 290 | - }else if ([[self strimStr:singleView5.contentTextField.text] length] == 0) { | ||
| 291 | - DS_showMessage(@"请输入商品名称"); | ||
| 292 | - return; | ||
| 293 | - } | ||
| 294 | - else if ([singleView5.contentTextField.text length] > 50) { | ||
| 295 | - DS_showMessage(@"商品名称最多支持50个字"); | ||
| 296 | - return; | ||
| 297 | - } | ||
| 298 | - else if ([singleView6.contentTextView.text length] > 30) | ||
| 299 | - { | ||
| 300 | - DS_showMessage(@"副商品名称最多支持30个字"); | ||
| 301 | - return; | ||
| 302 | - }else if ([singleView7.contentTextField.text length] == 0) { | ||
| 303 | - DS_showMessage(@"请输入本店售价"); | ||
| 304 | - return; | ||
| 305 | - }else if ([singleView7.contentTextField.text onlyNumber] && [singleView7.contentTextField.text length] >= DSMaxPrice) { | ||
| 306 | - DS_showMessage(@"请输入正确的售价"); | ||
| 307 | - return; | ||
| 308 | - }else if ([singleView8.contentTextField.text onlyNumber] && [singleView8.contentTextField.text length] >= DSMaxPrice) { | ||
| 309 | - DS_showMessage(@"请输入正确的市场售价"); | ||
| 310 | - return; | ||
| 311 | - }else if ([singleView8.contentTextField.text length] == 0) { | ||
| 312 | - DS_showMessage(@"请输入的市场售价"); | ||
| 313 | - return; | ||
| 314 | - }else if ([singleView10.countTF.text length] >= 5) { | ||
| 315 | - DS_showMessage(@"请输入正确的起售件数"); | ||
| 316 | - return; | ||
| 317 | - }else if ([contentDetailsSelectImageUrls count] == 0) { | ||
| 318 | - DS_showMessage(@"请选择商品详情图"); | ||
| 319 | - return; | ||
| 320 | - }else if ([[self strimStr:singleView18.contentTextField.text] length] == 0) { | ||
| 321 | - DS_showMessage(@"请输入品名"); | ||
| 322 | - return; | ||
| 323 | - }else if ([[self strimStr:singleView19.contentTextField.text] length] == 0) { | ||
| 324 | - DS_showMessage(@"请输入规格"); | ||
| 325 | - return; | ||
| 326 | - }else if ([[self strimStr:singleView20.contentTextView.text] length] == 0) { | ||
| 327 | - DS_showMessage(@"请输入寄送区域"); | ||
| 328 | - return; | ||
| 329 | - }else if ([singleView21.contentTextField.text length] == 0) { | ||
| 330 | - DS_showMessage(@"请输入发货时效"); | ||
| 331 | - return; | 467 | + var bannerImage = NSMutableArray() |
| 468 | + for imageUrl in bannersSelectImageUrls{ | ||
| 469 | + bannerImage.add(["img":imageUrl,"ord":"99"]) | ||
| 332 | } | 470 | } |
| 471 | + var bannerImageStr = "" | ||
| 472 | + do { | ||
| 473 | + let bannerImageData = try JSONSerialization.data(withJSONObject: bannerImage, options: .prettyPrinted) | ||
| 474 | + bannerImageStr = String(data: bannerImageData, encoding: .utf8) ?? "" | ||
| 475 | + bannerImageStr = bannerImageStr.replacingOccurrences(of: "\\n", with: "") | ||
| 476 | + bannerImageStr = bannerImageStr.replacingOccurrences(of: "\n", with: "") | ||
| 477 | + bannerImageStr = bannerImageStr.replacingOccurrences(of: "\\", with: "") | ||
| 478 | + bannerImageStr = bannerImageStr.replacingOccurrences(of: " ", with: "") | ||
| 479 | + } catch _ {} | ||
| 333 | 480 | ||
| 334 | - | ||
| 335 | - NSMutableArray * kvArray = [[NSMutableArray alloc] init]; | ||
| 336 | - [kvArray addObject:@{@"k":@"品名",@"v":singleView18.contentTextField.text}]; | ||
| 337 | - [kvArray addObject:@{@"k":@"规格",@"v":singleView19.contentTextField.text}]; | ||
| 338 | - [kvArray addObject:@{@"k":@"寄送区域",@"v":singleView20.contentTextView.text}]; | ||
| 339 | - [kvArray addObject:@{@"k":@"发货时效",@"v":singleView21.contentTextField.text}]; | ||
| 340 | - | ||
| 341 | - NSMutableArray * tempArray = [self.bgScrollView.subviews mutableCopy]; | ||
| 342 | - [tempArray removeObjectsInRange:NSMakeRange(0, [tempArray indexOfObject:singleView21])]; | ||
| 343 | - if (tempArray.count > 2) { | ||
| 344 | - for (DSShopGoodsManageDetailsSingleView * singleView in tempArray) { | ||
| 345 | - if ([singleView isKindOfClass:DSShopGoodsManageDetailsSingleView.class]) { | ||
| 346 | - if (singleView.contentTextField.text.length > 0 && ![kvArray containsObject:@{@"k":singleView.model.title,@"v":singleView.contentTextField.text}]) { | ||
| 347 | - [kvArray addObject:@{@"k":singleView.model.title,@"v":singleView.contentTextField.text}]; | 481 | + let bannerSelectVideoUrl = singleView4.uploadImageView.getCurrentSelectVideoUrl() |
| 482 | + let contentDetailsSelectImageUrls = singleView13.uploadImageView.getCurrentSelectImageUrls() | ||
| 483 | + var contentDetailsImage = NSMutableArray() | ||
| 484 | + for imageUrl in contentDetailsSelectImageUrls{ | ||
| 485 | + contentDetailsImage.add(["img":imageUrl,"ord":"99"]) | ||
| 486 | + } | ||
| 487 | + var contentDetailsImageStr = "" | ||
| 488 | + do { | ||
| 489 | + let contentDetailsImageData = try JSONSerialization.data(withJSONObject: contentDetailsImage, options: .prettyPrinted) | ||
| 490 | + contentDetailsImageStr = String(data: contentDetailsImageData, encoding: .utf8)! | ||
| 491 | + contentDetailsImageStr = contentDetailsImageStr.replacingOccurrences(of: "\\n", with: "") | ||
| 492 | + contentDetailsImageStr = contentDetailsImageStr.replacingOccurrences(of: "\n", with: "") | ||
| 493 | + contentDetailsImageStr = contentDetailsImageStr.replacingOccurrences(of: "\\", with: "") | ||
| 494 | + contentDetailsImageStr = contentDetailsImageStr.replacingOccurrences(of: " ", with: "") | ||
| 495 | + } catch _ {} | ||
| 496 | + if self.type == .add && self.selectCategoryVC?.thiCategoryId?.count == 0{ | ||
| 497 | + showMessage(message: "请选择商品分类") | ||
| 498 | + return | ||
| 499 | + }else if self.selectShopClassifyVC.firCategoryId == nil || self.selectShopClassifyVC.firCategoryId?.count == 0 || self.selectShopClassifyVC.firCategoryId == "0"{ | ||
| 500 | + showMessage(message: "请选择店铺分类") | ||
| 501 | + return | ||
| 502 | + }else if bannersSelectImageUrls.count == 0 && bannerSelectVideoUrl.count == 0{ | ||
| 503 | + showMessage(message: "请选择商品轮播") | ||
| 504 | + return | ||
| 505 | + }else if self.strimStr(str: singleView5.contentTextField.text!).count == 0{ | ||
| 506 | + showMessage(message: "请输入商品名称") | ||
| 507 | + return | ||
| 508 | + }else if singleView5.contentTextField.text?.count ?? 0 > 50{ | ||
| 509 | + showMessage(message: "商品名称最多支持50个字") | ||
| 510 | + return | ||
| 511 | + }else if singleView6.contentTextView.text.count > 30{ | ||
| 512 | + showMessage(message: "副商品名称最多支持30个字") | ||
| 513 | + return | ||
| 514 | + }else if singleView7.contentTextField.text?.count == 0{ | ||
| 515 | + showMessage(message: "请输入本店售价") | ||
| 516 | + return | ||
| 517 | + }else if singleView7.contentTextField.text?.isPurnInt() == true && singleView7.contentTextField.text!.count >= kCNLiveShopMaxPrice{ | ||
| 518 | + showMessage(message: "请输入正确的售价") | ||
| 519 | + return | ||
| 520 | + }else if singleView8.contentTextField.text?.isPurnInt() == true && singleView8.contentTextField.text!.count >= kCNLiveShopMaxPrice{ | ||
| 521 | + showMessage(message: "请输入正确的市场售价") | ||
| 522 | + return | ||
| 523 | + }else if singleView8.contentTextField.text?.count == 0{ | ||
| 524 | + showMessage(message: "请输入的市场售价") | ||
| 525 | + return | ||
| 526 | + }else if singleView10.countTF.text?.count ?? 0 >= 5{ | ||
| 527 | + showMessage(message: "请输入正确的起售件数") | ||
| 528 | + return | ||
| 529 | + }else if contentDetailsSelectImageUrls.count == 0{ | ||
| 530 | + showMessage(message: "请选择商品详情图") | ||
| 531 | + return | ||
| 532 | + }else if self.strimStr(str: singleView18.contentTextField.text ?? "").count == 0{ | ||
| 533 | + showMessage(message: "请输入品名") | ||
| 534 | + return | ||
| 535 | + }else if self.strimStr(str: singleView19.contentTextField.text ?? "").count == 0{ | ||
| 536 | + showMessage(message: "请输入规格") | ||
| 537 | + return | ||
| 538 | + }else if self.strimStr(str: singleView20.contentTextView.text ?? "").count == 0{ | ||
| 539 | + showMessage(message: "请输入寄送区域") | ||
| 540 | + return | ||
| 541 | + }else if self.strimStr(str: singleView21.contentTextField.text ?? "").count == 0{ | ||
| 542 | + showMessage(message: "请输入发货时效") | ||
| 543 | + return | ||
| 544 | + } | ||
| 545 | + var kvArray = NSMutableArray() | ||
| 546 | + kvArray.add(["k":"品名","v":singleView18.contentTextField.text]) | ||
| 547 | + kvArray.add(["k":"规格","v":singleView19.contentTextField.text]) | ||
| 548 | + kvArray.add(["k":"寄送区域","v":singleView20.contentTextView.text]) | ||
| 549 | + kvArray.add(["k":"发货时效","v":singleView21.contentTextField.text]) | ||
| 550 | + var tempArray = NSMutableArray(array: self.bgScrollView.subviews) | ||
| 551 | + tempArray.subarray(with: NSRange(location: 0, length: tempArray.index(of: singleView21))) | ||
| 552 | + if tempArray.count > 2{ | ||
| 553 | + for singleView in tempArray { | ||
| 554 | + if (singleView as AnyObject).isKind(of: CNLiveShopAddGoodsSingleView.self){ | ||
| 555 | + | ||
| 556 | + if (singleView as! CNLiveShopAddGoodsSingleView).contentTextField.text?.count ?? 0 > 0 && !kvArray.contains(["k":(singleView as! CNLiveShopAddGoodsSingleView).addEditGoodsListModel?.title,"v":(singleView as! CNLiveShopAddGoodsSingleView).contentTextField.text]){ | ||
| 557 | + kvArray.add(["k":(singleView as! CNLiveShopAddGoodsSingleView).addEditGoodsListModel?.title,"v":(singleView as! CNLiveShopAddGoodsSingleView).contentTextField.text]) | ||
| 348 | } | 558 | } |
| 349 | } | 559 | } |
| 350 | } | 560 | } |
| 351 | } | 561 | } |
| 352 | - | ||
| 353 | - for (int i = 4; i < 20; i ++) { | ||
| 354 | - if (i == 11 || i == 16) continue; | ||
| 355 | - DSShopGoodsManageDetailsSingleView * singleView = [self.bgScrollView viewWithTag:i]; | ||
| 356 | - NSString * content = [singleView.contentTextField.text isNotBlank] ? singleView.contentTextField.text : singleView.contentTextView.text; | ||
| 357 | - if ([self stringContainsEmoji:content]) { | ||
| 358 | - DS_showMessage(@"参数不能添加表情"); | ||
| 359 | - return; | 562 | + for i in 4..<20 { |
| 563 | + if i == 11 || i == 16{ | ||
| 564 | + continue | ||
| 565 | + } | ||
| 566 | + var singleView = self.bgScrollView.viewWithTag(i) as! CNLiveShopAddGoodsSingleView | ||
| 567 | + let content = (singleView.contentTextField.text?.isEmpty == true ? singleView.contentTextField.text : singleView.contentTextView.text) ?? "" | ||
| 568 | + if self.stringContainsEmoji(string: content){ | ||
| 569 | + showMessage(message: "参数不能添加表情") | ||
| 570 | + return | ||
| 360 | } | 571 | } |
| 361 | } | 572 | } |
| 362 | - | ||
| 363 | - | ||
| 364 | - for (NSDictionary * subDict in kvArray) { | ||
| 365 | - if ([self stringContainsEmoji:[subDict objectForKey:@"k"]]) { | ||
| 366 | - DS_showMessage(@"规格参数不能添加表情"); | ||
| 367 | - return; | 573 | + |
| 574 | + for sub in kvArray{ | ||
| 575 | + let subDict = sub as! NSDictionary | ||
| 576 | + if self.stringContainsEmoji(string: subDict.object(forKey: "k") as! String){ | ||
| 577 | + showMessage(message: "规格参数不能添加表情") | ||
| 578 | + return | ||
| 368 | } | 579 | } |
| 369 | - if ([self stringContainsEmoji:[subDict objectForKey:@"v"]]) { | ||
| 370 | - DS_showMessage(@"规格参数不能添加表情"); | ||
| 371 | - return; | 580 | + if self.stringContainsEmoji(string: subDict.object(forKey: "v") as! String){ |
| 581 | + showMessage(message: "规格参数不能添加表情") | ||
| 582 | + return | ||
| 372 | } | 583 | } |
| 373 | } | 584 | } |
| 374 | - | ||
| 375 | - NSString *category_id = @""; | ||
| 376 | - if (![NSString isEmpty:self.selectShopClassifyVC.secCategoryId]) { | ||
| 377 | - category_id = self.selectShopClassifyVC.secCategoryId; | 585 | + var category_id = "" |
| 586 | + if self.selectShopClassifyVC.secCategoryId?.isEmpty == false { | ||
| 587 | + category_id = self.selectShopClassifyVC.secCategoryId! | ||
| 588 | + }else{ | ||
| 589 | + category_id = self.selectShopClassifyVC.firCategoryId! | ||
| 378 | } | 590 | } |
| 379 | - else | ||
| 380 | - { | ||
| 381 | - category_id = self.selectShopClassifyVC.firCategoryId; | 591 | + showLoading(message: "") |
| 592 | + if self.type == .add{ | ||
| 593 | + CNLiveShopGoodListViewModel.postGoodsAddWithUid(uid: DSUserInfoManager.shared.dsUserInfo.uid!, groupid3: self.selectCategoryVC?.thiCategoryId ?? "", bannerImg: bannerImageStr, simg: bannersSelectImageUrls.first!, video: bannerSelectVideoUrl, title: singleView5.contentTextField.text ?? "", ads: singleView6.contentTextView.text, price: singleView7.contentTextField.text ?? "", prices: singleView8.contentTextField.text ?? "", kg: singleView9.contentTextField.text ?? "", unit: singleView16.contentTextField.text ?? "", state: singleView11.contentSwitch.isOn ? "2" : "1", storage:self.dicArrayToJson(kvArray as! [Dictionary<String, Any>]), infoImg: contentDetailsImageStr, yunfei: singleView14.contentTextField.text ?? "", min_count: singleView10.countTF.text ?? "", isRefund: "0", category_id: category_id) { result, status in | ||
| 594 | + hiddenLoading() | ||
| 595 | + if status == .failed{ | ||
| 596 | + showMessage(message: "发布失败") | ||
| 597 | + return | ||
| 598 | + } | ||
| 599 | + if status == .success{ | ||
| 600 | + showMessage(message: "发布成功") | ||
| 601 | + NotificationCenter.default.post(name: NSNotification.Name.ShopGoodsManage.kDSGoodsManageAddNotification, object: nil) | ||
| 602 | + for i in 0..<self.dataModel.list.count{ | ||
| 603 | + var singleView = self.view.viewWithTag(i+1) as! CNLiveShopAddGoodsSingleView | ||
| 604 | + if singleView.addEditGoodsListModel?.style == "3"{ | ||
| 605 | + singleView.uploadImageView.deleteReplaceImageUrlAfterSuccessUploadThings() | ||
| 606 | + } | ||
| 607 | + } | ||
| 608 | + self.navigationController?.popViewController(animated: true) | ||
| 609 | + } | ||
| 610 | + } | ||
| 611 | + }else{ | ||
| 612 | + CNLiveShopGoodListViewModel.postGoodsAddWithUid(uid: DSUserInfoManager.shared.dsUserInfo.uid!, groupid3: self.selectCategoryVC?.thiCategoryId ?? "", bannerImg: bannerImageStr, simg: bannersSelectImageUrls.first!, video: bannerSelectVideoUrl, title: singleView5.contentTextField.text ?? "", ads: singleView6.contentTextView.text ?? "", price: singleView7.contentTextField.text ?? "", prices: singleView8.contentTextField.text ?? "", kg: singleView9.contentTextField.text ?? "", unit: singleView16.contentTextField.text ?? "", state: singleView11.contentSwitch.isOn ? "2" : "1", storage: self.dicArrayToJson(kvArray as! [Dictionary<String, Any>]), infoImg: contentDetailsImageStr, yunfei: singleView14.contentTextField.text ?? "", min_count: singleView10.countTF.text ?? "", isRefund: "0", category_id: category_id) { result, status in | ||
| 613 | + hiddenLoading() | ||
| 614 | + if status == .failed{ | ||
| 615 | + showMessage(message: "修改失败") | ||
| 616 | + return | ||
| 617 | + } | ||
| 618 | + if status == .success{ | ||
| 619 | + showMessage(message: "修改成功") | ||
| 620 | + NotificationCenter.default.post(name: NSNotification.Name.ShopGoodsManage.kDSGoodsManageEditNotification, object: nil, userInfo: (result as! Dictionary)) | ||
| 621 | + for i in 0..<self.dataModel.list.count{ | ||
| 622 | + var singleView = self.view.viewWithTag(i+1) as! CNLiveShopAddGoodsSingleView | ||
| 623 | + if singleView.addEditGoodsListModel?.style == "3"{ | ||
| 624 | + singleView.uploadImageView.deleteReplaceImageUrlAfterSuccessUploadThings() | ||
| 625 | + } | ||
| 626 | + } | ||
| 627 | + self.navigationController?.popViewController(animated: true) | ||
| 628 | + } | ||
| 629 | + } | ||
| 630 | + } | ||
| 631 | + } | ||
| 632 | + func dicArrayToJson(_ dicArray:[Dictionary<String, Any>])->String{ | ||
| 633 | + //首先判断能不能转换 | ||
| 634 | + if (!JSONSerialization.isValidJSONObject(dicArray)) { | ||
| 635 | + //print("is not a valid json object") | ||
| 636 | + return "" | ||
| 382 | } | 637 | } |
| 383 | 638 | ||
| 384 | - | ||
| 385 | - [self.view showLoading]; | ||
| 386 | - if (self.type == DSShopGoodsManageDetailsVCTypeAdd) { | ||
| 387 | - [DSShopRequest postGoodsAddWithUid:DS_USER_MODEL.uid | ||
| 388 | - groupid3:self.selectCategoryVC.thiCategoryId | ||
| 389 | - bannerImg:bannerImageStr | ||
| 390 | - simg:[bannersSelectImageUrls firstObject] | ||
| 391 | - video:bannerSelectVideoUrl | ||
| 392 | - title:singleView5.contentTextField.text | ||
| 393 | - ads:singleView6.contentTextView.text | ||
| 394 | - price:singleView7.contentTextField.text | ||
| 395 | - prices:singleView8.contentTextField.text | ||
| 396 | - kg:singleView9.contentTextField.text | ||
| 397 | - unit:singleView16.contentTextField.text | ||
| 398 | - state:singleView11.contentSwitch.on ? @"2" : @"1" | ||
| 399 | - storage:[kvArray mj_JSONString] | ||
| 400 | - infoImg:contentDetailsImageStr | ||
| 401 | - yunfei:singleView14.contentTextField.text | ||
| 402 | - min_count:singleView10.countTF.text | ||
| 403 | - isRefund:@"0"//singleView15.contentSwitch.on ? @"0" : @"1" | ||
| 404 | - category_id:category_id | ||
| 405 | - result:^(NSDictionary * _Nonnull jsonData, NSString * _Nonnull errorMessage) { | ||
| 406 | - [self.view hideLoading]; | ||
| 407 | - if (errorMessage) { | ||
| 408 | - DS_showMessage(errorMessage); | ||
| 409 | - return; | ||
| 410 | - } | ||
| 411 | - DS_showMessage(@"发布成功"); | ||
| 412 | - [[NSNotificationCenter defaultCenter] postNotificationName:kDSGoodsManageAddNotification object:nil]; | 639 | + //利用OC的json库转换成OC的NSData, |
| 640 | + //如果设置options为NSJSONWritingOptions.PrettyPrinted,则打印格式更好阅读 | ||
| 641 | + let data : Data! = try? JSONSerialization.data(withJSONObject: dicArray, options: []) | ||
| 642 | + //NSData转换成NSString打印输出 | ||
| 643 | + let str = NSString(data:data, encoding: String.Encoding.utf8.rawValue) | ||
| 644 | + //输出json字符串 | ||
| 645 | + return str! as String | ||
| 646 | + } | ||
| 647 | + // MARK: - 是否包含表情 | ||
| 648 | + func stringContainsEmoji(string:String) -> Bool { | ||
| 649 | + for scalar in string.unicodeScalars { | ||
| 650 | + switch scalar.value { | ||
| 651 | + case 0x1F600...0x1F64F, // Emoticons | ||
| 652 | + 0x1F300...0x1F5FF, // Misc Symbols and Pictographs | ||
| 653 | + 0x1F680...0x1F6FF, // Transport and Map | ||
| 654 | + 0x1F1E6...0x1F1FF, // Regional country flags | ||
| 655 | + 0x2600...0x26FF, // Misc symbols | ||
| 656 | + 0x2700...0x27BF, // Dingbats | ||
| 657 | + 0xFE00...0xFE0F, // Variation Selectors | ||
| 658 | + 0x1F900...0x1F9FF, // Supplemental Symbols and Pictographs | ||
| 659 | + 127000...127600, // Various asian characters | ||
| 660 | + 65024...65039, // Variation selector | ||
| 661 | + 9100...9300, // Misc items | ||
| 662 | + 8400...8447: // Combining Diacritical Marks for Symbols | ||
| 663 | + return true | ||
| 664 | + default: | ||
| 665 | + continue | ||
| 666 | + } | ||
| 667 | + } | ||
| 668 | + return false | ||
| 669 | + } | ||
| 670 | + | ||
| 671 | + // MARK: - 获取商品数据 | ||
| 672 | + func requestGoodsData(){ | ||
| 673 | + showLoading(message: "") | ||
| 674 | + CNLiveShopGoodListViewModel.getGoodsInfoWithGoodsId(goodsId: self.goodsId) { result, status in | ||
| 675 | + hiddenLoading() | ||
| 676 | + if status == .failed{ | ||
| 677 | + showMessage(message: "获取失败") | ||
| 678 | + return | ||
| 679 | + } | ||
| 680 | + if status == .success{ | ||
| 681 | + let model = result as! CNLiveShopGoodsDetailsModel | ||
| 682 | + self.shopGoodsDetailsModel = model | ||
| 683 | + //商品分类 | ||
| 684 | + var singleView1 = self.bgScrollView.viewWithTag(1) as! CNLiveShopAddGoodsSingleView | ||
| 685 | + //店铺分类 | ||
| 686 | + var singleView2 = self.bgScrollView.viewWithTag(2) as! CNLiveShopAddGoodsSingleView | ||
| 687 | + //商品轮播 | ||
| 688 | + var singleView4 = self.bgScrollView.viewWithTag(4) as! CNLiveShopAddGoodsSingleView | ||
| 689 | + //商品名称 | ||
| 690 | + var singleView5 = self.bgScrollView.viewWithTag(5) as! CNLiveShopAddGoodsSingleView | ||
| 691 | + //商品副标题 | ||
| 692 | + var singleView6 = self.bgScrollView.viewWithTag(6) as! CNLiveShopAddGoodsSingleView | ||
| 693 | + //本店售价 | ||
| 694 | + var singleView7 = self.bgScrollView.viewWithTag(7) as! CNLiveShopAddGoodsSingleView | ||
| 695 | + //市场售价 | ||
| 696 | + var singleView8 = self.bgScrollView.viewWithTag(8) as! CNLiveShopAddGoodsSingleView | ||
| 697 | + //商品重量 | ||
| 698 | + var singleView9 = self.bgScrollView.viewWithTag(9) as! CNLiveShopAddGoodsSingleView | ||
| 699 | + //最低起售 | ||
| 700 | + var singleView10 = self.bgScrollView.viewWithTag(10) as! CNLiveShopAddGoodsSingleView | ||
| 701 | + //上架 | ||
| 702 | + var singleView11 = self.bgScrollView.viewWithTag(11) as! CNLiveShopAddGoodsSingleView | ||
| 703 | + //商品详情图 | ||
| 704 | + var singleView13 = self.bgScrollView.viewWithTag(13) as! CNLiveShopAddGoodsSingleView | ||
| 705 | + //商品运费 | ||
| 706 | + var singleView14 = self.bgScrollView.viewWithTag(14) as! CNLiveShopAddGoodsSingleView | ||
| 707 | + //是否支持退货 | ||
| 708 | + var singleView15 = self.bgScrollView.viewWithTag(15) as! CNLiveShopAddGoodsSingleView | ||
| 709 | + //商品单位 | ||
| 710 | + var singleView16 = self.bgScrollView.viewWithTag(16) as! CNLiveShopAddGoodsSingleView | ||
| 711 | + //品名 | ||
| 712 | + var singleView18 = self.bgScrollView.viewWithTag(18) as! CNLiveShopAddGoodsSingleView | ||
| 713 | + //规格 | ||
| 714 | + var singleView19 = self.bgScrollView.viewWithTag(19) as! CNLiveShopAddGoodsSingleView | ||
| 715 | + //寄送区域 | ||
| 716 | + var singleView20 = self.bgScrollView.viewWithTag(20) as! CNLiveShopAddGoodsSingleView | ||
| 717 | + //发货时效 | ||
| 718 | + var singleView21 = self.bgScrollView.viewWithTag(21) as! CNLiveShopAddGoodsSingleView | ||
| 413 | 719 | ||
| 414 | - for (int i = 0; i < [self.disposeDataModel.list count]; i++) { | ||
| 415 | - DSShopGoodsManageDetailsSingleView * singleView = (DSShopGoodsManageDetailsSingleView*)[self.view viewWithTag:i+1]; | ||
| 416 | - if (singleView.model.style == 3) { | ||
| 417 | - [singleView.uploadImageView deleteReplaceImageUrlAfterSuccessUploadThings]; | 720 | + var tempArray = NSMutableArray(array: self.shopGoodsDetailsModel.storageArray) |
| 721 | + for dic in self.shopGoodsDetailsModel.storageArray{ | ||
| 722 | + let dict = dic as NSDictionary | ||
| 723 | + if dict.object(forKey: "k") as! String == "品名"{ | ||
| 724 | + let str = dict.stringValueForKey(key: "v") as String | ||
| 725 | + singleView18.contentTextField.text = str | ||
| 726 | + tempArray.remove(dict) | ||
| 727 | + } | ||
| 728 | + if dict.object(forKey: "k") as! String == "规格"{ | ||
| 729 | + let str = dict.stringValueForKey(key: "v") as String | ||
| 730 | + singleView19.contentTextField.text = str | ||
| 731 | + tempArray.remove(dict) | ||
| 732 | + } | ||
| 733 | + if dict.object(forKey: "k") as! String == "寄送区域"{ | ||
| 734 | + let str = dict.stringValueForKey(key: "v") as String | ||
| 735 | + singleView20.contentTextView.text = str | ||
| 736 | + tempArray.remove(dict) | ||
| 737 | + } | ||
| 738 | + if dict.object(forKey: "k") as! String == "发货时效"{ | ||
| 739 | + let str = dict.stringValueForKey(key: "v") as String | ||
| 740 | + singleView21.contentTextField.text = str | ||
| 741 | + tempArray.remove(dict) | ||
| 418 | } | 742 | } |
| 419 | } | 743 | } |
| 744 | + singleView1.contentTextField.text = self.shopGoodsDetailsModel.group_name | ||
| 745 | + singleView1.layoutSubviews() | ||
| 420 | 746 | ||
| 421 | - [self dsPopViewControllerAnimated:YES]; | ||
| 422 | - }]; | ||
| 423 | - }else { | ||
| 424 | - [DSShopRequest postGoodsEditWithGoodsId:self.goodsId | ||
| 425 | - uid:DS_USER_MODEL.uid | ||
| 426 | - bannerImg:bannerImageStr | ||
| 427 | - simg:[bannersSelectImageUrls firstObject] | ||
| 428 | - video:bannerSelectVideoUrl | ||
| 429 | - title:singleView5.contentTextField.text | ||
| 430 | - ads:singleView6.contentTextView.text | ||
| 431 | - price:singleView7.contentTextField.text | ||
| 432 | - prices:singleView8.contentTextField.text | ||
| 433 | - kg:singleView9.contentTextField.text | ||
| 434 | - unit:singleView16.contentTextField.text | ||
| 435 | - state:singleView11.contentSwitch.on ? @"2" : @"1" | ||
| 436 | - storage:[kvArray mj_JSONString] | ||
| 437 | - infoImg:contentDetailsImageStr | ||
| 438 | - yunfei:singleView14.contentTextField.text | ||
| 439 | - min_count:singleView10.countTF.text | ||
| 440 | - isRefund:@"0"//singleView15.contentSwitch.on ? @"0" : @"1" | ||
| 441 | - category_id:category_id | ||
| 442 | - result:^(NSDictionary * _Nonnull jsonData, NSString * _Nonnull errorMessage) { | ||
| 443 | - [self.view hideLoading]; | ||
| 444 | - if (errorMessage) { | ||
| 445 | - DS_showMessage(errorMessage); | ||
| 446 | - return; | 747 | + singleView2.contentTextField.text = self.shopGoodsDetailsModel.cate_name |
| 748 | + singleView2.layoutSubviews() | ||
| 749 | + | ||
| 750 | + var bannerImageUrls = NSMutableArray() | ||
| 751 | + for model in self.shopGoodsDetailsModel.image{ | ||
| 752 | + bannerImageUrls.add(model.simg ?? "") | ||
| 447 | } | 753 | } |
| 448 | - DS_showMessage(@"修改成功"); | ||
| 449 | - [[NSNotificationCenter defaultCenter] postNotificationName:kDSGoodsManageEditNotification object:nil userInfo:jsonData]; | 754 | + if let array = bannerImageUrls as? [String] { |
| 755 | + singleView4.uploadImageView.networkImageArr = array | ||
| 756 | + } | ||
| 757 | + singleView4.uploadImageView.setNetworkVideoUrl(networkVideoUrl: self.shopGoodsDetailsModel.video?.video_url ?? "", networkVideoImageUrl: self.shopGoodsDetailsModel.video?.video_img ?? "") | ||
| 758 | + | ||
| 759 | + singleView5.contentTextField.text = self.shopGoodsDetailsModel.title | ||
| 760 | + singleView6.contentTextView.text = self.shopGoodsDetailsModel.ads | ||
| 761 | + singleView7.contentTextField.text = self.shopGoodsDetailsModel.price?.keepTwoDecimalPlaces() | ||
| 762 | + singleView8.contentTextField.text = self.shopGoodsDetailsModel.prices?.keepTwoDecimalPlaces() | ||
| 763 | + singleView9.contentTextField.text = self.shopGoodsDetailsModel.kg | ||
| 764 | + singleView10.countTF.text = self.shopGoodsDetailsModel.min_buy_num | ||
| 765 | + singleView11.contentSwitch.isOn = self.shopGoodsDetailsModel.state == 2 ? true : false | ||
| 766 | + singleView10.subtractBtn.setImage(UIImage(named: Int(self.shopGoodsDetailsModel.min_buy_num ?? "0")! > 1 ? "DS_main_unadd_count" : "DS_main_unadd_count_n"), for: .normal) | ||
| 450 | 767 | ||
| 451 | - for (int i = 0; i < [self.disposeDataModel.list count]; i++) { | ||
| 452 | - DSShopGoodsManageDetailsSingleView * singleView = (DSShopGoodsManageDetailsSingleView*)[self.view viewWithTag:i+1]; | ||
| 453 | - if (singleView.model.style == 3) { | ||
| 454 | - [singleView.uploadImageView deleteReplaceImageUrlAfterSuccessUploadThings]; | 768 | + var contentDetailsImageUrls = NSMutableArray() |
| 769 | + for model in self.shopGoodsDetailsModel.detail_img{ | ||
| 770 | + contentDetailsImageUrls.add(model.simg) | ||
| 771 | + } | ||
| 772 | + singleView13.uploadImageView.networkImageArr = contentDetailsImageUrls as! Array<String> | ||
| 773 | + if let array = contentDetailsImageUrls as? [String] { | ||
| 774 | + singleView13.uploadImageView.networkImageArr = array | ||
| 775 | + } | ||
| 776 | + singleView14.contentTextField.text = self.shopGoodsDetailsModel.yunfei?.keepTwoDecimalPlaces() | ||
| 777 | + singleView15.contentSwitch.isOn = self.shopGoodsDetailsModel.is_refund == 0 ? true : false | ||
| 778 | + singleView16.contentTextField.text = self.shopGoodsDetailsModel.unit | ||
| 779 | + singleView4.uploadImageView.deleteImage = UIImage.imageWithColor(color: .clear, size: singleView4.uploadImageView.size) | ||
| 780 | + singleView13.uploadImageView.deleteImage = UIImage.imageWithColor(color: .clear, size: singleView13.uploadImageView.size) | ||
| 781 | + if tempArray.count > 0{ | ||
| 782 | + var array = NSMutableArray(array: self.dataModel.list) | ||
| 783 | + for i in 0..<tempArray.count{ | ||
| 784 | + let dict = tempArray.object(at: i) as! NSDictionary | ||
| 785 | + let paramDict = ["style":1,"isHaveTo":false,"title":dict.object(forKey: "k"),"contentTextFieldkeyboardType":1,"isDisplayLine":true,"contentType":1,"isDelect":true,"content":dict.object(forKey: "v")] | ||
| 786 | + let listModel = newDictionaryToModel(paramDict as [String : Any], CNLiveShopAddEditGoodsListModel.self) as! CNLiveShopAddEditGoodsListModel | ||
| 787 | + array.add(listModel) | ||
| 788 | + self.reloadBgScrollViewContentViewModel(model: listModel, index: self.dataModel.list.count+1+i, isScrollToBottom: false) | ||
| 789 | + if tempArray.count-1 == i{ | ||
| 790 | + self.dataModel.list = array as! [CNLiveShopAddEditGoodsListModel] | ||
| 791 | + self.viewWillLayoutSubviews() | ||
| 792 | + } | ||
| 455 | } | 793 | } |
| 456 | } | 794 | } |
| 457 | - | ||
| 458 | - [self dsPopViewControllerAnimated:YES]; | ||
| 459 | - }]; | ||
| 460 | - }*/ | 795 | + } |
| 796 | + } | ||
| 461 | } | 797 | } |
| 462 | } | 798 | } |
| 463 | 799 |
metaCode/Classes/Main/HomePage/View/GoodsManager/CNLiveAddGoodsSelectUploadImageView.swift
| @@ -6,8 +6,398 @@ | @@ -6,8 +6,398 @@ | ||
| 6 | // | 6 | // |
| 7 | 7 | ||
| 8 | import Foundation | 8 | import Foundation |
| 9 | +import UIKit | ||
| 10 | +import UniformTypeIdentifiers | ||
| 11 | +import AVFoundation | ||
| 12 | +import HXPHPicker | ||
| 13 | +///类型 | ||
| 14 | +enum CNLiveSelectUploadImageViewDisplayType:Int { | ||
| 15 | + ///选择 | ||
| 16 | + case select = 0 | ||
| 17 | + ///展示 | ||
| 18 | + case display | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +enum CNLiveSelectUploadImageViewHeightStyle:Int { | ||
| 22 | + ///高度自动控制 | ||
| 23 | + case autoCalc = 0 | ||
| 24 | + ///高度固定 | ||
| 25 | + case fixed | ||
| 26 | +} | ||
| 27 | +let DS_SUIV_ADD_TAG_COUNT = 123321 //所有view加一个默认tag值 以防和别的tag重复 | ||
| 9 | 28 | ||
| 10 | -class CNLiveAddGoodsSelectUploadImageView: UIView { | 29 | +typealias clickCallBackBlock = ()->Void |
| 30 | +typealias changeFrameCallBackBlock = ()->Void | ||
| 31 | +typealias changeUploadDataCallBackBlock = (_ imageUrls:Array<String> ,_ videoUrl:String)->Void | ||
| 32 | +typealias beginUploadImageCallBackBlock = ()->Void | ||
| 33 | +typealias endUploadImageCallBackBlock = ()->Void | ||
| 34 | + | ||
| 35 | + | ||
| 36 | +class CNLiveAddGoodsSelectUploadImageView: UIView,UIImagePickerControllerDelegate, PhotoPickerControllerDelegate { | ||
| 37 | + | ||
| 38 | + // MARK: - 属性 | ||
| 39 | + /// 显示类型 | ||
| 40 | + var _displayType:CNLiveSelectUploadImageViewDisplayType? | ||
| 41 | + var displayType:CNLiveSelectUploadImageViewDisplayType?{ | ||
| 42 | + get{ | ||
| 43 | + _displayType | ||
| 44 | + } | ||
| 45 | + set{ | ||
| 46 | + _displayType = newValue | ||
| 47 | + self.resetUI() | ||
| 48 | + } | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + /// 高度类型 | ||
| 52 | + var heightStyle:CNLiveSelectUploadImageViewHeightStyle | ||
| 53 | + /// 每张图的间距 默认DS_adapt_length(15) | ||
| 54 | + var _space:CGFloat = 15 | ||
| 55 | + var space:CGFloat{ | ||
| 56 | + get{ | ||
| 57 | + _space | ||
| 58 | + } | ||
| 59 | + set{ | ||
| 60 | + _space = newValue | ||
| 61 | + self.resetUI() | ||
| 62 | + self.autoAdjustHeight() | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | + /// 每行第一张图距左边的间距 默认DS_adapt_length(15) | ||
| 66 | + var _lSpace:CGFloat = 15 | ||
| 67 | + var lSpace:CGFloat{ | ||
| 68 | + get{ | ||
| 69 | + _lSpace | ||
| 70 | + } | ||
| 71 | + set{ | ||
| 72 | + _lSpace = newValue | ||
| 73 | + self.resetUI() | ||
| 74 | + self.autoAdjustHeight() | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + /// 每行最后一张图距右边的间距 默认DS_adapt_length(15) | ||
| 78 | + var _rSpace:CGFloat = 15 | ||
| 79 | + var rSpace:CGFloat{ | ||
| 80 | + get{ | ||
| 81 | + _rSpace | ||
| 82 | + } | ||
| 83 | + set{ | ||
| 84 | + _rSpace = newValue | ||
| 85 | + self.resetUI() | ||
| 86 | + self.autoAdjustHeight() | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + /// 图片的宽高(正方形) heightStyle=DSSelectUploadImageViewHeightStyleAutoCalc时自动计算 heightStyle=DSSelectUploadImageViewHeightStyleFixed时为0需自己赋值 (提示:图片右上角需留出DS_adapt_length(17)/2的空间,给X的图片留位置) | ||
| 90 | + var WHeight:CGFloat = 0 | ||
| 91 | + /// 自定义删除图片 默认DS_SelUplImageView_delete | ||
| 92 | + var _deleteImage:UIImage? | ||
| 93 | + var deleteImage:UIImage?{ | ||
| 94 | + get{ | ||
| 95 | + _deleteImage | ||
| 96 | + } | ||
| 97 | + set{ | ||
| 98 | + _deleteImage = newValue | ||
| 99 | + self.resetUI() | ||
| 100 | + } | ||
| 101 | + } | ||
| 102 | + /// 是否显示选取封面 | ||
| 103 | + var _isDisplySelectCover:Bool? | ||
| 104 | + var isDisplySelectCover:Bool?{ | ||
| 105 | + get{ | ||
| 106 | + _isDisplySelectCover | ||
| 107 | + } | ||
| 108 | + set{ | ||
| 109 | + _isDisplySelectCover = newValue | ||
| 110 | + self.resetUI() | ||
| 111 | + } | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + // MARK: - 回调 | ||
| 115 | + /// 点击处理事务前回调 | ||
| 116 | + var clickCallBack:clickCallBackBlock? | ||
| 117 | + /// 修改自身高度回调 | ||
| 118 | + var changeFrameCallBack:changeFrameCallBackBlock? | ||
| 119 | + /// 修改上传数据回调 | ||
| 120 | + var changeUploadDataCallBack:changeUploadDataCallBackBlock? | ||
| 121 | + | ||
| 122 | + // MARK: - 展示属性 | ||
| 123 | + /// 获取的网络图片数组 | ||
| 124 | + var _networkImageArr:Array<String> | ||
| 125 | + var networkImageArr:Array<String>{ | ||
| 126 | + get{ | ||
| 127 | + _networkImageArr | ||
| 128 | + } | ||
| 129 | + set{ | ||
| 130 | + _networkImageArr = newValue | ||
| 131 | + self.deleteUploadImageUrl() | ||
| 132 | + self.uploadImageUrls.removeAll() | ||
| 133 | + self.replaceImageUrls.removeAll() | ||
| 134 | + for imageUrl in self.networkImageArr{ | ||
| 135 | + var uploadImageModel = CNLiveSelectUploadImageModel() | ||
| 136 | + uploadImageModel.imageUrl = imageUrl | ||
| 137 | + uploadImageModel.isUploading = false | ||
| 138 | + self.uploadImageUrls.append(uploadImageModel) | ||
| 139 | + } | ||
| 140 | + self.resetUI() | ||
| 141 | + self.autoAdjustHeight() | ||
| 142 | + } | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + /// 获取的网络视频url | ||
| 146 | + var networkVideoUrl:String? | ||
| 147 | + /// 获取的网络视频图片 | ||
| 148 | + var networkVideoImageUrl:String? | ||
| 149 | + | ||
| 150 | + // MARK: - 选择属性 | ||
| 151 | + /// 列数默认4 | ||
| 152 | + var _column:Int = 4 | ||
| 153 | + var column:Int{ | ||
| 154 | + get{ | ||
| 155 | + _column | ||
| 156 | + } | ||
| 157 | + set{ | ||
| 158 | + _column = newValue | ||
| 159 | + self.resetUI() | ||
| 160 | + self.autoAdjustHeight() | ||
| 161 | + } | ||
| 162 | + } | ||
| 163 | + /// 图片选取最大数量 默认0 必传 | ||
| 164 | + var _maxSelectImageCount:Int = 0 | ||
| 165 | + var maxSelectImageCount:Int{ | ||
| 166 | + get{ | ||
| 167 | + _maxSelectImageCount | ||
| 168 | + } | ||
| 169 | + set{ | ||
| 170 | + _maxSelectImageCount = newValue | ||
| 171 | + if self.uploadImageUrls.count > self.maxSelectImageCount{ | ||
| 172 | + var i = self.uploadImageUrls.count-1 | ||
| 173 | + while i >= self.maxSelectImageCount { | ||
| 174 | + i -= 1 | ||
| 175 | + let model = self.uploadImageUrls[i] | ||
| 176 | + if model.isUploading == true{ | ||
| 177 | + [[DSQiNiuUploadManager sharedManager] cancelUploadKey:model.uploadKey]; | ||
| 178 | + }else{ | ||
| 179 | + [[DSQiNiuUploadManager sharedManager] requestQiNiuDeleteImageUrl:model.imageUrl complete:nil]; | ||
| 180 | + self.uploadImageUrls.remove(model) | ||
| 181 | + } | ||
| 182 | + } | ||
| 183 | + } | ||
| 184 | + self.resetUI() | ||
| 185 | + } | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + /// 是否可以选择视频 (目前只能选取一个,在索引1显示) | ||
| 189 | + var _isAbleSelectVideo:Bool? | ||
| 190 | + var isAbleSelectVideo:Bool?{ | ||
| 191 | + get{ | ||
| 192 | + _isAbleSelectVideo | ||
| 193 | + } | ||
| 194 | + set{ | ||
| 195 | + _isAbleSelectVideo = newValue | ||
| 196 | + self.resetUI() | ||
| 197 | + } | ||
| 198 | + } | ||
| 199 | + // MARK: - 上传操作 | ||
| 200 | + /// 是否正在上传图片中 | ||
| 201 | + var isUploading:Bool? | ||
| 202 | + /// 开始上传图片 | ||
| 203 | + var beginUploadImageCallBack:beginUploadImageCallBackBlock? | ||
| 204 | + /// 结束上传图片 | ||
| 205 | + var endUploadImageCallBack:endUploadImageCallBackBlock? | ||
| 206 | + | ||
| 207 | + /// 获取的网络视频属性 | ||
| 208 | + /// @param networkVideoUrl 获取的网络视频url | ||
| 209 | + /// @param networkVideoImageUrl 获取的网络视频图片 | ||
| 210 | + func setNetworkVideoUrl(networkVideoUrl:String,networkVideoImageUrl:String){ | ||
| 211 | + self.networkVideoUrl = networkVideoUrl | ||
| 212 | + self.networkVideoImageUrl = networkVideoImageUrl | ||
| 213 | + self.deleteUploadVideoUrl() | ||
| 214 | + self.uploadVideoModel = nil | ||
| 215 | + self.uploadVideoModel = CNLiveSelectUploadImageModel() | ||
| 216 | + self.uploadVideoModel?.isVideo = true | ||
| 217 | + self.uploadVideoModel?.videoUrl = self.networkVideoUrl | ||
| 218 | + self.uploadVideoModel?.imageUrl = self.networkVideoImageUrl | ||
| 219 | + self.uploadVideoModel?.isUploading = false | ||
| 220 | + self.resetUI() | ||
| 221 | + | ||
| 222 | + } | ||
| 223 | + | ||
| 224 | + // MARK: - 私有属性 | ||
| 225 | + /** | ||
| 226 | + 这次要上传的视频url | ||
| 227 | + */ | ||
| 228 | + var _uploadVideoModel:CNLiveSelectUploadImageModel? | ||
| 229 | + var uploadVideoModel:CNLiveSelectUploadImageModel?{ | ||
| 230 | + get{ | ||
| 231 | + if _uploadVideoModel == nil{ | ||
| 232 | + _uploadVideoModel = CNLiveSelectUploadImageModel() | ||
| 233 | + _uploadVideoModel?.isVideo = true | ||
| 234 | + } | ||
| 235 | + return _uploadVideoModel | ||
| 236 | + } | ||
| 237 | + set{ | ||
| 238 | + _uploadVideoModel = newValue | ||
| 239 | + } | ||
| 240 | + } | ||
| 241 | + /** | ||
| 242 | + 需要删除的视频urls | ||
| 243 | + */ | ||
| 244 | + var replaceVideoUrls = [CNLiveSelectUploadImageModel]() | ||
| 245 | + /** | ||
| 246 | + 这次要上传的图片urls | ||
| 247 | + */ | ||
| 248 | + var uploadImageUrls = [CNLiveSelectUploadImageModel]() | ||
| 249 | + /** | ||
| 250 | + 需要删除的图片urls | ||
| 251 | + */ | ||
| 252 | + var replaceImageUrls = [CNLiveSelectUploadImageModel]() | ||
| 253 | + /** | ||
| 254 | + 正在上传的图片数量 | ||
| 255 | + */ | ||
| 256 | + var _uploadingCount:Int = 0 | ||
| 257 | + var uploadingCount:Int{ | ||
| 258 | + get{ | ||
| 259 | + _uploadingCount | ||
| 260 | + } | ||
| 261 | + set{ | ||
| 262 | + _uploadingCount = newValue | ||
| 263 | + if _uploadingCount > 0{ | ||
| 264 | + self.isUploading = true | ||
| 265 | + }else{ | ||
| 266 | + self.isUploading = false | ||
| 267 | + } | ||
| 268 | + } | ||
| 269 | + } | ||
| 270 | + | ||
| 271 | + // MARK: - 公开方法 | ||
| 272 | + /** | ||
| 273 | + 获取当前选取的网络图片Url数组 | ||
| 274 | + @return 网络图片Url数组 | ||
| 275 | + */ | ||
| 276 | + func getCurrentSelectImageUrls()->Array<String>{ | ||
| 277 | + var imageUrls = NSMutableArray() | ||
| 278 | + for uploadImageModel in self.uploadImageUrls{ | ||
| 279 | + if uploadImageModel.isUploading == true || uploadImageModel.imageUrl?.isEmpty == true{ | ||
| 280 | + return Array() | ||
| 281 | + } | ||
| 282 | + imageUrls.add(uploadImageModel.imageUrl!) | ||
| 283 | + } | ||
| 284 | + let arr = imageUrls as NSArray | ||
| 285 | + return arr as! Array<String> | ||
| 286 | + } | ||
| 287 | + /** | ||
| 288 | + 获取当前选取的网络视频Url | ||
| 289 | + | ||
| 290 | + @return 网络视频Url | ||
| 291 | + */ | ||
| 292 | + func getCurrentSelectVideoUrl()->String{ | ||
| 293 | + if ((self.uploadVideoModel?.isUploading == true) || self.uploadVideoModel?.videoUrl?.count == 0){ | ||
| 294 | + return "" | ||
| 295 | + } | ||
| 296 | + return self.uploadVideoModel?.videoUrl ?? "" | ||
| 297 | + } | ||
| 298 | + /** | ||
| 299 | + 获取当前选取的本地视频Url | ||
| 300 | + | ||
| 301 | + @return 网络视频Url | ||
| 302 | + */ | ||
| 303 | + func getCurrentSelectLocalVideoUrl()->NSURL{ | ||
| 304 | + return self.uploadVideoModel?.localVideoUrl ?? NSURL() | ||
| 305 | + } | ||
| 306 | + /** | ||
| 307 | + 获取当前选取的本地视频Url第一帧图片 | ||
| 308 | + | ||
| 309 | + @return 网络视频Url第一帧图片 | ||
| 310 | + */ | ||
| 311 | + func getCurrentSelectLocalVideoUrlFirstImage() -> UIImage? { | ||
| 312 | + return self.uploadVideoModel?.image | ||
| 313 | + } | ||
| 314 | + /** | ||
| 315 | + 提交成功XXX后 删除(云中)替换掉的图片 (提交成功调用) | ||
| 316 | + */ | ||
| 317 | + func deleteReplaceImageUrlAfterSuccessUploadThings(){ | ||
| 318 | + for replaceImageModel in self.replaceImageUrls { | ||
| 319 | + [[DSQiNiuUploadManager sharedManager] requestQiNiuDeleteImageUrl:replaceImageModel.imageUrl complete:nil]; | ||
| 320 | + } | ||
| 321 | + self.networkImageArr = self.getCurrentSelectImageUrls() | ||
| 322 | + for replaceVideoModel in self.replaceVideoUrls { | ||
| 323 | + [[DSQiNiuUploadManager sharedManager] requestQiNiuDeleteImageUrl:replaceVideoModel.videoUrl complete:nil]; | ||
| 324 | + } | ||
| 325 | + self.networkVideoUrl = self.getCurrentSelectVideoUrl() | ||
| 326 | + } | ||
| 327 | + /** | ||
| 328 | + 不上传了 删除(云中)新上传的图片 (dealloc调用) | ||
| 329 | + */ | ||
| 330 | + func deleteUploadImageUrlAfterCancelUploadThings(){ | ||
| 331 | + self.deleteUploadImageUrl() | ||
| 332 | + self.deleteUploadVideoUrl() | ||
| 333 | + } | ||
| 334 | + /** | ||
| 335 | + 不上传了 删除(云中)新上传的图片 | ||
| 336 | + */ | ||
| 337 | + func deleteUploadImageUrl(){ | ||
| 338 | + for uploadImageModel in self.uploadImageUrls { | ||
| 339 | + if ((self.networkImageArr?.contains(uploadImageModel.imageUrl ?? "")) != nil){ | ||
| 340 | + [[DSQiNiuUploadManager sharedManager] requestQiNiuDeleteImageUrl:uploadImageModel.imageUrl complete:nil]; | ||
| 341 | + }else if uploadImageModel.isUploading == true{ | ||
| 342 | + [[DSQiNiuUploadManager sharedManager] cancelUploadKey:uploadImageModel.uploadKey]; | ||
| 343 | + } | ||
| 344 | + } | ||
| 345 | + for replaceImageModel in self.replaceImageUrls{ | ||
| 346 | + if ((self.networkImageArr.contains(replaceImageModel.imageUrl ?? "")) != nil){ | ||
| 347 | + [[DSQiNiuUploadManager sharedManager] requestQiNiuDeleteImageUrl:replaceImageModel.imageUrl complete:nil]; | ||
| 348 | + } | ||
| 349 | + } | ||
| 350 | + } | ||
| 351 | + /** | ||
| 352 | + 不上传了 删除(云中)新上传的视频 | ||
| 353 | + */ | ||
| 354 | + func deleteUploadVideoUrl(){ | ||
| 355 | + if self.networkVideoUrl != self.uploadVideoModel?.videoUrl{ | ||
| 356 | + [[DSQiNiuUploadManager sharedManager] requestQiNiuDeleteImageUrl:self.uploadVideoModel.videoUrl complete:nil]; | ||
| 357 | + }else if self.uploadVideoModel?.isUploading == true{ | ||
| 358 | + [[DSQiNiuUploadManager sharedManager] cancelUploadKey:self.uploadVideoModel.uploadKey]; | ||
| 359 | + } | ||
| 360 | + for replaceVideoModel in self.replaceVideoUrls { | ||
| 361 | + if self.networkVideoUrl != replaceVideoModel.videoUrl{ | ||
| 362 | + [[DSQiNiuUploadManager sharedManager] requestQiNiuDeleteImageUrl:replaceVideoModel.videoUrl complete:nil]; | ||
| 363 | + } | ||
| 364 | + } | ||
| 365 | + } | ||
| 366 | + // MARK: - 系统属性 | ||
| 367 | + override var frame: CGRect{ | ||
| 368 | + didSet { | ||
| 369 | + if self.heightStyle == .autoCalc{ | ||
| 370 | + //算出带X图片的间距 X图片宽高均为DS_adapt_length(17) | ||
| 371 | + var addXRSpace = self.rSpace - 17*0.5 | ||
| 372 | + var addXSpace = self.space - 17*0.5 | ||
| 373 | + let column = self.maxSelectImageCount < self.column ? self.maxSelectImageCount : self.column | ||
| 374 | + let totalSpace = self.lSpace + addXRSpace + addXSpace*CGFloat(column - 1) | ||
| 375 | + let aHeight = column == 0 ? 0.0 : (frame.size.width - totalSpace / CGFloat(column)) | ||
| 376 | + | ||
| 377 | + let subviewsCount = self.subviews.count | ||
| 378 | + let row = subviewsCount / column + (subviewsCount % column > 0 ? 1 : 0) | ||
| 379 | + let height = aHeight * CGFloat(row) + (row > 1 ? addXSpace : 0) + 10 | ||
| 380 | + var isNeedCallBack = false | ||
| 381 | + if self.height != 0 && self.height != height{ | ||
| 382 | + isNeedCallBack = true | ||
| 383 | + } | ||
| 384 | + super.frame = CGRect(x: frame.origin.x, y: frame.origin.y, width: frame.size.width, height: height == 0 ? frame.size.height : height) | ||
| 385 | + if isNeedCallBack{ | ||
| 386 | + self.changeFrameCallBack!() | ||
| 387 | + } | ||
| 388 | + }else{ | ||
| 389 | + super.frame = frame | ||
| 390 | + } | ||
| 391 | + } | ||
| 392 | + } | ||
| 393 | + | ||
| 394 | + // MARK: - 自动调整高度 | ||
| 395 | + func autoAdjustHeight(){ | ||
| 396 | + if self.heightStyle == .autoCalc{ | ||
| 397 | + self.frame = self.frame | ||
| 398 | + } | ||
| 399 | + } | ||
| 400 | + | ||
| 11 | override init(frame: CGRect) { | 401 | override init(frame: CGRect) { |
| 12 | super.init(frame: frame) | 402 | super.init(frame: frame) |
| 13 | } | 403 | } |
| @@ -15,4 +405,470 @@ class CNLiveAddGoodsSelectUploadImageView: UIView { | @@ -15,4 +405,470 @@ class CNLiveAddGoodsSelectUploadImageView: UIView { | ||
| 15 | required init?(coder: NSCoder) { | 405 | required init?(coder: NSCoder) { |
| 16 | fatalError("init(coder:) has not been implemented") | 406 | fatalError("init(coder:) has not been implemented") |
| 17 | } | 407 | } |
| 408 | + // MARK: - 初始化 | ||
| 409 | + init(frame:CGRect ,heightStyle:CNLiveSelectUploadImageViewHeightStyle,maxSelectImageCount:Int) { | ||
| 410 | + super.init(frame: frame) | ||
| 411 | + self.initData() | ||
| 412 | + self.resetUI() | ||
| 413 | + } | ||
| 414 | + | ||
| 415 | + func initData(){ | ||
| 416 | + self.backgroundColor = .clear | ||
| 417 | + self.clipsToBounds = true | ||
| 418 | + self.column = 4 | ||
| 419 | + self.space = 15 | ||
| 420 | + self.lSpace = 15 | ||
| 421 | + self.rSpace = 15 | ||
| 422 | + NotificationCenter.default.addObserver(self, selector: #selector(willTerminateNotification), name: UIApplication.willTerminateNotification, object: nil) | ||
| 423 | + } | ||
| 424 | + override func layoutSubviews() { | ||
| 425 | + super.layoutSubviews() | ||
| 426 | + | ||
| 427 | + //算出带X图片的间距 X图片宽高均为DS_adapt_length(17) | ||
| 428 | + let addXRSpace = self.rSpace - 17*0.5 | ||
| 429 | + let addXSpace = self.space - 17*0.5 | ||
| 430 | + let column = self.maxSelectImageCount < self.column ? self.maxSelectImageCount : self.column | ||
| 431 | + var width = 0.0 | ||
| 432 | + if self.heightStyle == .autoCalc{ | ||
| 433 | + let totalSpace = self.lSpace + addXRSpace + addXSpace * CGFloat(column - 1) | ||
| 434 | + width = (self.width - totalSpace) / Double(column) | ||
| 435 | + }else{ | ||
| 436 | + width = self.WHeight | ||
| 437 | + } | ||
| 438 | + let height = width | ||
| 439 | + let subViews = self.subviews | ||
| 440 | + for i in 0..<subViews.count { | ||
| 441 | + let singleImageView = self.viewWithTag(i+1+DS_SUIV_ADD_TAG_COUNT) | ||
| 442 | + singleImageView?.frame = CGRect(x: self.lSpace+(width+addXSpace)*Double((i%column)), y: (height+addXSpace)*Double((i/column)), width: width, height: height) | ||
| 443 | + } | ||
| 444 | + } | ||
| 445 | + deinit { | ||
| 446 | + NotificationCenter.default.removeObserver(self, name: UIApplication.willTerminateNotification, object: nil) | ||
| 447 | + } | ||
| 448 | + | ||
| 449 | + // MARK: - 通知 | ||
| 450 | + @objc func willTerminateNotification(){ | ||
| 451 | + self.deleteUploadImageUrlAfterCancelUploadThings() | ||
| 452 | + } | ||
| 453 | + | ||
| 454 | + // MARK: - resetUI | ||
| 455 | + func resetUI(){ | ||
| 456 | + self.subviews.forEach { $0.removeFromSuperview() } | ||
| 457 | + var isHideDeleteBtn = false | ||
| 458 | + if self.displayType == .display{ | ||
| 459 | + isHideDeleteBtn = true | ||
| 460 | + } | ||
| 461 | + if self.displayType == .select{ | ||
| 462 | + var lastIsSelectImage = false | ||
| 463 | + if self.isAbleSelectVideo == true{ | ||
| 464 | + let model1 = CNLiveSelectUploadImageModel() | ||
| 465 | + model1.isSelectPhotoPlaceholder = true | ||
| 466 | + let singleImageView1 = self.createSingleImageView() | ||
| 467 | + singleImageView1.tag = 1+DS_SUIV_ADD_TAG_COUNT | ||
| 468 | + singleImageView1.setModel(model: model1, isHideDeleteBtn: isHideDeleteBtn, isCover: false) | ||
| 469 | + self.addSubview(singleImageView1) | ||
| 470 | + let singleImageView2 = self.createSingleImageView() | ||
| 471 | + singleImageView2.tag = 2+DS_SUIV_ADD_TAG_COUNT | ||
| 472 | + singleImageView2.setModel(model: self.uploadVideoModel!, isHideDeleteBtn: isHideDeleteBtn, isCover: false) | ||
| 473 | + self.addSubview(singleImageView2) | ||
| 474 | + }else if self.uploadImageUrls.count < self.maxSelectImageCount{ | ||
| 475 | + lastIsSelectImage = true | ||
| 476 | + } | ||
| 477 | + var lastView:CNLiveSelUplSingleImageView? = nil | ||
| 478 | + for i in 0..<self.uploadImageUrls.count { | ||
| 479 | + let model = self.uploadImageUrls[i] | ||
| 480 | + var singleImageView = self.createSingleImageView() | ||
| 481 | + if self.isAbleSelectVideo! == true{ | ||
| 482 | + singleImageView.tag = i+3+DS_SUIV_ADD_TAG_COUNT | ||
| 483 | + }else{ | ||
| 484 | + singleImageView.tag = i+1+DS_SUIV_ADD_TAG_COUNT | ||
| 485 | + } | ||
| 486 | + singleImageView.setModel(model: model, isHideDeleteBtn: isHideDeleteBtn, isCover: i == 0 ? true : false) | ||
| 487 | + self.addSubview(singleImageView) | ||
| 488 | + lastView = singleImageView | ||
| 489 | + } | ||
| 490 | + if lastIsSelectImage{ | ||
| 491 | + var model = CNLiveSelectUploadImageModel() | ||
| 492 | + model.isSelectPhotoPlaceholder = true | ||
| 493 | + var singleImageView = self.createSingleImageView() | ||
| 494 | + if (lastView != nil){ | ||
| 495 | + singleImageView.tag = lastView!.tag | ||
| 496 | + }else{ | ||
| 497 | + singleImageView.tag = DS_SUIV_ADD_TAG_COUNT+1 | ||
| 498 | + } | ||
| 499 | + singleImageView.setModel(model: model, isHideDeleteBtn: isHideDeleteBtn, isCover: false) | ||
| 500 | + self.addSubview(singleImageView) | ||
| 501 | + } | ||
| 502 | + }else{ | ||
| 503 | + if self.networkVideoUrl!.count > 0{ | ||
| 504 | + var model = CNLiveSelectUploadImageModel() | ||
| 505 | + model.videoUrl = self.networkVideoUrl | ||
| 506 | + model.imageUrl = self.networkVideoImageUrl | ||
| 507 | + model.isVideo = true | ||
| 508 | + | ||
| 509 | + var singleImageView = self.createSingleImageView() | ||
| 510 | + singleImageView.tag = 1+DS_SUIV_ADD_TAG_COUNT | ||
| 511 | + singleImageView.setModel(model: model, isHideDeleteBtn: isHideDeleteBtn, isCover: false) | ||
| 512 | + self.addSubview(singleImageView) | ||
| 513 | + } | ||
| 514 | + for i in 0..<self.networkImageArr.count { | ||
| 515 | + var model = CNLiveSelectUploadImageModel() | ||
| 516 | + model.imageUrl = self.networkImageArr![i] | ||
| 517 | + | ||
| 518 | + var singleImageView = self.createSingleImageView() | ||
| 519 | + if self.networkVideoUrl!.count > 0{ | ||
| 520 | + singleImageView.tag = i + 2+DS_SUIV_ADD_TAG_COUNT | ||
| 521 | + }else{ | ||
| 522 | + singleImageView.tag = i+1+DS_SUIV_ADD_TAG_COUNT | ||
| 523 | + } | ||
| 524 | + singleImageView.setModel(model: model, isHideDeleteBtn: isHideDeleteBtn, isCover: i == 0 ? true : false) | ||
| 525 | + self.addSubview(singleImageView) | ||
| 526 | + } | ||
| 527 | + } | ||
| 528 | + | ||
| 529 | + } | ||
| 530 | + | ||
| 531 | + /// 创建单个视图 | ||
| 532 | + func createSingleImageView()->CNLiveSelUplSingleImageView{ | ||
| 533 | + var singleImageView = CNLiveSelUplSingleImageView() | ||
| 534 | + singleImageView.deleteImage = self.deleteImage | ||
| 535 | + singleImageView.isDisplySelectCover = self.isDisplySelectCover | ||
| 536 | + singleImageView.displayType = self.displayType | ||
| 537 | + singleImageView.clickCallBack = {model in | ||
| 538 | + self.selectImageModel(model: model) | ||
| 539 | + } | ||
| 540 | + singleImageView.clickDeleteCallBack = {model in | ||
| 541 | + self.delteImageModel(model: model) | ||
| 542 | + } | ||
| 543 | + singleImageView.clickSettingCoverCallBack = {model in | ||
| 544 | + self.clickCallBack!() | ||
| 545 | + UIApplication.shared.keyWindow?.endEditing(true) | ||
| 546 | + | ||
| 547 | + if let index = self.uploadImageUrls.firstIndex(of: model){ | ||
| 548 | + self.uploadImageUrls.remove(at: index) | ||
| 549 | + self.uploadImageUrls.insert(model, at: 0) | ||
| 550 | + }else{ | ||
| 551 | + return | ||
| 552 | + } | ||
| 553 | + self.resetUI() | ||
| 554 | + } | ||
| 555 | + return singleImageView | ||
| 556 | + } | ||
| 557 | + | ||
| 558 | + // MARK: - 选取图片/视频 | ||
| 559 | + func selectImageModel(model:CNLiveSelectUploadImageModel){ | ||
| 560 | + self.clickCallBack!() | ||
| 561 | + UIApplication.shared.keyWindow?.endEditing(true) | ||
| 562 | + if model.isVideo! == true{ | ||
| 563 | + if model.localVideoUrl != nil{ | ||
| 564 | + if ([[DSToolsModuleManager sharedManager].delegate respondsToSelector:@selector(skipPlayerVCWithPlayURL:coverImage:coverImageUrl:)]) { | ||
| 565 | + [[DSToolsModuleManager sharedManager].delegate skipPlayerVCWithPlayURL:model.localVideoUrl coverImage:model.image coverImageUrl:nil]; | ||
| 566 | + } | ||
| 567 | + }else if model.videoUrl?.count ?? 0 > 0{ | ||
| 568 | + if ([[DSToolsModuleManager sharedManager].delegate respondsToSelector:@selector(skipPlayerVCWithPlayURL:coverImage:coverImageUrl:)]) { | ||
| 569 | + [[DSToolsModuleManager sharedManager].delegate skipPlayerVCWithPlayURL:[NSURL URLWithString:model.videoUrl] coverImage:nil coverImageUrl:model.imageUrl]; | ||
| 570 | + } | ||
| 571 | + }else{ | ||
| 572 | + //TODO:后面再调整具体的配置 | ||
| 573 | + // 设置与微信主题一致的配置 | ||
| 574 | + let config = PhotoTools.getWXPickerConfig() | ||
| 575 | + config.selectOptions = [.video] | ||
| 576 | + config.previewView.bottomView.editButtonHidden = false | ||
| 577 | + let pickerController = PhotoPickerController(picker: config) | ||
| 578 | + pickerController.pickerDelegate = self | ||
| 579 | + // 是否选中原图 | ||
| 580 | + pickerController.isOriginal = true | ||
| 581 | + pickerController.modalPresentationStyle = .fullScreen | ||
| 582 | + currentViewController()?.present(pickerController, animated: true) | ||
| 583 | + } | ||
| 584 | + }else{ | ||
| 585 | + if model.isSelectPhotoPlaceholder! == true{ | ||
| 586 | + if self.uploadImageUrls.count >= self.maxSelectImageCount{ | ||
| 587 | + let message = String(format: "最多只能选取%ld张图片", self.maxSelectImageCount) | ||
| 588 | + showMessage(message: message) | ||
| 589 | + return | ||
| 590 | + } | ||
| 591 | + let config = PhotoTools.getWXPickerConfig() | ||
| 592 | + config.selectMode = .multiple | ||
| 593 | + config.selectOptions = .photo | ||
| 594 | + config.maximumSelectedPhotoCount = self.maxSelectImageCount-self.uploadImageUrls.count | ||
| 595 | + let pickerController = PhotoPickerController(picker: config) | ||
| 596 | + pickerController.pickerDelegate = self | ||
| 597 | + // 是否选中原图 | ||
| 598 | + pickerController.isOriginal = false | ||
| 599 | + pickerController.modalPresentationStyle = .fullScreen | ||
| 600 | + //TODO 少了一个不允许拍摄视频 allowTakeVideo=false | ||
| 601 | + currentViewController()?.present(pickerController, animated: true) | ||
| 602 | + | ||
| 603 | + }else{ | ||
| 604 | + if model.isUploading! == true || model.imageUrl == nil{ | ||
| 605 | + return | ||
| 606 | + } | ||
| 607 | + let subviews = self.subviews | ||
| 608 | + let currentPage = 0 | ||
| 609 | + var sourceDatas = NSMutableArray() | ||
| 610 | + for i in 0..<self.uploadImageUrls.count { | ||
| 611 | + var cmodel = self.uploadImageUrls[i] | ||
| 612 | + if cmodel.isUploading == nil && cmodel.imageUrl?.count ?? 0 > 0{ | ||
| 613 | + YBIBImageData * data = [YBIBImageData new]; | ||
| 614 | + data.imageURL = [NSURL URLWithString:cmodel.imageUrl]; | ||
| 615 | + for (DSSelUplSingleImageView * singleImageView in subviews) { | ||
| 616 | + if ([singleImageView.model.imageUrl isEqualToString:cmodel.imageUrl]) { | ||
| 617 | + data.projectiveView = singleImageView.displayImageView; | ||
| 618 | + break; | ||
| 619 | + } | ||
| 620 | + } | ||
| 621 | + [sourceDatas addObject:data]; | ||
| 622 | + } | ||
| 623 | + if ([cmodel.imageUrl isEqualToString:model.imageUrl]) { | ||
| 624 | + currentPage = i; | ||
| 625 | + } | ||
| 626 | + } | ||
| 627 | + YBImageBrowser * browser = [YBImageBrowser new]; | ||
| 628 | + browser.dataSourceArray = [sourceDatas copy]; | ||
| 629 | + browser.currentPage = currentPage; | ||
| 630 | + [browser show]; | ||
| 631 | + } | ||
| 632 | + } | ||
| 633 | + } | ||
| 634 | + | ||
| 635 | + // MARK: - 删除图片/视频 | ||
| 636 | + func delteImageModel(model:CNLiveSelectUploadImageModel){ | ||
| 637 | + self.clickCallBack!() | ||
| 638 | + UIApplication.shared.keyWindow?.endEditing(true) | ||
| 639 | + let subviews = self.subviews | ||
| 640 | + for i in 0..<subviews.count { | ||
| 641 | + var singleImageView = self.viewWithTag(i+1+DS_SUIV_ADD_TAG_COUNT) as! CNLiveSelUplSingleImageView | ||
| 642 | + if model.imageUrl == singleImageView.model?.imageUrl{ | ||
| 643 | + if singleImageView.model?.isVideo == true{ | ||
| 644 | + if singleImageView.model?.isUploading == true{ | ||
| 645 | + [[DSQiNiuUploadManager sharedManager] cancelUploadKey:singleImageView.model.uploadKey]; | ||
| 646 | + }else{ | ||
| 647 | + self.replaceVideoUrls.append(singleImageView.model!) | ||
| 648 | + var videoModel = CNLiveSelectUploadImageModel() | ||
| 649 | + videoModel.isVideo = true | ||
| 650 | + self.uploadVideoModel = videoModel | ||
| 651 | + } | ||
| 652 | + }else{ | ||
| 653 | + if singleImageView.model?.isUploading == true{ | ||
| 654 | + [[DSQiNiuUploadManager sharedManager] cancelUploadKey:singleImageView.model.uploadKey]; | ||
| 655 | + }else{ | ||
| 656 | + let index = self.uploadImageUrls.firstIndex(of: singleImageView.model!)! | ||
| 657 | + self.uploadImageUrls.remove(at: index) | ||
| 658 | + self.replaceImageUrls.append(singleImageView.model!) | ||
| 659 | + } | ||
| 660 | + } | ||
| 661 | + break | ||
| 662 | + } | ||
| 663 | + } | ||
| 664 | + self.resetUI() | ||
| 665 | + self.autoAdjustHeight() | ||
| 666 | + self.changeUploadDataCallBack!(self.getCurrentSelectImageUrls(),self.getCurrentSelectVideoUrl()) | ||
| 667 | + } | ||
| 668 | + | ||
| 669 | + // MARK: - PickerControllerDelegate | ||
| 670 | + func pickerController(_ pickerController: HXPHPicker.PhotoPickerController, didFinishSelection result: HXPHPicker.PickerResult) { | ||
| 671 | + let photoAssets = result.photoAssets | ||
| 672 | + for asset in photoAssets{ | ||
| 673 | + if asset.mediaType == .video | ||
| 674 | + { | ||
| 675 | + let videoFileName = "\(asset.phAsset?.localIdentifier ?? "").mp4".replacingOccurrences(of: "-", with: "").replacingOccurrences(of: "/", with: "") | ||
| 676 | + let videoURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(videoFileName) | ||
| 677 | + | ||
| 678 | + let videoData = NSData(contentsOf: videoURL) | ||
| 679 | + self.splitVideoFileUrlFps(splitFileUrl: videoURL, fps: 1) { isSucc,firstImage in | ||
| 680 | + if isSucc{ | ||
| 681 | + self.uploadVideoModel?.videoUrl = nil | ||
| 682 | + self.uploadVideoModel?.image = firstImage.first | ||
| 683 | + self.uploadVideoModel?.localVideoUrl = videoURL | ||
| 684 | + self.uploadVideoModel.isUploading = true | ||
| 685 | + | ||
| 686 | + self.uploadVideoModel?.uploadKey = [[DSQiNiuUploadManager sharedManager] uploadVideoData:videoData uploadProgress:^(NSString * _Nonnull key, CGFloat percent) { | ||
| 687 | + weakSelf.uploadVideoModel.uploadingPercent = percent; | ||
| 688 | + [weakSelf replaceVideoModelInSubviews:self.uploadVideoModel target:firstImage]; | ||
| 689 | + } complete:^(NSString * _Nonnull key, DSQiNiuUploadResult result, NSString * _Nonnull videoUrl, NSString * _Nonnull errorMessage) { | ||
| 690 | + if (errorMessage) { | ||
| 691 | + DS_showMessage(errorMessage); | ||
| 692 | + DSSelectUploadImageModel * videoModel = [[DSSelectUploadImageModel alloc] init]; | ||
| 693 | + videoModel.isVideo = YES; | ||
| 694 | + weakSelf.uploadVideoModel = videoModel; | ||
| 695 | + }else { | ||
| 696 | + self.uploadVideoModel.videoUrl = videoUrl; | ||
| 697 | + self.uploadVideoModel.isUploading = NO; | ||
| 698 | + self.uploadVideoModel.uploadKey = nil; | ||
| 699 | + [weakSelf replaceVideoModelInSubviews:self.uploadVideoModel target:firstImage]; | ||
| 700 | + } | ||
| 701 | + | ||
| 702 | + weakSelf.uploadingCount = weakSelf.uploadingCount - 1; | ||
| 703 | + if (weakSelf.uploadingCount == 0) { | ||
| 704 | + if (weakSelf.endUploadImageCallBack) { | ||
| 705 | + weakSelf.endUploadImageCallBack(); | ||
| 706 | + } | ||
| 707 | + } | ||
| 708 | + if (weakSelf.changeUploadDataCallBack) { | ||
| 709 | + weakSelf.changeUploadDataCallBack([weakSelf getCurrentSelectImageUrls], [weakSelf getCurrentSelectVideoUrl]); | ||
| 710 | + } | ||
| 711 | + }]; | ||
| 712 | + [self resetUI]; | ||
| 713 | + [self autoAdjustHeight]; | ||
| 714 | + | ||
| 715 | + self.uploadingCount = self.uploadingCount + 1; | ||
| 716 | + if (self.uploadingCount == 1) { | ||
| 717 | + if (self.beginUploadImageCallBack) { | ||
| 718 | + self.beginUploadImageCallBack(); | ||
| 719 | + } | ||
| 720 | + } | ||
| 721 | + } | ||
| 722 | + } | ||
| 723 | + } | ||
| 724 | + } | ||
| 725 | + pickerController.dismiss(animated: true) | ||
| 726 | + } | ||
| 727 | + | ||
| 728 | + // MARK: - TZImagePickerControllerDelegate | ||
| 729 | + - (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto | ||
| 730 | + { | ||
| 731 | + [photos enumerateObjectsUsingBlock:^(UIImage * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { | ||
| 732 | + UIImage * image = obj; | ||
| 733 | + | ||
| 734 | + DSSelectUploadImageModel * model = [[DSSelectUploadImageModel alloc] init]; | ||
| 735 | + model.image = image; | ||
| 736 | + model.isUploading = YES; | ||
| 737 | + DS_WEAK_SELF(self); | ||
| 738 | + model.uploadKey = [[DSQiNiuUploadManager sharedManager] uploadImageData:UIImageJPEGRepresentation(image, 0.5) uploadProgress:^(NSString * _Nonnull key, CGFloat percent) { | ||
| 739 | + model.uploadingPercent = percent; | ||
| 740 | + [weakSelf replaceImageModelInDataArr:model target:image]; | ||
| 741 | + } complete:^(NSString * _Nonnull key, DSQiNiuUploadResult result, NSString * _Nonnull imageUrl, NSString * _Nonnull errorMessage) { | ||
| 742 | + if (errorMessage) { | ||
| 743 | + DS_showMessage(errorMessage); | ||
| 744 | + [weakSelf.uploadImageUrls removeObject:model]; | ||
| 745 | + }else { | ||
| 746 | + model.imageUrl = imageUrl; | ||
| 747 | + model.isUploading = NO; | ||
| 748 | + model.uploadKey = nil; | ||
| 749 | + [weakSelf replaceImageModelInDataArr:model target:image]; | ||
| 750 | + } | ||
| 751 | + | ||
| 752 | + weakSelf.uploadingCount = weakSelf.uploadingCount - 1; | ||
| 753 | + if (weakSelf.uploadingCount == 0) { | ||
| 754 | + if (weakSelf.endUploadImageCallBack) { | ||
| 755 | + weakSelf.endUploadImageCallBack(); | ||
| 756 | + } | ||
| 757 | + } | ||
| 758 | + if (weakSelf.changeUploadDataCallBack) { | ||
| 759 | + weakSelf.changeUploadDataCallBack([weakSelf getCurrentSelectImageUrls], [weakSelf getCurrentSelectVideoUrl]); | ||
| 760 | + } | ||
| 761 | + }]; | ||
| 762 | + [self.uploadImageUrls addObject:model]; | ||
| 763 | + [self resetUI]; | ||
| 764 | + [self autoAdjustHeight]; | ||
| 765 | + | ||
| 766 | + self.uploadingCount = self.uploadingCount + 1; | ||
| 767 | + if (self.uploadingCount == 1) { | ||
| 768 | + if (self.beginUploadImageCallBack) { | ||
| 769 | + self.beginUploadImageCallBack(); | ||
| 770 | + } | ||
| 771 | + } | ||
| 772 | + }]; | ||
| 773 | + } | ||
| 774 | + // MARK: - 获取视频的第一帧 | ||
| 775 | + func splitVideoFileUrlFps(splitFileUrl: URL, fps: Float, splitCompleteClosure: @escaping (Bool, [UIImage]) -> Void) { | ||
| 776 | + | ||
| 777 | + var splitImages = [UIImage]() | ||
| 778 | + let optDict = NSDictionary(object: NSNumber(value: false), forKey: AVURLAssetPreferPreciseDurationAndTimingKey as NSCopying) | ||
| 779 | + let urlAsset = AVURLAsset(url: splitFileUrl, options: optDict as? [String: Any]) | ||
| 780 | + | ||
| 781 | + let cmTime = urlAsset.duration | ||
| 782 | + let durationSeconds: Float64 = CMTimeGetSeconds(cmTime) //视频总秒数 | ||
| 783 | + | ||
| 784 | + var times = [NSValue]() | ||
| 785 | + let totalFrames: Float64 = durationSeconds * Float64(fps) //获取视频的总帧数 | ||
| 786 | + var timeFrame: CMTime | ||
| 787 | + | ||
| 788 | + for i in 0...Int(totalFrames) { | ||
| 789 | + timeFrame = CMTimeMake(value: Int64(i), timescale: Int32(fps)) //第i帧, 帧率 | ||
| 790 | + let timeValue = NSValue(time: timeFrame) | ||
| 791 | + | ||
| 792 | + times.append(timeValue) | ||
| 793 | + } | ||
| 794 | + | ||
| 795 | + let imgGenerator = AVAssetImageGenerator(asset: urlAsset) | ||
| 796 | + imgGenerator.requestedTimeToleranceBefore = CMTime.zero //防止时间出现偏差 | ||
| 797 | + imgGenerator.requestedTimeToleranceAfter = CMTime.zero | ||
| 798 | + imgGenerator.appliesPreferredTrackTransform = true //不知道是什么属性,不写true视频帧图方向不对 | ||
| 799 | + | ||
| 800 | + let timesCount = times.count | ||
| 801 | + | ||
| 802 | + //获取每一帧的图片 | ||
| 803 | + imgGenerator.generateCGImagesAsynchronously(forTimes: times) { (requestedTime, image, actualTime, result, error) in | ||
| 804 | + | ||
| 805 | + //times有多少次body就循环多少次。。。 | ||
| 806 | + | ||
| 807 | + var isSuccess = false | ||
| 808 | + switch (result) { | ||
| 809 | + case AVAssetImageGenerator.Result.cancelled: | ||
| 810 | + print("cancelled------") | ||
| 811 | + | ||
| 812 | + case AVAssetImageGenerator.Result.failed: | ||
| 813 | + print("failed++++++") | ||
| 814 | + | ||
| 815 | + case AVAssetImageGenerator.Result.succeeded: | ||
| 816 | + let framImg = UIImage(cgImage: image!) | ||
| 817 | + splitImages.append(framImg) | ||
| 818 | + | ||
| 819 | + if (Int(requestedTime.value) == (timesCount - 1)) { //最后一帧时 回调赋值 | ||
| 820 | + isSuccess = true | ||
| 821 | + splitCompleteClosure(isSuccess, splitImages) | ||
| 822 | + print("completed") | ||
| 823 | + } | ||
| 824 | + } | ||
| 825 | + } | ||
| 826 | + } | ||
| 827 | + | ||
| 828 | + // MARK: - 刷新数组中的图片model | ||
| 829 | + | ||
| 830 | + /** | ||
| 831 | + 刷新数组中的图片model | ||
| 832 | + | ||
| 833 | + @param model model | ||
| 834 | + @param target 目标图片 | ||
| 835 | + */ | ||
| 836 | + func replaceImageModelInDataArr(model:CNLiveSelectUploadImageModel,target:UIImage){ | ||
| 837 | + var muteArr = NSMutableArray(array: self.uploadImageUrls) | ||
| 838 | + for (idx,obj) in muteArr.enumerated() { | ||
| 839 | + let tempObj = obj as! CNLiveSelectUploadImageModel | ||
| 840 | + if tempObj.image == target{ | ||
| 841 | + muteArr.replaceObject(at: idx, with: tempObj) | ||
| 842 | + break | ||
| 843 | + } | ||
| 844 | + } | ||
| 845 | + self.uploadImageUrls = muteArr as! [CNLiveSelectUploadImageModel] | ||
| 846 | + for singleImageView in self.subviews{ | ||
| 847 | + let singleImgView = singleImageView as! CNLiveSelUplSingleImageView | ||
| 848 | + | ||
| 849 | + if singleImgView.model?.image == target{ | ||
| 850 | + singleImgView.setModel(model: model, isHideDeleteBtn: singleImgView.isHideDeleteBtn!, isCover: singleImgView.isCover) | ||
| 851 | + break | ||
| 852 | + } | ||
| 853 | + } | ||
| 854 | + } | ||
| 855 | + | ||
| 856 | + // MARK: - 刷新视图中视频view的model | ||
| 857 | + | ||
| 858 | + /** | ||
| 859 | + 刷新视图中视频view的model | ||
| 860 | + | ||
| 861 | + @param model model | ||
| 862 | + @param target 目标图片 | ||
| 863 | + */ | ||
| 864 | + func replaceVideoModelInSubviews(model:CNLiveSelectUploadImageModel,target:UIImage){ | ||
| 865 | + for singleImageView in self.subviews { | ||
| 866 | + let singleImgView = singleImageView as! CNLiveSelUplSingleImageView | ||
| 867 | + if singleImgView.model?.image == target{ | ||
| 868 | + singleImgView.setModel(model: model, isHideDeleteBtn: singleImgView.isHideDeleteBtn ?? false, isCover: singleImgView.isCover) | ||
| 869 | + break | ||
| 870 | + } | ||
| 871 | + } | ||
| 872 | + } | ||
| 873 | + | ||
| 18 | } | 874 | } |
metaCode/Classes/Main/HomePage/View/GoodsManager/CNLiveSelUplSingleImageView.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveSelUplSingleImageView.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by zx on 2023/11/21. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | +import Kingfisher | ||
| 10 | + | ||
| 11 | + | ||
| 12 | +typealias clickCallBackBlock1 = (_ model:CNLiveSelectUploadImageModel)->Void | ||
| 13 | +typealias clickDeleteCallBackBlock = (_ model:CNLiveSelectUploadImageModel)->Void | ||
| 14 | +typealias clickSettingCoverCallBackBlock = (_ model:CNLiveSelectUploadImageModel)->Void | ||
| 15 | + | ||
| 16 | + | ||
| 17 | +class CNLiveSelUplSingleImageView: UIView { | ||
| 18 | + | ||
| 19 | + // MARK: - UI | ||
| 20 | + /// 当前显示 | ||
| 21 | + var displayImageView : UIImageView? | ||
| 22 | + // MARK: - 赋值 | ||
| 23 | + /// 自定义删除图片 默认DS_SelUplImageView_delete | ||
| 24 | + var _deleteImage : UIImage? | ||
| 25 | + var deleteImage : UIImage?{ | ||
| 26 | + get{ | ||
| 27 | + _deleteImage | ||
| 28 | + } | ||
| 29 | + set{ | ||
| 30 | + _deleteImage = newValue | ||
| 31 | + | ||
| 32 | + if _deleteImage?.isKind(of: UIImage.self) == true { | ||
| 33 | + self.deleteImageView?.image = _deleteImage | ||
| 34 | + }else{ | ||
| 35 | + self.deleteImageView?.image = UIImage(named: "DS_SelUplImageView_delete") | ||
| 36 | + } | ||
| 37 | + self.deleteImageView?.image = UIImage(named: "DS_SelUplImageView_delete") | ||
| 38 | + } | ||
| 39 | + } | ||
| 40 | + /// 是否显示选取封面 | ||
| 41 | + var _isDisplySelectCover : Bool? | ||
| 42 | + var isDisplySelectCover : Bool?{ | ||
| 43 | + get{ | ||
| 44 | + _isDisplySelectCover | ||
| 45 | + } | ||
| 46 | + set{ | ||
| 47 | + _isDisplySelectCover = newValue | ||
| 48 | + if (self.model?.isSelectPhotoPlaceholder == false && self.model?.isVideo == false){ | ||
| 49 | + if _isDisplySelectCover!{ | ||
| 50 | + self.coverBtn?.isHidden = false | ||
| 51 | + }else{ | ||
| 52 | + self.coverBtn?.isHidden = true | ||
| 53 | + } | ||
| 54 | + }else{ | ||
| 55 | + self.coverBtn?.isHidden = true | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + /// 显示类型 | ||
| 61 | + var _displayType : CNLiveSelectUploadImageViewDisplayType? | ||
| 62 | + var displayType : CNLiveSelectUploadImageViewDisplayType?{ | ||
| 63 | + get{ | ||
| 64 | + _displayType | ||
| 65 | + } | ||
| 66 | + set{ | ||
| 67 | + _displayType = newValue | ||
| 68 | + if _displayType == .select{ | ||
| 69 | + self.coverBtn?.isUserInteractionEnabled = true | ||
| 70 | + }else{ | ||
| 71 | + self.coverBtn?.isUserInteractionEnabled = false | ||
| 72 | + } | ||
| 73 | + self.deleteImageView?.image = UIImage(named: "DS_SelUplImageView_delete") | ||
| 74 | + } | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + /// 数据 | ||
| 78 | + var model : CNLiveSelectUploadImageModel? | ||
| 79 | + | ||
| 80 | + /// 是否隐藏删除按钮 | ||
| 81 | + var isHideDeleteBtn : Bool? | ||
| 82 | + /// 是否是封面 | ||
| 83 | + var isCover : Bool | ||
| 84 | + /// 赋值 | ||
| 85 | + /// @param model 数据 | ||
| 86 | + /// @param isHideDeleteBtn 是否隐藏删除按钮 | ||
| 87 | + /// @param isCover 是否是封面 | ||
| 88 | + func setModel(model:CNLiveSelectUploadImageModel,isHideDeleteBtn:Bool,isCover:Bool){ | ||
| 89 | + self.model = model | ||
| 90 | + self.isHideDeleteBtn = isHideDeleteBtn | ||
| 91 | + self.isCover = isCover | ||
| 92 | + if self.model?.isSelectPhotoPlaceholder! == true{ | ||
| 93 | + self.displayImageView?.image = UIImage(named: "DS_SelUplImageView_selectImage") | ||
| 94 | + self.progressLab?.isHidden = true | ||
| 95 | + self.deleteBtn?.isHidden = true | ||
| 96 | + self.playImageView?.isHidden = true | ||
| 97 | + self.coverBtn?.isHidden = true | ||
| 98 | + }else if self.model?.isVideo! == true{ | ||
| 99 | + if self.model?.videoUrl?.count ?? 0 > 0{ | ||
| 100 | + self.displayImageView?.image = self.model?.image | ||
| 101 | + if self.model?.image == nil{ | ||
| 102 | + self.displayImageView?.kf.setImage(with: URL(string: self.model?.imageUrl ?? ""), placeholder: self.model?.image) | ||
| 103 | + } | ||
| 104 | + self.progressLab?.isHidden = true | ||
| 105 | + if self.isHideDeleteBtn! == true{ | ||
| 106 | + self.deleteBtn?.isHidden = true | ||
| 107 | + }else{ | ||
| 108 | + self.deleteBtn?.isHidden = false | ||
| 109 | + } | ||
| 110 | + self.playImageView?.isHidden = false | ||
| 111 | + }else if self.model?.isUploading! == true{ | ||
| 112 | + self.displayImageView?.image = self.model?.image | ||
| 113 | + self.progressLab?.text = String(format: "%.0f%%", (self.model?.uploadingPercent)!*100) | ||
| 114 | + self.progressLab?.isHidden = false | ||
| 115 | + self.deleteBtn?.isHidden = false | ||
| 116 | + self.playImageView?.isHidden = true | ||
| 117 | + }else{ | ||
| 118 | + self.displayImageView?.image = UIImage(named: "DS_SelUplImageView_selectVideo") | ||
| 119 | + self.progressLab?.isHidden = true | ||
| 120 | + self.deleteBtn?.isHidden = true | ||
| 121 | + self.playImageView?.isHidden = true | ||
| 122 | + | ||
| 123 | + } | ||
| 124 | + self.coverBtn?.isHidden = true | ||
| 125 | + }else{ | ||
| 126 | + self.displayImageView?.image = self.model?.image | ||
| 127 | + if self.model?.imageUrl?.count ?? 0 > 0 { | ||
| 128 | + self.displayImageView?.kf.setImage(with: URL(string: self.model?.imageUrl ?? ""), placeholder: self.model?.image) | ||
| 129 | + self.progressLab?.isHidden = true | ||
| 130 | + if self.isHideDeleteBtn! == true{ | ||
| 131 | + self.deleteBtn?.isHidden = true | ||
| 132 | + }else{ | ||
| 133 | + self.deleteBtn?.isHidden = false | ||
| 134 | + } | ||
| 135 | + }else if self.model?.isUploading! == true{ | ||
| 136 | + self.progressLab?.text = String(format: "%.0f%%", (self.model?.uploadingPercent)!*100) | ||
| 137 | + self.progressLab?.isHidden = false | ||
| 138 | + self.deleteBtn?.isHidden = false | ||
| 139 | + } | ||
| 140 | + self.playImageView?.isHidden = true | ||
| 141 | + self.coverBtn?.isHidden = self.isDisplySelectCover! == true ? false : true | ||
| 142 | + if self.isCover == true{ | ||
| 143 | + self.coverBtn?.setTitle("主页", for: .normal) | ||
| 144 | + self.coverBtn?.setTitleColor(HexColor("#F5A623"), for: .normal) | ||
| 145 | + self.coverBtn?.backgroundColor = HexColor("#FEF4E4") | ||
| 146 | + }else{ | ||
| 147 | + if self.displayType == .select{ | ||
| 148 | + self.coverBtn?.setTitle("设置主页", for: .normal) | ||
| 149 | + self.coverBtn?.setTitleColor(HexColor("#787878"), for: .normal) | ||
| 150 | + self.coverBtn?.backgroundColor = HexColor("#EAEAEA") | ||
| 151 | + }else{ | ||
| 152 | + self.coverBtn?.setTitle("", for: .normal) | ||
| 153 | + self.coverBtn?.setTitleColor(.clear, for: .normal) | ||
| 154 | + self.coverBtn?.backgroundColor = .clear | ||
| 155 | + } | ||
| 156 | + } | ||
| 157 | + } | ||
| 158 | + self.deleteImageView?.image = UIImage(named: "DS_SelUplImageView_delete") | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + // MARK: - 回调 | ||
| 162 | + /// 点击自身回调 | ||
| 163 | + var clickCallBack:clickCallBackBlock1? | ||
| 164 | + /// 点击删除回调 | ||
| 165 | + var clickDeleteCallBack:clickDeleteCallBackBlock? | ||
| 166 | + /// 点击设为主页回调 | ||
| 167 | + var clickSettingCoverCallBack:clickSettingCoverCallBackBlock? | ||
| 168 | + var progressLab : UILabel? | ||
| 169 | + var deleteBtn : UIButton? | ||
| 170 | + var deleteImageView : UIImageView? | ||
| 171 | + var playImageView : UIImageView? | ||
| 172 | + var coverBtn : UIButton? | ||
| 173 | + | ||
| 174 | + // MARK: - init | ||
| 175 | + override init(frame: CGRect) { | ||
| 176 | + super.init(frame: frame) | ||
| 177 | + self.initUI() | ||
| 178 | + let selfTap = UITapGestureRecognizer(target: self, action: #selector(selfTap)) | ||
| 179 | + self.addGestureRecognizer(selfTap) | ||
| 180 | + } | ||
| 181 | + | ||
| 182 | + required init?(coder: NSCoder) { | ||
| 183 | + fatalError("init(coder:) has not been implemented") | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + override func layoutSubviews() { | ||
| 187 | + super.layoutSubviews() | ||
| 188 | + self.deleteBtn?.frame = CGRect(x: self.width-25, y: 0, width: 25, height: 30) | ||
| 189 | + self.deleteImageView?.frame = CGRect(x: self.deleteBtn!.width-17, y: 0, width: 17, height: 17) | ||
| 190 | + self.displayImageView?.frame = CGRect(x: 0, y: self.deleteImageView!.height/2, width: self.width-self.deleteImageView!.width/2, height: self.width-self.deleteImageView!.height/2) | ||
| 191 | + self.progressLab?.frame = self.displayImageView!.frame | ||
| 192 | + self.playImageView?.frame = CGRect(x: self.displayImageView!.width-26/2, y: self.displayImageView!.top+self.displayImageView!.height-26/2, width: 26, height: 26) | ||
| 193 | + self.coverBtn?.frame = CGRect(x: self.displayImageView!.left, y: self.displayImageView!.bottom, width: self.displayImageView!.width, height: 20) | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + // MARK: - initUI | ||
| 197 | + func initUI(){ | ||
| 198 | + self.displayImageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 78, height: 78)) | ||
| 199 | + self.displayImageView?.clipsToBounds = true | ||
| 200 | + self.displayImageView?.contentMode = .scaleAspectFill | ||
| 201 | + self.addSubview(self.displayImageView!) | ||
| 202 | + | ||
| 203 | + self.progressLab = UILabel() | ||
| 204 | + self.progressLab?.textColor = HexColor("#ffffff") | ||
| 205 | + self.progressLab?.font = Font_12 | ||
| 206 | + self.progressLab?.backgroundColor = HexColor("#000000", alpha: 0.6) | ||
| 207 | + self.progressLab?.textAlignment = .center | ||
| 208 | + self.addSubview(self.progressLab!) | ||
| 209 | + | ||
| 210 | + self.deleteBtn = UIButton(type: .custom) | ||
| 211 | + self.deleteBtn?.addTarget(self, action: #selector(deleteBtnClick), for: .touchUpInside) | ||
| 212 | + self.addSubview(self.deleteBtn!) | ||
| 213 | + | ||
| 214 | + self.deleteImageView = UIImageView() | ||
| 215 | + self.deleteImageView?.clipsToBounds = true | ||
| 216 | + self.deleteImageView?.contentMode = .scaleAspectFit | ||
| 217 | + self.deleteImageView?.image = UIImage(named: "DS_SelUplImageView_delete") | ||
| 218 | + self.deleteBtn?.addSubview(self.deleteImageView!) | ||
| 219 | + | ||
| 220 | + self.playImageView = UIImageView() | ||
| 221 | + self.playImageView?.clipsToBounds = true | ||
| 222 | + self.playImageView?.contentMode = .scaleAspectFit | ||
| 223 | + self.playImageView?.image = UIImage(named: "DS_SelUplImageView_play") | ||
| 224 | + self.addSubview(self.playImageView!) | ||
| 225 | + | ||
| 226 | + self.coverBtn = UIButton(type: .custom) | ||
| 227 | + self.coverBtn?.addTarget(self, action: #selector(coverBtnClick), for: .touchUpInside) | ||
| 228 | + self.coverBtn?.titleLabel?.font = Font_11 | ||
| 229 | + self.coverBtn?.isUserInteractionEnabled = false | ||
| 230 | + self.addSubview(self.coverBtn!) | ||
| 231 | + } | ||
| 232 | + | ||
| 233 | + // MARK: - 触发事件 | ||
| 234 | + @objc func selfTap(){ | ||
| 235 | + self.clickCallBack!(self.model) | ||
| 236 | + } | ||
| 237 | + @objc func deleteBtnClick(){ | ||
| 238 | + self.clickDeleteCallBack!(self.model!) | ||
| 239 | + } | ||
| 240 | + @objc func coverBtnClick(){ | ||
| 241 | + self.clickSettingCoverCallBack!(self.model!) | ||
| 242 | + } | ||
| 243 | +} |
metaCode/Classes/Main/HomePage/View/GoodsManager/CNLiveShopAddGoodsSingleView.swift
| @@ -7,13 +7,21 @@ | @@ -7,13 +7,21 @@ | ||
| 7 | 7 | ||
| 8 | import Foundation | 8 | import Foundation |
| 9 | 9 | ||
| 10 | -///回调 | 10 | +//商品标题最大长度 |
| 11 | +let TitleMaxLength = 50 | ||
| 12 | +/// 修改自身高度回调 | ||
| 11 | typealias updateBlock = ()->Void | 13 | typealias updateBlock = ()->Void |
| 14 | + | ||
| 15 | +///修改添加通用参数回调 | ||
| 16 | +typealias changeFrameParamCallBack = (_ isDelect:Bool,_ model:CNLiveShopAddEditGoodsListModel,_ singleView:CNLiveShopAddGoodsSingleView)->Void | ||
| 17 | + | ||
| 12 | typealias tapClickBlock = (_ singleView:CNLiveShopAddGoodsSingleView)->Void | 18 | typealias tapClickBlock = (_ singleView:CNLiveShopAddGoodsSingleView)->Void |
| 13 | 19 | ||
| 14 | -class CNLiveShopAddGoodsSingleView: UIView, UITextFieldDelegate { | ||
| 15 | - /// | 20 | +class CNLiveShopAddGoodsSingleView: UIView, UITextFieldDelegate, UITextViewDelegate { |
| 21 | + | ||
| 16 | var updateFrameBlock:updateBlock? | 22 | var updateFrameBlock:updateBlock? |
| 23 | + /// | ||
| 24 | + var changeFrameBlock:changeFrameParamCallBack? | ||
| 17 | // | 25 | // |
| 18 | var tapBlock:tapClickBlock? | 26 | var tapBlock:tapClickBlock? |
| 19 | //model | 27 | //model |
| @@ -31,11 +39,6 @@ class CNLiveShopAddGoodsSingleView: UIView, UITextFieldDelegate { | @@ -31,11 +39,6 @@ class CNLiveShopAddGoodsSingleView: UIView, UITextFieldDelegate { | ||
| 31 | ///标题 | 39 | ///标题 |
| 32 | lazy var titleLabel: UILabel = { | 40 | lazy var titleLabel: UILabel = { |
| 33 | let titleLabel = UILabel.init(frame: CGRectMake(15 , 15, 145, 20)) | 41 | let titleLabel = UILabel.init(frame: CGRectMake(15 , 15, 145, 20)) |
| 34 | -// titleLabel.textColor = HexColor("#333333") | ||
| 35 | -// titleLabel.textAlignment = .left | ||
| 36 | -// titleLabel.font = Font_15 | ||
| 37 | -// titleLabel.adjustsFontSizeToFitWidth=true | ||
| 38 | -// titleLabel.text = "啊啊啊啊啊" | ||
| 39 | return titleLabel | 42 | return titleLabel |
| 40 | }() | 43 | }() |
| 41 | //副标题 | 44 | //副标题 |
| @@ -45,24 +48,28 @@ class CNLiveShopAddGoodsSingleView: UIView, UITextFieldDelegate { | @@ -45,24 +48,28 @@ class CNLiveShopAddGoodsSingleView: UIView, UITextFieldDelegate { | ||
| 45 | var rightImageView = UIImageView() | 48 | var rightImageView = UIImageView() |
| 46 | var contentSwitch = UISwitch() | 49 | var contentSwitch = UISwitch() |
| 47 | var uploadImageView = CNLiveAddGoodsSelectUploadImageView(frame: CGRectZero) | 50 | var uploadImageView = CNLiveAddGoodsSelectUploadImageView(frame: CGRectZero) |
| 48 | - var contentTextBgView = UIView() | ||
| 49 | - var contentTextView = UITextView()// | 51 | + var contentTextBgView = CNLiveRoundedRectView() |
| 52 | + var contentTextView = CNLiveShopTextView() | ||
| 50 | var addBtn = UIButton() | 53 | var addBtn = UIButton() |
| 51 | var subtractBtn = UIButton() | 54 | var subtractBtn = UIButton() |
| 52 | var countTF = UITextField() | 55 | var countTF = UITextField() |
| 53 | var descLab = UILabel() | 56 | var descLab = UILabel() |
| 54 | var line = UIImageView() | 57 | var line = UIImageView() |
| 55 | var starImageView = UIImageView() | 58 | var starImageView = UIImageView() |
| 56 | - | ||
| 57 | - | 59 | + //开始输入前的文本 |
| 60 | + var beginText:String | ||
| 58 | 61 | ||
| 59 | override init(frame: CGRect) { | 62 | override init(frame: CGRect) { |
| 60 | super.init(frame: frame) | 63 | super.init(frame: frame) |
| 61 | - self.setUI() | 64 | + |
| 65 | + NotificationCenter.default.addObserver(self, selector: #selector(textFieldTextDidChangeNotification), name: Notification.Name("UITextFieldTextDidChangeNotification"), object:nil) | ||
| 66 | + self.addObserver(self, forKeyPath: "tag",options: [.new,.old],context: nil) | ||
| 67 | + | ||
| 62 | } | 68 | } |
| 63 | 69 | ||
| 64 | - func setUI(){ | ||
| 65 | - | 70 | + deinit { |
| 71 | + NotificationCenter.default.removeObserver(self, name: Notification.Name("UITextFieldTextDidChangeNotification"), object: nil) | ||
| 72 | + self.removeObserver(self, forKeyPath: "tag") | ||
| 66 | } | 73 | } |
| 67 | 74 | ||
| 68 | func setupNewUI(model:CNLiveShopAddEditGoodsListModel){ | 75 | func setupNewUI(model:CNLiveShopAddEditGoodsListModel){ |
| @@ -86,7 +93,7 @@ class CNLiveShopAddGoodsSingleView: UIView, UITextFieldDelegate { | @@ -86,7 +93,7 @@ class CNLiveShopAddGoodsSingleView: UIView, UITextFieldDelegate { | ||
| 86 | subBtn.setTitleColor(HexColor("#0091FF"), for: .normal) | 93 | subBtn.setTitleColor(HexColor("#0091FF"), for: .normal) |
| 87 | subBtn.titleLabel?.font = Font_14 | 94 | subBtn.titleLabel?.font = Font_14 |
| 88 | subBtn.titleLabel?.textAlignment = .right | 95 | subBtn.titleLabel?.textAlignment = .right |
| 89 | - subBtn.addTarget(self, action: #selector(subBtnAction), for: .touchUpInside) | 96 | + subBtn.addTarget(self, action: #selector(selectAddParamAction), for: .touchUpInside) |
| 90 | self.subButton = subBtn | 97 | self.subButton = subBtn |
| 91 | self.addSubview(self.subButton) | 98 | self.addSubview(self.subButton) |
| 92 | } | 99 | } |
| @@ -160,35 +167,33 @@ class CNLiveShopAddGoodsSingleView: UIView, UITextFieldDelegate { | @@ -160,35 +167,33 @@ class CNLiveShopAddGoodsSingleView: UIView, UITextFieldDelegate { | ||
| 160 | self.height = 50 | 167 | self.height = 50 |
| 161 | }else if (model.style == "3") { | 168 | }else if (model.style == "3") { |
| 162 | self.uploadImageView = CNLiveAddGoodsSelectUploadImageView(frame: CGRectZero) | 169 | self.uploadImageView = CNLiveAddGoodsSelectUploadImageView(frame: CGRectZero) |
| 163 | -// self.uploadImageView.column = 3 | ||
| 164 | -// self.uploadImageView.maxSelectImageCount = model.maxSelectImageCount | ||
| 165 | -// self.uploadImageView.isAbleSelectVideo = model.isAbleSelectVideo | ||
| 166 | -// self.uploadImageView.isDisplySelectCover = model.isAbleSelectCover | ||
| 167 | -// if model.id?.isEmpty { | ||
| 168 | -// self.uploadImageView.deleteImage = UIImage(named: "DS_shop_manageGoodsDetails_delete") | ||
| 169 | -// } | ||
| 170 | -// [self.uploadImageView setChangeFrameCallBack:^{ | ||
| 171 | -// weakSelf.height = CGRectGetMaxY(weakSelf.uploadImageView.frame) + DS_adapt_length(15); | ||
| 172 | -// if (weakSelf.changeFrameCallBack) { | ||
| 173 | -// weakSelf.changeFrameCallBack(); | ||
| 174 | -// } | ||
| 175 | -// }]; | 170 | + self.uploadImageView.column = 3 |
| 171 | + self.uploadImageView.maxSelectImageCount = (model.maxSelectImageCount! as NSString).integerValue | ||
| 172 | + self.uploadImageView.isAbleSelectVideo = model.isAbleSelectVideo | ||
| 173 | + self.uploadImageView.isDisplySelectCover = model.isAbleSelectCover | ||
| 174 | + if model.id?.isEmpty == true { | ||
| 175 | + self.uploadImageView.deleteImage = UIImage(named: "DS_shop_manageGoodsDetails_delete") | ||
| 176 | + } | ||
| 177 | + self.uploadImageView.changeFrameCallBack = {[weak self] in | ||
| 178 | + self?.height = (self?.uploadImageView.bottom)! + 15 | ||
| 179 | + self?.updateFrameBlock!() | ||
| 180 | + } | ||
| 176 | self.addSubview(self.uploadImageView) | 181 | self.addSubview(self.uploadImageView) |
| 177 | }else if (model.style == "4") { | 182 | }else if (model.style == "4") { |
| 178 | - self.contentTextBgView = UIView() | ||
| 179 | -// self.contentTextBgView.fillColor = HexColor("F9F9F9") | ||
| 180 | -// self.contentTextBgView.radius = 8 | 183 | + self.contentTextBgView = CNLiveRoundedRectView() |
| 184 | + self.contentTextBgView.fillColor = HexColor("F9F9F9") | ||
| 185 | + self.contentTextBgView.radius = 8 | ||
| 181 | self.addSubview(self.contentTextBgView) | 186 | self.addSubview(self.contentTextBgView) |
| 182 | 187 | ||
| 183 | -// self.contentTextView = UITextView() | ||
| 184 | -// self.contentTextView.placeholder = model.placeholder | ||
| 185 | -// self.contentTextView.placeholderColor = HexColor("c6c6c6") | ||
| 186 | -// self.contentTextView.font = Font_14 | ||
| 187 | -// self.contentTextView.textColor = HexColor("787878") | ||
| 188 | -// self.contentTextView.delegate = self | ||
| 189 | -// if (model.content?.count ?? 0 > 0){ self.contentTextView.text = model.content | ||
| 190 | -// } | ||
| 191 | -// self.contentTextBgView.addSubview(self.contentTextView) | 188 | + self.contentTextView = CNLiveShopTextView() |
| 189 | + self.contentTextView.placeHolder = model.placeholder ?? "" | ||
| 190 | + self.contentTextView.placeHolderColor = HexColor("c6c6c6") ?? .gray | ||
| 191 | + self.contentTextView.font = Font_14 | ||
| 192 | + self.contentTextView.textColor = HexColor("787878") | ||
| 193 | + self.contentTextView.delegate = self | ||
| 194 | + if (model.content?.count ?? 0 > 0){ self.contentTextView.text = model.content | ||
| 195 | + } | ||
| 196 | + self.contentTextBgView.addSubview(self.contentTextView) | ||
| 192 | self.height = 120 | 197 | self.height = 120 |
| 193 | }else if (model.style == "5") { | 198 | }else if (model.style == "5") { |
| 194 | //添加输入框 | 199 | //添加输入框 |
| @@ -288,10 +293,20 @@ class CNLiveShopAddGoodsSingleView: UIView, UITextFieldDelegate { | @@ -288,10 +293,20 @@ class CNLiveShopAddGoodsSingleView: UIView, UITextFieldDelegate { | ||
| 288 | fatalError("init(coder:) has not been implemented") | 293 | fatalError("init(coder:) has not been implemented") |
| 289 | } | 294 | } |
| 290 | 295 | ||
| 296 | + // MARK: - KVO | ||
| 297 | + override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { | ||
| 298 | + let newTagValue = change?[NSKeyValueChangeKey.newKey] as! Int | ||
| 299 | + if newTagValue == 5 { | ||
| 300 | + self.contentTextField.placeholder = "请输入(最多输入50个字)" | ||
| 301 | + }else if newTagValue == 6{ | ||
| 302 | + self.contentTextView.placeHolder = "请在此输入...(备注:最多输入30个字)" | ||
| 303 | + } | ||
| 304 | + } | ||
| 305 | + | ||
| 291 | // MARK: - BtnAction | 306 | // MARK: - BtnAction |
| 292 | - @objc func subBtnAction(){ | ||
| 293 | - if ((self.updateFrameBlock) != nil) { | ||
| 294 | - self.updateFrameBlock!() | 307 | + @objc func selectAddParamAction(){ |
| 308 | + if ((self.changeFrameBlock) != nil) { | ||
| 309 | + self.changeFrameBlock!(false, self.addEditGoodsListModel!, self) | ||
| 295 | } | 310 | } |
| 296 | } | 311 | } |
| 297 | @objc func selectDelectParamAction(){ | 312 | @objc func selectDelectParamAction(){ |
| @@ -313,12 +328,30 @@ class CNLiveShopAddGoodsSingleView: UIView, UITextFieldDelegate { | @@ -313,12 +328,30 @@ class CNLiveShopAddGoodsSingleView: UIView, UITextFieldDelegate { | ||
| 313 | 328 | ||
| 314 | } | 329 | } |
| 315 | @objc func addBtnClick(){ | 330 | @objc func addBtnClick(){ |
| 316 | - | 331 | + if (self.countTF.text?.count ?? 0 > 0 && self.countTF.text?.isPurnInt() == true){ |
| 332 | + var count = Int(self.countTF.text!)! | ||
| 333 | + count = count + 1 | ||
| 334 | + self.countTF.text = "\(count)" | ||
| 335 | + self.subtractBtn.setImage(UIImage(named: "DS_main_unadd_count"), for: .normal) | ||
| 336 | + } | ||
| 317 | } | 337 | } |
| 338 | + | ||
| 318 | @objc func subtractBtnClick(){ | 339 | @objc func subtractBtnClick(){ |
| 319 | - | 340 | + if (self.countTF.text?.count ?? 0 > 0 && self.countTF.text?.isPurnInt() == true){ |
| 341 | + var count = Int(self.countTF.text!)! | ||
| 342 | + if (count <= 2){ | ||
| 343 | + self.countTF.text = "1" | ||
| 344 | + subtractBtn.setImage(UIImage(named: "DS_main_unadd_count_n"), for: .normal) | ||
| 345 | + }else{ | ||
| 346 | + count = count - 1 | ||
| 347 | + self.countTF.text = "\(count)" | ||
| 348 | + subtractBtn.setImage(UIImage(named: "DS_main_unadd_count"), for: .normal) | ||
| 349 | + } | ||
| 350 | + } | ||
| 320 | } | 351 | } |
| 321 | 352 | ||
| 353 | + // MARK: - UITextFieldDelegate | ||
| 354 | + | ||
| 322 | @objc func textDidChange(sender:UITextField) { | 355 | @objc func textDidChange(sender:UITextField) { |
| 323 | if (sender == self.countTF) { | 356 | if (sender == self.countTF) { |
| 324 | if (self.countTF.text?.count ?? 0 > 0 && (self.countTF.text?.isPurnInt() == false)) { | 357 | if (self.countTF.text?.count ?? 0 > 0 && (self.countTF.text?.isPurnInt() == false)) { |
| @@ -331,5 +364,165 @@ class CNLiveShopAddGoodsSingleView: UIView, UITextFieldDelegate { | @@ -331,5 +364,165 @@ class CNLiveShopAddGoodsSingleView: UIView, UITextFieldDelegate { | ||
| 331 | } | 364 | } |
| 332 | } | 365 | } |
| 333 | } | 366 | } |
| 367 | + func textViewDidEndEditing(_ textView: UITextView) { | ||
| 368 | + if self.stringContainsEmoji(string: textView.text){ | ||
| 369 | + showMessage(message: "输入内容不能包含表情") | ||
| 370 | + }else{ | ||
| 371 | + if textView.text.count > 0{ | ||
| 372 | + self.addEditGoodsListModel?.content = textView.text | ||
| 373 | + } | ||
| 374 | + } | ||
| 375 | + } | ||
| 376 | + | ||
| 377 | + // MARK: - UITextFieldDelegate | ||
| 378 | + func textFieldDidBeginEditing(_ textField: UITextField) { | ||
| 379 | + if self.addEditGoodsListModel?.style == "1"{ | ||
| 380 | + if self.contentTextField == textField && self.addEditGoodsListModel?.contentTextFieldkeyboardType == "2"{ | ||
| 381 | + self.beginText = textField.text ?? "" | ||
| 382 | + } | ||
| 383 | + } | ||
| 384 | + } | ||
| 385 | + func textFieldShouldEndEditing(_ textField: UITextField) -> Bool { | ||
| 386 | + if textField.text?.count ?? 0 > 0{ | ||
| 387 | + self.addEditGoodsListModel?.content = textField.text | ||
| 388 | + } | ||
| 389 | + if self.stringContainsEmoji(string: textField.text ?? ""){ | ||
| 390 | + showMessage(message: "输入内容不能包含表情") | ||
| 391 | + } | ||
| 392 | + if textField == self.countTF && (self.countTF.text?.count == 0 || Int(self.countTF.text ?? "0") ?? 0 <= 0){ | ||
| 393 | + showMessage(message: "最低起售不能为空") | ||
| 394 | + self.subtractBtn.setImage(UIImage(named: "DS_main_unadd_count_n"), for: .normal) | ||
| 395 | + return false | ||
| 396 | + } | ||
| 397 | + if textField == self.countTF{ | ||
| 398 | + if (self.countTF.text?.count ?? 0 > 0 && self.countTF.text?.isPurnInt() == true){ | ||
| 399 | + let count = Int(self.countTF.text ?? "0")! | ||
| 400 | + if count > 255{ | ||
| 401 | + showMessage(message: "最大起售数不能超过255") | ||
| 402 | + return false | ||
| 403 | + } | ||
| 404 | + } | ||
| 405 | + } | ||
| 406 | + return true | ||
| 407 | + } | ||
| 408 | + | ||
| 409 | + func textFieldShouldReturn(_ textField: UITextField) -> Bool { | ||
| 410 | + if textField == self.countTF{ | ||
| 411 | + if (self.countTF.text?.count ?? 0 > 0 && self.countTF.text?.isPurnInt() == true){ | ||
| 412 | + let count = Int(self.countTF.text ?? "0")! | ||
| 413 | + if count > 255{ | ||
| 414 | + showMessage(message: "最大起售数不能超过255") | ||
| 415 | + return false | ||
| 416 | + } | ||
| 417 | + } | ||
| 418 | + } | ||
| 419 | + keyWindow?.endEditing(true) | ||
| 420 | + return true | ||
| 421 | + } | ||
| 422 | + | ||
| 423 | + func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { | ||
| 424 | + if string.isEmpty{ | ||
| 425 | + //点击的删除键 | ||
| 426 | + return true | ||
| 427 | + } | ||
| 428 | + if (self.tag == 5 && textField.text?.count ?? 0 >= TitleMaxLength || (textField.text?.count ?? 0) + string.count > TitleMaxLength){ | ||
| 429 | + return false | ||
| 430 | + } | ||
| 431 | + if self.addEditGoodsListModel?.style == "1"{ | ||
| 432 | + if self.contentTextField == textField && self.addEditGoodsListModel?.contentTextFieldkeyboardType == "2"{ | ||
| 433 | + return self.allowWriteString(string: "0123456789.") | ||
| 434 | + } | ||
| 435 | + } | ||
| 436 | + if self.stringContainsEmoji(string: textField.text ?? ""){ | ||
| 437 | + showMessage(message: "输入内容不能包含表情") | ||
| 438 | + return false | ||
| 439 | + } | ||
| 440 | + return true | ||
| 441 | + } | ||
| 442 | + | ||
| 443 | + @objc func textFieldTextDidChangeNotification(notification:Notification){ | ||
| 444 | + let textField = notification.object as! UITextField | ||
| 445 | + if self.addEditGoodsListModel?.style == "1"{ | ||
| 446 | + if (self.contentTextField == textField && self.addEditGoodsListModel?.contentTextFieldkeyboardType == "2"){ | ||
| 447 | + let oldStr = self.beginText | ||
| 448 | + var newStr = textField.text | ||
| 449 | + | ||
| 450 | + if newStr?.count ?? 0 > 0{ | ||
| 451 | + let newFirstStr = newStr?.subString(start: 0, length:1) | ||
| 452 | + if newFirstStr == "."{ | ||
| 453 | + newStr = "0%\(newFirstStr ?? ".")" | ||
| 454 | + textField.text = newStr | ||
| 455 | + return | ||
| 456 | + } | ||
| 457 | + } | ||
| 458 | + var isFindDecimalPoint = false | ||
| 459 | + var behindDecimalPointLength = 0 | ||
| 460 | + if newStr?.count ?? 0 > oldStr.count{ | ||
| 461 | + for i in 0..<(newStr?.count ?? 0) { | ||
| 462 | + let newNextStr = newStr?.subString(start: i, length: 1) | ||
| 463 | + if (!isFindDecimalPoint && newNextStr == "."){ | ||
| 464 | + isFindDecimalPoint = true | ||
| 465 | + }else if isFindDecimalPoint{ | ||
| 466 | + if (behindDecimalPointLength >= Int((self.addEditGoodsListModel?.decimalLength!)!)! || newNextStr == "."){ | ||
| 467 | + textField.text = newStr?.subString(start: 0, length: i+1) | ||
| 468 | + return | ||
| 469 | + } | ||
| 470 | + behindDecimalPointLength += 1 | ||
| 471 | + } | ||
| 472 | + } | ||
| 473 | + } | ||
| 474 | + } | ||
| 475 | + } | ||
| 476 | + } | ||
| 477 | + // MARK: - UITextViewDelegate | ||
| 478 | + func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { | ||
| 479 | + if text.isEmpty{ | ||
| 480 | + //点击的删除键 | ||
| 481 | + return true | ||
| 482 | + } | ||
| 483 | + if self.stringContainsEmoji(string: textView.text){ | ||
| 484 | + showMessage(message: "输入内容不能包含表情") | ||
| 485 | + return false | ||
| 486 | + } | ||
| 487 | + return true | ||
| 488 | + | ||
| 489 | + } | ||
| 490 | + | ||
| 491 | + // MARK: - 是否包含表情 | ||
| 492 | + func stringContainsEmoji(string:String) -> Bool { | ||
| 493 | + for scalar in string.unicodeScalars { | ||
| 494 | + switch scalar.value { | ||
| 495 | + case 0x1F600...0x1F64F, // Emoticons | ||
| 496 | + 0x1F300...0x1F5FF, // Misc Symbols and Pictographs | ||
| 497 | + 0x1F680...0x1F6FF, // Transport and Map | ||
| 498 | + 0x1F1E6...0x1F1FF, // Regional country flags | ||
| 499 | + 0x2600...0x26FF, // Misc symbols | ||
| 500 | + 0x2700...0x27BF, // Dingbats | ||
| 501 | + 0xFE00...0xFE0F, // Variation Selectors | ||
| 502 | + 0x1F900...0x1F9FF, // Supplemental Symbols and Pictographs | ||
| 503 | + 127000...127600, // Various asian characters | ||
| 504 | + 65024...65039, // Variation selector | ||
| 505 | + 9100...9300, // Misc items | ||
| 506 | + 8400...8447: // Combining Diacritical Marks for Symbols | ||
| 507 | + return true | ||
| 508 | + default: | ||
| 509 | + continue | ||
| 510 | + } | ||
| 511 | + } | ||
| 512 | + return false | ||
| 513 | + } | ||
| 514 | + | ||
| 515 | + /** | ||
| 516 | + 查看允不允许输入 例如 允许输入1、2时传入12 | ||
| 517 | + */ | ||
| 518 | + func allowWriteString(string:String)->Bool{ | ||
| 519 | + //判断输入的是否是数字 否则无效 | ||
| 520 | + var cs = CharacterSet() | ||
| 521 | + // 获取除以下数字所有的字符集合 | ||
| 522 | + cs = CharacterSet(charactersIn: string).inverted | ||
| 523 | + let filterArr = string.components(separatedBy: cs) | ||
| 524 | + // 对比一下是否为数字 | ||
| 525 | + return filterArr.count == string.count ? true:false | ||
| 526 | + } | ||
| 334 | 527 | ||
| 335 | } | 528 | } |
metaCode/Classes/Main/HomePage/View/GoodsManager/CNLiveShopClassifyCell.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveShopClassifyCell.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by zx on 2023/11/17. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | + | ||
| 10 | +class CNLiveShopClassifyCell: UITableViewCell { | ||
| 11 | + ///标题 | ||
| 12 | + lazy var titleLabel: UILabel = { | ||
| 13 | + let titleLabel = UILabel.init(frame: CGRectMake(15, 0, KSreenWidth-15*2, 40)) | ||
| 14 | + titleLabel.textColor = HexColor("#666666") | ||
| 15 | + titleLabel.textAlignment = .left | ||
| 16 | + titleLabel.font = Font_14 | ||
| 17 | + titleLabel.adjustsFontSizeToFitWidth=true | ||
| 18 | + titleLabel.lineBreakMode = .byTruncatingTail | ||
| 19 | + titleLabel.tag = 1 | ||
| 20 | + return titleLabel | ||
| 21 | + }() | ||
| 22 | + | ||
| 23 | + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
| 24 | + super.init(style: style, reuseIdentifier: reuseIdentifier) | ||
| 25 | + self.selectionStyle = .none | ||
| 26 | + contentView.backgroundColor = .white | ||
| 27 | + contentView.addSubview(self.titleLabel) | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + required init?(coder: NSCoder) { | ||
| 31 | + fatalError("init(coder:) has not been implemented") | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | +} |
metaCode/Classes/Main/HomePage/View/GoodsManager/CNLiveShopClassifyInputTableViewCell.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveShopClassifyInputTableViewCell.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by zx on 2023/11/18. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | + | ||
| 10 | +class CNLiveShopClassifyInputTableViewCell:UITableViewCell{ | ||
| 11 | + | ||
| 12 | + // MARK: - Lazy | ||
| 13 | + lazy var titlelab: UILabel = { | ||
| 14 | + let titlelab = UILabel.init() | ||
| 15 | + titlelab.textColor = HexColor("#333333") | ||
| 16 | + titlelab.textAlignment = .left | ||
| 17 | + titlelab.font = Font_14 | ||
| 18 | + titlelab.adjustsFontSizeToFitWidth=true | ||
| 19 | + return titlelab | ||
| 20 | + }() | ||
| 21 | + lazy var star: UILabel = { | ||
| 22 | + let star = UILabel.init(frame: CGRect(x: 5, y: 0, width: 6, height: 50)) | ||
| 23 | + star.textColor = HexColor("#FF725C") | ||
| 24 | + star.textAlignment = .left | ||
| 25 | + star.text = "*" | ||
| 26 | + star.font = Font_12 | ||
| 27 | + return star | ||
| 28 | + }() | ||
| 29 | + lazy var textFiled :UITextField = { | ||
| 30 | + let textFiled = UITextField() | ||
| 31 | + textFiled.textAlignment = .right | ||
| 32 | + textFiled.font = Font_14 | ||
| 33 | + return textFiled | ||
| 34 | + }() | ||
| 35 | + | ||
| 36 | + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
| 37 | + super.init(style: style, reuseIdentifier: reuseIdentifier) | ||
| 38 | + self.selectionStyle = .none | ||
| 39 | + self.initUI() | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + required init?(coder: NSCoder) { | ||
| 43 | + fatalError("init(coder:) has not been implemented") | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + func initUI(){ | ||
| 47 | + self.contentView.addSubview(self.titlelab) | ||
| 48 | + self.contentView.addSubview(self.star) | ||
| 49 | + self.contentView.addSubview(self.textFiled) | ||
| 50 | + self.p_massony() | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + func p_massony(){ | ||
| 54 | + | ||
| 55 | + self.titlelab.snp.makeConstraints { make in | ||
| 56 | + make.left.equalTo(15) | ||
| 57 | + make.centerY.equalTo(self.contentView.centerY) | ||
| 58 | + } | ||
| 59 | + self.titlelab.setContentCompressionResistancePriority(.required, for: .horizontal) | ||
| 60 | + self.textFiled.snp.makeConstraints { make in | ||
| 61 | + make.left.equalTo(self.titlelab.right).offset(15) | ||
| 62 | + make.centerY.equalTo(self.contentView.centerY) | ||
| 63 | + make.right.equalTo(self.contentView.right).offset(-15) | ||
| 64 | + make.height.equalTo(50) | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | +} | ||
| 68 | + | ||
| 69 | +///输入标题cell | ||
| 70 | +class CNLiveShopClassifyInputTitleCell:CNLiveShopClassifyInputTableViewCell{ | ||
| 71 | + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
| 72 | + super.init(style: style, reuseIdentifier: reuseIdentifier) | ||
| 73 | + self.titlelab.text = "分类名称" | ||
| 74 | + self.textFiled.placeholder = "请输入分类名称" | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + required init?(coder: NSCoder) { | ||
| 78 | + fatalError("init(coder:) has not been implemented") | ||
| 79 | + } | ||
| 80 | +} | ||
| 81 | + | ||
| 82 | +///输入排序cell | ||
| 83 | +class CNLiveShopClassifyInputSortCell:CNLiveShopClassifyInputTableViewCell{ | ||
| 84 | + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
| 85 | + super.init(style: style, reuseIdentifier: reuseIdentifier) | ||
| 86 | + self.selectionStyle = .none | ||
| 87 | + self.titlelab.text = "排序" | ||
| 88 | + self.textFiled.placeholder = "请输入排序" | ||
| 89 | + self.textFiled.keyboardType = .numberPad | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + required init?(coder: NSCoder) { | ||
| 93 | + fatalError("init(coder:) has not been implemented") | ||
| 94 | + } | ||
| 95 | +} |
metaCode/Classes/Main/HomePage/View/GoodsManager/CNLiveShopClassifySwitchTableViewCell.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveShopClassifySwitchTableViewCell.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by zx on 2023/11/18. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | + | ||
| 10 | +///排序类型 | ||
| 11 | +enum CNLiveShopClassifySwitchType:Int { | ||
| 12 | + ///是否显示分类 | ||
| 13 | + case classify | ||
| 14 | + ///是否显示导航栏 | ||
| 15 | + case nav | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +typealias switchBlock = (_ on:Bool,_ type:CNLiveShopClassifySwitchType)->Void | ||
| 19 | + | ||
| 20 | +///包含 Switch的 cell | ||
| 21 | +class CNLiveShopClassifySwitchTableViewCell: UITableViewCell { | ||
| 22 | + var switchType:CNLiveShopClassifySwitchType? | ||
| 23 | + var switchClickBlock:switchBlock? | ||
| 24 | + | ||
| 25 | + // MARK: - Lazy | ||
| 26 | + lazy var titlelab: UILabel = { | ||
| 27 | + let titlelab = UILabel.init() | ||
| 28 | + titlelab.textColor = HexColor("#333333") | ||
| 29 | + titlelab.textAlignment = .left | ||
| 30 | + titlelab.font = Font_14 | ||
| 31 | + titlelab.adjustsFontSizeToFitWidth=true | ||
| 32 | + return titlelab | ||
| 33 | + }() | ||
| 34 | + lazy var star: UILabel = { | ||
| 35 | + let star = UILabel.init(frame: CGRect(x: 5, y: 0, width: 6, height: 50)) | ||
| 36 | + star.textColor = HexColor("#FF725C") | ||
| 37 | + star.textAlignment = .left | ||
| 38 | + star.text = "*" | ||
| 39 | + star.font = Font_12 | ||
| 40 | + return star | ||
| 41 | + }() | ||
| 42 | + lazy var rightSwitch: UISwitch = { | ||
| 43 | + let rightSwitch = UISwitch.init() | ||
| 44 | + rightSwitch.tintColor = .green | ||
| 45 | + rightSwitch.addTarget(self, action: #selector(switchAction), for: .valueChanged) | ||
| 46 | + return rightSwitch | ||
| 47 | + }() | ||
| 48 | + | ||
| 49 | + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
| 50 | + super.init(style: style, reuseIdentifier: reuseIdentifier) | ||
| 51 | + self.selectionStyle = .none | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + required init?(coder: NSCoder) { | ||
| 55 | + fatalError("init(coder:) has not been implemented") | ||
| 56 | + } | ||
| 57 | + // MARK: - 初始化UI | ||
| 58 | + func initUI(){ | ||
| 59 | + self.contentView.addSubview(self.titlelab) | ||
| 60 | + self.contentView.addSubview(self.star) | ||
| 61 | + self.contentView.addSubview(self.rightSwitch) | ||
| 62 | + self.p_massony() | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + func p_massony(){ | ||
| 66 | + | ||
| 67 | + self.titlelab.snp.makeConstraints { make in | ||
| 68 | + make.left.equalTo(15) | ||
| 69 | + make.centerY.equalTo(self.contentView.centerY) | ||
| 70 | + } | ||
| 71 | + self.rightSwitch.snp.makeConstraints { make in | ||
| 72 | + | ||
| 73 | + make.right.equalTo(-15) | ||
| 74 | + make.centerY.equalTo(self.contentView.centerY) | ||
| 75 | + make.size.equalTo(CGSize(width: 45, height: 22)) | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | + // MARK: - switchAction | ||
| 79 | + @objc func switchAction(sender:UISwitch){ | ||
| 80 | + self.switchClickBlock!(self.rightSwitch.isOn, self.switchType!) | ||
| 81 | + } | ||
| 82 | +} |
metaCode/Classes/Main/HomePage/View/GoodsManager/CNLiveShopClassilyIconTableViewCell.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveShopClassilyIconTableViewCell.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by zx on 2023/11/18. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | + | ||
| 10 | +///上传图片成功 | ||
| 11 | +typealias uploadImageViewSuceessBlock = (_ imageUrl:String)->Void | ||
| 12 | + | ||
| 13 | +///店铺分类图标cell | ||
| 14 | +class CNLiveShopClassilyIconTableViewCell: UITableViewCell { | ||
| 15 | + var _selectUploadImageView:CNLiveAddGoodsSelectUploadImageView? | ||
| 16 | + var selectUploadImageView:CNLiveAddGoodsSelectUploadImageView?{ | ||
| 17 | + get{ | ||
| 18 | + if _selectUploadImageView == nil{ | ||
| 19 | + _selectUploadImageView = CNLiveAddGoodsSelectUploadImageView() | ||
| 20 | + _selectUploadImageView?.maxSelectImageCount = 1 | ||
| 21 | + _selectUploadImageView?.isAbleSelectVideo = false | ||
| 22 | + _selectUploadImageView?.deleteImage = UIImage(named: "DS_happ_daren_dynamic_delete") | ||
| 23 | + _selectUploadImageView?.endUploadImageCallBack = { | ||
| 24 | + let imageUrl = self.selectUploadImageView?.getCurrentSelectImageUrls().first | ||
| 25 | + self.uploadImageSuceessBlock!(imageUrl ?? "") | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + } | ||
| 29 | + return _selectUploadImageView | ||
| 30 | + } | ||
| 31 | + set{ | ||
| 32 | + _selectUploadImageView = newValue | ||
| 33 | + | ||
| 34 | + } | ||
| 35 | + } | ||
| 36 | + var uploadImageSuceessBlock:uploadImageViewSuceessBlock? | ||
| 37 | + | ||
| 38 | + // MARK: - Lazy | ||
| 39 | + lazy var titlelab: UILabel = { | ||
| 40 | + let titlelab = UILabel.init() | ||
| 41 | + titlelab.textColor = HexColor("#999999") | ||
| 42 | + titlelab.textAlignment = .left | ||
| 43 | + titlelab.font = Font_12 | ||
| 44 | + titlelab.numberOfLines = 2 | ||
| 45 | + var att = NSMutableAttributedString(string: "分类图标 (注:手机端专用,建议上传正方形图片 100*100)") | ||
| 46 | + att.addAttribute(NSAttributedString.Key.font, value: Font_14, range: NSRange(location: 0, length: 4)) | ||
| 47 | + att.addAttribute(NSAttributedString.Key.foregroundColor, value: HexColor("#333333")! as UIColor, range: NSRange(location: 0, length: 4)) | ||
| 48 | + titlelab.attributedText = att | ||
| 49 | + return titlelab | ||
| 50 | + }() | ||
| 51 | + lazy var star: UILabel = { | ||
| 52 | + let star = UILabel.init(frame: CGRect(x: 5, y: 0, width: 6, height: 40)) | ||
| 53 | + star.textColor = HexColor("#FF725C") | ||
| 54 | + star.textAlignment = .left | ||
| 55 | + star.text = "*" | ||
| 56 | + star.font = Font_12 | ||
| 57 | + return star | ||
| 58 | + }() | ||
| 59 | + | ||
| 60 | + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
| 61 | + super.init(style: style, reuseIdentifier: reuseIdentifier) | ||
| 62 | + self.selectionStyle = .none | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + required init?(coder: NSCoder) { | ||
| 66 | + fatalError("init(coder:) has not been implemented") | ||
| 67 | + } | ||
| 68 | + // MARK: - 初始化UI | ||
| 69 | + func initUI(){ | ||
| 70 | + self.contentView.addSubview(self.titlelab) | ||
| 71 | + self.contentView.addSubview(self.star) | ||
| 72 | + self.contentView.addSubview(self.selectUploadImageView!) | ||
| 73 | + self.p_massony() | ||
| 74 | + } | ||
| 75 | + func p_massony(){ | ||
| 76 | + self.titlelab.snp.makeConstraints { make in | ||
| 77 | + make.left.equalTo(15) | ||
| 78 | + make.top.equalTo(0) | ||
| 79 | + make.height.equalTo(40) | ||
| 80 | + } | ||
| 81 | + self.selectUploadImageView?.frame = CGRect(x: 0, y: 40, width: 120, height: 120) | ||
| 82 | + } | ||
| 83 | +} |
metaCode/Classes/Main/HomePage/View/GoodsManager/CNLiveShopGoodsManageDetailsInputManager.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveShopGoodsManageDetailsInputManager.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by zx on 2023/11/16. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | + | ||
| 10 | +typealias completerDoneBlock = (_ k:String,_ v:String)->Void | ||
| 11 | + | ||
| 12 | + | ||
| 13 | +class CNLiveShopGoodsManageDetailsInputManager:NSObject{ | ||
| 14 | + var modalViewController = CNLiveModalPresentationViewController() | ||
| 15 | + var paramField = UITextField() | ||
| 16 | + var contentField = UITextField() | ||
| 17 | + var completerBlock:completerDoneBlock? | ||
| 18 | + | ||
| 19 | + func showCustomParamAlertWithCompleterBlock(completeBlock:@escaping completerDoneBlock){ | ||
| 20 | + let contentView = UIView(frame: CGRect(x: 0, y: 0, width: KSreenWidth, height: 230)) | ||
| 21 | + contentView.backgroundColor = .white | ||
| 22 | + contentView.layer.cornerRadius = 6 | ||
| 23 | + | ||
| 24 | + let titleLabel = UILabel(frame: CGRect(x: 0, y: 20, width: KSreenWidth-20, height: 30)) | ||
| 25 | + titleLabel.font = Font_16 | ||
| 26 | + titleLabel.textAlignment = .center | ||
| 27 | + titleLabel.text = "添加通用参数" | ||
| 28 | + titleLabel.textColor = HexColor("#333333") | ||
| 29 | + titleLabel.backgroundColor = .white | ||
| 30 | + contentView.addSubview(titleLabel) | ||
| 31 | + | ||
| 32 | + let paramView = UIView(frame: CGRect(x: 10, y: titleLabel.bottom+10, width: KSreenWidth-40, height: 40)) | ||
| 33 | + paramView.backgroundColor = HexColor("#F7F7F7") | ||
| 34 | + paramView.layer.masksToBounds = true | ||
| 35 | + paramView.layer.cornerRadius = 5 | ||
| 36 | + contentView.addSubview(paramView) | ||
| 37 | + | ||
| 38 | + let paramField = UITextField(frame: CGRect(x: 5, y: 5, width: KSreenWidth-50, height: 35)) | ||
| 39 | + paramField.placeholder = "请输入参数名称" | ||
| 40 | + paramField.returnKeyType = .next | ||
| 41 | + paramField.font = Font_14 | ||
| 42 | + paramField.textColor = HexColor("#333333") | ||
| 43 | + paramField.backgroundColor = .clear | ||
| 44 | + paramView.addSubview(paramField) | ||
| 45 | + self.paramField = paramField | ||
| 46 | + | ||
| 47 | + let contentSubView = UIView(frame: CGRect(x: 10, y: paramView.bottom+10, width: contentView.width-40, height: 40)) | ||
| 48 | + contentSubView.backgroundColor = HexColor("#F7F7F7") | ||
| 49 | + contentSubView.layer.masksToBounds = true | ||
| 50 | + contentSubView.layer.cornerRadius = 5 | ||
| 51 | + contentView.addSubview(contentSubView) | ||
| 52 | + | ||
| 53 | + let contentField = UITextField(frame: CGRect(x: 5, y: 5, width: KSreenWidth-50, height: 30)) | ||
| 54 | + contentField.placeholder = "请输入参数内容" | ||
| 55 | + contentField.returnKeyType = .done | ||
| 56 | + contentField.font = Font_14 | ||
| 57 | + contentField.textColor = HexColor("#333333") | ||
| 58 | + contentField.backgroundColor = .clear | ||
| 59 | + contentSubView.addSubview(contentField) | ||
| 60 | + self.contentField = contentField | ||
| 61 | + | ||
| 62 | + let cancelButton = UIButton(type: .custom) | ||
| 63 | + cancelButton.frame = CGRect(x: 10, y: contentSubView.bottom+10, width: (contentView.width-50)*0.5, height: 40) | ||
| 64 | + cancelButton.setTitle("取消", for: .normal) | ||
| 65 | + cancelButton.setTitle("取消", for: .highlighted) | ||
| 66 | + cancelButton.setTitleColor(HexColor("#999999"), for: .normal) | ||
| 67 | + cancelButton.setTitleColor(HexColor("#999999"), for: .highlighted) | ||
| 68 | + cancelButton.layer.cornerRadius = 5 | ||
| 69 | + cancelButton.backgroundColor = .white | ||
| 70 | + cancelButton.layer.borderColor = HexColor("#999999")!.cgColor | ||
| 71 | + cancelButton.layer.borderWidth = 1 | ||
| 72 | + cancelButton.layer.masksToBounds = true | ||
| 73 | + cancelButton.titleLabel?.font = Font_14 | ||
| 74 | + contentView.addSubview(cancelButton) | ||
| 75 | + | ||
| 76 | + let confirmButton = UIButton(type: .custom) | ||
| 77 | + confirmButton.frame = CGRect(x: 20+cancelButton.width, y: contentSubView.bottom+10, width: (contentView.width-50)*0.5, height: 40) | ||
| 78 | + confirmButton.setTitle("确定", for: .normal) | ||
| 79 | + confirmButton.setTitle("确定", for: .highlighted) | ||
| 80 | + confirmButton.setTitleColor(HexColor("#FFFFFF"), for: .normal) | ||
| 81 | + confirmButton.setTitleColor(HexColor("#FFFFFF"), for: .highlighted) | ||
| 82 | + confirmButton.layer.cornerRadius = 5 | ||
| 83 | + confirmButton.layer.masksToBounds = true | ||
| 84 | + confirmButton.backgroundColor = HexColor("#61C463") | ||
| 85 | + confirmButton.titleLabel?.font = Font_14 | ||
| 86 | + contentView.addSubview(confirmButton) | ||
| 87 | + | ||
| 88 | + let modalViewController = CNLiveModalPresentationViewController() | ||
| 89 | + modalViewController.contentView = contentView | ||
| 90 | + modalViewController.showingAnimationWithCompletion { finished in | ||
| 91 | + | ||
| 92 | + } | ||
| 93 | + self.modalViewController = modalViewController | ||
| 94 | + | ||
| 95 | + cancelButton.addTarget(modalViewController, action: #selector(cancelButtonAction), for: .touchUpInside) | ||
| 96 | + | ||
| 97 | + self.completerBlock = completeBlock | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + @objc func cancelButtonAction(){ | ||
| 101 | + self.modalViewController.hidingAnimationWithCompletion { finished in | ||
| 102 | + | ||
| 103 | + } | ||
| 104 | + } | ||
| 105 | + @objc func confirmButtonAction(){ | ||
| 106 | + | ||
| 107 | + if self.paramField.text?.count ?? 0 > 0 && self.contentField.text?.count ?? 0 > 0{ | ||
| 108 | + self.modalViewController.hidingAnimationWithCompletion { finished in | ||
| 109 | + if finished{ | ||
| 110 | + | ||
| 111 | + self.completerBlock!((self.paramField.text?.count ?? 0 > 10 ? self.paramField.text?.subString(start: 0, length: 10) : self.paramField.text) ?? "",self.contentField.text ?? "") | ||
| 112 | + } | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | +} |
metaCode/Classes/Main/HomePage/View/GoodsManager/CNLiveShopTextView.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveShopTextView.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by zx on 2023/11/15. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | + | ||
| 10 | +class CNLiveShopTextView: UITextView { | ||
| 11 | + /// setNeedsDisplay调用drawRect | ||
| 12 | + var placeHolder: String = ""{ | ||
| 13 | + didSet{ | ||
| 14 | + self.setNeedsDisplay() | ||
| 15 | + } | ||
| 16 | + } | ||
| 17 | + var placeHolderColor: UIColor = UIColor.gray{ | ||
| 18 | + didSet{ | ||
| 19 | + self.setNeedsDisplay() | ||
| 20 | + } | ||
| 21 | + } | ||
| 22 | + override var font: UIFont?{ | ||
| 23 | + didSet{ | ||
| 24 | + self.setNeedsDisplay() | ||
| 25 | + } | ||
| 26 | + } | ||
| 27 | + override var text: String!{ | ||
| 28 | + didSet{ | ||
| 29 | + self.setNeedsDisplay() | ||
| 30 | + } | ||
| 31 | + } | ||
| 32 | + override var attributedText: NSAttributedString!{ | ||
| 33 | + didSet{ | ||
| 34 | + self.setNeedsDisplay() | ||
| 35 | + } | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + override init(frame: CGRect, textContainer: NSTextContainer?) { | ||
| 39 | + super.init(frame: frame, textContainer: textContainer) | ||
| 40 | + /// default字号 | ||
| 41 | + self.font = UIFont.systemFont(ofSize: 14) | ||
| 42 | + NotificationCenter.default.addObserver(self, selector: #selector(textDidChanged(noti:)), name: UITextView.textDidChangeNotification, object: self) | ||
| 43 | + } | ||
| 44 | + required init?(coder aDecoder: NSCoder) { | ||
| 45 | + fatalError("init(coder:) has not been implemented") | ||
| 46 | + } | ||
| 47 | + @objc func textDidChanged(noti: NSNotification) { | ||
| 48 | + self.setNeedsDisplay() | ||
| 49 | + } | ||
| 50 | + override func draw(_ rect: CGRect) { | ||
| 51 | + if self.hasText { | ||
| 52 | + return | ||
| 53 | + } | ||
| 54 | + var newRect = CGRect() | ||
| 55 | + newRect.origin.x = 5 | ||
| 56 | + newRect.origin.y = 7 | ||
| 57 | + let size = self.placeHolder.getStringSize(rectSize: rect.size, font: self.font ?? UIFont.systemFont(ofSize: 14)) | ||
| 58 | + newRect.size.width = size.width | ||
| 59 | + newRect.size.height = size.height | ||
| 60 | + /// 将placeHolder画在textView上 | ||
| 61 | + (self.placeHolder as NSString).draw(in: newRect, withAttributes: [NSAttributedString.Key.font: self.font ?? UIFont.systemFont(ofSize: 14),NSAttributedString.Key.foregroundColor: self.placeHolderColor]) | ||
| 62 | + } | ||
| 63 | + override func layoutSubviews() { | ||
| 64 | + super.layoutSubviews() | ||
| 65 | + self.setNeedsDisplay() | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + deinit { | ||
| 69 | + NotificationCenter.default.removeObserver(self, name: UITextView.textDidChangeNotification, object: self) | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | +} | ||
| 73 | + | ||
| 74 | +extension String { | ||
| 75 | + /// 计算字符串的尺寸 | ||
| 76 | + /// | ||
| 77 | + /// - Parameters: | ||
| 78 | + /// - text: 字符串 | ||
| 79 | + /// - rectSize: 容器的尺寸 | ||
| 80 | + /// - fontSize: 字体 | ||
| 81 | + /// - Returns: 尺寸 | ||
| 82 | + /// | ||
| 83 | + public func getStringSize(rectSize: CGSize,font: UIFont) -> CGSize { | ||
| 84 | + let str: NSString = self as NSString | ||
| 85 | + let rect = str.boundingRect(with: rectSize, options: NSStringDrawingOptions.usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font: font], context: nil) | ||
| 86 | + return CGSize(width: ceil(rect.width), height: ceil(rect.height)) | ||
| 87 | + } | ||
| 88 | +} |
metaCode/Classes/Main/HomePage/ViewModel/CNLiveShopDetailViewModel.swift
metaCode/Classes/Main/HomePage/ViewModel/GoodsManager/CNLiveShopGoodListViewModel.swift
| @@ -8,6 +8,8 @@ | @@ -8,6 +8,8 @@ | ||
| 8 | import Foundation | 8 | import Foundation |
| 9 | import CNLiveRequestBastKit | 9 | import CNLiveRequestBastKit |
| 10 | 10 | ||
| 11 | +typealias categoryResultBlock = (_ result: Any,_ status:CNLiveDownSlideResponseType) -> Void | ||
| 12 | + | ||
| 11 | class CNLiveShopGoodListViewModel:NSObject{ | 13 | class CNLiveShopGoodListViewModel:NSObject{ |
| 12 | /// 请求店铺商品列表 | 14 | /// 请求店铺商品列表 |
| 13 | /// - Parameters: | 15 | /// - Parameters: |
| @@ -44,6 +46,142 @@ class CNLiveShopGoodListViewModel:NSObject{ | @@ -44,6 +46,142 @@ class CNLiveShopGoodListViewModel:NSObject{ | ||
| 44 | } | 46 | } |
| 45 | } | 47 | } |
| 46 | 48 | ||
| 49 | + // MARK: - 商品管理 | ||
| 50 | + /// 商品发布 | ||
| 51 | + /// @param uid 用户id | ||
| 52 | + /// @param groupid3 三级分类id | ||
| 53 | + /// @param bannerImg 轮播图片json字符串 案例:[{"img":"","ord":"99"}] | ||
| 54 | + /// @param simg 轮播主图 | ||
| 55 | + /// @param video 主图视频地址 | ||
| 56 | + /// @param title 商品名称 | ||
| 57 | + /// @param ads 商品副标题 | ||
| 58 | + /// @param price 本店售价 | ||
| 59 | + /// @param prices 市场售价 | ||
| 60 | + /// @param kg 商品重量 | ||
| 61 | + /// @param unit 商品单位 | ||
| 62 | + /// @param storage 商品参数 | ||
| 63 | + /// @param state 上下架状态 1下架 2上架 | ||
| 64 | + /// @param infoImg 详情图片json字符串 案例:[{"img":"","ord":"99"}] | ||
| 65 | + /// @param min_count 最小起购数 | ||
| 66 | + /// @param yunfei 运费 | ||
| 67 | + /// @param isRefund 是否可退 0可以退 1不可退 | ||
| 68 | + /// @param category_id 店铺分类id,选中了二级分类,传二级分类的id,没选二级分类就传一级分类的id | ||
| 69 | + /// @param result 结果 | ||
| 70 | + static func postGoodsAddWithUid(uid:String,groupid3:String,bannerImg:String,simg:String,video:String,title:String,ads:String,price:String,prices:String,kg:String,unit:String,state:String,storage:String,infoImg:String,yunfei:String,min_count:String,isRefund:String,category_id:String,resultBlock: @escaping downSlideResultBlock){ | ||
| 71 | + let param = NSMutableDictionary() | ||
| 72 | + param.setValue(uid, forKey: "uid") | ||
| 73 | + param.setValue(groupid3, forKey: "groupid3") | ||
| 74 | + param.setValue(bannerImg, forKey: "banner_img") | ||
| 75 | + param.setValue(simg, forKey: "simg") | ||
| 76 | + param.setValue(video, forKey: "video") | ||
| 77 | + param.setValue(title, forKey: "title") | ||
| 78 | + param.setValue(ads, forKey: "ads") | ||
| 79 | + param.setValue(price, forKey: "price") | ||
| 80 | + param.setValue(prices, forKey: "prices") | ||
| 81 | + param.setValue(kg, forKey: "kg") | ||
| 82 | + param.setValue(unit, forKey: "unit") | ||
| 83 | + param.setValue(state, forKey: "state") | ||
| 84 | + param.setValue(storage, forKey: "storage") | ||
| 85 | + param.setValue(infoImg, forKey: "info_img") | ||
| 86 | + param.setValue(yunfei, forKey: "yunfei") | ||
| 87 | + param.setValue(min_count, forKey: "min_buy_num") | ||
| 88 | + param.setValue(isRefund, forKey: "is_refund") | ||
| 89 | + param.setValue(category_id, forKey: "category_id") | ||
| 90 | + | ||
| 91 | + CNLiveNetworking.setAllowRequestDefaultArgument(true) | ||
| 92 | + CNLiveNetworking.setupShowDataResult(false) | ||
| 93 | + CNLiveNetworking.setupDSRequest(true) | ||
| 94 | + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseWjjBUrl+"/api/v1/goodsAdd", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in | ||
| 95 | + hiddenLoading() | ||
| 96 | + if (error == nil) { | ||
| 97 | + resultBlock(result as Any,.success) | ||
| 98 | + }else{ | ||
| 99 | + resultBlock(NSNull(),.failed) | ||
| 100 | + } | ||
| 101 | + } | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + // MARK: - 商品详情 | ||
| 105 | + /** | ||
| 106 | + 商品详情 | ||
| 107 | + | ||
| 108 | + @param goodsId 商品id | ||
| 109 | + @param result 结果 | ||
| 110 | + */ | ||
| 111 | + static func getGoodsInfoWithGoodsId(goodsId:String,resultBlock: @escaping categoryResultBlock){ | ||
| 112 | + let param = NSMutableDictionary() | ||
| 113 | + param.setValue(goodsId, forKey: "id") | ||
| 114 | + | ||
| 115 | + CNLiveNetworking.setAllowRequestDefaultArgument(true) | ||
| 116 | + CNLiveNetworking.setupShowDataResult(false) | ||
| 117 | + CNLiveNetworking.setupDSRequest(true) | ||
| 118 | + CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseWjjBUrl+"/api/v1/goodsInfo", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in | ||
| 119 | + hiddenLoading() | ||
| 120 | + if (error == nil) { | ||
| 121 | + let resp = result as! NSDictionary | ||
| 122 | + let model = newDictionaryToModel(resp as! [String : Any], CNLiveShopGoodsDetailsModel.self) | ||
| 123 | + resultBlock(model,.success) | ||
| 124 | + }else{ | ||
| 125 | + resultBlock(NSNull(),.failed) | ||
| 126 | + } | ||
| 127 | + } | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + /// 商品修改 | ||
| 131 | + /// @param goodsId 商品id | ||
| 132 | + /// @param uid 用户id | ||
| 133 | + /// @param bannerImg 轮播图片json字符串 案例:[{"img":"","ord":"99"}] | ||
| 134 | + /// @param simg 轮播主图 | ||
| 135 | + /// @param video 主图视频地址 | ||
| 136 | + /// @param title 商品名称 | ||
| 137 | + /// @param ads 商品副标题 | ||
| 138 | + /// @param price 本店售价 | ||
| 139 | + /// @param prices 市场售价 | ||
| 140 | + /// @param kg 商品重量 | ||
| 141 | + /// @param unit 商品单位 | ||
| 142 | + /// @param state 上下架状态 1下架 2上架 | ||
| 143 | + /// @param storage 规格参数 | ||
| 144 | + /// @param infoImg 详情图片json字符串 案例:[{"img":"","ord":"99"}] | ||
| 145 | + /// @param min_count 最小起购数 | ||
| 146 | + /// @param yunfei 运费 | ||
| 147 | + /// @param isRefund 是否可退 0可以退 1不可退 | ||
| 148 | + /// @param category_id 店铺分类id,选中了二级分类,传二级分类的id,没选二级分类就传一级分类的id | ||
| 149 | + /// @param result 结果 | ||
| 150 | + static func postGoodsEditWithGoodsId(goodsId:String,uid:String,bannerImg:String,simg:String,video:String,title:String,ads:String,price:String,prices:String,kg:String,unit:String,state:String,storage:String,infoImg:String,yunfei:String,min_count:String,isRefund:String,category_id:String,resultBlock: @escaping downSlideResultBlock){ | ||
| 151 | + | ||
| 152 | + let param = NSMutableDictionary() | ||
| 153 | + param.setValue(goodsId, forKey: "id") | ||
| 154 | + param.setValue(uid, forKey: "uid") | ||
| 155 | + param.setValue(bannerImg, forKey: "banner_img") | ||
| 156 | + param.setValue(simg, forKey: "simg") | ||
| 157 | + param.setValue(video, forKey: "video") | ||
| 158 | + param.setValue(title, forKey: "title") | ||
| 159 | + param.setValue(ads, forKey: "ads") | ||
| 160 | + param.setValue(price, forKey: "price") | ||
| 161 | + param.setValue(prices, forKey: "prices") | ||
| 162 | + param.setValue(kg, forKey: "kg") | ||
| 163 | + param.setValue(unit, forKey: "unit") | ||
| 164 | + param.setValue(state, forKey: "state") | ||
| 165 | + param.setValue(storage, forKey: "storage") | ||
| 166 | + param.setValue(infoImg, forKey: "info_img") | ||
| 167 | + param.setValue(yunfei, forKey: "yunfei") | ||
| 168 | + param.setValue(min_count, forKey: "min_buy_num") | ||
| 169 | + param.setValue(isRefund, forKey: "is_refund") | ||
| 170 | + param.setValue(category_id, forKey: "category_id") | ||
| 171 | + | ||
| 172 | + CNLiveNetworking.setAllowRequestDefaultArgument(true) | ||
| 173 | + CNLiveNetworking.setupShowDataResult(false) | ||
| 174 | + CNLiveNetworking.setupDSRequest(true) | ||
| 175 | + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseWjjBUrl+"/api/v1/goodsEdit", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in | ||
| 176 | + hiddenLoading() | ||
| 177 | + if (error == nil) { | ||
| 178 | + resultBlock(result as Any,.success) | ||
| 179 | + }else{ | ||
| 180 | + resultBlock(NSNull(),.failed) | ||
| 181 | + } | ||
| 182 | + } | ||
| 183 | + } | ||
| 184 | + | ||
| 47 | /// 商品单个属性修改 | 185 | /// 商品单个属性修改 |
| 48 | /// @param shopId 商家id | 186 | /// @param shopId 商家id |
| 49 | /// @param goodsId 商品id | 187 | /// @param goodsId 商品id |
| @@ -93,4 +231,56 @@ class CNLiveShopGoodListViewModel:NSObject{ | @@ -93,4 +231,56 @@ class CNLiveShopGoodListViewModel:NSObject{ | ||
| 93 | } | 231 | } |
| 94 | } | 232 | } |
| 95 | 233 | ||
| 234 | + /// 获取店铺分类 | ||
| 235 | + /// @param uid 用户id | ||
| 236 | + /// @param pid 上级分类id | ||
| 237 | + /// @param result 结果 | ||
| 238 | + static func getGetGroupWithUid(uid:String,pid:String,resultBlock: @escaping categoryResultBlock){ | ||
| 239 | + let param = NSMutableDictionary() | ||
| 240 | + param.setValue(uid, forKey: "uid") | ||
| 241 | + param.setValue(pid, forKey: "pid") | ||
| 242 | + | ||
| 243 | + CNLiveNetworking.setAllowRequestDefaultArgument(true) | ||
| 244 | + CNLiveNetworking.setupShowDataResult(false) | ||
| 245 | + CNLiveNetworking.setupDSRequest(true) | ||
| 246 | + CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseWjjBUrl+"/api/v1/getGroup", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in | ||
| 247 | + hiddenLoading() | ||
| 248 | + if (error == nil) { | ||
| 249 | + let resp = result as! NSDictionary | ||
| 250 | + var dataArr:[BaseModel] = [] | ||
| 251 | + let respArr = resp["list"] as! NSArray | ||
| 252 | + for dic in respArr{ | ||
| 253 | + let dataDic = dic as! NSDictionary | ||
| 254 | + let cateListModel = newDictionaryToModel(dataDic as! [String : Any], CNLiveShopGoodsManageDetailsGoodsCategoryModel.self) | ||
| 255 | + dataArr.append(cateListModel) | ||
| 256 | + } | ||
| 257 | + resultBlock(dataArr,.success) | ||
| 258 | + }else{ | ||
| 259 | + resultBlock(NSNull(),.failed) | ||
| 260 | + } | ||
| 261 | + } | ||
| 262 | + } | ||
| 263 | + | ||
| 264 | + /// 获取分类列表 | ||
| 265 | + /// @param shopId 店铺id | ||
| 266 | + /// @param resultBlock 回调 | ||
| 267 | + static func getCateListWithShopId(shopId:String,resultBlock: @escaping categoryResultBlock){ | ||
| 268 | + let param = NSMutableDictionary() | ||
| 269 | + param.setValue(shopId, forKey: "shop_id") | ||
| 270 | + | ||
| 271 | + CNLiveNetworking.setAllowRequestDefaultArgument(true) | ||
| 272 | + CNLiveNetworking.setupShowDataResult(false) | ||
| 273 | + CNLiveNetworking.setupDSRequest(true) | ||
| 274 | + CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseWjjBUrl+"/api/v1/cateList", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in | ||
| 275 | + hiddenLoading() | ||
| 276 | + if (error == nil) { | ||
| 277 | + let resp = result as! NSDictionary | ||
| 278 | + let listModel = newDictionaryToModel(resp as! [String : Any], CNLiveShopClassifyListModel.self) | ||
| 279 | + resultBlock(listModel,.success) | ||
| 280 | + }else{ | ||
| 281 | + resultBlock(NSNull(),.failed) | ||
| 282 | + } | ||
| 283 | + } | ||
| 284 | + } | ||
| 285 | + | ||
| 96 | } | 286 | } |
metaCode/Classes/Main/HomePage/ViewModel/ShopClassify/CNLiveShopClassilyViewModel.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveShopClassilyViewModel.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by zx on 2023/11/18. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | +import CNLiveRequestBastKit | ||
| 10 | + | ||
| 11 | +class CNLiveShopClassilyViewModel: BaseModel{ | ||
| 12 | + | ||
| 13 | + /// 添加分类接口 | ||
| 14 | + /// @param model 分类数据 | ||
| 15 | + /// @param resultBlock 请求完成回调 | ||
| 16 | + static func postAddCateRequestWithModel(model:CNLiveShopClassifyModel,resultBlock: @escaping downSlideResultBlock){ | ||
| 17 | + let param = NSMutableDictionary() | ||
| 18 | + param.setValue(model.shop_id, forKey: "shop_id") | ||
| 19 | + param.setValue(model.title, forKey: "title") | ||
| 20 | + param.setValue(model.state, forKey: "state") | ||
| 21 | + param.setValue(model.isnav, forKey: "isnav") | ||
| 22 | + param.setValue(model.ord, forKey: "ord") | ||
| 23 | + param.setValue(model.pid, forKey: "pid") | ||
| 24 | + param.setValue(model.simg, forKey: "simg") | ||
| 25 | + | ||
| 26 | + CNLiveNetworking.setAllowRequestDefaultArgument(true) | ||
| 27 | + CNLiveNetworking.setupShowDataResult(false) | ||
| 28 | + CNLiveNetworking.setupDSRequest(true) | ||
| 29 | + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseWjjBUrl+"/api/v1/addCate", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in | ||
| 30 | + hiddenLoading() | ||
| 31 | + if (error == nil) { | ||
| 32 | + resultBlock(result as Any,.success) | ||
| 33 | + }else{ | ||
| 34 | + resultBlock(NSNull(),.failed) | ||
| 35 | + } | ||
| 36 | + } | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + /// 编辑分类接口 | ||
| 40 | + /// @param model 分类数据 | ||
| 41 | + /// @param resultBlock 请求完成回调 | ||
| 42 | + static func postEditCateRequestWithModel(model:CNLiveShopClassifyModel,resultBlock: @escaping downSlideResultBlock){ | ||
| 43 | + let param = NSMutableDictionary() | ||
| 44 | + param.setValue(model.shop_id, forKey: "shop_id") | ||
| 45 | + param.setValue(model.title, forKey: "title") | ||
| 46 | + param.setValue(model.state, forKey: "state") | ||
| 47 | + param.setValue(model.isnav, forKey: "isnav") | ||
| 48 | + param.setValue(model.ord, forKey: "ord") | ||
| 49 | + param.setValue(model.id, forKey: "id") | ||
| 50 | + param.setValue(model.simg, forKey: "simg") | ||
| 51 | + | ||
| 52 | + CNLiveNetworking.setAllowRequestDefaultArgument(true) | ||
| 53 | + CNLiveNetworking.setupShowDataResult(false) | ||
| 54 | + CNLiveNetworking.setupDSRequest(true) | ||
| 55 | + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseWjjBUrl+"/api/v1/editCate", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in | ||
| 56 | + hiddenLoading() | ||
| 57 | + if (error == nil) { | ||
| 58 | + resultBlock(result as Any,.success) | ||
| 59 | + }else{ | ||
| 60 | + resultBlock(NSNull(),.failed) | ||
| 61 | + } | ||
| 62 | + } | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + /// 删除分类接口 | ||
| 66 | + /// @param model 分类数据 | ||
| 67 | + /// @param resultBlock 请求完成回调 | ||
| 68 | + static func postDeleteCateRequestWithModel(model:CNLiveShopClassifyModel,resultBlock: @escaping downSlideResultBlock){ | ||
| 69 | + let param = NSMutableDictionary() | ||
| 70 | + param.setValue(model.id, forKey: "id") | ||
| 71 | + | ||
| 72 | + CNLiveNetworking.setAllowRequestDefaultArgument(true) | ||
| 73 | + CNLiveNetworking.setupShowDataResult(false) | ||
| 74 | + CNLiveNetworking.setupDSRequest(true) | ||
| 75 | + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseWjjBUrl+"/api/v1/delCate", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in | ||
| 76 | + hiddenLoading() | ||
| 77 | + if (error == nil) { | ||
| 78 | + resultBlock(result as Any,.success) | ||
| 79 | + }else{ | ||
| 80 | + resultBlock(NSNull(),.failed) | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | + } | ||
| 84 | +} |
metaCode/Classes/Main/MinePage/Controller/CNLiveMineInfoViewController.swift
| @@ -158,7 +158,7 @@ class CNLiveMineInfoViewController: CNLiveBaseViewController, PhotoPickerControl | @@ -158,7 +158,7 @@ class CNLiveMineInfoViewController: CNLiveBaseViewController, PhotoPickerControl | ||
| 158 | extension CNLiveMineInfoViewController { | 158 | extension CNLiveMineInfoViewController { |
| 159 | 159 | ||
| 160 | func pickerController(_ pickerController: PhotoPickerController, | 160 | func pickerController(_ pickerController: PhotoPickerController, |
| 161 | - didFinishSelection result: PickerResult) { | 161 | + didFinishSelection result: CNLiveMineInputViewControllerPickerResult) { |
| 162 | result.getImage { [weak self] (image, photoAsset, index) in | 162 | result.getImage { [weak self] (image, photoAsset, index) in |
| 163 | if let image = image { | 163 | if let image = image { |
| 164 | self!._select_image = image | 164 | self!._select_image = image |
metaCode/Classes/Main/Model/CNLiveShopUserInfoModel.swift
| @@ -12,7 +12,9 @@ class CNLiveShopUserInfoModel:BaseModel{ | @@ -12,7 +12,9 @@ class CNLiveShopUserInfoModel:BaseModel{ | ||
| 12 | 12 | ||
| 13 | ///darenid生成付款码时用到 | 13 | ///darenid生成付款码时用到 |
| 14 | var daren_id: String? | 14 | var daren_id: String? |
| 15 | - ///uid 用于请求老达人信息接口 | 15 | + ///用户云中用户id uid |
| 16 | + var uid: String? | ||
| 17 | + //用于请求老达人信息接口 | ||
| 16 | var daren_uid: String? | 18 | var daren_uid: String? |
| 17 | ///id | 19 | ///id |
| 18 | var id: String? | 20 | var id: String? |
metaCode/Classes/Main/Model/GoodsDetail/CNLiveSelectUploadImageModel.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveSelectUploadImageModel.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by zx on 2023/11/20. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | + | ||
| 10 | +class CNLiveSelectUploadImageModel: BaseModel,Equatable { | ||
| 11 | + static func == (lhs: CNLiveSelectUploadImageModel, rhs: CNLiveSelectUploadImageModel) -> Bool { | ||
| 12 | + | ||
| 13 | + } | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + 是否是选取图片占位 | ||
| 18 | + */ | ||
| 19 | + var isSelectPhotoPlaceholder:Bool? | ||
| 20 | + /** | ||
| 21 | + 是否是视频 | ||
| 22 | + */ | ||
| 23 | + var isVideo:Bool? | ||
| 24 | + /** | ||
| 25 | + 本地视频路径 | ||
| 26 | + */ | ||
| 27 | + var localVideoUrl:URL? | ||
| 28 | + /** | ||
| 29 | + 视频url | ||
| 30 | + */ | ||
| 31 | + var videoUrl:String? | ||
| 32 | + /** | ||
| 33 | + 图片url | ||
| 34 | + */ | ||
| 35 | + var imageUrl:String? | ||
| 36 | + /** | ||
| 37 | + 图片 | ||
| 38 | + */ | ||
| 39 | + var image:UIImage? | ||
| 40 | + /** | ||
| 41 | + 是否正在上传中 | ||
| 42 | + */ | ||
| 43 | + var isUploading:Bool? | ||
| 44 | + /** | ||
| 45 | + 上传的key 用于取消上传 | ||
| 46 | + */ | ||
| 47 | + var uploadKey:String? | ||
| 48 | + /** | ||
| 49 | + 上传百分比 0~1 | ||
| 50 | + */ | ||
| 51 | + var uploadingPercent:CGFloat? | ||
| 52 | +} |
metaCode/Classes/Main/Model/GoodsDetail/CNLiveShopGoodsDetailsModel.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveShopGoodsDetailsModel.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by zx on 2023/11/20. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | +// MARK: - 商品属性 | ||
| 10 | +class CNLiveGoodsDetailsAttrModel:BaseModel{ | ||
| 11 | + /** | ||
| 12 | + 表格左侧 | ||
| 13 | + */ | ||
| 14 | + var k:String? | ||
| 15 | + /** | ||
| 16 | + 表格右侧 | ||
| 17 | + */ | ||
| 18 | + var v:String? | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +// MARK: - 详情多图 | ||
| 22 | +class CNLiveGoodsDetailsContentModel: BaseModel { | ||
| 23 | + /** | ||
| 24 | + 详情图片id | ||
| 25 | + */ | ||
| 26 | + var id:String = "" | ||
| 27 | + /** | ||
| 28 | + 图片 | ||
| 29 | + */ | ||
| 30 | + var simg:String? | ||
| 31 | + /** | ||
| 32 | + 宽 | ||
| 33 | + */ | ||
| 34 | + var w:CGFloat = 0 | ||
| 35 | + /** | ||
| 36 | + 高 | ||
| 37 | + */ | ||
| 38 | + var h:CGFloat = 0 | ||
| 39 | + /** | ||
| 40 | + 失败次数>3不重新请求 | ||
| 41 | + */ | ||
| 42 | + var failureCount:CGFloat = 0 | ||
| 43 | + | ||
| 44 | +} | ||
| 45 | +// MARK: - banner多图 | ||
| 46 | +class CNLiveGoodsDetailsImageModel:BaseModel{ | ||
| 47 | + /** | ||
| 48 | + 图片id | ||
| 49 | + */ | ||
| 50 | + var id:String = "" | ||
| 51 | + /** | ||
| 52 | + 图片 | ||
| 53 | + */ | ||
| 54 | + var simg:String? | ||
| 55 | + /** | ||
| 56 | + 排序 | ||
| 57 | + */ | ||
| 58 | + var ord:String? | ||
| 59 | +} | ||
| 60 | +// MARK: - 视频模型 | ||
| 61 | +class CNLiveGoodsDetailsBannerVideosModel:BaseModel{ | ||
| 62 | + /** | ||
| 63 | + 视频 | ||
| 64 | + */ | ||
| 65 | + var video_url:String? | ||
| 66 | + /** | ||
| 67 | + 图片 | ||
| 68 | + */ | ||
| 69 | + var video_img:String? | ||
| 70 | + /** | ||
| 71 | + 图片(自己加的用于预览传) | ||
| 72 | + */ | ||
| 73 | + var video_image:UIImage? | ||
| 74 | +} | ||
| 75 | +// MARK: - 第一级 | ||
| 76 | +class CNLiveShopGoodsDetailsModel:BaseModel{ | ||
| 77 | + /** | ||
| 78 | + 商品id | ||
| 79 | + */ | ||
| 80 | + var id:String? | ||
| 81 | + /** | ||
| 82 | + 商家id | ||
| 83 | + */ | ||
| 84 | + var shopid:String? | ||
| 85 | + /** | ||
| 86 | + 货号 | ||
| 87 | + */ | ||
| 88 | + var code:String? | ||
| 89 | + | ||
| 90 | + /** | ||
| 91 | + 名称 | ||
| 92 | + */ | ||
| 93 | + var title:String? | ||
| 94 | + /** | ||
| 95 | + 广告语 | ||
| 96 | + */ | ||
| 97 | + var ads:String? | ||
| 98 | + /** | ||
| 99 | + 系列id | ||
| 100 | + */ | ||
| 101 | + var pid:String? | ||
| 102 | + /** | ||
| 103 | + 封面图 | ||
| 104 | + */ | ||
| 105 | + var simg:String? | ||
| 106 | + /** | ||
| 107 | + 销售价格 | ||
| 108 | + */ | ||
| 109 | + var price:String? | ||
| 110 | + /** | ||
| 111 | + 划去的价格 | ||
| 112 | + */ | ||
| 113 | + var prices:String? | ||
| 114 | + /** | ||
| 115 | + 店铺商品分类id,一级分类id | ||
| 116 | + */ | ||
| 117 | + var category_id:String? | ||
| 118 | + /** | ||
| 119 | + 店铺商品分类id,二级分类id | ||
| 120 | + */ | ||
| 121 | + var category_id2:String? | ||
| 122 | + /** | ||
| 123 | + 店铺商品分类名 | ||
| 124 | + */ | ||
| 125 | + var cate_name:String? | ||
| 126 | + /** | ||
| 127 | + 平台分类id 1级 | ||
| 128 | + */ | ||
| 129 | + var groupid:String? | ||
| 130 | + /** | ||
| 131 | + 平台分类id 2级 | ||
| 132 | + */ | ||
| 133 | + var groupid2:String? | ||
| 134 | + /** | ||
| 135 | + 平台分类id 3级 | ||
| 136 | + */ | ||
| 137 | + var groupid3:String? | ||
| 138 | + /** | ||
| 139 | + 1/2/3级分类名称合并 | ||
| 140 | + */ | ||
| 141 | + var group_name:String? | ||
| 142 | + /** | ||
| 143 | + 可销售库存 | ||
| 144 | + */ | ||
| 145 | + var count:String? | ||
| 146 | + /** | ||
| 147 | + banner图片数组 | ||
| 148 | + */ | ||
| 149 | + var image = [CNLiveGoodsDetailsImageModel]() | ||
| 150 | + /** | ||
| 151 | + 详情图片数组 | ||
| 152 | + */ | ||
| 153 | + var detail_img = [CNLiveGoodsDetailsContentModel]() | ||
| 154 | + /** | ||
| 155 | + 当前选择 | ||
| 156 | + */ | ||
| 157 | + var attr = [CNLiveGoodsDetailsAttrModel]() | ||
| 158 | + /** | ||
| 159 | + 预览当前选择 | ||
| 160 | + */ | ||
| 161 | + var attrArray = [Dictionary<String, Any>]() | ||
| 162 | + /** | ||
| 163 | + 赠送礼物入口图片 | ||
| 164 | + */ | ||
| 165 | + var give_goods_img:String? | ||
| 166 | + /** | ||
| 167 | + 商品删除 | ||
| 168 | + */ | ||
| 169 | + var is_del:String? | ||
| 170 | + /** | ||
| 171 | + 是否开启赠送礼物 1开启 0关闭 | ||
| 172 | + */ | ||
| 173 | + var is_gift:Bool? | ||
| 174 | + /** | ||
| 175 | + banner第一个视频 | ||
| 176 | + */ | ||
| 177 | + var video:CNLiveGoodsDetailsBannerVideosModel? | ||
| 178 | + /** | ||
| 179 | + 重量 | ||
| 180 | + */ | ||
| 181 | + var kg:String? | ||
| 182 | + /** | ||
| 183 | + 运费 | ||
| 184 | + */ | ||
| 185 | + var yunfei:String? | ||
| 186 | + /** | ||
| 187 | + 1不可退 0可退 | ||
| 188 | + */ | ||
| 189 | + var is_refund:Int = 0 | ||
| 190 | + /** | ||
| 191 | + 状态 2上架 1下架 | ||
| 192 | + */ | ||
| 193 | + var state:Int = 0 | ||
| 194 | + /** | ||
| 195 | + 单位 | ||
| 196 | + */ | ||
| 197 | + var unit:String? | ||
| 198 | + /** | ||
| 199 | + 规格 | ||
| 200 | + */ | ||
| 201 | + var storage:String? | ||
| 202 | + /** | ||
| 203 | + 规格 | ||
| 204 | + */ | ||
| 205 | + var storage_arr:String? | ||
| 206 | + /** | ||
| 207 | + 最小购买数 | ||
| 208 | + */ | ||
| 209 | + var min_buy_num:String? | ||
| 210 | + /** | ||
| 211 | + 规格所有参数 @{@"k":@"品名",@"v":@"商品名"} | ||
| 212 | + */ | ||
| 213 | + var storageArray = [Dictionary<String, Any>]() | ||
| 214 | + | ||
| 215 | +} |