Skip to content

Commit

Permalink
介绍页头部
Browse files Browse the repository at this point in the history
  • Loading branch information
lwlizhe committed Dec 13, 2019
1 parent 218de6e commit 9db151e
Show file tree
Hide file tree
Showing 17 changed files with 1,424 additions and 69 deletions.
73 changes: 58 additions & 15 deletions lib/app/api/api_novel.dart
Original file line number Diff line number Diff line change
@@ -1,28 +1,71 @@
import 'package:flutter_novel/app/novel/entity/entity_book_detail.dart';
import 'package:flutter_novel/base/http/manager_net_request.dart';

class NovelApi {
static const String DMZJ_REFERER_URL = "http://images.dmzj.com/";
static const String BASE_URL = "http://api.zhuishushenqi.com/";

static const String BASE_URL = "https://v3api.dmzj.com/novel/";

static const String HOME_RECOMMEND = BASE_URL + "recommend.json";

static const String QUERY_AUTO_COMPLETE_KEYWORD =
"http://api.zhuishushenqi.com/book/auto-complete?query=";
static const String QUERY_AUTO_COMPLETE_QUERY_KEYWORD =
BASE_URL + "book/auto-complete?query=";
static const String QUERY_HOT_QUERY_KEYWORD = BASE_URL + "book/hot-word";
static const String QUERY_BOOK_DETAIL_INFO = BASE_URL + "book/";

var client = NetRequestManager.instance;

Future<List<String>> getSearchWord(String keyWord) async {
Future<BaseResponse<List<String>>> getSearchWord(String keyWord) async {
var response;
List<String> result = [];
response =
await client.getRequest(url: QUERY_AUTO_COMPLETE_KEYWORD + keyWord);
bool isOk = response.data["ok"];
if (isOk) {
for (var data in response.data["keywords"]) {
result.add(data);
BaseResponse<List<String>> result = BaseResponse();
List<String> resultData = [];
try {
response =
await client.getRequest(QUERY_AUTO_COMPLETE_QUERY_KEYWORD + keyWord);
bool isOk = response?.data["ok"];
if (isOk) {
for (var data in response.data["keywords"]) {
resultData.add(data);
}
}
result.isSuccess = isOk;
result.data = resultData;
} catch (e) {
print("$e");
result.isSuccess = false;
}
return result;
}

Future<BaseResponse<List<String>>> getHotSearchWord() async {
var response;
BaseResponse<List<String>> result = BaseResponse();

List<String> resultData = [];
try {
response = await client.getRequest(QUERY_HOT_QUERY_KEYWORD);
for (var data in response.data["hotWords"]) {
resultData.add(data);
}
result.isSuccess = true;
result.data = resultData;
} catch (e) {
print("$e");
}
return result;
}

Future<BaseResponse<NovelDetailInfo>> getNovelDetailInfo(
String bookId) async {
BaseResponse<NovelDetailInfo> result = BaseResponse()..isSuccess = false;
try {
var response = await client.getRequest(QUERY_BOOK_DETAIL_INFO + bookId);
result.isSuccess = true;
result.data = NovelDetailInfo.fromJson(response.data);
} catch (e) {
print("$e");
}
return result;
}
}

class BaseResponse<T> {
bool isSuccess;
T data;
}
5 changes: 2 additions & 3 deletions lib/app/main/main_page_view.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart' hide NestedScrollView;
import 'package:flutter_novel/app/novel/view/novel_book_search.dart';
import 'package:flutter_novel/app/novel/view/novel_book_shelf.dart';
import 'package:flutter_novel/base/structure/base_view.dart';
import 'package:flutter_novel/base/structure/base_view_model.dart';
import 'package:flutter_novel/base/util/utils_toast.dart';
Expand Down Expand Up @@ -61,8 +61,7 @@ class MainPageViewState
child: Container(
child: TabBarView(
children: [
NovelSearchView(),
// NovelBookShelfView(),
NovelBookShelfView(),
Text("找书部分,其实就是个列表"),
Text("我的部分,简单描述下这个项目,贴个跳转")
],
Expand Down
211 changes: 211 additions & 0 deletions lib/app/novel/entity/entity_book_detail.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
import 'package:json_annotation/json_annotation.dart';

part 'entity_book_detail.g.dart';

@JsonSerializable()
class NovelDetailInfo extends Object {

@JsonKey(name: '_id')
String id;

@JsonKey(name: 'title')
String title;

@JsonKey(name: 'author')
String author;

@JsonKey(name: 'majorCate')
String majorCate;

@JsonKey(name: 'cover')
String cover;

@JsonKey(name: 'longIntro')
String longIntro;

@JsonKey(name: 'starRatingCount')
int starRatingCount;

@JsonKey(name: 'starRatings')
List<StarRatings> starRatings;

@JsonKey(name: 'isMakeMoneyLimit')
bool isMakeMoneyLimit;

@JsonKey(name: 'contentLevel')
int contentLevel;

@JsonKey(name: 'isFineBook')
bool isFineBook;

@JsonKey(name: 'safelevel')
int safelevel;

@JsonKey(name: 'allowFree')
bool allowFree;

@JsonKey(name: 'originalAuthor')
String originalAuthor;

@JsonKey(name: 'anchors')
List<dynamic> anchors;

@JsonKey(name: 'authorDesc')
String authorDesc;

@JsonKey(name: 'rating')
Rating rating;

@JsonKey(name: 'hasCopyright')
bool hasCopyright;

@JsonKey(name: 'buytype')
int buytype;

@JsonKey(name: 'sizetype')
int sizetype;

@JsonKey(name: 'superscript')
String superscript;

@JsonKey(name: 'currency')
int currency;

@JsonKey(name: 'contentType')
String contentType;

@JsonKey(name: '_le')
bool le;

@JsonKey(name: 'allowMonthly')
bool allowMonthly;

@JsonKey(name: 'allowVoucher')
bool allowVoucher;

@JsonKey(name: 'allowBeanVoucher')
bool allowBeanVoucher;

@JsonKey(name: 'hasCp')
bool hasCp;

@JsonKey(name: 'banned')
int banned;

@JsonKey(name: 'postCount')
int postCount;

@JsonKey(name: 'totalFollower')
int totalFollower;

@JsonKey(name: 'latelyFollower')
int latelyFollower;

@JsonKey(name: 'followerCount')
int followerCount;

@JsonKey(name: 'wordCount')
int wordCount;

@JsonKey(name: 'serializeWordCount')
int serializeWordCount;

@JsonKey(name: 'retentionRatio')
String retentionRatio;

@JsonKey(name: 'updated')
String updated;

@JsonKey(name: 'isSerial')
bool isSerial;

@JsonKey(name: 'chaptersCount')
int chaptersCount;

@JsonKey(name: 'lastChapter')
String lastChapter;

@JsonKey(name: 'gender')
List<dynamic> gender;

@JsonKey(name: 'tags')
List<dynamic> tags;

@JsonKey(name: 'advertRead')
bool advertRead;

@JsonKey(name: 'donate')
bool donate;

@JsonKey(name: 'copyright')
String copyright;

@JsonKey(name: '_gg')
bool gg;

@JsonKey(name: 'isForbidForFreeApp')
bool isForbidForFreeApp;

@JsonKey(name: 'isAllowNetSearch')
bool isAllowNetSearch;

@JsonKey(name: 'limit')
bool limit;

@JsonKey(name: 'copyrightInfo')
String copyrightInfo;

@JsonKey(name: 'copyrightDesc')
String copyrightDesc;

NovelDetailInfo(this.id,this.title,this.author,this.majorCate,this.cover,this.longIntro,this.starRatingCount,this.starRatings,this.isMakeMoneyLimit,this.contentLevel,this.isFineBook,this.safelevel,this.allowFree,this.originalAuthor,this.anchors,this.authorDesc,this.rating,this.hasCopyright,this.buytype,this.sizetype,this.superscript,this.currency,this.contentType,this.le,this.allowMonthly,this.allowVoucher,this.allowBeanVoucher,this.hasCp,this.banned,this.postCount,this.totalFollower,this.latelyFollower,this.followerCount,this.wordCount,this.serializeWordCount,this.retentionRatio,this.updated,this.isSerial,this.chaptersCount,this.lastChapter,this.gender,this.tags,this.advertRead,this.donate,this.copyright,this.gg,this.isForbidForFreeApp,this.isAllowNetSearch,this.limit,this.copyrightInfo,this.copyrightDesc,);

factory NovelDetailInfo.fromJson(Map<String, dynamic> srcJson) => _$NovelDetailInfoFromJson(srcJson);

Map<String, dynamic> toJson() => _$NovelDetailInfoToJson(this);

}


@JsonSerializable()
class StarRatings extends Object {

@JsonKey(name: 'count')
int count;

@JsonKey(name: 'star')
int star;

StarRatings(this.count,this.star,);

factory StarRatings.fromJson(Map<String, dynamic> srcJson) => _$StarRatingsFromJson(srcJson);

Map<String, dynamic> toJson() => _$StarRatingsToJson(this);

}


@JsonSerializable()
class Rating extends Object {

@JsonKey(name: 'score')
double score;

@JsonKey(name: 'count')
int count;

@JsonKey(name: 'tip')
String tip;

@JsonKey(name: 'isEffect')
bool isEffect;

Rating(this.score,this.count,this.tip,this.isEffect,);

factory Rating.fromJson(Map<String, dynamic> srcJson) => _$RatingFromJson(srcJson);

Map<String, dynamic> toJson() => _$RatingToJson(this);

}


Loading

0 comments on commit 9db151e

Please sign in to comment.