1.manifest.json配置:
將自己申請好的Id,填到組態檔中:

2.在page.json中添加個小圖示:
{
"path" : "pages/instrument/diary/diary",
"style" : {
"navigationBarTitleText": "施工日志",
"app-plus": {
"scrollIndicator":"none",// 移動端去掉滾動條
"titleNView": {
"buttons": [
{
"text": "\ue7c5",
"fontSrc": "/static/iconfont.ttf",
"fontSize": "18px"
}
]
}
}
}
}
來張效果圖;(右邊小圖示)

3.給小圖示個點擊事件:
備注:這里要用到uniapp自帶方法哦!
onNavigationBarButtonTap() {
//這里可以根據需求,跳轉頁面或者直接打開分享的彈框即可!
//我是直接跳轉頁面了,在跳轉后的頁面實作分享鏈接
uni.navigateTo({
url:"../../share/shareApp"
})
},
4.微信分享,或者QQ分享:

給各自圖示加點擊方法:
toShireqq(){
let that = this
let url = that.$http.shareUrl+that.accountId
//判斷是不是ios,蘋果登錄(發現的bug,如果不判斷另外一個就無法分享)
if(uni.getSystemInfoSync().platform =='ios'){
uni.share({
provider: "qq",
scene: "WXSceneSession",
type: 1,
summary:'這里是發送出去的話加上可以點擊的h5頁面!'+ url,
success: function (res) {
that.$refs.popup.close()
},
fail: function (err) {
console.log("fail:" + JSON.stringify(err));
}
});
}else{
uni.share({
provider: "qq",
scene: "WXSceneSession",
title:'建助江湖',
type: 1,
href:url,
summary:'這里是發送出去的話加上可以點擊的h5頁面!!'+ url,
success: function (res) {
that.$refs.popup.close()
},
fail: function (err) {
console.log("fail:" + JSON.stringify(err));
}
});
}
},
toShirewx(){
let that = this
let url = that.$http.shareUrl+that.accountId
uni.share({
provider: "weixin",
scene: "WXSceneSession",
type: 1,
summary: '這里是發送出去的話加上可以點擊的h5頁面'+ url,
success: function (res) {
that.$refs.popup.close()
},
fail: function (err) {
console.log("fail:" + JSON.stringify(err));
}
});
},
到此結束分享!代碼既粘即用,沒有bug,如有問題,評論說明!!!!
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/58952.html
標籤:java
