feat: 增加门店身份注销流程
This commit is contained in:
@@ -14,6 +14,7 @@ final class SettingViewController: BaseViewController {
|
||||
private let contentView = UIView()
|
||||
private let cardView = UIView()
|
||||
private let rowsStack = UIStackView()
|
||||
private let deregistrationRow = SettingMenuRow(title: "注销当前门店身份", titleColor: AppColor.danger, showsDivider: false)
|
||||
private let versionRow = SettingMenuRow(title: "系统版本", showsChevron: false)
|
||||
private let copyrightLabel = UILabel()
|
||||
|
||||
@@ -68,6 +69,10 @@ final class SettingViewController: BaseViewController {
|
||||
rows[2].addTarget(self, action: #selector(copyDownloadTapped), for: .touchUpInside)
|
||||
rows[3].addTarget(self, action: #selector(userAgreementTapped), for: .touchUpInside)
|
||||
rows[4].addTarget(self, action: #selector(privacyTapped), for: .touchUpInside)
|
||||
if AppStore.shared.session.accountType == .storeUser {
|
||||
rowsStack.addArrangedSubview(deregistrationRow)
|
||||
deregistrationRow.addTarget(self, action: #selector(deregistrationTapped), for: .touchUpInside)
|
||||
}
|
||||
}
|
||||
|
||||
override func setupConstraints() {
|
||||
@@ -119,6 +124,29 @@ final class SettingViewController: BaseViewController {
|
||||
openAgreement(.privacyPolicy)
|
||||
}
|
||||
|
||||
/// 仅从当前门店业务会话创建注销流程,冻结 Token 与门店用户 ID。
|
||||
@objc private func deregistrationTapped() {
|
||||
do {
|
||||
let session = AppStore.shared.session
|
||||
let identity = try StoreAccountDeregistrationIdentity(session: session)
|
||||
let api = StoreAccountDeregistrationAPI(client: NetworkServices.shared.apiClient, identity: identity) {
|
||||
identity.matches(session: session)
|
||||
}
|
||||
let controller = StoreAccountDeregistrationViewController(
|
||||
identityName: identity.displayName,
|
||||
viewModel: StoreAccountDeregistrationViewModel(
|
||||
storeUserID: Int(identity.userID) ?? 0,
|
||||
submissionStore: StoreAccountDeregistrationSubmissionStore(storeUserID: identity.userID)
|
||||
), api: api, onUnresolvedSubmission: {
|
||||
NotificationCenter.default.post(name: NotificationName.storeAccountDeregistrationRestricted,
|
||||
object: nil, userInfo: [NotificationUserInfoKey.deregistrationRequestToken: identity.token])
|
||||
}
|
||||
)
|
||||
controller.hidesBottomBarWhenPushed = true
|
||||
navigationController?.pushViewController(controller, animated: true)
|
||||
} catch { showError(error.localizedDescription) }
|
||||
}
|
||||
|
||||
private func openAgreement(_ kind: SettingAgreementKind) {
|
||||
let destination = viewModel.agreementDestination(for: kind)
|
||||
navigationController?.pushViewController(
|
||||
@@ -138,8 +166,10 @@ final class SettingMenuRow: UIControl {
|
||||
private let divider = UIView()
|
||||
private let showsChevron: Bool
|
||||
|
||||
/// 创建菜单行,可为注销等操作单独指定标题颜色,不影响其他行。
|
||||
init(
|
||||
title: String,
|
||||
titleColor: UIColor = UIColor(hex: 0x4B5563),
|
||||
value: String? = nil,
|
||||
valueColor: UIColor = AppColor.textPrimary,
|
||||
showsChevron: Bool = true,
|
||||
@@ -150,6 +180,7 @@ final class SettingMenuRow: UIControl {
|
||||
setupUI()
|
||||
setupConstraints()
|
||||
titleLabel.text = title
|
||||
titleLabel.textColor = titleColor
|
||||
valueLabel.text = value
|
||||
valueLabel.textColor = valueColor
|
||||
chevronImageView.isHidden = !showsChevron
|
||||
@@ -175,7 +206,6 @@ final class SettingMenuRow: UIControl {
|
||||
|
||||
private func setupUI() {
|
||||
titleLabel.font = .systemFont(ofSize: 14)
|
||||
titleLabel.textColor = UIColor(hex: 0x4B5563)
|
||||
|
||||
valueLabel.font = .systemFont(ofSize: 14)
|
||||
valueLabel.textColor = AppColor.textPrimary
|
||||
|
||||
Reference in New Issue
Block a user