update:本地测试成功网页跳转短信
This commit is contained in:
parent
97f779b5f4
commit
744579a692
@ -56,7 +56,7 @@ const routes=[
|
|||||||
{
|
{
|
||||||
path:'/m',
|
path:'/m',
|
||||||
name:'m',
|
name:'m',
|
||||||
component:()=>import('@/views/m/m.vue'),
|
component:()=>import('@/views/wxJump/WxJump.vue'),
|
||||||
meta:{
|
meta:{
|
||||||
isFullpage: true
|
isFullpage: true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +0,0 @@
|
|||||||
<template>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
location.href='weixin://dl/business/?t=9FVo0FY1jLk'
|
|
||||||
</script>
|
|
||||||
61
src/views/wxJump/WxJump.vue
Normal file
61
src/views/wxJump/WxJump.vue
Normal 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>
|
||||||
Loading…
Reference in New Issue
Block a user