|
@@ -10,20 +10,39 @@ Parse.serverURL = "http://web2023.fmode.cn:9999/parse"; // 设置serverURL
|
|
|
styleUrls: ['tab3.page.scss']
|
|
|
})
|
|
|
export class Tab3Page implements OnInit{
|
|
|
+ //数据定义
|
|
|
+ hasData: boolean = false;
|
|
|
+ currentTab: string = 'unpublished';
|
|
|
+ userImage: string = 'https://via.placeholder.com/150'; // 默认图片地址
|
|
|
+ // 由于Parse.User.current()是随着localStorage变化的属性
|
|
|
+ // 为了避免首次复制后用户状态变化,页面不同步,通过get方法实现实时获取
|
|
|
+ user:Parse.User|undefined
|
|
|
+
|
|
|
+ async ngOnInit() {
|
|
|
+ this.user = await Parse.User.current()
|
|
|
+ setInterval(async ()=>{
|
|
|
+ this.user = await Parse.User.current()
|
|
|
+ },1000)
|
|
|
+ this.loadCreatContentsDate()
|
|
|
+ }
|
|
|
+ logout(){
|
|
|
+ Parse.User.logOut();
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+ constructor(private router: Router) { this.checkData();}
|
|
|
+
|
|
|
+
|
|
|
cards = [
|
|
|
{ title: '我的订单', content: '查看全部', icon: 'document-text-outline' },
|
|
|
{ title: '积分中心', content: '答题赢积分', icon: 'trophy-outline' },
|
|
|
{ title: '我的勋章', content: '2枚勋章', icon: 'medal-outline' }
|
|
|
];
|
|
|
|
|
|
-
|
|
|
- currentTab: string = 'unpublished';
|
|
|
- userImage: string = 'https://via.placeholder.com/150'; // 默认图片地址
|
|
|
-
|
|
|
+
|
|
|
onFileSelected(event: Event) {
|
|
|
const inputElement = event.target as HTMLInputElement;
|
|
|
- if (inputElement.files && inputElement.files.length > 0) {
|
|
|
+ if (inputElement.files && inputElement.files.length > 0) {
|
|
|
const file = inputElement.files[0];
|
|
|
const reader = new FileReader();
|
|
|
reader.onload = () => {
|
|
@@ -32,39 +51,38 @@ export class Tab3Page implements OnInit{
|
|
|
}
|
|
|
};
|
|
|
reader.readAsDataURL(file);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
|
|
|
- // 由于Parse.User.current()是随着localStorage变化的属性
|
|
|
- // 为了避免首次复制后用户状态变化,页面不同步,通过get方法实现实时获取
|
|
|
- user:Parse.User|undefined
|
|
|
- async ngOnInit() {
|
|
|
- this.user = await Parse.User.current()
|
|
|
- setInterval(async ()=>{
|
|
|
- this.user = await Parse.User.current()
|
|
|
- },1000)
|
|
|
- this.loadPets()
|
|
|
- }
|
|
|
- logout(){
|
|
|
- Parse.User.logOut();
|
|
|
- }
|
|
|
- constructor(private router: Router) {}
|
|
|
+ //跳转到新页面
|
|
|
GoToLoginPage(){
|
|
|
this.router.navigate(['/user/login'])
|
|
|
}
|
|
|
- //跳转到新页面
|
|
|
navigateToCreatePage() {
|
|
|
this.router.navigate(['/tab3/tab3-create']);
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ //数据库CreatContents中数据调入前端页面
|
|
|
InputContentsList:Array<Parse.Object> = []
|
|
|
- async loadPets(){
|
|
|
+ async loadCreatContentsDate(){
|
|
|
let query = new Parse.Query("CreatContents");
|
|
|
let list = await query.find();
|
|
|
this.InputContentsList = list
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ //查询数据库中是否有CreatContents的数据
|
|
|
+ async checkData() {
|
|
|
+ const CreatContents = Parse.Object.extend("CreatContents");
|
|
|
+ const query = new Parse.Query(CreatContents);
|
|
|
+ const results = await query.find();
|
|
|
+
|
|
|
+ if (results.length > 0) {
|
|
|
+ this.hasData = true;
|
|
|
+ } else {
|
|
|
+ this.hasData = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|