|
@@ -7,24 +7,145 @@
|
|
|
//
|
|
|
|
|
|
import UIKit
|
|
|
+import JXSegmentedView
|
|
|
+
|
|
|
+/// 我的订单类型
|
|
|
+///
|
|
|
+/// - all: 全部
|
|
|
+/// - pendingPayment: 待付款
|
|
|
+/// - toBeShipped: 待收货
|
|
|
+/// - toBeReceived: 待发货
|
|
|
+/// - toBeEvaluated: 待评价
|
|
|
+/// - refund: 退款
|
|
|
+enum OrderVCType : Int {
|
|
|
+ case all = -1
|
|
|
+ case pendingPayment = 0
|
|
|
+ case toBeShipped = 1
|
|
|
+ case toBeReceived = 2
|
|
|
+ case toBeEvaluated = 3
|
|
|
+ case refund = 4
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
class OrderViewController: BaseViewController {
|
|
|
+
|
|
|
+ var orderVCType : OrderVCType?
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
|
-
|
|
|
- // Do any additional setup after loading the view.
|
|
|
+ setupViews()
|
|
|
+ setupLayouts()
|
|
|
+ setupData()
|
|
|
+ }
|
|
|
+
|
|
|
+ override func setupViews() {
|
|
|
+ navigationBar.title = "我的订单"
|
|
|
+ view.addSubview(segmentedView)
|
|
|
+ view.addSubview(listContainerView)
|
|
|
}
|
|
|
|
|
|
+ override func setupLayouts() {
|
|
|
+ segmentedView.snp.makeConstraints { (make) in
|
|
|
+ make.left.right.equalToSuperview()
|
|
|
+ make.height.equalTo(44)
|
|
|
+ make.top.equalTo(kNavBarTotalHeight)
|
|
|
|
|
|
- /*
|
|
|
- // MARK: - Navigation
|
|
|
+ }
|
|
|
+ listContainerView.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(segmentedView.snp.bottom)
|
|
|
+ make.left.right.bottom.equalToSuperview()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override func setupData() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //1.初始化JXSegmentedView
|
|
|
+ lazy var segmentedView: JXSegmentedView = {
|
|
|
+ let segmentedView = JXSegmentedView()
|
|
|
+ segmentedView.delegate = self
|
|
|
+ segmentedView.dataSource = segmentedDataSource
|
|
|
+ segmentedView.indicators = [indicator]
|
|
|
+ segmentedView.contentScrollView = listContainerView.scrollView
|
|
|
+ return segmentedView
|
|
|
+ }()
|
|
|
+
|
|
|
+ //2.初始化dataSource
|
|
|
+ lazy var segmentedDataSource: JXSegmentedTitleDataSource = {
|
|
|
+ let segmentedDataSource = JXSegmentedTitleDataSource()
|
|
|
+ segmentedDataSource.titles = ["全部","待付款","待发货","待收货","待评价","退款"]
|
|
|
+ segmentedDataSource.isTitleColorGradientEnabled = true
|
|
|
+ segmentedDataSource.isItemSpacingAverageEnabled = true
|
|
|
+ segmentedDataSource.titleNormalColor = k333333Color
|
|
|
+ segmentedDataSource.titleSelectedColor = kFFA42FColor
|
|
|
+ segmentedDataSource.titleNormalFont = kRegularFont14!
|
|
|
+ segmentedDataSource.titleSelectedFont = kBoldFont14
|
|
|
+
|
|
|
+ //reloadData(selectedIndex:)方法一定要调用,方法内部会刷新数据源数组
|
|
|
+ segmentedDataSource.reloadData(selectedIndex: 0)
|
|
|
+ return segmentedDataSource
|
|
|
+ }()
|
|
|
+ //3.初始化指示器indicator
|
|
|
+ lazy var indicator: JXSegmentedIndicatorLineView = {
|
|
|
+ let indicator = JXSegmentedIndicatorLineView()
|
|
|
+ indicator.indicatorColor = kFFA42FColor
|
|
|
+ indicator.indicatorHeight = 4
|
|
|
+ indicator.indicatorWidth = 20
|
|
|
+ return indicator
|
|
|
+ }()
|
|
|
+
|
|
|
+ //4.初始化JXSegmentedListContainerView
|
|
|
+ lazy var listContainerView: JXSegmentedListContainerView = {
|
|
|
+ let listContainerView = JXSegmentedListContainerView(dataSource: self)
|
|
|
+ listContainerView.didAppearPercent = 0.01
|
|
|
+ return listContainerView
|
|
|
+ }()
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
- // In a storyboard-based application, you will often want to do a little preparation before navigation
|
|
|
- override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
|
|
- // Get the new view controller using segue.destination.
|
|
|
- // Pass the selected object to the new view controller.
|
|
|
+extension OrderViewController : JXSegmentedViewDelegate {
|
|
|
+ //点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,而不关心具体是点击还是滚动选中的情况。
|
|
|
+ func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // 点击选中的情况才会调用该方法
|
|
|
+ func segmentedView(_ segmentedView: JXSegmentedView, didClickSelectedItemAt index: Int) {
|
|
|
+ //传递didClickSelectedItemAt事件给listContainerView,必须调用!!!
|
|
|
+ listContainerView.didClickSelectedItem(at: index)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 滚动选中的情况才会调用该方法
|
|
|
+ func segmentedView(_ segmentedView: JXSegmentedView, didScrollSelectedItemAt index: Int) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // 正在滚动中的回调
|
|
|
+ func segmentedView(_ segmentedView: JXSegmentedView, scrollingFrom leftIndex: Int, to rightIndex: Int, percent: CGFloat) {
|
|
|
+ //传递scrolling事件给listContainerView,必须调用!!!
|
|
|
+ listContainerView.segmentedViewScrolling(from: leftIndex, to: rightIndex, percent: percent, selectedIndex: segmentedView.selectedIndex)
|
|
|
}
|
|
|
- */
|
|
|
+
|
|
|
+ /// 是否允许点击选中目标index的item
|
|
|
+ func segmentedView(_ segmentedView: JXSegmentedView, canClickItemAt index: Int) -> Bool {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
+extension OrderViewController :JXSegmentedListContainerViewDataSource {
|
|
|
+
|
|
|
+
|
|
|
+ func numberOfLists(in listContainerView: JXSegmentedListContainerView) -> Int {
|
|
|
+ if let titleDataSource = segmentedView.dataSource as? JXSegmentedBaseDataSource {
|
|
|
+ return titleDataSource.dataSource.count
|
|
|
+ }
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ func listContainerView(_ listContainerView: JXSegmentedListContainerView, initListAt index: Int) -> JXSegmentedListContainerViewListDelegate {
|
|
|
+ let vc = OrderListViewController()
|
|
|
+// let cmsTemplateModel = cmsTemplateModels![index]
|
|
|
+// vc.shoppingMallListVCType = cmsTemplateModel.applyType ?? 0
|
|
|
+ return vc
|
|
|
+ }
|
|
|
}
|