初始化

This commit is contained in:
魏啾
2024-05-23 14:45:18 +08:00
parent c6f49f161e
commit e6d878888c
4 changed files with 53 additions and 18 deletions

View File

@@ -40,6 +40,7 @@
</view>
</template>
<script>
import wx from 'weixin-js-sdk';
export default {
components: {},
data() {
@@ -97,22 +98,46 @@
},
onShow() {},
methods: {
jumpToMiniProgram() {
plus.share.getServices(function (res) {
var sweixin = null;
for (var i = 0; i < res.length; i++) {
var t = res[i];
if (t.id == 'weixin') {
sweixin = t;
}
}
if (sweixin) {
sweixin.launchMiniProgram({
id:'gh_fa9286427a5b', //这里写你的小程序原始id以gh开头
type: 0, // //小程序版本 0-正式版; 1-测试版; 2-体验版
path: 'pages/index/index' //这里是指定页的路径,如需传参直接字符串拼接(首页可以省略
});
}
async jumpToMiniProgram() {
let res = await this.api.userttwechat()
console.log(res)
// plus.share.getServices(function (res) {
// var sweixin = null;
// for (var i = 0; i < res.length; i++) {
// var t = res[i];
// if (t.id == 'weixin') {
// sweixin = t;
// }
// }
// if (sweixin) {
// sweixin.launchMiniProgram({
// id:'gh_fa9286427a5b', //这里写你的小程序原始id以gh开头
// type: 0, // //小程序版本 0-正式版; 1-测试版; 2-体验版
// path: 'pages/index/index' //这里是指定页的路径,如需传参直接字符串拼接(首页可以省略)
// });
// }
// });
wx.config({
"debug": true,
"beta": false,
"jsApiList": ['wx-open-launch-weapp'],
openTagList: ['wx-open-launch-weapp'], // 跳转小程序时必填
"appId": res.data.wechat_mini.appId,
"nonceStr": res.data.wechat_mini.nonceStr,
"timestamp": res.data.wechat_mini.timestamp,
"url": res.data.wechat_mini.url,
"signature": res.data.wechat_mini.signature,
});
// res.data.wechat_mini
// 在wx.ready内调用
wx.ready(function() {
// 在这里调用 API
uni.navigateTo({
url: '/pages/index/index' // 跳转到的页面路径
});
});
wx.error(function(res) {
console.log('err', res)
});
// // #ifdef H5
// // 在H5环境中调用此函数来跳转到小程序