|
|
@ -34,37 +34,34 @@ export class ArticleItemComponent implements OnInit,AfterViewInit {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onUnlock() {
|
|
|
|
onUnlock() {
|
|
|
|
getUser().subscribe((res)=>{
|
|
|
|
if(this.username == "") {
|
|
|
|
if(res.username == "") {
|
|
|
|
// 未登录,显示提示框
|
|
|
|
// 未登录,显示提示框
|
|
|
|
this.alertCtrl.create({
|
|
|
|
this.alertCtrl.create({
|
|
|
|
header: '提示',
|
|
|
|
header: '提示',
|
|
|
|
message: '请先登录后再进行操作',
|
|
|
|
message: '请先登录后再进行操作',
|
|
|
|
buttons: [
|
|
|
|
buttons: [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
text: '取消',
|
|
|
|
text: '取消',
|
|
|
|
role: 'cancel'
|
|
|
|
role: 'cancel'
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
text: '去登录',
|
|
|
|
text: '去登录',
|
|
|
|
handler: () => {
|
|
|
|
handler: () => {
|
|
|
|
// 保存当前路径并跳转到登录页
|
|
|
|
// 保存当前路径并跳转到登录页
|
|
|
|
this.navCtrl.navigateForward('/mine/login', {
|
|
|
|
this.navCtrl.navigateForward('/mine/login', {
|
|
|
|
state: { returnUrl: this.router.url }
|
|
|
|
state: { returnUrl: this.router.url }
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}).then(alert => alert.present());
|
|
|
|
]
|
|
|
|
} else {
|
|
|
|
}).then(alert => alert.present());
|
|
|
|
this.homeService.getArticlePrice(this.article.eventId).subscribe((res) => {
|
|
|
|
} else {
|
|
|
|
this.navCtrl.navigateForward('/home/article-buy', {
|
|
|
|
this.homeService.getArticlePrice(this.article.eventId).subscribe((res) => {
|
|
|
|
state: {article: this.article, price: res}
|
|
|
|
this.navCtrl.navigateForward('/home/article-buy', {
|
|
|
|
});
|
|
|
|
state: {article: this.article, price: res}
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.username = res.username
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getFreeReadCount():number{
|
|
|
|
getFreeReadCount():number{
|
|
|
@ -78,58 +75,55 @@ export class ArticleItemComponent implements OnInit,AfterViewInit {
|
|
|
|
|
|
|
|
|
|
|
|
unlockArticle(event: any) {
|
|
|
|
unlockArticle(event: any) {
|
|
|
|
event.stopPropagation()
|
|
|
|
event.stopPropagation()
|
|
|
|
getUser().subscribe((res)=>{
|
|
|
|
if(this.username == "") {
|
|
|
|
if(res.username == "") {
|
|
|
|
// 未登录,显示提示框
|
|
|
|
// 未登录,显示提示框
|
|
|
|
this.alertCtrl.create({
|
|
|
|
this.alertCtrl.create({
|
|
|
|
header: '提示',
|
|
|
|
header: '提示',
|
|
|
|
message: '请先登录后再进行操作',
|
|
|
|
message: '请先登录后再进行操作',
|
|
|
|
buttons: ['确定']
|
|
|
|
buttons: ['确定']
|
|
|
|
}).then(alert => alert.present());
|
|
|
|
}).then(alert => alert.present());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.alertCtrl.create({
|
|
|
|
this.alertCtrl.create({
|
|
|
|
header: '提示',
|
|
|
|
header: '提示',
|
|
|
|
message: `您剩余${this.freeReadCount}次,确定使用1次解锁该文章吗?解锁后剩余赠送次数为${this.freeReadCount - 1}次`,
|
|
|
|
message: `您剩余${this.freeReadCount}次,确定使用1次解锁该文章吗?解锁后剩余赠送次数为${this.freeReadCount - 1}次`,
|
|
|
|
buttons: [
|
|
|
|
buttons: [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
text: '确认',
|
|
|
|
text: '确认',
|
|
|
|
role: 'cancel',
|
|
|
|
role: 'cancel',
|
|
|
|
handler: () => {
|
|
|
|
handler: () => {
|
|
|
|
this.homeService.unlockArticle({eventId: this.article.eventId} as Article).subscribe((res) => {
|
|
|
|
this.homeService.unlockArticle({eventId: this.article.eventId} as Article).subscribe((res) => {
|
|
|
|
this.toastCtrl.create({
|
|
|
|
this.toastCtrl.create({
|
|
|
|
message: '解锁成功!',
|
|
|
|
message: '解锁成功!',
|
|
|
|
duration: 2000,
|
|
|
|
duration: 2000,
|
|
|
|
color: 'success',
|
|
|
|
color: 'success',
|
|
|
|
position: 'top',
|
|
|
|
position: 'top',
|
|
|
|
cssClass: 'ion-text-center'
|
|
|
|
cssClass: 'ion-text-center'
|
|
|
|
}).then(toast => toast.present());
|
|
|
|
}).then(toast => toast.present());
|
|
|
|
this.article.unlock = true;
|
|
|
|
this.article.unlock = true;
|
|
|
|
this.article.content = res.content;
|
|
|
|
this.article.content = res.content;
|
|
|
|
this.article.stocks = res.stocks;
|
|
|
|
this.article.stocks = res.stocks;
|
|
|
|
this.freeReadCount-- ;
|
|
|
|
this.freeReadCount-- ;
|
|
|
|
this.cdr.detectChanges()
|
|
|
|
this.cdr.detectChanges()
|
|
|
|
useGiftCount()
|
|
|
|
useGiftCount()
|
|
|
|
}, error => {
|
|
|
|
}, error => {
|
|
|
|
this.toastCtrl.create({
|
|
|
|
this.toastCtrl.create({
|
|
|
|
message: '解锁失败,请稍后重试',
|
|
|
|
message: '解锁失败,请稍后重试',
|
|
|
|
duration: 2000,
|
|
|
|
duration: 2000,
|
|
|
|
color: 'danger',
|
|
|
|
color: 'danger',
|
|
|
|
position: 'top',
|
|
|
|
position: 'top',
|
|
|
|
cssClass: 'ion-text-center'
|
|
|
|
cssClass: 'ion-text-center'
|
|
|
|
}).then(toast => toast.present());
|
|
|
|
}).then(toast => toast.present());
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{text: '取消',}
|
|
|
|
{text: '取消',}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
}).then((v1) => {
|
|
|
|
}).then((v1) => {
|
|
|
|
v1.present()
|
|
|
|
v1.present()
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.username = res.username
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|