123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519 |
- <template>
- <div class="page">
- <van-list
- v-model="isLoadingMore"
- :finished="finished"
- :immediate-check="false"
- :finished-text="total ? '没有更多了' : ''"
- @load="onLoadMore"
- >
- <div class="page-top"></div>
- <div class="page-content">
- <!-- 搜索区域 -->
- <div class="search flex justify-center">
- <input
- type="text"
- placeholder="搜索店铺"
- v-model="listQuery.clubName"
- @keyup.enter="onSearch"
- />
- </div>
- <!-- 地区筛选 -->
- <div class="city">
- <LdmCity
- @change="onCityChange"
- :options="cityList"
- labelName="name"
- valueName="id"
- ></LdmCity>
- </div>
- <!-- 标题 -->
- <div class="title">距你最近...</div>
- <!-- 机构列表 -->
- <div class="list">
- <div
- class="section flex items-center"
- v-for="item in list"
- :key="item.authId"
- @click="toDetail(item)"
- >
- <img class="cover" :src="item.logo || drawLogo(item.clubName)" />
- <div class="info">
- <div class="name" v-text="item.clubName"></div>
- <div class="line"></div>
- <div class="mobile">{{ item.mobile || '未知' }}</div>
- <div class="address">
- {{ formatAddress(item.area, item.address) }}
- </div>
- <div
- class="distance"
- v-text="item.distance + 'km'"
- v-if="item.distance && item.distance !== 99999"
- ></div>
- </div>
- </div>
- </div>
- <!-- 列表为空 -->
- <LdmEmpty v-if="!total && !isRequest" name="ldm-empty.png"></LdmEmpty>
- </div>
- </van-list>
- </div>
- </template>
- <script>
- import { mapGetters } from 'vuex'
- import { loactionSelf } from '@/utils/map-utils'
- import { debounce, drawLogo } from '@/utils'
- export default {
- layout: 'app-ldm',
- data() {
- return {
- isLoadingMore: true,
- finished: false,
- isRequest: true,
- list: [],
- listQuery: {
- authUserId: '',
- lngAndLat: '',
- clubName: '',
- provinceId: '',
- cityId: '',
- townId: '',
- pageNum: 1,
- pageSize: 4,
- },
- total: 0,
- cityList: [],
- }
- },
- computed: {
- ...mapGetters(['supplierInfo', 'authUserId']),
- emptyList() {
- return 3 - (this.list.length % 3)
- },
- },
- mounted() {
- this.initData()
- this.fetchCityList()
- },
- methods: {
- // 绘制logo的方法
- drawLogo,
- // 查看详情
- toDetail(item) {
- localStorage.setItem('clubInfo', JSON.stringify(item))
- const authUserId = this.$store.getters.authUserId
- this.$router.push(
- `/${authUserId}/ldm/approve/club/detail?id=${item.authId}`
- )
- },
- // 初始化页面数据
- async initData() {
- // 自定义加载图标
- this.$toast.loading({
- message: '正在获取您附近的机构...',
- duration: 0,
- })
- // 获取定位信息 百度坐标转高德坐标
- try {
- const location = await loactionSelf()
- const result = await this.$http.api.assistant({
- key: '1bcc97330f6cf517e8dd9d5278957e67',
- locations: `${location.point.lng},${location.point.lat}`,
- coordsys: 'baidu',
- output: 'JSON',
- })
- const res = await result.json()
- this.listQuery.lngAndLat = res.locations
- } catch (error) {
- this.$toast.clear()
- this.$toast('获取定位信息失败,请确保您开启的定位权限并保存网络畅通')
- this.isRequest = false
- }
- this.listQuery.authUserId = this.authUserId
- // 获取机构列表
- 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
- } catch (error) {
- console.log(error)
- } finally {
- this.$toast.clear()
- this.isRequest = false
- this.isLoadingMore = false
- }
- }, 400),
- // 获取地址列表
- fetchCityList() {
- this.$http.api.fetchAllCityList().then((res) => {
- this.cityList = res.data
- })
- },
- // 城市变化
- onCityChange(selectValue) {
- this.listQuery.provinceId = ''
- this.listQuery.cityId = ''
- this.listQuery.townId = ''
- selectValue.map((item, index) => {
- if (index === 0) {
- this.listQuery.provinceId = item.id
- } else if (index === 1) {
- this.listQuery.cityId = item.id
- } else {
- this.listQuery.townId = item.id
- }
- })
- this.listQuery.pageNum = 1
- this.list = []
- this.fetchList()
- },
- // 搜索
- onSearch() {
- this.listQuery.pageNum = 1
- this.list = []
- this.fetchList()
- },
- // 页码变化
- onPagiantionChange(index) {},
- // 格式化地址
- formatAddress(a1, a2) {
- let resutl = ''
- if (typeof a1 === 'string') {
- resutl += a1
- }
- if (typeof a2 === 'string') {
- resutl += a2
- }
- return resutl || '未知'
- },
- // 加载更多
- onLoadMore() {
- if (this.isRequest) return
- this.listQuery.pageNum += 1
- this.fetchList()
- },
- },
- beforeDestroy() {
- this.$toast.clear()
- },
- }
- </script>
- <style scoped lang="scss">
- @media screen and (min-width: 768px) {
- .page-top {
- height: 596px;
- background: url(https://static.caimei365.com/www/authentic/pc/ldm-bg-club.png)
- no-repeat center;
- background-size: auto 596px;
- }
- .page-content {
- width: 836px;
- margin: 0 auto;
- overflow: hidden;
- .city {
- position: relative;
- z-index: 99;
- }
- .search {
- width: 836px;
- position: relative;
- margin: 69px auto 40px;
- input {
- display: block;
- width: 100%;
- height: 56px;
- border: 0.1vw solid #000000;
- box-sizing: border-box;
- padding-left: 80px;
- font-size: 24px;
- }
- &::after {
- position: absolute;
- left: 33px;
- top: 50%;
- transform: translateY(-50%);
- content: '';
- display: block;
- width: 37px;
- height: 37px;
- background: url(https://static.caimei365.com/www/authentic/pc/ldm-icon-search.png)
- no-repeat center;
- background-size: 37px;
- }
- }
- .title {
- text-align: right;
- font-size: 22px;
- color: #000;
- }
- .list {
- padding-top: 24px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- flex-wrap: wrap;
- .section {
- width: 409px;
- background: #f1f1f1;
- border-radius: 20px;
- padding: 16px;
- box-sizing: border-box;
- margin-bottom: 20px;
- cursor: pointer;
- .cover {
- width: 92px;
- height: 92px;
- border-radius: 17px;
- }
- .info {
- position: relative;
- width: 263px;
- margin-left: 23px;
- .name {
- width: 200px;
- position: relative;
- font-size: 15px;
- color: #000;
- font-weight: bold;
- text-overflow: ellipsis;
- white-space: nowrap;
- overflow: hidden;
- padding-left: 20px;
- line-height: 20px;
- &::after {
- content: '';
- display: block;
- width: 20px;
- height: 20px;
- position: absolute;
- left: 0;
- top: 50%;
- transform: translateY(-50%);
- background-size: 14px 14px;
- background-repeat: no-repeat;
- background-position: left center;
- }
- }
- .name {
- &::after {
- background-image: url(https://static.caimei365.com/www/authentic/pc/ldm-icon-store.png);
- }
- }
- .line {
- height: 1px;
- margin: 14px 0;
- background: rgba(0, 0, 0, 0.169);
- }
- .mobile,
- .address {
- position: relative;
- font-size: 12px;
- color: #000000;
- padding-left: 20px;
- line-height: 20px;
- text-overflow: ellipsis;
- white-space: nowrap;
- overflow: hidden;
- &::after {
- content: '';
- display: block;
- width: 20px;
- height: 20px;
- position: absolute;
- left: 0;
- top: 50%;
- transform: translateY(-50%);
- background-size: 14px 14px;
- background-repeat: no-repeat;
- background-position: left center;
- }
- }
- .mobile {
- &::after {
- background-image: url(https://static.caimei365.com/www/authentic/pc/ldm-icon-contact.png);
- }
- }
- .address {
- &::after {
- background-image: url(https://static.caimei365.com/www/authentic/pc/ldm-icon-address.png);
- }
- }
- .distance {
- position: absolute;
- font-size: 12px;
- color: #404040;
- top: 0.2vw;
- right: 0;
- }
- }
- }
- }
- }
- }
- @media screen and (max-width: 768px) {
- .page-top {
- height: 59.6vw;
- background: url(https://static.caimei365.com/www/authentic/h5/ldm-bg-club.png);
- background-size: auto 59.6vw;
- }
- .page-content {
- overflow: hidden;
- .search {
- width: 86vw;
- position: relative;
- margin: 7.6vw auto 5.6vw;
- input {
- display: block;
- width: 100%;
- height: 8vw;
- border: 0.1vw solid #000000;
- box-sizing: border-box;
- padding-left: 10.5vw;
- }
- &::after {
- position: absolute;
- left: 2.9vw;
- top: 50%;
- transform: translateY(-50%);
- content: '';
- display: block;
- width: 5.4vw;
- height: 5.4vw;
- background: url(https://static.caimei365.com/www/authentic/h5/ldm-icon-search.png)
- no-repeat center;
- background-size: 5.4vw;
- }
- }
- .title {
- text-align: right;
- padding-right: 6.6vw;
- font-size: 3.5vw;
- color: #000;
- }
- .list {
- display: flex;
- flex-direction: column;
- align-items: center;
- .section {
- width: 95.1vw;
- background: #f1f1f1;
- border-radius: 2vw;
- padding: 3.2vw;
- box-sizing: border-box;
- margin-top: 5.7vw;
- .cover {
- width: 21.5vw;
- height: 21.5vw;
- border-radius: 1.7vw;
- }
- .info {
- position: relative;
- width: 61.3vw;
- margin-left: 5.8vw;
- .name {
- width: 46vw;
- position: relative;
- font-size: 3.5vw;
- color: #000;
- font-weight: bold;
- text-overflow: ellipsis;
- white-space: nowrap;
- overflow: hidden;
- padding-left: 5vw;
- line-height: 5vw;
- &::after {
- content: '';
- display: block;
- width: 4vw;
- height: 4vw;
- position: absolute;
- left: 0;
- top: 50%;
- transform: translateY(-50%);
- background-size: 3.6vw 3.6vw;
- background-repeat: no-repeat;
- }
- }
- .name {
- &::after {
- background-image: url(https://static.caimei365.com/www/authentic/h5/ldm-icon-store.png);
- }
- }
- .line {
- height: 0.1vw;
- margin: 2.8vw 0;
- background: rgba(0, 0, 0, 0.169);
- }
- .mobile,
- .address {
- position: relative;
- font-size: 3vw;
- color: #000000;
- padding-left: 5vw;
- line-height: 5vw;
- text-overflow: ellipsis;
- white-space: nowrap;
- overflow: hidden;
- &::after {
- content: '';
- display: block;
- width: 4vw;
- height: 4vw;
- position: absolute;
- left: 0;
- top: 50%;
- transform: translateY(-50%);
- background-size: 3.6vw 3.6vw;
- background-repeat: no-repeat;
- }
- }
- .mobile {
- &::after {
- background-image: url(https://static.caimei365.com/www/authentic/h5/ldm-icon-contact.png);
- }
- }
- .address {
- &::after {
- background-image: url(https://static.caimei365.com/www/authentic/h5/ldm-icon-address.png);
- }
- }
- .distance {
- position: absolute;
- font-size: 3vw;
- color: #404040;
- top: 0.2vw;
- right: 0;
- }
- }
- }
- }
- }
- }
- </style>
|