Commit f361af6ce1d08ffa1b4648b24999eaa35faffeb8
1 parent
50ede8bb
编辑商品 - 删除
Showing
6 changed files
with
136 additions
and
78 deletions
metaCode/Classes/Main/HomePage/Controller/GoodsManager/CNLiveGoodsCategoryController.swift
| @@ -201,8 +201,6 @@ class CNLiveGoodsCategoryController: CNLiveBaseViewController, UITableViewDataSo | @@ -201,8 +201,6 @@ class CNLiveGoodsCategoryController: CNLiveBaseViewController, UITableViewDataSo | ||
| 201 | self.postShopClassify() | 201 | self.postShopClassify() |
| 202 | } | 202 | } |
| 203 | } | 203 | } |
| 204 | - | ||
| 205 | - | ||
| 206 | // MARK: - initUI | 204 | // MARK: - initUI |
| 207 | func initUI(){ | 205 | func initUI(){ |
| 208 | self.shadowView = UIView(frame: self.view.bounds) | 206 | self.shadowView = UIView(frame: self.view.bounds) |
metaCode/Classes/Main/HomePage/Controller/GoodsManager/CNLiveShopNewProductController.swift
| @@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
| 6 | // 新增商品 | 6 | // 新增商品 |
| 7 | 7 | ||
| 8 | import Foundation | 8 | import Foundation |
| 9 | - | 9 | +import HandyJSON |
| 10 | /// | 10 | /// |
| 11 | enum CNLiveShopGoodsAddEditType{ | 11 | enum CNLiveShopGoodsAddEditType{ |
| 12 | 12 | ||
| @@ -39,9 +39,66 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | @@ -39,9 +39,66 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | ||
| 39 | let shopGoodsDetailsModel = CNLiveShopGoodsDetailsModel() | 39 | let shopGoodsDetailsModel = CNLiveShopGoodsDetailsModel() |
| 40 | return shopGoodsDetailsModel | 40 | return shopGoodsDetailsModel |
| 41 | }() | 41 | }() |
| 42 | - var selectCategoryVC:CNLiveGoodsCategoryController? | 42 | + |
| 43 | + var _selectCategoryVC:CNLiveGoodsCategoryController? | ||
| 44 | + var selectCategoryVC:CNLiveGoodsCategoryController?{ | ||
| 45 | + get{ | ||
| 46 | + if _selectCategoryVC == nil{ | ||
| 47 | + let vc = CNLiveGoodsCategoryController() | ||
| 48 | + vc.categoryType = .goods | ||
| 49 | + if self.shopGoodsDetailsModel.id?.count ?? 0 > 0{ | ||
| 50 | + vc.firCategoryId = self.shopGoodsDetailsModel.groupid | ||
| 51 | + vc.secCategoryId = self.shopGoodsDetailsModel.groupid2 | ||
| 52 | + vc.thiCategoryId = self.shopGoodsDetailsModel.groupid3 | ||
| 53 | + } | ||
| 54 | + vc.finishBlock = { | ||
| 55 | + //商品分类 | ||
| 56 | + let singleView1 = self.bgScrollView.viewWithTag(1) as! CNLiveShopAddGoodsSingleView | ||
| 57 | + singleView1.contentTextField.text = "\(self.selectCategoryVC?.firCategoryName ?? "") \(self.selectCategoryVC?.secCategoryName ?? "")" | ||
| 58 | + singleView1.layoutSubviews() | ||
| 59 | + } | ||
| 60 | + self.addChild(vc) | ||
| 61 | + vc.view.frame = CGRect(x: 0, y: KNavigationHeight, width: self.view.width, height: self.view.height-KNavigationHeight) | ||
| 62 | + vc.didMove(toParent: self) | ||
| 63 | + self.view.addSubview(vc.view) | ||
| 64 | + _selectCategoryVC = vc | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + return _selectCategoryVC | ||
| 68 | + } | ||
| 69 | + set{ | ||
| 70 | + | ||
| 71 | + _selectCategoryVC = newValue | ||
| 72 | + | ||
| 73 | + } | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + // lazy var selectCategoryVC :CNLiveGoodsCategoryController = { | ||
| 77 | +// let vc = CNLiveGoodsCategoryController() | ||
| 78 | +// vc.categoryType = .goods | ||
| 79 | +// if self.shopGoodsDetailsModel.id?.count ?? 0 > 0{ | ||
| 80 | +// vc.firCategoryId = self.shopGoodsDetailsModel.groupid | ||
| 81 | +// vc.secCategoryId = self.shopGoodsDetailsModel.groupid2 | ||
| 82 | +// vc.thiCategoryId = self.shopGoodsDetailsModel.groupid3 | ||
| 83 | +// } | ||
| 84 | +// vc.finishBlock = { | ||
| 85 | +// //商品分类 | ||
| 86 | +// let singleView1 = self.bgScrollView.viewWithTag(1) as! CNLiveShopAddGoodsSingleView | ||
| 87 | +// singleView1.contentTextField.text = "\(self.selectCategoryVC.firCategoryName ?? "") \(self.selectCategoryVC.secCategoryName ?? "")" | ||
| 88 | +// singleView1.layoutSubviews() | ||
| 89 | +// } | ||
| 90 | +//// self.addChild(vc) | ||
| 91 | +//// vc.view.frame = CGRect(x: 0, y: 0, width: self.view.width, height: self.view.height) | ||
| 92 | +//// vc.didMove(toParent: self) | ||
| 93 | +//// self.view.addSubview(vc.view) | ||
| 94 | +// self.selectCategoryVC = vc | ||
| 95 | +// | ||
| 96 | +// return selectCategoryVC | ||
| 97 | +// }() | ||
| 98 | + | ||
| 43 | 99 | ||
| 44 | lazy var selectShopClassifyVC:CNLiveGoodsCategoryController = { | 100 | lazy var selectShopClassifyVC:CNLiveGoodsCategoryController = { |
| 101 | + | ||
| 45 | let vc = CNLiveGoodsCategoryController() | 102 | let vc = CNLiveGoodsCategoryController() |
| 46 | 103 | ||
| 47 | vc.categoryType = .shop | 104 | vc.categoryType = .shop |
| @@ -87,15 +144,18 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | @@ -87,15 +144,18 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | ||
| 87 | self.bgScrollView.frame = CGRect(x: 0, y: KNavigationHeight, width: KSreenWidth, height: KSreenHeight-KNavigationHeight-KTabBarHeight) | 144 | self.bgScrollView.frame = CGRect(x: 0, y: KNavigationHeight, width: KSreenWidth, height: KSreenHeight-KNavigationHeight-KTabBarHeight) |
| 88 | var lastView:UIView? = nil | 145 | var lastView:UIView? = nil |
| 89 | for i in 0..<self.dataModel.list.count{ | 146 | for i in 0..<self.dataModel.list.count{ |
| 90 | - let singleView = self.view.viewWithTag(i+1) as! CNLiveShopAddGoodsSingleView | ||
| 91 | - singleView.frame = CGRect(x: 0, y: lastView?.bottom ?? 0, width: self.bgScrollView.width, height: singleView.height) | ||
| 92 | - if i+1 == 15{ | ||
| 93 | - singleView.frame = CGRect(x: 0, y: lastView?.bottom ?? 0, width: self.bgScrollView.width, height: 0.001) | 147 | + if let singleView = self.view.viewWithTag(i+1) as? CNLiveShopAddGoodsSingleView{ |
| 148 | + singleView.frame = CGRect(x: 0, y: lastView?.bottom ?? 0, width: self.bgScrollView.width, height: singleView.height) | ||
| 149 | + if i+1 == 15{ | ||
| 150 | + singleView.frame = CGRect(x: 0, y: lastView?.bottom ?? 0, width: self.bgScrollView.width, height: 0.001) | ||
| 151 | + } | ||
| 152 | + lastView = singleView | ||
| 153 | + }else{ | ||
| 154 | + | ||
| 94 | } | 155 | } |
| 95 | - lastView = singleView | ||
| 96 | } | 156 | } |
| 97 | self.bgScrollView.contentSize = CGSize(width: self.bgScrollView.width, height: lastView?.bottom ?? 0) | 157 | self.bgScrollView.contentSize = CGSize(width: self.bgScrollView.width, height: lastView?.bottom ?? 0) |
| 98 | - self.selectCategoryVC?.view.frame = CGRect(x: 0, y: 0, width: self.view.width, height: self.view.height) | 158 | + self.selectCategoryVC!.view.frame = CGRect(x: 0, y: KNavigationHeight, width: self.view.width, height: self.view.height-KNavigationHeight) |
| 99 | } | 159 | } |
| 100 | 160 | ||
| 101 | deinit { | 161 | deinit { |
| @@ -120,7 +180,6 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | @@ -120,7 +180,6 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | ||
| 120 | deleteNavBtn.setTitleColor(HexColor("#FC1541"), for: .normal) | 180 | deleteNavBtn.setTitleColor(HexColor("#FC1541"), for: .normal) |
| 121 | deleteNavBtn.addTarget(self, action: #selector(deleteNavBtnClick), for: .touchUpInside) | 181 | deleteNavBtn.addTarget(self, action: #selector(deleteNavBtnClick), for: .touchUpInside) |
| 122 | self.rightNavBtns = [deleteNavBtn] | 182 | self.rightNavBtns = [deleteNavBtn] |
| 123 | - | ||
| 124 | } | 183 | } |
| 125 | 184 | ||
| 126 | self.initBottomView() | 185 | self.initBottomView() |
| @@ -265,27 +324,11 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | @@ -265,27 +324,11 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | ||
| 265 | 324 | ||
| 266 | // MARK: - 显示选取分类界面 | 325 | // MARK: - 显示选取分类界面 |
| 267 | func displaySelectCategoryVC(){ | 326 | func displaySelectCategoryVC(){ |
| 268 | - if self.selectCategoryVC == nil{ | ||
| 269 | - let vc = CNLiveGoodsCategoryController() | ||
| 270 | - vc.categoryType = .goods | ||
| 271 | - if self.shopGoodsDetailsModel.id?.count ?? 0 > 0{ | ||
| 272 | - vc.firCategoryId = self.shopGoodsDetailsModel.groupid | ||
| 273 | - vc.secCategoryId = self.shopGoodsDetailsModel.groupid2 | ||
| 274 | - vc.thiCategoryId = self.shopGoodsDetailsModel.groupid3 | ||
| 275 | - } | ||
| 276 | - vc.finishBlock = { | ||
| 277 | - //商品分类 | ||
| 278 | - let singleView1 = self.bgScrollView.viewWithTag(1) as! CNLiveShopAddGoodsSingleView | ||
| 279 | - singleView1.contentTextField.text = "\(self.selectCategoryVC?.firCategoryName ?? "") \(self.selectCategoryVC?.secCategoryName ?? "")" | ||
| 280 | - singleView1.layoutSubviews() | ||
| 281 | - } | ||
| 282 | - self.addChild(vc) | ||
| 283 | - vc.view.frame = CGRect(x: 0, y: 0, width: self.view.width, height: self.view.height) | ||
| 284 | - vc.didMove(toParent: self) | ||
| 285 | - self.view.addSubview(vc.view) | ||
| 286 | - self.selectCategoryVC = vc | ||
| 287 | - } | ||
| 288 | - self.selectCategoryVC?.display() | 327 | +// self.addChild(self.selectCategoryVC!) |
| 328 | +// self.selectCategoryVC!.view.frame = CGRect(x: 0, y: 0, width: self.view.width, height: self.view.height) | ||
| 329 | +// self.selectCategoryVC!.didMove(toParent: self) | ||
| 330 | +// self.view.addSubview(self.selectCategoryVC!.view) | ||
| 331 | + self.selectCategoryVC!.display() | ||
| 289 | } | 332 | } |
| 290 | 333 | ||
| 291 | // MARK: - 获取店铺分类view | 334 | // MARK: - 获取店铺分类view |
| @@ -316,7 +359,8 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | @@ -316,7 +359,8 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | ||
| 316 | // MARK: - BtnAction | 359 | // MARK: - BtnAction |
| 317 | @objc func deleteNavBtnClick(){ | 360 | @objc func deleteNavBtnClick(){ |
| 318 | AlertTool.showSystemAlert(title: "确认删除?", message: nil, actionTitles: ["取消","确定"], style: .alert, actionStyles:[.cancel,.default] ) { index in | 361 | AlertTool.showSystemAlert(title: "确认删除?", message: nil, actionTitles: ["取消","确定"], style: .alert, actionStyles:[.cancel,.default] ) { index in |
| 319 | - if (index == 1) { | 362 | + //1取消 2确定 |
| 363 | + if (index == 2) { | ||
| 320 | showLoading(message: "") | 364 | showLoading(message: "") |
| 321 | CNLiveShopGoodListViewModel.postChangeGoodsStateWithGoodsId(goodsId: self.goodsId, state: "3") { result, status in | 365 | CNLiveShopGoodListViewModel.postChangeGoodsStateWithGoodsId(goodsId: self.goodsId, state: "3") { result, status in |
| 322 | hiddenLoading() | 366 | hiddenLoading() |
| @@ -331,7 +375,6 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | @@ -331,7 +375,6 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | ||
| 331 | } | 375 | } |
| 332 | } | 376 | } |
| 333 | } | 377 | } |
| 334 | - | ||
| 335 | @objc func previewBtnClick(){ | 378 | @objc func previewBtnClick(){ |
| 336 | 379 | ||
| 337 | //商品轮播 | 380 | //商品轮播 |
| @@ -496,7 +539,7 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | @@ -496,7 +539,7 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | ||
| 496 | contentDetailsImageStr = contentDetailsImageStr.replacingOccurrences(of: "\\", with: "") | 539 | contentDetailsImageStr = contentDetailsImageStr.replacingOccurrences(of: "\\", with: "") |
| 497 | contentDetailsImageStr = contentDetailsImageStr.replacingOccurrences(of: " ", with: "") | 540 | contentDetailsImageStr = contentDetailsImageStr.replacingOccurrences(of: " ", with: "") |
| 498 | } catch _ {} | 541 | } catch _ {} |
| 499 | - if self.type == .add && self.selectCategoryVC?.thiCategoryId == 0{ | 542 | + if self.type == .add && self.selectCategoryVC!.thiCategoryId == 0{ |
| 500 | showMessage(message: "请选择商品分类") | 543 | showMessage(message: "请选择商品分类") |
| 501 | return | 544 | return |
| 502 | }else if self.selectShopClassifyVC.firCategoryId == 0{ | 545 | }else if self.selectShopClassifyVC.firCategoryId == 0{ |
| @@ -593,7 +636,7 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | @@ -593,7 +636,7 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | ||
| 593 | } | 636 | } |
| 594 | showLoading(message: "") | 637 | showLoading(message: "") |
| 595 | if self.type == .add{ | 638 | if self.type == .add{ |
| 596 | - CNLiveShopGoodListViewModel.postGoodsAddWithUid(uid: DSUserInfoManager.shared.dsUserInfo.uid!, groupid3: self.selectCategoryVC?.thiCategoryId != 0 ? String(format: "%d", self.selectCategoryVC?.thiCategoryId ?? 0) : "", 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: String(format: "%d", category_id)) { result, status in | 639 | + CNLiveShopGoodListViewModel.postGoodsAddWithUid(uid: DSUserInfoManager.shared.dsUserInfo.uid!, groupid3: self.selectCategoryVC!.thiCategoryId != 0 ? String(format: "%d", 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: String(format: "%d", category_id)) { result, status in |
| 597 | hiddenLoading() | 640 | hiddenLoading() |
| 598 | if status == .failed{ | 641 | if status == .failed{ |
| 599 | showMessage(message: "发布失败") | 642 | showMessage(message: "发布失败") |
| @@ -612,8 +655,21 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | @@ -612,8 +655,21 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | ||
| 612 | } | 655 | } |
| 613 | } | 656 | } |
| 614 | }else{ | 657 | }else{ |
| 615 | - CNLiveShopGoodListViewModel.postGoodsAddWithUid(uid: DSUserInfoManager.shared.dsUserInfo.uid!, groupid3:self.selectCategoryVC?.thiCategoryId != 0 ? String(format: "%d", self.selectCategoryVC?.thiCategoryId ?? 0) : "" , 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: String(format: "%d", category_id)) { result, status in | ||
| 616 | - hiddenLoading() | 658 | + //编辑 |
| 659 | + var kvArrayJSONStr = "" | ||
| 660 | + do { | ||
| 661 | + let jsonData = try JSONSerialization.data(withJSONObject: kvArray) // 将数组转换为JSON格式的NSData对象 | ||
| 662 | + | ||
| 663 | + if let jsonString = String(data: jsonData, encoding: .utf8) { | ||
| 664 | + print("转换后的JSON字符串:\n\(jsonString)") | ||
| 665 | + kvArrayJSONStr = jsonString | ||
| 666 | + } else { | ||
| 667 | + print("无法将JSON数据转换为字符串") | ||
| 668 | + } | ||
| 669 | + } catch { | ||
| 670 | + print("发生错误:\(error)") | ||
| 671 | + } | ||
| 672 | + CNLiveShopGoodListViewModel.postGoodsEditWithGoodsId(goodsId: self.goodsId, uid: DSUserInfoManager.shared.dsUserInfo.uid!, 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: kvArrayJSONStr, infoImg: contentDetailsImageStr, yunfei: singleView14.contentTextField.text ?? "", min_count: singleView10.countTF.text ?? "", isRefund: "0", category_id: String(format: "%d", category_id)) { result, status in | ||
| 617 | if status == .failed{ | 673 | if status == .failed{ |
| 618 | showMessage(message: "修改失败") | 674 | showMessage(message: "修改失败") |
| 619 | return | 675 | return |
| @@ -622,9 +678,10 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | @@ -622,9 +678,10 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | ||
| 622 | showMessage(message: "修改成功") | 678 | showMessage(message: "修改成功") |
| 623 | NotificationCenter.default.post(name: NSNotification.Name.ShopGoodsManage.kDSGoodsManageEditNotification, object: nil, userInfo: (result as! Dictionary)) | 679 | NotificationCenter.default.post(name: NSNotification.Name.ShopGoodsManage.kDSGoodsManageEditNotification, object: nil, userInfo: (result as! Dictionary)) |
| 624 | for i in 0..<self.dataModel.list.count{ | 680 | for i in 0..<self.dataModel.list.count{ |
| 625 | - let singleView = self.view.viewWithTag(i+1) as! CNLiveShopAddGoodsSingleView | ||
| 626 | - if singleView.addEditGoodsListModel?.style == "3"{ | ||
| 627 | - singleView.uploadImageView.deleteReplaceImageUrlAfterSuccessUploadThings() | 681 | + if let singleView = self.view.viewWithTag(i+1) as? CNLiveShopAddGoodsSingleView{ |
| 682 | + if singleView.addEditGoodsListModel?.style == "3"{ | ||
| 683 | + singleView.uploadImageView.deleteReplaceImageUrlAfterSuccessUploadThings() | ||
| 684 | + } | ||
| 628 | } | 685 | } |
| 629 | } | 686 | } |
| 630 | self.navigationController?.popViewController(animated: true) | 687 | self.navigationController?.popViewController(animated: true) |
| @@ -683,6 +740,7 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | @@ -683,6 +740,7 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ | ||
| 683 | if status == .success{ | 740 | if status == .success{ |
| 684 | let model = result as! CNLiveShopGoodsDetailsModel | 741 | let model = result as! CNLiveShopGoodsDetailsModel |
| 685 | self.shopGoodsDetailsModel = model | 742 | self.shopGoodsDetailsModel = model |
| 743 | + let thiCategoryId = self.selectCategoryVC!.thiCategoryId | ||
| 686 | //商品分类 | 744 | //商品分类 |
| 687 | let singleView1 = self.bgScrollView.viewWithTag(1) as! CNLiveShopAddGoodsSingleView | 745 | let singleView1 = self.bgScrollView.viewWithTag(1) as! CNLiveShopAddGoodsSingleView |
| 688 | //店铺分类 | 746 | //店铺分类 |
metaCode/Classes/Main/HomePage/Controller/GoodsManager/CNLiveShopProductManagerController.swift
| @@ -302,8 +302,8 @@ class CNLiveShopProductManagerController:CNLiveBaseViewController, UITableViewDa | @@ -302,8 +302,8 @@ class CNLiveShopProductManagerController:CNLiveBaseViewController, UITableViewDa | ||
| 302 | } | 302 | } |
| 303 | @objc func goodsManageEditNotification(notification:Notification){ | 303 | @objc func goodsManageEditNotification(notification:Notification){ |
| 304 | let dict = (notification.userInfo ?? ["":""]) as! [String :Any] | 304 | let dict = (notification.userInfo ?? ["":""]) as! [String :Any] |
| 305 | - let nModel = newDictionaryToModel(dict, CNLiveShopGoodsListModel.self) as! CNLiveShopGoodsListModel | ||
| 306 | - var dataArr = Array(self.dataArray) | 305 | + let nModel = newDictionaryToModel(dict["data"] as! [String : Any], CNLiveShopGoodsListModel.self) as! CNLiveShopGoodsListModel |
| 306 | + let dataArr = Array(self.dataArray) | ||
| 307 | 307 | ||
| 308 | for (idx,mdl) in dataArr.enumerated() { | 308 | for (idx,mdl) in dataArr.enumerated() { |
| 309 | let model = mdl as! CNLiveShopGoodsListModel | 309 | let model = mdl as! CNLiveShopGoodsListModel |
| @@ -318,7 +318,7 @@ class CNLiveShopProductManagerController:CNLiveBaseViewController, UITableViewDa | @@ -318,7 +318,7 @@ class CNLiveShopProductManagerController:CNLiveBaseViewController, UITableViewDa | ||
| 318 | model.state = nModel.state | 318 | model.state = nModel.state |
| 319 | model.count = nModel.count | 319 | model.count = nModel.count |
| 320 | model.ord = nModel.ord | 320 | model.ord = nModel.ord |
| 321 | - self.dataArray.replaceObject(at: idx, with: nModel) | 321 | + self.dataArray.replaceObject(at: idx, with: model) |
| 322 | self.tableView.reloadData() | 322 | self.tableView.reloadData() |
| 323 | break | 323 | break |
| 324 | } | 324 | } |
| @@ -351,12 +351,12 @@ class CNLiveShopProductManagerController:CNLiveBaseViewController, UITableViewDa | @@ -351,12 +351,12 @@ class CNLiveShopProductManagerController:CNLiveBaseViewController, UITableViewDa | ||
| 351 | 351 | ||
| 352 | if self.pageNum == 1 { | 352 | if self.pageNum == 1 { |
| 353 | self.dataArray.removeAllObjects() | 353 | self.dataArray.removeAllObjects() |
| 354 | - self.dataArray.addObjects(from: result as! [CNLiveShopGoodsListModel]) | 354 | + self.dataArray.addObjects(from: arr) |
| 355 | if (self.dataArray.count > 0 && self.tableView.mj_header == nil && self.tableView.mj_footer == nil) { | 355 | if (self.dataArray.count > 0 && self.tableView.mj_header == nil && self.tableView.mj_footer == nil) { |
| 356 | self.addRefreshView() | 356 | self.addRefreshView() |
| 357 | } | 357 | } |
| 358 | }else if self.pageNum > 1 { | 358 | }else if self.pageNum > 1 { |
| 359 | - self.dataArray.addObjects(from: result as! [CNLiveShopGoodsListModel]) | 359 | + self.dataArray.addObjects(from: arr) |
| 360 | } | 360 | } |
| 361 | self.tableView.reloadData() | 361 | self.tableView.reloadData() |
| 362 | self.tableView.mj_header?.endRefreshing() | 362 | self.tableView.mj_header?.endRefreshing() |
metaCode/Classes/Main/HomePage/View/CNMainView.swift
| @@ -170,7 +170,7 @@ class CNFrontMainView : UIView{ | @@ -170,7 +170,7 @@ class CNFrontMainView : UIView{ | ||
| 170 | frontCardContentView.isHidden = true | 170 | frontCardContentView.isHidden = true |
| 171 | //显示textview 添加身份 | 171 | //显示textview 添加身份 |
| 172 | frontDescContentView.isHidden = false | 172 | frontDescContentView.isHidden = false |
| 173 | - textView.text = newValue!.descriptions | 173 | + textView.text = newValue!.description |
| 174 | addStandBtn.backgroundColor = HexColor(newValue!.backgroundColor) | 174 | addStandBtn.backgroundColor = HexColor(newValue!.backgroundColor) |
| 175 | textViewBgImgView.kf.setImage(with: URL(string: _idModel!.descBackgroundImg), placeholder: UIImage(named: "homepage_desc_bgImg")) | 175 | textViewBgImgView.kf.setImage(with: URL(string: _idModel!.descBackgroundImg), placeholder: UIImage(named: "homepage_desc_bgImg")) |
| 176 | } | 176 | } |
metaCode/Classes/Main/HomePage/ViewModel/GoodsManager/CNLiveShopGoodListViewModel.swift
| @@ -93,7 +93,8 @@ class CNLiveShopGoodListViewModel:NSObject{ | @@ -93,7 +93,8 @@ class CNLiveShopGoodListViewModel:NSObject{ | ||
| 93 | CNLiveNetworking.setupDSRequest(true) | 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 | 94 | CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseWjjBUrl+"/api/v1/goodsAdd", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in |
| 95 | hiddenLoading() | 95 | hiddenLoading() |
| 96 | - if (error == nil) { | 96 | + let res = (result as! Dictionary<String, Any>)["code"] as! String |
| 97 | + if (error == nil && (res == "200" || res == "0")) { | ||
| 97 | resultBlock(result as Any,.success) | 98 | resultBlock(result as Any,.success) |
| 98 | }else{ | 99 | }else{ |
| 99 | resultBlock(NSNull(),.failed) | 100 | resultBlock(NSNull(),.failed) |
| @@ -101,33 +102,6 @@ class CNLiveShopGoodListViewModel:NSObject{ | @@ -101,33 +102,6 @@ class CNLiveShopGoodListViewModel:NSObject{ | ||
| 101 | } | 102 | } |
| 102 | } | 103 | } |
| 103 | 104 | ||
| 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 respDic = result as! NSDictionary | ||
| 122 | - let resp = respDic["data"] as! NSDictionary | ||
| 123 | - let model = newDictionaryToModel(resp as! [String : Any], CNLiveShopGoodsDetailsModel.self) as! CNLiveShopGoodsDetailsModel | ||
| 124 | - resultBlock(model,.success) | ||
| 125 | - }else{ | ||
| 126 | - resultBlock(NSNull(),.failed) | ||
| 127 | - } | ||
| 128 | - } | ||
| 129 | - } | ||
| 130 | - | ||
| 131 | /// 商品修改 | 105 | /// 商品修改 |
| 132 | /// @param goodsId 商品id | 106 | /// @param goodsId 商品id |
| 133 | /// @param uid 用户id | 107 | /// @param uid 用户id |
| @@ -148,8 +122,8 @@ class CNLiveShopGoodListViewModel:NSObject{ | @@ -148,8 +122,8 @@ class CNLiveShopGoodListViewModel:NSObject{ | ||
| 148 | /// @param isRefund 是否可退 0可以退 1不可退 | 122 | /// @param isRefund 是否可退 0可以退 1不可退 |
| 149 | /// @param category_id 店铺分类id,选中了二级分类,传二级分类的id,没选二级分类就传一级分类的id | 123 | /// @param category_id 店铺分类id,选中了二级分类,传二级分类的id,没选二级分类就传一级分类的id |
| 150 | /// @param result 结果 | 124 | /// @param result 结果 |
| 125 | + /// | ||
| 151 | 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){ | 126 | 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){ |
| 152 | - | ||
| 153 | let param = NSMutableDictionary() | 127 | let param = NSMutableDictionary() |
| 154 | param.setValue(goodsId, forKey: "id") | 128 | param.setValue(goodsId, forKey: "id") |
| 155 | param.setValue(uid, forKey: "uid") | 129 | param.setValue(uid, forKey: "uid") |
| @@ -175,7 +149,8 @@ class CNLiveShopGoodListViewModel:NSObject{ | @@ -175,7 +149,8 @@ class CNLiveShopGoodListViewModel:NSObject{ | ||
| 175 | CNLiveNetworking.setupDSRequest(true) | 149 | CNLiveNetworking.setupDSRequest(true) |
| 176 | CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseWjjBUrl+"/api/v1/goodsEdit", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in | 150 | CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseWjjBUrl+"/api/v1/goodsEdit", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in |
| 177 | hiddenLoading() | 151 | hiddenLoading() |
| 178 | - if (error == nil) { | 152 | + let res = (result as! Dictionary<String, Any>)["code"] as! String |
| 153 | + if (error == nil && (res == "200" || res == "0")) { | ||
| 179 | resultBlock(result as Any,.success) | 154 | resultBlock(result as Any,.success) |
| 180 | }else{ | 155 | }else{ |
| 181 | resultBlock(NSNull(),.failed) | 156 | resultBlock(NSNull(),.failed) |
| @@ -183,6 +158,33 @@ class CNLiveShopGoodListViewModel:NSObject{ | @@ -183,6 +158,33 @@ class CNLiveShopGoodListViewModel:NSObject{ | ||
| 183 | } | 158 | } |
| 184 | } | 159 | } |
| 185 | 160 | ||
| 161 | + // MARK: - 商品详情 | ||
| 162 | + /** | ||
| 163 | + 商品详情 | ||
| 164 | + | ||
| 165 | + @param goodsId 商品id | ||
| 166 | + @param result 结果 | ||
| 167 | + */ | ||
| 168 | + static func getGoodsInfoWithGoodsId(goodsId:String,resultBlock: @escaping categoryResultBlock){ | ||
| 169 | + let param = NSMutableDictionary() | ||
| 170 | + param.setValue(goodsId, forKey: "id") | ||
| 171 | + | ||
| 172 | + CNLiveNetworking.setAllowRequestDefaultArgument(true) | ||
| 173 | + CNLiveNetworking.setupShowDataResult(false) | ||
| 174 | + CNLiveNetworking.setupDSRequest(true) | ||
| 175 | + CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseWjjBUrl+"/api/v1/goodsInfo", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in | ||
| 176 | + hiddenLoading() | ||
| 177 | + if (error == nil) { | ||
| 178 | + let respDic = result as! NSDictionary | ||
| 179 | + let resp = respDic["data"] as! NSDictionary | ||
| 180 | + let model = newDictionaryToModel(resp as! [String : Any], CNLiveShopGoodsDetailsModel.self) as! CNLiveShopGoodsDetailsModel | ||
| 181 | + resultBlock(model,.success) | ||
| 182 | + }else{ | ||
| 183 | + resultBlock(NSNull(),.failed) | ||
| 184 | + } | ||
| 185 | + } | ||
| 186 | + } | ||
| 187 | + | ||
| 186 | /// 商品单个属性修改 | 188 | /// 商品单个属性修改 |
| 187 | /// @param shopId 商家id | 189 | /// @param shopId 商家id |
| 188 | /// @param goodsId 商品id | 190 | /// @param goodsId 商品id |
metaCode/Classes/Main/MinePage/ViewModel/CNLiveMineBaseModel.swift
| @@ -143,7 +143,7 @@ final class StandListModel: BaseModel {//, TableCodable { | @@ -143,7 +143,7 @@ final class StandListModel: BaseModel {//, TableCodable { | ||
| 143 | var backgroundImg: String = ""//首页背景图- | 143 | var backgroundImg: String = ""//首页背景图- |
| 144 | var backgroundColor: String = ""//添加身份按钮背景色- | 144 | var backgroundColor: String = ""//添加身份按钮背景色- |
| 145 | var backgroundColour: String = ""//- | 145 | var backgroundColour: String = ""//- |
| 146 | - var descriptions: String = ""//首页身份说明描述- | 146 | + var description: String = ""//首页身份说明描述- |
| 147 | var descBackgroundImg: String = ""//首页文字背景图 | 147 | var descBackgroundImg: String = ""//首页文字背景图 |
| 148 | var cardImg: String = ""//卡片背景图- | 148 | var cardImg: String = ""//卡片背景图- |
| 149 | var cardBackgroundImg: String = ""//首页卡片背景图 | 149 | var cardBackgroundImg: String = ""//首页卡片背景图 |