|
@@ -18,11 +18,16 @@ import { ConnectTaskService } from '../../../services/connectTask.service';
|
|
|
templateUrl: './room-manage.component.html',
|
|
|
styleUrls: ['./room-manage.component.scss'],
|
|
|
standalone: true,
|
|
|
- imports: [...ionicStandaloneModules, NavComponent, UploadComponent,FormsModule],
|
|
|
+ imports: [
|
|
|
+ ...ionicStandaloneModules,
|
|
|
+ NavComponent,
|
|
|
+ UploadComponent,
|
|
|
+ FormsModule,
|
|
|
+ ],
|
|
|
})
|
|
|
export class RoomManageComponent implements OnInit {
|
|
|
@ViewChild('upload') upload!: UploadComponent;
|
|
|
- room?:Parse.Object
|
|
|
+ room?: Parse.Object;
|
|
|
formData: any = {
|
|
|
title: '',
|
|
|
cover: null,
|
|
@@ -30,20 +35,23 @@ export class RoomManageComponent implements OnInit {
|
|
|
price: 0.5,
|
|
|
};
|
|
|
loading: any;
|
|
|
- profile?: Parse.Object
|
|
|
- initLoad:boolean = true;
|
|
|
+ profile?: Parse.Object;
|
|
|
+ initLoad: boolean = true;
|
|
|
+ placeholder: string = '请填写点播费用';
|
|
|
+ min: number = 1;
|
|
|
+ max: number = 990;
|
|
|
constructor(
|
|
|
private toastController: ToastController,
|
|
|
private loadingCtrl: LoadingController,
|
|
|
private liveService: LiveService,
|
|
|
private alertController: AlertController,
|
|
|
private connectTask: ConnectTaskService,
|
|
|
- private authServ: AuthService,
|
|
|
+ private authServ: AuthService
|
|
|
) {}
|
|
|
|
|
|
async ngOnInit() {
|
|
|
await this.getProfile();
|
|
|
- this.getRoom()
|
|
|
+ this.getRoom();
|
|
|
}
|
|
|
// 获取用户信息
|
|
|
async getProfile() {
|
|
@@ -54,6 +62,25 @@ export class RoomManageComponent implements OnInit {
|
|
|
// query.select('isCheck', 'isCross');
|
|
|
let r = await query.first();
|
|
|
this.profile = r;
|
|
|
+ if (r?.get('state')) {
|
|
|
+ switch (r?.get('state')) {
|
|
|
+ case '三星':
|
|
|
+ this.min = 20;
|
|
|
+ this.max = 99;
|
|
|
+ break;
|
|
|
+ case '四星':
|
|
|
+ this.min = 100;
|
|
|
+ this.max = 150;
|
|
|
+ break;
|
|
|
+ case '五星':
|
|
|
+ this.min = 160;
|
|
|
+ this.max = 990;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.placeholder = this.min + '-' + this.max;
|
|
|
localStorage.setItem('profile', JSON.stringify(this.profile?.toJSON()));
|
|
|
}
|
|
|
/* 直播间 */
|
|
@@ -70,23 +97,35 @@ export class RoomManageComponent implements OnInit {
|
|
|
price: this.profile?.get('laborCosts') || 1,
|
|
|
};
|
|
|
console.log(this.formData);
|
|
|
- this.initLoad = false
|
|
|
+ this.initLoad = false;
|
|
|
}
|
|
|
onChange() {
|
|
|
- this.formData.price = Math.max(0.5, parseFloat(this.formData.price.toFixed(1)));
|
|
|
+ this.formData.price = Math.max(
|
|
|
+ 0.5,
|
|
|
+ parseFloat(this.formData.price.toFixed(1))
|
|
|
+ );
|
|
|
console.log(this.formData.price);
|
|
|
}
|
|
|
async saveEdit(e: any) {
|
|
|
- let url = e[0]?.url
|
|
|
+ let url = e[0]?.url;
|
|
|
console.log(url);
|
|
|
- if(!url || !this.formData.title || !this.formData.price){
|
|
|
+ if (!url || !this.formData.title || !this.formData.price) {
|
|
|
const toast = await this.toastController.create({
|
|
|
message: '请填写完整',
|
|
|
color: 'warning',
|
|
|
duration: 1000,
|
|
|
});
|
|
|
- toast.present()
|
|
|
- return
|
|
|
+ toast.present();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(this.formData.price < this.min || this.formData.price > this.max){
|
|
|
+ const toast = await this.toastController.create({
|
|
|
+ message: '请输入正确的点播费用',
|
|
|
+ color: 'warning',
|
|
|
+ duration: 1000,
|
|
|
+ });
|
|
|
+ toast.present();
|
|
|
+ return;
|
|
|
}
|
|
|
this.loading = await this.loadingCtrl.create({
|
|
|
message: '正在保存修改',
|
|
@@ -108,16 +147,16 @@ export class RoomManageComponent implements OnInit {
|
|
|
className: 'Profile',
|
|
|
objectId: this.profile?.id,
|
|
|
});
|
|
|
- this.room?.set('roomid', this.profile?.id,);
|
|
|
+ this.room?.set('roomid', this.profile?.id);
|
|
|
}
|
|
|
this.room?.set('title', this.formData.title);
|
|
|
this.room?.set('cover', url);
|
|
|
this.room?.set('content', this.formData.content);
|
|
|
await this.room?.save();
|
|
|
- this.room && this.liveService.getToken(this.room)
|
|
|
+ this.room && this.liveService.getToken(this.room);
|
|
|
this.loading.dismiss();
|
|
|
this.getRoom();
|
|
|
- await this.connectTask.anchorOnline();//房间修改或创建后重新初始化连接
|
|
|
+ await this.connectTask.anchorOnline(); //房间修改或创建后重新初始化连接
|
|
|
this.presentAlert('保存成功');
|
|
|
}
|
|
|
async presentAlert(msg: string) {
|