|
@@ -179,7 +179,27 @@
|
|
|
methods: {
|
|
methods: {
|
|
|
init() {
|
|
init() {
|
|
|
},
|
|
},
|
|
|
- // 解析路由参数 id/salt
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 把 query/scene 字符串解析成键值(供货商收款页用)
|
|
|
|
|
+ * 小程序码扫入时只有 scene=id=xx&salt=yy,普通码可能是完整 URL 的 q
|
|
|
|
|
+ */
|
|
|
|
|
+ parseQueryPairs(queryStr) {
|
|
|
|
|
+ const sceneArray = {}
|
|
|
|
|
+ if (!queryStr) {
|
|
|
|
|
+ return sceneArray
|
|
|
|
|
+ }
|
|
|
|
|
+ const sceneItem = String(queryStr).split('&')
|
|
|
|
|
+ for (let i = 0, l = sceneItem.length; i < l; i++) {
|
|
|
|
|
+ const arr = sceneItem[i].split('=')
|
|
|
|
|
+ const key = arr[0]
|
|
|
|
|
+ if (!key) {
|
|
|
|
|
+ continue
|
|
|
|
|
+ }
|
|
|
|
|
+ sceneArray[key] = arr.length > 1 ? arr.slice(1).join('=') : ''
|
|
|
|
|
+ }
|
|
|
|
|
+ return sceneArray
|
|
|
|
|
+ },
|
|
|
|
|
+ // 解析路由参数 id/salt:直链 / 小程序码 scene / 普通二维码 q
|
|
|
parsePayPageParams() {
|
|
parsePayPageParams() {
|
|
|
let id = 0
|
|
let id = 0
|
|
|
let salt = ''
|
|
let salt = ''
|
|
@@ -187,15 +207,19 @@
|
|
|
if (option.id && option.salt) {
|
|
if (option.id && option.salt) {
|
|
|
id = option.id || 0
|
|
id = option.id || 0
|
|
|
salt = option.salt || ''
|
|
salt = option.salt || ''
|
|
|
|
|
+ } else if (option.scene) {
|
|
|
|
|
+ // 无数量限制小程序码:参数在 scene 里,需 decode 后再拆
|
|
|
|
|
+ const sceneArray = this.parseQueryPairs(decodeURIComponent(option.scene))
|
|
|
|
|
+ if (sceneArray.id) {
|
|
|
|
|
+ id = sceneArray.id
|
|
|
|
|
+ }
|
|
|
|
|
+ if (sceneArray.salt) {
|
|
|
|
|
+ salt = sceneArray.salt
|
|
|
|
|
+ }
|
|
|
} else if (option.q) {
|
|
} else if (option.q) {
|
|
|
const currentUrl = decodeURIComponent(option.q)
|
|
const currentUrl = decodeURIComponent(option.q)
|
|
|
const str = currentUrl.substring(currentUrl.lastIndexOf('?') + 1)
|
|
const str = currentUrl.substring(currentUrl.lastIndexOf('?') + 1)
|
|
|
- const sceneItem = str.split('&')
|
|
|
|
|
- const sceneArray = {}
|
|
|
|
|
- for (let i = 0, l = sceneItem.length; i < l; i++) {
|
|
|
|
|
- const arr = sceneItem[i].split('=')
|
|
|
|
|
- sceneArray[arr[0]] = arr[1]
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const sceneArray = this.parseQueryPairs(str)
|
|
|
if (sceneArray.id) {
|
|
if (sceneArray.id) {
|
|
|
id = sceneArray.id
|
|
id = sceneArray.id
|
|
|
}
|
|
}
|