收藏
回答

onShareAppMessage 取消分享

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug onShareAppMessage 微信安卓客户端 8.0037 2.28
 当用户点击分享时   有些业务逻辑需要判断   按照官方的返回  promise  reject中断   判断登录时 好友弹框和自己的弹框一起被弹出来 分享没有被中止
 报错

onShareAppMessage(res) {
    let that = this;
    let promise = new Promise(async (resolve, reject) => {
   console.log(!this.isLogin,'!this.isLogin')
      if (!this.isLogin) {
        reject();
        await this.$ui.showModal({
          title: "欢迎光临",
          content: "?",
          confirmText: "前去登录",
          success: (res) => {
            if (res.confirm) {
              uni.navigateTo({
                url: "/pages/auth/login",
              });
            }
          },
        });
      } else if (!this.userinfo?.store && !this.userinfo?.agent) {
        that.$ui.showModal({
          title: "",
          content: "",
          confirmText: "是",
          success: (res) => {
            if (res.confirm) {
              uni.navigateTo({
                url: "/pages/agent/apply_agent",
              });
            } else {
              // 取消的相关操作
              uni.navigateBack();
            }
          },
        });
        reject();
      } else {
        // 判断邀请名额是否用完
        if (that.userinfo.leftConsumerInvites == 0) {
          that.$ui.showModal({
            title: "",
            content: "",
            showCancel: false,
            success: (res) => {
              uni.navigateBack();
            },
          });
          reject();
        } else {
          resolve({
            title: that.goods.title,
            type: 0,
            imageUrl:
              "https://mall-oss.gszjxtpt.com/mall/icon/%E5%95%86%E5%93%81%EF%BC%88%E5%88%86%E4%BA%AB%E5%8D%A1%E7%89%87%EF%BC%89.png",
          });
        }
        setTimeout(() => {
          debugger;
          return {
            title: "",
            type: 0,
            promise,
            path:
              "/pages/mall/goods_detail/goods_detail?inviteId=" +
              that.userinfo.userId +
              "&goodsId=" +
              that.goodsId,
          };
        }, 1000);
      }
    });

  },

最后一次编辑于  2023-06-25
回答关注问题邀请回答
收藏
登录 后发表内容