吉光研途前端代码仓库
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.

290 lines
7.0 KiB

3 days ago
3 days ago
3 days ago
3 days ago
3 days ago
3 days ago
3 days ago
3 days ago
3 days ago
  1. <template>
  2. <view class="page__view">
  3. <view class="bg"></view>
  4. <view class="main">
  5. <!-- 搜索栏 -->
  6. <view class="section search">
  7. <uv-search v-model="keyword" placeholder="输入关键词搜索" bgColor="#FBFBFB" @custom="search" @search="search">
  8. <template #prefix>
  9. <image class="search-icon" src="@/static/image/icon-search.png" mode="widthFix"></image>
  10. </template>
  11. </uv-search>
  12. </view>
  13. <!-- 轮播图 -->
  14. <view class="section swiper">
  15. <uv-swiper :list="bannerList" keyName="image" indicator indicatorMode="dot" indicatorActiveColor="#4883F9" indicatorInactiveColor="#FFFFFF" height="239rpx"></uv-swiper>
  16. </view>
  17. <view class="section card" v-for="(group, gIdx) in list" :key="group.id">
  18. <view class="card-header">
  19. <view class="card-header-title">{{ group.title }}</view>
  20. <view class="card-header-tag">JGYT</view>
  21. </view>
  22. <view class="card-content">
  23. <template v-if="gIdx === 0">
  24. <view class="card-item card-row" v-for="item in group.children" :key="item.id">
  25. <view class="flex info">
  26. <image class="info-icon" :src="item.image" mode="widthFix"></image>
  27. <view class="info-label">{{ item.title }}</view>
  28. </view>
  29. <button class="btn" @click="jumpToCategory(group.id, item.id, item.title)">查看</button>
  30. </view>
  31. </template>
  32. <template v-else>
  33. <view class="card-box">
  34. <view class="card-item info" v-for="item in group.children" :key="item.id" @click="jumpToCategory(group.id, item.id, item.title)">
  35. <image class="info-icon" :src="item.image" mode="widthFix"></image>
  36. <view class="info-label">{{ item.title }}</view>
  37. </view>
  38. </view>
  39. </template>
  40. </view>
  41. </view>
  42. </view>
  43. <tabber select="home" />
  44. </view>
  45. </template>
  46. <script>
  47. import tabber from '@/components/base/tabbar.vue'
  48. export default {
  49. components: {
  50. tabber,
  51. },
  52. data() {
  53. return {
  54. keyword: '',
  55. bannerList: [],
  56. list: [],
  57. }
  58. },
  59. onLoad() {
  60. this.fetchBanner()
  61. this.getData()
  62. },
  63. methods: {
  64. async getData() {
  65. try {
  66. let records = (await this.$fetch('queryCategoryThesisList', { pageNo: 1, pageSize: 1000 }))?.records
  67. let groups = []
  68. records.forEach(record => {
  69. if (record.hasChild == 1) {
  70. const { id, title, createTime } = record
  71. const index = groups.findIndex(group => group.id === id)
  72. if (index === -1) {
  73. groups.push({ id, title, createTime, children: [] })
  74. } else {
  75. groups[index].title = title
  76. groups[index].createTime = createTime
  77. }
  78. } else {
  79. const { pid, id, title, image, createTime } = record
  80. const index = groups.findIndex(group => group.id === pid)
  81. const item = { id, title, image, createTime }
  82. if (index === -1) {
  83. groups.push({ id: pid, children: [item] })
  84. } else {
  85. groups[index].children.push(item)
  86. }
  87. }
  88. })
  89. groups.forEach(group => {
  90. let { children } = group
  91. children.sort((a, b) => new Date(a.createTime).getTime() - new Date(b.createTime).getTime())
  92. group.children = children
  93. })
  94. groups.sort((a, b) => new Date(a.createTime).getTime() - new Date(b.createTime).getTime())
  95. this.list = groups
  96. } catch (err) {
  97. }
  98. },
  99. search() {
  100. uni.navigateTo({
  101. url: '/pages_order/thesis/search?search=' + this.keyword
  102. })
  103. this.keyword = ''
  104. },
  105. // 获取轮播图
  106. async fetchBanner() {
  107. try {
  108. this.bannerList = (await this.$fetch('queryBannerList', { type: '0' }))?.records // type:0-首页 1-案例 2-服务 3-其他
  109. } catch (err) {
  110. }
  111. },
  112. jumpToCategory(categoryOne, categoryTwo, title) {
  113. uni.navigateTo({
  114. url: `/pages_order/thesis/search?categoryOne=${categoryOne}&categoryTwo=${categoryTwo}&title=${title}`
  115. })
  116. },
  117. },
  118. }
  119. </script>
  120. <style scoped lang="scss">
  121. .bg {
  122. width: 100%;
  123. height: 438rpx;
  124. background-image: linear-gradient(#4883F9, #4883F9, #4883F9, #FCFDFF);
  125. }
  126. .main {
  127. position: absolute;
  128. top: 0;
  129. left: 0;
  130. width: 100%;
  131. padding: 192rpx 0 182rpx 0;
  132. }
  133. .section {
  134. margin: 0 18rpx 0 18rpx;
  135. }
  136. .search {
  137. width: calc(100% - 20rpx * 2);
  138. background-color: #FFFFFF;
  139. border-radius: 37rpx;
  140. padding: 13rpx 0 13rpx 18rpx;
  141. box-sizing: border-box;
  142. display: flex;
  143. align-items: center;
  144. /deep/ .uv-search__action {
  145. color: $uni-color;
  146. padding: 10rpx 18rpx;
  147. }
  148. &-icon {
  149. width: 26rpx;
  150. height: auto;
  151. }
  152. }
  153. .swiper {
  154. margin-top: 29rpx;
  155. margin-bottom: 26rpx;
  156. border-radius: 25rpx;
  157. overflow: hidden;
  158. /deep/ .uv-swiper-indicator__wrapper__dot {
  159. width: 15rpx;
  160. height: 15rpx;
  161. }
  162. /deep/ .uv-swiper-indicator__wrapper__dot--active {
  163. width: 15rpx;
  164. }
  165. }
  166. .card {
  167. margin-bottom: 35rpx;
  168. width: calc(100% - 20rpx * 2);
  169. box-sizing: border-box;
  170. padding-bottom: 45rpx;
  171. background-image: linear-gradient(164deg,#cfecfe 88rpx, #fcfdfe 176rpx);
  172. border: 3rpx solid #FFFFFF;
  173. border-radius: 25rpx;
  174. box-shadow: 0px 3rpx 6rpx 0rpx rgba(0,0,0,0.16);
  175. &-header {
  176. position: relative;
  177. width: 100%;
  178. box-sizing: border-box;
  179. padding: 46rpx 0 17rpx 33rpx;
  180. overflow: hidden;
  181. &-title {
  182. font-size: 42rpx;
  183. font-weight: 800;
  184. color: #000000;
  185. }
  186. &-tag {
  187. position: absolute;
  188. top: -40rpx;
  189. right: 12rpx;
  190. font-size: 156rpx;
  191. font-weight: 800;
  192. color: rgba(255,255,255,0.3);
  193. }
  194. }
  195. &-content {
  196. padding: 0 30rpx;
  197. box-sizing: border-box;
  198. }
  199. &-item {
  200. display: flex;
  201. align-items: center;
  202. justify-content: flex-start;
  203. column-gap: 50rpx;
  204. padding: 26rpx 28rpx;
  205. box-sizing: border-box;
  206. background: #f3f6fd;
  207. border-radius: 28rpx;
  208. box-shadow: 0rpx 3rpx 6rpx 0rpx rgba(0,0,0,0.16);
  209. }
  210. .info {
  211. &-icon {
  212. width: 80rpx;
  213. height: auto;
  214. }
  215. &-label {
  216. font-size: 32rpx;
  217. font-weight: 400;
  218. color: #000000;
  219. }
  220. }
  221. &-row {
  222. justify-content: space-between;
  223. padding: 15rpx 35rpx;
  224. & + & {
  225. margin-top: 33rpx;
  226. }
  227. .info {
  228. column-gap: 33rpx;
  229. }
  230. .btn {
  231. padding: 7rpx 30rpx;
  232. font-size: 28rpx;
  233. font-weight: 400;
  234. color: #4883F9;
  235. background: #FFFFFF;
  236. border-radius: 27rpx;
  237. }
  238. }
  239. &-box {
  240. display: grid;
  241. grid-template-columns: repeat(2, 1fr);
  242. column-gap: 34rpx;
  243. row-gap: 26rpx;
  244. .info {
  245. column-gap: 50rpx;
  246. }
  247. }
  248. }
  249. </style>