webapp项目vue框架点击按钮实现微信好友分享,朋友圈分享

<template>

    <div class="" id="share" v-for="(items,index) in strands" :key="index" @click="wxShare(index)"> 

             <img v-if="index==0" src="../assets/img/gg/wChart.png" alt="">

             <img v-if="index==1" src="../assets/img/gg/circle.png" alt="">

        <span>{{items.flag}}</span>  

    </div>

</template>

data(){

        return{

            strands:[{flag:'微信好友'},{flag:'朋友圈'}]

        }

    },

methods:{

  wxShare(index){

            let msg = {}

                msg.type='web'  

                msg.title='XX软件名'

                msg.content='这里填一些分享信息,是在好友还未点进去看到的信息'

                msg.thumbs=['../assets/img/alert/logo.png']                 //打包进app的本地applogo

                msg.href='https://www.baidu.com/'                              //好友点进去需要跳转的连接

            if(index==0){

                msg.extra={scene:"WXSceneSession"}                      //好友分享

            }else if(index==1){

                msg.extra={scene:"WXSceneTimeline"}                     //朋友圈分享

            }

           plus.share.getServices(function(e) {                            //移动端获取服务,这里的plus方法只能在移动端有效,在pc端运行会报plus错误,下一步就该打包检验

              this.shareData = e                               //这个回调函数的参数 e 就包含了所有对象的数组

              for(var i in e){        

                  if('weixin' == e[i].id){

                      this.sharewx = e[i]  

                  }

              }

          })

           // 使用send发起分享

            this.sharewx.send(msg,function(){

     alert('分享成功')  

          },function(error) {

               alert('分享失败')

       })

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值