Commit f361af6ce1d08ffa1b4648b24999eaa35faffeb8
1 parent
50ede8bb
编辑商品 - 删除
Showing
6 changed files
with
136 additions
and
78 deletions
metaCode/Classes/Main/HomePage/Controller/GoodsManager/CNLiveGoodsCategoryController.swift
metaCode/Classes/Main/HomePage/Controller/GoodsManager/CNLiveShopNewProductController.swift
| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | // 新增商品 |
| 7 | 7 | |
| 8 | 8 | import Foundation |
| 9 | - | |
| 9 | +import HandyJSON | |
| 10 | 10 | /// |
| 11 | 11 | enum CNLiveShopGoodsAddEditType{ |
| 12 | 12 | |
| ... | ... | @@ -39,9 +39,66 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ |
| 39 | 39 | let shopGoodsDetailsModel = CNLiveShopGoodsDetailsModel() |
| 40 | 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 | 100 | lazy var selectShopClassifyVC:CNLiveGoodsCategoryController = { |
| 101 | + | |
| 45 | 102 | let vc = CNLiveGoodsCategoryController() |
| 46 | 103 | |
| 47 | 104 | vc.categoryType = .shop |
| ... | ... | @@ -87,15 +144,18 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ |
| 87 | 144 | self.bgScrollView.frame = CGRect(x: 0, y: KNavigationHeight, width: KSreenWidth, height: KSreenHeight-KNavigationHeight-KTabBarHeight) |
| 88 | 145 | var lastView:UIView? = nil |
| 89 | 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 | 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 | 161 | deinit { |
| ... | ... | @@ -120,7 +180,6 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ |
| 120 | 180 | deleteNavBtn.setTitleColor(HexColor("#FC1541"), for: .normal) |
| 121 | 181 | deleteNavBtn.addTarget(self, action: #selector(deleteNavBtnClick), for: .touchUpInside) |
| 122 | 182 | self.rightNavBtns = [deleteNavBtn] |
| 123 | - | |
| 124 | 183 | } |
| 125 | 184 | |
| 126 | 185 | self.initBottomView() |
| ... | ... | @@ -265,27 +324,11 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ |
| 265 | 324 | |
| 266 | 325 | // MARK: - 显示选取分类界面 |
| 267 | 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 | 334 | // MARK: - 获取店铺分类view |
| ... | ... | @@ -316,7 +359,8 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ |
| 316 | 359 | // MARK: - BtnAction |
| 317 | 360 | @objc func deleteNavBtnClick(){ |
| 318 | 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 | 364 | showLoading(message: "") |
| 321 | 365 | CNLiveShopGoodListViewModel.postChangeGoodsStateWithGoodsId(goodsId: self.goodsId, state: "3") { result, status in |
| 322 | 366 | hiddenLoading() |
| ... | ... | @@ -331,7 +375,6 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ |
| 331 | 375 | } |
| 332 | 376 | } |
| 333 | 377 | } |
| 334 | - | |
| 335 | 378 | @objc func previewBtnClick(){ |
| 336 | 379 | |
| 337 | 380 | //商品轮播 |
| ... | ... | @@ -496,7 +539,7 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ |
| 496 | 539 | contentDetailsImageStr = contentDetailsImageStr.replacingOccurrences(of: "\\", with: "") |
| 497 | 540 | contentDetailsImageStr = contentDetailsImageStr.replacingOccurrences(of: " ", with: "") |
| 498 | 541 | } catch _ {} |
| 499 | - if self.type == .add && self.selectCategoryVC?.thiCategoryId == 0{ | |
| 542 | + if self.type == .add && self.selectCategoryVC!.thiCategoryId == 0{ | |
| 500 | 543 | showMessage(message: "请选择商品分类") |
| 501 | 544 | return |
| 502 | 545 | }else if self.selectShopClassifyVC.firCategoryId == 0{ |
| ... | ... | @@ -593,7 +636,7 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ |
| 593 | 636 | } |
| 594 | 637 | showLoading(message: "") |
| 595 | 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 | 640 | hiddenLoading() |
| 598 | 641 | if status == .failed{ |
| 599 | 642 | showMessage(message: "发布失败") |
| ... | ... | @@ -612,8 +655,21 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ |
| 612 | 655 | } |
| 613 | 656 | } |
| 614 | 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 | 673 | if status == .failed{ |
| 618 | 674 | showMessage(message: "修改失败") |
| 619 | 675 | return |
| ... | ... | @@ -622,9 +678,10 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ |
| 622 | 678 | showMessage(message: "修改成功") |
| 623 | 679 | NotificationCenter.default.post(name: NSNotification.Name.ShopGoodsManage.kDSGoodsManageEditNotification, object: nil, userInfo: (result as! Dictionary)) |
| 624 | 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 | 687 | self.navigationController?.popViewController(animated: true) |
| ... | ... | @@ -683,6 +740,7 @@ class CNLiveShopNewProductController:CNLiveBaseViewController{ |
| 683 | 740 | if status == .success{ |
| 684 | 741 | let model = result as! CNLiveShopGoodsDetailsModel |
| 685 | 742 | self.shopGoodsDetailsModel = model |
| 743 | + let thiCategoryId = self.selectCategoryVC!.thiCategoryId | |
| 686 | 744 | //商品分类 |
| 687 | 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 | 302 | } |
| 303 | 303 | @objc func goodsManageEditNotification(notification:Notification){ |
| 304 | 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 | 308 | for (idx,mdl) in dataArr.enumerated() { |
| 309 | 309 | let model = mdl as! CNLiveShopGoodsListModel |
| ... | ... | @@ -318,7 +318,7 @@ class CNLiveShopProductManagerController:CNLiveBaseViewController, UITableViewDa |
| 318 | 318 | model.state = nModel.state |
| 319 | 319 | model.count = nModel.count |
| 320 | 320 | model.ord = nModel.ord |
| 321 | - self.dataArray.replaceObject(at: idx, with: nModel) | |
| 321 | + self.dataArray.replaceObject(at: idx, with: model) | |
| 322 | 322 | self.tableView.reloadData() |
| 323 | 323 | break |
| 324 | 324 | } |
| ... | ... | @@ -351,12 +351,12 @@ class CNLiveShopProductManagerController:CNLiveBaseViewController, UITableViewDa |
| 351 | 351 | |
| 352 | 352 | if self.pageNum == 1 { |
| 353 | 353 | self.dataArray.removeAllObjects() |
| 354 | - self.dataArray.addObjects(from: result as! [CNLiveShopGoodsListModel]) | |
| 354 | + self.dataArray.addObjects(from: arr) | |
| 355 | 355 | if (self.dataArray.count > 0 && self.tableView.mj_header == nil && self.tableView.mj_footer == nil) { |
| 356 | 356 | self.addRefreshView() |
| 357 | 357 | } |
| 358 | 358 | }else if self.pageNum > 1 { |
| 359 | - self.dataArray.addObjects(from: result as! [CNLiveShopGoodsListModel]) | |
| 359 | + self.dataArray.addObjects(from: arr) | |
| 360 | 360 | } |
| 361 | 361 | self.tableView.reloadData() |
| 362 | 362 | self.tableView.mj_header?.endRefreshing() | ... | ... |
metaCode/Classes/Main/HomePage/View/CNMainView.swift
| ... | ... | @@ -170,7 +170,7 @@ class CNFrontMainView : UIView{ |
| 170 | 170 | frontCardContentView.isHidden = true |
| 171 | 171 | //显示textview 添加身份 |
| 172 | 172 | frontDescContentView.isHidden = false |
| 173 | - textView.text = newValue!.descriptions | |
| 173 | + textView.text = newValue!.description | |
| 174 | 174 | addStandBtn.backgroundColor = HexColor(newValue!.backgroundColor) |
| 175 | 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 | 93 | CNLiveNetworking.setupDSRequest(true) |
| 94 | 94 | CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseWjjBUrl+"/api/v1/goodsAdd", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in |
| 95 | 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 | 98 | resultBlock(result as Any,.success) |
| 98 | 99 | }else{ |
| 99 | 100 | resultBlock(NSNull(),.failed) |
| ... | ... | @@ -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 | 106 | /// @param goodsId 商品id |
| 133 | 107 | /// @param uid 用户id |
| ... | ... | @@ -148,8 +122,8 @@ class CNLiveShopGoodListViewModel:NSObject{ |
| 148 | 122 | /// @param isRefund 是否可退 0可以退 1不可退 |
| 149 | 123 | /// @param category_id 店铺分类id,选中了二级分类,传二级分类的id,没选二级分类就传一级分类的id |
| 150 | 124 | /// @param result 结果 |
| 125 | + /// | |
| 151 | 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 | 127 | let param = NSMutableDictionary() |
| 154 | 128 | param.setValue(goodsId, forKey: "id") |
| 155 | 129 | param.setValue(uid, forKey: "uid") |
| ... | ... | @@ -175,7 +149,8 @@ class CNLiveShopGoodListViewModel:NSObject{ |
| 175 | 149 | CNLiveNetworking.setupDSRequest(true) |
| 176 | 150 | CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseWjjBUrl+"/api/v1/goodsEdit", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in |
| 177 | 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 | 154 | resultBlock(result as Any,.success) |
| 180 | 155 | }else{ |
| 181 | 156 | resultBlock(NSNull(),.failed) |
| ... | ... | @@ -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 | 189 | /// @param shopId 商家id |
| 188 | 190 | /// @param goodsId 商品id | ... | ... |
metaCode/Classes/Main/MinePage/ViewModel/CNLiveMineBaseModel.swift
| ... | ... | @@ -143,7 +143,7 @@ final class StandListModel: BaseModel {//, TableCodable { |
| 143 | 143 | var backgroundImg: String = ""//首页背景图- |
| 144 | 144 | var backgroundColor: String = ""//添加身份按钮背景色- |
| 145 | 145 | var backgroundColour: String = ""//- |
| 146 | - var descriptions: String = ""//首页身份说明描述- | |
| 146 | + var description: String = ""//首页身份说明描述- | |
| 147 | 147 | var descBackgroundImg: String = ""//首页文字背景图 |
| 148 | 148 | var cardImg: String = ""//卡片背景图- |
| 149 | 149 | var cardBackgroundImg: String = ""//首页卡片背景图 | ... | ... |