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, priceRepo: priceRepo,
columnRepo: columnRepo, columnRepo: columnRepo,
payService: payService, payService: payService,
runLog: runLog,
orderRepo: orderRepo, orderRepo: orderRepo,
userRepo: userRepo, userRepo: userRepo,
couponRepo: couponRepo, couponRepo: couponRepo,

@ -50,9 +50,9 @@ export class AppComponent implements OnInit {
} else { } else {
// 如果都没有token重定向到获取token的页面 // 如果都没有token重定向到获取token的页面
console.log("需要获取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) { } private cdr:ChangeDetectorRef) { }
ngOnInit() { ngOnInit() {
this.getData();
this.getUsername(); this.getUsername();
this.routerSub = this.router.events.subscribe(event => { this.routerSub = this.router.events.subscribe(event => {
if (event instanceof NavigationEnd) { if (event instanceof NavigationEnd) {
if(event.url == "/home/special-column" || event.url == "/home") { if(event.url == "/home/special-column" || event.url == "/home") {
this.checkOrderOcc() this.checkOrderOcc()
this.getUsername();
} }
} }
}); });
@ -127,10 +128,18 @@ export class ArticleContentComponent implements OnInit,OnDestroy {
} }
getUsername(){ getUsername(){
getUser().subscribe((res)=>{ const token = localStorage.getItem("token")
this.username = res.username if(token) {
this.cdr.detectChanges(); getUser().subscribe((res)=>{
}) this.username = res.username
this.loadData()
this.cdr.detectChanges();
})
} else {
this.username = ""
this.loadData()
}
} }
getNewData() { getNewData() {

@ -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
})
} }

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

Loading…
Cancel
Save