Commit 9dd252b2 authored by lujunye's avatar lujunye

修改刷新完成

parent 8477b4fa
......@@ -70,10 +70,8 @@ class GYS_FX_Product_ListVc: BaseViewController ,PagingViewControllerDelegate,UI
pagingViewController.menuItemSize = .fixed(width: 0, height: 44*glscale)
pagingViewController.font = UIFont.systemFont(ofSize: 13)
pagingViewController.selectedFont = UIFont.systemFont(ofSize: 13)
// pagingViewController.textColor = UIColor.init(named: "灰色字体颜色")!
// pagingViewController.selectedTextColor = UIColor.init(named: "蓝色字体颜色")!
pagingViewController.textColor = UIColor.white
pagingViewController.selectedTextColor = UIColor.white
pagingViewController.textColor = UIColor.init(named: "灰色字体颜色")!
pagingViewController.selectedTextColor = UIColor.init(named: "蓝色字体颜色")!
pagingViewController.delegate = self
pagingViewController.dataSource = self
pagingViewController.sizeDelegate = self
......@@ -88,64 +86,44 @@ class GYS_FX_Product_ListVc: BaseViewController ,PagingViewControllerDelegate,UI
NotificationCenter.default.addObserver(self, selector: #selector(getNoti2(noti:)), name: NSNotification.Name(rawValue: "sum_goods_count"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(getNoti(noti:)), name: NSNotification.Name(rawValue: "fx_action"), object: nil)
contentV.addSubview(left_title)
contentV.addSubview(right_title)
right_title.textColor = UIColor.init(named: "灰色字体颜色")!
left_title.textColor = UIColor.init(named: "蓝色字体颜色")!
left_title.text = "已铺货商品"
left_title.font = UIFont(name: "PingFangSC-Medium", size: 13)
left_title.textAlignment = .center
left_title.snp.makeConstraints { (make) in
make.top.left.equalTo(0)
make.width.equalTo(ScreenWidth*0.5)
make.height.equalTo(49)
}
right_title.text = "可铺货商品"
right_title.font = UIFont(name: "PingFangSC-Medium", size: 13)
right_title.textAlignment = .center
right_title.snp.makeConstraints { (make) in
make.top.right.equalTo(0)
make.width.equalTo(ScreenWidth*0.5)
make.height.equalTo(49)
}
}
let left_title = UILabel()
let right_title = UILabel()
var needs_refresh = false
@objc func getNoti(noti:Notification){
// var idx = 0
// let noti_str = String(describing: noti.userInfo!["intro"])
// if noti_str.contains("取消") {
// idx = 1
// }
viewControllers.forEach { (vc) in
vc.isUpData = true
vc.home_list_tbv.mj_header?.beginRefreshing()
}
}
@objc func getNoti2(noti:Notification){
let sum_goods = String(describing: noti.userInfo!["sum_goods"]!)
let sum_goods2 = String(describing: noti.userInfo!["sum_goods2"]!)
left_title.text = "已铺货商品"
var left_title = "已铺货商品"
if sum_goods != "0" {
left_title.text = "已铺货商品(" + sum_goods + ")"
left_title = "已铺货商品(" + sum_goods + ")"
}
right_title.text = "可铺货商品"
var right_title = "可铺货商品"
if sum_goods2 != "0" {
right_title.text = "可铺货商品(" + sum_goods2 + ")"
right_title = "可铺货商品(" + sum_goods2 + ")"
}
// cities = [
// left_title,
// right_title
// ]
//
//
// pagingVC?.reloadMenu()
// pagingVC?.select(index: 1)
cities = [
left_title,
right_title
]
pagingVC?.reloadData(around: PagingIndexItem(index: selectIndex, title: cities[selectIndex]))
}
@objc func getNoti(noti:Notification){
needs_refresh = true
}
deinit {
/// 移除通知
......@@ -175,14 +153,18 @@ class GYS_FX_Product_ListVc: BaseViewController ,PagingViewControllerDelegate,UI
self.center_title_lbl.text = self.centersArr.first?.shop_name
self.arrow_img.image = UIImage(named: "down_blue")
self.shop_id = (self.centersArr.first?.shop_id)!
if model.code == 1 {
HUD.hide()
}
self.shop_id = (model.data?.first?.shop_id)!
self.viewControllers.forEach { (vc) in
vc.shop_id = self.shop_id
vc.isUpData = false
}
let vc = self.viewControllers[self.selectIndex]
vc.home_list_tbv.mj_header?.beginRefreshing()
}
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "btn_click"), object: self.shop_id)
} failture: { (err) in
......@@ -306,11 +288,17 @@ class GYS_FX_Product_ListVc: BaseViewController ,PagingViewControllerDelegate,UI
cell.selectBtn.isSelected = true
closeAction()
let model = centersArr[indexPath.row]
center_title_lbl.text = model.shop_name
shop_id = model.shop_id!
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "btn_click"), object: shop_id)
self.shop_id = model.shop_id!
self.viewControllers.forEach { (vc) in
vc.shop_id = self.shop_id
vc.isUpData = false
}
let vc = self.viewControllers[self.selectIndex]
vc.home_list_tbv.mj_header?.beginRefreshing()
}
......@@ -324,18 +312,13 @@ class GYS_FX_Product_ListVc: BaseViewController ,PagingViewControllerDelegate,UI
guard let item = pagingItem as? PagingIndexItem else { return}
if selectIndex != item.index {
selectIndex = item.index
if selectIndex == 0 {
right_title.textColor = UIColor.init(named: "灰色字体颜色")!
left_title.textColor = UIColor.init(named: "蓝色字体颜色")!
}else{
right_title.textColor = UIColor.init(named: "蓝色字体颜色")!
left_title.textColor = UIColor.init(named: "灰色字体颜色")!
let vc = viewControllers[selectIndex]
if !vc.isUpData {
vc.home_list_tbv.mj_header?.beginRefreshing()
}
}
if needs_refresh {
needs_refresh = false
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "btn_click"), object: shop_id)
}
}
}
......@@ -346,18 +329,12 @@ extension GYS_FX_Product_ListVc: PagingViewControllerDataSource {
guard let item = pagingItem as? PagingIndexItem else { return}
if selectIndex != item.index {
selectIndex = item.index
if selectIndex == 0 {
right_title.textColor = UIColor.init(named: "灰色字体颜色")!
left_title.textColor = UIColor.init(named: "蓝色字体颜色")!
}else{
right_title.textColor = UIColor.init(named: "蓝色字体颜色")!
left_title.textColor = UIColor.init(named: "灰色字体颜色")!
let vc = viewControllers[selectIndex]
if !vc.isUpData {
vc.home_list_tbv.mj_header?.beginRefreshing()
}
}
if needs_refresh {
needs_refresh = false
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "btn_click"), object: shop_id)
}
closeAction()
}
......
......@@ -27,8 +27,9 @@ class GYS_FX_Product_VC: BaseViewController,UITableViewDelegate,UITableViewDataS
"action":action]
spreadGoods(dic) { (data) in
HUD.flash(.label(intro), delay: 1.2)
self.home_list_tbv.mj_header?.beginRefreshing()
// self.home_list_tbv.mj_header?.beginRefreshing()
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "fx_action"), object:nil)
// NotificationCenter.default.post(name: NSNotification.Name(rawValue: "fx_action"), object: nil, userInfo: ["intro":intro])
} failture: { (err) in
}
}
......@@ -37,7 +38,15 @@ class GYS_FX_Product_VC: BaseViewController,UITableViewDelegate,UITableViewDataS
@IBOutlet weak var center_select_btn: UIView!
var page : Int = 0
var isUpData = false
var isUpData = true{
didSet{
if isUpData {
if home_list_tbv != nil {
home_list_tbv.mj_header?.beginRefreshing()
}
}
}
}
let UserToken = UserDefaults.standard.value(forKey: "user_token")
var shop_id:Int = 0
......@@ -78,33 +87,23 @@ class GYS_FX_Product_VC: BaseViewController,UITableViewDelegate,UITableViewDataS
NotificationCenter.default.addObserver(self, selector: #selector(getNoti(noti:)), name: NSNotification.Name(rawValue: "haveChange"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(getNoti2(noti:)), name: NSNotification.Name(rawValue: "btn_click"), object: nil)
}
deinit {
/// 移除通知
NotificationCenter.default.removeObserver(self)
}
@objc func getNoti(noti:Notification){
home_list_tbv.mj_header?.beginRefreshing()
}
@objc func getNoti2(noti:Notification){
if shop_id != noti.object as! Int {
shop_id = noti.object as! Int
}
//下拉刷新相关设置
self.headerMJ.setRefreshingTarget(self, refreshingAction: #selector(self.loadData))
self.home_list_tbv.mj_header = self.headerMJ
//上拉加载相关设置
self.home_list_tbv.mj_header?.beginRefreshing()
self.footerMJ.setRefreshingTarget(self, refreshingAction: #selector(self.loadMoreData))
self.home_list_tbv.mj_footer = self.footerMJ
}
deinit {
/// 移除通知
NotificationCenter.default.removeObserver(self)
}
@objc func getNoti(noti:Notification){
home_list_tbv.mj_header?.beginRefreshing()
}
var look_type = 2
var look_type = -1
//MARK:--加载数据
@objc func loadData(){
print("加载数据")
......
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