Commit ed536890 by 李伟康

refactor(components): 重构车辆品牌组件和消息框组件

- 将CarBrands组件从选项式API转换为组合式API
- 添加CustomPopup自定义弹窗组件替换原有的uni-popup
- 修改MessageBox组件使用新的CustomPopup组件
- 优化代码结构和类型定义
- 修复样式单位从toRpx到rpx的转换
- 更新导入语句和状态管理方式
- 调整组件暴露方法和事件处理逻辑
1 parent 2f29f6dc
Showing 25 changed files with 747 additions and 1306 deletions
<template>
<view
v-if="showMask"
class="custom-popup-mask"
:class="{ 'mask-visible': isAnimated }"
@click="handleMaskClick"
>
<view
class="custom-popup-content"
:class="[`popup-${positionClass}`, { 'content-visible': isAnimated }]"
@click.stop
>
<slot></slot>
</view>
</view>
</template>
<script setup lang="uts">
const props = defineProps({
visible: {
type: Boolean,
default: false
},
position: {
type: String,
default: "center"
},
maskClosable: {
type: Boolean,
default: true
},
duration: {
type: Number,
default: 300
}
})
const emit = defineEmits(['update:visible', 'close', 'mask-click', 'opened', 'closed'])
const showMask = ref<boolean>(props.visible)
const isAnimated = ref<boolean>(false)
let closeTimer: any = null
let openTimer: any = null
const positionClass = computed(() => {
const positionMap: Record<string, string> = {
'top': 'top',
'center': 'center',
'bottom': 'bottom',
'left': 'left',
'right': 'right'
}
return positionMap[props.position] || 'center'
})
watch(() => props.visible, (newVal) => {
if (newVal) {
// 打开流程
if (closeTimer) {
clearTimeout(closeTimer)
closeTimer = null
}
if (openTimer) {
clearTimeout(openTimer)
openTimer= null
}
showMask.value = true
isAnimated.value = false
// 等待 DOM 渲染后添加动画类
openTimer = setTimeout(() => {
isAnimated.value = true
}, 50)
// 动画完成后触发事件
setTimeout(() => {
emit('opened')
}, props.duration + 50)
} else {
// 关闭流程
if (openTimer) {
clearTimeout(openTimer)
openTimer = null
}
isAnimated.value = false
closeTimer= setTimeout(() => {
showMask.value = false
emit('closed')
}, props.duration)
}
}, { immediate: true })
function handleMaskClick(): void {
emit('mask-click')
if (props.maskClosable) {
close()
}
}
function close(): void {
emit('update:visible', false)
emit('close')
}
function open(): void {
emit('update:visible', true)
}
defineExpose({
open,
close
})
</script>
<style scoped lang="scss">
.custom-popup-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.3);
z-index: 1000;
display: flex;
justify-content: center;
align-items: center;
opacity: 0;
transition: opacity 0.3s ease;
&.mask-visible {
opacity: 1;
}
}
.custom-popup-content {
position: absolute;
max-height: 90%;
opacity: 0;
transform: scale(0.95);
transition: opacity 0.3s ease, transform 0.3s ease;
&.content-visible {
opacity: 1;
transform: scale(1);
}
&.popup-top {
top: 0;
left: 50%;
transform: translateY(-100%) translateX(-50%);
width: 100%;
border-bottom-left-radius: 20rpx;
border-bottom-right-radius: 20rpx;
&.content-visible {
transform: translateY(0) translateX(-50%);
}
}
&.popup-center {
top: 50%;
left: 50%;
transform: translate(-50%, -50%) scale(0.95);
min-width: 600rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.15);
&.content-visible {
transform: translate(-50%, -50%) scale(1);
}
}
&.popup-bottom {
bottom: 0;
left: 50%;
transform: translateY(100%) translateX(-50%);
width: 100%;
border-top-left-radius: 20rpx;
border-top-right-radius: 20rpx;
&.content-visible {
transform: translateY(0) translateX(-50%);
}
}
&.popup-left {
top: 50%;
left: 0;
transform: translateX(-100%) translateY(-50%);
height: 100%;
max-width: 80vw;
border-top-right-radius: 20rpx;
border-bottom-right-radius: 20rpx;
&.content-visible {
transform: translateX(0) translateY(-50%);
}
}
&.popup-right {
top: 50%;
right: 0;
transform: translateX(100%) translateY(-50%);
height: 100%;
max-width: 80vw;
border-top-left-radius: 20rpx;
border-bottom-left-radius: 20rpx;
&.content-visible {
transform: translateX(0) translateY(-50%);
}
}
}
</style>
\ No newline at end of file
<template>
<uni-popup
ref="tips"
:type="position"
:is-mask-click="false"
:animation="animation"
<CustomPopup
ref="popupRef"
:visible="visible"
:position="position"
:mask-closable="false"
:duration="300"
@update:visible="visible = $event"
@close="onClose"
>
<view
class="tips-wrapper"
:style="{ width: popupW + 'rpx', minHeight: popupH + 'rpx',maxHeight: maxHeight + 'rpx' }"
class="tips-wrapper"
:style="{ width: popupW + 'rpx', minHeight: popupH + 'rpx', maxHeight: maxHeight + 'rpx' }"
>
<view class="tips-content">
<view
class="icon-close-box flex"
class="icon-close-box flex"
@click="close"
>
<uni-icons
class="icon-close"
type="closeempty"
class="icon-close"
type="closeempty"
:size="18"
color="#1A1A1A"
color="#1A1A1A"
></uni-icons>
</view>
<view class="tips-title">
<template v-if="back">
<view
class="sprite-icon icon-back"
class="sprite-icon icon-back"
@click="close"
></view>
</template>
{{ title }}
</view>
<text
class="tips-text"
v-if="content"
class="tips-text"
v-if="content"
>{{ content }}</text>
<slot></slot>
</view>
<view
class="tips-footer"
v-if="isFooter"
class="tips-footer"
v-if="isFooter"
>
<view
v-if="showCancelBtn"
class="tips-btn close"
@click="cancel()"
v-if="showCancelBtn"
class="tips-btn close"
@click="cancel"
>{{
cancelBtnText
cancelBtnText
}}</view>
<view
class="tips-btn preview"
@click="confirm()"
class="tips-btn preview"
@click="confirm"
>{{
confirmBtnText
confirmBtnText
}}</view>
</view>
<template v-else>
<slot name="footer"></slot>
</template>
</view>
</uni-popup>
</CustomPopup>
</template>
<script>
export default {
name: "MessageBox",
data () {
return {};
<script setup lang="uts">
import CustomPopup from './CustomPopup.uvue'
const props = defineProps({
isAutoClose: {
type: Boolean,
default: true
},
props: {
animation: {
type: Boolean,
default: true
},
isAutoClose: {
type: Boolean,
default: true,
},
position: {
type: String,
default: "center",
},
popupW: {
type: Number,
},
popupH: {
type: Number,
default: 372,
},
isFooter: {
type: Boolean,
default: true,
},
title: {
type: String,
default: "提示",
},
content: {
type: String,
default: "",
},
confirmBtnText: {
type: String,
default: "确定",
},
cancelBtnText: {
type: String,
default: "取消",
},
maxHeight: Number,
back: Boolean,
showCancelBtn: {
type: Boolean,
default: true,
}
position: {
type: String,
default: "center"
},
popupW: Number,
popupH: {
type: Number,
default: 372
},
isFooter: {
type: Boolean,
default: true
},
title: {
type: String,
default: "提示"
},
content: {
type: String,
default: ""
},
methods: {
close () {
this.$refs.tips.close();
this.$emit("close");
},
open () {
this.$refs.tips.open();
},
cancel () {
if (this.isAutoClose) this.$refs.tips.close();
this.$emit("cancel");
},
confirm () {
if (this.isAutoClose) this.$refs.tips.close();
this.$emit("confirm");
},
confirmBtnText: {
type: String,
default: "确定"
},
};
cancelBtnText: {
type: String,
default: "取消"
},
maxHeight: Number,
back: Boolean,
showCancelBtn: {
type: Boolean,
default: true
}
})
const emit = defineEmits(['close', 'cancel', 'confirm'])
const visible = ref<boolean>(false)
const popupRef= ref<any>(null)
function onClose(): void {
emit('close')
}
function close(): void {
if (props.isAutoClose) {
visible.value = false
} else {
popupRef.value?.close()
}
emit('close')
}
function open(): void {
visible.value = true
}
function cancel(): void {
if (props.isAutoClose) {
visible.value = false
}
emit('cancel')
}
function confirm(): void {
if (props.isAutoClose) {
visible.value = false
}
emit('confirm')
}
defineExpose({
open,
close
})
</script>
<style scoped lang="scss">
.tips-wrapper {
background: #ffffff;
border-radius: toRpx(20);
border-radius: 20rpx 20rpx 0 0;
height: 100%;
.tips-content {
padding: toRpx(48);
padding: 48rpx;
box-sizing: border-box;
height: calc(100% - #{toRpx(100)});
height: calc(100% - 100rpx);
position: relative;
.icon-close-box {
position: absolute;
right: 0;
top: 0;
width: toRpx(120);
height: toRpx(120);
width: 120rpx;
height: 120rpx;
justify-content: center;
z-index: 2;
}
.tips-title {
position: relative;
width: 100%;
font-weight: 500;
font-size: toRpx(36);
color: #292d33;
font-size: 36rpx;
color: #292d33;
text-align: center;
.icon-back {
position: absolute;
left: 0;
......@@ -166,36 +189,40 @@ export default {
}
}
}
.tips-text {
display: block;
font-size: toRpx(30);
color: #5a5e66;
letter-spacing: toRpx(1);
display: block;
font-size: 30rpx;
color: #5a5e66;
letter-spacing: 1rpx;
text-align: center;
line-height: toRpx(40);
margin-top: toRpx(48);
line-height: 40rpx;
margin-top: 48rpx;
}
.tips-footer {
display: flex;
display: flex;
align-items: center;
justify-content: center;
height: toRpx(100);
height: 100rpx;
border-top: 1px solid #e8e8e8;
.close {
color: #6c6c70;
color: #6c6c70;
}
.preview {
color: #2c66f7;
color: #2c66f7;
}
}
.tips-btn {
width: 50%;
text-align: center;
font-size: toRpx(32);
font-size: 32rpx;
text-align: center;
line-height: toRpx(44);
line-height: 44rpx;
font-weight: 500;
}
}
</style>
</style>
\ No newline at end of file
<template>
<view>
<movable-area
class="container zoom-pan-container"
@touchstart="handleTouchStart"
@touchmove="handleTouchMove"
@touchend="handleTouchEnd"
<view
class="zoom-pan-container"
:style="{ 'overflow': 'hidden', 'position': 'relative', 'touch-action': 'none' }"
@touchstart="handleTouchStart"
@touchmove="handleTouchMove"
@touchend="handleTouchEnd"
>
<view
class="content"
:style="contentStyle"
>
<movable-view
class="content"
:style="{ 'transform-origin': transformOriginStyle }"
:scale="!disabled"
:direction="scale == 1 ? 'none' : 'all'"
:scale-min="scaleMin"
:scale-max="scaleMax"
:disabled="disabled"
@scale="onScale"
:scale-value="defaultScale"
>
<slot name="content">
</slot>
</movable-view>
</movable-area>
<slot name="content">
</slot>
</view>
</view>
</template>
<script setup lang="uts">
import { throttle } from '@/utils/throttle.uts'
import { throttle } from '@/utils/common.uts'
import { state } from "@/store/index.uts"
const props = defineProps({
disabled: Boolean,
......@@ -40,48 +33,102 @@ const props = defineProps({
})
const scale = ref<number>(1)
const defaultScale = ref<number>(1)
const isScaling = ref<boolean>(false)
const transformOriginStyle = ref<string>('50% 50%')
const initialDistance = ref<number>(0)
const initialScale = ref<number>(1)
const translateX = ref<number>(0)
const translateY = ref<number>(0)
const lastTouchCenter = ref<{ x: number; y: number }>({ x: 0, y: 0 })
const currentTouchCenter = ref<{ x: number; y: number }>({ x: 0, y: 0 })
const contentStyle = computed(() => {
return {
'transform': `translate(${translateX.value}px, ${translateY.value}px) scale(${scale.value})`,
'transform-origin': 'center center',
'transition': isScaling.value ? 'none' : 'transform 0.3s ease-out',
'will-change': 'transform',
'position': 'absolute',
'left': '0',
'top': '0',
'width': '100%',
'height': '100%'
}
})
const watchStatus = computed(() => {
return useStore().state.user.historyStatus
return state.user.historyStatus
})
watch(() => watchStatus.value, (newval) => {
if (scale.value != 1) {
defaultScale.value = 1.1
scale.value = 1
translateX.value = 0
translateY.value = 0
}
scale.value = 1
transformOriginStyle.value = '50% 50%'
setTimeout(() => {
defaultScale.value = 1
}, 100)
}, { immediate: true })
function handleTouchStart(e: any): void {
if (props.disabled) return
if (e.touches.length === 2) {
isScaling.value = true
initialDistance.value = getTouchDistance(e.touches)
initialScale.value = scale.value
const center = getTouchCenter(e.touches)
lastTouchCenter.value = center
currentTouchCenter.value = center
}
}
const handleTouchMove = throttle(function(e: any): void {
if (props.disabled) return
if (isScaling.value && e.touches.length === 2) {
const currentDistance = getTouchDistance(e.touches)
const newScale = Math.max(
props.scaleMin,
Math.min(
props.scaleMax,
initialScale.value * (currentDistance / initialDistance.value)
)
)
scale.value = newScale
const center = getTouchCenter(e.touches)
transformOriginStyle.value = `${center.x}px ${center.y}px`
currentTouchCenter.value = center
if (scale.value > 1) {
const deltaX = center.x - lastTouchCenter.value.x
const deltaY = center.y - lastTouchCenter.value.y
translateX.value += deltaX
translateY.value += deltaY
}
lastTouchCenter.value = center
emit('scale', scale.value)
}
}, 16)
function handleTouchEnd(): void {
isScaling.value = false
if (isScaling.value) {
isScaling.value = false
adjustPosition()
}
}
function onScale(e: any): void {
scale.value = e.detail.scale
emit('scale', e.detail)
function adjustPosition(): void {
if (scale.value <= 1) {
translateX.value = 0
translateY.value = 0
scale.value = 1
}
}
function getTouchDistance(touches: Array<any>): number {
const dx = touches[0].pageX - touches[1].pageX
const dy = touches[0].pageY - touches[1].pageY
return Math.sqrt(dx * dx + dy * dy)
}
function getTouchCenter(touches: Array<any>): { x: number; y: number } {
......@@ -97,8 +144,9 @@ const emit = defineEmits(['scale'])
.zoom-pan-container {
width: 100%;
height: 100%;
overflow: hidden;
position: relative;
overflow: hidden;
touch-action: none;
}
.content {
......@@ -107,9 +155,7 @@ const emit = defineEmits(['scale'])
position: absolute;
left: 0;
top: 0;
}
.disabled {
pointer-events: none;
transform-origin: center center;
will-change: transform;
}
</style>
\ No newline at end of file
......@@ -172,7 +172,7 @@
.list-body {
display:flex;
flex-direction:column;
max-height: 60vh;
max-height: 60%;
overflow-y: auto;
}
.item {
......@@ -196,7 +196,7 @@
}
.showList {
display: flex;
max-height: 1000rpx;
max-height: 1048rpx;
opacity: 1;
transform: translateY(0) scale(1);
padding-bottom: 16rpx;
......
<template>
<view class="layout">
<wnCanvas
:drawStatus="penSwitch"
:canvasId="`c-${madiaId}`"
custom
@scale="onScale"
ref="canvasRef"
>
<template #customContent>
<view class="layout-content">
<PageTitle
:title="title"
:hasCarBrand="hasCarBrand"
:show="show"
/>
<template v-if="hasCarBrand">
<image
:key="viewKey"
class="content"
:src="views[customerInfo.carModelId] || require('@/assets/images/media/nothing.webp')"
/>
</template>
<template v-else>
<template v-if="views">
<image
v-if="views.detailUrl"
class="content"
:src="views.detailUrl"
/>
</template>
</template>
</view>
</template>
</wnCanvas>
</view>
</template>
<script setup lang="uts">
import PageTitle from './PageTitle.uvue'
import wnCanvas from '@/components/PanCanvas/index.uts'
import { state } from "@/store/index.uts"
interface Views {
detailUrl?: string
bgUrl?: string
[key: string]: any
}
interface CustomerInfo {
carModelId?: string
[key: string]: any
}
const props = defineProps({
views: {
type: Object as () => Views | Array<any>,
default: () => ({})
},
penSwitch: Boolean,
title: String,
madiaId: Number,
show: Boolean,
hasCarBrand: Boolean
})
const emit = defineEmits(['scale'])
const canvasRef = ref<any>(null)
const customerInfo = computed<CustomerInfo>(() => {
return state.user.customerInfo || {}
})
const viewKey = computed<string>(() => {
return state.user?.viewKey || ''
})
function onScale(e: number): void {
emit('scale', e)
}
defineExpose({
canvasRef
})
</script>
<style scoped lang="scss">
.layout {
width: 100%;
height: 100%;
&-content {
height: 100%;
position: relative;
margin: 40rpx;
}
.content {
position: absolute;
width: 100%;
height: 100%;
z-index: 1;
}
.bg {
width: 100vw;
height: 100vh;
position: fixed;
left: 0;
top: 0;
}
}
</style>
\ No newline at end of file
<template>
<view class="page-title-box flex">
{{title}}
<view
class="car-options flex"
v-if="hasCarBrand"
@click="openCarBrand"
>
{{customerInfo.carModel||'请选择'}}
<view class="sprite-icon icon-arrow-bottom"></view>
</view>
<CarBrands
ref="carBrandListVisible"
@select="handleSelect"
/>
</view>
</template>
<script setup lang="uts">
import CarBrands from '@/components/CarBrands.uvue'
import { state } from "@/store/index.uts"
import { storage } from '@/utils/storage.uts'
interface CustomerInfo {
carModel?: string
carModelId?: string
[key: string]: any
}
interface UserInfo {
channelType: number
[key: string]: any
}
const props = defineProps({
title: String,
hasCarBrand: Boolean,
show: Boolean
})
const carBrandListVisible = ref<any>(null)
const customerInfo = ref<CustomerInfo>({})
const watchCustomerInfo = computed<CustomerInfo>(() => {
return state.user?.customerInfo || {}
})
const watchStatus = computed<boolean>(() => {
return state.user?.historyStatus || false
})
const isAito = computed<boolean>(() => {
const userInfo: UserInfo = storage.get('userInfo') || { channelType: 0 }
return userInfo.channelType == 1
})
watch(() => props.show, (newval) => {
if (newval && props.hasCarBrand && !customerInfo.value.carModel && isAito.value) {
setTimeout(() => {
carBrandListVisible.value?.autoSelect()
}, 1000)
}
}, { immediate: true })
watch(() => watchCustomerInfo.value, (newval) => {
if (newval) {
customerInfo.value = { ...newval }
}
}, { immediate: true })
function handleSelect(item: any): void {
carBrandListVisible.value?.close()
customerInfo.value.carModel = item.name
customerInfo.value.carModelId = item.id
uni.$store?.dispatch('setCustomerInfo', customerInfo.value)
}
function openCarBrand(): void {
carBrandListVisible.value?.open()
}
defineExpose({
carBrandListVisible
})
</script>
<style scoped lang='scss'>
.page-title-box {
justify-content: center;
position: absolute;
height: 96rpx;
left: 0;
top: 48rpx;
font-weight: 500;
font-size: 36rpx;
color: #333;
text-align: center;
width: 100%;
z-index: 2;
.car-options {
&::before {
content: '';
width: 2rpx;
height: 36rpx;
opacity: 1;
background: #333333;
margin: 0 24rpx;
}
}
}
</style>
\ No newline at end of file
<template>
<view class="layout">
<wnCanvas
<wn-canvas
saveImageType="3"
canvasId="c-1"
:drawStatus="penSwitch"
custom
@scale="onScale"
>
<template slot="customContent">
<template #customContent>
<view class="layout-content">
<view class="title flex">
{{ title }}
......@@ -70,7 +70,7 @@
</view>
</view>
</template>
</wnCanvas>
</wn-canvas>
<car-brands
ref="carBrandListVisibleRef"
@select="onSelect($event, 'carBrandListVisible')"
......@@ -83,6 +83,8 @@
import CarBrands from '@/components/CarBrands.uvue'
// import CustomerAutocomplete from '@/components/CustomerAutocomplete.vue'
import { store } from '@/store/index.uts'
import { storage } from '@/utils/storage.uts'
import wnCanvas from '@/components/PanCanvas/index.uts'
interface FormItem {
placeholder: string
......@@ -152,7 +154,7 @@
})
const isAito = computed(() => {
const userInfo = uni.$storage.get('userInfo')
const userInfo = storage.get('userInfo')
return userInfo.channelType == 1
})
......@@ -163,7 +165,6 @@
}, { immediate: true })
watch(() => props.show, (n) => {
carBrandListVisibleRef.value.$callMethod('open')
if (n && !customerInfo.value.carModel && isAito.value) {
setTimeout(() => {
carBrandListVisibleRef.value.$callMethod('autoSelect')
......@@ -252,14 +253,20 @@
<style lang="scss">
.layout {
.flex {
display: flex;
align-items: center;
}
width: 100%;
height: 100%;
background-size: 100%;
&-content {
width:100%;
position: relative;
height: 100%;
margin: 24rpx;
padding: 24rpx;
box-sizing:border-box;
}
.title {
......@@ -277,6 +284,8 @@
}
.content {
width:100%;
height:100%;
.form-box {
height: 80rpx;
padding: 0 110rpx;
......@@ -290,12 +299,12 @@
display: flex;
gap: 0 28rpx;
height: 100%;
flex-direction: row;
&-item {
width: 524rpx;
height: 100%;
position: relative;
&-box {
position: relative;
width: 100%;
......@@ -306,6 +315,7 @@
box-sizing: border-box;
padding: 0 24rpx;
z-index: 2;
}
.input,
......@@ -320,10 +330,14 @@
box-sizing: border-box;
line-height: 80rpx;
padding: 0 !important;
flex-direction: row;
&::placeholder {
color: #999999;
}
.value{
font-size: 28rpx;
}
}
.placeholderStyle {
......
......@@ -25,7 +25,8 @@
@touchstart.stop="touchStart"
@touchend.stop="touchEnd"
>
<component
<!-- 不支持动态组件 -->
<!-- <component
:is="item.componentName"
:detail="item"
@full="handleFull"
......@@ -41,7 +42,29 @@
@onProductModel="productModelStatus = $event"
:isPreview="isPreview"
:hasCarBrand="item.hasCarBrand"
/>
/> -->
<template v-if="item.componentName == 'reception'">
<reception
:views="item.receptionSourceDetailList || []"
:penSwitch="penSwitch"
:show="id == item.id"
:ref="'media' + item.id"
:title="item.detailTitle || ''"
/>
</template>
<template v-else-if="item.componentName == 'media-component'">
<media-component
:views="item.receptionSourceDetailList || []"
:penSwitch="penSwitch"
:show="id == item.id"
:ref="'media' + item.id"
:title="item.detailTitle || ''"
:madiaId="item.id"
:hasCarBrand="item.hasCarBrand"
/>
</template>
</view>
</template>
<template v-if="type != 'preview'">
......@@ -88,7 +111,7 @@
import ToolBox from '@/components/ToolBox.uvue'
import Reception from './components/Reception.uvue'
// import CaseCenter from './components/CaseCenter.vue'
// import MediaComponent from './components/MediaComponent.vue'
import MediaComponent from './components/MediaComponent.uvue'
// import History from './components/History.vue'
// import ThreeGuarantees from './components/ThreeGuarantees.vue'
// import payPop from './components/payPop.vue'
......@@ -99,9 +122,6 @@
import { ref, getCurrentInstance, ComponentPublicInstance } from 'vue'
import { state } from "@/store/index.uts"
// 注册动态组件
defineNativeEmbed('Reception', Reception)
const backZindex = ref<number>(9)
const drawStatus = ref<boolean>(false)
const startX = ref<any>(null)
......@@ -278,22 +298,22 @@
}
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,
if (!e || !e.changedTouches || drawStatus.value || pageToolList.value.length == 0 || e.changedTouches.length === 0) return
let halfScreenWidth = screenWidth.value / 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)
isDistanceSignificant = Math.abs(touch.pageX - startX.value) > screenWidth.value / 6,
index = pageToolList.value.findIndex((item: any) => item.id == id.value)
if (Math.abs(startY.value - touch.pageY) > 150) return
if (!scaleValueObject.value[id.value]) scaleValueObject.value[id.value] = 1
if (isDistanceSignificant && index != -1 && scaleValueObject.value[id.value] == 1 && !productModelStatus.value) {
const { nextId, modeName: modeNameVal, title: titleVal } = getNextId(index, pageToolList.value, startX.value, halfScreenWidth)
modeName.value = modeNameVal
// receptionTrackLeave()
emit('update:id', nextId)
uni.$logger.local.info(`预览${titleVal}`)
id.value = nextId
// uni.$logger.local.info(`预览${titleVal}`)
setTimeout(() => {
modeName.value = ''
}, 500)
......@@ -376,9 +396,20 @@
<style lang="scss">
.detail-box {
position: relative;
width: 100vw;
height: 100vh;
width: 100%;
height: 100%;
margin: 0 auto;
&::after {
content: '';
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-image: url('@/assets/images/common/home-bg-1.webp');
background-size: 100% 100%;
z-index: -1;
}
}
.nav-bar {
position: fixed;
......@@ -389,8 +420,8 @@
z-index: 9;
pointer-events: none;
.back {
width: 96rpx;
height: 100%;
aspect-ratio: 1/1;
display: flex;
align-items: center;
justify-content: center;
......
## 1.9.11(2025-08-20)
- 修复 uni-popup-dialog组件设置 borderRadius 不生效的 Bug
## 1.9.10(2025-07-18)
- 修复 nvue 下弹窗样式错乱的问题 ,更新依赖 uni-transition 组件
- 更新 示例取消 borderRadius 属性 ,如需内容圆角,用户应该直接在内容插槽中实现
## 1.9.9(2025-06-11)
- 修复 uni-popup-dialog 中 setVal 方法报错的问题
- 修复 uni-popup-dialog 数据双向绑定问题。
## 1.9.8(2025-04-16)
- 修复 更新组件示例 ,解决更新数据或保存项目导致弹窗消失的问题
## 1.9.7(2025-04-14)
- 修复 uni-popup-dialog 弹出框在vue3中双向绑定问题
## 1.9.6(2025-01-08)
- 修复 示例中过期图片地址
## 1.9.5(2024-10-15)
- 修复 微信小程序中的getSystemInfo警告
## 1.9.2(2024-09-21)
- 修复 uni-popup在android上的重复点击弹出位置不正确的bug
## 1.9.1(2024-04-02)
- 修复 uni-popup-dialog vue3下使用value无法进行绑定的bug(双向绑定兼容旧写法)
## 1.9.0(2024-03-28)
- 修复 uni-popup-dialog 双向绑定时初始化逻辑修正
## 1.8.9(2024-03-20)
- 修复 uni-popup-dialog 数据输入时修正为双向绑定
## 1.8.8(2024-02-20)
- 修复 uni-popup 在微信小程序下出现文字向上闪动的bug
## 1.8.7(2024-02-02)
- 新增 uni-popup-dialog 新增属性focus:input模式下,是否自动自动聚焦
## 1.8.6(2024-01-30)
- 新增 uni-popup-dialog 新增属性maxLength:限制输入框字数
## 1.8.5(2024-01-26)
- 新增 uni-popup-dialog 新增属性showClose:控制关闭按钮的显示
## 1.8.4(2023-11-15)
- 新增 uni-popup 支持uni-app-x 注意暂时仅支持 `maskClick` `@open` `@close`
## 1.8.3(2023-04-17)
- 修复 uni-popup 重复打开时的 bug
## 1.8.2(2023-02-02)
- uni-popup-dialog 组件新增 inputType 属性
## 1.8.1(2022-12-01)
- 修复 nvue 下 v-show 报错
## 1.8.0(2022-11-29)
- 优化 主题样式
## 1.7.9(2022-04-02)
- 修复 弹出层内部无法滚动的bug
## 1.7.8(2022-03-28)
- 修复 小程序中高度错误的bug
## 1.7.7(2022-03-17)
- 修复 快速调用open出现问题的Bug
## 1.7.6(2022-02-14)
- 修复 safeArea 属性不能设置为false的bug
## 1.7.5(2022-01-19)
- 修复 isMaskClick 失效的bug
## 1.7.4(2022-01-19)
- 新增 cancelText \ confirmText 属性 ,可自定义文本
- 新增 maskBackgroundColor 属性 ,可以修改蒙版颜色
- 优化 maskClick属性 更新为 isMaskClick ,解决微信小程序警告的问题
## 1.7.3(2022-01-13)
- 修复 设置 safeArea 属性不生效的bug
## 1.7.2(2021-11-26)
- 优化 组件示例
## 1.7.1(2021-11-26)
- 修复 vuedoc 文字错误
## 1.7.0(2021-11-19)
- 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-popup](https://uniapp.dcloud.io/component/uniui/uni-popup)
## 1.6.2(2021-08-24)
- 新增 支持国际化
## 1.6.1(2021-07-30)
- 优化 vue3下事件警告的问题
## 1.6.0(2021-07-13)
- 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
## 1.5.0(2021-06-23)
- 新增 mask-click 遮罩层点击事件
## 1.4.5(2021-06-22)
- 修复 nvue 平台中间弹出后,点击内容,再点击遮罩无法关闭的Bug
## 1.4.4(2021-06-18)
- 修复 H5平台中间弹出后,点击内容,再点击遮罩无法关闭的Bug
## 1.4.3(2021-06-08)
- 修复 错误的 watch 字段
- 修复 safeArea 属性不生效的问题
- 修复 点击内容,再点击遮罩无法关闭的Bug
## 1.4.2(2021-05-12)
- 新增 组件示例地址
## 1.4.1(2021-04-29)
- 修复 组件内放置 input 、textarea 组件,无法聚焦的问题
## 1.4.0 (2021-04-29)
- 新增 type 属性的 left\right 值,支持左右弹出
- 新增 open(String:type) 方法参数 ,可以省略 type 属性 ,直接传入类型打开指定弹窗
- 新增 backgroundColor 属性,可定义主窗口背景色,默认不显示背景色
- 新增 safeArea 属性,是否适配底部安全区
- 修复 App\h5\微信小程序底部安全区占位不对的Bug
- 修复 App 端弹出等待的Bug
- 优化 提升低配设备性能,优化动画卡顿问题
- 优化 更简单的组件自定义方式
## 1.2.9(2021-02-05)
- 优化 组件引用关系,通过uni_modules引用组件
## 1.2.8(2021-02-05)
- 调整为uni_modules目录规范
## 1.2.7(2021-02-05)
- 调整为uni_modules目录规范
- 新增 支持 PC 端
- 新增 uni-popup-message 、uni-popup-dialog扩展组件支持 PC 端
// #ifdef H5
export default {
name: 'Keypress',
props: {
disable: {
type: Boolean,
default: false
}
},
mounted () {
const keyNames = {
esc: ['Esc', 'Escape'],
tab: 'Tab',
enter: 'Enter',
space: [' ', 'Spacebar'],
up: ['Up', 'ArrowUp'],
left: ['Left', 'ArrowLeft'],
right: ['Right', 'ArrowRight'],
down: ['Down', 'ArrowDown'],
delete: ['Backspace', 'Delete', 'Del']
}
const listener = ($event) => {
if (this.disable) {
return
}
const keyName = Object.keys(keyNames).find(key => {
const keyName = $event.key
const value = keyNames[key]
return value === keyName || (Array.isArray(value) && value.includes(keyName))
})
if (keyName) {
// 避免和其他按键事件冲突
setTimeout(() => {
this.$emit(keyName, {})
}, 0)
}
}
document.addEventListener('keyup', listener)
this.$once('hook:beforeDestroy', () => {
document.removeEventListener('keyup', listener)
})
},
render: () => {}
}
// #endif
<template>
<view class="uni-popup-dialog" :style="{ borderRadius }">
<view class="uni-dialog-title">
<text class="uni-dialog-title-text" :class="['uni-popup__'+dialogType]">{{titleText}}</text>
</view>
<view v-if="mode === 'base'" class="uni-dialog-content">
<slot>
<text class="uni-dialog-content-text">{{content}}</text>
</slot>
</view>
<view v-else class="uni-dialog-content">
<slot>
<input class="uni-dialog-input" :maxlength="maxlength" v-model="val" :type="inputType"
:placeholder="placeholderText" :focus="focus">
</slot>
</view>
<view class="uni-dialog-button-group">
<view class="uni-dialog-button" v-if="showClose" @click="closeDialog">
<text class="uni-dialog-button-text">{{closeText}}</text>
</view>
<view class="uni-dialog-button" :class="showClose?'uni-border-left':''" @click="onOk">
<text class="uni-dialog-button-text uni-button-color">{{okText}}</text>
</view>
</view>
</view>
</template>
<script>
import popup from '../uni-popup/popup.js'
import {
initVueI18n
} from '@dcloudio/uni-i18n'
import messages from '../uni-popup/i18n/index.js'
const {
t
} = initVueI18n(messages)
/**
* PopUp 弹出层-对话框样式
* @description 弹出层-对话框样式
* @tutorial https://ext.dcloud.net.cn/plugin?id=329
* @property {String} value input 模式下的默认值
* @property {String} placeholder input 模式下输入提示
* @property {Boolean} focus input模式下是否自动聚焦,默认为true
* @property {String} type = [success|warning|info|error] 主题样式
* @value success 成功
* @value warning 提示
* @value info 消息
* @value error 错误
* @property {String} mode = [base|input] 模式、
* @value base 基础对话框
* @value input 可输入对话框
* @showClose {Boolean} 是否显示关闭按钮
* @property {String} content 对话框内容
* @property {Boolean} beforeClose 是否拦截取消事件
* @property {Number} maxlength 输入
* @event {Function} confirm 点击确认按钮触发
* @event {Function} close 点击取消按钮触发
*/
export default {
name: "uniPopupDialog",
mixins: [popup],
emits: ['confirm', 'close', 'update:modelValue', 'input'],
props: {
inputType: {
type: String,
default: 'text'
},
showClose: {
type: Boolean,
default: true
},
// #ifdef VUE2
value: {
type: [String, Number],
default: ''
},
// #endif
// #ifdef VUE3
modelValue: {
type: [Number, String],
default: ''
},
// #endif
placeholder: {
type: [String, Number],
default: ''
},
type: {
type: String,
default: 'error'
},
mode: {
type: String,
default: 'base'
},
title: {
type: String,
default: ''
},
content: {
type: String,
default: ''
},
beforeClose: {
type: Boolean,
default: false
},
cancelText: {
type: String,
default: ''
},
confirmText: {
type: String,
default: ''
},
maxlength: {
type: Number,
default: -1,
},
focus: {
type: Boolean,
default: true,
},
borderRadius: {
type: String,
default: '11px',
}
},
data() {
return {
dialogType: 'error',
val: ""
}
},
computed: {
okText() {
return this.confirmText || t("uni-popup.ok")
},
closeText() {
return this.cancelText || t("uni-popup.cancel")
},
placeholderText() {
return this.placeholder || t("uni-popup.placeholder")
},
titleText() {
return this.title || t("uni-popup.title")
}
},
watch: {
type(val) {
this.dialogType = val
},
mode(val) {
if (val === 'input') {
this.dialogType = 'info'
}
},
value(val) {
this.setVal(val)
},
// #ifdef VUE3
modelValue(val) {
this.setVal(val)
},
// #endif
val(val) {
// #ifdef VUE2
// TODO 兼容 vue2
this.$emit('input', val);
// #endif
// #ifdef VUE3
// TODO 兼容 vue3
this.$emit('update:modelValue', val);
// #endif
}
},
created() {
// 对话框遮罩不可点击
this.popup.disableMask()
// this.popup.closeMask()
if (this.mode === 'input') {
this.dialogType = 'info'
this.val = this.value;
// #ifdef VUE3
this.val = this.modelValue;
// #endif
} else {
this.dialogType = this.type
}
},
methods: {
/**
* 给val属性赋值
*/
setVal(val) {
if (this.maxlength != -1 && this.mode === 'input') {
this.val = val.slice(0, this.maxlength);
} else {
this.val = val
}
},
/**
* 点击确认按钮
*/
onOk() {
if (this.mode === 'input') {
this.$emit('confirm', this.val)
} else {
this.$emit('confirm')
}
if (this.beforeClose) return
this.popup.close()
},
/**
* 点击取消按钮
*/
closeDialog() {
this.$emit('close')
if (this.beforeClose) return
this.popup.close()
},
close() {
this.popup.close()
}
}
}
</script>
<style lang="scss">
.uni-popup-dialog {
width: 300px;
background-color: #fff;
}
.uni-dialog-title {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
justify-content: center;
padding-top: 25px;
}
.uni-dialog-title-text {
font-size: 16px;
font-weight: 500;
}
.uni-dialog-content {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
justify-content: center;
align-items: center;
padding: 20px;
}
.uni-dialog-content-text {
font-size: 14px;
color: #6C6C6C;
}
.uni-dialog-button-group {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
border-top-color: #f5f5f5;
border-top-style: solid;
border-top-width: 1px;
}
.uni-dialog-button {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex: 1;
flex-direction: row;
justify-content: center;
align-items: center;
height: 45px;
}
.uni-border-left {
border-left-color: #f0f0f0;
border-left-style: solid;
border-left-width: 1px;
}
.uni-dialog-button-text {
font-size: 16px;
color: #333;
}
.uni-button-color {
color: #007aff;
}
.uni-dialog-input {
flex: 1;
font-size: 14px;
border: 1px #eee solid;
height: 40px;
padding: 0 10px;
border-radius: 5px;
color: #555;
}
.uni-popup__success {
color: #4cd964;
}
.uni-popup__warn {
color: #f0ad4e;
}
.uni-popup__error {
color: #dd524d;
}
.uni-popup__info {
color: #909399;
}
</style>
<template>
<view class="uni-popup-message">
<view class="uni-popup-message__box fixforpc-width" :class="'uni-popup__'+type">
<slot>
<text class="uni-popup-message-text" :class="'uni-popup__'+type+'-text'">{{message}}</text>
</slot>
</view>
</view>
</template>
<script>
import popup from '../uni-popup/popup.js'
/**
* PopUp 弹出层-消息提示
* @description 弹出层-消息提示
* @tutorial https://ext.dcloud.net.cn/plugin?id=329
* @property {String} type = [success|warning|info|error] 主题样式
* @value success 成功
* @value warning 提示
* @value info 消息
* @value error 错误
* @property {String} message 消息提示文字
* @property {String} duration 显示时间,设置为 0 则不会自动关闭
*/
export default {
name: 'uniPopupMessage',
mixins:[popup],
props: {
/**
* 主题 success/warning/info/error 默认 success
*/
type: {
type: String,
default: 'success'
},
/**
* 消息文字
*/
message: {
type: String,
default: ''
},
/**
* 显示时间,设置为 0 则不会自动关闭
*/
duration: {
type: Number,
default: 3000
},
maskShow:{
type:Boolean,
default:false
}
},
data() {
return {}
},
created() {
this.popup.maskShow = this.maskShow
this.popup.messageChild = this
},
methods: {
timerClose(){
if(this.duration === 0) return
clearTimeout(this.timer)
this.timer = setTimeout(()=>{
this.popup.close()
},this.duration)
}
}
}
</script>
<style lang="scss" >
.uni-popup-message {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
justify-content: center;
}
.uni-popup-message__box {
background-color: #e1f3d8;
padding: 10px 15px;
border-color: #eee;
border-style: solid;
border-width: 1px;
flex: 1;
}
@media screen and (min-width: 500px) {
.fixforpc-width {
margin-top: 20px;
border-radius: 4px;
flex: none;
min-width: 380px;
/* #ifndef APP-NVUE */
max-width: 50%;
/* #endif */
/* #ifdef APP-NVUE */
max-width: 500px;
/* #endif */
}
}
.uni-popup-message-text {
font-size: 14px;
padding: 0;
}
.uni-popup__success {
background-color: #e1f3d8;
}
.uni-popup__success-text {
color: #67C23A;
}
.uni-popup__warn {
background-color: #faecd8;
}
.uni-popup__warn-text {
color: #E6A23C;
}
.uni-popup__error {
background-color: #fde2e2;
}
.uni-popup__error-text {
color: #F56C6C;
}
.uni-popup__info {
background-color: #F2F6FC;
}
.uni-popup__info-text {
color: #909399;
}
</style>
<template>
<view class="uni-popup-share">
<view class="uni-share-title"><text class="uni-share-title-text">{{shareTitleText}}</text></view>
<view class="uni-share-content">
<view class="uni-share-content-box">
<view class="uni-share-content-item" v-for="(item,index) in bottomData" :key="index" @click.stop="select(item,index)">
<image class="uni-share-image" :src="item.icon" mode="aspectFill"></image>
<text class="uni-share-text">{{item.text}}</text>
</view>
</view>
</view>
<view class="uni-share-button-box">
<button class="uni-share-button" @click="close">{{cancelText}}</button>
</view>
</view>
</template>
<script>
import popup from '../uni-popup/popup.js'
import {
initVueI18n
} from '@dcloudio/uni-i18n'
import messages from '../uni-popup/i18n/index.js'
const { t } = initVueI18n(messages)
export default {
name: 'UniPopupShare',
mixins:[popup],
emits:['select'],
props: {
title: {
type: String,
default: ''
},
beforeClose: {
type: Boolean,
default: false
}
},
data() {
return {
// TODO 替换为自己的图标
bottomData: [{
text: '微信',
icon: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png',
name: 'wx'
},
{
text: '支付宝',
icon: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png',
name: 'ali'
},
{
text: 'QQ',
icon: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png',
name: 'qq'
},
{
text: '新浪',
icon: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png',
name: 'sina'
},
// {
// text: '百度',
// icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/1ec6e920-50bf-11eb-8a36-ebb87efcf8c0.png',
// name: 'copy'
// },
// {
// text: '其他',
// icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/2e0fdfe0-50bf-11eb-b997-9918a5dda011.png',
// name: 'more'
// }
]
}
},
created() {},
computed: {
cancelText() {
return t("uni-popup.cancel")
},
shareTitleText() {
return this.title || t("uni-popup.shareTitle")
}
},
methods: {
/**
* 选择内容
*/
select(item, index) {
this.$emit('select', {
item,
index
})
this.close()
},
/**
* 关闭窗口
*/
close() {
if(this.beforeClose) return
this.popup.close()
}
}
}
</script>
<style lang="scss" >
.uni-popup-share {
background-color: #fff;
border-top-left-radius: 11px;
border-top-right-radius: 11px;
}
.uni-share-title {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
align-items: center;
justify-content: center;
height: 40px;
}
.uni-share-title-text {
font-size: 14px;
color: #666;
}
.uni-share-content {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
justify-content: center;
padding-top: 10px;
}
.uni-share-content-box {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
flex-wrap: wrap;
width: 360px;
}
.uni-share-content-item {
width: 90px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
justify-content: center;
padding: 10px 0;
align-items: center;
}
.uni-share-content-item:active {
background-color: #f5f5f5;
}
.uni-share-image {
width: 30px;
height: 30px;
}
.uni-share-text {
margin-top: 10px;
font-size: 14px;
color: #3B4144;
}
.uni-share-button-box {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
padding: 10px 15px;
}
.uni-share-button {
flex: 1;
border-radius: 50px;
color: #666;
font-size: 16px;
}
.uni-share-button::after {
border-radius: 50px;
}
</style>
{
"uni-popup.cancel": "cancel",
"uni-popup.ok": "ok",
"uni-popup.placeholder": "pleace enter",
"uni-popup.title": "Hint",
"uni-popup.shareTitle": "Share to"
}
import en from './en.json'
import zhHans from './zh-Hans.json'
import zhHant from './zh-Hant.json'
export default {
en,
'zh-Hans': zhHans,
'zh-Hant': zhHant
}
{
"uni-popup.cancel": "取消",
"uni-popup.ok": "确定",
"uni-popup.placeholder": "请输入",
"uni-popup.title": "提示",
"uni-popup.shareTitle": "分享到"
}
{
"uni-popup.cancel": "取消",
"uni-popup.ok": "確定",
"uni-popup.placeholder": "請輸入",
"uni-popup.title": "提示",
"uni-popup.shareTitle": "分享到"
}
// #ifdef H5
export default {
name: 'Keypress',
props: {
disable: {
type: Boolean,
default: false
}
},
mounted () {
const keyNames = {
esc: ['Esc', 'Escape'],
tab: 'Tab',
enter: 'Enter',
space: [' ', 'Spacebar'],
up: ['Up', 'ArrowUp'],
left: ['Left', 'ArrowLeft'],
right: ['Right', 'ArrowRight'],
down: ['Down', 'ArrowDown'],
delete: ['Backspace', 'Delete', 'Del']
}
const listener = ($event) => {
if (this.disable) {
return
}
const keyName = Object.keys(keyNames).find(key => {
const keyName = $event.key
const value = keyNames[key]
return value === keyName || (Array.isArray(value) && value.includes(keyName))
})
if (keyName) {
// 避免和其他按键事件冲突
setTimeout(() => {
this.$emit(keyName, {})
}, 0)
}
}
document.addEventListener('keyup', listener)
// this.$once('hook:beforeDestroy', () => {
// document.removeEventListener('keyup', listener)
// })
},
render: () => {}
}
// #endif
export default {
data() {
return {
}
},
created(){
this.popup = this.getParent()
},
methods:{
/**
* 获取父元素实例
*/
getParent(name = 'uniPopup') {
let parent = this.$parent;
let parentName = parent.$options.name;
while (parentName !== name) {
parent = parent.$parent;
if (!parent) return false
parentName = parent.$options.name;
}
return parent;
},
}
}
<template>
<view class="popup-root" v-if="isOpen" v-show="isShow" @click="clickMask">
<view @click.stop>
<slot></slot>
</view>
</view>
</template>
<script>
type CloseCallBack = ()=> void;
let closeCallBack:CloseCallBack = () :void => {};
export default {
emits:["close","clickMask"],
data() {
return {
isShow:false,
isOpen:false
}
},
props: {
maskClick: {
type: Boolean,
default: true
},
},
watch: {
// 设置show = true 时,如果没有 open 需要设置为 open
isShow:{
handler(isShow) {
// console.log("isShow",isShow)
if(isShow && this.isOpen == false){
this.isOpen = true
}
},
immediate:true
},
// 设置isOpen = true 时,如果没有 isShow 需要设置为 isShow
isOpen:{
handler(isOpen) {
// console.log("isOpen",isOpen)
if(isOpen && this.isShow == false){
this.isShow = true
}
},
immediate:true
}
},
methods:{
open(){
// ...funs : CloseCallBack[]
// if(funs.length > 0){
// closeCallBack = funs[0]
// }
this.isOpen = true;
},
clickMask(){
if(this.maskClick == true){
this.$emit('clickMask')
this.close()
}
},
close(): void{
this.isOpen = false;
this.$emit('close')
closeCallBack()
},
hiden(){
this.isShow = false
},
show(){
this.isShow = true
}
}
}
</script>
<style>
.popup-root {
position: fixed;
top: 0;
left: 0;
width: 750rpx;
height: 100%;
flex: 1;
background-color: rgba(0, 0, 0, 0.3);
justify-content: center;
align-items: center;
z-index: 99;
}
</style>
\ No newline at end of file
{
"id": "uni-popup",
"displayName": "uni-popup 弹出层",
"version": "1.9.11",
"description": " Popup 组件,提供常用的弹层",
"keywords": [
"uni-ui",
"弹出层",
"弹窗",
"popup",
"弹框"
],
"repository": "https://github.com/dcloudio/uni-ui",
"engines": {
"HBuilderX": "",
"uni-app": "^4.07",
"uni-app-x": ""
},
"directories": {
"example": "../../temps/example_temps"
},
"dcloudext": {
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue",
"darkmode": "x",
"i18n": "x",
"widescreen": "x"
},
"uni_modules": {
"dependencies": [
"uni-scss",
"uni-transition"
],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "x",
"aliyun": "x",
"alipay": "x"
},
"client": {
"uni-app": {
"vue": {
"vue2": "√",
"vue3": "√"
},
"web": {
"safari": "√",
"chrome": "√"
},
"app": {
"vue": "√",
"nvue": "√",
"android": "√",
"ios": "√",
"harmony": "√"
},
"mp": {
"weixin": "√",
"alipay": "√",
"toutiao": "√",
"baidu": "√",
"kuaishou": "-",
"jd": "-",
"harmony": "-",
"qq": "√",
"lark": "-"
},
"quickapp": {
"huawei": "-",
"union": "-"
}
},
"uni-app-x": {
"web": {
"safari": "√",
"chrome": "√"
},
"app": {
"android": "√",
"ios": "√",
"harmony": "√"
},
"mp": {
"weixin": "√"
}
}
}
}
}
}
\ No newline at end of file
## Popup 弹出层
> **组件名:uni-popup**
> 代码块: `uPopup`
> 关联组件:`uni-transition`
弹出层组件,在应用中弹出一个消息提示窗口、提示框等
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-popup)
#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!