Commit f500ab85 authored by pete谢兆麟's avatar pete谢兆麟

分享图片

parent 91332ef0
...@@ -299,6 +299,7 @@ ...@@ -299,6 +299,7 @@
047AA3F02C4F912D009C4554 /* YHListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047AA3EF2C4F912D009C4554 /* YHListViewModel.swift */; }; 047AA3F02C4F912D009C4554 /* YHListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047AA3EF2C4F912D009C4554 /* YHListViewModel.swift */; };
047AA3F42C50E5C7009C4554 /* YHInvitationWithGiftsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047AA3F32C50E5C7009C4554 /* YHInvitationWithGiftsViewModel.swift */; }; 047AA3F42C50E5C7009C4554 /* YHInvitationWithGiftsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047AA3F32C50E5C7009C4554 /* YHInvitationWithGiftsViewModel.swift */; };
047AA3F62C50E773009C4554 /* YHShareCashOutModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047AA3F52C50E773009C4554 /* YHShareCashOutModel.swift */; }; 047AA3F62C50E773009C4554 /* YHShareCashOutModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047AA3F52C50E773009C4554 /* YHShareCashOutModel.swift */; };
047AA3F82C5CC7B0009C4554 /* YHShareStepView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047AA3F72C5CC7B0009C4554 /* YHShareStepView.swift */; };
0480976B2BA15269000B9DCA /* YHCertificateInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0480976A2BA15269000B9DCA /* YHCertificateInfoCell.swift */; }; 0480976B2BA15269000B9DCA /* YHCertificateInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0480976A2BA15269000B9DCA /* YHCertificateInfoCell.swift */; };
0480976D2BA158A1000B9DCA /* YHCertificateListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0480976C2BA158A1000B9DCA /* YHCertificateListVC.swift */; }; 0480976D2BA158A1000B9DCA /* YHCertificateListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0480976C2BA158A1000B9DCA /* YHCertificateListVC.swift */; };
048097712BA18D66000B9DCA /* YHCertificateSearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048097702BA18D66000B9DCA /* YHCertificateSearchBar.swift */; }; 048097712BA18D66000B9DCA /* YHCertificateSearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048097702BA18D66000B9DCA /* YHCertificateSearchBar.swift */; };
...@@ -928,6 +929,7 @@ ...@@ -928,6 +929,7 @@
047AA3EF2C4F912D009C4554 /* YHListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHListViewModel.swift; sourceTree = "<group>"; }; 047AA3EF2C4F912D009C4554 /* YHListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHListViewModel.swift; sourceTree = "<group>"; };
047AA3F32C50E5C7009C4554 /* YHInvitationWithGiftsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHInvitationWithGiftsViewModel.swift; sourceTree = "<group>"; }; 047AA3F32C50E5C7009C4554 /* YHInvitationWithGiftsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHInvitationWithGiftsViewModel.swift; sourceTree = "<group>"; };
047AA3F52C50E773009C4554 /* YHShareCashOutModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHShareCashOutModel.swift; sourceTree = "<group>"; }; 047AA3F52C50E773009C4554 /* YHShareCashOutModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHShareCashOutModel.swift; sourceTree = "<group>"; };
047AA3F72C5CC7B0009C4554 /* YHShareStepView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHShareStepView.swift; sourceTree = "<group>"; };
0480976A2BA15269000B9DCA /* YHCertificateInfoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateInfoCell.swift; sourceTree = "<group>"; }; 0480976A2BA15269000B9DCA /* YHCertificateInfoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateInfoCell.swift; sourceTree = "<group>"; };
0480976C2BA158A1000B9DCA /* YHCertificateListVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateListVC.swift; sourceTree = "<group>"; }; 0480976C2BA158A1000B9DCA /* YHCertificateListVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateListVC.swift; sourceTree = "<group>"; };
048097702BA18D66000B9DCA /* YHCertificateSearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateSearchBar.swift; sourceTree = "<group>"; }; 048097702BA18D66000B9DCA /* YHCertificateSearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateSearchBar.swift; sourceTree = "<group>"; };
...@@ -1372,6 +1374,7 @@ ...@@ -1372,6 +1374,7 @@
0419A0A32C49184300A5FCFA /* YHInvitationNumberItemView.swift */, 0419A0A32C49184300A5FCFA /* YHInvitationNumberItemView.swift */,
047AA3D42C4A3643009C4554 /* YHInvitationWithGiftsDetailView.swift */, 047AA3D42C4A3643009C4554 /* YHInvitationWithGiftsDetailView.swift */,
047AA3D62C4A4399009C4554 /* YHInvitationWithGiftsShareView.swift */, 047AA3D62C4A4399009C4554 /* YHInvitationWithGiftsShareView.swift */,
047AA3F72C5CC7B0009C4554 /* YHShareStepView.swift */,
); );
path = V; path = V;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -3860,6 +3863,7 @@ ...@@ -3860,6 +3863,7 @@
A567E5AF2BD7643D00D5D5A0 /* YHHomeWebViewBottomForSavePicView.swift in Sources */, A567E5AF2BD7643D00D5D5A0 /* YHHomeWebViewBottomForSavePicView.swift in Sources */,
045A7E672C2ACB1A008F995B /* YHLoginOneLeadView.swift in Sources */, 045A7E672C2ACB1A008F995B /* YHLoginOneLeadView.swift in Sources */,
048787D72BCE96F50036E221 /* YHServiceOrderProgressTableViewCell.swift in Sources */, 048787D72BCE96F50036E221 /* YHServiceOrderProgressTableViewCell.swift in Sources */,
047AA3F82C5CC7B0009C4554 /* YHShareStepView.swift in Sources */,
04AD31792C23FFC700DF5655 /* YHInterestModel.swift in Sources */, 04AD31792C23FFC700DF5655 /* YHInterestModel.swift in Sources */,
04EA23082BB50753009DA928 /* YHDocumentMessageTableViewCell.swift in Sources */, 04EA23082BB50753009DA928 /* YHDocumentMessageTableViewCell.swift in Sources */,
045EEE8E2B9F171A0022A143 /* YHPreviewInfoWorkSummaryView.swift in Sources */, 045EEE8E2B9F171A0022A143 /* YHPreviewInfoWorkSummaryView.swift in Sources */,
......
...@@ -12,15 +12,36 @@ import Vision ...@@ -12,15 +12,36 @@ import Vision
import Photos import Photos
class YHInvatationShareViewController: YHBaseViewController { class YHInvatationShareViewController: YHBaseViewController {
var stepView: YHShareStepView!
var centerImageView: UIImageView!
var imageView: UIImageView!
var logoImageView: UIImageView!
var bottomView: UIView! var bottomView: UIView!
var leftButton: YHShareButton! var leftButton: YHShareButton!
var centerButton: YHShareButton! var centerButton: YHShareButton!
var rightButton: YHShareButton! var rightButton: YHShareButton!
lazy var myCollectView = {
// 设置布局方向
let flowLayout = UICollectionViewFlowLayout()
flowLayout.itemSize = CGSize(width: KScreenWidth, height: KScreenHeight - k_Height_NavigationtBarAndStatuBar - 148)
flowLayout.minimumInteritemSpacing = 0
flowLayout.minimumLineSpacing = 0
flowLayout.scrollDirection = .horizontal
let collectinoView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout)
collectinoView.backgroundColor = .white
collectinoView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
collectinoView.register(YHShareOneCollectionViewCell.self, forCellWithReuseIdentifier:YHShareOneCollectionViewCell.cellReuseIdentifier)
collectinoView.register(YHShareTwoCollectionViewCell.self, forCellWithReuseIdentifier:YHShareTwoCollectionViewCell.cellReuseIdentifier)
collectinoView.delegate = self
collectinoView.dataSource = self
collectinoView.translatesAutoresizingMaskIntoConstraints = false
collectinoView.alwaysBounceVertical = true
collectinoView.bounces = false
collectinoView.isPagingEnabled = true
collectinoView.showsHorizontalScrollIndicator = false
collectinoView.showsVerticalScrollIndicator = false
return collectinoView
}()
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
setView() setView()
...@@ -40,40 +61,11 @@ extension YHInvatationShareViewController { ...@@ -40,40 +61,11 @@ extension YHInvatationShareViewController {
func setView() { func setView() {
view.backgroundColor = .contentBkgColor view.backgroundColor = .contentBkgColor
gk_navTitle = "分享活动" gk_navTitle = "分享活动"
centerImageView = { view.addSubview(myCollectView)
let view = UIImageView() myCollectView.snp.makeConstraints { make in
view.image = UIImage(named: "invitation_with_gifts_share_detail") make.left.right.equalToSuperview()
return view make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
}() make.bottom.equalTo(-148)
view.addSubview(centerImageView)
centerImageView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.centerY.equalToSuperview().offset(-30)
make.height.equalTo(480)
make.width.equalTo(270)
}
imageView = {
let view = UIImageView()
view.image = UIImage(named: "invitation_with_gifts_share_detail")
return view
}()
centerImageView.addSubview(imageView)
imageView.snp.makeConstraints { make in
make.bottom.equalTo(-57)
make.right.equalTo(-27)
make.width.height.equalTo(56)
}
logoImageView = {
let view = UIImageView()
view.image = UIImage(named: "share_icon")
return view
}()
imageView.addSubview(logoImageView)
logoImageView.snp.makeConstraints { make in
make.center.equalToSuperview()
make.width.height.equalTo(17)
} }
bottomView = { bottomView = {
...@@ -128,18 +120,35 @@ extension YHInvatationShareViewController { ...@@ -128,18 +120,35 @@ extension YHInvatationShareViewController {
make.height.equalTo(74) make.height.equalTo(74)
make.width.equalTo(52) make.width.equalTo(52)
} }
stepView = {
let view = YHShareStepView()
return view
}()
view.addSubview(stepView)
stepView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.bottom.equalTo(bottomView.snp.top).offset(-41.5)
make.height.equalTo(1.5)
make.width.equalTo(35)
}
} }
func loadData() { func loadData() {
if let qrCode = generateQRCode(from: YHBaseUrlManager.shared.curH5URL() + "superAppBridge.html#/evaluation?channel=lkhtj-app&customer_id=\(YHLoginManager.shared.userModel?.id ?? "")&scene_id=30") {
// 可以将qrCode设置为UIImageView的image属性来显示二维码
imageView.image = qrCode
}
} }
@objc func saveBtnClick() { @objc func saveBtnClick() {
guard let combinedImage = combinedImageFrom(imageView: centerImageView) else { return } let currentPage = self.currentPage(collectionView: myCollectView)
saveImageToPhotosAlbum(image: combinedImage) if currentPage == 0 {
let cell = myCollectView.cellForItem(at: IndexPath(row: currentPage, section: 0)) as! YHShareOneCollectionViewCell
guard let combinedImage = combinedImageFrom(imageView: cell.centerImageView) else { return }
saveImageToPhotosAlbum(image: combinedImage)
} else {
let cell = myCollectView.cellForItem(at: IndexPath(row: currentPage, section: 0)) as! YHShareTwoCollectionViewCell
guard let combinedImage = combinedImageFrom(imageView: cell.centerImageView) else { return }
saveImageToPhotosAlbum(image: combinedImage)
}
} }
func saveImageToPhotosAlbum(image: UIImage) { func saveImageToPhotosAlbum(image: UIImage) {
...@@ -200,4 +209,198 @@ extension YHInvatationShareViewController { ...@@ -200,4 +209,198 @@ extension YHInvatationShareViewController {
return combinedImage return combinedImage
} }
func currentPage(collectionView: UICollectionView) -> Int {
let pageWidth = collectionView.frame.width
let offset = collectionView.contentOffset
return Int(offset.x / pageWidth)
}
}
extension YHInvatationShareViewController: UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 2
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if indexPath.row == 0 {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHShareOneCollectionViewCell.cellReuseIdentifier, for: indexPath) as! YHShareOneCollectionViewCell
return cell
} else {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHShareTwoCollectionViewCell.cellReuseIdentifier, for: indexPath) as! YHShareTwoCollectionViewCell
return cell
}
}
}
extension YHInvatationShareViewController: UIScrollViewDelegate {
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
let currentPage = self.currentPage(collectionView: myCollectView)
if currentPage == 0 {
stepView.stepOneView.backgroundColor = UIColor(hex: 0x94a3b8)
stepView.stepTwoView.backgroundColor = UIColor(hex: 0x94a3b8).withAlphaComponent(0.3)
} else {
stepView.stepOneView.backgroundColor = UIColor(hex: 0x94a3b8).withAlphaComponent(0.3)
stepView.stepTwoView.backgroundColor = UIColor(hex: 0x94a3b8)
}
}
}
class YHShareOneCollectionViewCell: UICollectionViewCell {
static let cellReuseIdentifier = "YHShareOneCollectionViewCell"
var centerImageView: UIImageView!
var imageView: UIImageView!
var logoImageView: UIImageView!
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
private func setupUI() {
self.backgroundColor = UIColor(hex: 0xededed)
centerImageView = {
let view = UIImageView()
view.image = UIImage(named: "invitation_with_gifts_share_detail")
return view
}()
contentView.addSubview(centerImageView)
centerImageView.snp.makeConstraints { make in
make.center.equalToSuperview()
make.height.equalTo(480)
make.width.equalTo(270)
}
imageView = {
let view = UIImageView()
view.image = UIImage(named: "invitation_with_gifts_share_detail")
return view
}()
centerImageView.addSubview(imageView)
imageView.snp.makeConstraints { make in
make.bottom.equalTo(-57)
make.right.equalTo(-27)
make.width.height.equalTo(56)
}
logoImageView = {
let view = UIImageView()
view.image = UIImage(named: "share_icon")
return view
}()
imageView.addSubview(logoImageView)
logoImageView.snp.makeConstraints { make in
make.center.equalToSuperview()
make.width.height.equalTo(17)
}
if let qrCode = generateQRCode(from: YHBaseUrlManager.shared.curH5URL() + "superAppBridge.html#/evaluation?channel=lkhtj-app&customer_id=\(YHLoginManager.shared.userModel?.id ?? "")&scene_id=30") {
// 可以将qrCode设置为UIImageView的image属性来显示二维码
imageView.image = qrCode
}
}
func generateQRCode(from string: String) -> UIImage? {
guard let data = string.data(using: .ascii, allowLossyConversion: false) else {
return nil
}
let filter = CIFilter(name: "CIQRCodeGenerator")
filter?.setValue(data, forKey: "inputMessage")
guard let outputImage = filter?.outputImage else {
return nil
}
let context = CIContext()
if let cgImage = context.createCGImage(outputImage, from: outputImage.extent) {
return UIImage(cgImage: cgImage)
}
return nil
}
}
class YHShareTwoCollectionViewCell: UICollectionViewCell {
static let cellReuseIdentifier = "YHShareTwoCollectionViewCell"
var centerImageView: UIImageView!
var imageView: UIImageView!
var logoImageView: UIImageView!
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
private func setupUI() {
self.backgroundColor = UIColor(hex: 0xededed)
centerImageView = {
let view = UIImageView()
view.image = UIImage(named: "invitation_with_gifts_share_detail2")
return view
}()
contentView.addSubview(centerImageView)
centerImageView.snp.makeConstraints { make in
make.center.equalToSuperview()
make.height.equalTo(480)
make.width.equalTo(270)
}
imageView = {
let view = UIImageView()
view.image = UIImage(named: "invitation_with_gifts_share_detail")
return view
}()
centerImageView.addSubview(imageView)
imageView.snp.makeConstraints { make in
make.bottom.equalTo(-46)
make.right.equalTo(-36)
make.width.height.equalTo(68)
}
logoImageView = {
let view = UIImageView()
view.image = UIImage(named: "share_icon")
return view
}()
imageView.addSubview(logoImageView)
logoImageView.snp.makeConstraints { make in
make.center.equalToSuperview()
make.width.height.equalTo(20)
}
if let qrCode = generateQRCode(from: YHBaseUrlManager.shared.curH5URL() + "superAppBridge.html#/evaluation?channel=lkhtj-app&customer_id=\(YHLoginManager.shared.userModel?.id ?? "")&scene_id=30") {
// 可以将qrCode设置为UIImageView的image属性来显示二维码
imageView.image = qrCode
}
}
func generateQRCode(from string: String) -> UIImage? {
guard let data = string.data(using: .ascii, allowLossyConversion: false) else {
return nil
}
let filter = CIFilter(name: "CIQRCodeGenerator")
filter?.setValue(data, forKey: "inputMessage")
guard let outputImage = filter?.outputImage else {
return nil
}
let context = CIContext()
if let cgImage = context.createCGImage(outputImage, from: outputImage.extent) {
return UIImage(cgImage: cgImage)
}
return nil
}
} }
//
// YHShareStepView.swift
// galaxy
//
// Created by EDY on 2024/8/2.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHShareStepView: UIView {
var stepOneView: UIView!
var stepTwoView: UIView!
override init(frame: CGRect) {
super.init(frame: frame)
setView()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setView() {
stepOneView = {
let view = UIView()
view.backgroundColor = UIColor(hex: 0x94a3b8)
return view
}()
addSubview(stepOneView)
stepOneView.snp.makeConstraints { make in
make.top.left.bottom.equalToSuperview()
make.width.equalTo(16)
}
stepTwoView = {
let view = UIView()
view.backgroundColor = UIColor(hex: 0x94a3b8).withAlphaComponent(0.3)
return view
}()
addSubview(stepTwoView)
stepTwoView.snp.makeConstraints { make in
make.top.right.bottom.equalToSuperview()
make.width.equalTo(16)
}
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "invitation_with_gifts_share_detail2@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "invitation_with_gifts_share_detail2@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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