admin 管理员组

文章数量: 1184232

<template>
	<view class="box">
		<button type="primary" @click="downloadApp">apk下载</button>
		<uni-popup ref="mypopups" :mask-click="false" type="top" :animation="false">
			<view style="height: 300rpx;width: 100%;text-align: right;">
				<image src="../../static/hare.png" mode=""></image>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isAndroid: false,
				isIOS: false,
				isWeiXin: false
			};
		},
		mounted() {
			/* 判断是否为微信环境 */
			this.isWeiXin = navigator.userAgent.toLowerCase().indexOf('micromessenger') > -1 ? true : false
			if (this.isWeiXin) {
				this.$refs.mypopups.open()
			} else {
				this.$refs.mypopups.close()
			}
		},
		methods: {
			/* 判断用户手机为安卓还是iphone */
			checkPhone() {
				let self = this
				let agent = (navigator.userAgent || navigator.vendor || window.opera)
				if (agent != null) {
					let agentName = agent.toLowerCase()
					if (/android/i.test(agentName)) {
						self.isAndroid = true
					} else if (/iphone/i.test(agentName)) {
						self.isIOS = true
					}
				}
			},
			/* 点击下载按钮 */
			downloadApp() {
				// 微信环境
				let self = this
				self.checkPhone()
				console.log(self.isAndroid, self.isIOS);
				let agent = (navigator.userAgent || navigator.vendor || window.opera)
				if (agent != null) {
					let agentName = agent.toLowerCase()
					if (self.isAndroid) {
						// 安卓包下载地址
						window.location.href =
							'xxxxxxxxxxx'
					} else if (self.isIOS) {
						uni.showModal({
							title: "还未开发,敬请期待~",
							confirmColor: '#009FEE',
							success: (res) => {
								if (res.confirm) {

								} else {
									console.log('cancel') //点击取消之后执行的代码
								}
							}
						})
						// 苹果商店链接地址
						// window.location.href = config.iosAppstoreUrl
					} else {
						uni.showModal({
							title: "暂不支持,敬请期待~",
							confirmColor: '#009FEE',
							success: (res) => {
								if (res.confirm) {

								} else {
									console.log('cancel') //点击取消之后执行的代码
								}
							}
						})
					}
				}
			}

		}
	}
</script>

<style lang="scss">
	.box {
		width: 100vw;
		height: 100vh;
		display: flex;
		align-items: center;
		justify-content: center;
	}
</style>

本文标签: 第三方 页面 方法 App