微信小程序转发功能

问题描述

微信小程序如何请求接口成功后再去调用微信转发的接口

问题出现的环境背景及自己尝试过哪些方法

相关代码

// 请把代码文本粘贴到下方(请勿用图片代替代码)

 <button formType="submit" wx:if="{{executorDtata.length==1}}"  open-type="share">创建并邀请好友</button>
 
  create:function(e){
    console.log('2222222')
    var that = this;
    if (this.data.taskContent.replace(/\s+/g, '')){
      wx.request({
        url: getApp().globalData.url + '/createTack',
        data: {
          groupId: getApp().globalData.groupId,
          isRepeat: this.data.listNoId ? 1 : 0,
          taskContent: this.data.taskContent,
          executeUserId: this.data.executorZid,
          remindUserIds: this.data.remindNoZid,
          remindTime: this.data.time,
          remindWeek: this.data.listNoId,
          flag: this.data.executorDtata.length > 1 ? 0 : 1
        },
        header: {
          Authorization: getApp().globalData.token,
          // formId: e.detail.formId
          formId: 1
        },
        success: function (res) {
          if (res.data.code == 100) {
            that.onShareAppMessage()
          }
        }
      })
    }else{
      wx.showToast({
        title: '请您输入创建任务',
        duration: 1000,
        icon: 'none'
      })
    }
  },
  onShareAppMessage: function(ops) {
    if (ops.from === 'button') {
      console.log('1111111111')
      return {
        title: '小哥哥图片',
        desc: '小哥哥图片',
        path: '/pages/join/join?inviteUserId=' + this.data.shareZid + "&groupId=" + this.data.shareGroupId,
        imageUrl: "../../images/userimg.jpg",
        success: (res) => {
          wx.reLaunch({
            url: '../task/task',
          })
        },
        fail: (res) => {
          console.log("转发失败", JSON.stringify(res));
        }
      }
      
    }
  },

你期待的结果是什么?实际看到的错误信息又是什么?

图片描述

阅读 2.3k
1 个回答

没太看懂
另外onShareAppMessage接口已经改了

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题