Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
galaxy-iOS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile-group
galaxy-iOS
Commits
69a1a665
Commit
69a1a665
authored
Sep 18, 2025
by
Alex朱枝文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加扫码逻辑
parent
c0755736
Changes
18
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
1717 additions
and
5 deletions
+1717
-5
project.pbxproj
galaxy/galaxy.xcodeproj/project.pbxproj
+40
-0
YHHomeHoldViewPageViewController.swift
...Modules/Home(首页)/C/YHHomeHoldViewPageViewController.swift
+4
-0
YHHomeSearchView.swift
.../galaxy/Classes/Modules/Home(首页)/V/YHHomeSearchView.swift
+22
-1
YHMyNewViewController.swift
...xy/Classes/Modules/Mine(我的)/C/YHMyNewViewController.swift
+20
-4
YHScanViewController.swift
...axy/Classes/Modules/Mine(我的)/C/YHScanViewController.swift
+60
-0
LBXPermissions.swift
galaxy/galaxy/Classes/Tools/SwiftScan/LBXPermissions.swift
+70
-0
LBXScanLineAnimation.swift
...galaxy/Classes/Tools/SwiftScan/LBXScanLineAnimation.swift
+79
-0
LBXScanNetAnimation.swift
.../galaxy/Classes/Tools/SwiftScan/LBXScanNetAnimation.swift
+76
-0
LBXScanView.swift
galaxy/galaxy/Classes/Tools/SwiftScan/LBXScanView.swift
+409
-0
LBXScanViewController.swift
...alaxy/Classes/Tools/SwiftScan/LBXScanViewController.swift
+202
-0
LBXScanViewStyle.swift
galaxy/galaxy/Classes/Tools/SwiftScan/LBXScanViewStyle.swift
+88
-0
LBXScanWrapper.swift
galaxy/galaxy/Classes/Tools/SwiftScan/LBXScanWrapper.swift
+603
-0
Contents.json
.../Assets.xcassets/Mine/qr_scan_icon.imageset/Contents.json
+22
-0
qr_scan_icon@2x.png
...s.xcassets/Mine/qr_scan_icon.imageset/qr_scan_icon@2x.png
+0
-0
qr_scan_icon@3x.png
...s.xcassets/Mine/qr_scan_icon.imageset/qr_scan_icon@3x.png
+0
-0
Contents.json
...ssets.xcassets/Mine/scan_move_line.imageset/Contents.json
+22
-0
scan_move_line@2x.png
...assets/Mine/scan_move_line.imageset/scan_move_line@2x.png
+0
-0
scan_move_line@3x.png
...assets/Mine/scan_move_line.imageset/scan_move_line@3x.png
+0
-0
No files found.
galaxy/galaxy.xcodeproj/project.pbxproj
View file @
69a1a665
...
...
@@ -1253,6 +1253,14 @@
04B00FC72D9A420F00F640C5
/* YHMakePlanPriceAlertView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04B00FB82D9A420F00F640C5
/* YHMakePlanPriceAlertView.swift */
;
};
04B00FC82D9A420F00F640C5
/* YHMakePlanCusttomHeadView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04B00FB62D9A420F00F640C5
/* YHMakePlanCusttomHeadView.swift */
;
};
04B00FCA2D9AAD6100F640C5
/* YHMakePlanTopView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04B00FC92D9AAD6100F640C5
/* YHMakePlanTopView.swift */
;
};
04C0ED6A2E7BAC2D00B0D182
/* LBXScanView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04C0ED652E7BAC2D00B0D182
/* LBXScanView.swift */
;
};
04C0ED6B2E7BAC2D00B0D182
/* LBXScanViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04C0ED662E7BAC2D00B0D182
/* LBXScanViewController.swift */
;
};
04C0ED6C2E7BAC2D00B0D182
/* LBXScanWrapper.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04C0ED682E7BAC2D00B0D182
/* LBXScanWrapper.swift */
;
};
04C0ED6D2E7BAC2D00B0D182
/* LBXScanViewStyle.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04C0ED672E7BAC2D00B0D182
/* LBXScanViewStyle.swift */
;
};
04C0ED6E2E7BAC2D00B0D182
/* LBXPermissions.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04C0ED622E7BAC2D00B0D182
/* LBXPermissions.swift */
;
};
04C0ED6F2E7BAC2D00B0D182
/* LBXScanNetAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04C0ED642E7BAC2D00B0D182
/* LBXScanNetAnimation.swift */
;
};
04C0ED702E7BAC2D00B0D182
/* LBXScanLineAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04C0ED632E7BAC2D00B0D182
/* LBXScanLineAnimation.swift */
;
};
04C0ED7C2E7BEF7800B0D182
/* YHScanViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04C0ED7B2E7BEF7800B0D182
/* YHScanViewController.swift */
;
};
04D8FF552D9258AA00703C75
/* YHPlanScoreView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04D8FF542D9258AA00703C75
/* YHPlanScoreView.swift */
;
};
04D8FF572D925A0800703C75
/* YHPlanScoreChart.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04D8FF562D925A0800703C75
/* YHPlanScoreChart.swift */
;
};
04D8FF592D925E6700703C75
/* YHPlanModel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04D8FF582D925E6700703C75
/* YHPlanModel.swift */
;
};
...
...
@@ -2593,6 +2601,14 @@
04B00FBA2D9A420F00F640C5
/* YHMakePlanShareAlertView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHMakePlanShareAlertView.swift
;
sourceTree
=
"<group>"
;
};
04B00FBB2D9A420F00F640C5
/* YHMakePlanStateHeadView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHMakePlanStateHeadView.swift
;
sourceTree
=
"<group>"
;
};
04B00FC92D9AAD6100F640C5
/* YHMakePlanTopView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHMakePlanTopView.swift
;
sourceTree
=
"<group>"
;
};
04C0ED622E7BAC2D00B0D182
/* LBXPermissions.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
LBXPermissions.swift
;
sourceTree
=
"<group>"
;
};
04C0ED632E7BAC2D00B0D182
/* LBXScanLineAnimation.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
LBXScanLineAnimation.swift
;
sourceTree
=
"<group>"
;
};
04C0ED642E7BAC2D00B0D182
/* LBXScanNetAnimation.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
LBXScanNetAnimation.swift
;
sourceTree
=
"<group>"
;
};
04C0ED652E7BAC2D00B0D182
/* LBXScanView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
LBXScanView.swift
;
sourceTree
=
"<group>"
;
};
04C0ED662E7BAC2D00B0D182
/* LBXScanViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
LBXScanViewController.swift
;
sourceTree
=
"<group>"
;
};
04C0ED672E7BAC2D00B0D182
/* LBXScanViewStyle.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
LBXScanViewStyle.swift
;
sourceTree
=
"<group>"
;
};
04C0ED682E7BAC2D00B0D182
/* LBXScanWrapper.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
LBXScanWrapper.swift
;
sourceTree
=
"<group>"
;
};
04C0ED7B2E7BEF7800B0D182
/* YHScanViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHScanViewController.swift
;
sourceTree
=
"<group>"
;
};
04D8FF542D9258AA00703C75
/* YHPlanScoreView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHPlanScoreView.swift
;
sourceTree
=
"<group>"
;
};
04D8FF562D925A0800703C75
/* YHPlanScoreChart.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHPlanScoreChart.swift
;
sourceTree
=
"<group>"
;
};
04D8FF582D925E6700703C75
/* YHPlanModel.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHPlanModel.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -5947,6 +5963,7 @@
045C0EE02D12CA5E00BD2DC0
/* YHVideoPlaySettingVC.swift */
,
048D6ADA2D5E00DE00BC6F4C
/* YHMemberCenterViewController.swift */
,
04AFEF562D6C78AA0007A011
/* YHVipLevelRightViewController.swift */
,
04C0ED7B2E7BEF7800B0D182
/* YHScanViewController.swift */
,
);
path
=
C
;
sourceTree
=
"<group>"
;
...
...
@@ -6264,6 +6281,7 @@
045C0F472D12CA5E00BD2DC0
/* Tools */
=
{
isa
=
PBXGroup
;
children
=
(
04C0ED692E7BAC2D00B0D182
/* SwiftScan */
,
045C0F0E2D12CA5E00BD2DC0
/* Analytics */
,
045C0F112D12CA5E00BD2DC0
/* CustomRefreshHeader */
,
045C0F232D12CA5E00BD2DC0
/* Extention */
,
...
...
@@ -6854,6 +6872,20 @@
path
=
MakePlan
;
sourceTree
=
"<group>"
;
};
04C0ED692E7BAC2D00B0D182
/* SwiftScan */
=
{
isa
=
PBXGroup
;
children
=
(
04C0ED622E7BAC2D00B0D182
/* LBXPermissions.swift */
,
04C0ED632E7BAC2D00B0D182
/* LBXScanLineAnimation.swift */
,
04C0ED642E7BAC2D00B0D182
/* LBXScanNetAnimation.swift */
,
04C0ED652E7BAC2D00B0D182
/* LBXScanView.swift */
,
04C0ED662E7BAC2D00B0D182
/* LBXScanViewController.swift */
,
04C0ED672E7BAC2D00B0D182
/* LBXScanViewStyle.swift */
,
04C0ED682E7BAC2D00B0D182
/* LBXScanWrapper.swift */
,
);
path
=
SwiftScan
;
sourceTree
=
"<group>"
;
};
04D8FF4F2D9257F700703C75
/* Plan(方案) */
=
{
isa
=
PBXGroup
;
children
=
(
...
...
@@ -7421,6 +7453,13 @@
045C0FE52D12CA5F00BD2DC0
/* YHStatusAdvantageBottomView.swift in Sources */
,
045C0FE62D12CA5F00BD2DC0
/* YHLifeItemTableViewCell.swift in Sources */
,
045C0FE72D12CA5F00BD2DC0
/* YHIndustryLocationCell.swift in Sources */
,
04C0ED6A2E7BAC2D00B0D182
/* LBXScanView.swift in Sources */
,
04C0ED6B2E7BAC2D00B0D182
/* LBXScanViewController.swift in Sources */
,
04C0ED6C2E7BAC2D00B0D182
/* LBXScanWrapper.swift in Sources */
,
04C0ED6D2E7BAC2D00B0D182
/* LBXScanViewStyle.swift in Sources */
,
04C0ED6E2E7BAC2D00B0D182
/* LBXPermissions.swift in Sources */
,
04C0ED6F2E7BAC2D00B0D182
/* LBXScanNetAnimation.swift in Sources */
,
04C0ED702E7BAC2D00B0D182
/* LBXScanLineAnimation.swift in Sources */
,
045C0FE82D12CA5F00BD2DC0
/* YHActivityApplyInfoItemView.swift in Sources */
,
045C0FE92D12CA5F00BD2DC0
/* YHVisaRenewalItemDetailType.swift in Sources */
,
045C0FEA2D12CA5F00BD2DC0
/* YHPrivacyAlertView.swift in Sources */
,
...
...
@@ -8214,6 +8253,7 @@
045C12822D12CA5F00BD2DC0
/* YHServiceCenterStepThreeTableHeadView.swift in Sources */
,
045C12832D12CA5F00BD2DC0
/* YHResignRiskWarningAlertView.swift in Sources */
,
045C12842D12CA5F00BD2DC0
/* YHDashLineView.swift in Sources */
,
04C0ED7C2E7BEF7800B0D182
/* YHScanViewController.swift in Sources */
,
045C12852D12CA5F00BD2DC0
/* YHPreviewInfoCertificateInformationItemsView.swift in Sources */
,
045C12862D12CA5F00BD2DC0
/* YHOfficialApprovalResultVC.swift in Sources */
,
045C12872D12CA5F00BD2DC0
/* YHStatusAdvantageVC.swift in Sources */
,
...
...
galaxy/galaxy/Classes/Modules/Home(首页)/C/YHHomeHoldViewPageViewController.swift
View file @
69a1a665
...
...
@@ -270,6 +270,10 @@ class YHHomeHoldViewPageViewController: YHBaseViewController, WKUIDelegate, WKNa
let
view
=
YHHomeSearchView
()
let
tap
=
UITapGestureRecognizer
(
target
:
self
,
action
:
#selector(
didSearchBarClicked
)
)
view
.
addGestureRecognizer
(
tap
)
view
.
didClickScanBtnEvent
=
{
[
weak
self
]
in
let
vc
=
YHScanViewController
()
self
?
.
navigationController
?
.
pushViewController
(
vc
)
}
return
view
}()
...
...
galaxy/galaxy/Classes/Modules/Home(首页)/V/YHHomeSearchView.swift
View file @
69a1a665
...
...
@@ -17,12 +17,22 @@ class YHHomeSearchView: UIView {
return
lable
}()
private
lazy
var
scanBtn
:
UIButton
=
{
let
btn
=
UIButton
()
btn
.
setImage
(
UIImage
(
named
:
"qr_scan_icon"
),
for
:
.
normal
)
btn
.
YH_clickEdgeInsets
=
UIEdgeInsets
(
top
:
20
,
left
:
20
,
bottom
:
20
,
right
:
20
)
btn
.
addTarget
(
self
,
action
:
#selector(
didClickScanBtn(btn:)
)
,
for
:
.
touchUpInside
)
return
btn
}()
var
placeHolder
:
String
=
""
{
didSet
{
self
.
placeHolderLabel
.
text
=
placeHolder
}
}
var
didClickScanBtnEvent
:
(()
->
Void
)?
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
initView
()
...
...
@@ -47,12 +57,23 @@ private extension YHHomeSearchView {
make
.
width
.
height
.
equalTo
(
16
)
}
addSubview
(
scanBtn
)
scanBtn
.
snp
.
makeConstraints
{
make
in
make
.
width
.
height
.
equalTo
(
24.0
)
make
.
right
.
equalToSuperview
()
.
offset
(
-
12
)
make
.
centerY
.
equalToSuperview
()
}
addSubview
(
placeHolderLabel
)
placeHolderLabel
.
snp
.
makeConstraints
{
make
in
make
.
centerY
.
equalToSuperview
()
make
.
left
.
equalTo
(
imageV
.
snp
.
right
)
.
offset
(
8
)
make
.
height
.
equalTo
(
18
)
make
.
right
.
equalTo
Superview
(
)
.
offset
(
-
12
)
make
.
right
.
equalTo
(
scanBtn
.
snp
.
left
)
.
offset
(
-
12
)
}
}
@objc
func
didClickScanBtn
(
btn
:
UIButton
)
{
didClickScanBtnEvent
?()
}
}
galaxy/galaxy/Classes/Modules/Mine(我的)/C/YHMyNewViewController.swift
View file @
69a1a665
...
...
@@ -130,6 +130,14 @@ class YHMyNewViewController: YHBaseViewController {
return
btn
}()
private
lazy
var
scanBtn
:
UIButton
=
{
let
btn
=
UIButton
()
btn
.
setImage
(
UIImage
(
named
:
"qr_scan_icon"
),
for
:
.
normal
)
btn
.
YH_clickEdgeInsets
=
UIEdgeInsets
(
top
:
20
,
left
:
20
,
bottom
:
20
,
right
:
20
)
btn
.
addTarget
(
self
,
action
:
#selector(
didClickScanBtn(btn:)
)
,
for
:
.
touchUpInside
)
return
btn
}()
private
lazy
var
settingRedPointView
:
UIView
=
{
let
view
=
UIView
()
view
.
layer
.
cornerRadius
=
kCornerRadius3
...
...
@@ -150,6 +158,7 @@ class YHMyNewViewController: YHBaseViewController {
view
.
addSubview
(
bgImgView
)
view
.
addSubview
(
tableView
)
view
.
addSubview
(
settingBtn
)
view
.
addSubview
(
scanBtn
)
view
.
addSubview
(
settingRedPointView
)
bgImgView
.
snp
.
makeConstraints
{
make
in
...
...
@@ -176,6 +185,12 @@ class YHMyNewViewController: YHBaseViewController {
make
.
bottom
.
equalTo
(
settingBtn
.
snp
.
top
)
.
offset
(
3
)
}
scanBtn
.
snp
.
makeConstraints
{
make
in
make
.
width
.
height
.
equalTo
(
24.0
)
make
.
right
.
equalTo
(
settingBtn
.
snp
.
left
)
.
offset
(
-
17
)
make
.
top
.
equalTo
(
k_Height_StatusBar
+
10
)
}
updateUserUI
()
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
loginSuccess
)
,
name
:
YhConstant
.
YhNotification
.
didLoginSuccessNotifiction
,
object
:
nil
)
...
...
@@ -303,12 +318,13 @@ class YHMyNewViewController: YHBaseViewController {
if
!
checkLogin
()
{
return
}
let
vc
=
YHMySettingViewController
()
self
.
navigationController
?
.
pushViewController
(
vc
)
}
// let vc = YHH5WebViewVC()
// vc.isFullScreenFlag = false
// vc.url = "http://192.168.34.113:10301/superAppBridge.html#/order/antom-pay?id=1864¶m=eyJhbGbolyFeciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NTc0NzI5MzAsImkiOjQyMzgxNzEzODcwNzAyMSwidSI6IumTtuays-mbhuWboiIsInIiOiJzdXBlcl9hcHAifQ.Phsg13OfN5XJ0cLe759U2W0hH1iTZeneimgTlnouPcg"
// self.navigationController?.pushViewController(vc)
@objc
func
didClickScanBtn
(
btn
:
UIButton
)
{
let
vc
=
YHScanViewController
()
self
.
navigationController
?
.
pushViewController
(
vc
)
}
}
extension
YHMyNewViewController
:
UITableViewDelegate
,
UITableViewDataSource
{
...
...
galaxy/galaxy/Classes/Modules/Mine(我的)/C/YHScanViewController.swift
0 → 100644
View file @
69a1a665
//
// YHScanViewController.swift
// galaxy
//
// Created by alexzzw on 2025/9/18.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import
UIKit
class
YHScanViewController
:
LBXScanViewController
{
private
let
topOffset
=
44.0
private
let
leftOffset
=
48.0
override
var
preferredStatusBarStyle
:
UIStatusBarStyle
{
return
.
lightContent
}
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
gk_navTitleColor
=
.
white
gk_navTitle
=
"扫码"
gk_navBarAlpha
=
0.0
gk_navBackgroundColor
=
.
clear
gk_backImage
=
UIImage
(
named
:
"back_icon_white"
)
setupScanStyle
()
}
override
func
handleCodeResult
(
arrayResult
:
[
LBXScanResult
])
{
//
}
deinit
{
//
}
}
extension
YHScanViewController
{
private
func
setupScanStyle
()
{
var
style
=
LBXScanViewStyle
()
style
.
centerUpOffset
=
topOffset
style
.
xScanRetangleOffset
=
leftOffset
style
.
photoframeAngleStyle
=
LBXScanViewPhotoframeAngleStyle
.
Inner
style
.
photoframeLineW
=
3
style
.
photoframeAngleW
=
18
style
.
photoframeAngleH
=
18
style
.
isNeedShowRetangle
=
false
style
.
anmiationStyle
=
LBXScanViewAnimationStyle
.
LineMove
// 扫描横线图片
style
.
animationImage
=
UIImage
(
named
:
"scan_move_line"
)
// 4个角的颜色
style
.
colorAngle
=
UIColor
.
white
// 非矩形框区域颜色
style
.
color_NotRecoginitonArea
=
UIColor
.
black
.
withAlphaComponent
(
0.3
)
scanStyle
=
style
}
}
galaxy/galaxy/Classes/Tools/SwiftScan/LBXPermissions.swift
0 → 100755
View file @
69a1a665
//
// LBXPermissions.swift
// swiftScan
//
// Created by xialibing on 15/12/15.
// Copyright © 2015年 xialibing. All rights reserved.
//
import
UIKit
import
AVFoundation
import
Photos
import
AssetsLibrary
class
LBXPermissions
:
NSObject
{
// MARK: - ---获取相册权限
static
func
authorizePhotoWith
(
comletion
:
@escaping
(
Bool
)
->
Void
)
{
let
granted
=
PHPhotoLibrary
.
authorizationStatus
()
switch
granted
{
case
PHAuthorizationStatus
.
authorized
:
comletion
(
true
)
case
PHAuthorizationStatus
.
denied
,
PHAuthorizationStatus
.
restricted
:
comletion
(
false
)
case
PHAuthorizationStatus
.
notDetermined
:
PHPhotoLibrary
.
requestAuthorization
({
(
status
)
in
DispatchQueue
.
main
.
async
{
comletion
(
status
==
PHAuthorizationStatus
.
authorized
?
true
:
false
)
}
})
case
.
limited
:
comletion
(
false
)
@unknown
default
:
comletion
(
false
)
}
}
// MARK: - --相机权限
static
func
authorizeCameraWith
(
comletion
:
@escaping
(
Bool
)
->
Void
)
{
let
granted
=
AVCaptureDevice
.
authorizationStatus
(
for
:
AVMediaType
.
video
)
switch
granted
{
case
.
authorized
:
comletion
(
true
)
case
.
denied
:
comletion
(
false
)
case
.
restricted
:
comletion
(
false
)
case
.
notDetermined
:
AVCaptureDevice
.
requestAccess
(
for
:
AVMediaType
.
video
,
completionHandler
:
{
(
granted
:
Bool
)
in
DispatchQueue
.
main
.
async
{
comletion
(
granted
)
}
})
@unknown
default
:
comletion
(
false
)
}
}
// MARK: 跳转到APP系统设置权限界面
static
func
jumpToSystemPrivacySetting
()
{
if
let
appSetting
=
URL
(
string
:
UIApplication
.
openSettingsURLString
)
{
if
#available(iOS 10, *)
{
UIApplication
.
shared
.
open
(
appSetting
,
options
:
[:],
completionHandler
:
nil
)
}
else
{
UIApplication
.
shared
.
openURL
(
appSetting
)
}
}
}
}
galaxy/galaxy/Classes/Tools/SwiftScan/LBXScanLineAnimation.swift
0 → 100755
View file @
69a1a665
//
// LBXScanLineAnimation.swift
// swiftScan
//
// Created by lbxia on 15/12/9.
// Copyright © 2015年 xialibing. All rights reserved.
//
import
UIKit
class
LBXScanLineAnimation
:
UIImageView
{
var
isAnimationing
=
false
var
animationRect
:
CGRect
=
CGRect
.
zero
func
startAnimatingWithRect
(
animationRect
:
CGRect
,
parentView
:
UIView
,
image
:
UIImage
?)
{
self
.
image
=
image
self
.
animationRect
=
animationRect
parentView
.
addSubview
(
self
)
self
.
isHidden
=
false
isAnimationing
=
true
if
image
!=
nil
{
stepAnimation
()
}
}
@objc
func
stepAnimation
()
{
if
!
isAnimationing
{
return
}
guard
let
image
=
self
.
image
else
{
return
}
var
frame
:
CGRect
=
animationRect
let
hImg
=
image
.
size
.
height
*
animationRect
.
size
.
width
/
image
.
size
.
width
frame
.
origin
.
y
-=
hImg
frame
.
size
.
height
=
hImg
self
.
frame
=
frame
self
.
alpha
=
0.0
UIView
.
animate
(
withDuration
:
1.4
,
animations
:
{
()
in
self
.
alpha
=
1.0
var
frame
=
self
.
animationRect
let
hImg
=
image
.
size
.
height
*
self
.
animationRect
.
size
.
width
/
image
.
size
.
width
frame
.
origin
.
y
+=
(
frame
.
size
.
height
-
hImg
)
frame
.
size
.
height
=
hImg
self
.
frame
=
frame
},
completion
:
{
(
_
:
Bool
)
in
self
.
perform
(
#selector(
LBXScanLineAnimation.stepAnimation
)
,
with
:
nil
,
afterDelay
:
0.3
)
})
}
func
stopStepAnimating
()
{
self
.
isHidden
=
true
isAnimationing
=
false
}
static
public
func
instance
()
->
LBXScanLineAnimation
{
return
LBXScanLineAnimation
()
}
deinit
{
stopStepAnimating
()
}
}
galaxy/galaxy/Classes/Tools/SwiftScan/LBXScanNetAnimation.swift
0 → 100755
View file @
69a1a665
//
// LBXScanNetAnimation.swift
// swiftScan
//
// Created by lbxia on 15/12/9.
// Copyright © 2015年 xialibing. All rights reserved.
//
import
UIKit
class
LBXScanNetAnimation
:
UIImageView
{
var
isAnimationing
=
false
var
animationRect
:
CGRect
=
CGRect
.
zero
static
public
func
instance
()
->
LBXScanNetAnimation
{
return
LBXScanNetAnimation
()
}
func
startAnimatingWithRect
(
animationRect
:
CGRect
,
parentView
:
UIView
,
image
:
UIImage
?)
{
self
.
image
=
image
self
.
animationRect
=
animationRect
parentView
.
addSubview
(
self
)
self
.
isHidden
=
false
isAnimationing
=
true
if
image
!=
nil
{
stepAnimation
()
}
}
@objc
func
stepAnimation
()
{
if
!
isAnimationing
{
return
}
guard
let
image
=
self
.
image
else
{
return
}
var
frame
=
animationRect
let
hImg
=
image
.
size
.
height
*
animationRect
.
size
.
width
/
image
.
size
.
width
frame
.
origin
.
y
-=
hImg
frame
.
size
.
height
=
hImg
self
.
frame
=
frame
self
.
alpha
=
0.0
UIView
.
animate
(
withDuration
:
1.2
,
animations
:
{
()
in
self
.
alpha
=
1.0
var
frame
=
self
.
animationRect
let
hImg
=
image
.
size
.
height
*
self
.
animationRect
.
size
.
width
/
image
.
size
.
width
frame
.
origin
.
y
+=
(
frame
.
size
.
height
-
hImg
)
frame
.
size
.
height
=
hImg
self
.
frame
=
frame
},
completion
:
{
(
_
:
Bool
)
in
self
.
perform
(
#selector(
LBXScanNetAnimation.stepAnimation
)
,
with
:
nil
,
afterDelay
:
0.3
)
})
}
func
stopStepAnimating
()
{
self
.
isHidden
=
true
isAnimationing
=
false
}
}
galaxy/galaxy/Classes/Tools/SwiftScan/LBXScanView.swift
0 → 100755
View file @
69a1a665
This diff is collapsed.
Click to expand it.
galaxy/galaxy/Classes/Tools/SwiftScan/LBXScanViewController.swift
0 → 100755
View file @
69a1a665
//
// LBXScanViewController.swift
// swiftScan
//
// Created by lbxia on 15/12/8.
// Copyright © 2015年 xialibing. All rights reserved.
//
import
UIKit
import
Foundation
import
AVFoundation
protocol
LBXScanViewControllerDelegate
:
AnyObject
{
func
scanFinished
(
scanResult
:
LBXScanResult
,
error
:
String
?)
}
protocol
QRRectDelegate
:
AnyObject
{
func
drawwed
()
}
class
LBXScanViewController
:
YHBaseViewController
,
UIImagePickerControllerDelegate
,
UINavigationControllerDelegate
{
// 返回扫码结果,也可以通过继承本控制器,改写该handleCodeResult方法即可
open
weak
var
scanResultDelegate
:
LBXScanViewControllerDelegate
?
open
var
delegate
:
QRRectDelegate
?
open
var
scanObj
:
LBXScanWrapper
?
open
var
scanStyle
:
LBXScanViewStyle
?
=
LBXScanViewStyle
()
open
var
qRScanView
:
LBXScanView
?
// 启动区域识别功能
open
var
isOpenInterestRect
=
false
// 识别码的类型
public
var
arrayCodeType
:
[
AVMetadataObject
.
ObjectType
]?
// 是否需要识别后的当前图像
public
var
isNeedCodeImage
=
false
// 相机启动提示文字
public
var
readyString
:
String
=
"loading"
override
open
func
viewDidLoad
()
{
super
.
viewDidLoad
()
self
.
view
.
backgroundColor
=
UIColor
.
black
drawScanView
()
// self.edgesForExtendedLayout = UIRectEdge(rawValue: 0)
}
open
func
setNeedCodeImage
(
needCodeImg
:
Bool
)
{
isNeedCodeImage
=
needCodeImg
}
// 设置框内识别
open
func
setOpenInterestRect
(
isOpen
:
Bool
)
{
isOpenInterestRect
=
isOpen
}
override
open
func
viewDidAppear
(
_
animated
:
Bool
)
{
super
.
viewDidAppear
(
animated
)
LBXPermissions
.
authorizeCameraWith
{
[
weak
self
]
granted
in
if
granted
{
self
?
.
perform
(
#selector(
LBXScanViewController.startScan
)
,
with
:
nil
,
afterDelay
:
0.3
)
}
else
{
// 跳转到系统设置
YHCommonAlertView
.
show
(
""
,
"没有相机权限,是否跳转设置页面开启?"
,
"取消"
,
"确定"
,
fullGuestureEnable
:
false
)
{
}
callBack
:
{
let
localUrl
=
URL
(
string
:
UIApplication
.
openSettingsURLString
)
if
let
url
=
localUrl
{
if
UIApplication
.
shared
.
canOpenURL
(
url
)
{
UIApplication
.
shared
.
open
(
url
,
options
:
[:],
completionHandler
:
nil
)
}
}
}
}
}
}
@objc
open
func
startScan
()
{
if
scanObj
==
nil
{
var
cropRect
=
CGRect
.
zero
if
isOpenInterestRect
{
guard
let
style
=
scanStyle
else
{
return
}
cropRect
=
LBXScanView
.
getScanRectWithPreView
(
preView
:
self
.
view
,
style
:
style
)
}
// 指定识别几种码
if
arrayCodeType
==
nil
{
arrayCodeType
=
[
.
qr
,
.
ean13
,
.
code39
,
.
code128
]
}
guard
let
codeTypes
=
arrayCodeType
else
{
return
}
scanObj
=
LBXScanWrapper
(
videoPreView
:
self
.
view
,
objType
:
codeTypes
,
isCaptureImg
:
isNeedCodeImage
,
cropRect
:
cropRect
,
success
:
{
[
weak
self
]
arrayResult
in
if
let
strongSelf
=
self
{
// 停止扫描动画
strongSelf
.
qRScanView
?
.
stopScanAnimation
()
strongSelf
.
handleCodeResult
(
arrayResult
:
arrayResult
)
}
})
}
// 结束相机等待提示
qRScanView
?
.
deviceStopReadying
()
// 开始扫描动画
qRScanView
?
.
startScanAnimation
()
// 相机运行
scanObj
?
.
start
()
}
open
func
stopScan
()
{
qRScanView
?
.
stopScanAnimation
()
scanObj
?
.
stop
()
}
open
func
drawScanView
()
{
if
qRScanView
==
nil
{
guard
let
style
=
scanStyle
else
{
return
}
let
qRScanView
=
LBXScanView
(
frame
:
self
.
view
.
frame
,
vstyle
:
style
)
self
.
qRScanView
=
qRScanView
self
.
view
.
addSubview
(
qRScanView
)
delegate
?
.
drawwed
()
}
qRScanView
?
.
deviceStartReadying
(
readyStr
:
readyString
)
}
// 处理扫码结果,如果是继承本控制器的,可以重写该方法,作出相应地处理,或者设置delegate作出相应处理
open
func
handleCodeResult
(
arrayResult
:
[
LBXScanResult
])
{
if
let
delegate
=
scanResultDelegate
{
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
let
result
:
LBXScanResult
=
arrayResult
[
0
]
delegate
.
scanFinished
(
scanResult
:
result
,
error
:
nil
)
}
else
{
for
result
:
LBXScanResult
in
arrayResult
{
debugPrint
(
"%@"
,
result
.
strScanned
??
""
)
}
let
result
:
LBXScanResult
=
arrayResult
[
0
]
YHCommonAlertView
.
show
(
result
.
strBarCodeType
,
result
.
strScanned
,
""
,
"确定"
,
fullGuestureEnable
:
false
)
{
}
callBack
:
{
}
}
}
override
open
func
viewWillDisappear
(
_
animated
:
Bool
)
{
NSObject
.
cancelPreviousPerformRequests
(
withTarget
:
self
)
stopScan
()
}
open
func
openPhotoAlbum
()
{
LBXPermissions
.
authorizePhotoWith
{
[
weak
self
]
granted
in
if
granted
{
let
picker
=
UIImagePickerController
()
picker
.
sourceType
=
.
photoLibrary
picker
.
delegate
=
self
picker
.
allowsEditing
=
true
self
?
.
present
(
picker
,
animated
:
true
,
completion
:
nil
)
}
else
{
YHCommonAlertView
.
show
(
""
,
"没有相册权限,是否跳转设置页面开启?"
,
"取消"
,
"确定"
,
fullGuestureEnable
:
false
)
{
}
callBack
:
{
let
localUrl
=
URL
(
string
:
UIApplication
.
openSettingsURLString
)
if
let
url
=
localUrl
{
if
UIApplication
.
shared
.
canOpenURL
(
url
)
{
UIApplication
.
shared
.
open
(
url
,
options
:
[:],
completionHandler
:
nil
)
}
}
}
}
}
}
// MARK: - 相册选择图片识别二维码 (条形码没有找到系统方法)
public
func
imagePickerController
(
_
picker
:
UIImagePickerController
,
didFinishPickingMediaWithInfo
info
:
[
UIImagePickerController
.
InfoKey
:
Any
])
{
picker
.
dismiss
(
animated
:
true
,
completion
:
nil
)
var
image
:
UIImage
?
=
info
[
.
editedImage
]
as?
UIImage
if
image
==
nil
{
image
=
info
[
.
originalImage
]
as?
UIImage
}
if
let
validImage
=
image
{
let
arrayResult
=
LBXScanWrapper
.
recognizeQRImage
(
image
:
validImage
)
if
arrayResult
.
count
>
0
{
handleCodeResult
(
arrayResult
:
arrayResult
)
return
}
}
YHCommonAlertView
.
show
(
""
,
"暂无法识别图片中二维码"
,
""
,
"确定"
,
fullGuestureEnable
:
false
)
{
}
callBack
:
{
}
}
deinit
{
}
}
galaxy/galaxy/Classes/Tools/SwiftScan/LBXScanViewStyle.swift
0 → 100755
View file @
69a1a665
//
// LBXScanViewStyle.swift
// swiftScan
//
// Created by xialibing on 15/12/8.
// Copyright © 2015年 xialibing. All rights reserved.
//
import
UIKit
/// 扫码区域动画效果
public
enum
LBXScanViewAnimationStyle
{
case
LineMove
// 线条上下移动
case
NetGrid
// 网格
case
LineStill
// 线条停止在扫码区域中央
case
None
// 无动画
}
/// 扫码区域4个角位置类型
public
enum
LBXScanViewPhotoframeAngleStyle
{
case
Inner
// 内嵌,一般不显示矩形框情况下
case
Outer
// 外嵌,包围在矩形框的4个角
case
On
// 在矩形框的4个角上,覆盖
}
public
struct
LBXScanViewStyle
{
// MARK: - -中心位置矩形框
/// 是否需要绘制扫码矩形框,默认YES
public
var
isNeedShowRetangle
:
Bool
=
true
/**
* 默认扫码区域为正方形,如果扫码区域不是正方形,设置宽高比
*/
public
var
whRatio
:
CGFloat
=
1.0
/**
@brief 矩形框(视频显示透明区)域向上移动偏移量,0表示扫码透明区域在当前视图中心位置,如果负值表示扫码区域下移
*/
public
var
centerUpOffset
:
CGFloat
=
44
/**
* 矩形框(视频显示透明区)域离界面左边及右边距离,默认60
*/
public
var
xScanRetangleOffset
:
CGFloat
=
60
/**
@brief 矩形框线条颜色,默认白色
*/
public
var
colorRetangleLine
=
UIColor
.
white
// MARK: - 矩形框(扫码区域)周围4个角
/**
@brief 扫码区域的4个角类型
*/
public
var
photoframeAngleStyle
=
LBXScanViewPhotoframeAngleStyle
.
Outer
// 4个角的颜色
public
var
colorAngle
=
UIColor
(
red
:
0.0
,
green
:
167.0
/
255.0
,
blue
:
231.0
/
255.0
,
alpha
:
1.0
)
// 扫码区域4个角的宽度和高度
public
var
photoframeAngleW
:
CGFloat
=
24.0
public
var
photoframeAngleH
:
CGFloat
=
24.0
/**
@brief 扫码区域4个角的线条宽度,默认6,建议8到4之间
*/
public
var
photoframeLineW
:
CGFloat
=
6
// MARK: - ---动画效果
/**
@brief 扫码动画效果:线条或网格
*/
public
var
anmiationStyle
=
LBXScanViewAnimationStyle
.
LineMove
/**
* 动画效果的图像,如线条或网格的图像
*/
public
var
animationImage
:
UIImage
?
// MARK: - 非识别区域颜色,默认 RGBA (0,0,0,0.5),范围(0--1)
public
var
color_NotRecoginitonArea
:
UIColor
=
UIColor
(
red
:
0.0
,
green
:
0.0
,
blue
:
0.0
,
alpha
:
0.5
)
public
init
()
{
}
}
galaxy/galaxy/Classes/Tools/SwiftScan/LBXScanWrapper.swift
0 → 100755
View file @
69a1a665
This diff is collapsed.
Click to expand it.
galaxy/galaxy/Res/Assets.xcassets/Mine/qr_scan_icon.imageset/Contents.json
0 → 100644
View file @
69a1a665
{
"images"
:
[
{
"idiom"
:
"universal"
,
"scale"
:
"1x"
},
{
"filename"
:
"qr_scan_icon@2x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"2x"
},
{
"filename"
:
"qr_scan_icon@3x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"3x"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
galaxy/galaxy/Res/Assets.xcassets/Mine/qr_scan_icon.imageset/qr_scan_icon@2x.png
0 → 100644
View file @
69a1a665
345 Bytes
galaxy/galaxy/Res/Assets.xcassets/Mine/qr_scan_icon.imageset/qr_scan_icon@3x.png
0 → 100644
View file @
69a1a665
437 Bytes
galaxy/galaxy/Res/Assets.xcassets/Mine/scan_move_line.imageset/Contents.json
0 → 100644
View file @
69a1a665
{
"images"
:
[
{
"idiom"
:
"universal"
,
"scale"
:
"1x"
},
{
"filename"
:
"scan_move_line@2x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"2x"
},
{
"filename"
:
"scan_move_line@3x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"3x"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
galaxy/galaxy/Res/Assets.xcassets/Mine/scan_move_line.imageset/scan_move_line@2x.png
0 → 100644
View file @
69a1a665
30 KB
galaxy/galaxy/Res/Assets.xcassets/Mine/scan_move_line.imageset/scan_move_line@3x.png
0 → 100644
View file @
69a1a665
61.4 KB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment