index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <template>
  2. <view class="s-header">
  3. <view class="header-search">
  4. <zzx-icon name="search" size="16"></zzx-icon>
  5. <input type="text" v-model="keyword" placeholder="搜索俱乐部名称" />
  6. <view class="search-btn" @click="to_search">
  7. 搜索
  8. </view>
  9. </view>
  10. <view class="venue-navbar">
  11. <view class="navbar-list" v-for="(item,index) in navbarList" :key="index" @click="select_nav(item)">
  12. <view class="list-text">{{item.title}}</view>
  13. <image :src="sel_index==index?'/static/notsel-icon.png':'/static/select-icon.png'" mode=""></image>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="content">
  18. <view class="select-btn">
  19. <view :class="sel_btn===index?'distance':'score'" v-for="(item,index) in selectList" :key="index"
  20. @click="select_btn(item,index)">{{item.text}}</view>
  21. </view>
  22. <view class="s-search-list" v-if="!searchLoading">
  23. <!-- 场地 -->
  24. <view v-if="sel_index==0">
  25. <!-- pages/index/gymDetail/index -->
  26. <view class="s-venue-card" v-for="(venue,index) in searchList" :key="venue.id" @click="RouterUtils.to_page(`/pages/index/gymDetail/index?id=${venue.id}`)">
  27. <view class="s-venue-info">
  28. <view class="venue-img">
  29. <image :src="venue.cover" mode=""></image>
  30. </view>
  31. <view class="venue-info">
  32. <view class="name">{{venue.name}}</view>
  33. <view class="appraise">
  34. <zzx-icon name="star" size="12"></zzx-icon>
  35. <view class="app-text"><text style="color: #FDD143 ;">{{venue.goodRate||0}}</text> | 37条评论</view>
  36. </view>
  37. <view class="address">{{venue.address}} | {{venue.km}}km</view>
  38. <view class="tags-box">
  39. <view class="tags" v-for="(tags,index) in venue.category" :key="index">{{tags}}</view>
  40. </view>
  41. </view>
  42. </view>
  43. <!-- <view class="s-course-list" v-for="item in 2">
  44. <view class="course-name">
  45. <view class="price">¥25.6</view>
  46. <view class="name">室内小班篮球培训课时</view>
  47. </view>
  48. <view class="sales">年售1万+</view>
  49. </view> -->
  50. </view>
  51. </view>
  52. <!-- 培训 -->
  53. <view v-if="sel_index==1">
  54. <view class="s-training-card" v-for="(venue,index) in searchList" :key="venue.id" @click="RouterUtils.to_page(`/pages/index/courseDetail/index?id=${venue.id}`)">
  55. <view class="training-box">
  56. <view class="training-img">
  57. <image class="t-img" :src="venue.cover" mode="">
  58. </image>
  59. </view>
  60. <view class="training-info">
  61. <view class="training-name">
  62. <!-- <view class="t-tags">公益课</view> -->
  63. <view class="t-name textHidden">{{venue.name}}</view>
  64. </view>
  65. <!-- <view class="tips">促进青少年长高</view> -->
  66. <view class="t-price">
  67. <view class="price"><text class="mini-text">¥</text>{{venue.originalPrice}}</view>
  68. <!-- <view class="price-tips">不支持退款</view> -->
  69. </view>
  70. <view class="sales">已售{{venue.sales}} {{venue.goodRate||'0'}}%好评</view>
  71. <view class="address">{{venue.address}} | {{venue.km}}km</view>
  72. </view>
  73. </view>
  74. <view class="tags-img">
  75. <image class="enroll-tags" src="@/static/search-icon1.png" mode="widthFix"></image>
  76. </view>
  77. </view>
  78. </view>
  79. <!-- 赛事 -->
  80. <view v-if="sel_index==2">
  81. <events :listData="searchList" />
  82. </view>
  83. <!-- 教练 -->
  84. <view v-if="sel_index==3">
  85. <instructor :listData="searchList" />
  86. </view>
  87. </view>
  88. <zs-loading v-else></zs-loading>
  89. <zs-empty v-if="searchList.length<1&&!searchLoading"></zs-empty>
  90. </view>
  91. </template>
  92. <script lang="ts" setup>
  93. import { ref, onMounted } from 'vue';
  94. import { onLoad,onReachBottom } from '@dcloudio/uni-app';
  95. import { http } from '@/utils/http'
  96. import {RouterUtils,TipsUtils} from '@/utils/util'
  97. import { useCacheStore } from '@/stores/cache'
  98. import events from './components/events.vue'
  99. import instructor from './components/instructor.vue'
  100. import zsEmpty from '@/components/zs-empty/index.vue'
  101. import zsLoading from '@/components/zzx-loading/zzx-loading.vue'
  102. const cache = useCacheStore()
  103. const selectList = ref()
  104. const sel_index = ref(0);
  105. const sel_btn = ref(0);
  106. const keyword = ref();
  107. const venueType=ref()
  108. const searchList=ref();
  109. const navbarList = ref([{title: '场地',value: 0,tagsVal:'0-1'},{title: '培训',value: 1,tagsVal:'1-1'},{title: '赛事',value: 2,tagsVal:'2-1'},{title: '教练',value: 3,tagsVal:'3-1'}]);
  110. onLoad((options) => {
  111. keyword.value = options.keyword
  112. venueType.value=options.venueType
  113. console.log(options);
  114. })
  115. onReachBottom(()=>{
  116. current.value++
  117. get_searchInfo(tagsVal.value||'0-1')
  118. })
  119. onMounted(() => {
  120. if(venueType.value){
  121. get_searchInfo(venueType.value)
  122. }else{
  123. get_searchInfo('0-1')
  124. }
  125. // get_dictItems()
  126. get_dictType(0)
  127. })
  128. const select_btn = (e,i) => {
  129. searchLoading.value=true
  130. sel_btn.value = i
  131. get_searchInfo(e.value)
  132. }
  133. const select_nav = (e) => {
  134. searchLoading.value=true
  135. sel_index.value = e.value
  136. tagsVal.value=e.tagsVal
  137. sel_btn.value=0
  138. searchList.value=[]
  139. get_dictType(e.value || 0)
  140. get_searchInfo(e.tagsVal)
  141. }
  142. // 查询分类
  143. const get_dictType = (type : number) => {
  144. http.get('/common/getDictItems', { data: { dictCode: 'search_type' } }).then(res => {
  145. let arr = []
  146. res.result.forEach((item) => {
  147. let value = parseInt(item.value.split('-')[0])
  148. if (type == value){
  149. return arr.push(item)
  150. }
  151. })
  152. selectList.value=arr
  153. })
  154. }
  155. const tagsVal=ref()
  156. const to_search=()=>{
  157. if(keyword.value=='') return TipsUtils.tips_toast('请输入搜索内容')
  158. searchLoading.value=true
  159. get_searchInfo(tagsVal.value||'0-1')
  160. }
  161. const searchLoading=ref(true)
  162. const current=ref(1)
  163. const get_searchInfo = (tagsVal) => {
  164. http.post('/home/search', { keyword: keyword.value, size: 10, current:current.value, venueType:String(tagsVal), longitude: cache.get('LON')||0, latitude: cache.get('LAT')||0 }).then((res) => {
  165. searchLoading.value=false
  166. if(current.value==1){
  167. searchList.value=res.result.records
  168. }else{
  169. searchList.value=[...searchList.value,...res.result.records]
  170. }
  171. })
  172. }
  173. </script>
  174. <style lang="less" scoped>
  175. .s-header {
  176. background: #fff;
  177. padding: 20rpx;
  178. .header-search {
  179. display: flex;
  180. align-items: center;
  181. gap: 10rpx;
  182. background: #F6F6F6;
  183. width: 680rpx;
  184. height: 60rpx;
  185. border-radius: 40rpx;
  186. padding-left: 20rpx;
  187. &>input {
  188. width: 670rpx;
  189. font-weight: bold;
  190. font-size: 24rpx;
  191. }
  192. .search-btn {
  193. width: 144rpx;
  194. height: 52rpx;
  195. background: #222222;
  196. border-radius: 28rpx;
  197. font-weight: bold;
  198. font-size: 28rpx;
  199. color: #C8FF0C;
  200. line-height: 52rpx;
  201. text-align: center;
  202. }
  203. }
  204. .venue-navbar {
  205. margin-top: 32rpx;
  206. display: flex;
  207. align-items: center;
  208. justify-content: space-around;
  209. .navbar-list {
  210. display: flex;
  211. align-items: center;
  212. gap: 10rpx;
  213. .list-text {
  214. font-weight: bold;
  215. font-size: 28rpx;
  216. color: #222222;
  217. }
  218. &>image {
  219. width: 30rpx;
  220. height: 30rpx;
  221. }
  222. }
  223. }
  224. }
  225. .content {
  226. .select-btn {
  227. display: flex;
  228. align-items: center;
  229. gap: 20rpx;
  230. margin-top: 20rpx;
  231. .distance {
  232. width: 92rpx;
  233. height: 48rpx;
  234. background: #222222;
  235. border-radius: 8rpx;
  236. font-size: 28rpx;
  237. color: #C8FF0C;
  238. line-height: 48rpx;
  239. text-align: center;
  240. }
  241. .score {
  242. width: 92rpx;
  243. height: 48rpx;
  244. background: #FFFFFF;
  245. border-radius: 8rpx;
  246. font-size: 28rpx;
  247. color: #AAAAAA;
  248. height: 48rpx;
  249. line-height: 48rpx;
  250. text-align: center;
  251. }
  252. }
  253. .s-search-list {
  254. .s-venue-card {
  255. margin-top: 20rpx;
  256. background: #FFFFFF;
  257. border-radius: 32rpx;
  258. padding: 20rpx;
  259. .s-venue-info {
  260. display: flex;
  261. align-items: center;
  262. gap: 20rpx;
  263. .venue-img {
  264. &>image {
  265. width: 200rpx;
  266. height: 200rpx;
  267. border-radius: 32rpx;
  268. }
  269. }
  270. .venue-info {
  271. .name {
  272. font-weight: 800;
  273. font-size: 32rpx;
  274. color: #222222;
  275. }
  276. .appraise {
  277. display: flex;
  278. align-items: center;
  279. margin-top: 16rpx;
  280. .app-text {
  281. font-size: 24rpx;
  282. color: #AAAAAA;
  283. }
  284. }
  285. .address {
  286. margin-top: 12rpx;
  287. font-size: 24rpx;
  288. color: #222222;
  289. }
  290. .tags-box {
  291. margin-top: 16rpx;
  292. display: flex;
  293. align-items: center;
  294. gap: 12rpx;
  295. flex-wrap: wrap;
  296. .tags {
  297. width: 92rpx;
  298. height: 36rpx;
  299. background: #F5F5F5;
  300. border-radius: 8rpx;
  301. font-size: 22rpx;
  302. color: #AAAAAA;
  303. line-height: 36rpx;
  304. text-align: center;
  305. }
  306. }
  307. }
  308. }
  309. .s-course-list {
  310. display: flex;
  311. align-items: center;
  312. justify-content: space-between;
  313. margin-top: 20rpx;
  314. .course-name {
  315. display: flex;
  316. align-items: center;
  317. gap: 20rpx;
  318. font-weight: bold;
  319. font-size: 28rpx;
  320. .price {
  321. color: #FB5B5B;
  322. }
  323. .name {
  324. color: #222222;
  325. }
  326. }
  327. .sales {
  328. font-size: 24rpx;
  329. color: #AAAAAA;
  330. }
  331. }
  332. }
  333. .s-training-card {
  334. margin-top: 20rpx;
  335. background: #FFFFFF;
  336. border-radius: 32rpx;
  337. padding: 20rpx;
  338. position: relative;
  339. .training-box {
  340. display: flex;
  341. align-items: center;
  342. gap: 20rpx;
  343. .training-img {
  344. position: relative;
  345. .t-img {
  346. width: 200rpx;
  347. height: 200rpx;
  348. border-radius: 32rpx;
  349. }
  350. .img-tags {
  351. position: absolute;
  352. left: -20rpx;
  353. top: 0;
  354. width: 113rpx;
  355. }
  356. .tags-text {
  357. position: absolute;
  358. font-size: 18rpx;
  359. color: #FFFFFF;
  360. top: 14rpx;
  361. left: 0;
  362. }
  363. .s-downtime {
  364. position: absolute;
  365. display: flex;
  366. bottom: 20rpx;
  367. left: 18rpx;
  368. .hours {
  369. width: 40rpx;
  370. height: 40rpx;
  371. background: rgba(200, 255, 12, 0.5);
  372. border-radius: 8rpx;
  373. font-weight: 800;
  374. font-size: 22rpx;
  375. color: #222222;
  376. line-height: 40rpx;
  377. text-align: center;
  378. }
  379. .unit {
  380. width: 20rpx;
  381. font-weight: 800;
  382. font-size: 22rpx;
  383. color: #222222;
  384. line-height: 40rpx;
  385. text-align: center;
  386. }
  387. }
  388. }
  389. .training-info {
  390. .training-name {
  391. display: flex;
  392. align-items: center;
  393. gap: 8rpx;
  394. .t-tags {
  395. width: 92rpx;
  396. height: 36rpx;
  397. background: #4DD951;
  398. border-radius: 8rpx;
  399. font-size: 22rpx;
  400. color: #FFFFFF;
  401. text-align: center;
  402. line-height: 36rpx;
  403. }
  404. .t-name {
  405. width: 360rpx;
  406. font-weight: 800;
  407. font-size: 32rpx;
  408. color: #222222;
  409. }
  410. }
  411. .tips {
  412. font-size: 22rpx;
  413. color: #AAAAAA;
  414. }
  415. .t-price {
  416. display: flex;
  417. align-items: center;
  418. gap: 12rpx;
  419. .price {
  420. font-weight: 800;
  421. font-size: 32rpx;
  422. color: #FB5B5B;
  423. }
  424. .price-tips {
  425. margin-top: 8rpx;
  426. width: 176rpx;
  427. height: 42rpx;
  428. background: linear-gradient(90deg, #C8FF0C 0%, #F2FFC7 79%, rgba(255, 255, 255, 0) 100%);
  429. border-radius: 28rpx;
  430. font-size: 22rpx;
  431. color: #222222;
  432. line-height: 42rpx;
  433. text-align: center;
  434. }
  435. }
  436. .sales {
  437. margin-top: 8rpx;
  438. font-size: 22rpx;
  439. color: #222222;
  440. }
  441. .address {
  442. margin-top: 8rpx;
  443. font-size: 22rpx;
  444. color: #222222;
  445. }
  446. }
  447. }
  448. .tags-img {
  449. position: absolute;
  450. right: 0;
  451. bottom: 0;
  452. .enroll-tags {
  453. width: 161rpx;
  454. }
  455. }
  456. }
  457. }
  458. }
  459. </style>