uniapp开发分享朋友圈,分享给微信好友列表

公司开发房产平台的,当分享朋友圈的时候,在朋友圈打开的时候,会出现一个白板,然后影响美观性,上头不满意,SO,SO,熬夜干出来了。

首先呢,路由先配置一下:

{
                    "path": "detail_twohand/index",
                    "style": {
                        "navigationStyle": "custom"
                    },
                    "mode":"shareTimeline"
                },

最重要的是要开启这个 "mode":"shareTimeline",然后在uniapp配置文件manifest.json里面开启朋友圈功能。

上图所示,上述准备工作已经做好了,开干 。

分享页面进来之后会有一个属性值在onload里面    

const launchOptions = uni.getLaunchOptionsSync();  小本本记好,等会要考

launchOptions.scene=1154就是分享进来的页面,还是在当前页面,就是那个空白页面。

OK,v-if判断一下 v-if="scene!==1154"(这是正常页面进来的效果)

 v-if="scene==1154"分享页面进来的效果

分享代码是:

//分享给微信好友的

onShareAppMessage() {
            return {
                title: this.detailList.community_name,
                path: `/PagesA/detail_newhome/index?id=${this.id}`
            }
        },

//用户点击右上角分享朋友圈
        onShareTimeline(res) {
            const str = this.detailList.location
            return {
                title: this.detailList.community_name,
                query: `community_name=${this.detailList.community_name}&&img=${this.images[0]}&&location=${str}&&id=${this.detailList.id}&&unit_price=${this.detailList.unit_price}&&id=${this.detailList.id}`,
                imageUrl: this.images[0]
            }
        },

query这样才能传递值!!!

接受值就非常简单了

launchOptions.query这就是刚刚小本本记的,分享到底结束。

咱该赋值的赋值,该咋用咋用,ok,去干其他活咯

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值