|
@@ -10,13 +10,14 @@ import { LiveService } from '../../../services/live.service';
|
|
import { UploadComponent } from '../../../app/components/upload/upload.component';
|
|
import { UploadComponent } from '../../../app/components/upload/upload.component';
|
|
import * as Parse from 'parse';
|
|
import * as Parse from 'parse';
|
|
import { AuthService } from '../../../services/auth.service';
|
|
import { AuthService } from '../../../services/auth.service';
|
|
|
|
+import { FormsModule } from '@angular/forms';
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
selector: 'app-room-manage',
|
|
selector: 'app-room-manage',
|
|
templateUrl: './room-manage.component.html',
|
|
templateUrl: './room-manage.component.html',
|
|
styleUrls: ['./room-manage.component.scss'],
|
|
styleUrls: ['./room-manage.component.scss'],
|
|
standalone: true,
|
|
standalone: true,
|
|
- imports: [IonicModule, NavComponent, UploadComponent],
|
|
|
|
|
|
+ imports: [IonicModule, NavComponent, UploadComponent,FormsModule],
|
|
})
|
|
})
|
|
export class RoomManageComponent implements OnInit {
|
|
export class RoomManageComponent implements OnInit {
|
|
@ViewChild('upload') upload!: UploadComponent;
|
|
@ViewChild('upload') upload!: UploadComponent;
|
|
@@ -25,9 +26,10 @@ export class RoomManageComponent implements OnInit {
|
|
title: '',
|
|
title: '',
|
|
cover: null,
|
|
cover: null,
|
|
content: null,
|
|
content: null,
|
|
|
|
+ price: 0.5,
|
|
};
|
|
};
|
|
loading: any;
|
|
loading: any;
|
|
- pid: string = localStorage.getItem('profile') ?? '';
|
|
|
|
|
|
+ profile?: Parse.Object
|
|
initLoad:boolean = true;
|
|
initLoad:boolean = true;
|
|
constructor(
|
|
constructor(
|
|
public toastController: ToastController,
|
|
public toastController: ToastController,
|
|
@@ -43,34 +45,38 @@ export class RoomManageComponent implements OnInit {
|
|
}
|
|
}
|
|
// 获取用户信息
|
|
// 获取用户信息
|
|
async getProfile() {
|
|
async getProfile() {
|
|
- if (this.pid) return;
|
|
|
|
let user = Parse.User.current();
|
|
let user = Parse.User.current();
|
|
let query = new Parse.Query('Profile');
|
|
let query = new Parse.Query('Profile');
|
|
query.equalTo('user', user?.id);
|
|
query.equalTo('user', user?.id);
|
|
query.notEqualTo('isDeleted', true);
|
|
query.notEqualTo('isDeleted', true);
|
|
query.select('isCheck', 'isCross');
|
|
query.select('isCheck', 'isCross');
|
|
let r = await query.first();
|
|
let r = await query.first();
|
|
- if (r?.id) this.pid = r?.id;
|
|
|
|
|
|
+ this.profile = r;
|
|
}
|
|
}
|
|
/* 直播间 */
|
|
/* 直播间 */
|
|
async getRoom() {
|
|
async getRoom() {
|
|
let query = new Parse.Query('Room');
|
|
let query = new Parse.Query('Room');
|
|
query.equalTo('user', Parse.User.current()?.id);
|
|
query.equalTo('user', Parse.User.current()?.id);
|
|
- query.equalTo('profile', this.pid);
|
|
|
|
|
|
+ query.equalTo('profile', this.profile?.id);
|
|
query.notEqualTo('isDeleted', true);
|
|
query.notEqualTo('isDeleted', true);
|
|
this.room = await query.first();
|
|
this.room = await query.first();
|
|
this.formData = {
|
|
this.formData = {
|
|
title: this.room?.get('title'),
|
|
title: this.room?.get('title'),
|
|
cover: this.room?.get('cover'),
|
|
cover: this.room?.get('cover'),
|
|
content: this.room?.get('content'),
|
|
content: this.room?.get('content'),
|
|
|
|
+ price: this.profile?.get('laborCosts') || 1,
|
|
};
|
|
};
|
|
console.log(this.formData);
|
|
console.log(this.formData);
|
|
this.initLoad = false
|
|
this.initLoad = false
|
|
}
|
|
}
|
|
|
|
+ onChange() {
|
|
|
|
+ this.formData.price = Math.max(0.5, parseFloat(this.formData.price.toFixed(1)));
|
|
|
|
+ console.log(this.formData.price);
|
|
|
|
+ }
|
|
async saveEdit(e: any) {
|
|
async saveEdit(e: any) {
|
|
let url = e[0]?.url
|
|
let url = e[0]?.url
|
|
console.log(url);
|
|
console.log(url);
|
|
- if(!url || !this.formData.title){
|
|
|
|
|
|
+ if(!url || !this.formData.title || !this.formData.price){
|
|
const toast = await this.toastController.create({
|
|
const toast = await this.toastController.create({
|
|
message: '请填写完整',
|
|
message: '请填写完整',
|
|
color: 'warning',
|
|
color: 'warning',
|
|
@@ -83,6 +89,8 @@ export class RoomManageComponent implements OnInit {
|
|
message: '正在保存修改',
|
|
message: '正在保存修改',
|
|
});
|
|
});
|
|
this.loading.present();
|
|
this.loading.present();
|
|
|
|
+ this.profile?.set('laborCosts', this.formData.price);
|
|
|
|
+ await this.profile?.save();
|
|
if (!this.room?.id) {
|
|
if (!this.room?.id) {
|
|
let obj = Parse.Object.extend('Room');
|
|
let obj = Parse.Object.extend('Room');
|
|
this.room = new obj();
|
|
this.room = new obj();
|
|
@@ -95,10 +103,10 @@ export class RoomManageComponent implements OnInit {
|
|
this.room?.set('profile', {
|
|
this.room?.set('profile', {
|
|
__type: 'Pointer',
|
|
__type: 'Pointer',
|
|
className: 'Profile',
|
|
className: 'Profile',
|
|
- objectId: this.pid,
|
|
|
|
|
|
+ objectId: this.profile?.id,
|
|
});
|
|
});
|
|
|
|
+ this.room?.set('roomid', this.profile?.id,);
|
|
}
|
|
}
|
|
- this.room?.set('roomid', this.pid);
|
|
|
|
this.room?.set('title', this.formData.title);
|
|
this.room?.set('title', this.formData.title);
|
|
this.room?.set('cover', url);
|
|
this.room?.set('cover', url);
|
|
this.room?.set('content', this.formData.content);
|
|
this.room?.set('content', this.formData.content);
|