Commit c9ceff6e by 李伟康

feat(equity): 添加权益详情页面功能

- 创建新的权益详情页面组件 detail/index.uvue
- 实现页面导航栏和返回功能
- 集成媒体内容展示模块,支持多种组件动态渲染
- 添加触摸滑动切换功能,支持左右滑动浏览
- 实现画笔工具状态控制和缩放功能
- 集成支付流程相关组件和逻辑
- 添加品牌车型配置支持和数据绑定
- 实现页面动画效果和样式布局
- 集成存储管理和用户信息获取功能
1 parent dab046f4
<template>
<view
class="detail-box"
:key="dateilKey"
>
<view
class="nav-bar"
:style="{ 'z-index': backZindex }"
>
<view
class="back"
@click="back"
>
<uni-icons
type="left"
:size="20"
color="#000"
>
</uni-icons>
</view>
</view>
<template v-for="(item, index) in (useCarConfig ? moduleList : media)" :key="index">
<view
:class="['view', { showView: id == item.id }, modeName]"
@touchstart.stop="touchStart"
@touchend.stop="touchEnd"
>
<component
@full="handleFull"
:detail="item"
:is="item.componentName"
:views="item.receptionSourceDetailList || []"
:penSwitch="penSwitch"
:show="id == item.id"
:ref="'media' + item.id"
:title="item.detailTitle || ''"
:madiaId="item.id"
@scale="scale"
:ulList="item.ulList"
:screenList="item.screenList"
@onProductModel="productModelStatus = $event"
:isPreview="isPreview"
:isByd="isByd"
:hasCarBrand="item.hasCarBrand"
:aitoCarModelIds="aitoCarModelIds"
/>
</view>
</template>
<template v-if="type != 'preview'">
<template v-if="backZindex">
<!-- <tool-box
ref="toolRef"
:data="pageToolList"
:type="type"
@choose="choose"
@finish="open"
:id="id"
@toPay="toPay"
:showPayBtn="watchPayInfo"
/> -->
<view
class="pen-box"
@click="drawStatus = !drawStatus"
>
<view :class="['sprite-icon', `${!drawStatus ? 'icon-pen' : 'icon-pen-active'}`]">
</view>
</view>
</template>
</template>
<!-- <pay-pop
ref="pay"
@jumpPay="showPayPage = true"
>
</pay-pop>
<finish-step
ref="stepRef"
@submit="done"
:titleTips="finishTips"
/>
<informationEntry
:showPayPage.sync="showPayPage"
@finish="open"
/> -->
</view>
</template>
<script setup lang="uts">
import { storage } from '@/utils/storage.uts'
// import ToolBox from '@/components/ToolBox.vue'
// import Reception from './components/Reception.vue'
// import CaseCenter from './components/CaseCenter.vue'
// import MediaComponent from './components/MediaComponent.vue'
// import History from './components/History.vue'
// import ThreeGuarantees from './components/ThreeGuarantees.vue'
// import payPop from './components/payPop.vue'
// import FinishStep from '@/components/FinishStep.vue'
// import informationEntry from './components/informationEntry.vue'
// import insurance from '@/components/Insurance/Insurance.vue'
// import { receptionTrackMixin } from '@/mixin/index.js'
import { ref, ComponentPublicInstance } from 'vue'
import { state } from "@/store/index.uts";
const backZindex = ref<number>(9)
const drawStatus = ref<boolean>(false)
const startX = ref<any>(null)
const startY = ref<any>(null)
const screenWidth = ref<any>(null)
const scaleValueObject = ref<UJSObject>({})
const showPayPage = ref<boolean>(false)
const productModelStatus = ref<boolean>(false)
const modeName = ref<string>('')
const pageToolList = ref<Array>([])
const moduleList = ref<Array>([])
const useCarConfig = ref<boolean>(false)
const dateilKey = ref<number>(Date.now())
const currentMediaId = ref<string>('')
const id = ref<string>('')
const type = ref<string>('')
const channelType = computed(() => {
const { channelType } = storage.get('userInfo')
return channelType
})
const shopMerchantId = computed(() => {
const { shopMerchantId } = storage.get('userInfo')
return shopMerchantId
})
const sceneType = computed(() => {
const { sceneType } = storage.get('userInfo')
return sceneType
})
const currentCarInfo = computed(() => {
return state.user.currentCarInfo
})
const watchStatus = computed(() => {
return state.user.historyStatus
})
const penSwitch = computed(() => {
return !props.isPreview && drawStatus.value
})
const watchPayInfo = computed(() => {
return state.user.paymentType.length ? true : false
})
const title = computed(() => {
// let { id } = props
// let name = props.media.find(e => e.id == id)?.detailTitle || ''
// return name
})
const finishTips = computed(() => {
let text = ''
if (channelType.value == 3) text = '检测到"汽车保险告知书"中未填写客户档案,请填写后再完成接待。'
return text
})
const isByd = computed(() => {
return channelType.value == 2
})
const isPreview = computed(() => {
return type.value == 'preview'
})
const customerInfo = computed(() => {
return state.user.customerInfo
})
const viewKey = computed(() => {
return state.user.viewKey
})
watch(() => watchStatus.value, (newval) => {
useCarConfig.value = false
dateilKey.value = Date.now()
// pageToolList.value = props.toolList
currentMediaId.value = id.value
if (newval) drawStatus.value = false
}, { immediate: true })
watch(() => id.value, (newval) => {
// if (!pageToolList.value.length) pageToolList.value = props.toolList
}, { immediate: true })
onMounted(() => {
const systemInfo = uni.getSystemInfoSync()
screenWidth.value = systemInfo.screenWidth
})
onLoad((options: OnLoadOptions) => {
const storageKey = `source_${sceneType.value}_${shopMerchantId.value}`
const data = uni.getStorageSync(storageKey)
id.value = options.id
type.value = options.type
pageToolList.value = data.toolList
console.log(data,'-----')
setPageData()
})
function open() {
stepRef.value?.open()
}
function handleFull(val: boolean) {
backZindex.value = val ? 0 : 9
}
function choose(e: any) {
Object.keys($refs).map(refKey => {
let ref = ($refs as any)[refKey]
if (ref) {
if (Array.isArray(ref)) ref = ref[0]
ref && ref.closeAllPopup && ref.closeAllPopup()
}
})
// receptionTrackLeave()
emit('update:id', e.id)
uni.$logger.local.info(`预览${e.title}`)
}
function back (): void{
if(showPayPage.value) return showPayPage.value = false
if(type.value !== 'preview') return
else uni.navigateBack()
}
function done(e: any) {
showPayPage.value = false
toolRef.value?.hide()
stepRef.value?.close()
// receptionTrackLeave()
emit('done', e)
}
function toPay() {
payRef.value?.show()
}
function touchStart(e: any) {
if (!drawStatus.value && e.changedTouches?.length) {
startX.value = e.changedTouches[0].pageX
startY.value = e.changedTouches[0].pageY
}
}
function touchEnd(e: any) {
if (modeName.value) return
try {
let { pageToolList: pageToolListVal, drawStatus: drawStatusVal, startX: startXVal, screenWidth: screenWidthVal, id, scaleValueObject: scaleValueObjectVal, productModelStatus: productModelStatusVal } = this
if (!e || !e.changedTouches || drawStatusVal || pageToolListVal.length == 0 || e.changedTouches.length === 0) return
let halfScreenWidth = screenWidthVal / 2,
touch = e.changedTouches[0],
isDistanceSignificant = Math.abs(touch.pageX - startXVal) > screenWidthVal / 6,
index = pageToolListVal.findIndex((item: any) => item.id == id)
if (Math.abs(startYVal - touch.pageY) > 150) return
if (!scaleValueObjectVal[id]) scaleValueObjectVal[id] = 1
if (isDistanceSignificant && index != -1 && scaleValueObjectVal[id] == 1 && !productModelStatusVal) {
const { nextId, modeName: modeNameVal, title: titleVal } = getNextId(index, pageToolListVal, startXVal, halfScreenWidth)
modeName.value = modeNameVal
// receptionTrackLeave()
emit('update:id', nextId)
uni.$logger.local.info(`预览${titleVal}`)
setTimeout(() => {
modeName.value = ''
}, 500)
}
} catch (error) {
console.log(error)
}
}
function getNextId(index: number, pageToolList: Array, startX: number, halfScreenWidth: number) {
let nextItem = {},
modeName = ''
if (startX > halfScreenWidth) {
nextItem = index === pageToolList.length - 1 ? pageToolList[0] : pageToolList[index + 1]
modeName = 'to-right'
} else {
nextItem = index === 0 ? pageToolList[pageToolList.length - 1] : pageToolList[index - 1]
modeName = 'to-left'
}
return {
nextId: (nextItem as any).id,
modeName,
title: (nextItem as any).title
}
}
function scale(e: number) {
let { id } = props
scaleValueObject.value[id] = e
}
async function setPageData() {
return
const { carBrandId, carChildsBrandId } = currentCarInfo.value,
params = {
brandId: carBrandId,
subBrandId: carChildsBrandId
}
let storageName = `source_${sceneType.value}_${shopMerchantId.value}_${carBrandId}_${carChildsBrandId}`
let data = uni.getStorageSync(storageName)
try {
let requestData = await uni.$api.systemApi.getSoureData(shopMerchantId.value, sceneType.value, params)
if (requestData) setViewInfo(requestData)
} catch (error) {
if (data) setViewInfo(data)
}
}
function setViewInfo(data: any) {
let array = moduleList.value,
{ detailTitle } = array.find((item: any) => item.id == id.value)
// receptionTrackLeave()
moduleList.value = data.moduleList
pageToolList.value = data.toolList
useCarConfig.value = true
if (data.id != currentMediaId.value) {
let jumpItem = data.moduleList.find((e: any) => e.detailTitle == detailTitle)
emit('update:id', jumpItem ? jumpItem.id : data.moduleList[0].id)
}
currentMediaId.value = id
}
// const { receptionTrackLeave } = receptionTrackMixin.methods
const emit = defineEmits(['update:id',
'back',
'done'])
const toolRef = ref(null)
const payRef = ref(null)
const stepRef = ref(null)
</script>
<style lang="scss">
.detail-box {
position: relative;
width: 100vw;
height: 100vh;
margin: 0 auto;
}
.nav-bar {
position: fixed;
width: 100%;
height: 96rpx;
left: 0;
top: 48rpx;
z-index: 9;
pointer-events: none;
.back {
height: 100%;
aspect-ratio: 1/1;
display: flex;
align-items: center;
justify-content: center;
pointer-events: auto;
}
}
.pen-box {
position: fixed;
right: 40rpx;
top: 5%;
width: 120rpx;
height: 120rpx;
z-index: 10;
box-shadow: 0 4rpx 12rpx 0 #00000033;
border-radius: 16rpx;
overflow: hidden;
image {
width: 100%;
height: 100%;
}
}
.view {
position: absolute;
width: 100%;
height: 100%;
z-index: -1;
top: 0;
left: 0;
visibility: hidden;
}
.showView {
position: absolute;
z-index: 1;
visibility: visible;
}
.to-left {
animation: to-left 0.25s forwards;
}
.to-right {
animation: to-right 0.25s forwards;
}
@keyframes to-left {
0% {
left: -100%;
}
100% {
left: 0;
}
}
@keyframes to-right {
0% {
left: 100%;
}
100% {
left: 0;
}
}
</style>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!