//
|
// StoresInfoView.swift
|
// WanPai
|
//
|
// Created by 杨锴 on 2023/6/14.
|
//
|
|
import UIKit
|
import JQTools
|
import QMUIKit
|
|
class StoresInfoView: UIView,JQNibView{
|
@IBOutlet weak var label_topTitle: UILabel!
|
@IBOutlet weak var view_container: UIView!
|
@IBOutlet weak var img_logo: UIImageView!
|
@IBOutlet weak var label_title: UILabel!
|
@IBOutlet weak var label_address: UILabel!
|
@IBOutlet weak var label_distance: UILabel!
|
@IBOutlet weak var btn_exchange: QMUIButton!
|
|
|
private var clouse:((Bool)->Void)!
|
private var storeType:StoreType!
|
|
enum StoreType{
|
case normal
|
case worldCup
|
}
|
|
override func awakeFromNib() {
|
super.awakeFromNib()
|
view_container.transform = .init(scaleX: 0.1, y: 0.1)
|
alpha = 0
|
layoutIfNeeded()
|
btn_exchange.imagePosition = .top
|
btn_exchange.spacingBetweenImageAndTitle = 8
|
}
|
|
static func show(_ detailModel:CourseDetailModel,clouse:@escaping (Bool)->Void){
|
let storesView = StoresInfoView.jq_loadNibView()
|
storesView.frame = sceneDelegate?.window?.frame ?? .zero
|
storesView.label_topTitle.text = "请报名预约门店"
|
storesView.img_logo.sd_setImage(with: URL(string: detailModel.storeCoverDrawing))
|
storesView.label_title.text = detailModel.storeName
|
storesView.label_address.text = detailModel.storeAddress
|
storesView.label_distance.text = String(format: "距你%.2lfkm", detailModel.distance)
|
storesView.clouse = clouse
|
sceneDelegate?.window?.addSubview(storesView)
|
|
UIView.animate(withDuration: 0.4) {
|
storesView.view_container.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
|
storesView.alpha = 1
|
}
|
}
|
|
static func show(_ activityModel:ActivityDetailStoreModel,type:StoresInfoView.StoreType = .normal,clouse:@escaping (Bool)->Void){
|
let storesView = StoresInfoView.jq_loadNibView()
|
storesView.frame = sceneDelegate?.window?.frame ?? .zero
|
|
if type == .normal{
|
storesView.label_topTitle.text = "请确认预约门店"
|
storesView.btn_exchange.setTitle("更换门店", for: .normal)
|
}else{
|
storesView.label_topTitle.text = "请确认参与赛点"
|
storesView.btn_exchange.setTitle("更换赛点", for: .normal)
|
}
|
|
|
storesView.img_logo.sd_setImage(with: URL(string: activityModel.storeCoverDrawing))
|
storesView.label_title.text = activityModel.name
|
storesView.label_address.text = activityModel.address
|
storesView.label_distance.text = String(format: "距你%.2lfkm", activityModel.distance)
|
storesView.clouse = clouse
|
sceneDelegate?.window?.addSubview(storesView)
|
|
UIView.animate(withDuration: 0.4) {
|
storesView.view_container.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
|
storesView.alpha = 1
|
}
|
}
|
|
static func show(_ siteDetailModel:SiteDetailModel,clouse:@escaping (Bool)->Void){
|
let storesView = StoresInfoView.jq_loadNibView()
|
storesView.frame = sceneDelegate?.window?.frame ?? .zero
|
|
storesView.img_logo.sd_setImage(with: URL(string: siteDetailModel.storeCoverDrawing))
|
storesView.label_title.text = siteDetailModel.storeName
|
storesView.label_address.text = siteDetailModel.storeAddress
|
storesView.label_distance.text = String(format: "距你%.2lfkm", siteDetailModel.distance)
|
storesView.clouse = clouse
|
sceneDelegate?.window?.addSubview(storesView)
|
|
UIView.animate(withDuration: 0.4) {
|
storesView.view_container.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
|
storesView.alpha = 1
|
}
|
}
|
|
static func show(model:ActivityDetailStoreModel,clouse:@escaping (Bool)->Void){
|
let storesView = StoresInfoView.jq_loadNibView()
|
storesView.frame = sceneDelegate?.window?.frame ?? .zero
|
storesView.label_topTitle.text = "请确认参与赛点"
|
storesView.img_logo.sd_setImage(with: URL(string: model.storeCoverDrawing))
|
storesView.label_title.text = model.name
|
storesView.label_address.text = model.address
|
storesView.label_distance.text = String(format: "距你%.2lfkm", model.distance)
|
storesView.clouse = clouse
|
sceneDelegate?.window?.addSubview(storesView)
|
|
UIView.animate(withDuration: 0.4) {
|
storesView.view_container.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
|
storesView.alpha = 1
|
}
|
}
|
|
|
@IBAction func cancelAction(_ sender: UIButton) {
|
close()
|
}
|
|
|
@IBAction func exchangeAction(_ sender: UIButton) {
|
close()
|
clouse(false)
|
}
|
|
@IBAction func completeAction(_ sender: UIButton) {
|
close()
|
clouse(true)
|
}
|
|
private func close(){
|
UIView.animate(withDuration: 0.4) {
|
self.view_container.transform = .init(scaleX: 0.1, y: 0.1)
|
self.alpha = 0
|
} completion: { _ in
|
self.removeFromSuperview()
|
}
|
}
|
}
|