Files
xdd-uniapp-new/pkg_product/views/experienceProjectDetail.vue
T

708 lines
20 KiB
Vue

<template>
<view class="experience-project-page">
<hx-navbar
:fixed="true"
:background-color="[0, [0, 0, 0, 0], [0, 0, 0, 0]]"
statusBarFontColor="#ffffff"
barPlaceholder="hidden"
transparent="auto"
color="#ffffff"
/>
<scroll-view scroll-y class="page-scroll">
<view class="hero-wrap">
<swiper v-if="bannerList.length > 0 || project.video" class="hero-img" circular :autoplay="swiperAutoplay" :interval="3000" @change="handleSwiperChange">
<swiper-item v-if="project.video">
<video :src="project.video" id="hero-video" class="hero-img" :autoplay="currentSwiperIndex === 0" object-fit="contain" :controls="false" :enable-progress-gesture="false" @play="onVideoPlay" @ended="onVideoEnd" @pause="onVideoEnd" @click="toggleVideo"></video>
</swiper-item>
<swiper-item v-for="(item, index) in bannerList" :key="index">
<image :src="item" class="hero-img" mode="heightFix|widthFix" />
</swiper-item>
</swiper>
<image
v-else-if="project.cover"
:src="project.cover"
class="hero-img"
mode="aspectFill"
/>
</view>
<view class="content">
<view class="store-card">
<view class="store-name">
{{ project.name }}
</view>
<view class="store-intro">
{{ project.intro }}
</view>
<view class="store-tags" style="display: flex; flex-wrap: wrap; align-items: center;">
<view style="display: flex; align-items: center; margin-right: 16rpx; border-radius: 44rpx;">
<view style="border-radius: 44rpx 0 0 44rpx;font-size: 24rpx; color: #fff; background-color: #C52733; height: 44rpx; display: flex; align-items: center; padding: 0 20rpx; position: relative; z-index: 1;">营业时间</view>
<view style="font-size: 24rpx; color: #333; background-color: #fff; border: 2rpx solid #C52733; border-radius: 44rpx; height: 44rpx; display: flex; align-items: center; padding: 0 20rpx 0 16rpx; box-sizing: border-box; margin-left: -20rpx; position: relative; z-index: 2;">
{{ project.serviceTime || '00:00' }}~{{ project.serviceEndTime || '23:59' }}
</view>
</view>
<view class="license-tag" @click="handleViewLicense">营业执照</view>
</view>
<view class="store-meta">
<view class="meta-left">
<!-- <u-icon
:name="webUrl + '/page/qianxian/icon-location.png'"
size="20"
color="#C52733"
/> -->
<view class="meta-info">
<text class="meta-text">
{{ project.cityName }}{{ project.address }}
</text>
</view>
<view v-if="distanceText" class="distance-row">
<u-icon :name="webUrl + '/orderIcon/map.png'" size="16"></u-icon>
<text class="distance-text">距该地{{ distanceText }}</text>
</view>
</view>
<view class="meta-actions">
<view class="action-item" @click="handleNavigate">
<view class="action-icon">
<u-icon :name="webUrl + '/page/qianxian/icon-addr.png'" color="#fff" size="24"></u-icon>
</view>
<text class="action-text">导航</text>
</view>
<view class="action-item" @click="handleContact">
<view class="action-icon">
<u-icon :name="webUrl + '/page/qianxian/icon-phone.png'" color="#fff" size="24"></u-icon>
</view>
<text class="action-text">客服</text>
</view>
</view>
</view>
</view>
<view class="experience-badge-wrap">
<view class="experience-badge">
<view class="badge-diamond">
<view class="badge-icon">
<u-icon :name="webUrl + '/icon/zuanshi.png'" color="#F9D24D" size="16"></u-icon>
</view>
</view>
<view class="badge-bg">
<text class="badge-text">超值体验</text>
</view>
</view>
</view>
<view class="section">
<!-- <view class="section-title">体验项目</view> -->
<swiper
v-if="projectList.length > 0"
class="experience-swiper"
circular
:autoplay="true"
:interval="3000"
:indicator-dots="false"
indicator-color="rgba(255, 255, 255, .4)"
indicator-active-color="#ffffff"
>
<swiper-item v-for="(item, index) in projectList" :key="index">
<view class="experience-card">
<image
v-if="item.projectImage"
:src="item.projectImage"
class="experience-image"
mode="widthFix|heightFix"
/>
<view class="experience-info">
<view class="experience-title-wrap">
<view class="experience-title">
{{ item.themeName || item.projectName }}
</view>
</view>
<view class="experience-subtitle">
{{ item.projectIntro || item.detail }}
</view>
</view>
</view>
</swiper-item>
</swiper>
</view>
<view class="section" v-if="project.detailText || project.remark">
<view class="section-title" v-if="project.detailText">详情</view>
<view class="detail-list">
<view>
<u-parse :content="project.detailText"></u-parse>
</view>
</view>
<template v-if="project.remark">
<view class="section-title" style="margin-top: 24rpx;">备注</view>
<view class="section-text with-dot">
<text class="dot"></text>
<text>{{ project.remark }}</text>
</view>
</template>
</view>
<view class="section" v-if="usageNotice">
<view class="section-title">使用须知</view>
<view class="section-content">
<u-parse :content="usageNotice"></u-parse>
</view>
</view>
<view class="bottom-space" />
</view>
</scroll-view>
</view>
</template>
<script>
import { getExperienceStoreDetail } from '@/api/qianxian'
export default {
data() {
const webUrl = this.$VUE_APP_RESOURCES_URL
return {
webUrl,
project: {
id: '',
name: '',
cover: '',
intro: '',
serviceTime: '',
serviceEndTime: '',
cityName: '',
address: '',
latitude: '',
longitude: '',
phone: '',
wechat: '',
video: '',
banner: '',
experienceTitle: '',
experienceSubTitle: '',
detailText: '',
remark: '',
qualification: ''
},
detailList: [],
experienceMerchantId: '',
totalPrice: 0,
validFrom: '',
validTo: '',
usageNotice: '',
currentSwiperIndex: 0,
videoContext: null,
swiperAutoplay: true,
isVideoPlaying: false,
projectList: [],
userLatitude: null,
userLongitude: null,
distanceText: ''
}
},
computed: {
bannerList() {
if (!this.project.banner) return []
return this.project.banner.split(',').filter(item => item)
}
},
onLoad(query) {
const decode = v => decodeURIComponent(v || '')
const id = query.experienceMerchantId || query.id || ''
this.experienceMerchantId = id
this.project.id = id
this.project.name = decode(query.name)
this.project.cover = decode(query.cover)
this.project.video = decode(query.video)
this.project.banner = decode(query.banner)
this.project.intro = decode(query.intro)
this.project.serviceTime = query.serviceTime || ''
this.project.serviceEndTime = query.serviceEndTime || ''
this.project.cityName = decode(query.cityName)
this.project.address = decode(query.address)
this.project.latitude = query.latitude || ''
this.project.longitude = query.longitude || ''
this.project.experienceTitle = decode(query.experienceTitle || '')
this.project.experienceSubTitle = decode(query.experienceSubTitle || '')
this.project.detailText = decode(query.detailText || '')
this.project.remark = decode(query.remark || '')
this.validFrom = query.validFrom || ''
this.validTo = query.validTo || ''
this.usageNotice = decode(query.usageNotice || '')
this.getUserLocation()
if (query.detailList) {
try {
const list = JSON.parse(decode(query.detailList))
if (Array.isArray(list)) {
this.detailList = list.map(item => ({
name: item.name || '',
count: item.count || ''
}))
}
} catch (e) {}
}
this.fetchProjectDetail()
},
onReady() {
this.videoContext = uni.createVideoContext('hero-video', this)
},
methods: {
handleSwiperChange(e) {
this.currentSwiperIndex = e.detail.current
if (this.project.video && this.videoContext) {
if (this.currentSwiperIndex === 0) {
this.videoContext.play()
} else {
this.videoContext.pause()
}
}
},
onVideoPlay() {
this.swiperAutoplay = false
this.isVideoPlaying = true
},
onVideoEnd() {
this.swiperAutoplay = true
this.isVideoPlaying = false
},
toggleVideo() {
if (!this.videoContext) return
if (this.isVideoPlaying) {
this.videoContext.pause()
this.swiperAutoplay = true
} else {
this.videoContext.play()
}
},
fetchProjectDetail() {
if (!this.experienceMerchantId) {
return
}
uni.showLoading({
title: '加载中',
mask: true
})
getExperienceStoreDetail(this.experienceMerchantId).then(res => {
if (res && res.status === 200) {
const data = res.data || {}
this.project.name = data.name || this.project.name
this.project.cover = data.cover || this.project.cover
this.project.video = data.video || this.project.video
this.project.banner = data.banner || this.project.banner
this.project.intro = data.intro || this.project.intro
this.project.serviceTime = data.serviceTime || this.project.serviceTime
this.project.serviceEndTime = data.serviceEndTime || this.project.serviceEndTime
this.project.cityName = data.cityName || this.project.cityName
this.project.address = data.address || this.project.address
this.project.latitude = data.latitude || this.project.latitude
this.project.longitude = data.longitude || this.project.longitude
this.updateDistance()
this.project.phone = data.phone || this.project.phone
this.project.wechat = data.wechat || this.project.wechat
this.project.qualification = data.qualification || this.project.qualification
const project = data.project || {}
this.project.experienceTitle = project.themeName || this.project.experienceTitle || this.project.name
if (project.themeImage) {
this.project.cover = project.themeImage
}
this.project.detailText = project.detail || this.project.detailText
this.project.remark = project.remark || this.project.remark
this.usageNotice = project.useNotice || this.usageNotice
console.log('this.usageNotice', this.usageNotice)
if (project.totalPrice != null) {
this.totalPrice = project.totalPrice
}
if (data.totalPrice != null && this.totalPrice === 0) {
this.totalPrice = data.totalPrice
}
if (project.validityStartTime) {
this.validFrom = project.validityStartTime
}
if (project.validityEndTime) {
this.validTo = project.validityEndTime
}
if (project.projectList && project.projectList.length) {
this.projectList = project.projectList
this.detailList = project.projectList.map(item => ({
name: item.projectName || '',
count: item.projectIntro || ''
}))
}
}
}).finally(() => {
uni.hideLoading()
})
},
getUserLocation() {
uni.getLocation({
type: 'gcj02',
success: res => {
this.userLatitude = Number(res.latitude)
this.userLongitude = Number(res.longitude)
this.updateDistance()
}
})
},
calculateDistance(lat1, lon1, lat2, lon2) {
if (!lat1 || !lon1 || !lat2 || !lon2) {
return ''
}
const R = 6371
const dLat = (lat2 - lat1) * Math.PI / 180
const dLon = (lon2 - lon1) * Math.PI / 180
const a =
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) *
Math.sin(dLon / 2) * Math.sin(dLon / 2)
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))
const d = R * c
return d.toFixed(1) + 'km'
},
updateDistance() {
const storeLatitude = Number(this.project.latitude)
const storeLongitude = Number(this.project.longitude)
if (
this.userLatitude == null ||
this.userLongitude == null ||
!storeLatitude ||
!storeLongitude
) {
this.distanceText = ''
return
}
this.distanceText = this.calculateDistance(
this.userLatitude,
this.userLongitude,
storeLatitude,
storeLongitude
)
},
handleNavigate() {
if (!this.project.latitude || !this.project.longitude) {
uni.showToast({
title: '暂无位置信息',
icon: 'none'
})
return
}
uni.openLocation({
latitude: Number(this.project.latitude),
longitude: Number(this.project.longitude),
name: this.project.name,
address: this.project.address
})
},
handleContact() {
if (!this.project.phone) {
uni.showToast({
title: '暂无联系方式',
icon: 'none'
})
return
}
uni.makePhoneCall({
phoneNumber: this.project.phone
})
},
handleViewLicense() {
if (this.project.qualification) {
uni.navigateTo({
url: `/pkg_product/views/storeLicense?name=${encodeURIComponent(this.project.name)}&images=${encodeURIComponent(this.project.qualification)}`
})
} else {
uni.showToast({
title: '暂无营业执照',
icon: 'none'
})
}
}
}
}
</script>
<style scoped lang="less">
.experience-project-page {
min-height: 100vh;
background: #f5f5f5;
}
.page-scroll {
// height: calc(100vh - 120rpx);
}
.hero-wrap {
position: relative;
width: 100%;
height: 700rpx;
overflow: hidden;
}
.hero-img {
width: 100%;
height: 100%;
}
.content {
margin-top: -100rpx;
padding: 0 24rpx 40rpx;
box-sizing: border-box;
position: relative;
z-index: 2;
}
.store-card {
padding: 32rpx 24rpx;
border-radius: 24rpx;
background: #ffffff;
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.06);
}
.store-name {
color: #333;
font-size: 36rpx;
font-weight: bold;
}
.store-intro {
margin-top: 16rpx;
color: #666;
font-size: 26rpx;
line-height: 1.5;
}
.store-tags {
display: flex;
align-items: center;
margin-top: 24rpx;
gap: 16rpx;
}
.time-tag {
display: flex;
align-items: center;
border: 1rpx solid #C52733;
border-radius: 24rpx;
overflow: hidden;
height: 40rpx;
}
.time-tag-label {
background: #C52733;
color: #ffffff;
font-size: 22rpx;
padding: 0 16rpx;
height: 100%;
line-height: 40rpx;
}
.time-tag-value {
color: #333;
font-size: 22rpx;
padding: 0 16rpx;
height: 100%;
line-height: 40rpx;
background: #ffffff;
}
.license-tag {
border: 1rpx solid #C52733;
color: #C52733;
font-size: 22rpx;
padding: 0 16rpx;
border-radius: 24rpx;
height: 40rpx;
line-height: 40rpx;
}
.store-meta {
margin-top: 32rpx;
padding-top: 32rpx;
// border-top: 1rpx solid #f0f0f0;
display: flex;
align-items: center;
justify-content: space-between;
}
.meta-left {
flex: 1;
// display: flex;
align-items: center;
padding-right: 32rpx;
}
.meta-info {
display: flex;
flex-direction: column;
row-gap: 8rpx;
}
.distance-row {
margin-left: 4rpx;
display: flex;
align-items: center;
column-gap: 8rpx;
}
.distance-text {
font-size: 22rpx;
color: #666;
margin-top: 8rpx;
}
.meta-text {
margin-left: 12rpx;
font-size: 26rpx;
color: #333;
font-weight: 500;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
}
.meta-actions {
display: flex;
align-items: center;
gap: 32rpx;
flex-shrink: 0;
}
.action-item {
display: flex;
flex-direction: column;
align-items: center;
}
.action-icon {
width: 64rpx;
height: 64rpx;
border-radius: 50%;
background: #C52733;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 8rpx;
}
.action-text {
font-size: 22rpx;
color: #333;
}
.section-experience {
margin-top: 40rpx;
position: relative;
}
.experience-badge-wrap {
z-index: 10;
margin-top: 40rpx;
margin-left: 20rpx;
}
.experience-badge {
display: flex;
align-items: center;
position: relative;
height: 44rpx;
}
.badge-diamond {
width: 44rpx;
height: 44rpx;
background: #ffffff;
border: 4rpx solid #C52733;
transform: rotate(45deg);
display: flex;
align-items: center;
justify-content: center;
z-index: 2;
box-sizing: border-box;
margin-left: -14rpx;
}
.badge-icon {
transform: rotate(-45deg);
display: flex;
align-items: center;
justify-content: center;
}
.badge-bg {
background: #C52733;
border-radius: 0 24rpx 24rpx 0;
height: 100%;
display: flex;
align-items: center;
padding: 0 20rpx 0 24rpx;
margin-left: -16rpx;
}
.badge-text {
color: #ffffff;
font-size: 24rpx;
font-weight: bold;
font-style: italic;
line-height: 1;
}
.experience-card {
border-radius: 24rpx;
background: #C52733;
overflow: hidden;
box-shadow: 0 8rpx 24rpx rgba(197, 39, 51, 0.15);
margin-bottom: 24rpx;
}
.experience-swiper {
margin-top: 16rpx;
width: 100%;
height: 520rpx;
}
.experience-image {
width: 100%;
height: 360rpx;
border-radius: 24rpx;
display: block;
}
.experience-info {
padding: 24rpx;
}
.experience-title-wrap {
display: inline-block;
background: #ffffff;
border-radius: 40rpx;
padding: 8rpx 32rpx;
margin-bottom: 16rpx;
}
.experience-title {
color: #C52733;
font-size: 32rpx;
font-weight: bold;
}
.experience-subtitle {
color: #ffffff;
font-size: 26rpx;
opacity: 0.9;
}
.section {
margin-top: 24rpx;
padding: 32rpx 24rpx;
border-radius: 24rpx;
background: #ffffff;
}
.section-title {
font-size: 32rpx;
font-weight: bold;
color: #333;
margin-bottom: 24rpx;
}
.detail-list {
background: transparent;
}
.detail-item {
display: flex;
align-items: flex-start;
justify-content: space-between;
font-size: 26rpx;
color: #666;
margin-bottom: 16rpx;
}
.detail-name {
flex: 1;
display: flex;
align-items: flex-start;
line-height: 1.5;
}
.detail-count {
margin-left: 24rpx;
color: #999;
}
.dot {
display: inline-block;
width: 8rpx;
height: 8rpx;
border-radius: 50%;
background: #999;
margin-top: 14rpx;
margin-right: 16rpx;
flex-shrink: 0;
}
.section-text {
font-size: 26rpx;
color: #666;
line-height: 1.6;
}
.with-dot {
display: flex;
align-items: flex-start;
margin-bottom: 16rpx;
}
.bottom-space {
height: 40rpx;
}
</style>