index.vue 17 KB

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