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

支付宝小程序扫描普通二维码获取不到 qrCode 值 #10528

Open
sanonz opened this issue Oct 29, 2021 · 1 comment
Open

支付宝小程序扫描普通二维码获取不到 qrCode 值 #10528

sanonz opened this issue Oct 29, 2021 · 1 comment
Labels
F-react Framework - React T-alipay Target - 编译到支付宝小程序 V-3 Version - 3.x

Comments

@sanonz
Copy link
Contributor

sanonz commented Oct 29, 2021

相关平台

支付宝小程序

复现仓库


小程序基础库: 2.16.0
使用框架: React

复现步骤

  1. 按照此官方文档配置普通二维码:https://opendocs.alipay.com/mini/operation/vzd5v0
  2. 扫码普通二维码跳转指定页面通过 useRouter().params.qrCode 代码获取不到对应参数

期望结果

通过 useRouter().params.qrCode 获取对应支付宝小程序参数

实际结果

获取不到

环境信息

👽 Taro v3.3.12


  Taro CLI 3.3.12 environment info:
    System:
      OS: macOS 11.6
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 15.14.0 - ~/.nvm/versions/node/v15.14.0/bin/node
      Yarn: 1.22.15 - ~/.nvm/versions/node/v16.0.0/bin/yarn
      npm: 7.20.1 - ~/.nvm/versions/node/v15.14.0/bin/npm
    npmPackages:
      @tarojs/cli: ^3.3.12 => 3.3.12 
      @tarojs/components: ^3.3.12 => 3.3.12 
      @tarojs/mini-runner: ^3.3.12 => 3.3.12 
      @tarojs/react: ^3.3.12 => 3.3.12 
      @tarojs/runtime: ^3.3.12 => 3.3.12 
      @tarojs/taro: ^3.3.12 => 3.3.12 
      @tarojs/webpack-runner: ^3.3.12 => 3.3.12 
      babel-preset-taro: ^3.3.12 => 3.3.12 
      eslint-config-taro: ^3.3.12 => 3.3.12 
      react: ^17.0.2 => 17.0.2
@taro-bot2 taro-bot2 bot added F-react Framework - React T-alipay Target - 编译到支付宝小程序 V-3 Version - 3.x labels Oct 29, 2021
@sanonz
Copy link
Contributor Author

sanonz commented Nov 1, 2021

以下为支付宝扫码普通二维码打开小程序页面过程的日志

日志代码为

console.log(`onLoad: this.$taroParams -> ${this.$taroParams}`)
console.log(`onLoad: Current.router.params -> ${Current.router?.params}`)

onLoad 打印位置为

onLoad (this: MpInstance, options, cb?: Func) {
perf.start(PAGE_INIT)
Current.page = this as any
this.config = pageConfig || {}
options.$taroTimestamp = Date.now()
// this.$taroPath 是页面唯一标识,不可变,因此页面参数 options 也不可变
this.$taroPath = getPath(id, options)
// this.$taroParams 作为暴露给开发者的页面参数对象,可以被随意修改
if (this.$taroParams == null) {
this.$taroParams = Object.assign({}, options)
}
const router = isBrowser ? this.$taroPath : this.route || this.__route__
Current.router = {
params: this.$taroParams,
path: addLeadingSlash(router),
onReady: getOnReadyEventKey(id),
onShow: getOnShowEventKey(id),
onHide: getOnHideEventKey(id)
}

onShow 打印位置为

onShow () {
Current.page = this as any
this.config = pageConfig || {}
const router = isBrowser ? this.$taroPath : this.route || this.__route__
Current.router = {
params: this.$taroParams,
path: addLeadingSlash(router),
onReady: getOnReadyEventKey(id),
onShow: getOnShowEventKey(id),
onHide: getOnHideEventKey(id)
}

onShow2 打印位置为

onShow: {
enumerable: true,
writable: true,
value (options) {
const app = ref.current
Current.router = {
params: options?.query,
...options
}

framework: App onHide
framework: page onHide pages/index/index
framework: App onHide
framework: App onShow
onShow2: this.$taroParams -> undefined
onShow2: Current.router.params -> {qrCode: "https://domain.com/mp/inbox/9ca5db16-c334-4ad5-b029-27a9d9ee99dc"}
framework: page onUnload pages/index/index
framework: page onLoad pages/inboxes/inboxes
onLoad: this.$taroParams -> {$taroTimestamp: 1635739041686}
onLoad: Current.router.params -> {qrCode: "https://domain.com/mp/inbox/9ca5db16-c334-4ad5-b029-27a9d9ee99dc"}
onShow: this.$taroParams -> {$taroTimestamp: 1635739041686}
onShow: Current.router.params -> {$taroTimestamp: 1635739041686}
framework: page onShow pages/inboxes/inboxes
framework:pages/inboxes/inboxes: transfer costs 14ms, render costs 7ms.
framework: page onReady pages/inboxes/inboxes
framework:pages/inboxes/inboxes: transfer costs 20ms, render costs 12ms.
framework:pages/inboxes/inboxes: transfer costs 18ms, render costs 9ms.
framework:pages/inboxes/inboxes: transfer costs 6ms, render costs 29ms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-alipay Target - 编译到支付宝小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

1 participant