Commit 6e0740a2 cgx

睡前故事和测评添加播放量和测评数

1 个父辈 68ee5ebe
正在显示 32 个修改的文件 包含 244 行增加15 行删除
......@@ -12,6 +12,8 @@
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UILabel *descLab;
@property (nonatomic, strong) UILabel *countLab;
@property (nonatomic, strong) UIImageView *testIcon;
@property (nonatomic, strong) UILabel *testCountLab;
@property (nonatomic, strong) UIButton *startBtn;
@end
......@@ -23,6 +25,8 @@
[self.contentView addSubview:self.titleLab];
[self.contentView addSubview:self.descLab];
[self.contentView addSubview:self.countLab];
[self.contentView addSubview:self.testIcon];
[self.contentView addSubview:self.testCountLab];
[self.contentView addSubview:self.startBtn];
[self.coverIV mas_makeConstraints:^(MASConstraintMaker *make) {
......@@ -39,14 +43,10 @@
make.left.equalTo(self.titleLab);
make.right.equalTo(self.titleLab);
}];
[self.countLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.contentView);
make.left.equalTo(self.titleLab);
make.right.equalTo(self.startBtn.mas_left).offset(-10);
}];
[self.startBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.contentView);
make.right.equalTo(self.contentView).offset(-15);
make.size.mas_equalTo(CGSizeMake(96, 34));
}];
}
return self;
......@@ -58,7 +58,24 @@
[self.coverIV yy_setImageWithURL:[NSURL URLWithString:evaluateModel.cover_img] placeholder:[UIImage defaultPlaceholderWithSize:CGSizeMake(76, 90)]];
self.titleLab.text = evaluateModel.title;
self.descLab.text = evaluateModel.cover_desc;
self.countLab.text = [NSString stringWithFormat:@"%@道题", evaluateModel.total_subjects];
self.countLab.text = evaluateModel.total_subjects;
self.testCountLab.text = [NSString stringWithFormat:@"%d人测过", evaluateModel.total_times];
[self.countLab mas_remakeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.contentView);
make.left.equalTo(self.titleLab);
make.width.equalTo(@([UILabel getWidthWithText:self.countLab.text font:self.countLab.font]));
}];
[self.testIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.countLab.mas_right).offset(16);
make.size.mas_equalTo(CGSizeMake(14, 14));
make.centerY.equalTo(self.countLab);
}];
[self.testCountLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.testIcon.mas_right).offset(4);
make.centerY.equalTo(self.testIcon);
make.right.equalTo(self.startBtn.mas_left).offset(-12);
}];
}
#pragma mark - lazy
......@@ -91,11 +108,26 @@
- (UILabel *)countLab {
if (!_countLab) {
_countLab = [UILabel labWithFont:SysFont(12)];
_countLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .3), DSWhite);
_countLab.dk_textColorPicker = DKColorPickerWithKey(BrandBG);
}
return _countLab;
}
- (UIImageView *)testIcon {
if (!_testIcon) {
_testIcon = [[UIImageView alloc] dk_initWithImagePicker:DKImagePickerWithNames(@"ic_shequ_ceshiliang", @"dk_ic_shequ_ceshiliang", @"ic_shequ_ceshiliang")];
}
return _testIcon;
}
- (UILabel *)testCountLab {
if (!_testCountLab) {
_testCountLab = [UILabel labWithFont:SysFont(12)];
_testCountLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .3), DSWhite);
}
return _testCountLab;
}
- (UIButton *)startBtn {
if (!_startBtn) {
_startBtn = [UIButton btnWithTitle:@"开始测试" font:BoldFont(16)];
......
......@@ -22,6 +22,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, copy) NSString *total_subjects;
/// 详情url
@property (nonatomic, copy) NSString *redirect_url;
/// 测评总次数
@property (nonatomic, assign) int total_times;
@end
NS_ASSUME_NONNULL_END
......@@ -176,6 +176,9 @@
NSString *step = self.courseType == CourseTypeSafe ? @"舒眠课程" : @"助眠音乐";
[DataStatisticsUtil event:Audio_Detail attributes:@{@"step":step, @"audio_name":model.audio_name}];
SubAudioModel *audioModel = self.subAudioArr[indexPath.row];
[SafeSleepRequestModel updateAudioPlayCountWithAudioID:audioModel.audio_id completion:^(SafeSleepRequestModel * _Nonnull requestModel) {}];
}
}
}
......
......@@ -29,7 +29,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) int is_lock;
// 音频封面图
@property (nonatomic, copy) NSString *audio_img;
// 睡眠故事音频播放次数
// 音频播放量
@property (nonatomic, assign) int play_count;
// 颜色值
@property (nonatomic, copy) NSString *day_bg_color;
......
......@@ -36,6 +36,11 @@ NS_ASSUME_NONNULL_BEGIN
/// 获取首页睡眠故事数据
/// @param completion completion
+ (NSURLSessionDataTask *)querySleepAudioStoryWithCompletion:(void (^)(SafeSleepRequestModel *requestModel, SleepStoryHomeModel * sshModel))completion;
/// 更新音频播放量接口
/// @param audioID 音频id
/// @param completion completion
+ (NSURLSessionDataTask *)updateAudioPlayCountWithAudioID:(int)audioID completion:(void (^)(SafeSleepRequestModel *requestModel))completion;
@end
NS_ASSUME_NONNULL_END
......@@ -88,4 +88,19 @@
}];
}
+ (NSURLSessionDataTask *)updateAudioPlayCountWithAudioID:(int)audioID completion:(void (^)(SafeSleepRequestModel *requestModel))completion {
NSString *api = @"update_audio_play_count";
NSString *argStr = [NSString stringWithFormat:@"mutation{%@(audio_id:%d)}", api, audioID];
SafeSleepRequestModel * requestModel = [[SafeSleepRequestModel alloc] init];
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:NO loadingInfo:nil hasFailInfo:NO success:^(NSDictionary *apiDic) {
requestModel.resCode = DSResCodeSuccess;
DSLog(@"更新音频播放量接口dataDic:%@", apiDic);
completion(requestModel);
} failure:^(id failureInfo) {
requestModel.resCode = [failureInfo[@"errorCode"] integerValue];
requestModel.errMessage = failureInfo[@"errMessage"];
completion(requestModel);
}];
}
@end
......@@ -50,6 +50,8 @@
[self presentViewController:playVC animated:YES completion:nil];
[DataStatisticsUtil event:AccessSleepStory attributes:@{@"name":audioModel.audio_name ? audioModel.audio_name : @""}];
[SafeSleepRequestModel updateAudioPlayCountWithAudioID:audioModel.audio_id completion:^(SafeSleepRequestModel * _Nonnull requestModel) {}];
}
#pragma mark - lazy
......
......@@ -13,6 +13,8 @@
@property (nonatomic, strong) UILabel *audioDescLab;
@property (nonatomic, strong) UIImageView *timeIcon;
@property (nonatomic, strong) UILabel *playTimeLab;
@property (nonatomic, strong) UIImageView *earIcon;
@property (nonatomic, strong) UILabel *listenCountLab;
@property (nonatomic, strong) UIButton *playBtn;
@end
......@@ -25,6 +27,8 @@
[self.contentView addSubview:self.audioDescLab];
[self.contentView addSubview:self.timeIcon];
[self.contentView addSubview:self.playTimeLab];
[self.contentView addSubview:self.earIcon];
[self.contentView addSubview:self.listenCountLab];
[self.contentView addSubview:self.playBtn];
[self.audioIV mas_makeConstraints:^(MASConstraintMaker *make) {
......@@ -46,14 +50,10 @@
make.size.mas_equalTo(CGSizeMake(14, 14));
make.bottom.equalTo(self.audioIV).offset(-2);
}];
[self.playTimeLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.timeIcon.mas_right).offset(8);
make.centerY.equalTo(self.timeIcon);
make.right.equalTo(self.contentView).offset(-84);
}];
[self.playBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.contentView);
make.right.equalTo(self.contentView).offset(-15);
make.size.mas_equalTo(CGSizeMake(64, 34));
}];
}
return self;
......@@ -66,6 +66,23 @@
self.audioLab.text = storyModel.audio_name;
self.audioDescLab.text = storyModel.audio_desc;
self.playTimeLab.text = storyModel.play_time;
self.listenCountLab.text = [NSString stringWithFormat:@"%d人听过", storyModel.play_count];
[self.playTimeLab mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.timeIcon.mas_right).offset(8);
make.centerY.equalTo(self.timeIcon);
make.width.equalTo(@([UILabel getWidthWithText:self.playTimeLab.text font:self.playTimeLab.font]));
}];
[self.earIcon mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.playTimeLab.mas_right).offset(16);
make.size.mas_equalTo(CGSizeMake(14, 14));
make.centerY.equalTo(self.playTimeLab);
}];
[self.listenCountLab mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.earIcon.mas_right).offset(4);
make.centerY.equalTo(self.earIcon);
make.right.equalTo(self.playBtn.mas_left).offset(-12);
}];
}
#pragma mark - lazy
......@@ -97,7 +114,7 @@
- (UIImageView *)timeIcon {
if (!_timeIcon) {
_timeIcon = [[UIImageView alloc] dk_initWithImagePicker:DKImagePickerWithNames(@"muse_time_icon", @"dk_muse_time_icon", @"muse_time_icon")];
_timeIcon = [[UIImageView alloc] dk_initWithImagePicker:DKImagePickerWithNames(@"sleep_audio_time_icon", @"dk_sleep_audio_time_icon", @"sleep_audio_time_icon")];
}
return _timeIcon;
}
......@@ -105,11 +122,26 @@
- (UILabel *)playTimeLab {
if (!_playTimeLab) {
_playTimeLab = [UILabel labWithFont:SysFont(12)];
_playTimeLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .3), DSWhite);
_playTimeLab.dk_textColorPicker = DKColorPickerWithKey(BrandBG);
}
return _playTimeLab;
}
- (UIImageView *)earIcon {
if (!_earIcon) {
_earIcon = [[UIImageView alloc] dk_initWithImagePicker:DKImagePickerWithNames(@"ic_shuiqiangushi_tongguo", @"dk_ic_shuiqiangushi_tongguo", @"ic_shuiqiangushi_tongguo")];
}
return _earIcon;
}
- (UILabel *)listenCountLab {
if (!_listenCountLab) {
_listenCountLab = [UILabel labWithFont:SysFont(12)];
_listenCountLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .3), DSWhite);
}
return _listenCountLab;
}
- (UIButton *)playBtn {
if (!_playBtn) {
_playBtn = [UIButton btnWithTitle:@"播放" font:BoldFont(16)];
......
{
"images" : [
{
"filename" : "dk_ic_shequ_ceshiliang.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_ic_shequ_ceshiliang@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_ic_shequ_ceshiliang@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_shequ_ceshiliang.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_shequ_ceshiliang@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_shequ_ceshiliang@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "dk_ic_shuiqiangushi_tongguo.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_ic_shuiqiangushi_tongguo@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_ic_shuiqiangushi_tongguo@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "dk_sleep_audio_time_icon.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_sleep_audio_time_icon@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_sleep_audio_time_icon@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_shuiqiangushi_tongguo.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_shuiqiangushi_tongguo@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_shuiqiangushi_tongguo@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sleep_audio_time_icon.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sleep_audio_time_icon@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sleep_audio_time_icon@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!