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(){
const token = localStorage.getItem("token")
if(token) {
getUser().subscribe((res)=>{ getUser().subscribe((res)=>{
this.username = res.username this.username = res.username
this.loadData()
this.cdr.detectChanges(); this.cdr.detectChanges();
}) })
} else {
this.username = ""
this.loadData()
}
} }
getNewData() { getNewData() {

@ -34,8 +34,7 @@ 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: '提示',
@ -63,8 +62,6 @@ export class ArticleItemComponent implements OnInit,AfterViewInit {
}); });
}) })
} }
this.username = res.username
})
} }
getFreeReadCount():number{ getFreeReadCount():number{
@ -78,8 +75,7 @@ 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: '提示',
@ -128,8 +124,6 @@ export class ArticleItemComponent implements OnInit,AfterViewInit {
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