q-koa 8.5.2 → 8.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -112,6 +112,7 @@ exports.cash = async ({
|
|
|
112
112
|
if (result.err_code_des) throw new Error(result.err_code_des)
|
|
113
113
|
return result
|
|
114
114
|
}
|
|
115
|
+
|
|
115
116
|
exports.qr_code = async ({
|
|
116
117
|
app,
|
|
117
118
|
page,
|
|
@@ -168,18 +169,38 @@ exports.qr_code = async ({
|
|
|
168
169
|
const fileName = `${
|
|
169
170
|
String(new Date().getTime()).split('').reverse().join('') + Math.random()
|
|
170
171
|
}.png`
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (
|
|
174
|
-
|
|
175
|
-
|
|
172
|
+
|
|
173
|
+
const handelResult = (result) => {
|
|
174
|
+
if (result && result.res && result.res.status === 200) {
|
|
175
|
+
if (oss_host && cdn_host) {
|
|
176
|
+
const url = result.url.replace(oss_host, cdn_host)
|
|
177
|
+
return url
|
|
178
|
+
} else {
|
|
179
|
+
return result.url
|
|
180
|
+
}
|
|
176
181
|
} else {
|
|
177
|
-
|
|
178
|
-
return url
|
|
182
|
+
return null
|
|
179
183
|
}
|
|
180
|
-
} else {
|
|
181
|
-
throw new Error(result.res.statusMessage)
|
|
182
184
|
}
|
|
185
|
+
|
|
186
|
+
return client
|
|
187
|
+
.put(fileName, buffer)
|
|
188
|
+
|
|
189
|
+
.then((result) => {
|
|
190
|
+
if (result && result.res && result.res.status === 200) {
|
|
191
|
+
if (oss_host && cdn_host) {
|
|
192
|
+
const url = result.url.replace(oss_host, cdn_host)
|
|
193
|
+
return Promise.resolve(url)
|
|
194
|
+
} else {
|
|
195
|
+
return Promise.resolve(result.url)
|
|
196
|
+
}
|
|
197
|
+
} else {
|
|
198
|
+
return Promise.reject(new Error('小程序码生成错误,请重试'))
|
|
199
|
+
}
|
|
200
|
+
})
|
|
201
|
+
.catch((e) => {
|
|
202
|
+
return Promise.reject(new Error(e.message))
|
|
203
|
+
})
|
|
183
204
|
}
|
|
184
205
|
}
|
|
185
206
|
|
|
@@ -404,7 +404,6 @@ module.exports = class Singleton {
|
|
|
404
404
|
.join('&')
|
|
405
405
|
: '',
|
|
406
406
|
}
|
|
407
|
-
const creatuuid = uuid.v1()
|
|
408
407
|
|
|
409
408
|
const bufferResult = await axios
|
|
410
409
|
.post(url, payLoad, {
|
|
@@ -419,7 +418,7 @@ module.exports = class Singleton {
|
|
|
419
418
|
if (bufferResult.errcode) {
|
|
420
419
|
if (bufferResult.errcode === 40001) {
|
|
421
420
|
cache.reset()
|
|
422
|
-
return await this.
|
|
421
|
+
return await this.createQRBuffer(options)
|
|
423
422
|
}
|
|
424
423
|
throw new Error(bufferResult.errmsg)
|
|
425
424
|
}
|