|
@@ -1,11 +1,11 @@
|
|
|
<template>
|
|
|
<div class="page">
|
|
|
<van-list
|
|
|
- v-model="isLoadingMore"
|
|
|
+ v-model="loadingMore"
|
|
|
:finished="finished"
|
|
|
:immediate-check="false"
|
|
|
:finished-text="total ? '没有更多了' : ''"
|
|
|
- @load="onLoadMore"
|
|
|
+ @load="fetchClubList"
|
|
|
>
|
|
|
<div class="page-top flex flex-col justify-center items-center">
|
|
|
<!-- <img class="logo" :src="supplierInfo.logo" /> -->
|
|
@@ -18,8 +18,8 @@
|
|
|
<!-- 搜索区域 -->
|
|
|
<div class="search">
|
|
|
<simple-search
|
|
|
- v-model="listQuery.clubName"
|
|
|
- @search="onSearch"
|
|
|
+ v-model="listQuery.authParty"
|
|
|
+ @search="filterClubList"
|
|
|
placeholder="搜索机构"
|
|
|
/>
|
|
|
</div>
|
|
@@ -50,10 +50,10 @@
|
|
|
>
|
|
|
<img
|
|
|
class="cover"
|
|
|
- :src="item.logo || drawLogo(item.clubName)"
|
|
|
+ :src="item.logo || drawLogo(item.authParty)"
|
|
|
/>
|
|
|
<div class="info">
|
|
|
- <div class="name" v-text="item.clubName"></div>
|
|
|
+ <div class="name" v-text="item.authParty"></div>
|
|
|
<div class="mobile">{{ item.mobile || '暂无' }}</div>
|
|
|
<div class="address">
|
|
|
{{ formatAddress(item.area, item.address) }}
|
|
@@ -81,16 +81,16 @@
|
|
|
:key="item.authId"
|
|
|
@click="toDetail(item)"
|
|
|
>
|
|
|
- <img class="cover" :src="item.logo || drawLogo(item.clubName)" />
|
|
|
+ <img class="cover" :src="item.logo || drawLogo(item.authParty)" />
|
|
|
<div class="info">
|
|
|
- <div class="name" v-text="item.clubName"></div>
|
|
|
+ <div class="name" v-text="item.authParty"></div>
|
|
|
<div class="mobile">{{ item.mobile || '暂无' }}</div>
|
|
|
<div class="address">
|
|
|
{{ formatAddress(item.area, item.address) }}
|
|
|
</div>
|
|
|
<div
|
|
|
class="distance"
|
|
|
- v-text="generateDistance(item.distance)"
|
|
|
+ v-text="formatDistance(item.distance)"
|
|
|
v-if="item.distance && item.distance !== 99999"
|
|
|
></div>
|
|
|
</div>
|
|
@@ -111,34 +111,19 @@
|
|
|
|
|
|
<script>
|
|
|
import { mapGetters } from 'vuex'
|
|
|
-import { geolocation } from '@/utils/map-utils'
|
|
|
-import { drawLogo, debounce } from '@/utils'
|
|
|
+import clubListMixin from '@/mixins/clubList'
|
|
|
+import { objectCover } from '@/utils'
|
|
|
export default {
|
|
|
layout: 'app',
|
|
|
+ mixins: [clubListMixin],
|
|
|
data() {
|
|
|
return {
|
|
|
- isLoadingMore: true,
|
|
|
- finished: false,
|
|
|
- isRequest: true,
|
|
|
- list: [],
|
|
|
- listQuery: {
|
|
|
- authUserId: '',
|
|
|
- lngAndLat: '',
|
|
|
- clubName: '',
|
|
|
- provinceId: '',
|
|
|
- cityId: '',
|
|
|
- townId: '',
|
|
|
- pageNum: 1,
|
|
|
- pageSize: 9,
|
|
|
- },
|
|
|
- total: 0,
|
|
|
cityList: [],
|
|
|
selectValue: [],
|
|
|
- starList: [],
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
- ...mapGetters(['supplierInfo', 'authUserId', 'routePrefix']),
|
|
|
+ ...mapGetters(['supplierInfo']),
|
|
|
emptyList() {
|
|
|
return 3 - (this.list.length % 3)
|
|
|
},
|
|
@@ -146,104 +131,25 @@ export default {
|
|
|
return 3 - (this.starList.length % 3)
|
|
|
},
|
|
|
},
|
|
|
- mounted() {
|
|
|
- const cacheData = this.$getStorage(this.routePrefix, 'club_list_data')
|
|
|
- if (cacheData) {
|
|
|
- this.initFromCache(cacheData)
|
|
|
- this.$removeStorage(this.routePrefix, 'club_list_data')
|
|
|
- } else {
|
|
|
- this.initData()
|
|
|
- this.fetchCityList()
|
|
|
- }
|
|
|
- this.fetchAuthClubStarList()
|
|
|
- },
|
|
|
- beforeDestroy() {
|
|
|
- this.$toast.clear()
|
|
|
+ created() {
|
|
|
+ this.fetchCityList()
|
|
|
},
|
|
|
methods: {
|
|
|
- // 获取明星机构列表
|
|
|
- async fetchAuthClubStarList() {
|
|
|
- try {
|
|
|
- const res = await this.$http.api.getAuthClubStarList({
|
|
|
- authUserId: this.authUserId,
|
|
|
- })
|
|
|
- this.starList = res.data.slice(0, 3)
|
|
|
- } catch (error) {
|
|
|
- console.log(error)
|
|
|
- }
|
|
|
- },
|
|
|
- // 绘制logo的方法
|
|
|
- drawLogo,
|
|
|
- // 查看详情
|
|
|
- toDetail(item) {
|
|
|
- this.$setStorage(this.routePrefix, 'club_list_data', this.$data, {
|
|
|
- expiredTime: 5 * 60 * 1000,
|
|
|
- })
|
|
|
- this.$setStorage(this.routePrefix, 'clubInfo', item)
|
|
|
- const url = `${this.routePrefix}/approve/club/detail?id=${item.authId}`
|
|
|
- this.$router.push(url)
|
|
|
- },
|
|
|
// 从缓存中获取数据
|
|
|
initFromCache(cacheData) {
|
|
|
- this.isLoadingMore = cacheData.isLoadingMore
|
|
|
- this.finished = cacheData.finished
|
|
|
- this.isRequest = cacheData.isRequest
|
|
|
- this.list = cacheData.list
|
|
|
- this.listQuery = cacheData.listQuery
|
|
|
- this.total = cacheData.total
|
|
|
- this.cityList = cacheData.cityList
|
|
|
- this.selectValue = cacheData.selectValue
|
|
|
- this.$refs.citySelect.setSelectValue(this.selectValue)
|
|
|
- },
|
|
|
-
|
|
|
- generateDistance(value) {
|
|
|
- return value > 1 ? value + 'km' : value * 1000 + 'm'
|
|
|
- },
|
|
|
-
|
|
|
- // 初始化页面数据
|
|
|
- async initData() {
|
|
|
- this.listQuery.authUserId = this.authUserId
|
|
|
-
|
|
|
- // 自定义加载图标
|
|
|
- this.$toast.loading({
|
|
|
- message: '正在获取您附近的机构...',
|
|
|
- duration: 0,
|
|
|
+ const data = objectCover(this, cacheData)
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.citySelect.setSelectValue(data.selectValue)
|
|
|
})
|
|
|
-
|
|
|
- // 获取定位信息 这里使用的是高德地图获取用户具体位置信息
|
|
|
- try {
|
|
|
- const resLocation = await geolocation()
|
|
|
- this.listQuery.lngAndLat = `${resLocation.position.lng},${resLocation.position.lat}`
|
|
|
- } catch (error) {
|
|
|
- this.$toast('获取定位信息失败,请确保您开启的定位权限并保存网络畅通')
|
|
|
- this.isRequest = false
|
|
|
- }
|
|
|
-
|
|
|
- // 获取机构列表
|
|
|
- this.fetchList()
|
|
|
},
|
|
|
- fetchList: debounce(async function () {
|
|
|
- try {
|
|
|
- this.isLoadingMore = true
|
|
|
- const res = await this.$http.api.getAuthClubList(this.listQuery)
|
|
|
- this.total = res.data.total
|
|
|
- this.list = [...this.list, ...res.data.list]
|
|
|
- this.finished = !res.data.hasNextPage
|
|
|
- this.isLoadingMore = false
|
|
|
- this.listQuery.pageNum += 1
|
|
|
- } catch (error) {
|
|
|
- console.log(error)
|
|
|
- } finally {
|
|
|
- this.$toast.clear()
|
|
|
- this.isRequest = false
|
|
|
- }
|
|
|
- }, 400),
|
|
|
+
|
|
|
// 获取地址列表
|
|
|
fetchCityList() {
|
|
|
this.$http.api.fetchAllCityList().then((res) => {
|
|
|
this.cityList = res.data
|
|
|
})
|
|
|
},
|
|
|
+
|
|
|
// 城市变化
|
|
|
onCityChange(selectValue) {
|
|
|
this.listQuery.provinceId = ''
|
|
@@ -260,30 +166,7 @@ export default {
|
|
|
this.listQuery.townId = item.id
|
|
|
}
|
|
|
})
|
|
|
- this.listQuery.pageNum = 1
|
|
|
- this.list = []
|
|
|
- this.fetchList()
|
|
|
- },
|
|
|
- // 搜索
|
|
|
- onSearch() {
|
|
|
- this.listQuery.pageNum = 1
|
|
|
- this.list = []
|
|
|
- this.fetchList()
|
|
|
- },
|
|
|
- // 格式化地址
|
|
|
- formatAddress(a1, a2) {
|
|
|
- let resutl = ''
|
|
|
- if (typeof a1 === 'string') {
|
|
|
- resutl += a1
|
|
|
- }
|
|
|
- if (typeof a2 === 'string') {
|
|
|
- resutl += a2
|
|
|
- }
|
|
|
- return resutl || '暂无'
|
|
|
- },
|
|
|
- // 加载更多
|
|
|
- onLoadMore() {
|
|
|
- this.fetchList()
|
|
|
+ this.filterClubList()
|
|
|
},
|
|
|
},
|
|
|
}
|