index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. <template>
  2. <div class="page">
  3. <van-list
  4. v-model="isLoadingMore"
  5. :finished="finished"
  6. :immediate-check="false"
  7. :finished-text="total ? '没有更多了' : ''"
  8. @load="onLoadMore"
  9. >
  10. <div class="page-top flex flex-col justify-center items-center"></div>
  11. <div class="page-content">
  12. <div
  13. class="navbar flex items-center flex-col"
  14. :style="{ top: offsetTop }"
  15. >
  16. <nuxt-link
  17. :to="routePrefix + '/approve/device'"
  18. class="link flex items-center flex-col"
  19. >
  20. <span class="icon icon-device"></span>
  21. <span class="text">设备认证</span>
  22. </nuxt-link>
  23. <nuxt-link
  24. :to="routePrefix + '/approve/personnel/operate'"
  25. class="link flex items-center flex-col md:mt-6 mt-4"
  26. >
  27. <span class="icon icon-doctor"></span>
  28. <span class="text">体疗师认证</span>
  29. </nuxt-link>
  30. </div>
  31. <div class="filter">
  32. <div class="search">
  33. <el-input
  34. placeholder="搜索机构"
  35. v-model="listQuery.clubName"
  36. @change="onSearch"
  37. >
  38. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  39. </el-input>
  40. </div>
  41. <div class="area">
  42. <RossSelectGroup @change="onCityChange" ref="citySelect" />
  43. </div>
  44. </div>
  45. <!-- 标题 -->
  46. <div class="title flex justify-between px-4 pt-8 pb-6 md:px-0">
  47. <div>距您最近...</div>
  48. <div>共<span v-text="total" class="font-bold"></span>家授权机构</div>
  49. </div>
  50. <!-- 列表 -->
  51. <div class="list">
  52. <template v-for="item in list">
  53. <div
  54. class="section flex justify-between mb-4"
  55. :key="item.authId"
  56. @click="toDetail(item)"
  57. >
  58. <img class="cover" :src="item.logo || drawLogo(item.clubName)" />
  59. <div class="info">
  60. <div class="name" v-text="item.clubName"></div>
  61. <div class="mobile">{{ item.mobile || '暂无' }}</div>
  62. <div class="address">
  63. {{ formatAddress(item.area, item.address) }}
  64. </div>
  65. <div
  66. class="distance"
  67. v-text="generateDistance(item.distance)"
  68. v-if="item.distance && item.distance !== 99999"
  69. ></div>
  70. </div>
  71. </div>
  72. </template>
  73. </div>
  74. <!-- 列表为空 -->
  75. <SimpleEmpty
  76. v-if="!total && !isRequest"
  77. name="icon-empty-club.png"
  78. description="敬请期待~"
  79. ></SimpleEmpty>
  80. </div>
  81. </van-list>
  82. </div>
  83. </template>
  84. <script>
  85. import { mapGetters } from 'vuex'
  86. import { loactionSelf, geolocation } from '@/utils/map-utils'
  87. import { drawLogo, debounce } from '@/utils'
  88. export default {
  89. layout: 'app-ross',
  90. data() {
  91. return {
  92. isLoadingMore: true,
  93. finished: false,
  94. isRequest: true,
  95. list: [],
  96. listQuery: {
  97. authUserId: '',
  98. lngAndLat: '',
  99. clubName: '',
  100. provinceId: '',
  101. cityId: '',
  102. townId: '',
  103. pageNum: 1,
  104. pageSize: 10,
  105. },
  106. total: 0,
  107. scrollTop: 0,
  108. }
  109. },
  110. computed: {
  111. ...mapGetters(['authUserId', 'routePrefix', 'screenWidth', 'isPc']),
  112. offsetTop() {
  113. if (this.scrollTop <= window.innerHeight / 2) return '240px'
  114. return 240 + this.scrollTop - window.innerHeight / 2 + 'px'
  115. },
  116. },
  117. mounted() {
  118. const cacheData = this.$getStorage(this.routePrefix, 'club_list_data')
  119. if (cacheData) {
  120. this.initFromCache(cacheData)
  121. this.$removeStorage(this.routePrefix, 'club_list_data')
  122. } else {
  123. this.initData()
  124. }
  125. window.addEventListener('scroll', () => {
  126. this.scrollTop = document.documentElement.scrollTop
  127. })
  128. },
  129. beforeDestroy() {
  130. this.$toast.clear()
  131. window.removeEventListener('scroll', () => {})
  132. },
  133. methods: {
  134. // 绘制logo的方法
  135. drawLogo,
  136. // 查看详情
  137. toDetail(item) {
  138. this.$setStorage(this.routePrefix, 'club_list_data', this.$data, {
  139. expiredTime: 5 * 60 * 1000,
  140. })
  141. this.$setStorage(this.routePrefix, 'clubInfo', item)
  142. const url = `${this.routePrefix}/approve/club/detail?id=${item.authId}`
  143. this.$router.push(url)
  144. },
  145. // 从缓存中获取数据
  146. initFromCache(cacheData) {
  147. this.isLoadingMore = cacheData.isLoadingMore
  148. this.finished = cacheData.finished
  149. this.isRequest = cacheData.isRequest
  150. this.list = cacheData.list
  151. this.listQuery = cacheData.listQuery
  152. this.total = cacheData.total
  153. this.$nextTick(() => {
  154. this.$refs.citySelect.initSelectValue({
  155. provinceId: this.listQuery.provinceId,
  156. cityId: this.listQuery.cityId,
  157. townId: this.listQuery.townId,
  158. })
  159. })
  160. },
  161. generateDistance(value) {
  162. return value > 1 ? value + 'km' : value * 1000 + 'm'
  163. },
  164. // 初始化页面数据
  165. async initData() {
  166. this.listQuery.authUserId = this.authUserId
  167. // 自定义加载图标
  168. this.$toast.loading({
  169. message: '正在获取您附近的机构...',
  170. duration: 0,
  171. })
  172. // 获取定位信息 这里使用的是高德地图获取用户具体位置信息
  173. try {
  174. const resLocation = await geolocation()
  175. this.listQuery.lngAndLat = `${resLocation.position.lng},${resLocation.position.lat}`
  176. } catch (error) {
  177. this.$toast('获取定位信息失败,请确保您开启的定位权限并保存网络畅通')
  178. this.isRequest = false
  179. }
  180. // 获取机构列表
  181. this.fetchList()
  182. },
  183. fetchList: debounce(async function () {
  184. try {
  185. this.isLoadingMore = true
  186. const res = await this.$http.api.getAuthClubList(this.listQuery)
  187. this.total = res.data.total
  188. this.list = [...this.list, ...res.data.list]
  189. this.finished = !res.data.hasNextPage
  190. this.isLoadingMore = false
  191. this.listQuery.pageNum += 1
  192. } catch (error) {
  193. console.log(error)
  194. } finally {
  195. this.$toast.clear()
  196. this.isRequest = false
  197. }
  198. }, 400),
  199. // 城市变化
  200. onCityChange(valueMap) {
  201. const { provinceId, cityId, townId } = valueMap
  202. this.listQuery.provinceId = provinceId
  203. this.listQuery.cityId = cityId
  204. this.listQuery.townId = townId
  205. this.listQuery.pageNum = 1
  206. this.list = []
  207. this.fetchList()
  208. },
  209. // 搜索
  210. onSearch() {
  211. this.listQuery.pageNum = 1
  212. this.list = []
  213. this.fetchList()
  214. },
  215. // 格式化地址
  216. formatAddress(a1, a2) {
  217. let resutl = ''
  218. if (typeof a1 === 'string') {
  219. resutl += a1
  220. }
  221. if (typeof a2 === 'string') {
  222. resutl += a2
  223. }
  224. return resutl || '暂无'
  225. },
  226. // 加载更多
  227. onLoadMore() {
  228. this.fetchList()
  229. },
  230. },
  231. }
  232. </script>
  233. <style scoped lang="scss">
  234. .el-input {
  235. ::v-deep {
  236. & > {
  237. .el-input.is-active .el-input__inner,
  238. .el-input__inner:focus {
  239. @include themify($themes) {
  240. border-color: themed('color');
  241. }
  242. }
  243. }
  244. }
  245. }
  246. // pc 端
  247. @media screen and (min-width: 768px) {
  248. .page {
  249. position: relative;
  250. min-height: calc(100vh - 80px - 80px);
  251. background-color: #fff;
  252. }
  253. .page-top {
  254. height: 530px;
  255. @include themify($themes) {
  256. background-image: themed('pc-banner-club');
  257. }
  258. background-size: cover;
  259. background-position: center;
  260. }
  261. .page-content {
  262. position: relative;
  263. width: 1000px;
  264. margin: 0 auto;
  265. .title {
  266. font-size: 16px;
  267. color: #404040;
  268. span {
  269. @include themify($themes) {
  270. color: themed('color');
  271. }
  272. }
  273. }
  274. .filter {
  275. padding: 48px 0 105px;
  276. .search {
  277. width: 640px;
  278. margin: 0 auto;
  279. .el-input {
  280. height: 46px;
  281. font-size: 16px;
  282. .el-input__icon {
  283. font-size: 24px;
  284. line-height: 46px;
  285. margin-left: 12px;
  286. }
  287. ::v-deep {
  288. & > .el-input__inner {
  289. height: 46px;
  290. padding-left: 55px;
  291. }
  292. }
  293. }
  294. }
  295. }
  296. .navbar {
  297. position: absolute;
  298. top: 240px;
  299. right: -168px;
  300. width: 120px;
  301. border-radius: 16px;
  302. background: #fff;
  303. box-shadow: 0px 6px 20px rgba(40, 40, 40, 0.1);
  304. padding: 24px 0;
  305. box-sizing: border-box;
  306. z-index: 2;
  307. .link {
  308. &:hover {
  309. .icon {
  310. &.icon-device {
  311. background: url(~assets/theme-images/ross/pc-nav-entry-device-active.png)
  312. no-repeat center center,
  313. linear-gradient(180deg, #ffba63 0%, #f3920d 100%);
  314. background-size: 48px, 100%;
  315. }
  316. &.icon-doctor {
  317. background: url(~assets/theme-images/ross/pc-nav-entry-doctor-active.png)
  318. no-repeat center center,
  319. linear-gradient(180deg, #ffba63 0%, #f3920d 100%);
  320. background-size: 48px, 100%;
  321. }
  322. }
  323. .text {
  324. @include themify($themes) {
  325. color: themed('color');
  326. }
  327. }
  328. }
  329. span {
  330. display: block;
  331. }
  332. .icon {
  333. width: 72px;
  334. height: 72px;
  335. // background: linear-gradient(180deg, #ffba63 0%, #f3920d 100%);
  336. background-color: #f6f6f7;
  337. border-radius: 12px;
  338. &.icon-device {
  339. background: url(~assets/theme-images/ross/pc-nav-entry-device.png)
  340. no-repeat center center #f6f6f7;
  341. background-size: 48px;
  342. }
  343. &.icon-doctor {
  344. background: url(~assets/theme-images/ross/pc-nav-entry-doctor.png)
  345. no-repeat center center #f6f6f7;
  346. background-size: 48px;
  347. }
  348. }
  349. .text {
  350. font-size: 16px;
  351. color: #404040;
  352. margin-top: 8px;
  353. }
  354. }
  355. }
  356. .list {
  357. display: flex;
  358. align-items: center;
  359. justify-content: space-between;
  360. flex-wrap: wrap;
  361. .empty {
  362. width: 390px;
  363. }
  364. .section {
  365. width: 490px;
  366. height: 136px;
  367. background-color: #f3f5f6;
  368. border-radius: 4px;
  369. box-sizing: border-box;
  370. padding: 16px;
  371. cursor: pointer;
  372. transition: all 0.4s;
  373. &:hover {
  374. box-shadow: 0 0 24px rgba(0, 0, 0, 0.2);
  375. }
  376. .cover {
  377. display: block;
  378. width: 104px;
  379. height: 104px;
  380. }
  381. .info {
  382. position: relative;
  383. margin-left: 12px;
  384. width: 330px;
  385. .name {
  386. width: 200px;
  387. font-size: 18px;
  388. color: #101010;
  389. font-weight: bold;
  390. margin-bottom: 24px;
  391. text-overflow: ellipsis;
  392. white-space: nowrap;
  393. overflow: hidden;
  394. }
  395. .mobile,
  396. .address {
  397. width: 268px;
  398. position: relative;
  399. font-size: 14px;
  400. color: #404040;
  401. padding-left: 24px;
  402. line-height: 24px;
  403. text-overflow: ellipsis;
  404. white-space: nowrap;
  405. margin-top: 6px;
  406. overflow: hidden;
  407. &::after {
  408. content: '';
  409. display: block;
  410. width: 16px;
  411. height: 16px;
  412. position: absolute;
  413. left: 0;
  414. top: 50%;
  415. transform: translateY(-50%);
  416. background-size: 16px;
  417. background-repeat: no-repeat;
  418. }
  419. }
  420. .mobile {
  421. &::after {
  422. background-image: url(~assets/theme-images/common/pc-icon-mobile.png);
  423. }
  424. }
  425. .address {
  426. &::after {
  427. background-image: url(~assets/theme-images/common/pc-icon-address.png);
  428. }
  429. }
  430. .distance {
  431. position: absolute;
  432. font-size: 14px;
  433. color: #404040;
  434. top: 2px;
  435. right: 0;
  436. }
  437. }
  438. }
  439. }
  440. }
  441. }
  442. // 移动 端
  443. @media screen and (max-width: 768px) {
  444. .page-top {
  445. height: 100vw;
  446. @include themify($themes) {
  447. background: themed('h5-banner-club');
  448. }
  449. background-size: 100vw 100vw !important;
  450. .logo {
  451. display: block;
  452. width: 14.8vw;
  453. height: 14.8vw;
  454. border-radius: 50%;
  455. background: #fff;
  456. }
  457. .name {
  458. font-size: 4vw;
  459. color: #fff;
  460. }
  461. }
  462. .page-content {
  463. position: relative;
  464. .title {
  465. font-size: 3.4vw;
  466. color: #404040;
  467. span {
  468. @include themify($themes) {
  469. color: themed('color');
  470. }
  471. }
  472. }
  473. .filter {
  474. padding: 6.4vw 3.2vw 12.8vw;
  475. }
  476. .navbar {
  477. position: fixed;
  478. top: 50% !important;
  479. right: 3.2vw;
  480. left: unset !important;
  481. width: 14vw;
  482. border-radius: 1.6vw;
  483. background: #fff;
  484. box-shadow: 0px 0.6vw 2vw rgba(40, 40, 40, 0.1);
  485. padding: 2.8vw 0;
  486. box-sizing: border-box;
  487. z-index: 2;
  488. span {
  489. display: block;
  490. }
  491. .icon {
  492. position: relative;
  493. width: 7.2vw;
  494. height: 7.2vw;
  495. border-radius: 1.2vw;
  496. background: linear-gradient(180deg, #ffba63 0%, #f3920d 100%);
  497. &.icon-device,
  498. &.icon-doctor {
  499. &::after {
  500. content: '';
  501. display: block;
  502. width: 4.8vw;
  503. height: 4.8vw;
  504. position: absolute;
  505. left: 50%;
  506. top: 50%;
  507. transform: translate(-50%, -50%);
  508. background-size: 4.8vw !important;
  509. }
  510. }
  511. &.icon-device {
  512. &::after {
  513. background: url(~assets/theme-images/ross/pc-nav-entry-device-active.png)
  514. no-repeat center;
  515. }
  516. }
  517. &.icon-doctor {
  518. &::after {
  519. background: url(~assets/theme-images/ross/pc-nav-entry-doctor-active.png)
  520. no-repeat center;
  521. }
  522. }
  523. }
  524. .text {
  525. font-size: 2.4vw;
  526. color: #f3920d;
  527. margin-top: 1.2vw;
  528. }
  529. }
  530. }
  531. .list {
  532. display: flex;
  533. align-items: center;
  534. flex-direction: column;
  535. .section {
  536. width: 93.6vw;
  537. height: 26vw;
  538. background-color: #f3f5f6;
  539. border-radius: 4px;
  540. box-sizing: border-box;
  541. padding: 3.2vw;
  542. .cover {
  543. display: block;
  544. width: 19.6vw;
  545. height: 19.6vw;
  546. }
  547. .info {
  548. position: relative;
  549. margin-left: 3.2vw;
  550. .name {
  551. width: 48vw;
  552. font-size: 4vw;
  553. color: #101010;
  554. font-weight: bold;
  555. margin-bottom: 4vw;
  556. text-overflow: ellipsis;
  557. white-space: nowrap;
  558. overflow: hidden;
  559. }
  560. .mobile,
  561. .address {
  562. width: 66vw;
  563. position: relative;
  564. font-size: 3vw;
  565. color: #404040;
  566. padding-left: 5vw;
  567. line-height: 5vw;
  568. text-overflow: ellipsis;
  569. white-space: nowrap;
  570. overflow: hidden;
  571. &::after {
  572. content: '';
  573. display: block;
  574. width: 4vw;
  575. height: 4vw;
  576. position: absolute;
  577. left: 0;
  578. top: 50%;
  579. transform: translateY(-50%);
  580. background-size: 4vw 4vw;
  581. background-repeat: no-repeat;
  582. }
  583. }
  584. .mobile {
  585. &::after {
  586. background-image: url(~assets/theme-images/common/h5-icon-mobile.png);
  587. }
  588. }
  589. .address {
  590. &::after {
  591. background-image: url(~assets/theme-images/common/h5-icon-address.png);
  592. }
  593. }
  594. .distance {
  595. position: absolute;
  596. font-size: 3vw;
  597. color: #404040;
  598. top: 0.8vw;
  599. right: 0;
  600. }
  601. }
  602. }
  603. }
  604. }
  605. </style>