q-koa 8.5.2 → 8.5.3
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,17 +169,35 @@ 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
|
-
|
|
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
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
return null
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
const result = await client.put(fileName, buffer)
|
|
187
|
+
const url = handelResult(result)
|
|
188
|
+
if (url) {
|
|
175
189
|
return url
|
|
176
190
|
} else {
|
|
177
|
-
|
|
191
|
+
throw new Error(`发生错误,请重试`)
|
|
192
|
+
}
|
|
193
|
+
} catch (e) {
|
|
194
|
+
const result = await client.put(fileName, buffer)
|
|
195
|
+
const url = handelResult(result)
|
|
196
|
+
if (url) {
|
|
178
197
|
return url
|
|
198
|
+
} else {
|
|
199
|
+
throw new Error(`发生错误,请重试`)
|
|
179
200
|
}
|
|
180
|
-
} else {
|
|
181
|
-
throw new Error(result.res.statusMessage)
|
|
182
201
|
}
|
|
183
202
|
}
|
|
184
203
|
}
|