warrior 5 månader sedan
förälder
incheckning
2ae325513b

+ 1 - 1
projects/live-app/src/moduls/tabs/my/my.component.html

@@ -155,7 +155,7 @@
         </div>
         <ion-icon name="chevron-forward-outline"></ion-icon>
       </div>
-      <div class="li">
+      <div class="li" (click)="toUrl('user/feedback')">
         <div class="li-lable">
           <img src="/img/意见反馈.png" alt="" class="icon" />
           意见反馈

+ 31 - 0
projects/live-app/src/moduls/user/feedback/feedback.component.html

@@ -0,0 +1,31 @@
+<nav title="意见反馈"></nav>
+<ion-content class="content">
+  <div class="feedback">
+    <div class="section">
+      <ion-textarea
+        autofocus
+        autoGrow
+        rows="6"
+        cols="20"
+        placeholder="填写您的意见反馈"
+        maxlength="500"
+        (ionChange)="textChange($event)"
+      ></ion-textarea>
+      <span>{{ inputNum }}/500</span>
+    </div>
+    <div class="title">上传截图</div>
+    <!-- 文件上传 -->
+    <div class="upload">
+      <app-upload
+        (onChange)="onFilesChange($event)"
+        #upload
+        [boxWidth]="380"
+        [maxlenght]="8"
+        [files]="fileList"
+      ></app-upload>
+    </div>
+    <!-- 提交 -->
+    <!-- <ion-button  (click)="submit()" expand="block">提交</ion-button> -->
+  </div>
+</ion-content>
+<ion-button class="add_btn" (click)="upload.onUpload()">保存</ion-button>

+ 59 - 0
projects/live-app/src/moduls/user/feedback/feedback.component.scss

@@ -0,0 +1,59 @@
+.content{
+    padding-bottom: 50px;
+}
+.feedback {
+  width: 100%;
+//   height: 100vh;
+  background-color: #fff;
+
+  // 输入框
+  .section {
+    width: 380px;
+    background: #eeeeee;
+    border-radius: 0.24rem;
+    margin: 0.3rem auto;
+    padding: 0.3rem;
+    position: relative;
+
+    textarea {
+      width: 100%;
+      height: 100%;
+    }
+
+    span {
+      width: 100%;
+      text-align: right;
+      font-size: 12px;
+      font-family: Source Han Sans CN;
+      font-weight: 400;
+      color: #666666;
+      text-align: right;
+      position: absolute;
+      bottom: 0.3rem;
+      right: 0.3rem;
+    }
+  }
+
+  .title {
+    width: 380px;
+    font-size: 14px;
+    font-family: Source Han Sans CN;
+    font-weight: 600;
+    color: #222222;
+    margin: 10px auto;
+  }
+
+  .upload {
+    width: 380px;
+    margin: 10px auto;
+    // background-color: #eeeeee;
+  }
+}
+.add_btn {
+  position: fixed;
+  bottom: 1vh;
+  width: 80%;
+  left: 10vw;
+  background: #92a1ff;
+  border-radius: 18px;
+}

+ 24 - 0
projects/live-app/src/moduls/user/feedback/feedback.component.spec.ts

@@ -0,0 +1,24 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { IonicModule } from '@ionic/angular';
+
+import { FeedbackComponent } from './feedback.component';
+
+describe('FeedbackComponent', () => {
+  let component: FeedbackComponent;
+  let fixture: ComponentFixture<FeedbackComponent>;
+
+  beforeEach(async(() => {
+    TestBed.configureTestingModule({
+      declarations: [ FeedbackComponent ],
+      imports: [IonicModule.forRoot()]
+    }).compileComponents();
+
+    fixture = TestBed.createComponent(FeedbackComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  }));
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 105 - 0
projects/live-app/src/moduls/user/feedback/feedback.component.ts

@@ -0,0 +1,105 @@
+import { Component, OnInit } from '@angular/core';
+import * as Parse from 'parse';
+import { IonicModule, ToastController } from '@ionic/angular';
+import { FormsModule } from '@angular/forms';
+import { NavComponent } from '../../../app/components/nav/nav.component';
+import { AuthService } from '../../../services/auth.service';
+import { UploadComponent } from '../../../app/components/upload/upload.component';
+
+@Component({
+  selector: 'app-feedback',
+  templateUrl: './feedback.component.html',
+  styleUrls: ['./feedback.component.scss'],
+  standalone: true,
+  imports: [IonicModule, FormsModule, UploadComponent,NavComponent],
+})
+export class FeedbackComponent implements OnInit {
+  fileList: any = [];
+  content: string = '';
+  inputNum: number = 0;
+  company: string | null = '';
+  constructor(
+    private authServ: AuthService,
+    public toastController: ToastController
+  ) {
+    this.company = authServ.company;
+  }
+  textChange(e: any) {
+    this.content = e.detail.value;
+    this.inputNum = e.detail.value.length;
+  }
+  ngOnInit() {}
+  async presentToast(title: string, time: number, color: string) {
+    const toast = await this.toastController.create({
+      message: title,
+      duration: time,
+      color: color,
+    });
+    toast.present();
+  }
+  onFilesChange(event: any) {
+    console.log(event);
+    this.fileList = event;
+  }
+  async submit() {
+    let user = Parse.User.current();
+    if (!user) {
+      this.authServ.logout();
+      return;
+    }
+    console.log(this.fileList);
+    if (
+      (this.content == '' || this.content.trim() == '') &&
+      this.fileList.length < 1
+    ) {
+      await this.presentToast('请填写内容', 1500, 'danger');
+      return;
+    }
+    let images = [];
+    for (let i = 0; i < this.fileList.length; i++) {
+      let item = this.fileList[i];
+      images.push({
+        url: item,
+      });
+    }
+    let mobile = user.get('mobile');
+    let Profile = new Parse.Query('Profile');
+    Profile.equalTo('user', user.id);
+    Profile.notEqualTo('isDeleted',true)
+    let profile = await Profile.first();
+    let Feedback = Parse.Object.extend('Feedback');
+    let feedback = new Feedback();
+    feedback.set('user', {
+      __type: 'Pointer',
+      className: '_User',
+      objectId: user.id,
+    });
+    feedback.set('company', {
+      __type: 'Pointer',
+      className: 'Company',
+      objectId: this.company,
+    });
+
+    if (profile) {
+      feedback.set('profile', {
+        __type: 'Pointer',
+        className: 'Profile',
+        objectId: profile.id,
+      });
+    }
+
+    feedback.set('content', this.content ? this.content : undefined);
+    feedback.set('images', images);
+    feedback.set('mobile', mobile);
+    let result = await feedback.save();
+    if (result && result.id) {
+      await this.presentToast('提交成功', 1500, 'success');
+      history.go(-1);
+    } else {
+      await this.presentToast('提交失败', 1500, 'danger');
+      setTimeout(() => {
+        history.go(-1);
+      }, 1500);
+    }
+  }
+}

+ 5 - 0
projects/live-app/src/moduls/user/user.modules.routes.ts

@@ -2,6 +2,7 @@ import { NgModule } from '@angular/core';
 import { RouterModule, Routes } from '@angular/router';
 import { AlbumComponent } from './album/album.component';
 import { CertificationComponent } from './certification/certification.component';
+import { FeedbackComponent } from './feedback/feedback.component';
 const routes: Routes = [
   {
     path: '',
@@ -16,6 +17,10 @@ const routes: Routes = [
     path: 'album',//相册
     component: AlbumComponent,
   },
+  {
+    path: 'feedback',//意见反馈
+    component: FeedbackComponent,
+  },
 ]
 @NgModule({
   imports: [RouterModule.forChild(routes)],