-
@@ -770,10 +848,35 @@ layout("/layouts/platform_h5.html"){
+ :close-on-click-overlay="false"
+ @click-close-icon="closeOptionDetail"
+ @closed="resetDetailZoom"
+ :style="{ height: '82vh' }">
@@ -830,6 +933,14 @@ layout("/layouts/platform_h5.html"){
hasSubmittedBefore: false, // 是否之前提交过
showOptionDetailDialog: false, // 选项详情弹窗
selectedOption: null, // 当前选中的选项
+ popupHistoryOwner: "welfare-select-" + Date.now(),
+ detailScale: 1,
+ detailMinScale: 0.5,
+ detailMaxScale: 3,
+ detailContentWidth: 0,
+ detailContentHeight: 0,
+ detailPinchStartDistance: 0,
+ detailPinchStartScale: 1,
mobileError: false, // 手机号错误标记
userNameError: false, // 收货人错误标记
formData: {
@@ -890,6 +1001,20 @@ layout("/layouts/platform_h5.html"){
const diffHours = (endTime - now) / (1000 * 60 * 60)
return diffHours > 0 && diffHours < 24
+ },
+
+ detailStageStyle() {
+ return {
+ width: Math.ceil(this.detailContentWidth * this.detailScale) + "px",
+ height: Math.ceil(this.detailContentHeight * this.detailScale) + "px"
+ }
+ },
+
+ detailContentStyle() {
+ return {
+ width: this.detailContentWidth > 0 ? this.detailContentWidth + "px" : "100%",
+ transform: "scale(" + this.detailScale + ")"
+ }
}
},
@@ -1100,6 +1225,7 @@ layout("/layouts/platform_h5.html"){
if (res.code === 0) {
this.$toast.success("选择成功")
setTimeout(() => {
+ this.clearPopupHistory()
this.$pjaxReplace("/platform/h5/welfare/userSelect/success")
}, 1500)
} else {
@@ -1195,7 +1321,8 @@ layout("/layouts/platform_h5.html"){
this.showConfirmDialog = true
},
- async openChoose(row) {
+ openChoose(row) {
+ this.clearPopupHistory()
this.$pjaxReplace("/platform/h5/welfare/userChoose/index?id=" + row.id)
},
@@ -1221,10 +1348,127 @@ layout("/layouts/platform_h5.html"){
// 显示选项详情
showOptionDetail(option) {
- // 阻止事件冒泡,避免触发父元素的点击事件
- event.stopPropagation()
this.selectedOption = option
this.showOptionDetailDialog = true
+ this.detailScale = 1
+ this.detailContentWidth = 0
+ this.detailContentHeight = 0
+ this.$nextTick(() => {
+ this.measureDetailContent()
+ })
+ if (window.mobilePopupHistory) {
+ window.mobilePopupHistory.open(this.popupHistoryOwner, "optionDetail")
+ }
+ },
+
+ closeOptionDetail() {
+ if (window.mobilePopupHistory) {
+ window.mobilePopupHistory.close(this.popupHistoryOwner, "optionDetail")
+ } else {
+ this.showOptionDetailDialog = false
+ }
+ },
+
+ closePopupFromHistory(popupId) {
+ if (popupId === "optionDetail") {
+ this.showOptionDetailDialog = false
+ }
+ },
+
+ handlePageBack() {
+ if (window.mobilePopupHistory && window.mobilePopupHistory.hasOpen(this.popupHistoryOwner)) {
+ window.history.back()
+ return
+ }
+ this.historyBack()
+ },
+
+ clearPopupHistory() {
+ if (window.mobilePopupHistory) {
+ window.mobilePopupHistory.clear(this.popupHistoryOwner)
+ }
+ },
+
+ measureDetailContent() {
+ this.$nextTick(() => {
+ const viewport = this.$refs.detailViewport
+ const content = this.$refs.detailContent
+ if (!viewport || !content) return
+ this.detailContentWidth = Math.max(viewport.clientWidth, content.scrollWidth)
+ this.detailContentHeight = Math.max(viewport.clientHeight, content.scrollHeight)
+ Array.from(content.querySelectorAll("img")).forEach((image) => {
+ if (!image.complete) {
+ image.addEventListener("load", () => {
+ this.measureDetailContent()
+ }, {once: true})
+ }
+ })
+ })
+ },
+
+ resetDetailZoom() {
+ this.detailScale = 1
+ this.detailPinchStartDistance = 0
+ this.$nextTick(() => {
+ this.measureDetailContent()
+ const viewport = this.$refs.detailViewport
+ if (viewport) {
+ viewport.scrollLeft = 0
+ viewport.scrollTop = 0
+ }
+ })
+ },
+
+ changeDetailScale(delta) {
+ const viewport = this.$refs.detailViewport
+ if (!viewport) return
+ this.setDetailScale(this.detailScale + delta, viewport.clientWidth / 2, viewport.clientHeight / 2)
+ },
+
+ setDetailScale(scale, centerX, centerY) {
+ const viewport = this.$refs.detailViewport
+ if (!viewport) return
+ const oldScale = this.detailScale
+ const newScale = Math.min(this.detailMaxScale, Math.max(this.detailMinScale, scale))
+ if (Math.abs(newScale - oldScale) < 0.001) return
+ const contentX = (viewport.scrollLeft + centerX) / oldScale
+ const contentY = (viewport.scrollTop + centerY) / oldScale
+ this.detailScale = newScale
+ this.$nextTick(() => {
+ viewport.scrollLeft = Math.max(0, contentX * newScale - centerX)
+ viewport.scrollTop = Math.max(0, contentY * newScale - centerY)
+ })
+ },
+
+ getTouchDistance(touches) {
+ const deltaX = touches[0].clientX - touches[1].clientX
+ const deltaY = touches[0].clientY - touches[1].clientY
+ return Math.sqrt(deltaX * deltaX + deltaY * deltaY)
+ },
+
+ onDetailTouchStart(event) {
+ if (event.touches.length !== 2) return
+ this.detailPinchStartDistance = this.getTouchDistance(event.touches)
+ this.detailPinchStartScale = this.detailScale
+ },
+
+ onDetailTouchMove(event) {
+ if (event.touches.length !== 2 || this.detailPinchStartDistance <= 0) return
+ event.preventDefault()
+ const viewport = this.$refs.detailViewport
+ const rect = viewport.getBoundingClientRect()
+ const centerX = (event.touches[0].clientX + event.touches[1].clientX) / 2 - rect.left
+ const centerY = (event.touches[0].clientY + event.touches[1].clientY) / 2 - rect.top
+ const distance = this.getTouchDistance(event.touches)
+ this.setDetailScale(this.detailPinchStartScale * distance / this.detailPinchStartDistance,
+ centerX, centerY)
+ },
+
+ onDetailTouchEnd(event) {
+ if (event.touches.length < 2) {
+ this.detailPinchStartDistance = 0
+ this.detailPinchStartScale = this.detailScale
+ }
},
// 重置签名
@@ -1247,6 +1491,7 @@ layout("/layouts/platform_h5.html"){
// 跳转到地址管理页面
goToAddressManage() {
+ this.clearPopupHistory()
this.$pjaxReplace("/platform/h5/welfare/address/list")
},
@@ -1291,11 +1536,12 @@ layout("/layouts/platform_h5.html"){
},
// 获取收货地址
- async getAddress() {
- const resp = await this.$axios.post("/platform/welfare/addressManage/selectUserAddress")
- if (resp.code === 0) {
- this.addressOptions = resp.data
- }
+ getAddress() {
+ this.$axios.post("/platform/welfare/addressManage/selectUserAddress").then((resp) => {
+ if (resp.code === 0) {
+ this.addressOptions = resp.data
+ }
+ })
}
},
@@ -1337,21 +1583,34 @@ layout("/layouts/platform_h5.html"){
}
},
- async created() {
+ created() {
+ if (window.mobilePopupHistory) {
+ window.mobilePopupHistory.register(this.popupHistoryOwner, (popupId) => {
+ this.closePopupFromHistory(popupId)
+ })
+ }
this.projectId = GetQueryString("id")
if (this.projectId) {
- // 先获取字典数据
- this.welfareProvideMode = await this.$businessTool.getDictOptions("welfareProvideMode")
- this.welfareSignMode = await this.$businessTool.getDictOptions("welfareSignMode")
-
- // 然后获取项目信息和用户选择
- this.getProjectInfo()
+ Promise.all([
+ this.$businessTool.getDictOptions("welfareProvideMode"),
+ this.$businessTool.getDictOptions("welfareSignMode")
+ ]).then((results) => {
+ this.welfareProvideMode = results[0]
+ this.welfareSignMode = results[1]
+ this.getProjectInfo()
+ })
} else {
this.$toast.fail("参数错误")
setTimeout(() => {
this.historyBack()
}, 1500)
}
+ },
+
+ beforeDestroy() {
+ if (window.mobilePopupHistory) {
+ window.mobilePopupHistory.unregister(this.popupHistoryOwner)
+ }
}
})