123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- <import name="x-book" src="../../components/book/book.ux"></import>
- <template>
- <div class="home-wrap">
- <div class="home_title"><text>精选</text></div>
- <div class="type-wrap_content">
- <div class="type-wrap">
- <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>
- <!-- <text class="feebar-text" @click="toPage('Free')">限时免费</text> -->
- </div>
- <div class="search-bar">
- <div class="search-bar__wrap">
- <text @click="toCategory">请输入书名或者作者名</text
- ><image
- src="https://yueduyun.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/img/search.png"
- ></image>
- </div>
- </div>
- </div>
- <!-- <div class="type-bar">
- <div class="search-bar__wrap">
- <text @click="toCategory">请输入书名或者作者名</text
- ><image
- src="https://yueduyun.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/img/search.png"
- ></image>
- </div>
- </div> -->
- <list class="list-content">
- <list-item type="swipe" class="swipe-bar">
- <swiper class="swipe-bar" autoplay="true" indicator="false">
- <block for="b in banner">
- <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/to_search.png"
- @click="toPage('Search')"
- ></image>
- </div>
- <div>
- <image
- src="../../assets/imgs/to_task.png"
- @click="toPage('Task')"
- ></image>
-
- </div>
- <div>
- <image
- src="../../assets/imgs/to_rank.png"
- @click="toPage('Leaderboard')"
- ></image>
- </div>
- </div>
- </list-item> -->
- <block for="bookObj in list">
- <list-item type="simple" class="book-list__wrap" if="$idx % 3 === 0">
- <div class="book-list_content">
- <div class="book-list__title">
- <text class="border"></text>
- <text>{{ bookObj.lable }}</text>
- </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>
- <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>
- </list-item>
- <list-item
- type="multi"
- class="book-list__wrap book-list__wrap--multi"
- else
- >
- <div class="book-list_content">
- <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>
- </div>
- </list-item>
- </block>
- <list-item style="height:120px;"></list-item>
- </list>
- </div>
- </template>
- <script>
- import { getHomeList , getBannerData,checkAdvertisement} 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) {
- if(page.ids){
- try{
- let type = page.type ? "default" : "";
- checkAdvertisement(type,page.ids);
- // console.log('type',type);
- }catch(e){
- }
- }
- if (page.redirect_url && page.redirect_url != "#") {
- if (page.redirect_type == "book") {
- router.push({
- uri: page.redirect_url,
- params: {
- bid: page.bid,
- chapter_id: page.cid
- }
- })
- } else if (page.redirect_type == "activity") {
- router.push({
- uri: page.redirect_url,
- params:page.param
- })
- }
- }
- },
- toMyRead() {
- this.$emit('change')
- },
- jump(page) {
- router.push({
- uri: '/views/' + page
- })
- },toPage(page) {
- router.push({
- uri: '/views/' + page,
- params: {
- sex: this.current
- }
- })
- },toCategory() {
- router.push({
- uri: '/views/Search',
- })
- },
- 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)
- let banner = await getBannerData(sex == "female" ? 2 : 1);
- this.banner = banner;
- }
- }
- </script>
- <style lang="less">
- @import "../../assets/less/home.less";
- </style>
|