123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- //
- // SelfMentionContactsListViewController.swift
- // RainbowPlanet
- //
- // Created by 南鑫林 on 2019/4/25.
- // Copyright © 2019 南鑫林. All rights reserved.
- //
- import UIKit
- class SelfMentionContactsListViewController: BaseViewController {
-
- var selfMentionContactsModels : Array<SelfMentionContactsModel>?
-
- // 是否由支付订单页面进入
- var isFromOrderPay: Bool = false
-
- override func viewDidLoad() {
- super.viewDidLoad()
- setupViews()
- setupLayouts()
- setupData()
- }
-
- override func setupViews() {
- navigationBar.title = "我的自提收货信息"
- navigationBar.wr_setRightButton(title: "添加新收货人", titleColor: k333333Color)
- navigationBar.rightButton.titleLabel!.font = kRegularFont14
- navigationBar.onClickRightButton = {
- [weak self] in
- self?.pushEditSelfMention()
- }
- view.addSubview(selfMentionContactsListView)
- }
-
- override func setupLayouts() {
- selfMentionContactsListView.snp.makeConstraints { (make) in
- make.top.equalTo(kNavBarTotalHeight)
- make.left.right.bottom.equalToSuperview()
- }
- }
-
- override func setupData() {
- self.selfMentionContactsListView
- .tableView
- .addHeaderWithHeader(withBeginRefresh: true, animation: false) {
- [weak self] (data) in
- self?.userExpreesContactsListApi()
- }
- }
-
- private lazy var selfMentionContactsListView: SelfMentionContactsListView = {
- let selfMentionContactsListView = SelfMentionContactsListView()
- selfMentionContactsListView.editClosure = { //编辑,新增
- [weak self] selfMentionContactsModel in
- self?.pushEditSelfMention(selfMentionContactsModel: selfMentionContactsModel)
- }
- selfMentionContactsListView.didSelectRowClosure = {
- [weak self] indexPath in
- let selfMentionContactsModel = self?.selfMentionContactsModels?[indexPath.row]
- self?.userSetExpreesContactsDefaultApi(id: selfMentionContactsModel?.id ?? 0)
- }
- return selfMentionContactsListView
- }()
-
-
- /// 修改/新建
- ///
- /// - Parameter selfMentionContactsModel: 修改个人信息
- func pushEditSelfMention(selfMentionContactsModel:SelfMentionContactsModel? = nil) -> Void {
- let vc = EditSelfMentionContactsViewController()
- vc.saveClosure = {
- [weak self] in
- self?.userExpreesContactsListApi()
- }
- if let selfMentionContactsModel = selfMentionContactsModel {
- vc.selfMentionContactsModel = selfMentionContactsModel
- }
- self.navigationController?.pushViewController(vc, animated: true)
- }
-
-
- /// 自提收货人信息
- func userExpreesContactsListApi() {
- SwiftMoyaNetWorkServiceUser.shared().userExpreesContactsListApi {
- [weak self] (contactListModel) -> (Void) in
- let originMdl = contactListModel as? ContactListModel
- self?.selfMentionContactsModels = originMdl?.list
- self?.selfMentionContactsListView.selfMentionContactsModels = self?.selfMentionContactsModels
- }
- }
-
- /// 自提点收货人信息,设置默认
- func userSetExpreesContactsDefaultApi(id:Int = 0) {
- SwiftMoyaNetWorkServiceUser.shared().userSetExpreesContactsDefaultApi(id: id, completion: {
- [weak self] (data) -> (Void) in
- if self!.isFromOrderPay {
- self?.navigationController?.popViewController(animated: true)
- } else {
- self?.userExpreesContactsListApi()
- }
- })
- }
- }
|