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

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