index.vue 16 KB

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