fix(drone-dock): 适配小程序收款码图片展示与重试
This commit is contained in:
@@ -30,7 +30,7 @@ struct DroneDockProject: Decodable, Hashable, Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
/// 后端生成的可重复购买付款链接;不代表单笔交易或到账结果。
|
||||
/// 后端生成的小程序收款码及报价;同一码可重复购买,不代表单笔交易或到账结果。
|
||||
struct DroneDockPayCode: Decodable, Equatable, Sendable {
|
||||
/// 报价所属套餐 ID。
|
||||
let projectID: Int
|
||||
@@ -44,17 +44,17 @@ struct DroneDockPayCode: Decodable, Equatable, Sendable {
|
||||
let storeUserID: Int
|
||||
/// 收款归属的店铺 ID。
|
||||
let storeID: Int
|
||||
/// 用于绘制普通二维码的 HTTP(S) 付款链接。
|
||||
/// 后端小程序码的 HTTP(S) 图片地址,直接加载原图,不再编码成普通二维码。
|
||||
let payURL: String
|
||||
|
||||
/// 付款链接接口字段。
|
||||
/// 小程序收款码接口字段;pay_url 沿用字段名,内容为图片地址。
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case price
|
||||
case projectID = "project_id", projectName = "project_name", shootCount = "shoot_count"
|
||||
case storeUserID = "store_user_id", storeID = "store_id", payURL = "pay_url"
|
||||
}
|
||||
|
||||
/// 验证身份、报价和链接格式;不接受缺失或不可扫码的付款地址。
|
||||
/// 验证身份、报价和图片地址格式;图片内容与加载结果由视图处理。
|
||||
init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
projectID = try container.paymentInteger(.projectID, minimum: 1)
|
||||
@@ -72,7 +72,7 @@ struct DroneDockPayCode: Decodable, Equatable, Sendable {
|
||||
let scheme = components.scheme?.lowercased(), ["https", "http"].contains(scheme),
|
||||
let host = components.host, !host.isEmpty, components.url != nil,
|
||||
components.user == nil, components.password == nil else {
|
||||
throw DecodingError.dataCorruptedError(forKey: .payURL, in: container, debugDescription: "付款链接必须是有效 HTTP(S) 地址")
|
||||
throw DecodingError.dataCorruptedError(forKey: .payURL, in: container, debugDescription: "收款码图片必须是有效 HTTP(S) 地址")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user