mirror of
https://gitee.com/bootx/dax-pay-h5
synced 2026-08-10 14:56:07 +08:00
feat 优化码牌支持固定金额
This commit is contained in:
@@ -99,7 +99,7 @@ export const DaxPayH5Route: RouteRecordRaw = {
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/onboarded/leshua',
|
||||
path: '/onboarded/leshua_pay',
|
||||
name: 'leshua',
|
||||
component: () => import('@/views/daxpay/h5/onboarded/leshua/index.vue'),
|
||||
meta: {
|
||||
|
||||
@@ -87,25 +87,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 关闭页面 -->
|
||||
<div v-if="closeObj.showCloseMask" id="cancelPay" class="cancelMask">
|
||||
<div class="confirmDialog">
|
||||
<div class="confirmHeader">
|
||||
确定关闭该页面?
|
||||
</div>
|
||||
<div class="confimContent">
|
||||
<p class="contentTxt" />
|
||||
</div>
|
||||
<div class="confimFooter">
|
||||
<div id="confirmLeaveBtn" class="confimBtn" @click="closeObj.handleConfirmClose">
|
||||
确认关闭
|
||||
</div>
|
||||
<div id="continuePay" class="confimBtn payBtn" style="color: #E41937" @click="closeObj.handleContinueClose">
|
||||
继续支付
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -227,48 +208,13 @@ const cancelObj = reactive({
|
||||
},
|
||||
})
|
||||
|
||||
// 关闭弹窗对象
|
||||
const closeObj = reactive({
|
||||
// 控制弹窗
|
||||
showCloseMask: false,
|
||||
// 处理确认关闭
|
||||
handleConfirmClose: () => {
|
||||
closeObj.showCloseMask = false // 隐藏弹窗
|
||||
// 尝试关闭页面
|
||||
try {
|
||||
window.close() // 尝试关闭当前页面
|
||||
}
|
||||
catch {
|
||||
// eslint-disable-next-line no-alert
|
||||
alert('无法关闭页面,请手动关闭。')
|
||||
router.replace('/')
|
||||
}
|
||||
},
|
||||
// 处理继续支付
|
||||
handleContinueClose: () => {
|
||||
closeObj.showCloseMask = false // 隐藏弹窗
|
||||
history.pushState(null, '', location.href) // 阻止返回行为
|
||||
},
|
||||
// 监听关闭事件处理
|
||||
handleBeforeUnload: (event: BeforeUnloadEvent) => {
|
||||
event.preventDefault()
|
||||
closeObj.showCloseMask = true
|
||||
},
|
||||
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
init()
|
||||
// 初始化历史记录栈
|
||||
history.pushState({ page: 'cashier' }, '', location.href)
|
||||
// 监听点击浏览器返回
|
||||
window.addEventListener('popstate', cancelObj.handlePopstate)
|
||||
window.addEventListener('beforeunload', closeObj.handleBeforeUnload)
|
||||
})
|
||||
onUnmounted(() => {
|
||||
pause()
|
||||
window.removeEventListener('popstate', cancelObj.handlePopstate)
|
||||
window.removeEventListener('beforeunload', closeObj.handleBeforeUnload)
|
||||
})
|
||||
|
||||
/**
|
||||
@@ -500,90 +446,5 @@ function init() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 取消支付 */
|
||||
.cancelMask {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
z-index: 9999;
|
||||
|
||||
.confirmDialog {
|
||||
width: 15rem;
|
||||
background: #ffffff;
|
||||
border-radius: 0.2rem;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.confirmHeader {
|
||||
font-size: 0.9rem;
|
||||
line-height: 1.2rem;
|
||||
color: #22242e;
|
||||
padding: 1.55rem 0.6rem 0;
|
||||
}
|
||||
|
||||
.confimContent {
|
||||
width: 100%;
|
||||
font-size: 0.7rem;
|
||||
font-weight: 400;
|
||||
color: #6c6e75;
|
||||
padding: 0.55rem 1rem 1.55rem;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
.contentTxt {
|
||||
line-height: 1.05rem;
|
||||
}
|
||||
|
||||
.confimFooter {
|
||||
width: 100%;
|
||||
height: 2.5rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-top: 1px solid #eeeeee;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.confimFooter::after {
|
||||
position: absolute;
|
||||
content: '';
|
||||
height: 100%;
|
||||
width: 1px;
|
||||
background: #eeeeee;
|
||||
left: 50%;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.confimBtn {
|
||||
height: 100%;
|
||||
flex: 1;
|
||||
color: #22242e;
|
||||
text-align: center;
|
||||
font-size: 0.7rem;
|
||||
line-height: 0.95rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.payBtn {
|
||||
color: #5568d5;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -100,6 +100,8 @@ export interface WxJsapiSignResult {
|
||||
export interface GatewayCashierCodeConfig {
|
||||
// 码牌名称
|
||||
name?: string
|
||||
// 是否启用
|
||||
enable?: boolean
|
||||
// 金额类型
|
||||
amountType?: string
|
||||
// 金额
|
||||
@@ -108,7 +110,7 @@ export interface GatewayCashierCodeConfig {
|
||||
channel?: string
|
||||
// 支付调起方式
|
||||
callType?: string
|
||||
// 判断是否需要
|
||||
// 判断是否需要获取openId
|
||||
needOpenId?: boolean
|
||||
// 备注
|
||||
remark?: string
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
/>
|
||||
</van-dialog>
|
||||
<van-number-keyboard
|
||||
v-if="cashierInfo.amountType === 'random'"
|
||||
:show="!loading"
|
||||
theme="custom"
|
||||
extra-key="."
|
||||
@@ -82,7 +83,7 @@ const { code } = route.params
|
||||
|
||||
const showRemark = ref<boolean>(false) // 是否展示备注
|
||||
const loading = ref<boolean>(false) // 加载状态
|
||||
const cashierInfo = ref<GatewayCashierCodeConfig>()
|
||||
const cashierInfo = ref<GatewayCashierCodeConfig>({})
|
||||
const amount = ref<string>('0') // 金额
|
||||
const description = ref<string>()
|
||||
|
||||
@@ -104,8 +105,19 @@ function initData() {
|
||||
router.replace({ name: 'payFail', query: { msg: res.msg } })
|
||||
return
|
||||
}
|
||||
loading.value = false
|
||||
cashierInfo.value = res.data as any
|
||||
// 是否启用
|
||||
if (!cashierInfo.value?.enable) {
|
||||
router.replace({ name: 'payFail', query: { msg: '收银码牌未启用' } })
|
||||
}
|
||||
// 判断类型
|
||||
if (cashierInfo.value?.amountType === 'fixed') {
|
||||
amount.value = res.data.amount as string
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
loading.value = false
|
||||
})
|
||||
.catch((res) => {
|
||||
router.replace({ name: 'payFail', query: { msg: res.message } })
|
||||
|
||||
Reference in New Issue
Block a user