Commit ed648c5e authored by 刘俊宏's avatar 刘俊宏

添加上下架操作

parent 882284fd
...@@ -8,9 +8,15 @@ ...@@ -8,9 +8,15 @@
import UIKit import UIKit
import LGButton import LGButton
protocol GoodsCollectionViewCellDelegate {
func selectListsIndex(index:Int)
func changeGoodsIsShow(isTrue:Bool,byIndex:Int)
}
class GoodsCollectionViewCell: UICollectionViewCell { class GoodsCollectionViewCell: UICollectionViewCell {
var delegate : GoodsCollectionViewCellDelegate?
@IBOutlet weak var goodsImgV: UIImageView! @IBOutlet weak var goodsImgV: UIImageView!
@IBOutlet weak var codeBtn: UIButton! @IBOutlet weak var codeBtn: UIButton!
@IBOutlet weak var rightBtn: UIButton! @IBOutlet weak var rightBtn: UIButton!
...@@ -26,14 +32,17 @@ class GoodsCollectionViewCell: UICollectionViewCell { ...@@ -26,14 +32,17 @@ class GoodsCollectionViewCell: UICollectionViewCell {
@IBAction func lgBtnAction(_ sender: LGButton) { @IBAction func lgBtnAction(_ sender: LGButton) {
print("点击图片背景==\(sender.tag)") print("点击图片背景==\(sender.tag)")
self.delegate?.selectListsIndex(index: sender.tag)
} }
@IBAction func leftAction(_ sender: UIButton) { @IBAction func leftAction(_ sender: UIButton) {
print("点击左边按钮\(sender.tag)") print("点击左边按钮\(sender.tag)")
self.delegate?.changeGoodsIsShow(isTrue: false, byIndex: sender.tag)
} }
@IBAction func rightAction(_ sender: UIButton) { @IBAction func rightAction(_ sender: UIButton) {
print("点击右边按钮\(sender.tag)") print("点击右边按钮\(sender.tag)")
self.delegate?.changeGoodsIsShow(isTrue: true, byIndex: sender.tag)
} }
@IBAction func codeAction(_ sender: UIButton) { @IBAction func codeAction(_ sender: UIButton) {
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
import UIKit import UIKit
import ViewAnimator import ViewAnimator
class GoodsManageListVC: BaseViewController, UICollectionViewDelegate, UICollectionViewDataSource ,UICollectionViewDelegateFlowLayout,HeaderSelectViewDelegate,SelectContentViewDelegate,UISearchBarDelegate, SearchBarViewDelegate{ class GoodsManageListVC: BaseViewController, UICollectionViewDelegate, UICollectionViewDataSource ,UICollectionViewDelegateFlowLayout,HeaderSelectViewDelegate,SelectContentViewDelegate,UISearchBarDelegate, SearchBarViewDelegate, GoodsCollectionViewCellDelegate{
var collection : UICollectionView? = nil var collection : UICollectionView? = nil
var layout = UICollectionViewFlowLayout() var layout = UICollectionViewFlowLayout()
...@@ -367,6 +367,7 @@ class GoodsManageListVC: BaseViewController, UICollectionViewDelegate, UICollect ...@@ -367,6 +367,7 @@ class GoodsManageListVC: BaseViewController, UICollectionViewDelegate, UICollect
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "GoodsCollectionViewCell", for: indexPath) as! GoodsCollectionViewCell let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "GoodsCollectionViewCell", for: indexPath) as! GoodsCollectionViewCell
let rowModel = self.items[indexPath.row] let rowModel = self.items[indexPath.row]
cell.delegate = self
cell.goodsName.text = rowModel.goods_name cell.goodsName.text = rowModel.goods_name
cell.priceLbl.text = "¥" + rowModel.price! cell.priceLbl.text = "¥" + rowModel.price!
// cell.goodsImgV.kf.setImage(with: URL.init(string:SERVERCE_HOST + rowModel.goods_thumb!)!, placeholder: nil, options: nil, progressBlock: nil, completionHandler: nil) // cell.goodsImgV.kf.setImage(with: URL.init(string:SERVERCE_HOST + rowModel.goods_thumb!)!, placeholder: nil, options: nil, progressBlock: nil, completionHandler: nil)
...@@ -401,6 +402,44 @@ class GoodsManageListVC: BaseViewController, UICollectionViewDelegate, UICollect ...@@ -401,6 +402,44 @@ class GoodsManageListVC: BaseViewController, UICollectionViewDelegate, UICollect
} }
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
print("选中===\(indexPath)") print("选中===\(indexPath)")
let vc = ProductDetailViewController()
self.navigationController?.pushViewController(vc, animated: true)
}
//MARK:---cell delegate 选中
func selectListsIndex(index: Int) {
let vc = ProductDetailViewController()
self.navigationController?.pushViewController(vc, animated: true)
}
//MARK:-- cell delegate 上下架,入库
func changeGoodsIsShow(isTrue: Bool, byIndex: Int) {
//左按钮为false 右按钮为true
let rowModel = self.items[byIndex]
if rowModel.is_show == 0 {
if isTrue {
//"下架"
editField(["user_token":"","function_id":"15","prval":"goods_id","value":"0",], success: { (data) in
self.loadData()
}) { (erro) in
}
}else{
//"入库"
}
}else if rowModel.is_show == 1{
if isTrue {
//"入库"
}else{
//"上架"
editField(["user_token":"","function_id":"15","prval":rowModel.goods_id,"value":"1",], success: { (data) in
self.loadData()
}) { (erro) in
}
}
}
}
func upDataByGoodsId(goodsId:String) {
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment