123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- //
- // OrderListCell.swift
- // ADHTuanCan
- //
- // Created by 敖德亨 on 2023/10/8.
- //
- import UIKit
- import SwiftyUserDefaults
- class OrderListCell: UITableViewCell {
-
- /// 头像
- @IBOutlet weak var headImh: UIImageView!
-
- /// 内容
- @IBOutlet weak var contentLab: UILabel!
-
- /// 状态
- @IBOutlet weak var typeLab: UILabel!
-
- /// 计数lab
- @IBOutlet weak var numCountLab: UILabel!
-
- /// 价格
- @IBOutlet weak var priceLab: UILabel!
-
- @IBOutlet weak var foodView1: UIView!
-
- @IBOutlet weak var foodView2: UIView!
-
- @IBOutlet weak var foodView3: UIView!
-
- @IBOutlet weak var foodView4: UIView!
-
- @IBOutlet weak var foodName1: UILabel!
-
- @IBOutlet weak var foodImg1: UIImageView!
-
- @IBOutlet weak var foodLabOne: UILabel!
-
- @IBOutlet weak var foodLab2: UILabel!
-
- @IBOutlet weak var foodImg2: UIImageView!
-
- @IBOutlet weak var foodName3: UILabel!
-
- @IBOutlet weak var foodImg3: UIImageView!
-
- @IBOutlet weak var foodName4: UILabel!
-
- @IBOutlet weak var foodImg4: UIImageView!
- var dataModel : OrderListModel?
- ///待付款
- @IBOutlet weak var willPayView: UIView!
- ///完成未评论
- @IBOutlet weak var commentView: UIView!
- ///已完成
- @IBOutlet weak var finishView: UIView!
- ///待配送 配送中
- @IBOutlet weak var deliveryView: UIView!
-
- /// 列表按钮点击 1去支付 ,2取消订单
- var callBackBlock : ((_ type : Int)->Void)?
-
-
- override func awakeFromNib() {
- super.awakeFromNib()
- // Initialization code
- }
- func showBtnViewWithType(type : String){
- //待付款
- if type === 1{
- self.willPayView.isHidden = false
- self.deliveryView.isHidden = true
- self.commentView.isHidden = true
- self.finishView.isHidden = true
- }
-
- //待接单
- if type === 2{
- self.willPayView.isHidden = true
- self.deliveryView.isHidden = true
- self.commentView.isHidden = true
- self.finishView.isHidden = true
- }
-
- //待配送
- if type === 3{
- self.willPayView.isHidden = true
- self.deliveryView.isHidden = false
- self.commentView.isHidden = true
- self.finishView.isHidden = true
- }
-
- //已完成
- if type === 4 || type === 5 || type === 6 || type === 7{
- self.willPayView.isHidden = true
- self.deliveryView.isHidden = true
- self.commentView.isHidden = true
- self.finishView.isHidden = false
- }
-
- //待评论
- if type === 8{
- self.willPayView.isHidden = true
- self.deliveryView.isHidden = true
- self.commentView.isHidden = false
- self.finishView.isHidden = true
- }
-
- }
-
- func configModel(model : OrderListModel){
- self.dataModel = model
- self.foodView4.isHidden = true
- if model.link == nil{
- self.headImh.sd_setImage(url: URL.init(string: Defaults[\.Avatar] ?? "") ,placeHolderImage: UIImage.init(named: "placeHolderImage"))
- }else{
- self.headImh.sd_setImage(url: URL.init(string: model.link ?? "") ,placeHolderImage: UIImage.init(named: "placeHolderImage"))
- }
-
- self.contentLab.text = "\(model.orderName ?? "")"
-
- self.priceLab.text = "s$\(model.orderPrice ?? "")"
-
- self.numCountLab.text = LanguagesUtil.createTextBy(Ctext: "共\(model.orderMeals?.count ?? 0)件", Etext: "total \(model.orderMeals?.count ?? 0)")
-
- self.showBtnViewWithType(type: model.status ?? "4")
- if model.status === 1{
- self.typeLab.text = LanguagesUtil.createTextBy(Ctext: "待付款", Etext: "Wait for payment")
- self.typeLab.textColor = UIColor.orange
- }
- if model.status === 2{
- self.typeLab.text = "待接单"
- self.typeLab.text = LanguagesUtil.createTextBy(Ctext: "待接单", Etext: "Waiting fo accept the order")
- self.typeLab.textColor = kThemeOfTextDarkColor
- }
- if model.status === 3{
- self.typeLab.text = "待配送"
- self.typeLab.text = LanguagesUtil.createTextBy(Ctext: "待配送", Etext: "Waiting for delivery")
- self.typeLab.textColor = kThemeColor
- }
- if model.status === 4{
- self.typeLab.text = "已完成"
- self.typeLab.text = LanguagesUtil.createTextBy(Ctext: "已完成", Etext: "Finished")
- self.typeLab.textColor = kThemeOfTextDarkColor
- }
- if model.status === 5{
- self.typeLab.text = "已取消"
- self.typeLab.text = LanguagesUtil.createTextBy(Ctext: "已取消", Etext: "Canceled")
- self.typeLab.textColor = kThemeOfTextDarkColor
- }
- if model.status === 6{
- self.typeLab.text = "退款中"
- self.typeLab.text = LanguagesUtil.createTextBy(Ctext: "退款中", Etext: "Being refunded")
- self.typeLab.textColor = kThemeOfTextDarkColor
- }
- if model.status === 7{
- self.typeLab.text = "已退款"
- self.typeLab.text = LanguagesUtil.createTextBy(Ctext: "已退款", Etext: "Refunded")
- self.typeLab.textColor = kThemeOfTextDarkColor
- }
- if model.status === 8{
- //已评价
- self.typeLab.text = "已完成"
- self.typeLab.text = LanguagesUtil.createTextBy(Ctext: "已完成", Etext: "Finished")
- self.typeLab.textColor = kThemeOfTextDarkColor
- }
-
-
-
- if model.orderMeals?.count ?? 0 > 2{
- self.foodLabOne.isHidden = true
- self.foodName1.isHidden = false
- self.foodView2.isHidden = false
- self.foodView3.isHidden = false
- for i in 0..<3{
- let item : OrderListModelItem = model.orderMeals![i]
- if i == 0{
- self.foodLabOne.text = "\(item.name ?? "")"
- self.foodName1.text = "\(item.name ?? "")"
- self.foodImg1.sd_setImage(url: URL.init(string: item.link ?? "") ,placeHolderImage: UIImage.init(named: "placeHolderImage"))
- }
- if i == 1{
- self.foodLab2.text = "\(item.name ?? "")"
- self.foodImg2.sd_setImage(url: URL.init(string: item.link ?? "") ,placeHolderImage: UIImage.init(named: "placeHolderImage"))
- }
- if i == 2{
- self.foodName3.text = "\(item.name ?? "")"
- self.foodImg3.sd_setImage(url: URL.init(string: item.link ?? "") ,placeHolderImage: UIImage.init(named: "placeHolderImage"))
- }
- }
-
- if model.orderMeals?.count ?? 0 > 3{
- self.foodView4.isHidden = false
- let item : OrderListModelItem = model.orderMeals![3]
- self.foodName4.text = "\(item.name ?? "")"
- self.foodImg4.sd_setImage(url: URL.init(string: item.link ?? "") ,placeHolderImage: UIImage.init(named: "placeHolderImage"))
- }
-
- }else{
- if model.orderMeals?.count == 1{
- self.foodLabOne.isHidden = false
- self.foodName1.isHidden = true
- let item : OrderListModelItem = model.orderMeals![0]
- self.foodLabOne.text = "\(item.name ?? "")"
- self.foodName1.text = "\(item.name ?? "")"
- self.foodImg1.sd_setImage(url: URL.init(string: item.link ?? "") ,placeHolderImage: UIImage.init(named: "placeHolderImage"))
- self.foodView2.isHidden = true
- self.foodView3.isHidden = true
- }
- if model.orderMeals?.count == 2{
- self.foodLabOne.isHidden = true
- self.foodName1.isHidden = false
- self.foodView2.isHidden = false
- self.foodView3.isHidden = true
- for i in 0..<2{
- let item : OrderListModelItem = model.orderMeals![i]
- if i == 0{
- self.foodLabOne.text = "\(item.name ?? "")"
- self.foodName1.text = "\(item.name ?? "")"
- self.foodImg1.sd_setImage(url: URL.init(string: item.link ?? "") ,placeHolderImage: UIImage.init(named: "placeHolderImage"))
- }
- if i == 1{
- self.foodLab2.text = "\(item.name ?? "")"
- self.foodImg2.sd_setImage(url: URL.init(string: item.link ?? "") ,placeHolderImage: UIImage.init(named: "placeHolderImage"))
- }
- }
- }
- if model.orderMeals?.count == 3{
- self.foodLabOne.isHidden = true
- self.foodName1.isHidden = false
- self.foodView2.isHidden = false
- self.foodView3.isHidden = false
- for i in 0..<3{
- let item : OrderListModelItem = model.orderMeals![i]
- if i == 0{
- self.foodLabOne.text = "\(item.name ?? "")"
- self.foodName1.text = "\(item.name ?? "")"
- self.foodImg1.sd_setImage(url: URL.init(string: item.link ?? "") ,placeHolderImage: UIImage.init(named: "placeHolderImage"))
- }
- if i == 1{
- self.foodLab2.text = "\(item.name ?? "")"
- self.foodImg2.sd_setImage(url: URL.init(string: item.link ?? "") ,placeHolderImage: UIImage.init(named: "placeHolderImage"))
- }
- if i == 2{
- self.foodName3.text = "\(item.name ?? "")"
- self.foodImg3.sd_setImage(url: URL.init(string: item.link ?? "") ,placeHolderImage: UIImage.init(named: "placeHolderImage"))
- }
- }
- }
- }
- }
-
- func setFoodViewDetail(){
-
- }
-
- /// 去支付
- /// - Parameter sender: <#sender description#>
- @IBAction func gotoPayAction(_ sender: UIButton) {
- if self.callBackBlock != nil{
- self.callBackBlock!(1)
- }
- }
-
- /// 取消订单
- /// - Parameter sender: <#sender description#>
- @IBAction func cancelAction(_ sender: UIButton) {
- if self.callBackBlock != nil{
- self.callBackBlock!(2)
- }
- }
-
- }
|