index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. <template>
  2. <div class="page">
  3. <div class="page-top"></div>
  4. <div class="page-content">
  5. <!-- 搜索区域 -->
  6. <div class="search flex justify-center">
  7. <input
  8. type="text"
  9. placeholder="搜索店铺"
  10. v-model="listQuery.clubName"
  11. @keyup.enter="onSearch"
  12. />
  13. </div>
  14. <!-- 地区筛选 -->
  15. <div class="city">
  16. <LdmCity
  17. @change="onCityChange"
  18. :options="cityList"
  19. labelName="name"
  20. valueName="id"
  21. ></LdmCity>
  22. </div>
  23. <!-- 标题 -->
  24. <div class="title">距你最近...</div>
  25. <!-- 机构列表 -->
  26. <div class="list">
  27. <div
  28. class="section flex items-center"
  29. v-for="item in list"
  30. :key="item.authId"
  31. @click="toDetail(item)"
  32. >
  33. <img class="cover" :src="item.logo || drawLogo(item.clubName)" />
  34. <div class="info">
  35. <div class="name" v-text="item.clubName"></div>
  36. <div class="line"></div>
  37. <div class="mobile">{{ item.mobile || '未知' }}</div>
  38. <div class="address">
  39. {{ formatAddress(item.area, item.address) }}
  40. </div>
  41. <div
  42. class="distance"
  43. v-text="item.distance + 'km'"
  44. v-if="item.distance && item.distance !== 99999"
  45. ></div>
  46. </div>
  47. </div>
  48. </div>
  49. <!-- 列表为空 -->
  50. <SimpleEmpty
  51. v-if="!total && !isRequest"
  52. description="敬请期待~"
  53. ></SimpleEmpty>
  54. <!-- 页码 -->
  55. <SimplePagination
  56. themeType="black"
  57. v-if="total > listQuery.pageSize"
  58. :total="total"
  59. :pageItems="listQuery.pageSize"
  60. @change="onPagiantionChange"
  61. ></SimplePagination>
  62. </div>
  63. </div>
  64. </template>
  65. <script>
  66. import { mapGetters } from 'vuex'
  67. import { loactionSelf } from '@/utils/map-utils'
  68. import { drawLogo } from '@/utils'
  69. export default {
  70. layout: 'app-ldm',
  71. data() {
  72. return {
  73. isRequest: true,
  74. list: [],
  75. listQuery: {
  76. authUserId: '',
  77. lngAndLat: '',
  78. clubName: '',
  79. provinceId: '',
  80. cityId: '',
  81. townId: '',
  82. pageNum: 1,
  83. pageSize: 4,
  84. },
  85. total: 0,
  86. cityList: [],
  87. }
  88. },
  89. computed: {
  90. ...mapGetters(['supplierInfo', 'authUserId']),
  91. emptyList() {
  92. return 3 - (this.list.length % 3)
  93. },
  94. },
  95. mounted() {
  96. this.initData()
  97. this.fetchCityList()
  98. },
  99. methods: {
  100. // 绘制logo的方法
  101. drawLogo,
  102. // 查看详情
  103. toDetail(item) {
  104. localStorage.setItem('clubInfo', JSON.stringify(item))
  105. const authUserId = this.$store.getters.authUserId
  106. this.$router.push(
  107. `/${authUserId}/ldm/approve/club/detail?id=${item.authId}`
  108. )
  109. },
  110. // 初始化页面数据
  111. async initData() {
  112. // 自定义加载图标
  113. this.$toast.loading({
  114. message: '正在获取您附近的机构...',
  115. duration: 0,
  116. })
  117. // 获取定位信息 百度坐标转高德坐标
  118. try {
  119. const location = await loactionSelf()
  120. const result = await this.$http.api.assistant({
  121. key: '1bcc97330f6cf517e8dd9d5278957e67',
  122. locations: `${location.point.lng},${location.point.lat}`,
  123. coordsys: 'baidu',
  124. output: 'JSON',
  125. })
  126. const res = await result.json()
  127. this.listQuery.lngAndLat = res.locations
  128. } catch (error) {
  129. this.$toast.clear()
  130. this.$toast('获取定位信息失败,请确保您开启的定位权限并保存网络畅通')
  131. this.isRequest = false
  132. }
  133. this.listQuery.authUserId = this.authUserId
  134. // 获取机构列表
  135. this.fetchList()
  136. },
  137. // 获取机构列表
  138. async fetchList() {
  139. try {
  140. const res = await this.$http.api.getAuthClubList(this.listQuery)
  141. this.total = res.data.total
  142. this.list = res.data.list
  143. } catch (error) {
  144. console.log(error)
  145. } finally {
  146. this.$toast.clear()
  147. this.isRequest = false
  148. }
  149. },
  150. // 获取地址列表
  151. fetchCityList() {
  152. this.$http.api.fetchAllCityList().then((res) => {
  153. this.cityList = res.data
  154. })
  155. },
  156. // 城市变化
  157. onCityChange(selectValue) {
  158. this.listQuery.provinceId = ''
  159. this.listQuery.cityId = ''
  160. this.listQuery.townId = ''
  161. selectValue.map((item, index) => {
  162. if (index === 0) {
  163. this.listQuery.provinceId = item.id
  164. } else if (index === 1) {
  165. this.listQuery.cityId = item.id
  166. } else {
  167. this.listQuery.townId = item.id
  168. }
  169. })
  170. this.listQuery.pageNum = 1
  171. this.fetchList()
  172. },
  173. // 搜索
  174. onSearch() {
  175. this.listQuery.pageNum = 1
  176. this.fetchList()
  177. },
  178. // 页码变化
  179. onPagiantionChange(index) {
  180. this.listQuery.pageNum = index
  181. this.fetchList()
  182. },
  183. // 格式化地址
  184. formatAddress(a1, a2) {
  185. let resutl = ''
  186. if (typeof a1 === 'string') {
  187. resutl += a1
  188. }
  189. if (typeof a2 === 'string') {
  190. resutl += a2
  191. }
  192. return resutl || '未知'
  193. },
  194. },
  195. beforeDestroy() {
  196. this.$toast.clear()
  197. },
  198. }
  199. </script>
  200. <style scoped lang="scss">
  201. @media screen and (min-width: 768px) {
  202. .page-top {
  203. height: 596px;
  204. background: url(https://static.caimei365.com/www/authentic/pc/ldm-bg-club.png)
  205. no-repeat center;
  206. background-size: auto 596px;
  207. }
  208. .page-content {
  209. width: 836px;
  210. padding-bottom: 80px;
  211. margin: 0 auto;
  212. overflow: hidden;
  213. .city{
  214. position: relative;
  215. z-index: 99;
  216. }
  217. .search {
  218. width: 836px;
  219. position: relative;
  220. margin: 69px auto 40px;
  221. input {
  222. display: block;
  223. width: 100%;
  224. height: 56px;
  225. border: 0.1vw solid #000000;
  226. box-sizing: border-box;
  227. padding-left: 80px;
  228. font-size: 24px;
  229. }
  230. &::after {
  231. position: absolute;
  232. left: 33px;
  233. top: 50%;
  234. transform: translateY(-50%);
  235. content: '';
  236. display: block;
  237. width: 37px;
  238. height: 37px;
  239. background: url(https://static.caimei365.com/www/authentic/pc/ldm-icon-search.png)
  240. no-repeat center;
  241. background-size: 37px;
  242. }
  243. }
  244. .title {
  245. text-align: right;
  246. font-size: 22px;
  247. color: #000;
  248. }
  249. .list {
  250. padding-top: 24px;
  251. display: flex;
  252. align-items: center;
  253. justify-content: space-between;
  254. flex-wrap: wrap;
  255. .section {
  256. width: 409px;
  257. background: #f1f1f1;
  258. border-radius: 20px;
  259. padding: 16px;
  260. box-sizing: border-box;
  261. margin-bottom: 20px;
  262. cursor: pointer;
  263. .cover {
  264. width: 92px;
  265. height: 92px;
  266. border-radius: 17px;
  267. }
  268. .info {
  269. position: relative;
  270. width: 263px;
  271. margin-left: 23px;
  272. .name {
  273. width: 200px;
  274. position: relative;
  275. font-size: 15px;
  276. color: #000;
  277. font-weight: bold;
  278. text-overflow: ellipsis;
  279. white-space: nowrap;
  280. overflow: hidden;
  281. padding-left: 20px;
  282. line-height: 20px;
  283. &::after {
  284. content: '';
  285. display: block;
  286. width: 20px;
  287. height: 20px;
  288. position: absolute;
  289. left: 0;
  290. top: 50%;
  291. transform: translateY(-50%);
  292. background-size: 14px 14px;
  293. background-repeat: no-repeat;
  294. background-position: left center;
  295. }
  296. }
  297. .name {
  298. &::after {
  299. background-image: url(https://static.caimei365.com/www/authentic/pc/ldm-icon-store.png);
  300. }
  301. }
  302. .line {
  303. height: 1px;
  304. margin: 14px 0;
  305. background: rgba(0, 0, 0, 0.169);
  306. }
  307. .mobile,
  308. .address {
  309. position: relative;
  310. font-size: 12px;
  311. color: #000000;
  312. padding-left: 20px;
  313. line-height: 20px;
  314. text-overflow: ellipsis;
  315. white-space: nowrap;
  316. overflow: hidden;
  317. &::after {
  318. content: '';
  319. display: block;
  320. width: 20px;
  321. height: 20px;
  322. position: absolute;
  323. left: 0;
  324. top: 50%;
  325. transform: translateY(-50%);
  326. background-size: 14px 14px;
  327. background-repeat: no-repeat;
  328. background-position: left center;
  329. }
  330. }
  331. .mobile {
  332. &::after {
  333. background-image: url(https://static.caimei365.com/www/authentic/pc/ldm-icon-contact.png);
  334. }
  335. }
  336. .address {
  337. &::after {
  338. background-image: url(https://static.caimei365.com/www/authentic/pc/ldm-icon-address.png);
  339. }
  340. }
  341. .distance {
  342. position: absolute;
  343. font-size: 12px;
  344. color: #404040;
  345. top: 0.2vw;
  346. right: 0;
  347. }
  348. }
  349. }
  350. }
  351. }
  352. }
  353. @media screen and (max-width: 768px) {
  354. .page-top {
  355. height: 59.6vw;
  356. background: url(https://static.caimei365.com/www/authentic/h5/ldm-bg-club.png);
  357. background-size: auto 59.6vw;
  358. }
  359. .page-content {
  360. overflow: hidden;
  361. .search {
  362. width: 86vw;
  363. position: relative;
  364. margin: 7.6vw auto 5.6vw;
  365. input {
  366. display: block;
  367. width: 100%;
  368. height: 8vw;
  369. border: 0.1vw solid #000000;
  370. box-sizing: border-box;
  371. padding-left: 10.5vw;
  372. }
  373. &::after {
  374. position: absolute;
  375. left: 2.9vw;
  376. top: 50%;
  377. transform: translateY(-50%);
  378. content: '';
  379. display: block;
  380. width: 5.4vw;
  381. height: 5.4vw;
  382. background: url(https://static.caimei365.com/www/authentic/h5/ldm-icon-search.png)
  383. no-repeat center;
  384. background-size: 5.4vw;
  385. }
  386. }
  387. .title {
  388. text-align: right;
  389. padding-right: 6.6vw;
  390. font-size: 3.5vw;
  391. color: #000;
  392. }
  393. .list {
  394. display: flex;
  395. flex-direction: column;
  396. align-items: center;
  397. .section {
  398. width: 95.1vw;
  399. background: #f1f1f1;
  400. border-radius: 2vw;
  401. padding: 3.2vw;
  402. box-sizing: border-box;
  403. margin-top: 5.7vw;
  404. &:last-child {
  405. margin-bottom: 5.7vw;
  406. }
  407. .cover {
  408. width: 21.5vw;
  409. height: 21.5vw;
  410. border-radius: 1.7vw;
  411. }
  412. .info {
  413. position: relative;
  414. width: 61.3vw;
  415. margin-left: 5.8vw;
  416. .name {
  417. width: 46vw;
  418. position: relative;
  419. font-size: 3.5vw;
  420. color: #000;
  421. font-weight: bold;
  422. text-overflow: ellipsis;
  423. white-space: nowrap;
  424. overflow: hidden;
  425. padding-left: 5vw;
  426. line-height: 5vw;
  427. &::after {
  428. content: '';
  429. display: block;
  430. width: 4vw;
  431. height: 4vw;
  432. position: absolute;
  433. left: 0;
  434. top: 50%;
  435. transform: translateY(-50%);
  436. background-size: 3.6vw 3.6vw;
  437. background-repeat: no-repeat;
  438. }
  439. }
  440. .name {
  441. &::after {
  442. background-image: url(https://static.caimei365.com/www/authentic/h5/ldm-icon-store.png);
  443. }
  444. }
  445. .line {
  446. height: 0.1vw;
  447. margin: 2.8vw 0;
  448. background: rgba(0, 0, 0, 0.169);
  449. }
  450. .mobile,
  451. .address {
  452. position: relative;
  453. font-size: 3vw;
  454. color: #000000;
  455. padding-left: 5vw;
  456. line-height: 5vw;
  457. text-overflow: ellipsis;
  458. white-space: nowrap;
  459. overflow: hidden;
  460. &::after {
  461. content: '';
  462. display: block;
  463. width: 4vw;
  464. height: 4vw;
  465. position: absolute;
  466. left: 0;
  467. top: 50%;
  468. transform: translateY(-50%);
  469. background-size: 3.6vw 3.6vw;
  470. background-repeat: no-repeat;
  471. }
  472. }
  473. .mobile {
  474. &::after {
  475. background-image: url(https://static.caimei365.com/www/authentic/h5/ldm-icon-contact.png);
  476. }
  477. }
  478. .address {
  479. &::after {
  480. background-image: url(https://static.caimei365.com/www/authentic/h5/ldm-icon-address.png);
  481. }
  482. }
  483. .distance {
  484. position: absolute;
  485. font-size: 3vw;
  486. color: #404040;
  487. top: 0.2vw;
  488. right: 0;
  489. }
  490. }
  491. }
  492. }
  493. }
  494. }
  495. </style>