小说小程序前端代码仓库(小程序)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
2.2 KiB

  1. <template>
  2. <view class="page">
  3. <navbar title="搜素" leftClick @leftClick="$utils.navigateBack" />
  4. <view class="search">
  5. <uv-search bgColor="#ffffff"
  6. placeholder="搜索"
  7. inputAlign="left"
  8. @search="getData"
  9. @clear="getData"
  10. @custom="getData"
  11. v-model="queryParams.name"
  12. showAction="false"></uv-search>
  13. </view>
  14. <view class="tabs">
  15. <uv-tabs
  16. :list="category"
  17. :activeStyle="{color : '#000', fontWeight : 600}"
  18. lineColor="#000"
  19. :inactiveStyle="{color: '#000'}"
  20. lineHeight="8rpx"
  21. lineWidth="50rpx"
  22. :current="current"
  23. keyName="title"
  24. @click="clickTabs"></uv-tabs>
  25. </view>
  26. <view class="novel-list">
  27. <novel-item v-for="(item, index) in list"
  28. @click="navigateToDetail(item.id)"
  29. :key="index" :book="item" />
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import novelItem from '@/components/novel/novelItem.vue'
  35. import mixinsList from '@/mixins/list.js'
  36. export default {
  37. mixins: [mixinsList],
  38. components: {
  39. novelItem,
  40. },
  41. data() {
  42. return {
  43. mixinsListApi : '',
  44. current : 0,
  45. category: [],
  46. }
  47. },
  48. onLoad() {
  49. this.getCategoryList()
  50. },
  51. methods: {
  52. async getCategoryList() {
  53. const data = await this.$fetch('getCategoryList')
  54. data.unshift({
  55. title : '全部'
  56. })
  57. this.category = data
  58. this.mixinsListApi = 'getRecommendList'
  59. this.getData()
  60. },
  61. beforeGetData(){
  62. let params = {}
  63. if(this.category[this.current].id){
  64. params.shopClass = this.category[this.current].id
  65. }
  66. return params
  67. },
  68. navigateToDetail(id) {
  69. // 跳转到小说详情页
  70. this.$utils.navigateTo(`/pages_order/novel/novelDetail?id=${id}`)
  71. },
  72. clickTabs({index}){
  73. this.current = index
  74. // 更新对应分类的书籍列表
  75. this.getData()
  76. },
  77. }
  78. }
  79. </script>
  80. <style scoped lang="scss">
  81. .search {
  82. background-color: #fff;
  83. border-radius: 40rpx;
  84. display: flex;
  85. padding: 20rpx;
  86. margin: 20rpx;
  87. :deep(.uv-search__content) {
  88. box-shadow: 0 5rpx 15rpx rgba(0, 0, 0, 0.1);
  89. }
  90. }
  91. .novel-list{
  92. padding: 20rpx;
  93. }
  94. </style>