index.vue 18 KB

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