Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用相机扫码完成或失败后,调用message组件显示提示信息,连续两次调用时,提示信息会直接消失 #3067

Open
DouDouLi-YouTang opened this issue Aug 13, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@DouDouLi-YouTang
Copy link

DouDouLi-YouTang commented Aug 13, 2024

tdesign-miniprogram 版本

1.5.1

重现链接

No response

重现步骤

wx.scanCode({
    onlyFromCamera: true,// 只能使用相机扫码
    scanType: ['qrCode'], // 只接受二维码
}).then( res => {
  console.log('二维码', res.result)
  Message.success({
    context: this,
    offset: [90, 32],
    duration: -1,
    content: '扫码成功'
  });
}).catch(res => {
  if (res.errMsg === 'scanCode:fail cancel') {
    Message.warning({
      context: this,
      offset: [90, 32],
      content: '用户取消扫码',
    });
  } else {
    Message.error({
      context: this,
      offset: [90, 32],
      content: '二维码无效,扫码失败!',
    });
  }
})

期望结果

扫码结束后,提示信息能正常显示

实际结果

提示消息会突然消失,或者消失的很快,并未等到时间结束

基础库版本

3.5.3

补充说明

复现步骤,快速两次取消扫码即可触发

Copy link
Contributor

👋 @DouDouLi-YouTang,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@anlyyao
Copy link
Collaborator

anlyyao commented Aug 13, 2024

@DouDouLi-YouTang 可能是组件内部单独设置一个动画持续时间,所以在快速连续调用下,会存在时机错误。message问题我们验证一下。 但是你这个场景用 Toast 比较合适吧 🤔

@anlyyao anlyyao added the bug Something isn't working label Aug 13, 2024
@DouDouLi-YouTang
Copy link
Author

@DouDouLi-YouTang 可能是组件内部单独设置一个动画持续时间,所以在快速连续调用下,会存在时机错误。message问题我们验证一下。 但是你这个场景用 Toast 比较合适吧 🤔

Toast 样式感觉不是很好看😂

@anlyyao
Copy link
Collaborator

anlyyao commented Aug 13, 2024

@DouDouLi-YouTang 刚刚看了一下,问题的原因可能是wx.scanCode()结束关闭扫码页面时,会触发页面重新渲染,而此时message实例并未移除,你可以试试调用wx.scanCode()之前调用一下message hide,手动移除实例。另外wx.scanCode()调用成功/失败都有相应的回调函数、

 testScan() {
    Message.hide({
      context: this,
    });
    wx.scanCode({
      onlyFromCamera: true,
      scanType: ['qrCode'],
      success: () => {
        Message.success({
        ...
        });
      },
      fail: () => {
        Message.error({
          ...
        });
      },
    });
  }

@DouDouLi-YouTang
Copy link
Author

@DouDouLi-YouTang 刚刚看了一下,问题的原因可能是wx.scanCode()结束关闭扫码页面时,会触发页面重新渲染,而此时message实例并未移除,你可以试试调用wx.scanCode()之前调用一下message hide,手动移除实例。另外wx.scanCode()调用成功/失败都有相应的回调函数、

 testScan() {
    Message.hide({
      context: this,
    });
    wx.scanCode({
      onlyFromCamera: true,
      scanType: ['qrCode'],
      success: () => {
        Message.success({
        ...
        });
      },
      fail: () => {
        Message.error({
          ...
        });
      },
    });
  }

好的好的,感谢

@DouDouLi-YouTang DouDouLi-YouTang closed this as not planned Won't fix, can't repro, duplicate, stale Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants