• 小程序分享H5页面


    1、在要分享的按钮上写一个跳转

    <navigator url="../invite1/invite1">
      <button class="invite_btn">立即邀请</button>
    </navigator>
    2、再新建一个页面invite1,新建一个web-view

    wxml页面

    <web-view src="{{shareUrl}}"></web-view>
    js页面

    定义一个变量,并对其赋值。

    data:{
      shareUrl: null
    },
    onLoad: function (options) {
      var that = this
      that.setData({
        shareUrl: "http://test.meetfit.com.cn/share/active/?userId=" + id + "&userName=" + nickname
      })
    },
    

      

    3、分享js
    onShareAppMessage: function (res) {
      var that = this
      if (res.from === 'button') {
        // 来自页面内转发按钮
        console.log(res.target)
      }
      return {
        title: '分享H5',
    //这一点很重要哦,小程序只能打开自己的页面,所以需要本地的地址+webViewUrl的地址才行。
        path: "/pages/mine/invite1/invite1?url=" +res.webViewUrl,  
        imageUrl: "",
        success: (res) => {
          if (res.data.code == 0) {
            wx.showToast({
            title: '发送邀请好友成功',
            icon: 'success',
            duration: 2000
          })
        } else {
         wx.showToast({
          title: res.data.message,
          icon: 'none',
          duration: 2000
        })
       }
      },
        fail: (res) => {
        console.log("转发失败", res);
        }
      }
    }
    

      

  • 相关阅读:
    使用FluentScheduler和IIS预加载在asp.net中实现定时任务管理
    [WCF REST] Web消息主体风格(Message Body Style)
    [WCF REST] Web消息主体风格(Message Body Style)
    REST WCF Service中的WebMessageBodyStyle
    REST WCF Service中的WebMessageBodyStyle
    C#表示空字符
    053517
    053516
    053515
    053514
  • 原文地址:https://www.cnblogs.com/chengmingxiaowu/p/9766211.html
Copyright © 2020-2023  润新知