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

248 lines
5.0 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 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. @click="navigateToDetail(book.id)"
  38. :book="book">
  39. </novelItem>
  40. </view>
  41. <uv-empty v-if="list.length == 0" text="还没有呢"/>
  42. </view>
  43. </uv-vtabs-item>
  44. </uv-vtabs>
  45. </view>
  46. <!-- tabbar -->
  47. <tabber select="category" />
  48. </view>
  49. </template>
  50. <script>
  51. import {
  52. mapState
  53. } from 'vuex'
  54. import tabber from '@/components/base/tabbar.vue'
  55. import novelItem from '@/components/novel/novelItem.vue'
  56. import mixinsList from '@/mixins/list.js'
  57. export default {
  58. mixins: [mixinsList],
  59. components: {
  60. tabber,
  61. novelItem
  62. },
  63. data() {
  64. return {
  65. mixinsListApi: '',
  66. current : 0,
  67. currentChildren : 0,
  68. categoryList: [],
  69. category: [],
  70. }
  71. },
  72. computed: {
  73. },
  74. onLoad({
  75. search,
  76. cid
  77. }) {
  78. if (search) {
  79. this.queryParams.title = search
  80. }
  81. // this.$store.commit('getCategoryList')
  82. // if(this.category.length > 0 && cid){
  83. // this.category.forEach((n, i) => {
  84. // if(n.id == cid){
  85. // this.current = i
  86. // }
  87. // })
  88. // // this.queryParams.classId = cid
  89. // }else if (this.category.length > 0) {
  90. // // this.queryParams.classId = this.category[0].id
  91. // }
  92. },
  93. onShow() {
  94. this.getCategoryList()
  95. // this.getBookAreaList()
  96. },
  97. methods: {
  98. change(e) {
  99. // this.queryParams.classId = this.category[e].id
  100. this.currentChildren = e
  101. // 更新对应分类的书籍列表
  102. this.getData()
  103. },
  104. clickTabs({index}){
  105. this.current = index
  106. this.currentChildren = 0
  107. // 更新对应分类的书籍列表
  108. this.getData()
  109. },
  110. search(){
  111. this.getData()
  112. },
  113. beforeGetData(){
  114. let data = {}
  115. if(this.categoryList[this.currentChildren].id){
  116. data.shopCion = this.categoryList[this.currentChildren].id
  117. }
  118. if(this.category[this.current].id){
  119. data.shopClass = this.category[this.current].id
  120. }
  121. return data
  122. },
  123. async getCategoryList() {
  124. // const data = await this.$fetch('getCategoryList')
  125. // this.category = data
  126. let [data1, data2] = await Promise.all([this.$fetch('getCategoryList'), this.$fetch('getBookAreaList')])
  127. this.category = [
  128. {
  129. title : '全部'
  130. },
  131. ...data1,
  132. ]
  133. this.categoryList = data2
  134. this.mixinsListApi = 'getRecommendList'
  135. this.queryParams.pageSize = 999999
  136. this.getData()
  137. },
  138. async getBookAreaList() {
  139. const data = await this.$fetch('getBookAreaList')
  140. this.categoryList = data
  141. },
  142. navigateToDetail(id) {
  143. // 跳转到小说详情页
  144. this.$utils.navigateTo(`/pages_order/novel/novelDetail?id=${id}`)
  145. },
  146. }
  147. }
  148. </script>
  149. <style scoped lang="scss">
  150. .page {
  151. /deep/ .uv-vtabs {
  152. height: calc(100vh - 460rpx) !important;
  153. }
  154. /deep/ .uv-vtabs__bar {
  155. height: calc(100vh - 460rpx) !important;
  156. }
  157. /deep/ .uv-vtabs__content {
  158. height: calc(100vh - 460rpx) !important;
  159. }
  160. .search {
  161. position: relative;
  162. background: #FFFFFF;
  163. margin: 20rpx;
  164. border-radius: 41rpx;
  165. padding: 10rpx 20rpx;
  166. display: flex;
  167. align-items: center;
  168. /deep/ .uv-search__action {
  169. background-color: $uni-color;
  170. color: #FFFFFF;
  171. padding: 10rpx 20rpx;
  172. border-radius: 30rpx;
  173. }
  174. }
  175. &::v-deep .uv-vtabs__content {
  176. background: transparent !important;
  177. overflow: hidden;
  178. }
  179. }
  180. .category {
  181. font-size: 30rpx;
  182. color: #333;
  183. .category-title{
  184. position: relative;
  185. display: flex;
  186. justify-content: center;
  187. align-items: center;
  188. height: 120rpx;
  189. &::before,
  190. &::after {
  191. position: absolute;
  192. top: 50%;
  193. content: '';
  194. width: 10%;
  195. border-top: 2rpx solid black;
  196. }
  197. &::before {
  198. left: 25%;
  199. }
  200. &::after {
  201. right: 25%;
  202. }
  203. }
  204. &::v-deep .uv-vtabs {
  205. width: 750rpx;
  206. overflow: hidden;
  207. }
  208. .list {
  209. width: 100%;
  210. padding: 0rpx 20rpx;
  211. box-sizing: border-box;
  212. }
  213. .category-item {
  214. padding: 0 20rpx;
  215. .novel-list {
  216. width: 100%;
  217. display: flex;
  218. flex-direction: column;
  219. gap: 10rpx;
  220. }
  221. }
  222. }
  223. </style>