123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465 |
- <template>
- <div class="page">
- <div class="page-top flex flex-col justify-center items-center">
- <img class="logo" :src="supplierInfo.logo" />
- <div class="mt-2 name">
- <span v-text="supplierInfo.shopName"></span>
- <span>官方授权机构</span>
- </div>
- </div>
- <div class="page-content">
- <!-- 搜索区域 -->
- <div class="search">
- <simple-search v-model="listQuery.clubName" @search="onSearch" />
- </div>
- <!-- 地区选择 -->
- <div class="city">
- <SimpleCity
- @change="onCityChange"
- :options="cityList"
- labelName="name"
- valueName="id"
- ></SimpleCity>
- </div>
- <!-- 标题 -->
- <div class="title flex justify-between px-4 pt-8 pb-8 md:px-0">
- <div>距您最近...</div>
- <div>共<span v-text="total"></span>家机构</div>
- </div>
- <!-- 列表 -->
- <div class="list">
- <template v-for="item in list">
- <div
- class="section flex justify-between mb-4"
- :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="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>
- </template>
- <div class="empty" v-for="i in emptyList" :key="i"></div>
- </div>
- <!-- 列表为空 -->
- <SimpleEmpty
- v-if="!total && !isRequest"
- description="敬请期待~"
- ></SimpleEmpty>
- <!-- 页码 -->
- <SimplePagination
- v-if="total > listQuery.pageSize"
- :total="total"
- :pageItems="listQuery.pageSize"
- @change="onPagiantionChange"
- ></SimplePagination>
- </div>
- </div>
- </template>
- <script>
- import { mapGetters } from 'vuex'
- import { loactionSelf } from '@/utils/map-utils'
- import { drawLogo } from '@/utils'
- export default {
- layout: 'app',
- data() {
- return {
- isRequest: true,
- list: [],
- listQuery: {
- appId: '',
- lngAndLat: '',
- clubName: '',
- provinceId: '',
- cityId: '',
- townId: '',
- pageNum: 1,
- pageSize: 10,
- },
- total: 0,
- cityList: [],
- }
- },
- computed: {
- ...mapGetters(['supplierInfo', 'appId']),
- emptyList() {
- return 3 - (this.list.length % 3)
- },
- },
- mounted() {
- this.initData()
- this.fetchCityList()
- },
- methods: {
- // 绘制logo的方法
- drawLogo,
- // 查看详情
- toDetail(item) {
- localStorage.setItem('clubInfo', JSON.stringify(item))
- this.$router.push('/ph/approve/club/detail')
- },
- // 初始化页面数据
- 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.appId = this.appId
- // 获取机构列表
- this.fetchList()
- },
- // 获取机构列表
- async fetchList() {
- try {
- const res = await this.$http.api.getAuthClubList(this.listQuery)
- this.total = res.data.total
- this.list = res.data.list
- } catch (error) {
- console.log(error)
- } finally {
- this.$toast.clear()
- this.isRequest = false
- }
- },
- // 获取地址列表
- 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.fetchList()
- },
- // 搜索
- onSearch() {
- this.listQuery.pageNum = 1
- this.fetchList()
- },
- // 页码变化
- onPagiantionChange(index) {
- this.listQuery.pageNum = index
- this.fetchList()
- },
- // 格式化地址
- formatAddress(a1, a2) {
- let resutl = ''
- if (typeof a1 === 'string') {
- resutl += a1
- }
- if (typeof a2 === 'string') {
- resutl += a2
- }
- return resutl || '未知'
- },
- },
- beforeDestroy() {
- this.$toast.clear()
- },
- }
- </script>
- <style scoped lang="scss">
- // pc 端
- @media screen and (min-width: 768px) {
- .page {
- position: relative;
- min-height: calc(100vh - 80px - 80px);
- background-color: #fff;
- }
- .page-top {
- height: 420px;
- background: url(https://static.caimei365.com/www/authentic/pc/bg-club.png);
- background-size: auto 420px;
- .logo {
- display: block;
- width: 120px;
- height: 120px;
- border-radius: 50%;
- }
- .name {
- font-size: 30px;
- color: #fff;
- }
- .logo,
- .name {
- transform: translateY(-60px);
- }
- }
- .page-content {
- width: 1200px;
- margin: 0 auto;
- .search {
- position: absolute;
- left: 50%;
- top: 260px;
- transform: translateX(-50%);
- }
- .city {
- position: absolute;
- left: 50%;
- top: 320px;
- transform: translateX(-50%);
- z-index: 9;
- }
- .title {
- font-size: 16px;
- color: #404040;
- span {
- color: #bc1724;
- }
- }
- .list {
- display: flex;
- align-items: center;
- justify-content: space-between;
- flex-wrap: wrap;
- .empty {
- width: 390px;
- }
- .section {
- width: 390px;
- height: 108px;
- background-color: #f3f5f6;
- border-radius: 4px;
- box-sizing: border-box;
- padding: 12px;
- cursor: pointer;
- transition: all 0.4s;
- &:hover {
- box-shadow: 0 0 24px rgba(0, 0, 0, 0.2);
- }
- .cover {
- display: block;
- width: 84px;
- height: 84px;
- }
- .info {
- position: relative;
- margin-left: 12px;
- .name {
- font-size: 16px;
- color: #101010;
- font-weight: bold;
- margin-bottom: 16px;
- text-overflow: ellipsis;
- white-space: nowrap;
- overflow: hidden;
- }
- .mobile,
- .address {
- width: 268px;
- position: relative;
- font-size: 14px;
- color: #404040;
- padding-left: 24px;
- line-height: 24px;
- text-overflow: ellipsis;
- white-space: nowrap;
- overflow: hidden;
- &::after {
- content: '';
- display: block;
- width: 16px;
- height: 16px;
- position: absolute;
- left: 0;
- top: 50%;
- transform: translateY(-50%);
- background-size: 16px;
- background-repeat: no-repeat;
- }
- }
- .mobile {
- &::after {
- background-image: url(https://static.caimei365.com/www/authentic/pc/icon-phone.png);
- }
- }
- .address {
- &::after {
- background-image: url(https://static.caimei365.com/www/authentic/pc/icon-address.png);
- }
- }
- .distance {
- position: absolute;
- font-size: 12px;
- color: #404040;
- top: 2px;
- right: 0;
- }
- }
- }
- }
- }
- }
- // 移动 端
- @media screen and (max-width: 768px) {
- .page-top {
- height: 46vw;
- background: url(https://static.caimei365.com/www/authentic/h5/bg-club.png);
- background-size: auto 46vw;
- .logo {
- display: block;
- width: 14.8vw;
- height: 14.8vw;
- border-radius: 50%;
- }
- .name {
- font-size: 4vw;
- color: #fff;
- }
- }
- .page-content {
- position: relative;
- .search {
- position: absolute;
- left: 50%;
- top: 0;
- transform: translate(-50%, -50%);
- }
- .city {
- position: relative;
- z-index: 9;
- padding-top: 12vw;
- }
- .title {
- font-size: 3.4vw;
- color: #404040;
- span {
- color: #bc1724;
- }
- }
- .list {
- display: flex;
- align-items: center;
- flex-direction: column;
- .section {
- width: 93.6vw;
- height: 26vw;
- background-color: #f3f5f6;
- border-radius: 4px;
- box-sizing: border-box;
- padding: 3.2vw;
- .cover {
- display: block;
- width: 19.6vw;
- height: 19.6vw;
- }
- .info {
- position: relative;
- margin-left: 3.2vw;
- .name {
- font-size: 4vw;
- color: #101010;
- font-weight: bold;
- margin-bottom: 4vw;
- text-overflow: ellipsis;
- white-space: nowrap;
- overflow: hidden;
- }
- .mobile,
- .address {
- width: 66vw;
- position: relative;
- font-size: 3vw;
- color: #404040;
- 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: 4vw 4vw;
- background-repeat: no-repeat;
- }
- }
- .mobile {
- &::after {
- background-image: url(https://static.caimei365.com/www/authentic/h5/icon-phone.png);
- }
- }
- .address {
- &::after {
- background-image: url(https://static.caimei365.com/www/authentic/h5/icon-address.png);
- }
- }
- .distance {
- position: absolute;
- font-size: 3vw;
- color: #404040;
- top: 0.8vw;
- right: 0;
- }
- }
- }
- }
- }
- }
- </style>
|