123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325 |
- //
- // OrderViewModel.swift
- // ADHTuanCan
- //
- // Created by 敖德亨 on 2023/11/5.
- //
- import UIKit
- import RxCocoa
- import RxSwift
- class OrderViewModel: MCBaseViewModel {
- var shopType = OrderGeneraType.whiteOrder
- var orderType = OrderTypeEnumProtocol.willPay
-
- //MARK: - 获取订单列表
- var getOrderListModel : GetOrderListModel = GetOrderListModel.init()
- var dataList : [OrderListModel]?
- var getOrderListRequset : MCDataRequest?
- func signalGetOrderList(_ isFirstPage: Bool) -> Observable<Int>? {
-
- if let _ = getOrderListRequset{
- return nil
- }
-
- if isFirstPage{
- self.getOrderListModel.current = 1
- }
-
- if self.shopType == .whiteOrder{
- self.getOrderListModel.isGeneral = "2"
- }
- if self.shopType == .generalOrder{
- self.getOrderListModel.isGeneral = "1"
- }
-
- if self.orderType == .willPay{
- self.getOrderListModel.status = "1"
- }
- if self.orderType == .takeOrdering{
- self.getOrderListModel.status = "2"
- }
- if self.orderType == .delivery{
- self.getOrderListModel.status = "3"
- }
- if self.orderType == .finish{
- self.getOrderListModel.status = "4"
- }
- if self.orderType == .all{
- self.getOrderListModel.status = nil
- }
-
- return Observable.create {(disposable) -> Disposable in
- self.getOrderListRequset = MCHttpUtil.request(self.getOrderListModel, responseClass: Array<OrderListModel>.self, success: {[unowned self] (data) in
-
- if isFirstPage{
- self.dataList = []
- }
- self.dataList?.append(contentsOf: data.data ?? [])
- self.getOrderListModel.current! = self.getOrderListModel.current! + 1
-
- self.getOrderListRequset = nil
- disposable.onNext(data.responseData?.count ?? 0)
- disposable.onCompleted()
- }, error: {[weak self] (error) in
- self?.getOrderListRequset = nil
- disposable.onError(error)
- })
- return Disposables.create()
- }
- }
-
- //MARK: - 获取订单详情
- var getOrderDetailModel : GetOrderDetailModel = GetOrderDetailModel.init()
- var orderOutDataModel : OrderOutDetailModel?
- var getOrderDetailRequset : MCDataRequest?
- func signalGetOrderDetail() -> Observable<Int>? {
-
- if let _ = getOrderDetailRequset{
- return nil
- }
- return Observable.create {(disposable) -> Disposable in
- self.getOrderDetailRequset = MCHttpUtil.request(self.getOrderDetailModel, responseClass: OrderOutDetailModel.self, success: {[unowned self] (data) in
- self.orderOutDataModel = data.data
- self.getOrderDetailRequset = nil
- disposable.onNext(data.responseData?.count ?? 0)
- disposable.onCompleted()
- }, error: {[weak self] (error) in
- self?.getOrderDetailRequset = nil
- disposable.onError(error)
- })
- return Disposables.create()
- }
- }
-
- //MARK: - 获取支付方式
- var getPayPayMentTypeModel : GetPayPaymentTypeModel = GetPayPaymentTypeModel.init()
- /// 结算方式列表
- var payMentList : [PayMentTypeModel]?
- var getPayMentRequest : MCDataRequest?
- /// 获取支付方式
- /// - Returns: <#description#>
- func signalGetPayMentType() -> Observable<Int>? {
-
- if let _ = getPayMentRequest{
- return nil
- }
-
- return Observable.create {(disposable) -> Disposable in
- self.getPayMentRequest = MCHttpUtil.request(self.getPayPayMentTypeModel, responseClass: Array<PayMentTypeModel>.self, success: {[unowned self] (data) in
- self.payMentList = []
- self.payMentList?.append(contentsOf: data.data ?? [])
- self.getPayMentRequest = nil
- disposable.onNext(data.responseData?.count ?? 0)
- disposable.onCompleted()
- }, error: {[weak self] (error) in
- self?.getPayMentRequest = nil
- disposable.onError(error)
- })
- return Disposables.create()
- }
- }
-
- //MARK: - 获取是否密码支付or StripePay
- var getIsStripePayModel : GetIsStripePayModel = GetIsStripePayModel.init()
- /// 拉起支付密码支付
- var isStripePayModel : IsStripePayModel?
- var getIsStripePayRequest : MCDataRequest?
- /// 获取是否密码支付or StripePay
- /// - Returns: <#description#>
- func signalGetIsStripePayRequest() -> Observable<Int>? {
-
- if let _ = getIsStripePayRequest{
- return nil
- }
-
- return Observable.create {(disposable) -> Disposable in
- self.getIsStripePayRequest = MCHttpUtil.request(self.getIsStripePayModel, responseClass: IsStripePayModel.self, success: {[unowned self] (data) in
- self.isStripePayModel = data.data
- self.getIsStripePayRequest = nil
- disposable.onNext(data.responseData?.count ?? 0)
- disposable.onCompleted()
- }, error: {[weak self] (error) in
- self?.getIsStripePayRequest = nil
- disposable.onError(error)
- })
- return Disposables.create()
- }
- }
-
- //MARK: - 配置支付信息
- var getPayConfigurationModel : GetPayConfiguration = GetPayConfiguration.init()
- var payConfiguration : PayConfigurationModel?
- var getPayConfigurationRequest : MCDataRequest?
- /// 配置支付信息
- /// - Returns: <#description#>
- func signalGetPayConfiguration() -> Observable<Int>? {
-
-
- if let _ = getPayConfigurationRequest{
- return nil
- }
-
- return Observable.create {(disposable) -> Disposable in
- self.getPayConfigurationRequest = MCHttpUtil.request(self.getPayConfigurationModel, responseClass: PayConfigurationModel.self, success: {[unowned self] (data) in
- self.payConfiguration = data.data
- self.getPayConfigurationRequest = nil
- disposable.onNext(data.responseData?.count ?? 0)
- disposable.onCompleted()
- }, error: {[weak self] (error) in
- self?.getPayConfigurationRequest = nil
- disposable.onError(error)
- })
- return Disposables.create()
- }
- }
-
- //MARK: - 密码支付
- var pswPayModel : PSWPayRequestModel = PSWPayRequestModel.init()
- var pswPayRequest : MCDataRequest?
- /// 密码支付
- /// - Returns: <#description#>
- func signalPSWPay() -> Observable<Int>? {
-
- if let _ = pswPayRequest{
- return nil
- }
-
- return Observable.create {(disposable) -> Disposable in
- self.pswPayRequest = MCHttpUtil.request(self.pswPayModel, responseClass: MCBaseModel.self, success: {[unowned self] (data) in
-
- self.pswPayRequest = nil
- disposable.onNext(data.responseData?.count ?? 0)
- disposable.onCompleted()
- }, error: {[weak self] (error) in
- self?.pswPayRequest = nil
- disposable.onError(error)
- })
- return Disposables.create()
- }
- }
-
- //MARK: - 取消订单
- var cancelOrderModel : CancelOrderModel = CancelOrderModel.init()
- /// Request
- var cancelOrderRequest : MCDataRequest?
- /// 取消订单
- /// - Returns: <#description#>
- func signalCancelOrder() -> Observable<Int>? {
-
- if let _ = cancelOrderRequest{
- return nil
- }
-
- return Observable.create {(disposable) -> Disposable in
- self.cancelOrderRequest = MCHttpUtil.request(self.cancelOrderModel, responseClass: MCBaseModel.self, success: {[unowned self] (data) in
-
- self.cancelOrderRequest = nil
-
- disposable.onNext(data.responseData?.count ?? 0)
- disposable.onCompleted()
- }, error: {[weak self] (error) in
- self?.cancelOrderRequest = nil
- disposable.onError(error)
- })
- return Disposables.create()
- }
- }
-
-
- //MARK: - 修改订单地址
- var editOrderAddressModel : EditOrderAddressModel = EditOrderAddressModel.init()
- /// 修改订单地址Request
- var editOrderAddrRequest : MCDataRequest?
- /// 修改订单地址
- /// - Returns: <#description#>
- func signalEditOrderAddress() -> Observable<Int>? {
-
- if let _ = editOrderAddrRequest{
- return nil
- }
-
- return Observable.create {(disposable) -> Disposable in
- self.editOrderAddrRequest = MCHttpUtil.request(self.editOrderAddressModel, responseClass: MCBaseModel.self, success: {[unowned self] (data) in
-
- self.editOrderAddrRequest = nil
-
- disposable.onNext(data.responseData?.count ?? 0)
- disposable.onCompleted()
- }, error: {[weak self] (error) in
- self?.editOrderAddrRequest = nil
- disposable.onError(error)
- })
- return Disposables.create()
- }
- }
-
-
- //MARK: - 确认收货
-
- /// 确认收货MOdle
- var confirmReceiptModel : ConfirmReceiptModel = ConfirmReceiptModel.init()
- /// 确认收货Request
- var confirmReceiptRequest : MCDataRequest?
- /// 确认收货MOdle
- /// - Returns: <#description#>
- func signalConfirmReceipt() -> Observable<Int>? {
-
- if let _ = confirmReceiptRequest{
- return nil
- }
-
- return Observable.create {(disposable) -> Disposable in
- self.confirmReceiptRequest = MCHttpUtil.request(self.confirmReceiptModel, responseClass: MCBaseModel.self, success: {[unowned self] (data) in
-
- self.confirmReceiptRequest = nil
-
- disposable.onNext(data.responseData?.count ?? 0)
- disposable.onCompleted()
- }, error: {[weak self] (error) in
- self?.confirmReceiptRequest = nil
- disposable.onError(error)
- })
- return Disposables.create()
- }
- }
-
-
- //MARK: - 获取客服电话
- /// 获取客服电话MOdle
- var getServiceTelModel : GetServiceTelModel = GetServiceTelModel.init()
- /// 客服电话MOdle
- var serviceTelModel : ServiceTelModel?
- /// 获取客服电话Request
- var getServiceTelRequest : MCDataRequest?
- /// 获取客服电话
- /// - Returns: <#description#>
- func signalGetServiceTell() -> Observable<Int>? {
-
- if let _ = getServiceTelRequest{
- return nil
- }
-
- return Observable.create {(disposable) -> Disposable in
- self.getServiceTelRequest = MCHttpUtil.request(self.getServiceTelModel, responseClass: ServiceTelModel.self, success: {[unowned self] (data) in
-
- self.serviceTelModel = data.data
- self.getServiceTelRequest = nil
-
- disposable.onNext(data.responseData?.count ?? 0)
- disposable.onCompleted()
- }, error: {[weak self] (error) in
- self?.getServiceTelRequest = nil
- disposable.onError(error)
- })
- return Disposables.create()
- }
- }
- }
|