q-koa 12.3.2 → 12.3.4
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.
package/core/app.js
CHANGED
|
@@ -295,10 +295,10 @@ exports.swagger = async (ctx) => {
|
|
|
295
295
|
ctx.SUCCESS(apis)
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
exports.getLocation = async (ctx) => {
|
|
298
|
+
exports.getLocation = async (ctx, _data) => {
|
|
299
299
|
const { app } = getAppByCtx(ctx)
|
|
300
300
|
|
|
301
|
-
const { provinceName, cityName, address } = ctx.request.body
|
|
301
|
+
const { provinceName, cityName, address } = _data || ctx.request.body
|
|
302
302
|
if (!provinceName || !cityName || !address) {
|
|
303
303
|
return ctx.SUCCESS({
|
|
304
304
|
longitude: null,
|
|
@@ -320,16 +320,21 @@ exports.getLocation = async (ctx) => {
|
|
|
320
320
|
|
|
321
321
|
const { lng: longitude, lat: latitude } = result.location
|
|
322
322
|
|
|
323
|
-
|
|
323
|
+
ctx.SUCCESS({
|
|
324
324
|
longitude,
|
|
325
325
|
latitude,
|
|
326
326
|
})
|
|
327
|
+
|
|
328
|
+
return {
|
|
329
|
+
longitude,
|
|
330
|
+
latitude,
|
|
331
|
+
}
|
|
327
332
|
}
|
|
328
333
|
|
|
329
|
-
exports.getLngAndLat = async (ctx) => {
|
|
334
|
+
exports.getLngAndLat = async (ctx, _data) => {
|
|
330
335
|
const { app } = getAppByCtx(ctx)
|
|
331
336
|
|
|
332
|
-
const { longitude, latitude } = ctx.request.body
|
|
337
|
+
const { longitude, latitude } = _data || ctx.request.body
|
|
333
338
|
|
|
334
339
|
const appConfig = getConfig(app)
|
|
335
340
|
const { tencent_key } = await appConfig.getObject('map')
|
|
@@ -346,7 +351,8 @@ exports.getLngAndLat = async (ctx) => {
|
|
|
346
351
|
latitude,
|
|
347
352
|
})
|
|
348
353
|
|
|
349
|
-
|
|
354
|
+
ctx.SUCCESS(res)
|
|
355
|
+
return res
|
|
350
356
|
}
|
|
351
357
|
|
|
352
358
|
exports.syncModel = async (ctx) => {
|
|
@@ -48,7 +48,7 @@ module.exports = class Singleton {
|
|
|
48
48
|
.then((res) => res.data)
|
|
49
49
|
|
|
50
50
|
if (data.status === 0) return data.result
|
|
51
|
-
throw new Error(data.message)
|
|
51
|
+
throw new Error(`${this.key.split('-')[0]}${data.message}`)
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
async getToLngAndLat(name) {
|
|
@@ -61,7 +61,7 @@ module.exports = class Singleton {
|
|
|
61
61
|
if (data.message === '查询无结果') {
|
|
62
62
|
throw new Error(`找不到【${name}】,可能需要更详细一点(省市区)`)
|
|
63
63
|
} else {
|
|
64
|
-
throw new Error(data.message)
|
|
64
|
+
throw new Error(`${this.key.split('-')[0]}${data.message}`)
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|