收藏
回答

wx.onMenuShareAppMessage 分享微信好友在手机使用无效?

两个问题:

1、配置了wx.config,并正确添加jsApiList,但是点击右侧底部菜单里没有分享微信好友和朋友圈的入口按钮,有时候刷新下页面就能出来

打开debug后,有时会触发多次debug

2、当分享按钮出来时,点击分享微信好友,在手机中就直接什么都没有配置的图片和文案都没正确展出,只有一个链接

代码如下:

async shareConfig() {

const host = this.$development ? 'b' : 's'

const { wechatAppId } = getApp().globalData

const { doctorId, doctorName, departmentName, doctorHeadUrl } = this.doctor

const title = `${doctorName}医生的出诊信息-${this.currentOrganDutyInfo.dutyName} ${departmentName}`

let link = `https://${host}.xiaoluyy.com/patient/?appId=${wechatAppId}#/pages/order/appointment/appointmentInfo?dutyId=${this.currentOrganDutyInfo.dutyId}&organIds=&doctorId=${doctorId}&appId=${wechatAppId}`

await this.getWeChatConfig()

wx.showMenuItems({

menuList: ['menuItem:share:appMessage', 'menuItem:share:timeline']

})

wx.onMenuShareAppMessage({

title,

desc: '',

link,

imgUrl: doctorHeadUrl

})

wx.onMenuShareTimeline({

title,

link,

imgUrl: doctorHeadUrl

})

},

getWeChatConfig() {

let href = location.href.split('#')[0]

const { wechatAppId } = getApp().globalData

return new Promise((resolve) => {

uni.request({

url: '/xiaoluwebserver/wx_service/getWeChatConfig',

data: {

appId: wechatAppId,

url: encodeURIComponent(href)

},

header: { 'content-type': 'application/x-www-form-urlencoded' },

method: 'POST',

success: (res) => {

let data = res.data

if (data.code == 1000) {

let obj = data.datas

wx.config({

debug: true,

appId: obj.appId,

timestamp: obj.timestamp,

nonceStr: obj.nonceStr,

signature: obj.signature,

jsApiList: ['showMenuItems', 'onMenuShareTimeline', 'onMenuShareAppMessage']

})

wx.ready(function (res) {

console.log('wx.ready ===>>>')

resolve()

})

wx.error((err) => {

console.log('wx.error', err)

})

}

}

})

})

},

控制台打印:


最后一次编辑于  02-26
回答关注问题邀请回答
收藏

2 个回答

登录 后发表内容