先在mainfest.json的模块配置中勾选Share(分享),填好微信开放平台申请的应用的appid,生成通用链接。 uniapp的vue文件js代码: function msg(tit, cont, k, fun) {//消息主题,消息内容,k为0表示有取消按钮,k为1不要取消按钮, k>100为显示时长毫秒数, k为字符串表示有输入框且k串可作为输入提示,fun为结果处理法 var ts = '', ed = false; if(typeof(cont)!='string' && !k){ k=cont; cont=''; } if (typeof(k) == 'string') { ts = k; ed = true; } var qx = true; if (!k) k = 0; if (k == 1) qx = false; if (k > 100) { uni.showToast({title: tit,icon: 'success',duration: k}); return; } uni.showModal({ title: tit,content: cont,showCancel: qx, editable: ed, placeholderText: ts, success: (e) => { if (e.cancel) return; if (typeof(fun) == 'function') fun(e.confirm); } }) } if (a.action == 'fxgpy') {//分享给好友 uni.share({ provider: "weixin", scene: "WXSceneSession", type: 0, href: a.url, title: a.title, summary: a.desc, imageUrl: a.pic, success: function(res) { console.log("success:" + JSON.stringify(res)); }, fail: function(err) { console.log("fail:" + JSON.stringify(err)); msg('提示', '未分享给朋友', 1) console.log("提示:未分享给朋友"); } }); } else if (a.action == 'fxdpyq') {//分享到朋友圈 uni.share({ provider: "weixin", scene: "WXSceneTimeline", type: 0, href: a.url, title: a.title, summary: a.desc, imageUrl: a.pic, success: function(res) { console.log("success:" + JSON.stringify(res)); }, fail: function(err) { console.log("fail:" + JSON.stringify(err)); msg('提示', '未分享到朋友圈', 1) console.log("提示:未分享到朋友圈"); } }); } |
![]() |
上一篇: | DeepSeek本地部署操作指南(免费) |
下一篇: | uniapp中跳转微信小程序 |