123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 |
- <import name="x-book" src="../../components/book/book.ux"></import>
-
- <template>
- <div class="home-wrap">
- <div class="type-bar">
- <block for="type in typeList">
- <div class="type-item" @click="typeChange(type.index)">
- <text class="{{type.index === current ? 'cur' : ''}}">{{type.name}}</text>
- <text class="choose-bar" show="{{type.index === current}}"></text>
- </div>
- </block>
- </div>
- <list class="list-content">
- <list-item type="search" class="search-bar">
- <div class="search-bar__wrap">
- <image src="https://yueduyun.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/img/search.png"></image>
- <text @click="toCategory">书名</text>
- </div>
- </list-item>
- <list-item type="swipe">
- <swiper class="swipe-bar" autoplay="true" indicator="false">
- <block for="b in banner.books">
- <div class="swipe-item">
- <image class="cover" src="{{b.banner_url}}" @click="pageRouter(b)"></image>
- </div>
- </block>
- </swiper>
- </list-item>
- <list-item type="entrance">
- <div class="entrance_block">
- <div><image src="../../assets/imgs/home_fl.png" @click="jump('Category')"></image><text>分类</text></div>
- <div><image src="../../assets/imgs/home_rank.png" @click="jump('Leaderboard')"></image><text>排行榜</text></div>
- <div><image src="../../assets/imgs/home_free.png" @click="jump('Free')"></image><text>限时免费</text></div>
- <div><image src="../../assets/imgs/home_pre.png" @click="toMyRead"></image><text>最近阅读</text></div>
- </div>
- </list-item>
- <block for="bookObj in list">
- <list-item type="simple" class="book-list__wrap" if="$idx % 2 === 0">
- <div class="book-list__title">
- <text>{{bookObj.lable}}</text>
- </div>
- <div class="book-list">
- <block for="book in bookObj.books">
- <x-book multi="{{false}}" book="{{book}}"></x-book>
- </block>
- </div>
- </list-item>
- <list-item type="multi" class="book-list__wrap book-list__wrap--multi" else>
- <div class="book-list__title">
- <text class="border"></text>
- <text>{{bookObj.lable}}</text>
- </div>
- <div class="book-list__line">
- <block for="book in bookObj.books.slice(0, 4)">
- <x-book multi="{{false}}" width="{{150}}" lines="{{true}}" book="{{book}}"></x-book>
- </block>
- </div>
- <div class="book-list__multi">
- <block for="book in bookObj.books.slice(4)">
- <div class="book-item">
- <x-book multi="{{true}}" width="{{150}}" book="{{book}}" >
- <div class="book-info__multi">
- <text class="name">{{book.book_name}}</text>
- <text class="intro">{{book.book_summary}}</text>
- </div>
- </x-book>
- </div>
- </block>
- </div>
- </list-item>
- </block>
- </list>
- </div>
- </template>
- <script>
- import { getHomeList } from "../../api";
- import storage from '@system.storage';
- import router from '@system.router';
- export default {
- props: {
- tabindex: {
- type: Number,
- default: 0
- }
- },
- data() {
- return {
- typeList: [
- {
- name: "男生",
- index: 0
- },
- {
- name: "女生",
- index: 1
- }
- ],
- banner: [],
- list: [],
- current: 1
- }
- },
- async onInit() {
- await this.getCityListByTabChange();
- this.$on('refreshData',this.broadevt);
- this.$watch('current', 'getCityListByTabChange');
- this.$watch('tabindex', 'watchPropsChange');
- },
- typeChange(index) {
- this.current = index;
- },
- watchPropsChange(v){
- if (v === 0) this.getCityListByTabChange(this.current);
- },
- async broadevt(evt){
- if(evt.detail.current==0){
- await this.getCityListByTabChange(this.current);
- }
- },
- toCategory() {
- //this.$emit('change');
- router.push({
- uri: '/views/Search',
- })
- },
- pageRouter(page) {
- router.push({
- uri: page.redirect_url,
- params: {
- bid: page.bid,
- chapter_id: page.cid
- }
- })
- },
- toMyRead(){
- this.$emit('change');
- },
- jump(page) {
- router.push({
- uri: '/views/' + page,
- })
- },
- async getCityListByTabChange(index = 1) {
- await storage.set({ key: "sex", value: index || 0 });
- let sex = index ? "female" : "male";
- let ret = await getHomeList(sex);
- this.banner = ret.slice(0, 1)[0];
- this.list = ret.slice(1);
- }
- }
- </script>
- <style lang="less">
- /* @import "../../assets/less/home.less"; */
- .home-wrap {
- background-color: #fff;
- flex-direction: column;
- padding-top: 20px;
- .entrance_block {
- width: 100%;
- padding: 30px;
- display: flex;
- justify-content: space-around;
- div{
- flex-direction: column;
- text{
- margin-top: 10px;
- text-align: center;
- }
- }
- image {
- width:80px;
- height:80px;
- margin:0 auto;
- }
- }
- .type-bar {
- background-color: #fff;
- .type-item {
- flex: 1;
- justify-content: center;
- align-items: center;
- flex-direction: column;
- position: relative;
- text {
- font-size: 30px;
- color: #999;
- // padding: 34px 0;
- }
- .cur {
- color: #ef5952;
- font-size: 36px;
- font-weight: bold;
- }
- .choose-bar {
- width: 38px;
- height: 4px;
- background-color: #ef5952;
- border-radius: 2px;
- margin-top: 10px;
- }
- }
- }
- .search-bar {
- padding: 24px;
- .search-bar__wrap {
- flex: 1;
- background-color: #f7f7f7;
- height: 62px;
- padding: 0 14px;
- border-radius: 30px;
- align-items: center;
- image {
- margin-right: 20px;
- width: 36px;
- height: 36px;
- }
- text {
- flex: 1;
- font-size: 24px;
- color: #999;
- }
- }
- }
- .swipe-bar {
- height: 260px;
- // background-color: #fff;
- .swipe-item {
- padding: 0px 24px;
- .swipe-item__info {
- flex: 1;
- flex-direction: column;
- padding-right: 32px;
- .name {
- font-size: 32px;
- color: #333;
- }
- .intro {
- font-size: 26px;
- color: #666;
- margin-top: 36px;
- lines: 4;
- text-overflow: ellipsis;
- }
- .category {
- font-size: 24px;
- color: #32a1ff;
- margin-top: 10px;
- }
- }
- .cover {
- width: 100%;
- height: 260px;
- // flex-basis: 180px;
- // flex-shrink: 0;
- // height: 240px;
- border-radius: 6px;
- }
- }
- }
- .book-list__wrap {
- background-color: #fff;
- // margin-top: 24px;
- padding: 0 24px;
- flex-direction: column;
- .book-list__title {
- padding: 30px 0;
- align-items: center;
- text {
- color: #333;
- font-size: 32px;
- }
- }
- }
- .book-list {
- flex: 1;
- flex-direction: row;
- flex-wrap: wrap;
- justify-content: space-between;
- }
- .book-list__multi {
- margin-top: 30px;
- flex-direction: column;
- .book-item {
- margin-bottom: 30px;
- }
- .book-info__multi {
- flex: 1;
- flex-direction: column;
- justify-content: flex-start;
- align-items: flex-start;
- margin-left: 38px;
- // margin-bottom: 40px;
- .name {
- font-size: 32px;
- color: #333;
- lines: 1;
- text-overflow: ellipsis;
- }
- .intro {
- font-size: 24px;
- color: #666;
- lines: 3;
- text-overflow: ellipsis;
- margin-top: 36px;
- line-height: 36px;
- }
- }
- }
- .book-list__line {
- justify-content: space-between;
- align-items: flex-start;
- border-bottom: 2px solid #f7f7f7;
- }
- }
- </style>
|