import { drawLogo } from '@/utils' import { mapNavigate } from '@/utils/map-utils' import { callMobile } from '@/utils' import { mapGetters } from 'vuex' export default { filters: { formatEmpty(val) { return val || '暂无' }, formatSnCode(code) { if (!code) return '' return code.replace(/^(\w{2})\w+(\w{4})$/, '$1******$2') }, }, data() { return { showAuthCard: false, authId: '', clubInfo: {}, } }, computed: { ...mapGetters(['routePrefix', 'supplierInfo']), address() { let resultAddress = this.clubInfo.area ? this.clubInfo.area + this.clubInfo.address : this.clubInfo.address return resultAddress || '暂无' }, isEmpty() { return this.clubInfo.productList ? this.clubInfo.productList.length === 0 : true }, // 授权牌 authCardImage() { if (!this.clubInfo) return '' return this.clubInfo.authImage }, }, mounted() { this.initData() }, beforeDestroy() { this.$removeStorage(this.routePrefix, 'clubInfo') }, methods: { callMobile, // 显示授权牌 onShowAuthCard() { this.showAuthCard = true }, // 隐藏授权牌 onHideAuthCard() { this.showAuthCard = false }, // 设备详情 toDetail(item) { const url = `${this.routePrefix}/approve/device/detail?id=${item.productId}` this.$router.push(url) }, // 初始化 initData() { this.authId = parseInt(this.$route.query.id) const clubInfo = this.$getStorage(this.routePrefix, 'clubInfo') if (clubInfo) { this.clubInfo = clubInfo } this.fetchDetail() }, // 获取机构详细信息 async fetchDetail() { try { const res = await this.$http.api.getAuthClubDetail({ authId: this.authId, }) this.clubInfo = { ...this.clubInfo, ...res.data } // 合并 } catch (error) { console.log(error) } // 默认轮播图 if (this.clubInfo.bannerList.length <= 0) { this.clubInfo.bannerList.push('/placeholder.png') } // 默认logo if (!this.clubInfo.logo) { this.clubInfo.logo = drawLogo(this.clubInfo.authParty) } }, // 地图导航 onMapNav() { this.$refs.mapNav.open() }, // 导航 navigation(type) { const point = this.clubInfo.lngAndLat.split(',') let lng = point[0] let lat = point[1] mapNavigate( { lat, lng, title: this.clubInfo.authParty, address: this.address }, type ) this.$refs.mapNav.close() }, }, }