Przeglądaj źródła

链接跳转 请求详情 根据机型显示不同的书架样式

hjr 3 miesięcy temu
rodzic
commit
ea8a633b75

+ 2 - 1
src/components/bookshelf/index.ux

@@ -27,7 +27,7 @@
           </div>
           <div class="delete-icon" @click="deleteBook($item)">
             <image
-              src="../..https://ytnovels.oss-cn-shanghai.aliyuncs.com/appStatic/images/cancel.png"
+              src="https://ytnovels.oss-cn-shanghai.aliyuncs.com/appStatic/images/cancel.png"
               show="{{editStatus}}"
             ></image>
           </div>
@@ -60,6 +60,7 @@ export default {
       bookId: item.id,
       bookTitle: item.novelName,
       total: item.novelChapterCount || 100,
+      chapterId:item.chapterId || 1,
     })
   },
   deleteBook(item) {

+ 31 - 14
src/components/library/book-list.ux

@@ -5,13 +5,13 @@
     <list-item type="custom">
       <slot></slot>
     </list-item>
-    <list-item type="title">
+    <list-item type="title" if="{{ brand =='vivo' }}">
       <text class="rank-title">收藏榜单</text>
     </list-item>
-    <list-item type="rank-item" for="{{rankList}}">
+    <list-item type="rank-item" for="{{rankList}}" if="{{ brand =='vivo' }}">
       <stack class="rank-item {{`rank-${$idx}`}}" onclick="goToDetail($item)">
         <div class="rank-bg"></div>
-        <div class="rank-icon">
+        <div class="rank-icon"> 
           <text>{{ $idx + 1 }}</text>
         </div>
         <div class="rank-text">
@@ -20,18 +20,29 @@
         </div>
       </stack>
     </list-item>
-    <!-- <list-item type="rank-item" for="{{rankList}}">
-      <stack class="rank-item {{`rank-${$idx}`}}" onclick="goToDetail($item)">
-        <div class="rank-bg"></div>
-        <div class="rank-icon">
-          <text>{{ $idx + 1 }}</text>
-        </div>
-        <div class="rank-text">
-          <text>{{ $item.title }}</text>
-          <text>{{ $item.author }}</text>
+    <list-item type="title" if="{{ brand =='OPPO' }}">
+      <text class="rank-title">全网精品</text>
+    </list-item>
+    <list-item type="oppo" if="{{ brand =='OPPO' }}">
+      <div style="flex-wrap: wrap;">
+        <div
+            type="book-item"
+            class="book-item"
+            for="{{hotList}}"
+            onclick="goToDetail($item)"
+            style="flex-wrap: wrap;width: 33%;height: 320px;flex-direction: column;
+            align-items: center;border-bottom-width:0px;padding-bottom:10px;padding-top:10px;"
+          >
+            <div class="list-image" style="margin-right: 0px;">
+              <image src="{{$item.novelImg}}"></image>
+            </div>
+            <div class="list-text" style="margin-top: 10px;">
+              <text class="book-title text-title" style="font-size: 26px;">{{ $item.novelName }}</text>
+            </div>
+          </div>
         </div>
-      </stack>
-    </list-item> -->
+      </div>
+    </list-item>
     <list-item type="title">
       <text class="list-title">图书列表</text>
     </list-item>
@@ -74,6 +85,12 @@ export default {
     },
     rankList: {
       default: []
+    },
+    hotList:{
+      default:[]
+    },
+    brand:{
+      default:'vivo'
     }
   },
   /* -------------------SelfCustomEvent------------------ */

+ 5 - 15
src/components/library/index.ux

@@ -4,27 +4,15 @@
 <template>
   <div class="page-container">
     <search-input-bar onsearch="search" is-click="{{ true }}"></search-input-bar>
-    <!-- <book-list
-      list="{{library.list}}"
-      show-load="{{library.load}}"
-      onload-more="queryLibraryList"
-      rank-list="{{rankList}}"
-    > -->
     <book-list
       list="{{library.list}}"
       show-load="{{library.load}}"
       onload-more="queryLibraryList"
       rank-list="{{rankList}}"
+      hot-list="{{hotList}}"
+      brand="{{ brand }}"
     >
       <div class="sub-container">
-        <!-- <swiper autoplay="true" class="swiper">
-          <image
-            class="swiper-image"
-            src="{{$item.swiper}}"
-            for="swiperList"
-            onclick="goToDetail($item)"
-          ></image>
-        </swiper> -->
         <swiper autoplay="true" class="swiper">
           <image
             class="swiper-image"
@@ -61,6 +49,7 @@ export default {
     bookList:[],// 图书列表
     bannerAd: null,
     adUnitId: "278eae7418b04abbb5926847ed42271e", // 这个id是vivo的com.quickapp.center创建的,需要修改manifest的package才能预览出效果
+    brand:'vivo',// 当前手机品牌  vivo OPPO xiaomi honor
   },
   search(info) {
     let searchText = info.detail
@@ -90,13 +79,14 @@ export default {
     }
   },
   async onInit() {
+    this.brand = await $utils.getStorage('brand')
     console.log(ad.getProvider())
     this.initAd()
     this.queryLibraryList(1)
     const res = await $apis.common.novelBanner({bannerType: 8, pageNum: 1,pageSize: 10})
     this.bannerList = res.data.result.list
     const res1 = await $apis.common.novelModulePage({moduleType: 8, pageNum: 1,pageSize: 10,statu:1})
-    // this.hotList = res1.data.result.list
+    this.hotList = res1.data.result.list.slice(3)
     this.rankList = res1.data.result.list.slice(0, 3)
     // 国内
     const res2 = await $apis.common.novelModulePage({moduleType: 8, ageNum: 1,pageSize: 10})

+ 47 - 12
src/components/tools-mall/index.ux

@@ -5,7 +5,9 @@
       <div class="box" for="(index, item) in hotList">
           <text class="title_"> {{ item.title }}</text>
          <div class="hot-list" >
-           <div class="hot-item" style="background-color: {{items.bg}}" 
+           background: linear-gradient(to bottom, #a9d4ff, #cce6ff);
+           <!-- style="background-color: {{items.bg}}" -->
+           <div class="hot-item {{ items.bg }}"
             @click="toPage(items.path)" for="(indexs, items) in item.list">
             <text class="icon-font-span icon {{ items.name =='一键省电'?'left_0':'left_28' }}" style="color:{{  items.color }}">{{ items.icon }}</text>
             <text class="name"  style="color:{{ items.color }};"> {{  items.name }}</text>
@@ -31,27 +33,27 @@ export default {
 		{
 			title:'基础功能',
 			list:[
-				{name:'一键省电',icon:'\ue607',bg:'#cfffcd',color:'#60b956',path:'yiJianShengDian'},
-				{name:'声波除尘',icon:'\ue7dc',bg:'#ffd8db',color:'#fb5e53',path:'shengBoChuChen'},
-				{name:'网络信息',icon:'\ue61d',bg:'#ccccfe',color:'#8370ee',path:'wangLuoXinXi'},
-				{name:'手机测距',icon:'\uea07',bg:'#80fafb',color:'#02cfdf',path:'shouJiCeJu'},
-				{name:'WiFi管理',icon:'\ue76c',bg:'#9ed1fe',color:'#3d9aee',path:'wifiGuanLi'},
-				{name:'手机清理',icon:'\ue60e',bg:'#fad2ec',color:'#ff4bb9',path:'shouJiQingLi'},
-				{name:'精选壁纸',icon:'\ue640',bg:'#fec2f8',color:'#c95884',path:'jingXuanBiZhi'},
+				{name:'一键省电',icon:'\ue607',bg:'bg_cfffcd',color:'#60b956',path:'yiJianShengDian'},
+				{name:'声波除尘',icon:'\ue7dc',bg:'bg_ffd8db',color:'#fb5e53',path:'shengBoChuChen'},
+				{name:'网络信息',icon:'\ue61d',bg:'bg_ccccfe',color:'#8370ee',path:'wangLuoXinXi'},
+				{name:'手机测距',icon:'\uea07',bg:'bg_80fafb',color:'#02cfdf',path:'shouJiCeJu'},
+				{name:'WiFi管理',icon:'\ue76c',bg:'bg_9ed1fe',color:'#3d9aee',path:'wifiGuanLi'},
+				{name:'手机清理',icon:'\ue60e',bg:'bg_fad2ec',color:'#ff4bb9',path:'shouJiQingLi'},
+				{name:'精选壁纸',icon:'\ue640',bg:'bg_fec2f8',color:'#c95884',path:'jingXuanBiZhi'},
 			],
 		},
 		{
 			title:'趣味测评',
 			list:[
-				{name:'趣味测评',icon:'\ue6cc',bg:'#e8ffc4',color:'#98ec05',path:'quWeiCePing'},
+				{name:'趣味测评',icon:'\ue6cc',bg:'bg_e8ffc4',color:'#98ec05',path:'quWeiCePing'},
 			],
 		},
 		{
 			title:'知识课堂',
 			list:[
-				{name:'养生课堂',icon:'\ue650',bg:'#fdd1c0',color:'#fc7f43',path:'yangShengKeTang'},
-				{name:'运动计步',icon:'\ue61c',bg:'#9ce4fd',color:'#3d9afb',path:'yunDongJiBu'},
-				{name:'字体大小',icon:'\ue7b1',bg:'#edcbfd',color:'#d617d1',path:'ziTiDaXiao'},
+				{name:'养生课堂',icon:'\ue650',bg:'bg_fdd1c0',color:'#fc7f43',path:'yangShengKeTang'},
+				{name:'运动计步',icon:'\ue61c',bg:'bg_9ce4fd',color:'#3d9afb',path:'yunDongJiBu'},
+				{name:'字体大小',icon:'\ue7b1',bg:'bg_edcbfd',color:'#d617d1',path:'ziTiDaXiao'},
 			],
 		}
 	],
@@ -82,6 +84,39 @@ export default {
   font-family: iconfont;
   src: url("/assets/iconfont/iconfont.ttf");
 }
+.bg_cfffcd{
+  background: linear-gradient(to bottom, #cfffcd, #fff);
+}
+.bg_ffd8db{
+  background: linear-gradient(to bottom, #ffd8db, #fff);
+}
+.bg_ccccfe{
+  background: linear-gradient(to bottom, #ccccfe, #fff);
+}
+.bg_80fafb{
+  background: linear-gradient(to bottom, #80fafb, #fff);
+}
+.bg_9ed1fe{
+  background: linear-gradient(to bottom, #9ed1fe, #fff);
+}
+.bg_fad2ec{
+  background: linear-gradient(to bottom, #fad2ec, #fff);
+}
+.bg_fec2f8{
+  background: linear-gradient(to bottom, #fec2f8, #fff);
+}
+.bg_e8ffc4{
+  background: linear-gradient(to bottom, #e8ffc4, #fff);
+}
+.bg_fdd1c0{
+  background: linear-gradient(to bottom, #fdd1c0, #fff);
+}
+.bg_9ce4fd{
+  background: linear-gradient(to bottom, #9ce4fd, #fff);
+}
+.bg_edcbfd{
+  background: linear-gradient(to bottom, #edcbfd, #fff);
+}
 .icon-font-span {
   font-family: iconfont;
   font-size: 92px;

+ 4 - 0
src/helper/apis/common.js

@@ -31,4 +31,8 @@ export default {
   novelDetail(data) {
     return $ajax.post('novel/detail', data)
   },
+  /** 链接详情  linkId */
+  ytNovelLinkDetail(data) {
+    return $ajax.get('ytNovelLink/detail', data)
+  },
 }

+ 28 - 15
src/pages/book-content/index.ux

@@ -20,11 +20,6 @@
               {{ content }}</richtext>
             <text if="{{totalPage > 0}}" class="index-class">{{ currentPage }} / {{ totalPage }} </text>
           </div>
-          <!-- <swiper class="swiper" loop="{{false}}" index="{{currentPage}}" 
-          onchange="pageChange" indicator="{{ false }}">
-            <text class="book-text swiper-item" for="(index,item) in  pages" 
-            style="{{contentStyle}}">{{item}}</text>
-          </swiper> -->
         </list-item>
         <!-- <list-item type="content" onclick="showOrHidePop" show="{{!!content}}">
           <div style="width: 100%;justify-content: flex-end;">
@@ -54,9 +49,6 @@
           </div>
         </list-item>
       </list>
-      <!-- <swiper class="swiper" index="{{currentPage}}" onchange="pageChange">
-            <text class="book-text swiper-item" for="(index,item) in  pages" style="{{contentStyle}}">{{item}}</text>
-      </swiper> -->
       <div class="pop-layer" show="{{showPop}}">
         <div class="header">
           <image src="https://ytnovels.oss-cn-shanghai.aliyuncs.com/appStatic/images/back.svg" onclick="back"></image>
@@ -79,8 +71,8 @@
           </div>
         </div> -->
       </div>
-      <div class="pop-layer" if="{{showCategory}}">
-        <div class="footer">
+      <div class="pop-layer" if="{{showCategory}}"  onclick="showOrHidePop">
+        <div class="footer" onclick="onChildClickHandler">
           <div class="font-change">
             <text
               class="font-item {{$item.font === userSetting.fontFamily ? 'selected' : ''}}"
@@ -122,9 +114,6 @@
             </text>
             <text @click="goToContents" class="btn-bottom btn-margin"
               >目录</text
-            >
-             <text @click="showCategoryFn" class="btn-bottom btn-margin"
-              >收起</text
             >
             <text
               @click="switchChapter('next')"
@@ -151,9 +140,10 @@ export default {
     bookId: 1,
     bookTitle: '红楼梦',
     chapterId: 1,
-    total: 120
+    total: 100
   },
   private: {
+    shelfList:[],//书架列表
     totalPage: 0,
     index: 0,
     showRich:false,
@@ -221,6 +211,10 @@ export default {
         console.log(`handling success, brand = ${ ret.screenHeight } ${ ret.screenWidth }`)
       }
     })
+    $utils.getStorage('bookshelf').then(value => {
+        console.log('value  bookshelf',value)
+          this.shelfList = JSON.parse(value)
+      })
     //搜索优化
     this.$page.setMeta({
       title: this.bookTitle,
@@ -324,6 +318,20 @@ export default {
     this.getTxtContent(infos.content)
     this.$element('list').scrollTo({ index: 0 })
     this.currentPage = 1
+    this.editChapterId()
+  },
+  // 修改书架中当前阅读的章节
+  editChapterId (){
+      // 找到bookId相等的 修改底下的chapterId
+      let index = this.shelfList.findIndex((item) => {
+        return item.id == this.bookId
+      })
+      if(index > -1){
+        this.shelfList[index].chapterId = this.chapterId
+        $utils.setShelfList(this.shelfList, true) // 保存到全局变量和storage
+      }
+      console.log('index3444',index)
+
   },
   goToContents() {
     $utils.route2theUrl('pages/contents', {
@@ -341,6 +349,11 @@ export default {
       this.showPop = !this.showPop
     }
   },
+   onChildClickHandler (evt) {
+      console.info(`触发子组件事件:类型:${evt.type}`)
+      // 阻止事件冒泡
+      evt.stopPropagation()
+    },
   back() {
     $utils.routerBack()
   },
@@ -415,7 +428,7 @@ export default {
   position: fixed;
   font-size: 30px;
   color: grey;
-  left: 50px;
+  left: 0px;
   bottom: 10px;
 }
 

+ 21 - 8
src/pages/book-detail/index.ux

@@ -16,8 +16,8 @@
       <list-item type="sub-title" class="sub-title">
         <text class="text-title">共{{ bookInfo.novelChapterCount || 100 }}章</text>
         <div @click="goToContents">
-          <text class="text-remark">{{ bookInfo?.createTime?.split('T')[0] || '' }}更新</text>
-          <text class="text-remark iconfont">&#xe6d7;</text>
+          <text class="text-remark">{{ bookInfo.createTime && bookInfo.createTime.split('T')[0] || '' }}更新</text>
+          <text class="text-remark iconfont">&#xe622;</text>
         </div>
       </list-item>
       <!-- <list-item type="sub-title" class="detail-title">
@@ -30,7 +30,6 @@
       <!-- <list-item type="comment" for="{{commentList}}">
         <comment-item-simple
           item="{{$item}}"
-          onreply-comment="replyComment"
         ></comment-item-simple>
       </list-item> -->
       <!-- <list-item type="detail-title" class="detail-title">
@@ -66,28 +65,41 @@ import { bookListData } from '../../assets/data/book-list.js'
 import { commentData } from '../../assets/data/comment.js'
 export default {
   public: {
-    info: ''
+    info: '',
+    linkId:'',//链接id
   },
   private: {
     bookInfo: {},
     commentList: commentData.slice(0, 3),
     recommandBook: bookListData.slice(0, 3),
     isInShelf: false,
-    shelfList: []
+    shelfList: [],
+    shelfInfo:{},//书架信息
+    linkInfo:{},
   },
   async onInit() {
     // 此处直接将图书内容传进来,实际开发中也可以传入id查询图书信息
     this.bookInfo = this.info ? JSON.parse(this.info) : {}
-    console.log('info',this.bookInfo)
+    if(this.linkId){
+      this.linkId = this.linkId.replace(/\?/g, '');
+      const detail = await $apis.common.ytNovelLinkDetail({ linkId:this.linkId })
+      this.linkInfo = detail.data
+      // channelName 渠道名称 phoneTypeName 机型名称
+      this.bookInfo.novelId = detail.data.novelId
+    }
     // $shelfList:全局变量
     this.shelfList = $shelfList
     this.isInShelf = !!this.shelfList.filter(book => {
       return book.id === this.bookInfo.id
     }).length
+    if(this.isInShelf){ // 如果在书架中
+      this.shelfInfo = this.shelfList.filter(book => {
+        return book.id === this.bookInfo.id
+      })[0] || {}
+    }
     // 如果没有书名 有id
     if(this.bookInfo.novelId){
       const res = await $apis.common.novelDetail({id:this.bookInfo.novelId})
-      console.log('resss',res)
       this.bookInfo = res.data.ytNovel
     }
   },
@@ -113,7 +125,7 @@ export default {
       bookId: this.bookInfo.id,
       bookTitle: this.bookInfo.novelName,//title,
       total: this.bookInfo.novelChapterCount,//count
-      chapterId:1,
+      chapterId:this.shelfInfo.chapterId || 1, // 如果在书架中
     })
   },
   addToShelf() {
@@ -128,6 +140,7 @@ export default {
       return
     }
     this.isInShelf = true
+    this.bookInfo.chapterId = 1 // 设置默认章节为第一章
     this.shelfList.push(this.bookInfo)
     $utils.setShelfList(this.shelfList, true) // 保存到全局变量和storage
     this.$child('toast').showToast({

+ 27 - 24
src/pages/contents/index.ux

@@ -6,12 +6,12 @@
   <div class="page-wrapper">
     <div class="title-bar">
       <text class="text-black">共{{ total }}章</text>
-      <div @click="switchOrder">
+      <!-- <div @click="switchOrder">
         <text class="text-primary iconfont">{{
           reverse ? '&#xe624;' : '&#xe6d6;'
         }}</text>
         <text class="text-primary">{{ reverse ? '正序' : '倒序' }}</text>
-      </div>
+      </div> -->
     </div>
     <contents-list list="{{contents}}" ondetail="detail"></contents-list>
     <div class="bottom-bar">
@@ -58,9 +58,9 @@ export default {
     this.totalList = infos
     console.log('infos',infos)
     this.total = infos.length
+    this.pageCount = Math.ceil(this.total / 50)
     this.lastList = infos.slice(0, 50)
     this.nextList = infos.slice(50)
-
     // this.total = contentsData[this.bookId].length
     // this.lastList = contentsData[this.bookId].slice(0, 50)
     // this.nextList = contentsData[this.bookId].slice(50)
@@ -84,27 +84,30 @@ export default {
   },
   switchList() {
     // 开发时应该调用接口,根据bookId,pageNo,reverse获取章节目录。此处是模拟翻页/改变顺序。
-    if (this.reverse) {
-      if (this.pageNo === 1) {
-        this.pageNumStart = this.totalList.length
-        this.pageNumEnd = 51
-        this.contents = this.nextList.reverse()
-      } else if (this.pageNo === 2) {
-        this.pageNumStart = 50
-        this.pageNumEnd = 1
-        this.contents = this.lastList.reverse()
-      }
-    } else {
-      if (this.pageNo === 1) {
-        this.pageNumStart = 1
-        this.pageNumEnd = 50
-        this.contents = this.lastList
-      } else if (this.pageNo === 2) {
-        this.pageNumStart = 51
-        this.pageNumEnd = this.totalList.length
-        this.contents = this.nextList
-      }
-    }
+    this.pageNumStart = (this.pageNo - 1) * 50 + 1
+    this.pageNumEnd = this.pageNo * 50
+    this.contents = this.totalList.slice((this.pageNo - 1) * 50,50 * (this.pageNo))
+    // if (this.reverse) {
+    //   if (this.pageNo === 1) {
+    //     this.pageNumStart = this.totalList.length
+    //     this.pageNumEnd = 51
+    //     this.contents = this.nextList.reverse()
+    //   } else if (this.pageNo === 2) {
+    //     this.pageNumStart = 50
+    //     this.pageNumEnd = 1
+    //     this.contents = this.lastList.reverse()
+    //   }
+    // } else {
+    //   if (this.pageNo === 1) {
+    //     this.pageNumStart = 1
+    //     this.pageNumEnd = 50
+    //     this.contents = this.lastList
+    //   } else if (this.pageNo === 2) {
+    //     this.pageNumStart = 51
+    //     this.pageNumEnd = this.totalList.length
+    //     this.contents = this.nextList
+    //   }
+    // }
   },
   detail(param) {
     let item = param.detail.item

+ 16 - 4
src/pages/main/index.ux

@@ -4,6 +4,7 @@
 <import name="tools-mall" src="../../components/tools-mall"></import>
 <import name="my" src="../../components/my"></import>
 <import name="red-packet" src="../../components/red-packet"></import>
+<import name="top-button" src="../../components/top-button"></import>
 
 <template>
   <div class="page-wrapper">
@@ -28,11 +29,14 @@
       </tab-bar>
     </tabs>
     <red-packet></red-packet>
+    <!-- <top-button></top-button> -->
   </div>
 </template>
 
 <script>
 import { bookListData } from '../../assets/data/book-list.js'
+import device from '@system.device'
+
 export default {
   private: {
     tabList: [
@@ -64,14 +68,23 @@ export default {
     ],
     selectedTab: 1,
     defaultShelfList: [],//bookListData.slice(0, 2),
-    shelfList: []
+    shelfList: [],
+    brand:'vivo', // 根据机型修改样式
   },
-  onInit() {
+  async onInit() {
     this.getBookShelf()
+    var that = this
+    device.getInfo({
+     success: function(ret) {
+        that.brand = ret.brand
+        $utils.setStorage('brand',ret.brand)
+        // const data = await $utils.getStorage('brand')
+        console.log(`handling success, brand = ${ JSON.stringify(ret) }`)
+      }
+    })
   },
   getBookShelf (){
       $utils.getStorage('bookshelf').then(value => {
-        console.log('value  bookshelf',value)
         // 从storage获取
         if (!value) {
           this.shelfList = this.defaultShelfList
@@ -86,7 +99,6 @@ export default {
   changeTab(e) {
     let index = e.index === undefined ? 1 : e.index
     this.selectedTab = index
-    console.log('index',index)
     if(index == 0){
       this.getBookShelf()
     }