|
@@ -18,9 +18,10 @@ class ProductDetailViewController: BaseViewController {
|
|
|
}
|
|
|
weak var observe : NSObjectProtocol?
|
|
|
|
|
|
- var productModel : ProductModel?
|
|
|
-
|
|
|
- var productSearchModel : ProductSearchModel?
|
|
|
+ /// 商品Id
|
|
|
+ var productId : Int?
|
|
|
+ /// 店铺Id
|
|
|
+ var shopId : Int?
|
|
|
|
|
|
var productDetailModel : ProductDetailModel?
|
|
|
|
|
@@ -81,12 +82,7 @@ class ProductDetailViewController: BaseViewController {
|
|
|
productDetailView.lookAllCommentClosure = {
|
|
|
[weak self] in
|
|
|
let vc = ProductAllCommentViewController()
|
|
|
- if self?.productModel != nil {
|
|
|
- vc.productModel = self?.productModel
|
|
|
- }
|
|
|
- if self?.productSearchModel != nil {
|
|
|
- vc.productSearchModel = self?.productSearchModel
|
|
|
- }
|
|
|
+ vc.productId = self?.productId ?? 0
|
|
|
self?.navigationController?.pushViewController(vc, animated: true)
|
|
|
}
|
|
|
productDetailView.addCartClosure = {
|
|
@@ -126,61 +122,30 @@ class ProductDetailViewController: BaseViewController {
|
|
|
|
|
|
/// 获取商品详情
|
|
|
private func productDetailApi() {
|
|
|
- if self.productModel != nil {
|
|
|
- SwiftMoyaNetWorkServiceProduct.shared().productDetailApi(id: self.productModel?.id ?? 0) {
|
|
|
- [weak self] (productDetailModel) -> (Void) in
|
|
|
- self?.productDetailModel = productDetailModel as? ProductDetailModel
|
|
|
- self?.productDetailView.productDetailModel = productDetailModel as? ProductDetailModel
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if self.productSearchModel != nil {
|
|
|
- SwiftMoyaNetWorkServiceProduct.shared().productDetailApi(id: self.productSearchModel?.id ?? 0) {
|
|
|
- [weak self] (productDetailModel) -> (Void) in
|
|
|
- self?.productDetailModel = productDetailModel as? ProductDetailModel
|
|
|
- self?.productDetailView.productDetailModel = productDetailModel as? ProductDetailModel
|
|
|
- }
|
|
|
+ SwiftMoyaNetWorkServiceProduct.shared().productDetailApi(id: productId ?? 0) {
|
|
|
+ [weak self] (productDetailModel) -> (Void) in
|
|
|
+ self?.productDetailModel = productDetailModel as? ProductDetailModel
|
|
|
+ self?.productDetailView.productDetailModel = productDetailModel as? ProductDetailModel
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// 获取商家商品列表
|
|
|
private func productListApi() {
|
|
|
-
|
|
|
- if self.productModel != nil {
|
|
|
- SwiftMoyaNetWorkServiceProduct.shared().productListApi(page: 1, shopId: productSearchModel?.shopId ?? 0,desc: 2, fieldOrder: 1) {
|
|
|
- [weak self] (productListModel) -> (Void) in
|
|
|
- let productSearchListModel = productListModel as? ProductSearchListModel
|
|
|
- self?.productDetailView.productSearchListModel = productSearchListModel
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if self.productSearchModel != nil {
|
|
|
- SwiftMoyaNetWorkServiceProduct.shared().productListApi(page: 1, shopId: productSearchModel?.shopId ?? 0,desc: 2, fieldOrder: 1) {
|
|
|
- [weak self] (productListModel) -> (Void) in
|
|
|
- let productSearchListModel = productListModel as? ProductSearchListModel
|
|
|
- self?.productDetailView.productSearchListModel = productSearchListModel
|
|
|
- }
|
|
|
+ SwiftMoyaNetWorkServiceProduct.shared().productListApi(page: 1, shopId: productId ?? 0,desc: 2, fieldOrder: 1) {
|
|
|
+ [weak self] (productListModel) -> (Void) in
|
|
|
+ let productSearchListModel = productListModel as? ProductSearchListModel
|
|
|
+ self?.productDetailView.productSearchListModel = productSearchListModel
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/// 获取评价列表
|
|
|
func productCommentListApi() {
|
|
|
- if self.productModel != nil {
|
|
|
- SwiftMoyaNetWorkServiceProduct.shared().productCommentListApi(productId: productModel?.id ?? 0) {
|
|
|
- [weak self] (productCommentListModel) -> (Void) in
|
|
|
- let productCommentListModel = productCommentListModel as? ProductCommentListModel
|
|
|
- self?.productDetailView.productCommentListModel = productCommentListModel
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if self.productSearchModel != nil {
|
|
|
- SwiftMoyaNetWorkServiceProduct.shared().productCommentListApi(productId: productSearchModel?.id ?? 0) { [weak self] (productCommentListModel) -> (Void) in
|
|
|
- let productCommentListModel = productCommentListModel as? ProductCommentListModel
|
|
|
- self?.productDetailView.productCommentListModel = productCommentListModel
|
|
|
-
|
|
|
- }
|
|
|
+ SwiftMoyaNetWorkServiceProduct.shared().productCommentListApi(productId: productId ?? 0) {
|
|
|
+ [weak self] (productCommentListModel) -> (Void) in
|
|
|
+ let productCommentListModel = productCommentListModel as? ProductCommentListModel
|
|
|
+ self?.productDetailView.productCommentListModel = productCommentListModel
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|