Commit 43907df6 authored by Alex朱枝文's avatar Alex朱枝文

扫码签到规则更改

parent b23feb87
......@@ -50,28 +50,14 @@ struct YHScanType: OptionSet {
/// 从二维码内容识别类型
func recognizeType(from code: String) -> YHScanType? {
// 根据二维码内容规则识别类型
if contains(.checkIn) && code.hasPrefix("CHECKIN_") {
if contains(.checkIn) && code.hasPrefix("SLQD_") {
return .checkIn
}
if contains(.smartCabinet) && code.hasPrefix("CABINET_") {
return .smartCabinet
}
// if contains(.smartCabinet) && code.hasPrefix("CABINET_") {
// return .smartCabinet
// }
// 可以添加更多识别规则
// 示例: JSON 格式识别
if let data = code.data(using: .utf8),
let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
let type = json["type"] as? String {
switch type {
case "checkin":
return contains(.checkIn) ? .checkIn : nil
case "cabinet":
return contains(.smartCabinet) ? .smartCabinet : nil
default:
break
}
}
// 如果只有一个类型,直接返回
if self == .checkIn {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment