vue(h5+app分享微信、朋友圈、保存图片)

  • 注意并不是h5而是vue打包的app
  • h5+api(调用手机的一些功能) http://www.html5plus.org/doc/zh_cn/android.html
  • 分享海报(image)
 shareWx(scene) {
 //scene=> 'WXSceneTimeline'(朋友圈)、'WXSceneSession'(微信)、pic=>图片地址
        let pic = this.pic_img
        let msg = {
          type: "image",
          pictures: [pic],
          href: pic,
          extra: {
            scene:scene
          }
        }
        let t = this 
        plus.share.getServices(function(e) {
          //在这个数组里 找到属于微信的对象 循环匹配查找
          for (var i in e) {
            if ('weixin' == e[i].id) {
              t.sharewx = e[i] //保存到变量里 (之后即可使用该对象发起分享)
              t.getsend(msg)
            }
          }
        })
      },
  • 分享链接
 shareWx(scene) {
        let purl = "/static/imgs/thumb.png" //可以是本地图片
        var surl = this.logs.invite_url; //分享的链接
        let msg = {
         title:'xxxx', //标题
         content:'xxxxxxxxx', //内容
         thumbs:[purl], //缩略图
         href:surl,
          extra: {
            scene:scene
          }
        }
        let t = this
        plus.share.getServices((e)=>{
          //在这个数组里 找到属于微信的对象 循环匹配查找
          for (var i in e) {
            if ('weixin' == e[i].id) {
              t.sharewx = e[i] //保存到变量里 (之后即可使用该对象发起分享)
              t.getsend(msg)
            }
          }
        })
      },
  • 然后调用shareWx()
getsend(msg){
        this.sharewx.send(msg,()=>{
          this.$toast({
            message:'分享成功',
            duration:1000
          });
        },(error)=>{
          this.$toast({
            message:'分享失败,请重新分享',
            duration:1000
          });
        })
      },
  • 保存图片
getpic() {
//picurl=>图片地址
	plus.gallery.save(picurl, ()=>{
		 Toast("保存图片到相册成功");
	}, ()=>{
		 Toast("保存失败,请重新保存");
	});
},
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值