宽窄优行-由【嘉易行】项目成品而来
younger_times
2023-04-11 4356615a9252a987a62469331b1fcf91c102e24c
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
//
//  ValuationRuleVC.swift
//  OKProject
//
//  Created by 无故事王国 on 2022/6/30.
//  Copyright © 2022 yangwang. All rights reserved.
//
 
import UIKit
 
class ValuationRuleVC:YYViewController {
 
    var attribute = AttributedStringbuilder()
    var type:Int = 0 // 10:拼座 11:独享 12:一口价
//    var model:YYCarTypeModel?
//    var model:YYSpecialCarModel?
    var model:Any?
    var textView:UITextView! = UITextView()
 
    private var contentPutOne:CarTypeContent!
    private var contentNotOne:CarTypeContent!
    private var contentPutTwo:CarTypeContent!
    private var contentNotTwo:CarTypeContent!
    private var contentPutThree:CarTypeContent!
    private var contentNotThree:CarTypeContent!
    private var contentExclusive:CarTypeContent!
    private var contentPrice:CarTypeContent!
    private var fareTypeNote1:String = ""
    private var fareTypeNote2:String = ""
    private var fareTypeNote3:String = ""
 
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "计价规则"
 
        view.addSubview(textView)
        textView.isEditable = false
        textView.snp.makeConstraints { make in
            make.edges.equalToSuperview().inset(UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10))
        }
 
        let titleFront = UIFont.systemFont(ofSize: 15, weight: .medium)
        let contentFront = UIFont.systemFont(ofSize: 14)
 
        guard model != nil else {return}
 
        if let m = model as? YYCarTypeModel{
            contentPutOne = m.contentPutOne
            contentNotOne = m.contentNotOne
            contentPutTwo = m.contentPutTwo
            contentNotTwo = m.contentNotTwo
            contentPutThree = m.contentPutThree
            contentNotThree = m.contentNotThree
            contentExclusive = m.contentExclusive
            contentPrice = m.contentPrice
            fareTypeNote1 = m.fareTypeNote1
            fareTypeNote2 = m.fareTypeNote2
            fareTypeNote3 = m.fareTypeNote3
        }
 
        if let m = model as? YYSpecialCarModel{
            contentPutOne = m.contentPutOne
            contentNotOne = m.contentNotOne
            contentPutTwo = m.contentPutTwo
            contentNotTwo = m.contentNotTwo
            contentPutThree = m.contentPutThree
            contentNotThree = m.contentNotThree
            contentExclusive = m.contentExclusive
            contentPrice = m.contentPrice
            fareTypeNote1 = m.fareTypeNote1
            fareTypeNote2 = m.fareTypeNote2
            fareTypeNote3 = m.fareTypeNote3
        }
 
 
 
        if type == 10{
            attribute = attribute.add(string: "1人拼成\n", withFont: titleFront, withColor: .black,lineSpace: 10)
            attribute = attribute.add(string: mutableText(contentPutOne), withFont: contentFront, withColor: .black,lineSpace: 4)
            attribute = attribute.add(string: "\n\n1人未拼成\n", withFont: titleFront, withColor: .black,lineSpace: 10)
            attribute = attribute.add(string: mutableText(contentNotOne), withFont: contentFront, withColor: .black,lineSpace: 4)
            attribute = attribute.add(string: "\n\n2人拼成\n", withFont: titleFront, withColor: .black,lineSpace: 10)
            attribute = attribute.add(string:  mutableText(contentPutTwo), withFont: contentFront, withColor: .black,lineSpace: 4)
            attribute = attribute.add(string: "\n\n2人未拼成\n", withFont: titleFront, withColor: .black,lineSpace: 10)
            attribute = attribute.add(string:  mutableText(contentNotTwo), withFont: contentFront, withColor: .black,lineSpace: 4)
            attribute = attribute.add(string: "\n\n3人拼成\n", withFont: titleFront, withColor: .black,lineSpace: 10)
            attribute = attribute.add(string:  mutableText(contentPutThree), withFont: contentFront, withColor: .black,lineSpace: 4)
            attribute = attribute.add(string: "\n\n3人未拼成\n", withFont: titleFront, withColor: .black,lineSpace: 10)
            attribute = attribute.add(string:  mutableText(contentNotThree), withFont: contentFront, withColor: .black,lineSpace: 4)
            attribute = attribute.add(string: "\n\n计价说明\n", withFont: titleFront, withColor: .black,lineSpace: 10)
            attribute = attribute.add(string: fareTypeNote1, withFont: contentFront, withColor: .black,lineSpace: 4)
        }
        if type == 11{
            attribute = attribute.add(string: "独享\n", withFont: titleFront, withColor: .black,lineSpace: 10)
            attribute = attribute.add(string: mutableText(contentExclusive), withFont: contentFront, withColor: .black,lineSpace: 4)
            attribute = attribute.add(string: "\n\n计价说明\n", withFont: titleFront, withColor: .black,lineSpace: 10)
            attribute = attribute.add(string: fareTypeNote2, withFont: contentFront, withColor: .black,lineSpace: 4)
        }
 
        if type == 12{
            attribute = attribute.add(string: "一口价\n", withFont: titleFront, withColor: .black,lineSpace: 10)
            attribute = attribute.add(string: mutableText(contentPrice), withFont: contentFront, withColor: .black,lineSpace: 4)
            attribute = attribute.add(string: "\n\n计价说明\n", withFont: titleFront, withColor: .black,lineSpace: 10)
            attribute = attribute.add(string: fareTypeNote3, withFont: contentFront, withColor: .black,lineSpace: 4)
        }
 
        textView.attributedText = attribute.mutableAttributedString
    }
 
    private func mutableText(_ content:CarTypeContent)->String{
        var text = String()
        text = text.appending("起步价:起步价为")
        text = text.appending("\(content.num1)元,起步包含")
        text = text.appending("\(content.num2)公里,最多")
        text = text.appending("\(content.num3)分钟\n里程费:超过起步里程后每公里")
        text = text.appending("\(content.num4)元\n时长费:超过起步时长后每分钟")
        text = text.appending("\(content.num5)元\n远途费:总里程超过")
        text = text.appending("\(content.num6)公里不足")
        text = text.appending("\(content.num7)公里,超过部分每公里加收")
        text = text.appending("\(content.num8)元,超过")
        text = text.appending("\(content.num9)公里不足")
        text = text.appending("\(content.num10)公里时,超出部分每公里加收")
        text = text.appending("\(content.num11)元超过")
        text = text.appending("\(content.num12)公里以后,超出部分每公里加收")
        text = text.appending("\(content.num13)元\n夜间行驶费:")
        text = text.appending("\(content.num14)点位夜间行驶时间,起步价变为")
        text = text.appending("\(content.num15)元,里程费每公里")
        text = text.appending("\(content.num16)元,时长费每分钟")
        text = text.appending("\(content.num17)元,远途费每公里加收")
        text = text.appending("\(content.num18),")
        text = text.appending("\(content.num19),")
        text = text.appending("\(content.num20)元\n高峰期费用:")
        text = text.appending("\(content.num21)和")
        text = text.appending("\(content.num22)为高峰期行车时间,起步价变成")
        text = text.appending("\(content.num23)元,里程费为每公里")
        text = text.appending("\(content.num24)元,时长费为每分钟")
        text = text.appending("\(content.num25)元,远途费为每公里加收")
        text = text.appending("\(content.num26),")
        text = text.appending("\(content.num27),")
        text = text.appending("\(content.num28)元")
        return text
    }
 
}