uniapp 小程序 跳转到外部链接

场景:点击“积分列表”中的“积分兑换”,需要跳转到三方的“积分商城”链接进行兑换,兑换完成后,跳回小程序“积分列表”。

结论:无法离开小程序,跳转到其他地址。只能通过web-view内嵌的形式,将三方链接内嵌进小程序。

参数传递方式:拼接到src上 ,<web-view src='https://aaa.com/index?参数a=XXXXX&参数b=XXXXX' / >

积分列表页面

<template>
	<!-- 积分列表 -->
	<view class="bg_wrap fs_28">
		<text class="cor_9 fs_24">累计积分:{
   
   {info.total}}</text>
		<text class="cor_9 fs_24">剩余积分:{
   
   {info.surplus}}</text>
		<view class="green_btn_small" @click="go_thirdPart">去兑换</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info: {
					total: 12,
					surplus: 1
				}
			}
		},
		methods: {
			// 去兑换
			go_thirdPart() {
				uni.navigateTo({
					url: `/subpkg/bonus/bonus_exchange?openid=${uni.getStorageSync('openid')}&surplus=${this.info.surplus}`
				})
			}˝
		}
	}
</script>

积分兑换页面

<template>
	<!-- 积分兑换页面 -->
	<view class="bg_wrap fs_28">
		<web-view
			:src="`https://cy.jingxiniao.com/index/inlet.html?openid=${options.openid}&surplus=${options.surplus}`" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				options: {}
			}
		},
		onLoad(options) {
			this.options = options
		},
	}
</script>

猜你喜欢

转载自blog.csdn.net/Shimeng_1989/article/details/131403790