|
@@ -1,5 +1,6 @@
|
|
|
import {
|
|
|
- getCategoryWorks
|
|
|
+ getCategoryWorks,
|
|
|
+ searchWorks
|
|
|
} from '~/api/works'
|
|
|
import reachBottom from '~/mixins/reachBottom'
|
|
|
Page({
|
|
@@ -17,8 +18,7 @@ Page({
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad(options) {
|
|
|
- let title = '分类'
|
|
|
- console.log(options);
|
|
|
+ let title = '搜索'
|
|
|
// 没有二级分类
|
|
|
if (options.id) {
|
|
|
this.setData({
|
|
@@ -43,6 +43,9 @@ Page({
|
|
|
},
|
|
|
// 获取分类的内容
|
|
|
loadMore() {
|
|
|
+ if (this.data.type == 'search') {
|
|
|
+ return
|
|
|
+ }
|
|
|
let columnId = this.data.childType ? this.data.childType : this.data.categoryList[this.data.currentIndex].id
|
|
|
this.getData(getCategoryWorks, {
|
|
|
columnId
|
|
@@ -67,15 +70,27 @@ Page({
|
|
|
text: detail.value
|
|
|
})
|
|
|
},
|
|
|
- search() {
|
|
|
- console.log("搜索");
|
|
|
+ async search() {
|
|
|
+ if (!this.data.text) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let res = await searchWorks({
|
|
|
+ title: this.data.text,
|
|
|
+ grade: 'PRIMARY_FIRST_GRADE'
|
|
|
+ })
|
|
|
+ let list = res.map(item => {
|
|
|
+ return {
|
|
|
+ readAmount: item.readAmount,
|
|
|
+ ...item.userRead
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ list
|
|
|
+ })
|
|
|
},
|
|
|
goRead({
|
|
|
currentTarget
|
|
|
}) {
|
|
|
- console.log(
|
|
|
- currentTarget.dataset
|
|
|
- );
|
|
|
wx.navigateTo({
|
|
|
url: `/pages/reading/index?videoId=${currentTarget.dataset.id}`
|
|
|
})
|