1、分享給朋友
分享給朋友是小程序自帶API: onShareAppMessage
button組件配置open-type='share'
<button class="mini-btn" type="primary" size="mini" bindtap="handleCode" data-type="replay" data-url="{{erweiCOde}}" open-type="share" data-EMcode="{{employeeCode}}">發送給朋友</button>
JS
onShareAppMessage: function(res) { console.log(res) let that = this; const obj = { title: "發送給好友", imageUrl: that.data.erweiCOde, path: '/pages/login/index?employeeCode='+res.target.dataset.emcode,(打開路徑,在打開頁面里的onload里接收參數) success: function(res) { console.log(res, "轉發成功") }, fail: function(res) { wx.showToast({ title: '發送失敗', icon:'none' }) } } return obj }
2、小程序二維碼生成
小程序二維碼生成一般是后端提供接口,前端請求的時候只要進行參數配置
主要參數:
①、scene:要攜帶的參數
②、path:掃二維碼要進入的頁面路徑
要注意的是二維碼進入進入的頁面參數的接收(在要進入頁面的onload里面)
一定要用 decodeURIComponent() 進行二維碼解析