Commit 7e2e0ddd authored by 刘俊宏's avatar 刘俊宏

完成订单列表的付款码功能

parent 9e4c6c37
......@@ -99,7 +99,7 @@ func orderTypeStrByInt(statusNumber:Int) -> String? {
return str
}
//MARK:--根据order_status_d返回字符串状态
func orderStatusStrByInt(leftBtn:UIButton,rightBtn:UIButton,statusNumber:Int) -> String? {
func orderStatusStrByIntAndBtn(leftBtn:UIButton,rightBtn:UIButton,statusNumber:Int) -> String? {
var str = ""
leftBtn.isHidden = true
rightBtn.setTitle("查看详情", for: .normal)
......
......@@ -2,6 +2,7 @@
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
......@@ -272,7 +273,7 @@
<outlet property="submitBtn" destination="zm2-s9-DRT" id="Rct-tD-0rx"/>
<outlet property="typeLbl" destination="nLT-tE-vtc" id="KoZ-qA-tLi"/>
</connections>
<point key="canvasLocation" x="176.08695652173915" y="181.80803571428569"/>
<point key="canvasLocation" x="-164" y="64"/>
</tableViewCell>
</objects>
<resources>
......
......@@ -9,7 +9,7 @@
import UIKit
import ViewAnimator //cell动效
class OrderListVC: BaseViewController, UITableViewDelegate, UITableViewDataSource, DaiQueRenCellDelegate, GeliAlertViewDelegate, OrderDViewControllerDelegate{
class OrderListVC: BaseViewController, UITableViewDelegate, UITableViewDataSource, GeliAlertViewDelegate, OrderDViewControllerDelegate,CGDListCellDelegate{
//MARK:--基础数据
var keyword: String = ""
var startTime : Int = 0
......@@ -150,7 +150,7 @@ class OrderListVC: BaseViewController, UITableViewDelegate, UITableViewDataSourc
tableV.delegate = self
tableV.dataSource = self
tableV.separatorStyle = .none
tableV?.register(UINib(nibName: "DaiQueRenCell", bundle: nil), forCellReuseIdentifier: "DaiQueRenCell")
tableV?.register(UINib(nibName: "CGDListCell", bundle: nil), forCellReuseIdentifier: "CGDListCell")
let footerTbV = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.size.width, height: 15*glscale))
footerTbV.backgroundColor = UIColor.init(named: "app底色")
......@@ -171,67 +171,59 @@ class OrderListVC: BaseViewController, UITableViewDelegate, UITableViewDataSourc
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "DaiQueRenCell") as! DaiQueRenCell
let cell = tableView.dequeueReusableCell(withIdentifier: "CGDListCell") as! CGDListCell
let rowModel = self.dataArr[indexPath.row]
cell.cancelBtn.isHidden = false
cell.submitBtn.isHidden = false
cell.submitBtn.tag = indexPath.row
cell.cancelBtn.tag = indexPath.row
cell.nameLbl.text = rowModel.user_name
if rowModel.cus_name != nil {
cell.nameLbl.text = rowModel.cus_name
}
cell.statusLbl.text = orderStatusStrByInt(leftBtn: cell.cancelBtn, rightBtn: cell.submitBtn, statusNumber: rowModel.order_status!)
cell.accountLbl.text = rowModel.order_sn
cell.leftIcon.isHidden = true
cell.nameLblLeft.constant = -15
cell.nameLbl.text = rowModel.order_sn
cell.statusLbl.text = orderStatusStrByInt(statusNumber: rowModel.order_status!)
cell.countLbl.text = "\(rowModel.goods_number!)"
cell.priceLbl.text = rowModel.sum_amount
cell.timeLbl.text = TimeByDouble(sender: rowModel.add_time!)
cell.typeLbl.text = orderTypeStrByInt(statusNumber: rowModel.order_type!)
cell.formLbl.isHidden = true
cell.yuShouStatus.isHidden = true
if rowModel.order_type == 1 {
cell.typeLbl.isHidden = true
cell.yuShouStatus.isHidden = true
}else{
cell.typeLbl.isHidden = false
cell.yuShouStatus.isHidden = false
}
if rowModel.from == 3 {
cell.formLbl.isHidden = false
cell.typeLbl.isHidden = true
cell.yuShouStatus.isHidden = true
}else{
cell.formLbl.isHidden = true
}
if rowModel.order_type == 4 {
cell.formLbl.isHidden = true
cell.typeLbl.isHidden = false
cell.yuShouStatus.isHidden = false
}
cell.dateLbl.text = dayAndTimeByDouble(sender: rowModel.add_time!)
cell.countLbl.text = "商品数量:\(rowModel.goods_number!)"
cell.priceLbl.text = "金额:¥\(rowModel.sum_amount!)"
var btnStr:Array<String> = []
switch rowModel.order_status {
case 0:
btnStr = ["确认订单","取消订单"]
break
case 1:
btnStr = ["取消订单"]
break
default:
btnStr = ["查看详情"]
break
}
if rowModel.order_status! == 1 {
btnStr.append("付款码")
}
cell.delegate = self
cell.setBtnView(arr: btnStr, index: indexPath.row)
cell.dataArr = rowModel.order_goods
return cell
}
//MARK:--如果存在操作是否需要自动刷新?
func cancel(sender: UIButton) {
print(sender.tag)
//取消订单
isSrueOrder = false
let rowModel = self.dataArr[sender.tag]
let alertView = GeliAlertView(frame: self.view.window!.bounds)
alertView.delegate = self;
alertView.tishiLbl.text = ""
alertView.titileLbl.text = "是否确认取消订单?"
alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "确认"), for: .normal)
alertView.rightBtn.tag = rowModel.order_id!
self.view.window?.addSubview(alertView)
//MARK:--付款码测试完成
// let alertView = GeliAltetCodeView(frame: self.view.window!.bounds)
//
// alertView.saveImgID = rowModel.order_id!
// self.view.window?.addSubview(alertView)
}
var isSrueOrder = false
func submit(sender: UIButton) {
func allBtnSubmit(sender: UIButton) {
print(sender.tag)
let rowModel = self.dataArr[sender.tag]
if sender.titleLabel?.text == "确认订单" {
......@@ -257,6 +249,12 @@ class OrderListVC: BaseViewController, UITableViewDelegate, UITableViewDataSourc
self.view.window?.addSubview(alertView)
}else if sender.titleLabel?.text == "付款码" {
//MARK:--付款码测试完成
let alertView = GeliAltetCodeView(frame: self.view.window!.bounds)
alertView.saveImgID = rowModel.order_id!
self.view.window?.addSubview(alertView)
}else {
//跳转订单详情
let vc = OrderDViewController()
......@@ -305,7 +303,9 @@ class OrderListVC: BaseViewController, UITableViewDelegate, UITableViewDataSourc
self.tableV.mj_header?.beginRefreshing()
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 224
let rowModel = self.dataArr[indexPath.row]
return CGFloat(172 + (49 * rowModel.order_goods!.count))
}
}
......@@ -216,6 +216,12 @@ class OrderDViewController: BaseViewController,UITableViewDelegate,UITableViewDa
alertView.rightBtn.tag = 1005
self.view.window?.addSubview(alertView)
break
case "付款码":
let alertView = GeliAltetCodeView(frame: self.view.window!.bounds)
alertView.saveImgID = orderId
self.view.window?.addSubview(alertView)
break
default:
break
......@@ -1071,7 +1077,7 @@ class OrderDViewController: BaseViewController,UITableViewDelegate,UITableViewDa
break
case 1:
// str = "已确定" "待付款"
titleArr = ["修改价格","打印","取消订单"]
titleArr = ["修改价格","打印","付款码","取消订单"]
break
case 6:
// str = "待发货"
......
......@@ -7,8 +7,12 @@
//
import UIKit
protocol CGDListCellDelegate {
func allBtnSubmit(sender: UIButton)
}
class CGDListCell: UITableViewCell {
//销售下单图标
@IBOutlet weak var formLbl: UILabel!
///预售图标
@IBOutlet weak var yuShouStatus: UILabel!
///标题左间距
......@@ -27,8 +31,13 @@ class CGDListCell: UITableViewCell {
@IBOutlet weak var statusLbl: UILabel!
///标题
@IBOutlet weak var nameLbl: UILabel!
///时间
@IBOutlet weak var timeLbl: UILabel!
var delegate:CGDListCellDelegate?
var dataArr:Array<Any>?
//订单列表数据
var dataArr:Array<OrderListGoodsModel>?
override func awakeFromNib() {
super.awakeFromNib()
......@@ -43,13 +52,62 @@ class CGDListCell: UITableViewCell {
super.layoutIfNeeded()
}
func setBtnView(arr:Array<Any>){
//订单列表设置底部按钮
func setBtnView(arr:Array<Any>,index:Int){
//按钮
btnBgView.subviews.forEach { (view) in
view.removeFromSuperview()
}
var tempBtn:UIButton? = nil
arr.forEach { (str) in
let rightBtn = UIButton(type: .custom)
rightBtn.layer.borderWidth = 1
rightBtn.tag = index
rightBtn.backgroundColor = UIColor.white
rightBtn.layer.borderColor = UIColor.init(named: "按钮背景颜色")?.cgColor
rightBtn.setTitleColor(UIColor.init(named: "按钮背景颜色"), for: .normal)
rightBtn.titleLabel?.font = UIFont.systemFont(ofSize: 13)
rightBtn.layer.cornerRadius = 2
if str as! String == "查看详情"{
rightBtn.setTitle("查看详情", for: .normal)
}else if str as! String == "确认订单"{
rightBtn.setTitle("确认订单", for: .normal)
rightBtn.setTitleColor(UIColor.white, for: .normal)
rightBtn.backgroundColor = UIColor.init(named: "按钮背景颜色")
rightBtn.layer.borderColor = UIColor.init(named: "按钮背景颜色")?.cgColor
}else if str as! String == "取消订单"{
rightBtn.setTitle("取消订单", for: .normal)
}else if str as! String == "付款码"{
rightBtn.setTitle("付款码", for: .normal)
}
btnBgView.addSubview(rightBtn)
if tempBtn == nil {
rightBtn.snp.makeConstraints { (make) in
make.width.equalTo(82*glscale)
make.height.equalTo(30)
make.right.equalTo(0)
make.top.equalTo(0)
}
}else{
rightBtn.snp.makeConstraints { (make) in
make.width.equalTo(82*glscale)
make.height.equalTo(30)
make.right.equalTo(tempBtn!.snp_left).offset(-15)
make.top.equalTo(0)
}
}
rightBtn.addTarget(self, action: #selector(btnAction(sender:)), for: .touchUpInside)
tempBtn = rightBtn
}
func setListView(arr:Array<Any>){
}
//订单列表底部按钮方法
@objc func btnAction(sender:UIButton){
self.delegate?.allBtnSubmit(sender: sender)
}
//订单列表设置数据
func setListView(arr:Array<OrderListGoodsModel>){
//列表
listBgView.subviews.forEach { (view) in
view.removeFromSuperview()
......@@ -62,7 +120,7 @@ class CGDListCell: UITableViewCell {
num = arr.count
}
for i in 0 ..< num {
// let model = dataArr![i]
let model = dataArr![i]
let view = UIView()
listBgView.addSubview(view)
view.backgroundColor = UIColor.white
......@@ -84,17 +142,19 @@ class CGDListCell: UITableViewCell {
let lbl = UILabel()
lbl.font = UIFont.systemFont(ofSize: 13)
lbl.textColor = UIColor(named: "灰色字体颜色")
// lbl.text = model.goods_name
lbl.text = model.goods_name
view.addSubview(lbl)
lbl.snp.makeConstraints { (make) in
make.left.equalTo(15)
make.bottom.top.right.equalTo(0)
make.bottom.top.equalTo(0)
make.right.equalTo(-80*glscale)
}
let lbl2 = UILabel()
lbl2.font = UIFont.systemFont(ofSize: 13)
lbl2.textColor = UIColor(named: "灰色字体颜色")
// lbl2.text = "x" + "\(model.number!)"
lbl2.text = "x" + "\(model.goods_number!)"
lbl2.textAlignment = .right
view.addSubview(lbl2)
lbl2.snp.makeConstraints { (make) in
......
......@@ -145,6 +145,27 @@
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</label>
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="销售下单" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Zir-Fk-Cq5">
<rect key="frame" x="67" y="15" width="54" height="18"/>
<constraints>
<constraint firstAttribute="width" constant="54" id="78U-nU-5I5"/>
<constraint firstAttribute="height" constant="18" id="tPz-Tv-vSH"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<color key="textColor" name="蓝色字体颜色"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="borderColor">
<color key="value" name="蓝色字体颜色"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
<real key="value" value="1"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
<real key="value" value="2"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</label>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
......@@ -154,6 +175,8 @@
<constraint firstItem="ekx-rs-uaM" firstAttribute="leading" secondItem="CPQ-JB-dO9" secondAttribute="trailing" constant="5" id="5O5-f0-Pp7"/>
<constraint firstItem="ekx-rs-uaM" firstAttribute="centerY" secondItem="CPQ-JB-dO9" secondAttribute="centerY" id="66g-c2-yre"/>
<constraint firstItem="CPQ-JB-dO9" firstAttribute="centerY" secondItem="HVh-eU-WcT" secondAttribute="centerY" id="6qc-GO-WUG"/>
<constraint firstItem="Zir-Fk-Cq5" firstAttribute="leading" secondItem="CPQ-JB-dO9" secondAttribute="trailing" constant="5" id="ANa-Hm-2AY"/>
<constraint firstItem="Zir-Fk-Cq5" firstAttribute="centerY" secondItem="CPQ-JB-dO9" secondAttribute="centerY" id="Ds1-Oi-62z"/>
<constraint firstItem="CPQ-JB-dO9" firstAttribute="leading" secondItem="HVh-eU-WcT" secondAttribute="trailing" constant="5" id="F2c-jm-aNc"/>
<constraint firstItem="HVh-eU-WcT" firstAttribute="leading" secondItem="xNb-6a-mWT" secondAttribute="leading" constant="15" id="I5S-Pm-VYW"/>
<constraint firstAttribute="trailing" secondItem="7hI-Mv-St2" secondAttribute="trailing" id="OFd-nP-Oac"/>
......@@ -189,12 +212,14 @@
<connections>
<outlet property="btnBgView" destination="KO3-dv-aSL" id="FKG-4d-9rD"/>
<outlet property="countLbl" destination="J1p-oh-7KC" id="brI-AH-qUH"/>
<outlet property="formLbl" destination="Zir-Fk-Cq5" id="umP-9h-1on"/>
<outlet property="leftIcon" destination="HVh-eU-WcT" id="dMO-qL-wPe"/>
<outlet property="listBgView" destination="ZEQ-bR-jNZ" id="tlg-VJ-Qsv"/>
<outlet property="nameLbl" destination="CPQ-JB-dO9" id="iu0-NX-a71"/>
<outlet property="nameLblLeft" destination="F2c-jm-aNc" id="HWs-sw-XVh"/>
<outlet property="priceLbl" destination="gXv-WF-NRU" id="VRb-af-Nta"/>
<outlet property="statusLbl" destination="2ga-12-xdH" id="rf1-RB-YLe"/>
<outlet property="timeLbl" destination="3yk-m6-Ebz" id="vn8-8A-1YE"/>
<outlet property="yuShouStatus" destination="ekx-rs-uaM" id="O20-FR-ggQ"/>
</connections>
<point key="canvasLocation" x="131.15942028985509" y="96.428571428571431"/>
......@@ -220,5 +245,8 @@
<namedColor name="灰色分界线">
<color red="0.92941176470588238" green="0.92941176470588238" blue="0.92941176470588238" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="蓝色字体颜色">
<color red="0.27843137254901962" green="0.5607843137254902" blue="0.8901960784313725" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
</resources>
</document>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment