| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- //
- // CustomerViewController.swift
- // MTP2_iOS
- //
- // Created by Handy_Cao on 2020/11/6.
- // Copyright © 2020 Muchinfo. All rights reserved.
- //
- import UIKit
- import WHToast
- import SDWebImage
- /// 客服视图容器控制类
- class CustomerViewController: BaseViewController {
-
- // MARK: - 属性列表
- /// 关闭按钮
- @IBOutlet weak var closed: UIButton!
- /// 复制按钮
- @IBOutlet weak var copyButton: UIButton!
- /// 电话号码
- @IBOutlet weak var mobile: UIButton!
- /// 供应商
- @IBOutlet weak var vendorname: UILabel!
- /// 供应商
- @IBOutlet weak var image: UIImageView!
-
- /// 商品详情数据
- var goodsDetail: MoGoodsInfo? {
- didSet {
- DispatchQueue.main.asyncAfter(deadline: DispatchTime.now()+0.5) {
- /// 显示商品详情信息
- self.showGoodsDetail()
- }
- }
- }
- // MARK: - 生命周期
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do any additional setup after loading the view.
- }
-
- // MARK: - 数据显示
- /// 显示商品详情信息
- fileprivate func showGoodsDetail() {
- guard let obj = goodsDetail else { return }
- /// 电话号码
- mobile.setTitle(obj.vendorphone, for: .normal)
- /// 供应商
- vendorname.text = obj.vendorname
- /// 背景图片
- guard let url = StringUtils.getImageUrl(obj.vendorattr) else { return }
- image.sd_setImage(with: url, placeholderImage: UIImage(named: "placeholder_image"), options: .queryDiskDataSync, context: nil)
- }
-
- // MARK: - 交互相关
- /// onButtonPressed
- /// - Parameter sender: sender
- @IBAction func onButtonPressed(_ sender: UIButton) {
- switch sender {
- case closed: /// 关闭按钮
- self.dismiss(animated: true, completion: {})
- case copyButton: /// 复制按钮
- let pasteboard = UIPasteboard.general
- pasteboard.string = mobile.currentTitle
- WHToast.showSuccess(withMessage: "复制成功", duration: 1.5, finishHandler: {})
- default:
- guard let obj = goodsDetail else { return }
- let phone = "telprompt://" + obj.vendorphone
- if UIApplication.shared.canOpenURL(URL(string: phone)!) {
- UIApplication.shared.open(URL(string: phone)!, options: [:], completionHandler: nil)
- }
- }
- }
-
- /// onTapGestureRecognizer
- /// - Parameter sender: sender
- @IBAction fileprivate func onTapGestureRecognizer(_ sender: UITapGestureRecognizer) {
- self.dismiss(animated: true, completion: {})
- }
- /*
- // MARK: - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
- // Get the new view controller using segue.destination.
- // Pass the selected object to the new view controller.
- }
- */
- }
|