Commit 582e0a94 authored by lmj_521aiau@163.com's avatar lmj_521aiau@163.com

goods

parent f016bd75
This diff is collapsed.
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "底框@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "底框@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "形状结合@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "形状结合@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "对号@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "对号@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
"scale" : "1x" "scale" : "1x"
}, },
{ {
"filename" : "common_left_icon_me@2x.png", "filename" : "右上角@2x.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "2x" "scale" : "2x"
}, },
{ {
"filename" : "common_left_icon_me@3x.png", "filename" : "右上角@3x.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "3x" "scale" : "3x"
} }
......
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "quxiao.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "形状@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "形状@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
//
// CRMemberIAPViewController.swift
// CallRecording
//
// Created by Mazy on 2020/7/14.
// Copyright © 2020 Mazy. All rights reserved.
//
import UIKit
enum CallRecorderVipType: String {
case vipWeekly = "call_recorder_vip_weekly"
case vipQuarterly = "call_recorder_vip_quarterly"
case vipYearly = "call_recorder_vip_yearly"
case vipLifetime = "call_recorder_vip_lifetime"
}
class CRMemberIAPViewController: UIViewController {
@IBOutlet weak var checkViewOne: UIImageView!
@IBOutlet weak var checkViewTwo: UIImageView!
@IBOutlet weak var checkViewThree: UIImageView!
@IBOutlet weak var subTitleALabel: UILabel!
@IBOutlet weak var mainTitleALabel: UILabel!
@IBOutlet weak var subTitleBLabel: UILabel!
@IBOutlet weak var mainTitleBLabel: UILabel!
@IBOutlet weak var subTitleCLabel: UILabel!
@IBOutlet weak var mainTitleCLabel: UILabel!
@IBOutlet weak var continueButton: UIButton!
@IBOutlet weak var weekContentView: UIView!
@IBOutlet weak var yearContentView: UIView!
private var pruducts: [Any] = []
private var currentVipType: CallRecorderVipType = .vipYearly
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
getGoodsList()
continueButton.animationHeartbeat(repeatCount: 100)
let tempButton = UIButton()
tempButton.tag = 1002
memberTypeSelectAction(tempButton)
self.weekContentView.layer.borderColor = UIColor.white.withAlphaComponent(0.5).cgColor
}
private func getGoodsList() {
// CMNetworkManager.shared.getRequest(withPath: .getIPAPayConfig) { (json, error) in
// guard error == nil else { return }
// let goodsList = json["result"]["data"]["goodsList"].arrayValue.map({ CRIAPProductModel(json: $0) })
//
// if let lifePru = goodsList.filter({ $0.productId.contains("week") }).first {
// self.subTitleALabel.text = lifePru.name
// self.mainTitleALabel.text = lifePru.payDesc
// }
//
// if let quarterPru = goodsList.filter({ $0.productId.contains("quarter") }).first {
// self.subTitleBLabel.text = quarterPru.name
// self.mainTitleBLabel.text = quarterPru.payDesc
// }
// if let weekPru = goodsList.filter({ $0.productId.contains("year") }).first {
// self.subTitleCLabel.text = weekPru.name
// self.mainTitleCLabel.text = weekPru.payDesc
// }
// self.pruducts = goodsList
//
// }
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(true, animated: true)
}
@IBAction func memberTypeSelectAction(_ sender: UIButton) {
switch sender.tag {
case 1000:
checkViewOne.isHidden = false
checkViewTwo.isHidden = true
checkViewThree.isHidden = true
currentVipType = .vipWeekly
case 1001:
checkViewOne.isHidden = true
checkViewTwo.isHidden = false
checkViewThree.isHidden = true
currentVipType = .vipQuarterly
case 1002:
checkViewOne.isHidden = true
checkViewTwo.isHidden = true
checkViewThree.isHidden = false
currentVipType = .vipYearly
default:
break
}
udpateContentUI()
}
private func udpateContentUI() {
let normalColor = UIColor.white
let normalTextColor = UIColor.white.withAlphaComponent(0.9)
let grayColor = UIColor.white.withAlphaComponent(0.5)
switch currentVipType {
case .vipWeekly:
self.subTitleALabel.textColor = normalColor
self.mainTitleALabel.textColor = normalTextColor
self.subTitleBLabel.textColor = grayColor
self.mainTitleBLabel.textColor = grayColor
self.subTitleCLabel.textColor = grayColor
self.mainTitleCLabel.textColor = grayColor
self.yearContentView.layer.borderColor = grayColor.cgColor
self.weekContentView.layer.borderColor = normalColor.cgColor
case .vipQuarterly:
self.subTitleALabel.textColor = grayColor
self.mainTitleALabel.textColor = grayColor
self.subTitleBLabel.textColor = normalColor
self.mainTitleBLabel.textColor = normalColor
self.subTitleCLabel.textColor = grayColor
self.mainTitleCLabel.textColor = grayColor
case .vipYearly:
self.subTitleALabel.textColor = grayColor
self.mainTitleALabel.textColor = grayColor
self.subTitleBLabel.textColor = grayColor
self.mainTitleBLabel.textColor = grayColor
self.subTitleCLabel.textColor = normalColor
self.mainTitleCLabel.textColor = normalTextColor
self.weekContentView.layer.borderColor = grayColor.cgColor
self.yearContentView.layer.borderColor = normalColor.cgColor
default:
break
}
}
@IBAction func dismissAction() {
self.dismiss(animated: true, completion: nil)
}
@IBAction func userTermsAction() {
let webVc = SHWebViewController()
webVc.title = "使用条款"
// webVc.url = SHUserAccountManager.shared.h5_url["user"].stringValue
self.navigationController?.pushViewController(webVc, animated: true)
}
@IBAction func privacyPolicyAction() {
let webVc = SHWebViewController()
webVc.title = "隐私政策"
// webVc.url = SHUserAccountManager.shared.h5_url["privacy"].stringValue
self.navigationController?.pushViewController(webVc, animated: true)
}
// 继续付款
@IBAction func continueAction(_ sender: UIButton) {
// var productId = currentVipType.rawValue
//
// switch currentVipType {
// case .vipWeekly:
// productId = pruducts.filter({ $0.productId.contains("week") }).first?.productId ?? currentVipType.rawValue
// case .vipQuarterly:
// productId = pruducts.filter({ $0.productId.contains("quarter") }).first?.productId ?? currentVipType.rawValue
// case .vipYearly:
// productId = pruducts.filter({ $0.productId.contains("year") }).first?.productId ?? currentVipType.rawValue
// case .vipLifetime:
// productId = pruducts.filter({ $0.productId.contains("life") }).first?.productId ?? currentVipType.rawValue
// }
// CRPurchaseManager.purchaseWithProductId(productId: productId, inView: self.view, success: {
// SHUserAccountManager.shared.getUserInfo({ (model) in
// self.dismiss(animated: true, completion: nil)
// }, failure: {
// self.dismiss(animated: true, completion: nil)
// })
// }, faliure: {
//
// })
}
// 恢复购买
@IBAction func restoreAction(_ sender: UIButton) {
// CRPurchaseManager.restorePurchases(success: {
// SHUserAccountManager.shared.getUserInfo({ (model) in
// self.navigationController?.dismiss(animated: true, completion: nil)
// }, failure: {
// self.navigationController?.dismiss(animated: true, completion: nil)
// })
// }, toView: self.view)
}
}
...@@ -40,6 +40,14 @@ class SHBaseViewController: UIViewController { ...@@ -40,6 +40,14 @@ class SHBaseViewController: UIViewController {
self.navigationController?.popViewController(animated: true) self.navigationController?.popViewController(animated: true)
} }
@objc public func goGoods(){
let goodsVC = UIStoryboard.init(name: "Goods", bundle: nil).instantiateViewController(withIdentifier: "SHGoodsViewController") as! SHGoodsViewController
let nav = SHBaseNavigationController(rootViewController: goodsVC)
nav.modalPresentationStyle = .fullScreen
self.present(nav, animated: true, completion: nil)
}
deinit { deinit {
logWarning("\(#file) deinit") logWarning("\(#file) deinit")
} }
......
//
// UILabel+FontAppearance.h
// Dolphins
//
// Created by 明津李 on 2020/6/10.
// Copyright © 2020 Company. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UILabel(FontAppearance)
@property(nonatomic, copy) UIFont * appearanceFont;
@end
NS_ASSUME_NONNULL_END
//
// UILabel+FontAppearance.m
// Dolphins
//
// Created by 明津李 on 2020/6/10.
// Copyright © 2020 Company. All rights reserved.
//
#import "UILabel+FontAppearance.h"
@implementation UILabel(FontAppearance)
- (void)setAppearanceFont:(UIFont *)font {
if (font){
[self setFont:font];
}
}
- (UIFont *)appearanceFont {
return self.font;
}
@end
//
// UITextField+LimitLength.h
// TextLengthLimitDemo
//
// Created by Su XinDe on 13-4-8.
// Copyright (c) 2013年 Su XinDe. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UITextField (LimitLength)
- (void)limitTextLength:(int)length;
@end
//
// UITextField+LimitLength.m
// TextLengthLimitDemo
//
// Created by Su XinDe on 13-4-8.
// Copyright (c) 2013年 Su XinDe. All rights reserved.
//
#import "UITextField+LimitLength.h"
#import <objc/objc.h>
#import <objc/runtime.h>
@implementation UITextField (LimitLength)
static NSString *kLimitTextLengthKey = @"kLimitTextLengthKey";
- (void)limitTextLength:(int)length
{
objc_setAssociatedObject(self, (__bridge const void *)(kLimitTextLengthKey), [NSNumber numberWithInt:length], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
[self addTarget:self action:@selector(textFieldTextLengthLimit:) forControlEvents:UIControlEventEditingChanged];
}
- (void)textFieldTextLengthLimit:(id)sender
{
NSNumber *lengthNumber = objc_getAssociatedObject(self, (__bridge const void *)(kLimitTextLengthKey));
int length = [lengthNumber intValue];
if(self.text.length > length){
self.text = [self.text substringToIndex:length];
}
}
@end
This diff is collapsed.
//
// SHGoodsViewController.swift
// ShorthandMaster
//
// Created by 明津李 on 2020/9/1.
// Copyright © 2020 明津李. All rights reserved.
//
import UIKit
class SHGoodsViewController: SHBaseViewController {
@IBOutlet weak var yearStoreLab: UILabel!
@IBOutlet weak var yearStoreBtn: UIButton!
@IBOutlet weak var yearStoreBtnBgView: UIView!
private var pruducts: [SHAPProductModel] = []
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.setNavigationBarHidden(true, animated: true)
}
override func setupUI() {
view.layoutIfNeeded()
view.layoutSubviews()
yearStoreBtnBgView.layer.cornerRadius = yearStoreBtnBgView.frame.size.height/2
yearStoreBtn.layer.cornerRadius = yearStoreBtn.frame.size.height/2
}
func getDataSource(){
CMNetworkManager.shared.getRequest(withPath: .getIPAPayConfig) { (json, error) in
guard error == nil else { return }
let goodsList = json["result"]["data"]["goodsList"].arrayValue.map({ SHAPProductModel(json: $0) })
self.pruducts = goodsList
if let yearVip = goodsList.filter({ $0.productId.contains("year") }).first {
self.yearStoreLab.text = yearVip.name
}
}
}
@objc @IBAction func cancelBtnClick(_ sender: UIButton){
self.navigationController?.dismiss(animated: true, completion: nil)
}
@objc @IBAction func confirmBtnClick(_ sender: UIButton){
let productId = pruducts.filter({ $0.productId.contains("year") }).first?.productId ?? "com.ShorthandMaster.www.subscription.yearly"
SHStoreManager.purchaseWithProductId(productId: productId, inView: self.view, success: {
SHUserAccountManager.shared.getUserInfo({ (model) in
self.dismiss(animated: true, completion: nil)
}, failure: {
self.dismiss(animated: true, completion: nil)
})
}, faliure: { errString in
})
}
@objc @IBAction func bottomBtnClick(_ sender: UIButton){
switch sender.tag {
case 100:
let webVc = SHWebViewController()
webVc.title = "使用条款"
webVc.url = SHUserAccountManager.shared.h5_url["user"].stringValue
self.navigationController?.pushViewController(webVc, animated: true)
break
case 101:
SHStoreManager.restorePurchases(success: {
SHUserAccountManager.shared.getUserInfo({ (model) in
self.navigationController?.dismiss(animated: true, completion: nil)
}, failure: {
self.navigationController?.dismiss(animated: true, completion: nil)
})
}, toView: self.view)
break
case 102:
let webVc = SHWebViewController()
webVc.title = "隐私政策"
webVc.url = SHUserAccountManager.shared.h5_url["privacy"].stringValue
self.navigationController?.pushViewController(webVc, animated: true)
break
default:
break
}
}
}
...@@ -21,15 +21,15 @@ ...@@ -21,15 +21,15 @@
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
<true/> <true/>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key> <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>3333</string> <string>App需要您开启定位权限,命名您的文件名称</string>
<key>NSLocationAlwaysUsageDescription</key> <key>NSLocationAlwaysUsageDescription</key>
<string>6666</string> <string>App需要您开启定位权限,命名您的文件名称</string>
<key>NSLocationUsageDescription</key> <key>NSLocationUsageDescription</key>
<string>44444</string> <string>App需要您开启定位权限,命名您的文件名称</string>
<key>NSLocationWhenInUseUsageDescription</key> <key>NSLocationWhenInUseUsageDescription</key>
<string>55555</string> <string>App需要您开启定位权限,命名您的文件名称</string>
<key>NSMicrophoneUsageDescription</key> <key>NSMicrophoneUsageDescription</key>
<string>App需要访问麦克风,进行录音</string> <string>App需要访问麦克风,进行录音并保存</string>
<key>NSSpeechRecognitionUsageDescription</key> <key>NSSpeechRecognitionUsageDescription</key>
<string>XXXXXXX</string> <string>XXXXXXX</string>
<key>UIBackgroundModes</key> <key>UIBackgroundModes</key>
......
//
// UIAlertController+NSObjct.h
// poinner
//
// Created by cqh on 2016/12/21.
// Copyright © 2016年 QianEn payment technology co., LTD. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef void(^cancelBlock)(void);
typedef void(^confirmBlock)(id);
typedef void(^finishBlock)(void);
@interface AlertControllerTool : NSObject
+ (instancetype)manager;
+ (void)alertControllerWithTitle:(NSString *)tilte message:(NSString *)message cancelTitle:(NSString *)cancelTitle cancelBlock:(cancelBlock)cancelBlock finishBlock:(finishBlock)finishBlock;
+ (void)alertControllerWithTitle:(NSString *)tilte message:(NSString *)message view:(UIView *)currentView cancelTitle:(NSString *)cancelTitle cancelBlock:(cancelBlock)cancelBlock finishBlock:(finishBlock)finishBlock;
+ (void)alertControllerWithTitle:(NSString *)tilte message:(NSString *)message cancelTitle:(NSString *)cancelTitle cancelBlock:(cancelBlock)cancelBlock confirm:(NSString *)confirmTitle confirmBlock:(confirmBlock)confirmBlock finishBlock:(finishBlock)finishBlock;
+ (void)alertControllerWithTitle:(NSString *)tilte message:(NSString *)message view:(UIView *)currentView cancelTitle:(NSString *)cancelTitle cancelBlock:(cancelBlock)cancelBlock confirm:(NSString *)confirmTitle confirmBlock:(confirmBlock)confirmBlock finishBlock:(finishBlock)finishBlock;
+ (void)alertControllerWithTitle:(NSString *)tilte message:(NSString *)message alignment:(NSTextAlignment)alignment cancelTitle:(NSString *)cancelTitle cancelBlock:(cancelBlock)cancelBlock confirm:(NSString *)confirmTitle confirmBlock:(confirmBlock)confirmBlock finishBlock:(finishBlock)finishBlock;
//- (void)alertControllerWithPhoto:(NSString *)imageStr finishBlock:(finishBlock)finishBlock;
+ (UIViewController *)getCurrentVC;
+ (void)alertControllerWithTitle:(NSString *)tilte message:(NSString *)message textField:(NSString *)placeholder cancelTitle:(NSString *)cancelTitle cancelBlock:(cancelBlock)cancelBlock confirm:(NSString *)confirmTitle confirmBlock:(confirmBlock)confirmBlock finishBlock:(finishBlock)finishBlock;
@end
This diff is collapsed.
//
// SHMemberUpgradeAlertView.h
// Dolphins
//
// Created by 明津李 on 2020/6/19.
// Copyright © 2020 Company. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface SHMemberUpgradeAlertView : UIView
@property (nonatomic, copy) void(^callBack)(void);
@end
NS_ASSUME_NONNULL_END
//
// SHMemberUpgradeAlertView.m
// Dolphins
//
// Created by 明津李 on 2020/6/19.
// Copyright © 2020 Company. All rights reserved.
//
#import "SHMemberUpgradeAlertView.h"
@interface SHMemberUpgradeAlertView (){
UIView * bgview;
}
@end
@implementation SHMemberUpgradeAlertView
- (instancetype)init{
if (self = [super initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]) {
[self setUI];
}
return self;
}
- (void)setUI{
self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.0];
bgview = [[UIView alloc] initWithFrame:CGRectMake(0, KScreenHeight, KScaleWidth(188), KScaleWidth(335))];
bgview.center = CGPointMake(KScreenWidth/2, KScreenHeight/2);
bgview.backgroundColor = kColorWithRGB(247, 247, 247);
bgview.layer.cornerRadius = KScaleWidth(8);
bgview.layer.masksToBounds = YES;
[self addSubview:bgview];
[bgview mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.mas_bottom);
make.centerX.equalTo(self);
make.height.mas_equalTo(KScaleWidth(188));
make.width.mas_equalTo(KScaleWidth(335));
}];
UIButton * titleBtn = [[UIButton alloc] init];
[titleBtn setImage:[UIImage imageNamed:@"upgrade_sign"] forState:UIControlStateNormal];
titleBtn.titleLabel.font = [UIFont systemFontOfSize:KFont(16)];
[titleBtn setTitle:@" 提示" forState:UIControlStateNormal];
[titleBtn setTitleColor:kColorWithRGB(34, 34, 34) forState:UIControlStateNormal];
[bgview addSubview:titleBtn];
[titleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(bgview);
make.top.equalTo(bgview).mas_offset(KScaleWidth(15));
make.size.mas_offset(CGSizeMake(KScaleWidth(200), KScaleWidth(24)));
}];
UILabel * titleLabel = [[UILabel alloc] init];
titleLabel.text = @"实时转写免费时长已用完,购买后可继续使用";
titleLabel.textColor = kColorWithRGB(34, 34, 34);
titleLabel.font = [UIFont systemFontOfSize:KFont(14)];
titleLabel.textAlignment = NSTextAlignmentCenter;
titleLabel.numberOfLines = 0;
titleLabel.lineBreakMode = NSLineBreakByCharWrapping;
[bgview addSubview:titleLabel];
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(titleBtn.mas_bottom).mas_offset(KScaleWidth(20));
make.centerX.equalTo(bgview);
make.size.mas_offset(CGSizeMake(KScaleWidth(280), KScaleWidth(14)));
}];
UILabel * titleLabel2 = [[UILabel alloc] init];
titleLabel2.text = @"目前剩余转写时长00:00 剩余转写次数:0";
titleLabel2.textColor = kColorWithRGB(34, 34, 34);
titleLabel2.font = [UIFont systemFontOfSize:KFont(14)];
titleLabel2.textAlignment = NSTextAlignmentCenter;
titleLabel2.numberOfLines = 0;
titleLabel2.lineBreakMode = NSLineBreakByCharWrapping;
[bgview addSubview:titleLabel2];
[titleLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(titleLabel.mas_bottom).mas_offset(KScaleWidth(10));
make.centerX.equalTo(bgview);
make.size.mas_offset(CGSizeMake(KScaleWidth(280), KScaleWidth(14)));
}];
UIButton * confirmBtn = [[UIButton alloc] init];
[confirmBtn setTitle:@"现在升级" forState:UIControlStateNormal];
[confirmBtn setTitle:@"现在升级" forState:UIControlStateSelected];
[confirmBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[confirmBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
confirmBtn.backgroundColor = kColorWithRGB(255, 105, 110);
confirmBtn.titleLabel.font = [UIFont systemFontOfSize:KFont(16)];
[confirmBtn addTarget:self action:@selector(cancelBtnClick) forControlEvents:UIControlEventTouchUpInside];
confirmBtn.layer.cornerRadius = KScaleWidth(6);
[bgview addSubview:confirmBtn];
[confirmBtn mas_updateConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(bgview.mas_bottom).mas_offset(-KScaleWidth(20));
make.centerX.equalTo(bgview);
make.height.mas_equalTo(KScaleWidth(48));
make.width.mas_equalTo(KScaleWidth(279));
}];
UIButton * cancelBtn = [[UIButton alloc] init];
[cancelBtn setImage:[UIImage imageNamed:@"upgrade_cancel"] forState:UIControlStateNormal];
[cancelBtn addTarget:self action:@selector(confirmBtnClick) forControlEvents:UIControlEventTouchUpInside];
[bgview addSubview:cancelBtn];
[cancelBtn mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(bgview);
make.right.equalTo(bgview);
make.height.mas_equalTo(44);
make.width.mas_equalTo(44);
}];
[self startAnimation];
}
- (void)confirmBtnClick{
[self endAnimation:YES];
}
- (void)cancelBtnClick{
[self endAnimation:NO];
if (self.callBack) {
self.callBack();
}
}
- (void)startAnimation{
[self setNeedsUpdateConstraints];
[UIView animateWithDuration:0.25f animations:^{
self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:.4];
[self->bgview mas_updateConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self);
}];
}];
}
- (void)endAnimation:(BOOL)block{
[self setNeedsUpdateConstraints];
[UIView animateWithDuration:.25f animations:^{
self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:.0];
[self->bgview mas_updateConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.frame.size.height-200);
}];
[self layoutIfNeeded];
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
}
@end
...@@ -15,7 +15,7 @@ class SHRecordListCell: UITableViewCell { ...@@ -15,7 +15,7 @@ class SHRecordListCell: UITableViewCell {
set{ set{
_model = newValue _model = newValue
addressLab?.text = newValue.address.length > 0 ? newValue.address : newValue.pathFile addressLab?.text = newValue.rename.length > 0 ? newValue.rename : newValue.pathFile
timeLab?.text = newValue.time.format("yyyy-MM-dd HH:mm") timeLab?.text = newValue.time.format("yyyy-MM-dd HH:mm")
duringLab?.text = self.countSecond(newValue.during) duringLab?.text = self.countSecond(newValue.during)
} }
......
...@@ -25,19 +25,39 @@ class SHRecordListViewController: SHBaseViewController { ...@@ -25,19 +25,39 @@ class SHRecordListViewController: SHBaseViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(image: UIImage.init(named: "record_nav_user"), style: .plain, target: self, action: #selector(userCilck)) let leftImage = UIImage.init(named: "record_nav_user")?.withRenderingMode(.alwaysOriginal)
self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(image: leftImage, style: .plain, target: self, action: #selector(userCilck))
setupUI() setupUI()
SHCloudManager.shared.cheakAccountStatus { (result) in
if result == false{
AlertControllerTool.alertController(withTitle: "iCoiud同步", message: "iCloud云端“速记大师”已关闭,启用iCloud云端“速记大师”将允许您在所有设备上访问和同步录音", cancelTitle: "取消", cancel: {
}, confirm: "启用", confirmBlock: { message in
let url = URL.init(string: UIApplication.openSettingsURLString)
if UIApplication.shared.canOpenURL(url!) {
if #available(iOS 11.0, *) {
UIApplication.shared.open(url!, options: [:], completionHandler: nil)
}else{
UIApplication.shared.openURL(url!)
}
}
}, finish: nil)
}
}
} }
func prepareDateSource(){ func prepareDateSource(){
dataSources = [] dataSources = []
let list = CRUserDefaults.recordList if let list = CRUserDefaults.recordList {
for dic in list ?? []{ for dic in list.reversed(){
let model = SHRecordModel() let model = SHRecordModel()
model.setValuesForKeys(dic) model.setValuesForKeys(dic)
if model.delete == false{ if model.delete == false{
dataSources.append(model) dataSources.append(model)
}
} }
} }
...@@ -97,6 +117,13 @@ class SHRecordListViewController: SHBaseViewController { ...@@ -97,6 +117,13 @@ class SHRecordListViewController: SHBaseViewController {
} }
@IBAction func goRecord(){ @IBAction func goRecord(){
if let list = CRUserDefaults.recordList, list.count > 1{
if SHUserAccountManager.shared.isMember == false{
self.goGoods()
return
}
}
let record = UIStoryboard.init(name: "Record", bundle: nil).instantiateViewController(withIdentifier: "SHRecordViewController") as! SHRecordViewController let record = UIStoryboard.init(name: "Record", bundle: nil).instantiateViewController(withIdentifier: "SHRecordViewController") as! SHRecordViewController
self.navigationController?.pushViewController(record, animated: true) self.navigationController?.pushViewController(record, animated: true)
} }
...@@ -121,6 +148,7 @@ extension SHRecordListViewController: UITableViewDelegate, UITableViewDataSource ...@@ -121,6 +148,7 @@ extension SHRecordListViewController: UITableViewDelegate, UITableViewDataSource
} }
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let show = UIStoryboard.init(name: "Record", bundle: nil).instantiateViewController(withIdentifier: "SHRecordShowViewController") as! SHRecordShowViewController let show = UIStoryboard.init(name: "Record", bundle: nil).instantiateViewController(withIdentifier: "SHRecordShowViewController") as! SHRecordShowViewController
show.model = dataSources[indexPath.row] show.model = dataSources[indexPath.row]
self.navigationController?.pushViewController(show, animated: true) self.navigationController?.pushViewController(show, animated: true)
......
...@@ -13,6 +13,7 @@ class SHRecordModel: NSObject, NSCoding{ ...@@ -13,6 +13,7 @@ class SHRecordModel: NSObject, NSCoding{
@objc var time: Date = Date() @objc var time: Date = Date()
@objc var during: NSInteger = 0 @objc var during: NSInteger = 0
@objc var address: String = "" @objc var address: String = ""
@objc var rename: String = ""
@objc var pathFile: String = "" @objc var pathFile: String = ""
@objc var pcmPathFile: String = "" @objc var pcmPathFile: String = ""
@objc var txt: String = "" @objc var txt: String = ""
...@@ -27,7 +28,7 @@ class SHRecordModel: NSObject, NSCoding{ ...@@ -27,7 +28,7 @@ class SHRecordModel: NSObject, NSCoding{
} }
//构造方法 //构造方法
required init(time:Date=Date(), during:NSInteger=0, address:String="", pathFile:String="", pcmPathFile:String="", txt:String="", delete:Bool=false, deleteDate:Date=Date(), fileData:Data=Data()) { required init(time:Date=Date(), during:NSInteger=0, address:String="", rename:String="", pathFile:String="", pcmPathFile:String="", txt:String="", delete:Bool=false, deleteDate:Date=Date(), fileData:Data=Data()) {
self.time = time self.time = time
self.during = during self.during = during
self.address = address self.address = address
...@@ -37,6 +38,7 @@ class SHRecordModel: NSObject, NSCoding{ ...@@ -37,6 +38,7 @@ class SHRecordModel: NSObject, NSCoding{
self.delete = delete self.delete = delete
self.deleteDate = deleteDate self.deleteDate = deleteDate
self.fileData = fileData self.fileData = fileData
self.rename = rename
} }
//从object解析回来 //从object解析回来
...@@ -50,6 +52,7 @@ class SHRecordModel: NSObject, NSCoding{ ...@@ -50,6 +52,7 @@ class SHRecordModel: NSObject, NSCoding{
self.delete = decoder.decodeObject(forKey: "delete") as? Bool ?? false self.delete = decoder.decodeObject(forKey: "delete") as? Bool ?? false
self.deleteDate = (decoder.decodeObject(forKey: "deleteDate") as? Date)! self.deleteDate = (decoder.decodeObject(forKey: "deleteDate") as? Date)!
self.fileData = (decoder.decodeObject(forKey: "fileData") as? Data)! self.fileData = (decoder.decodeObject(forKey: "fileData") as? Data)!
self.rename = decoder.decodeObject(forKey: "rename") as? String ?? ""
} }
//编码成object //编码成object
...@@ -63,5 +66,6 @@ class SHRecordModel: NSObject, NSCoding{ ...@@ -63,5 +66,6 @@ class SHRecordModel: NSObject, NSCoding{
coder.encode(delete, forKey:"delete") coder.encode(delete, forKey:"delete")
coder.encode(deleteDate, forKey:"deleteDate") coder.encode(deleteDate, forKey:"deleteDate")
coder.encode(fileData, forKey:"fileData") coder.encode(fileData, forKey:"fileData")
coder.encode(rename, forKey:"rename")
} }
} }
...@@ -68,11 +68,18 @@ class SHRecordShowViewController: SHBaseViewController { ...@@ -68,11 +68,18 @@ class SHRecordShowViewController: SHBaseViewController {
setupUI() setupUI()
play() play()
prepareRecognition() // prepareRecognition()
} }
deinit { deinit {
player?.pause() player?.stop()
playerTimer?.invalidate()
confirmCilck()
}
override func goback() {
super.goback()
player?.stop()
playerTimer?.invalidate() playerTimer?.invalidate()
confirmCilck() confirmCilck()
} }
...@@ -109,24 +116,11 @@ class SHRecordShowViewController: SHBaseViewController { ...@@ -109,24 +116,11 @@ class SHRecordShowViewController: SHBaseViewController {
override func setupUI(){ override func setupUI(){
// self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(image: UIImage.init(named: "record_nav_user"), style: .plain, target: self, action: #selector(userCilck)) // self.navigationItem.rightBarButtonItem = UIBarButtonItem.init(title: "原文", style: .plain, target: self, action: #selector(confirmCilck))
// self.navigationItem.rightBarButtonItem = UIBarButtonItem.init(image: UIImage.init(named: "record_nav_confirm"), style: .plain, target: self, action: #selector(confirmCilck))
self.navigationItem.rightBarButtonItem = UIBarButtonItem.init(title: "原文", style: .plain, target: self, action: #selector(confirmCilck))
let titleLab = UILabel()
titleLab.frame = CGRect.init(x: 0, y: 0, width: 200, height: 44)
titleLab.text = Date().format("yyyy年MM月dd日")
titleLab.textColor = UIColor.init(r: 17, g: 17, b: 17)
titleLab.font = UIFont.systemFont(ofSize: 16)
titleLab.textAlignment = .center
titleLab.adjustsFontSizeToFitWidth = true
self.navigationItem.titleView = titleLab self.setNavTitle(model!.rename)
// recordTextView.attributedText = self.textView_text(model!.txt) recordTextView?.attributedText = self.textView_text(model!.txt)
recordTextView?.attributedText = self.textView_text("")
recordTextView?.textContainerInset = UIEdgeInsets.init(top: 20, left: 20, bottom: 20, right: 30) recordTextView?.textContainerInset = UIEdgeInsets.init(top: 20, left: 20, bottom: 20, right: 30)
recordTextView?.isEditable = false recordTextView?.isEditable = false
...@@ -144,6 +138,41 @@ class SHRecordShowViewController: SHBaseViewController { ...@@ -144,6 +138,41 @@ class SHRecordShowViewController: SHBaseViewController {
progress.addTarget(self, action: #selector(sliderPlayerPlay(_:)), for: .touchUpInside) progress.addTarget(self, action: #selector(sliderPlayerPlay(_:)), for: .touchUpInside)
} }
func setNavTitle(_ title:String){
let titleBtn = UIButton()
titleBtn.frame = CGRect.init(x: 0, y: 0, width: 200, height: 44)
titleBtn.setTitle(title, for: .normal)
titleBtn.setTitleColor(UIColor.init(r: 17, g: 17, b: 17), for: .normal)
titleBtn.titleLabel?.font = UIFont.systemFont(ofSize: 16)
titleBtn.titleLabel?.textAlignment = .center
titleBtn.titleLabel?.adjustsFontSizeToFitWidth = true
titleBtn.addTarget(self, action: #selector(remaneBtnClick), for: .touchUpInside)
self.navigationItem.titleView = titleBtn
}
@objc func remaneBtnClick(){
AlertControllerTool.alertController(withTitle: "文件重命名", message: "", textField: "请输入新文件名", cancelTitle: "取消", cancel: {
}, confirm: "确认", confirmBlock: { message in
if let rename:String = message as? String {
self.model!.rename = rename
self.setNavTitle(self.model!.rename)
var list = CRUserDefaults.recordList
for (index, dic) in list!.enumerated(){
if dic["pathFile"] as! String == self.model!.pathFile{
var subDic = dic
subDic["rename"] = rename
list![index] = subDic
break
}
}
CRUserDefaults.recordList = list
}
}, finish: nil)
}
@objc func sliderPlayerPause(_ sender:UISlider){ @objc func sliderPlayerPause(_ sender:UISlider){
self.recorderBtn.isSelected = true self.recorderBtn.isSelected = true
player?.pause() player?.pause()
...@@ -239,11 +268,11 @@ class SHRecordShowViewController: SHBaseViewController { ...@@ -239,11 +268,11 @@ class SHRecordShowViewController: SHBaseViewController {
@objc fileprivate func generatePDF() { @objc fileprivate func generatePDF() {
do { do {
let range: Range = model!.pathFile.range(of: "/record.wav")! let range: Range = model!.pathFile.range(of: "/record.mp3")!
let location: Int = model!.pathFile.distance(from: model!.pathFile.startIndex, to: range.lowerBound) let location: Int = model!.pathFile.distance(from: model!.pathFile.startIndex, to: range.lowerBound)
let subStr = model!.pathFile.prefix(location) let subStr = model!.pathFile.prefix(location)
let documentsFile = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first)!+subStr+"/\(subStr).pdf" let documentsFile = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first)!+subStr+"/\(model!.rename).pdf"
try PDFGenerator.generate(self.recordTextView!, to: documentsFile) try PDFGenerator.generate(self.recordTextView!, to: documentsFile)
//此三方会把传入控件约束移除 需重新添加 //此三方会把传入控件约束移除 需重新添加
...@@ -274,6 +303,8 @@ class SHRecordShowViewController: SHBaseViewController { ...@@ -274,6 +303,8 @@ class SHRecordShowViewController: SHBaseViewController {
@objc fileprivate func generateWav() { @objc fileprivate func generateWav() {
do{ do{
// let manager = FileManager.default
// manager.copyItem(atPath: <#T##String#>, toPath: <#T##String#>)
let documentsFile_wav = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first)!.appending(model!.pathFile) let documentsFile_wav = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first)!.appending(model!.pathFile)
let fileURL_wav = URL.init(fileURLWithPath: documentsFile_wav) let fileURL_wav = URL.init(fileURLWithPath: documentsFile_wav)
let data_wav = try Data.init(contentsOf: fileURL_wav) let data_wav = try Data.init(contentsOf: fileURL_wav)
......
...@@ -98,10 +98,6 @@ class SHRecordViewController: SHBaseViewController{ ...@@ -98,10 +98,6 @@ class SHRecordViewController: SHBaseViewController{
waveView = SHRecordWaveView(frame: waveBgView.bounds, type: .line, capacity: soundMeterCount) waveView = SHRecordWaveView(frame: waveBgView.bounds, type: .line, capacity: soundMeterCount)
waveBgView.addSubview(waveView) waveBgView.addSubview(waveView)
SHLocationManager.shared.locationStatusService { (address) in
self.currentAddress = address
}
setNavTitleAndConfirmBtn() setNavTitleAndConfirmBtn()
} }
...@@ -174,7 +170,7 @@ class SHRecordViewController: SHBaseViewController{ ...@@ -174,7 +170,7 @@ class SHRecordViewController: SHBaseViewController{
if let model = currentModel { if let model = currentModel {
self.removeCurrentRecored(model) self.removeCurrentRecored(model)
} }
// saveContent() saveContent()
if save == true { if save == true {
currentTxt = "" currentTxt = ""
recognitionTaskText = [] recognitionTaskText = []
...@@ -195,11 +191,26 @@ class SHRecordViewController: SHBaseViewController{ ...@@ -195,11 +191,26 @@ class SHRecordViewController: SHBaseViewController{
@objc @IBAction func recordBtnClick(_ sender:UIButton){ @objc @IBAction func recordBtnClick(_ sender:UIButton){
// setNavTitleAndConfirmBtn() if seconds >= 3 {
let isMember = self.verityMember()
if isMember == false {
return
}
}
sender.setImage(UIImage.init(named: "record_pause"), for: .normal) sender.setImage(UIImage.init(named: "record_pause"), for: .normal)
sender.isSelected = !sender.isSelected sender.isSelected = !sender.isSelected
if sender.isSelected == true { if sender.isSelected == true {
SHLocationManager.shared.locationStatusService { (address) in
self.currentAddress = address
if self.recognitionTaskText.count == 0 {
self.recordTextView.attributedText = self.textView_text(self.currentTxt ?? "")
}else{
self.recordTextView.attributedText = self.textView_text(self.recognitionTaskText.first! + "\n" + (self.currentTxt ?? ""))
}
}
self.view.sendSubviewToBack(maskView) self.view.sendSubviewToBack(maskView)
recorder?.record() recorder?.record()
recorder_mp3.start() recorder_mp3.start()
...@@ -223,6 +234,34 @@ class SHRecordViewController: SHBaseViewController{ ...@@ -223,6 +234,34 @@ class SHRecordViewController: SHBaseViewController{
} }
} }
func verityMember()->Bool{
if SHUserAccountManager.shared.isMember == false{
recorderBtn.isSelected = false
recorder?.pause()
recorder_mp3.pause()
start = false
recognitionTask?.cancel()
speechStop()
timerInvalidate()
self.showMemberAlert()
}
return SHUserAccountManager.shared.isMember
}
func showMemberAlert(){
let alert = SHMemberUpgradeAlertView.init()
self.view.window?.addSubview(alert)
alert.callBack = {
self.goGoods()
}
}
private func getRecorder() -> AVAudioRecorder?{ private func getRecorder() -> AVAudioRecorder?{
// setting : 录音的设置项 // setting : 录音的设置项
// 录音参数设置(不需要掌握, 一些固定的配置) // 录音参数设置(不需要掌握, 一些固定的配置)
...@@ -250,7 +289,6 @@ class SHRecordViewController: SHBaseViewController{ ...@@ -250,7 +289,6 @@ class SHRecordViewController: SHBaseViewController{
} }
} }
private func configPathFile(){ private func configPathFile(){
let fileManager = FileManager.default let fileManager = FileManager.default
...@@ -405,12 +443,13 @@ class SHRecordViewController: SHBaseViewController{ ...@@ -405,12 +443,13 @@ class SHRecordViewController: SHBaseViewController{
let model = SHRecordModel() let model = SHRecordModel()
model.time = Date() model.time = Date()
model.address = currentAddress ?? "" model.address = currentAddress ?? ""
model.rename = currentAddress ?? ""
model.txt = recognitionTaskText.first ?? (self.currentTxt ?? "") model.txt = recognitionTaskText.first ?? (self.currentTxt ?? "")
model.pathFile = mp3_file_path! model.pathFile = mp3_file_path!
model.pcmPathFile = pcm_file_path! model.pcmPathFile = pcm_file_path!
model.during = seconds model.during = seconds
let dic = ["time":model.time, "address":model.address, "txt":model.txt, "pathFile":model.pathFile, "during":model.during, "delete":model.delete] as [String : Any] let dic = ["time":model.time, "address":model.address, "txt":model.txt, "pathFile":model.pathFile, "during":model.during, "delete":model.delete, "rename":model.rename] as [String : Any]
var list = CRUserDefaults.recordList var list = CRUserDefaults.recordList
if list == nil { if list == nil {
...@@ -463,7 +502,6 @@ class SHRecordViewController: SHBaseViewController{ ...@@ -463,7 +502,6 @@ class SHRecordViewController: SHBaseViewController{
// } catch { // } catch {
// //
// } // }
} }
func removeCurrentRecored(_ model:SHRecordModel){ func removeCurrentRecored(_ model:SHRecordModel){
...@@ -508,6 +546,11 @@ extension SHRecordViewController{ ...@@ -508,6 +546,11 @@ extension SHRecordViewController{
let second = (seconds)%60; let second = (seconds)%60;
let timeString = String(format: "%02lu:%02lu:%02lu", hours, minutes, second) let timeString = String(format: "%02lu:%02lu:%02lu", hours, minutes, second)
secondsLabel.text = timeString secondsLabel.text = timeString
saveContent()
if seconds == 3 {
_ = self.verityMember()
}
} }
@objc private func updateMeters() { @objc private func updateMeters() {
...@@ -583,7 +626,7 @@ extension SHRecordViewController{ ...@@ -583,7 +626,7 @@ extension SHRecordViewController{
private func generatePDF() { private func generatePDF() {
do { do {
let range: Range = currentModel!.pathFile.range(of: "/record.wav")! let range: Range = currentModel!.pathFile.range(of: "/record.map")!
let location: Int = currentModel!.pathFile.distance(from: currentModel!.pathFile.startIndex, to: range.lowerBound) let location: Int = currentModel!.pathFile.distance(from: currentModel!.pathFile.startIndex, to: range.lowerBound)
let subStr = currentModel!.pathFile.prefix(location) let subStr = currentModel!.pathFile.prefix(location)
......
...@@ -24,28 +24,28 @@ class SHCloudManager: NSObject { ...@@ -24,28 +24,28 @@ class SHCloudManager: NSObject {
typealias handler = ((Bool) -> ()) typealias handler = ((Bool) -> ())
var statusHandler: handler? var statusHandler: handler?
// func cheakAccountStatus(_ handler:@escaping handler){ func cheakAccountStatus(_ handler:@escaping handler){
//
// statusHandler = handler statusHandler = handler
//
// let container = CKContainer.default() let container = CKContainer.default()
// container.accountStatus { (status, statusError) in container.accountStatus { (status, statusError) in
//
// if let error = statusError { if let error = statusError {
// self.statusHandler?(false) self.statusHandler?(false)
// print("\(error.localizedDescription)") print("\(error.localizedDescription)")
// }else{ }else{
// switch status { switch status {
// case .available: case .available:
// self.statusHandler?(true) self.statusHandler?(true)
// break; break;
// default: default:
// self.statusHandler?(false) self.statusHandler?(false)
// break; break;
// } }
// } }
// } }
// } }
func getAllRecordDataSource(){ func getAllRecordDataSource(){
......
...@@ -34,6 +34,8 @@ import SwiftyJSON ...@@ -34,6 +34,8 @@ import SwiftyJSON
@objc var isMember: Bool { @objc var isMember: Bool {
return true
let dateFormatter = DateFormatter() let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_CN") dateFormatter.locale = Locale(identifier: "en_CN")
dateFormatter.timeZone = TimeZone.current dateFormatter.timeZone = TimeZone.current
......
// //
// CRIAPProductModel.swift // SHAPProductModel.swift
// CallRecording //
// //
// Created by Mazy on 2020/7/16. // Created by Mazy on 2020/7/16.
// Copyright © 2020 Mazy. All rights reserved. // Copyright © 2020 . All rights reserved.
// //
import Foundation import Foundation
import SwiftyJSON import SwiftyJSON
struct CRIAPProductModel: Codable { struct SHAPProductModel: Codable {
let cash: Int let cash: Int
let days: Int let days: Int
......
...@@ -6,3 +6,5 @@ ...@@ -6,3 +6,5 @@
#import "AESCipher.h" #import "AESCipher.h"
#import "UIView+CornerRadii.h" #import "UIView+CornerRadii.h"
#import "SHMp3RecordManager.h" #import "SHMp3RecordManager.h"
#import "SHMemberUpgradeAlertView.h"
#import "AlertControllerTool.h"
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