feat(1.0.5):优化用户体验

developing
张帅 1 week ago
parent 3731591491
commit 88fbc6bde0

@ -47,6 +47,7 @@ func NewOrderService(repo order.AggregateRepository, articleRepo article.Article
priceRepo: priceRepo,
columnRepo: columnRepo,
payService: payService,
runLog: runLog,
orderRepo: orderRepo,
userRepo: userRepo,
couponRepo: couponRepo,

@ -50,9 +50,9 @@ export class AppComponent implements OnInit {
} else {
// 如果都没有token重定向到获取token的页面
console.log("需要获取token重定向到授权页面");
// window.location.href = "http://famyun.com/callback_test";
window.location.href = "http://famyun.com/callback_test";
// 生产环境使用微信授权
window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx13bd75fbedf283e5&redirect_uri=http%3A%2F%2Ffamyun.com%2Fcallback&response_type=code&scope=snsapi_base&state=123#wechat_redirect";
// window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx13bd75fbedf283e5&redirect_uri=http%3A%2F%2Ffamyun.com%2Fcallback&response_type=code&scope=snsapi_base&state=123#wechat_redirect";
}
}
});

@ -34,12 +34,13 @@ export class ArticleContentComponent implements OnInit,OnDestroy {
private cdr:ChangeDetectorRef) { }
ngOnInit() {
this.getData();
this.getUsername();
this.routerSub = this.router.events.subscribe(event => {
if (event instanceof NavigationEnd) {
if(event.url == "/home/special-column" || event.url == "/home") {
this.checkOrderOcc()
this.getUsername();
}
}
});
@ -127,10 +128,18 @@ export class ArticleContentComponent implements OnInit,OnDestroy {
}
getUsername(){
getUser().subscribe((res)=>{
this.username = res.username
this.cdr.detectChanges();
})
const token = localStorage.getItem("token")
if(token) {
getUser().subscribe((res)=>{
this.username = res.username
this.loadData()
this.cdr.detectChanges();
})
} else {
this.username = ""
this.loadData()
}
}
getNewData() {

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

@ -9,14 +9,15 @@ import {
Input
} from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import {NavigationEnd, Router} from '@angular/router';
import {ModalController, NavController, ToastController} from '@ionic/angular';
import { MineService } from '../mine.service';
import {getUser, MineService} from '../mine.service';
import {
SlidePoint,
SlideRef
} from "go-captcha-angular";
import {CaptchaModalComponent} from "../component/captcha-modal/captcha-modal.component";
import {Subscription} from "rxjs";
@Component({
selector: 'app-login',
@ -34,6 +35,7 @@ export class LoginPage implements OnInit, OnDestroy,AfterViewInit {
private timer: any;
private verifyToken: string | null = null;
private returnUrl: string | null = null;
private routerSub!: Subscription;
constructor(
private fb: FormBuilder,
@ -58,16 +60,31 @@ export class LoginPage implements OnInit, OnDestroy,AfterViewInit {
}
ngOnInit() {
this.createForm();
this.routerSub = this.router.events.subscribe(event => {
if (event instanceof NavigationEnd) {
if(event.url == "/mine/login") {
this.checkLoginStatus()
}
}
});
}
checkLoginStatus() {
const t = localStorage.getItem("token")
if(t!=""){
this.navCtrl.navigateBack("/mine/login")
}
}
ngAfterViewInit() {
}
ngOnDestroy() {
this.stopCountdown() ;
if (this.routerSub) {
this.routerSub.unsubscribe();
}
}
private createForm() {
// 根据登录类型动态设置验证器
this.loginForm.get('password')?.setValidators(

Loading…
Cancel
Save