66 lines
1.6 KiB
Swift
66 lines
1.6 KiB
Swift
//
|
|
// OrderAPI.swift
|
|
// QuickLocation
|
|
//
|
|
// Created by 八条 on 2026/6/17.
|
|
//
|
|
|
|
import Moya
|
|
import SwiftyUserDefaults
|
|
internal import Alamofire
|
|
|
|
/// 订单API
|
|
enum OrderAPI {
|
|
/// 充值内容
|
|
/// - Parameters:
|
|
/// - type: 类型 member
|
|
case rechargeInfo(type: String)
|
|
|
|
/// 支付参数
|
|
/// - Parameters:
|
|
/// - goodsId: 商品ID
|
|
/// - payType: alipay、weixin
|
|
/// - source: center
|
|
/// - extra: 额外参数
|
|
case orderPayParams(goodsId: String, payType: String, source: String, extra: [String:Any]=[:])
|
|
}
|
|
|
|
extension OrderAPI: MultiTargetProtocol {
|
|
|
|
var path: String {
|
|
switch self {
|
|
case .rechargeInfo:
|
|
return "api/order/goods"
|
|
case .orderPayParams:
|
|
return "api/order"
|
|
}
|
|
}
|
|
|
|
var method: Moya.Method {
|
|
switch self {
|
|
case .rechargeInfo:
|
|
return .get
|
|
default:
|
|
return .post
|
|
}
|
|
}
|
|
|
|
var task: Moya.Task {
|
|
switch self {
|
|
case let .rechargeInfo(type):
|
|
var params = Parameters()
|
|
params["type"] = type
|
|
return .requestParameters(parameters: params, encoding: URLEncoding())
|
|
|
|
case let .orderPayParams(goodsId, payType, source, extra):
|
|
var params = Parameters()
|
|
params["goods_id"] = goodsId
|
|
params["pay_type"] = payType
|
|
params["source"] = source
|
|
params["pay_source"] = "app"
|
|
params["extra"] = extra
|
|
return .requestParameters(parameters: params, encoding: JSONEncoding())
|
|
}
|
|
}
|
|
}
|