update:本地测试成功网页跳转短信

This commit is contained in:
lihaoyuan 2025-07-18 11:52:38 +08:00
parent 97f779b5f4
commit 744579a692
3 changed files with 62 additions and 8 deletions

View File

@ -56,7 +56,7 @@ const routes=[
{
path:'/m',
name:'m',
component:()=>import('@/views/m/m.vue'),
component:()=>import('@/views/wxJump/WxJump.vue'),
meta:{
isFullpage: true
}

View File

@ -1,7 +0,0 @@
<template>
</template>
<script setup>
location.href='weixin://dl/business/?t=9FVo0FY1jLk'
</script>

View File

@ -0,0 +1,61 @@
<template>
<div class="wrapper">
<p>正在打开小程序请稍候</p>
<button id="openBtn" class="btn" @click="forceOpen">
立即打开
</button>
</div>
</template>
<script setup>
import { onMounted } from 'vue'
// 1. URL Scheme
const scheme = 'weixin://dl/business/?t=9FVo0FY1jLk'
// 2.
const isWechat = /MicroMessenger/i.test(navigator.userAgent)
// 3. JSSDK
function wxJump() {
if (!isWechat) return false
if (!window.wx) return false
wx.miniProgram.navigateTo({ url: 'pages/index/index' })
return true
}
// 4. URL Scheme
function schemeJump() {
location.href = scheme
}
// 5.
function go() {
if (!wxJump()) schemeJump()
}
// 6.
onMounted(() => {
go()
})
</script>
<style scoped>
.wrapper {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
font-size: 16px;
}
.btn {
margin-top: 30px;
padding: 12px 28px;
background: #07c160;
color: #fff;
border: none;
border-radius: 4px;
font-size: 16px;
}
</style>