refactor: 修改确认框
This commit is contained in:
parent
c7495ae42c
commit
b25046f051
@ -157,11 +157,24 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 通用确认弹窗 -->
|
||||||
|
<ConfirmModal
|
||||||
|
:visible="confirmModal.visible"
|
||||||
|
:title="confirmModal.title"
|
||||||
|
:content="confirmModal.content"
|
||||||
|
:confirmText="confirmModal.confirmText"
|
||||||
|
:cancelText="confirmModal.cancelText"
|
||||||
|
:showCancel="confirmModal.showCancel"
|
||||||
|
@confirm="onConfirmModal"
|
||||||
|
@cancel="onCancelModal"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
import { GRID_CONFIG, generateGridCoordinates, IMAGE_W, IMAGE_H } from './config/cabin.js'
|
import { GRID_CONFIG, generateGridCoordinates, IMAGE_W, IMAGE_H } from './config/cabin.js'
|
||||||
|
import ConfirmModal from '@/components/ConfirmModal.vue'
|
||||||
|
|
||||||
const config = ref(JSON.parse(JSON.stringify(GRID_CONFIG)))
|
const config = ref(JSON.parse(JSON.stringify(GRID_CONFIG)))
|
||||||
const selectedIndex = ref(null)
|
const selectedIndex = ref(null)
|
||||||
@ -175,7 +188,46 @@ const scale = ref(1)
|
|||||||
// 滑动相关
|
// 滑动相关
|
||||||
const bgOffsetX = ref(0)
|
const bgOffsetX = ref(0)
|
||||||
let touchStartX = 0
|
let touchStartX = 0
|
||||||
let lastMoveX = 0
|
|
||||||
|
// 通用确认弹窗状态
|
||||||
|
const confirmModal = ref({
|
||||||
|
visible: false,
|
||||||
|
title: '',
|
||||||
|
content: '',
|
||||||
|
confirmText: '确认',
|
||||||
|
cancelText: '取消',
|
||||||
|
showCancel: true,
|
||||||
|
confirmCallback: null
|
||||||
|
})
|
||||||
|
|
||||||
|
// 弹窗确认回调
|
||||||
|
const onConfirmModal = () => {
|
||||||
|
if (confirmModal.value.confirmCallback) {
|
||||||
|
confirmModal.value.confirmCallback({ confirm: true })
|
||||||
|
}
|
||||||
|
confirmModal.value.visible = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// 弹窗取消回调
|
||||||
|
const onCancelModal = () => {
|
||||||
|
if (confirmModal.value.confirmCallback) {
|
||||||
|
confirmModal.value.confirmCallback({ confirm: false })
|
||||||
|
}
|
||||||
|
confirmModal.value.visible = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// 显示通用确认弹窗
|
||||||
|
const showConfirmModal = (options) => {
|
||||||
|
confirmModal.value = {
|
||||||
|
visible: true,
|
||||||
|
title: options.title || '',
|
||||||
|
content: options.content || '',
|
||||||
|
confirmText: options.confirmText || '确认',
|
||||||
|
cancelText: options.cancelText || '取消',
|
||||||
|
showCancel: options.showCancel !== false,
|
||||||
|
confirmCallback: options.success || null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 原始坐标(未缩放)
|
// 原始坐标(未缩放)
|
||||||
const originalCoords = computed(() => {
|
const originalCoords = computed(() => {
|
||||||
@ -354,7 +406,7 @@ const exportConfig = () => {
|
|||||||
console.log('}')
|
console.log('}')
|
||||||
}
|
}
|
||||||
|
|
||||||
uni.showModal({
|
showConfirmModal({
|
||||||
title: '配置已导出',
|
title: '配置已导出',
|
||||||
content: '请查看控制台输出,复制到 config/cabin.js',
|
content: '请查看控制台输出,复制到 config/cabin.js',
|
||||||
showCancel: false
|
showCancel: false
|
||||||
@ -362,7 +414,7 @@ const exportConfig = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const resetConfig = () => {
|
const resetConfig = () => {
|
||||||
uni.showModal({
|
showConfirmModal({
|
||||||
title: '确认重置',
|
title: '确认重置',
|
||||||
content: '将重置所有参数和调整,是否继续?',
|
content: '将重置所有参数和调整,是否继续?',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user