文件
OmniCard/mpuniapp/pages/template/external-link-launch/external-link-launch.uvue

55 行
2.7 KiB
Plaintext

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<template>
<view>
<!-- #ifdef APP -->
<button class="button" @click="openSchema('https://uniapp.dcloud.io/uni-app-x')">使用外部浏览器打开指定URL</button>
<!-- #endif -->
<!-- #ifdef APP-ANDROID -->
<button class="button" @click="openSchema('market://details?id=com.tencent.mm')">使用应用商店打开指定App</button>
<button class="button" @click="openSchema('androidamap://viewMap?sourceApplication=Hello%20uni-app&poiname=DCloud&lat=39.9631018208&lon=116.3406135236&dev=0')">
打开地图坐标
</button>
<!-- #endif -->
<!-- #ifdef APP-IOS -->
<button class="button" @click="openSchema('itms-apps://search.itunes.apple.com//WebObjects//MZSearch.woa/wa/search?media=software&lterm=')">打开 AppStore 到搜索页</button>
<button class="button" @click="openSchema('http://maps.apple.com/?q=数字天堂公司&sll=39.9631018208,116.3406135236&z=10&t=s')">打开 iOS 地图坐标</button>
<!-- apple协议:https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html -->
<!-- #endif -->
<!-- #ifdef WEB -->
<view class="tip">
<text>仅Android/iOS设备的浏览器中支持使用此功能,需先安装“Hello uni-app x”应用,如未安装请前往以下网页安装:</text>
<text class="link" @click="openSchema('https://hellouniappx.dcloud.net.cn/')">https://hellouniappx.dcloud.net.cn/</text>
</view>
<button class="button" @click="openSchema('hellouniappx://')">启动 Hello uni-app x 应用</button>
<!-- #endif -->
<!-- #ifdef APP-HARMONY -->
<button class="button" @click="openSchema('https://appgallery.huawei.com/app/detail?id=io.dcloud.hellouniapp.h')">使用应用商店打开指定App</button>
<button class="button" @click="openSchema('amapuri://route/plan?dlat=39.9631018208&dlon=116.3406135236&dname=数字天堂公司&sname=我的位置&t=0&sourceApplication=io.dcloud.uniappx')">
使用高德地图打开地图坐标
</button>
<!-- #endif -->
</view>
</template>
<script setup lang="uts">
/**
* @description: 演示通过统一入口唤起浏览器、应用商店、地图应用和自定义协议链接。
* @logic: 根据不同平台展示对应按钮,点击后调用 `openSchema` 打开目标链接、应用商店页面或地图坐标。
* @optimization: 把不同平台的跳转入口收敛到同一个 `openSchema` 调用,减少平台分支下的重复跳转逻辑。
*/
import { openSchema } from '@/uni_modules/uts-openSchema'
</script>
<style>
.button {
margin: 15px;
}
.tip {
padding: 8px;
}
.link {
color: #7A7E83;
font-size: 14px;
line-height: 20px;
}
</style>