Commit 57cb89c0 authored by pete谢兆麟's avatar pete谢兆麟

方案逻辑

parent 68877ba1
......@@ -11,10 +11,12 @@ import UIKit
class YHMakePlanViewController: YHBaseViewController {
var items: [[Int]] = []
let viewModel = YHMakePlanViewModel()
private var lastContentOffset: CGFloat = 0
private let scrollThreshold: CGFloat = 100 // 滑动100点显示导航栏
private var isNavigationBarHidden = false
lazy var headView: YHMakePlanHeadView = {
let view = YHMakePlanHeadView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 333.fix + 44))
return view
}()
lazy var tableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .grouped)
......@@ -27,7 +29,7 @@ class YHMakePlanViewController: YHBaseViewController {
tableView.delegate = self
tableView.dataSource = self
tableView.register(cellWithClass: YHMakePlanCell.self)
tableView.tableHeaderView = YHMakePlanHeadView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 333.fix + 44))
tableView.tableHeaderView = headView
return tableView
}()
......@@ -78,11 +80,35 @@ class YHMakePlanViewController: YHBaseViewController {
let totalPrice = viewModel.makePlanModel.calculateTotalPrice()
priceView.configure(price: totalPrice, actionText: "去办理") {
YHMakePlanPriceAlertView.show(dataSource: self.viewModel.makePlanModel) { _ in
self.addShopCard()
}
} nextHandler: {
YHMakePlanPriceAlertView.show(dataSource: self.viewModel.makePlanModel) { _ in
self.addShopCard()
}
}
func addShopCard() {
self.viewModel.addShopCard(model: self.viewModel.makePlanModel) { success, error in
if success {
//跳转购物车
if let token = YHLoginManager.shared.userModel?.token, token.count > 5 {
var url = YHBaseUrlManager.shared.curH5URL() + "superAppBridge.html#/goods/cart"
url = url + "?param=" + YHLoginManager.shared.h5Token
printLog("URL: \(url)")
var tUrl = url
if !url.contains("navigationH=") {
tUrl = url + "?navigationH=\(k_Height_NavigationtBarAndStatuBar)"
if url.contains("?") {
tUrl = url + "&navigationH=\(k_Height_NavigationtBarAndStatuBar)"
}
}
let vc = YHH5WebViewVC()
vc.url = tUrl
vc.isFullScreenFlag = false
vc.navTitle = "购物车"
vc.isSupportWebviewInterBackFlag = true
self.navigationController?.pushViewController(vc)
}
}
}
}
......@@ -94,7 +120,9 @@ class YHMakePlanViewController: YHBaseViewController {
}
@objc func share() {
YHMakePlanShareAlertView.show(url: viewModel.score.url) { _ in
}
}
func requestData() {
......@@ -108,7 +136,8 @@ class YHMakePlanViewController: YHBaseViewController {
func getScore() {
viewModel.getRate(model: viewModel.makePlanModel) {[weak self] _, _ in
guard let self = self else { return }
self.headView.dataSource = viewModel.score
self.topView.dataSource = viewModel.score
}
}
......@@ -142,6 +171,7 @@ extension YHMakePlanViewController: UITableViewDelegate, UITableViewDataSource {
cell.actionHandler = { product in
self.viewModel.makePlanModel.toggleAddCartStatus(for: product)
self.updataPrice()
self.getScore()
}
return cell
}
......
......@@ -34,6 +34,12 @@ class YHMakePlanHeadView: UIView {
return view
}()
var dataSource: YHMakePlanScoreModel? {
didSet {
centerView.dataSource = dataSource
}
}
override init(frame: CGRect) {
super.init(frame: frame)
setUpView()
......
......@@ -15,10 +15,11 @@ class YHMakePlanShareAlertView: UIView {
var sureButton: UIButton!
var leftButton: YHShareButton!
var rightButton: YHShareButton!
static func show(callBack: @escaping ((Int) -> Void)) {
var url: String = ""
static func show(url: String, callBack: @escaping ((Int) -> Void)) {
let view = YHMakePlanShareAlertView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight))
view.block = callBack
view.url = url
let window = UIApplication.shared.yhKeyWindow()
window?.addSubview(view)
}
......@@ -97,16 +98,13 @@ class YHMakePlanShareAlertView: UIView {
}
@objc func wxClick() {
// guard let combinedImage = combinedImageFrom(imageView: centerImageView) else { return }
YHShareManager.shared.sendLinkContent("香港身份规划专属礼包,限时领取!", "资深银河规划专家1V1评估方案", UIImage(named: "invitation_with_gifts_share_other") ?? UIImage(), link: YHBaseUrlManager.shared.curH5URL() + "superAppBridge.html#/evaluation?channel=lkhtj-app&customer_id=\(YHLoginManager.shared.userModel?.id ?? "")&scene_id=30")
// YHShareManager.shared.sendImageContent(combinedImage)
if let url = URL(string: url) {
UIPasteboard.general.url = url
}
}
@objc func peopleClick() {
// guard let combinedImage = combinedImageFrom(imageView: centerImageView) else { return }
// YHShareManager.shared.sendImageContent(combinedImage, WXSceneTimeline)
YHShareManager.shared.sendLinkContent("香港身份规划专属礼包,限时领取!", "资深银河规划专家1V1评估方案", UIImage(named: "invitation_with_gifts_share_other") ?? UIImage(), link: YHBaseUrlManager.shared.curH5URL() + "superAppBridge.html#/evaluation?channel=lkhtj-app&customer_id=\(YHLoginManager.shared.userModel?.id ?? "")&scene_id=30", WXSceneTimeline)
YHShareManager.shared.sendLinkContent("香港续签至永居方案分析", "具体方案您可以联系专属顾问和生活管家深入咨询~", UIImage(named: "invitation_with_gifts_share_plan") ?? UIImage(), link: url)
}
@objc private func handleTap(_ sender: AnyObject?) {
......
......@@ -9,6 +9,12 @@
import UIKit
class YHMakePlanStateHeadView: UIView {
var dataSource: YHMakePlanScoreModel? {
didSet {
guard let dataSource = dataSource else { return }
configure(model: dataSource)
}
}
// MARK: - UI Components
private let yearsLabel: UILabel = {
......@@ -95,8 +101,8 @@ class YHMakePlanStateHeadView: UIView {
}
// MARK: - Configuration
func configure(years: Int, percentage: Float) {
yearsLabel.text = "\(years)"
percentageLabel.text = "\(Int(percentage * 100))%"
func configure(model: YHMakePlanScoreModel) {
yearsLabel.text = "\(model.year)"
percentageLabel.text = model.pass_rate
}
}
......@@ -10,6 +10,18 @@ import UIKit
import AttributedString
class YHMakePlanTopView: UIView {
var dataSource: YHMakePlanScoreModel? {
didSet {
let a: ASAttributedString = .init("预计可续期(年) ", .font(UIFont.PFSC_M(ofSize: 14)), .foreground(UIColor(hex: 0x6a7586)))
let b: ASAttributedString = .init("\(dataSource?.year)", .font(UIFont.PFSC_M(ofSize: 24)), .foreground(UIColor.mainTextColor))
yearsLabel.attributed.text = a + b
let aa: ASAttributedString = .init("续签综合通过率 ", .font(UIFont.PFSC_M(ofSize: 14)), .foreground(UIColor(hex: 0x6a7586)))
let bb: ASAttributedString = .init("\(dataSource?.pass_rate)", .font(UIFont.PFSC_M(ofSize: 24)), .foreground(UIColor.mainTextColor))
// let c: ASAttributedString = .init("%", .font(UIFont.PFSC_M(ofSize: 16)), .foreground(UIColor.mainTextColor))
percentageLabel.attributed.text = aa + bb
}
}
private let yearsLabel: UILabel = {
let label = UILabel()
let a: ASAttributedString = .init("预计可续期(年) ", .font(UIFont.PFSC_M(ofSize: 14)), .foreground(UIColor(hex: 0x6a7586)))
......
......@@ -123,4 +123,87 @@ class YHMakePlanViewModel: YHBaseViewModel {
callBackBlock(false, err)
}
}
func addShopCard(model: YHMakePlanModel, callBackBlock: @escaping (_ success: Bool, _ error: YHErrorModel?) -> Void) {
var basic: [Int] = []
let basicArray = makePlanModel.basic
let workArray = makePlanModel.work
let liveArray = makePlanModel.live
let investArray = makePlanModel.invest
for item in basicArray {
if item.is_add_cart == true {
if item.sub_product.count > 0 {
for subItem in item.sub_product {
if subItem.is_add_cart == true {
basic.append(subItem.product_id)
}
}
} else {
basic.append(item.product_id)
}
}
}
for item in workArray {
if item.is_add_cart == true {
if item.sub_product.count > 0 {
for subItem in item.sub_product {
if subItem.is_add_cart == true {
basic.append(subItem.product_id)
}
}
} else {
basic.append(item.product_id)
}
}
}
for item in liveArray {
if item.is_add_cart == true {
if item.sub_product.count > 0 {
for subItem in item.sub_product {
if subItem.is_add_cart == true {
basic.append(subItem.product_id)
}
}
} else {
basic.append(item.product_id)
}
}
}
for item in investArray {
if item.is_add_cart == true {
if item.sub_product.count > 0 {
for subItem in item.sub_product {
if subItem.is_add_cart == true {
basic.append(subItem.product_id)
}
}
} else {
basic.append(item.product_id)
}
}
}
let params: [String: Any] = ["ids": basic,
"create_source": 2]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.ResignPlan.store
_ = YHNetRequest.postRequest(url: strUrl, params: params) { [weak self] json, _ in
// 1. json字符串 转 对象
guard self != nil else { return }
if json.code == 200 {
guard let dic = json.data?.peel as? [String: Any], let result = YHMakePlanScoreModel.deserialize(from: dic) else {
callBackBlock(false, nil)
return
}
callBackBlock(true, nil)
} else {
let error: YHErrorModel = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg.count > 0 ? json.msg : "数据错误")
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false, err)
}
}
}
......@@ -757,6 +757,7 @@ class YHAllApiName {
static let planlistApi = "super-app/renewal/advice/get-renewal-plan"
static let productListApi = "super-app/renewal/advice/get-renewal-product-list"
static let getRate = "super-app/renewal/advice/get-year-and-pass-rate"
static let store = "super-app/presale/app/shop-cart/store"
}
// 问卷
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "invitation_with_gifts_share_plan@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "invitation_with_gifts_share_plan@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