CNLiveShopBodyCustomView.swift 26.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687
//
//  CNLiveShopBodyCustomView.swift
//  metaCode
//
//  Created by open on 2023/11/6.
//

import Foundation
import SnapKit
import Kingfisher

typealias clickAgreeCallBack = (_ refundView: ShopBodyOrderRefundView,_ desc: String) -> Void
typealias clickButtonCallBack = (_ isSelected: Bool) -> Void
typealias clickInputCallBack = (_ content: String, _ row: NSInteger) -> Void
class ShopBodyOrderRefundView: UIView, UITextViewDelegate {
    
    var clickBlock: clickAgreeCallBack!
    
    lazy var shadowView: UIView = {
        let shadowView = UIView.init()
        shadowView.backgroundColor = UIColor(white: 0, alpha: 0.38)
        return shadowView
    }()
    
    lazy var alertView: UIView = {
        let alertView = UIView.init()
        alertView.backgroundColor = .white
        alertView.layer.cornerRadius = adapt_length(length: 4)
        alertView.layer.masksToBounds = true
        return alertView
    }()
    
    lazy var titleLab: UILabel = {
        let titleLab = UILabel.init()
        titleLab.font = medium_adapt_font(pointSize: 17)
        titleLab.textColor = HexColor("#444444")
        titleLab.textAlignment = .center
        titleLab.text = "拒绝原因"
        return titleLab
    }()
    
    lazy var contentBgView: UIView = {
        let contentBgView = UIView.init()
        contentBgView.backgroundColor = HexColor("#F5F6F8")
        contentBgView.layer.cornerRadius = adapt_length(length: 4)
        contentBgView.layer.masksToBounds = true
        return contentBgView
    }()
    
    lazy var contentTextView: UITextView = {
        let contentTextView = UITextView.init(frame: CGRect.zero)
        contentTextView.text = "拒单原因,最多不超过100字…"
        contentTextView.backgroundColor = HexColor("#F5F6F8")
        contentTextView.textColor = UIColor.lightGray
        contentTextView.font = regular_adapt_font(pointSize: 14)
        contentTextView.delegate = self
        contentTextView.returnKeyType = .done
        contentTextView.showsVerticalScrollIndicator = false
        return contentTextView
    }()
    
    lazy var cancelBtn: UIButton = {
        let cancelBtn = UIButton.init(type: .custom)
        cancelBtn.setTitle("取消", for: .normal)
        cancelBtn.setTitleColor(HexColor("#ffffff"), for: .normal)
        cancelBtn.titleLabel?.font = medium_adapt_font(pointSize: 14)
        cancelBtn.layer.cornerRadius = adapt_length(length: 4)
        cancelBtn.layer.masksToBounds = true
        cancelBtn.backgroundColor = HexColor("#F5A623")
        cancelBtn.addTarget(self, action: #selector(cancelBtnClick), for: .touchUpInside)
        return cancelBtn
    }()
    
    lazy var agreeBtn: UIButton = {
        let agreeBtn = UIButton.init(type: .custom)
        agreeBtn.setTitle("确认拒绝", for: .normal)
        agreeBtn.setTitleColor(HexColor("#ffffff"), for: .normal)
        agreeBtn.titleLabel?.font = medium_adapt_font(pointSize: 14)
        agreeBtn.layer.cornerRadius = adapt_length(length: 4)
        agreeBtn.layer.masksToBounds = true
        agreeBtn.backgroundColor = HexColor("#28C1C6")
        agreeBtn.addTarget(self, action: #selector(agreeBtnClick), for: .touchUpInside)
        return agreeBtn
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        addSubview(shadowView)
        shadowView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        addSubview(alertView)
        alertView.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(adapt_length(length: 30))
            make.right.equalToSuperview().offset(-adapt_length(length: 30))
            make.center.equalToSuperview()
            make.height.equalTo(KSreenWidth-adapt_length(length: 60))
        }
        alertView.addSubview(titleLab)
        titleLab.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(adapt_length(length: 20))
            make.top.equalToSuperview().offset(adapt_length(length: 20))
            make.right.equalToSuperview().offset(-adapt_length(length: 20))
        }
        alertView.addSubview(contentBgView)
        contentBgView.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(adapt_length(length: 25))
            make.top.equalTo(titleLab.snp.bottom).offset(adapt_length(length: 15))
            make.right.equalToSuperview().offset(-adapt_length(length: 25))
            make.bottom.equalToSuperview().offset(-adapt_length(length: 60))
        }
        contentBgView.addSubview(contentTextView)
        contentTextView.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(adapt_length(length: 15))
            make.top.equalToSuperview().offset(adapt_length(length: 12))
            make.right.equalToSuperview().offset(-adapt_length(length: 15))
            make.bottom.equalToSuperview().offset(-adapt_length(length: 12))
        }
        alertView.addSubview(cancelBtn)
        cancelBtn.snp.makeConstraints { make in
            make.left.equalToSuperview().offset((KSreenWidth-adapt_length(length: 228))/3)
            make.bottom.equalToSuperview().offset(-adapt_length(length: 15))
            make.width.equalTo(adapt_length(length: 84))
            make.height.equalTo(adapt_length(length: 30))
        }
        alertView.addSubview(agreeBtn)
        agreeBtn.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(-((KSreenWidth-adapt_length(length: 228))/3))
            make.bottom.equalToSuperview().offset(-adapt_length(length: 15))
            make.width.equalTo(adapt_length(length: 84))
            make.height.equalTo(adapt_length(length: 30))
        }
    }
    
    @objc func agreeBtnClick() {
        if (clickBlock != nil) {
            self.clickBlock(self, self.contentTextView.text)
        }
    }
    
    func textViewDidBeginEditing(_ textView: UITextView) {
        if textView.textColor == UIColor.lightGray {
            textView.text = nil
            textView.textColor = HexColor("#444444")
        }
    }
    
    func textViewShouldEndEditing(_ textView: UITextView) -> Bool {
        if textView.text.isEmpty {
            textView.text = "拒单原因,最多不超过100字…"
            textView.textColor = UIColor.lightGray
        } 
        return true
    }
    
    func textViewDidChange(_ textView: UITextView) {
        if self.contentTextView == textView && self.contentTextView.text.count > 100 {
            showMessage(message: "最多不超过100字!!!")
        }
    }
    
    func textViewDidEndEditing(_ textView: UITextView) {
        if self.contentTextView == textView && self.contentTextView.text.count > 100 {
            self.contentTextView.text = self.contentTextView.text.prefix(100).lowercased()
        }
    }
    func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
        if text == "\n" {
            self.endEditing(true)
            return false
        }
        return true
    }
    
    override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
        guard let contentTextViewRect = self.contentTextView.superview?.convert(self.contentTextView.frame, to: self) else { return self.contentTextView }
        
        if !CGRectContainsPoint(contentTextViewRect, point) {
            self.endEditing(true)
        }
        return super.hitTest(point, with: event)
    }
    
    @objc func cancelBtnClick() {
        removeFromSuperview()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}


class ShopBodyOrderSpliteTableViewCell: UITableViewCell {
    
    
    lazy var goodsImageView: UIImageView = {
        let goodsImageView = UIImageView.init()
        goodsImageView.backgroundColor = .white
        goodsImageView.contentMode = .scaleAspectFill
        goodsImageView.layer.masksToBounds = true
        return goodsImageView
    }()
    
    lazy var goodsTitle: UILabel = {
        let goodsTitle = UILabel.init()
        goodsTitle.lineBreakMode = .byClipping
        goodsTitle.numberOfLines = 2
        goodsTitle.textColor = HexColor("#333333")
        goodsTitle.font = regular_adapt_font(pointSize: 14)
        return goodsTitle
    }()
    
    lazy var priceLabel: UILabel = {
        let priceLabel = UILabel.init()
        priceLabel.textColor = HexColor("#FC1541")
        priceLabel.font = medium_adapt_font(pointSize: 21)
        return priceLabel
    }()
    
    lazy var numberLabel: UILabel = {
        let numberLabel = UILabel.init()
        numberLabel.textAlignment = .right
        numberLabel.textColor = HexColor("#222833")
        numberLabel.font = regular_adapt_font(pointSize: 15)
        return numberLabel
    }()
    
    lazy var lineLabel: UILabel = {
        let lineLabel = UILabel.init()
        lineLabel.backgroundColor = HexColor("#EAEAEA")
        return lineLabel
    }()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        contentView.backgroundColor = .clear
        selectionStyle = .none
        
        addSubview(goodsImageView)
        goodsImageView.snp.makeConstraints { make in
            make.left.top.equalToSuperview().offset(adapt_length(length: 15))
            make.size.equalTo(adapt_length(length: 100))
        }
        addSubview(goodsTitle)
        goodsTitle.snp.makeConstraints { make in
            make.top.equalTo(goodsImageView)
            make.left.equalTo(goodsImageView.snp.right).offset(adapt_length(length: 15))
            make.right.equalToSuperview().offset(-adapt_length(length: 15))
        }
        addSubview(priceLabel)
        priceLabel.snp.makeConstraints { make in
            make.left.equalTo(goodsTitle)
            make.bottom.equalTo(goodsImageView)
        }
        addSubview(numberLabel)
        numberLabel.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(-adapt_length(length: 10))
            make.bottom.equalTo(goodsImageView)
        }
        addSubview(lineLabel)
        lineLabel.snp.makeConstraints { make in
            make.left.equalTo(goodsImageView)
            make.right.equalTo(numberLabel)
            make.bottom.equalToSuperview().offset(-adapt_length(length: 0.5))
            make.height.equalTo(adapt_length(length: 0.5))
        }
    }
    
    func setupDataSource(goodsModel: ShopOrderListGoodsModel) {
        goodsImageView.kf.setImage(with: URL(string: goodsModel.simg!), placeholder: UIImage.imageWithColor(color: HexColor("#F8F8F8")!, size: CGSize(width: adapt_length(length: 100), height: adapt_length(length: 100))))
        goodsTitle.text = goodsModel.title
        priceLabel.text = \(goodsModel.price ?? 0.00)"
        priceLabel.sizeToFit()
        numberLabel.text = "x \(goodsModel.num ?? 0)"
        numberLabel.sizeToFit()
        setNeedsLayout()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}


class ShopBodyOrderSelectTableViewCell: UITableViewCell {
    
    lazy var goodsImageView: UIImageView = {
        let goodsImageView = UIImageView.init()
        goodsImageView.backgroundColor = .white
        goodsImageView.contentMode = .scaleAspectFill
        goodsImageView.layer.masksToBounds = true
        return goodsImageView
    }()
    
    lazy var goodsTitle: UILabel = {
        let goodsTitle = UILabel.init()
        goodsTitle.lineBreakMode = .byClipping
        goodsTitle.numberOfLines = 2
        goodsTitle.textColor = HexColor("#333333")
        goodsTitle.font = regular_adapt_font(pointSize: 14)
        return goodsTitle
    }()
    
    lazy var priceLabel: UILabel = {
        let priceLabel = UILabel.init()
        priceLabel.textColor = HexColor("#FC1541")
        priceLabel.font = medium_adapt_font(pointSize: 21)
        return priceLabel
    }()
    
    lazy var numberLabel: UILabel = {
        let numberLabel = UILabel.init()
        numberLabel.textAlignment = .right
        numberLabel.textColor = HexColor("#222833")
        numberLabel.font = regular_adapt_font(pointSize: 15)
        return numberLabel
    }()
    
    lazy var unNumberLabel: UILabel = {
        let unNumberLabel = UILabel.init()
        unNumberLabel.textAlignment = .right
        unNumberLabel.textColor = HexColor("#222833")
        unNumberLabel.font = regular_adapt_font(pointSize: 15)
        return unNumberLabel
    }()
    
    lazy var lineLabel: UILabel = {
        let lineLabel = UILabel.init()
        lineLabel.backgroundColor = HexColor("#EAEAEA")
        return lineLabel
    }()
    
    lazy var selectButton: UIButton = {
        let selectButton = UIButton.init(type: .custom)
        selectButton.setImage(UIImage(named: "DS_goods_select_no"), for: .normal)
        selectButton.setImage(UIImage(named: "DS_goods_select_yes"), for: .selected)
        selectButton.addTarget(self, action: #selector(buttonClick), for: .touchUpInside)
        selectButton.tag = 1001
        return selectButton
    }()
    
    lazy var addButton: UIButton = {
        let addButton = UIButton.init(type: .custom)
        addButton.setImage(UIImage(named: "DS_goods_add_yes"), for: .normal)
        addButton.setImage(UIImage(named: "DS_goods_add_no"), for: .selected)
        addButton.addTarget(self, action: #selector(buttonClick), for: .touchUpInside)
        addButton.tag = 1002
        return addButton
    }()
    
    lazy var minusButton: UIButton = {
        let minusButton = UIButton(type: .custom)
        minusButton.setImage(UIImage(named: "DS_goods_sub_yes"), for: .normal)
        minusButton.setImage(UIImage(named: "DS_goods_sub_no"), for: .selected)
        minusButton.addTarget(self, action: #selector(buttonClick), for: .touchUpInside)
        minusButton.tag = 1003
        return minusButton
    }()
    
    var clickCallBack: clickButtonCallBack!
    var _goodsModel: ShopOrderListGoodsModel!
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        contentView.backgroundColor = .clear
        selectionStyle = .none
        
        addSubview(selectButton)
        selectButton.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(adapt_length(length: 15))
            make.size.equalTo(adapt_length(length: 17))
        }
        addSubview(goodsImageView)
        goodsImageView.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalTo(selectButton.snp.right).offset(adapt_length(length: 15))
            make.size.equalTo(adapt_length(length: 100))
        }
        addSubview(goodsTitle)
        goodsTitle.snp.makeConstraints { make in
            make.top.equalTo(goodsImageView)
            make.left.equalTo(goodsImageView.snp.right).offset(adapt_length(length: 15))
            make.right.equalToSuperview().offset(-adapt_length(length: 15))
        }
        addSubview(unNumberLabel)
        unNumberLabel.snp.makeConstraints { make in
            make.left.equalTo(goodsTitle)
            make.top.equalTo(goodsTitle.snp.bottom).offset(adapt_length(length: 5))
        }
        addSubview(addButton)
        addButton.snp.makeConstraints { make in
            make.right.bottom.equalToSuperview().offset(-adapt_length(length: 15))
            make.size.equalTo(adapt_length(length: 29))
        }
        addSubview(numberLabel)
        numberLabel.snp.makeConstraints { make in
            make.right.equalTo(addButton.snp.left).offset(-adapt_length(length: 6))
            make.centerY.equalTo(addButton)
        }
        addSubview(minusButton)
        minusButton.snp.makeConstraints { make in
            make.right.equalTo(numberLabel.snp.left).offset(-adapt_length(length: 6))
            make.centerY.equalTo(addButton)
        }
        addSubview(priceLabel)
        priceLabel.snp.makeConstraints { make in
            make.left.equalTo(goodsTitle)
            make.bottom.equalTo(goodsImageView)
        }
        addSubview(lineLabel)
        lineLabel.snp.makeConstraints { make in
            make.left.equalTo(goodsImageView)
            make.right.equalTo(numberLabel)
            make.bottom.equalToSuperview().offset(-adapt_length(length: 0.5))
            make.height.equalTo(adapt_length(length: 0.5))
        }
    }
    
    @objc func buttonClick(sender: UIButton) {
        if sender.tag - 1000 != 1 {
            if sender.isSelected {
                return
            }
            var selectNum = _goodsModel.selectNum
            switch sender.tag - 1001 {
            case 1:
                selectNum! += 1
                break
            case 2:
                selectNum! -= 1
            default:
                break
            }
            _goodsModel.selectNum = selectNum
            numberLabel.text = "\(_goodsModel.selectNum ?? 0)"
            numberLabel.sizeToFit()
            setNeedsLayout()
            if unNumberLabel.isHidden {
                if _goodsModel.num! <= _goodsModel.selectNum! {
                    addButton.isSelected = true
                } else {
                    addButton.isSelected = false
                }
            } else {
                if _goodsModel.send_num! - _goodsModel.refund_num! <= _goodsModel.selectNum! {
                    addButton.isSelected = true
                } else {
                    addButton.isSelected = false
                }
            }
            if _goodsModel.selectNum! > 1 {
                minusButton.isSelected = false
            } else {
                minusButton.isSelected = true
            }
        } else {
            sender.isSelected = !sender.isSelected
            _goodsModel.select = sender.isSelected
            if (clickCallBack != nil) {
                self.clickCallBack(sender.isSelected)
            }
        }
    }
    
    func setupDataSource(goodsModel: ShopOrderListGoodsModel) {
        _goodsModel = goodsModel
        goodsImageView.kf.setImage(with: URL(string: goodsModel.simg!))
        goodsTitle.text = goodsModel.title
        unNumberLabel.text = "剩余发货数量:\(Int(goodsModel.send_num!)-Int(goodsModel.refund_num!))"
        unNumberLabel.isHidden = (Int(goodsModel.send_num!)-Int(goodsModel.refund_num!) == 0)
        unNumberLabel.sizeToFit()
        priceLabel.text = \(goodsModel.price!)"
        priceLabel.sizeToFit()
        numberLabel.text = "\(goodsModel.selectNum ?? 0)"
        numberLabel.sizeToFit()
        
        setNeedsLayout()
        
        if unNumberLabel.isHidden {
            if goodsModel.num! > goodsModel.selectNum! {
                addButton.isSelected = false
            } else {
                addButton.isSelected = true
            }
        } else {
            if (goodsModel.send_num! - goodsModel.refund_num! > goodsModel.selectNum!) {
                addButton.isSelected = false
            } else {
                addButton.isSelected = true
            }
        }
        if goodsModel.selectNum! > 1 {
            minusButton.isSelected = false
        } else {
            minusButton.isSelected = true
        }
        selectButton.isSelected = goodsModel.select
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

class ShopBodyOrderExpressTableViewCell: UITableViewCell, UITextFieldDelegate {
    
    lazy var titleLab: UILabel = {
        let titleLab = UILabel.init()
        titleLab.textColor = HexColor("#3a3a3a")
        titleLab.font = medium_adapt_font(pointSize: 14)
        return titleLab
    }()
    
    lazy var contentTextField: UITextField = {
        let contentTextField = UITextField.init()
        contentTextField.textColor = HexColor("#3a3a3a")
        contentTextField.font = medium_adapt_font(pointSize: 14)
        contentTextField.textAlignment = .left
        contentTextField.clipsToBounds = true
        contentTextField.keyboardType = .default
        contentTextField.delegate = self
        contentTextField.returnKeyType = .done
        return contentTextField
    }()
    
    lazy var rightArrowImageView: UIImageView = {
        let rightArrowImageView = UIImageView.init()
        rightArrowImageView.image = UIImage(named: "mine_header_message_gray_more")
        return rightArrowImageView
    }()
    
    lazy var lineLabel: UILabel = {
        let lineLabel = UILabel.init()
        lineLabel.backgroundColor = HexColor("#EAEAEA")
        return lineLabel
    }()
    
    var row: NSInteger!
    var clickBlock: clickInputCallBack!
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        contentView.backgroundColor = .clear
        selectionStyle = .none
        
        addSubview(titleLab)
        titleLab.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.width.equalTo(adapt_length(length: 100))
            make.left.equalToSuperview().offset(adapt_length(length: 15))
        }
        addSubview(rightArrowImageView)
        rightArrowImageView.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.right.equalToSuperview().offset(-adapt_length(length: 15))
            make.size.equalTo(adapt_length(length: 12))
        }
        addSubview(contentTextField)
        contentTextField.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalTo(titleLab.snp.right).offset(adapt_length(length: 15))
            make.right.equalTo(rightArrowImageView.snp.left).offset(-adapt_length(length: 10))
        }
        addSubview(lineLabel)
        lineLabel.snp.makeConstraints { make in
            make.left.equalTo(adapt_length(length: 10))
            make.right.equalTo(-adapt_length(length: 10))
            make.bottom.equalToSuperview().offset(-adapt_length(length: 0.5))
            make.height.equalTo(adapt_length(length: 0.5))
        }
    }
    
    func setup(title: String, content: String, placeHolder: String, contentIsEdit: Bool, isShowArrowImage: Bool, isShowLine: Bool) {
        titleLab.text = title
        contentTextField.text = content
        contentTextField.placeholder = placeHolder
        contentTextField.isUserInteractionEnabled = contentIsEdit
        rightArrowImageView.isHidden = !isShowArrowImage
        lineLabel.isHidden = !isShowLine
        
        let size = contentTextField.sizeThatFits(CGSize(width: KSreenWidth - adapt_length(length: 145), height: CGFLOAT_MAX))
        
        contentTextField.snp.remakeConstraints { make in
            make.left.equalTo(titleLab.snp.right).offset(adapt_length(length: 15))
            make.top.equalToSuperview().offset(adapt_length(length: 15))
            if rightArrowImageView.isHidden {
                make.right.equalToSuperview().offset(-adapt_length(length: 15))
                make.height.equalTo(size.height > adapt_length(length: 20) ? size.height : adapt_length(length: 20))
            } else {
                make.bottom.equalToSuperview().offset(-adapt_length(length: 15))
                make.right.equalTo(rightArrowImageView.snp.left).offset(-adapt_length(length: 5))
            }
        }
    }
    
    func textFieldDidEndEditing(_ textField: UITextField) {
        if textField == contentTextField {
            if (clickBlock != nil) {
                clickBlock(contentTextField.text!,row)
            }
        }
    }
    func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
        if string == "\n" || contentTextField.text!.count > 20 {
            return false
        } else {
            return true
        }
    }
    
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}


class ShopBodyOrderExpressFirmTableViewCell: UITableViewCell {
    
    lazy var headerImageView: UIImageView = {
        let headerImageView = UIImageView.init()
        headerImageView.backgroundColor = .white
        headerImageView.contentMode = .scaleAspectFill
        headerImageView.layer.masksToBounds = true
        return headerImageView
    }()
    
    lazy var titleLabel: UILabel = {
        let titleLabel = UILabel.init()
        titleLabel.textColor = HexColor("#383838")
        titleLabel.font = regular_adapt_font(pointSize: 15)
        return titleLabel
    }()
    
    lazy var descLabel: UILabel = {
        let descLabel = UILabel.init()
        descLabel.textColor = HexColor("#a5a5a5")
        descLabel.font = light_adapt_font(pointSize: 14)
        return descLabel
    }()
    
    lazy var lineLabel: UILabel = {
        let lineLabel = UILabel.init()
        lineLabel.backgroundColor = HexColor("#EAEAEA")
        return lineLabel
    }()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        contentView.backgroundColor = .clear
        selectionStyle = .none
        
        addSubview(headerImageView)
        headerImageView.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(adapt_length(length: 15))
            make.size.equalTo(adapt_length(length: 36))
        }
        addSubview(titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.top.equalTo(headerImageView.snp.top)
            make.left.equalTo(headerImageView.snp.right).offset(adapt_length(length: 10))
        }
        addSubview(descLabel)
        descLabel.snp.makeConstraints { make in
            make.bottom.equalTo(headerImageView.snp.bottom)
            make.left.equalTo(headerImageView.snp.right).offset(adapt_length(length: 10))
        }
        addSubview(lineLabel)
        lineLabel.snp.makeConstraints { make in
            make.left.equalTo(adapt_length(length: 10))
            make.right.equalTo(-adapt_length(length: 10))
            make.bottom.equalToSuperview().offset(-adapt_length(length: 0.5))
            make.height.equalTo(adapt_length(length: 0.5))
        }
    }
    
    func setupDataSource(model: ShopOrderExpressModel) {
        headerImageView.kf.setImage(with: URL(string: model.simg!))
        titleLabel.text = model.com
        descLabel.text = model.tel
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}