无故事王国
2024-07-24 59bd9f792891efa0d0d69f256e1a146c44c944db
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
//
//  GoodsItemTCell.swift
//  DolphinEnglishLearnManager
//
//  Created by 无故事王国 on 2024/5/20.
//
 
import UIKit
import RxSwift
 
class GoodsItemTCell: UITableViewCell {
                
                @IBOutlet weak var label_state: UILabel!
                @IBOutlet weak var label_goodsName: UILabel!
                @IBOutlet weak var label_types: UILabel!
                @IBOutlet weak var label_goodsNum: UILabel!
                @IBOutlet weak var label_receiptInfo: UILabel!
                @IBOutlet weak var label_sendInfo: UILabel!
                @IBOutlet weak var btn_state: UIButton!
                @IBOutlet weak var label_coin: UILabel!
                @IBOutlet weak var img_cover: UIImageView!
                @IBOutlet weak var view_container: UIView!
 
                private var exchangeRecordModel:ExchangeRecordModel?
                private var disposeBag = DisposeBag()
 
                override func awakeFromNib() {
        super.awakeFromNib()
                                selectionStyle = .none
                                backgroundColor = .clear
                                view_container.jq_addShadows(shadowColor: UIColor(hexStr: "#D9D9D9").withAlphaComponent(0.28), corner: 8, radius: 3, offset: CGSize(width: 0, height: 2), opacity: 1)
    }
 
                func setModel(_ model:ExchangeRecordModel){
                                exchangeRecordModel = model
                                label_goodsNum.text = "商品数量:\(model.count)"
                                label_coin.text = "\(model.integral)积分"
                                label_goodsName.text = model.goodsName
                                label_types.text = model.goodsType.joined(separator: "|")
                                img_cover.sd_setImage(with: URL(string: model.coverImg))
                                var items_consignee = Array<String>()
                                items_consignee.append(model.consigneeName)
                                items_consignee.append(model.consigneePhone)
                                items_consignee.append(model.consigneeAddress)
                                label_receiptInfo.text = "收货信息:" + items_consignee.joined(separator: "|")
 
                                var items_express = Array<String>()
                                items_express.append(model.express)
                                items_express.append(model.expressNumber)
 
                                label_sendInfo.isHidden = items_express.filter({!$0.isEmpty}).count == 0
                                label_sendInfo.text = "发货信息:" + items_express.joined(separator: "|")
 
                                //订单状态1待发货2已发货3已完成
                                switch model.state{
                                                case 1:
                                                                label_state.text = "待发货"
                                                                btn_state.setTitle("修改地址", for: .normal)
                                                                btn_state.isHidden = false
                                                case 2:
                                                                label_state.text = "平台已发货,请耐心等待"
                                                                btn_state.setTitle("已收货", for: .normal)
                                                                btn_state.isHidden = false
                                                case 3:
                                                                label_state.text = "已完成"
                                                                btn_state.isHidden = true
                                                default:
                                                                btn_state.isHidden = true
                                }
                }
 
                @IBAction func handleAction(_ sender: UIButton) {
 
                                switch exchangeRecordModel!.state{
                                                case 1:
                                                                let vc = AddressManageVC(type: .choose)
                                                                vc.title = "修改地址"
                                                                vc.chooseAddress { m in
                                                                                CommonAlertView.show(content: "确认修改当前收货地址吗?") {[weak self] () in
                                                                                                guard let weakSelf = self else { return }
                                                                                                if weakSelf.exchangeRecordModel?.consigneeAddress == m.address && weakSelf.exchangeRecordModel?.consigneeName == m.recipient && weakSelf.exchangeRecordModel?.consigneePhone == m.recipientPhone{
                                                                                                                alertError(msg: "修改地址信息与原地址信息相同");return
                                                                                                }
 
                                                                                                Services.updateOrderAddress(orderId: weakSelf.exchangeRecordModel!.orderId, recipientId: m.id).subscribe(onNext: {data in
                                                                                                                alertSuccess(msg: "修改成功")
                                                                                                                DispatchQueue.main.asyncAfter(delay: 1.8) {
                                                                                                                                NotificationCenter.default.post(name: Refresh_MarketExchange_Noti, object: nil)
                                                                                                                }
                                                                                                }).disposed(by: weakSelf.disposeBag)
                                                                                }
                                                                }
                                                                JQ_currentViewController().jq_push(vc: vc)
                                                case 2:
                                                                CommonAlertView.show(isSinple: false, content: "确认已收到货吗?") {[weak self] () in
                                                                                guard let weakSelf = self else { return }
                                                                                Services.confirmStudy(id: weakSelf.exchangeRecordModel!.orderId).subscribe(onNext: {data in
                                                                                                DispatchQueue.main.asyncAfter(delay: 1.8) {
                                                                                                                NotificationCenter.default.post(name: Refresh_MarketExchange_Noti, object: nil)
                                                                                                }
                                                                                }).disposed(by: weakSelf.disposeBag)
                                                                }
                                                default:break
                                }
                }
 
}