uniapp 公众号打开小程序,app打开小程序,小程序打开其他小程序

公众号打开小程序

第一步->进入项目目录:

npm install jweixin-module --save

第二步->在要调用得页面里面

import jweixin from 'jweixin-module'

第三步->获取签名信息

视图层:因为我是多个跳转按钮所以用一个for循环

<block v-for="(item,index) in list" :key="index">
<wx-open-launch-weapp id="launch-btn" username="gh_84b9766b95bc" :path="item.url">
<script type="text/wxtag-template">
<style>
.btn-open-weapp{
width: 226px;
height: 52px;
background: linear-gradient(0deg, rgba(255, 179, 16, 0.99), rgba(255, 227, 2, 0.99));
border-radius: 26px;
border: none;
margin-top: 18px;
color: #B0240A;
font-size: 16px;
font-weight: bold;
}
.btn-open-weapp::after {
border: none;
}
.btn-open-weapp::before {
border: none;
}
</style>
<button class="btn-open-weapp">{{item.name}}</button>
</script>
</wx-open-launch-weapp>
</block>

getsdksign(){
var that = this;
let url = window.location.href.split('#')[0]; // 很重要
let urls = url.split('#')[0];
that.$request({
url:'getsign',
methods:'GET'
},{
url:url
}).then(res=>{
let data = res.data.data;
jweixin.config({
debug: true, //测试时候用true 能看见wx.config的状态是否是config:ok
appId: data.appid, // 必填,公众号的唯一标识(公众号的APPid)
timestamp: data.timestamp, // 必填,生成签名的时间戳
nonceStr: data.noncestr, // 必填,生成签名的随机串
signature: data.sign, // 必填,签名
jsApiList: ['wx-open-launch-weapp'], // 必填,需要使用的JS接口列表
openTagList: ['wx-open-launch-weapp']
});
jweixin.ready(function (res1) {
console.log(res1);
});
jweixin.error(function (res1) {
console.log("接口调取失败:"+res1);
});
});
},

效果如下,是不是很简单丫。hhh...

( app打开小程序)

getPlus() {
//获取当前显示的webview
var pages = getCurrentPages()
var page = pages[pages.length - 1]
var currentWebview = page.$getAppWebview()
//调用H5+APP的扩展API
var shares=null;
let that = this
var pusher = plus.share.getServices(function(s){
shares={};
for(var i in s){
var t=s[i];
shares[t.id]=t;
}
that.sweixin=shares['weixin'];
}, function(e){
console.log("获取分享服务列表失败:"+e.message);
});
//放入当前的webview
currentWebview.append(pusher);
},

openmini(item){

var that = this;

that.sweixin.launchMiniProgram({
id:'gh_84b9766b95bc' ,//要跳转小程序的原始ID
// type:0, //0正式,1测试 ,2体验
path:item.url   //要打开得页面
});

}

ps:从app直接跳转到微信,并打开小程序,无法提供截图

(小程序打开其他小程序)

openmini(item){

var that = this;

uni.navigateToMiniProgram({
appId: 'wx77af438b3505c00e',
path:item.url, //要打开得页面
success(res) {
// 打开成功
}
});

}

效果如下,是不是很简单丫。hhh...

 

posted @ 2022-01-25 11:16  Monroe_Yu  阅读(643)  评论(0编辑  收藏  举报