index.vue 11 KB

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