page-publishsurvey.component.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { Component, OnInit } from '@angular/core';
  2. import { Router } from '@angular/router';
  3. import { IonHeader,IonButton, IonList, IonListHeader, IonItem,IonContent, IonIcon, IonLabel, IonCardHeader,IonCardContent, IonTitle,IonCard, IonToolbar,IonInput,IonSearchbar, IonSegment, IonSegmentButton, IonSelect, IonSelectOption } from '@ionic/angular/standalone';
  4. import { CommonModule } from '@angular/common';
  5. import { FormsModule } from '@angular/forms'; // 导入 FormsModule
  6. import { HttpClient } from '@angular/common/http';
  7. import { CloudObject } from 'src/lib/ncloud';
  8. @Component({
  9. selector: 'app-page-publishsurvey',
  10. templateUrl: './page-publishsurvey.component.html',
  11. styleUrls: ['./page-publishsurvey.component.scss'],
  12. standalone: true,
  13. imports: [
  14. IonHeader,IonToolbar,IonTitle,IonContent,IonSegment,IonSegmentButton,IonSelect,IonSelectOption,
  15. FormsModule,IonList, IonListHeader, IonItem,
  16. IonLabel,IonIcon,IonButton,IonCardContent,
  17. IonInput,IonSearchbar,IonCard,IonCardHeader,
  18. CommonModule,
  19. ]
  20. })
  21. export class PagePublishsurveyComponent implements OnInit {
  22. category: string = 'school'; // 默认类别
  23. surveyTitle: string = '';
  24. surveyLink: string = '';
  25. targetAudience: string = 'all'; // 默认面向对象
  26. societySurveyTitle: string = '';
  27. societySurveyLink: string = '';
  28. onCategoryChange() {
  29. console.log(`当前选择的类别: ${this.category}`);
  30. }
  31. publishSurvey() {
  32. console.log('发布学校问卷:');
  33. console.log(`标题: ${this.surveyTitle}`);
  34. console.log(`链接: ${this.surveyLink}`);
  35. console.log(`面向对象: ${this.targetAudience}`);
  36. // 这里可以添加逻辑将问卷发布到后端或其他处理
  37. const surveyData = {
  38. title: this.surveyTitle,
  39. link: this.surveyLink,
  40. audience: this.targetAudience,
  41. };
  42. let survey = new CloudObject("Survey");
  43. survey.set(surveyData)
  44. survey.save().then(data=>{
  45. console.log('问卷已成功发布',data);
  46. }).catch(err=>{
  47. console.error('发布问卷时出错');
  48. })
  49. }
  50. publishSocietySurvey() {
  51. console.log('发布社会问卷:');
  52. console.log(`标题: ${this.societySurveyTitle}`);
  53. console.log(`链接: ${this.societySurveyLink}`);
  54. // 这里可以添加逻辑将问卷发布到后端或其他处理
  55. }
  56. constructor(private router: Router,private http: HttpClient) { }
  57. goTab1(){
  58. this.router.navigate(['tabs/page-psysurvey']);
  59. }
  60. ngOnInit() {}
  61. }