forked from piaocbn2j/MTMusic
parent
14a6a42283
commit
73c9190727
@ -0,0 +1,53 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../models/getMusicList_bean.dart';
|
||||
import '../models/getRank_bean.dart';
|
||||
|
||||
const String _getMusic1 = 'http://flyingpig.fun:10010/musics/1';
|
||||
const String _getMusic2 = 'http://flyingpig.fun:10010/musics/2';
|
||||
const String _getMusic3 = 'http://flyingpig.fun:10010/musics/3';
|
||||
|
||||
///排行榜
|
||||
class GetMusic {
|
||||
final Dio dio = Dio();
|
||||
|
||||
Future<MusicListBean> getMusic1({required String Authorization}) async {
|
||||
Response response = await dio.get(
|
||||
_getMusic1,
|
||||
data: {
|
||||
'Authorization': Authorization,
|
||||
},
|
||||
options: Options(headers: {
|
||||
'Authorization': Authorization,
|
||||
'Content-Type': 'application/json;charset=UTF-8'
|
||||
}));
|
||||
print(response.data);
|
||||
return MusicListBean.formMap(response.data);
|
||||
}
|
||||
Future<MusicListBean> getMusic2({required String Authorization}) async {
|
||||
Response response = await dio.get(
|
||||
_getMusic2,
|
||||
data: {
|
||||
'Authorization': Authorization,
|
||||
},
|
||||
options: Options(headers: {
|
||||
'Authorization': Authorization,
|
||||
'Content-Type': 'application/json;charset=UTF-8'
|
||||
}));
|
||||
print(response.data);
|
||||
return MusicListBean.formMap(response.data);
|
||||
}
|
||||
Future<MusicListBean> getMusic3({required String Authorization}) async {
|
||||
Response response = await dio.get(
|
||||
_getMusic3,
|
||||
data: {
|
||||
'Authorization': Authorization,
|
||||
},
|
||||
options: Options(headers: {
|
||||
'Authorization': Authorization,
|
||||
'Content-Type': 'application/json;charset=UTF-8'
|
||||
}));
|
||||
print(response.data);
|
||||
return MusicListBean.formMap(response.data);
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
// home_view_model.dart
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'Song_widegt.dart';
|
||||
|
||||
class TryRow extends GetxController {
|
||||
final RxString txtSearch = ''.obs;
|
||||
|
||||
final List<Song> allSongs = [
|
||||
Song(
|
||||
artistPic: 'assets/img/music_artist.png',
|
||||
title: '背对背拥抱1',
|
||||
artist: '林俊杰 1',
|
||||
musicurl: 'audio/MAMAMOO.mp3',
|
||||
pic: 'assets/img/artist_pic.png',
|
||||
),
|
||||
// Add more songs here
|
||||
];
|
||||
|
||||
RxList<Song> filteredSongs = <Song>[].obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
filteredSongs.assignAll(allSongs);
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
void updateSearchResults() {
|
||||
final String query = txtSearch.value.toLowerCase();
|
||||
if (query.isEmpty) {
|
||||
filteredSongs.assignAll(allSongs);
|
||||
} else {
|
||||
filteredSongs.assignAll(allSongs
|
||||
.where((song) =>
|
||||
song.title.toLowerCase().contains(query) ||
|
||||
song.artist.toLowerCase().contains(query))
|
||||
.toList());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
class MusicListBean {
|
||||
int? code;
|
||||
String? msg;
|
||||
int? id;
|
||||
String? name;
|
||||
String? coverPath;
|
||||
String? musicPath;
|
||||
String? singerName;
|
||||
String? uploadUserName;
|
||||
bool? likeOrNot;
|
||||
bool? collectOrNot;
|
||||
MusicListBean.formMap(Map map){
|
||||
code = map['code'];
|
||||
msg= map['msg'];
|
||||
if (map['data'] == '') return;
|
||||
Map? data = map['data'];
|
||||
if (data == null) return;
|
||||
id = data['id'];
|
||||
name = data['name'];
|
||||
coverPath = data['coverPath'];
|
||||
musicPath = data['musicPath'];
|
||||
singerName = data['singerName'];
|
||||
uploadUserName = data['uploadUserName'];
|
||||
likeOrNot = data['likeOrNot'];
|
||||
collectOrNot = data['collectOrNot'];
|
||||
}
|
||||
}
|
Loading…
Reference in new issue