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

247 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. // 更新对应分类的书籍列表
  107. this.getData()
  108. },
  109. search(){
  110. this.getData()
  111. },
  112. beforeGetData(){
  113. let data = {}
  114. if(this.categoryList[this.currentChildren].id){
  115. data.shopCion = this.categoryList[this.currentChildren].id
  116. }
  117. if(this.category[this.current].id){
  118. data.shopClass = this.category[this.current].id
  119. }
  120. return data
  121. },
  122. async getCategoryList() {
  123. // const data = await this.$fetch('getCategoryList')
  124. // this.category = data
  125. let [data1, data2] = await Promise.all([this.$fetch('getCategoryList'), this.$fetch('getBookAreaList')])
  126. this.category = [
  127. {
  128. title : '全部'
  129. },
  130. ...data1,
  131. ]
  132. this.categoryList = data2
  133. this.mixinsListApi = 'getRecommendList'
  134. this.queryParams.pageSize = 999999
  135. this.getData()
  136. },
  137. async getBookAreaList() {
  138. const data = await this.$fetch('getBookAreaList')
  139. this.categoryList = data
  140. },
  141. navigateToDetail(id) {
  142. // 跳转到小说详情页
  143. this.$utils.navigateTo(`/pages_order/novel/novelDetail?id=${id}`)
  144. },
  145. }
  146. }
  147. </script>
  148. <style scoped lang="scss">
  149. .page {
  150. /deep/ .uv-vtabs {
  151. height: calc(100vh - 460rpx) !important;
  152. }
  153. /deep/ .uv-vtabs__bar {
  154. height: calc(100vh - 460rpx) !important;
  155. }
  156. /deep/ .uv-vtabs__content {
  157. height: calc(100vh - 460rpx) !important;
  158. }
  159. .search {
  160. position: relative;
  161. background: #FFFFFF;
  162. margin: 20rpx;
  163. border-radius: 41rpx;
  164. padding: 10rpx 20rpx;
  165. display: flex;
  166. align-items: center;
  167. /deep/ .uv-search__action {
  168. background-color: $uni-color;
  169. color: #FFFFFF;
  170. padding: 10rpx 20rpx;
  171. border-radius: 30rpx;
  172. }
  173. }
  174. &::v-deep .uv-vtabs__content {
  175. background: transparent !important;
  176. overflow: hidden;
  177. }
  178. }
  179. .category {
  180. font-size: 30rpx;
  181. color: #333;
  182. .category-title{
  183. position: relative;
  184. display: flex;
  185. justify-content: center;
  186. align-items: center;
  187. height: 120rpx;
  188. &::before,
  189. &::after {
  190. position: absolute;
  191. top: 50%;
  192. content: '';
  193. width: 10%;
  194. border-top: 2rpx solid black;
  195. }
  196. &::before {
  197. left: 25%;
  198. }
  199. &::after {
  200. right: 25%;
  201. }
  202. }
  203. &::v-deep .uv-vtabs {
  204. width: 750rpx;
  205. overflow: hidden;
  206. }
  207. .list {
  208. width: 100%;
  209. padding: 0rpx 20rpx;
  210. box-sizing: border-box;
  211. }
  212. .category-item {
  213. padding: 0 20rpx;
  214. .novel-list {
  215. width: 100%;
  216. display: flex;
  217. flex-direction: column;
  218. gap: 10rpx;
  219. }
  220. }
  221. }
  222. </style>