小说小程序前端代码仓库(小程序)
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.

232 lines
4.6 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. <template>
  2. <view class="page">
  3. <!-- 导航栏 -->
  4. <navbar title="书城"
  5. leftClick
  6. @leftClick="$utils.navigateBack"
  7. />
  8. <!-- 分类商品列表 -->
  9. <view class="category"
  10. >
  11. <view class="tabs">
  12. <uv-tabs
  13. :list="category"
  14. :activeStyle="{color : '#000', fontWeight : 600}"
  15. lineColor="#000"
  16. :inactiveStyle="{color: '#000'}"
  17. lineHeight="8rpx"
  18. lineWidth="50rpx"
  19. :current="current"
  20. keyName="title"
  21. @click="clickTabs"></uv-tabs>
  22. </view>
  23. <uv-vtabs
  24. :list="categoryList"
  25. :current="currentChildren"
  26. keyName="title"
  27. :chain="false"
  28. :barItemActiveLineStyle="{background : '#0A2463'}"
  29. :barItemActiveStyle="{color : '#0A2463', fontWeight : 600}"
  30. @change="change">
  31. <uv-vtabs-item>
  32. <view class="category-item">
  33. <view class="novel-list" v-if="list.length > 0">
  34. <novelItem
  35. v-for="(book, index) in list"
  36. :key="index"
  37. :book="book">
  38. </novelItem>
  39. </view>
  40. <uv-empty v-if="list.length == 0" text="还没有呢"/>
  41. </view>
  42. </uv-vtabs-item>
  43. </uv-vtabs>
  44. </view>
  45. <!-- tabbar -->
  46. <tabber select="category" />
  47. </view>
  48. </template>
  49. <script>
  50. import {
  51. mapState
  52. } from 'vuex'
  53. import tabber from '@/components/base/tabbar.vue'
  54. import novelItem from '@/components/novel/novelItem.vue'
  55. import mixinsList from '@/mixins/list.js'
  56. export default {
  57. mixins: [mixinsList],
  58. components: {
  59. tabber,
  60. novelItem
  61. },
  62. data() {
  63. return {
  64. mixinsListApi: '',
  65. current : 0,
  66. currentChildren : 0,
  67. categoryList: [],
  68. category: [],
  69. }
  70. },
  71. computed: {
  72. },
  73. onLoad({
  74. search,
  75. cid
  76. }) {
  77. if (search) {
  78. this.queryParams.title = search
  79. }
  80. // this.$store.commit('getCategoryList')
  81. // if(this.category.length > 0 && cid){
  82. // this.category.forEach((n, i) => {
  83. // if(n.id == cid){
  84. // this.current = i
  85. // }
  86. // })
  87. // // this.queryParams.classId = cid
  88. // }else if (this.category.length > 0) {
  89. // // this.queryParams.classId = this.category[0].id
  90. // }
  91. },
  92. onShow() {
  93. this.getCategoryList()
  94. // this.getBookAreaList()
  95. },
  96. methods: {
  97. change(e) {
  98. // this.queryParams.classId = this.category[e].id
  99. this.currentChildren = e
  100. // 更新对应分类的书籍列表
  101. this.getData()
  102. },
  103. clickTabs({index}){
  104. this.current = index
  105. this.currentChildren = 0
  106. // 更新对应分类的书籍列表
  107. this.getData()
  108. },
  109. search(){
  110. this.getData()
  111. },
  112. beforeGetData(){
  113. return {
  114. shopCion : this.categoryList[this.currentChildren].id,
  115. shopClass : this.category[this.current].id,
  116. }
  117. },
  118. async getCategoryList() {
  119. // const data = await this.$fetch('getCategoryList')
  120. // this.category = data
  121. let [data1, data2] = await Promise.all([this.$fetch('getCategoryList'), this.$fetch('getBookAreaList')])
  122. this.category = data1
  123. this.categoryList = data2
  124. this.mixinsListApi = 'getRecommendList'
  125. this.queryParams.pageSize = 999999
  126. this.getData()
  127. },
  128. async getBookAreaList() {
  129. const data = await this.$fetch('getBookAreaList')
  130. this.categoryList = data
  131. },
  132. }
  133. }
  134. </script>
  135. <style scoped lang="scss">
  136. .page {
  137. /deep/ .uv-vtabs {
  138. height: calc(100vh - 460rpx) !important;
  139. }
  140. /deep/ .uv-vtabs__bar {
  141. height: calc(100vh - 460rpx) !important;
  142. }
  143. /deep/ .uv-vtabs__content {
  144. height: calc(100vh - 460rpx) !important;
  145. }
  146. .search {
  147. position: relative;
  148. background: #FFFFFF;
  149. margin: 20rpx;
  150. border-radius: 41rpx;
  151. padding: 10rpx 20rpx;
  152. display: flex;
  153. align-items: center;
  154. /deep/ .uv-search__action {
  155. background-color: $uni-color;
  156. color: #FFFFFF;
  157. padding: 10rpx 20rpx;
  158. border-radius: 30rpx;
  159. }
  160. }
  161. &::v-deep .uv-vtabs__content {
  162. background: transparent !important;
  163. overflow: hidden;
  164. }
  165. }
  166. .category {
  167. font-size: 30rpx;
  168. color: #333;
  169. .category-title{
  170. position: relative;
  171. display: flex;
  172. justify-content: center;
  173. align-items: center;
  174. height: 120rpx;
  175. &::before,
  176. &::after {
  177. position: absolute;
  178. top: 50%;
  179. content: '';
  180. width: 10%;
  181. border-top: 2rpx solid black;
  182. }
  183. &::before {
  184. left: 25%;
  185. }
  186. &::after {
  187. right: 25%;
  188. }
  189. }
  190. &::v-deep .uv-vtabs {
  191. width: 750rpx;
  192. overflow: hidden;
  193. }
  194. .list {
  195. width: 100%;
  196. padding: 0rpx 20rpx;
  197. box-sizing: border-box;
  198. }
  199. .category-item {
  200. padding: 0 20rpx;
  201. .novel-list {
  202. width: 100%;
  203. display: flex;
  204. flex-direction: column;
  205. gap: 10rpx;
  206. }
  207. }
  208. }
  209. </style>