123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- //
- // ShopAddressViewController.swift
- // xingchuangke
- //
- // Created by Virgil on 2019/3/29.
- // Copyright © 2019 Virgil. All rights reserved.
- //
- import UIKit
- class TiXianFaPiaoViewController: BaseViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
- var shopOpen: ShopOpenEntity!
- @IBOutlet weak var txt1: UITextField!
- @IBOutlet weak var btnFinish: UIButton!
- @IBOutlet weak var txtNo: UITextField!
- @IBOutlet weak var view1: UIView!
- @IBOutlet weak var view2: UIView!
- @IBOutlet weak var view3: UIView!
- ///发票类型 : 0:普通 1专用3% 2专用6% 3不开发票
- var fbType = 0
- var machineTypeId: String = ""
- // 选择品牌设置的金额
- var brandEarnArr: NSArray?
- var money = ""
- ///是否开发票 0:否 1:是
- var isFaPiao = 0
- @IBOutlet weak var imgYYZZ: UIImageView!
- override func viewDidLoad() {
- super.viewDidLoad()
- initNavLeftBackButton()
- self.title = "提示"
- //发票类型: 增值税专用发票 增值税普通发票
- //税率: 3% 6%
- //不开票扣8% 普通发票扣6%
- }
- @IBAction func btnUploadClick(_ sender: Any) {
- CommonUntils.AlertView(controller: self, title: nil, message: nil, buttons: ["拍照上传", "从相册上传"], style: .actionSheet) {[weak self] (index, _) in
- let ipc = UIImagePickerController()
- if index == 0 {
- ipc.sourceType = .camera
- } else {
- ipc.sourceType = .photoLibrary
- }
- ipc.delegate = self!
- ipc.allowsEditing = false
- self!.present(ipc, animated: true, completion: nil)
- }
- }
- var imgTemp: UIImage!
- func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
- self.dismiss(animated: true) {[weak self] in
- var imgTemp: UIImage? = info[UIImagePickerController.InfoKey.originalImage] as? UIImage
- if picker.allowsEditing {
- imgTemp = info[UIImagePickerController.InfoKey.editedImage] as? UIImage
- }
- if imgTemp != nil {
- self!.UploadFile(img: imgTemp!)
- } else {
- SVProgressHUD.showError(withStatus: "图片选择失败,请重试")
- }
- }
- }
- var strImgYYZZ = ""
- func UploadFile(img: UIImage) {
- SVProgressHUD.show()
- let uploadFile = QiNiuUploadFile()
- uploadFile.uploadFile(img: img) {[weak self] (type, str) in
- SVProgressHUD.dismiss()
- if type == 1 {
- let userLoginUrl = RequestURL.qiNiuImageUrl + str
- self!.strImgYYZZ = userLoginUrl
- self!.imgYYZZ.loadImage(imgUrl: userLoginUrl, defaultImage: "")
- } else {
- SVProgressHUD.showError(withStatus: "上传失败")
- }
- }
- }
- override func KeyboardHidden(gestureRecognizer: UIGestureRecognizer) {
- txt1.resignFirstResponder()
- txtNo.resignFirstResponder()
- }
- var viewSelectCity: Virgil_SelectCity!
- @IBAction func btnSelectAddressClick(_ sender: Any) {
- //var viewSelectCity:Virgil_SelectCity!
- let addressList = CommonUntils.getPlistArrayForName(fileName: "AddressNew")
- if viewSelectCity == nil {
- viewSelectCity = Virgil_SelectCity(frame: CGRect(x: 0, y: 0, width: ScreenWidth, height: view.height()))
- viewSelectCity.modelType = 2
- viewSelectCity.initView(arrAddress: addressList) {[weak self] (dic) in
- self!.shopOpen.addressId1 = self!.getString(key: "addressId1", dic: dic)
- self!.shopOpen.addressId2 = self!.getString(key: "addressId2", dic: dic)
- self!.shopOpen.addressId3 = self!.getString(key: "addressId3", dic: dic)
- //self!.shopOpen.address = self!.getString(key: "address", dic: dic);
- self!.txt1.text = self!.getString(key: "address", dic: dic)
- }
- self.view.addSubview(viewSelectCity)
- }
- viewSelectCity.showPickerView()
- }
- @IBAction func btnFinishClick(_ sender: Any) {
- if strImgYYZZ == "" {
- SVProgressHUD.showError(withStatus: "请上传发票照片")
- return
- }
- if txtNo.text!.length() < 1 {
- SVProgressHUD.showError(withStatus: "请填写快递公司")
- return
- }
- if txt1.text!.length() < 1 {
- SVProgressHUD.showError(withStatus: "请填写快递号")
- return
- }
- submitData()
- }
- // MARK: =============加载数据===============
- func submitData() {
- var url = RequestURL.cashApplicationWithMachineTypeId
- let params = NSMutableDictionary()
- if machineTypeId == "" {
- url = RequestURL.cashApplicationWithMachineTypeIdAll
- let data = (try? JSONSerialization.data(withJSONObject: brandEarnArr!, options: .prettyPrinted))!
- let strJson = NSString(data: data, encoding: String.Encoding.utf8.rawValue)
- params.setValue(strJson, forKey: "machineTypeAndAtm")
- }
- params.setValue(machineTypeId, forKey: "machineTypeId")
- params.setValue(money, forKey: "amountMoney")
- params.setValue(isFaPiao, forKey: "type")
- params.setValue(strImgYYZZ, forKey: "invoicePhoto")
- params.setValue(txtNo.text!, forKey: "expressName")
- params.setValue(txt1.text!, forKey: "expressNumber")
- if fbType == 0 {
- params.setValue("0", forKey: "invoiceType")
- params.setValue("", forKey: "reteType")
- } else {
- params.setValue("1", forKey: "invoiceType")
- if fbType == 1 {
- params.setValue("0", forKey: "reteType")
- } else if fbType == 2 {
- params.setValue("1", forKey: "reteType")
- }
- }
- params.setValue("1", forKey: "phoneType")
- submitData(url: url, params: params, tag: 1001)
- }
- override func returnData(tag: Int) {
- if tag == 1001 {
- appDelegate.reloadUserInfo()
- toViewController(viewController: TiXianAlertViewController())
- }
- }
- override func returnError(tag: Int, type: String) {
- }
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- }
- override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
- super.init(nibName: "TiXianFaPiaoViewController", bundle: nil)
- }
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
|