feat(M03-C): 完成地图选店与距离排序
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
const { APP_API_BASE_URL, WECHAT_APP_ID } = require('../config/env.js')
|
||||
|
||||
function request(path, options = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.request({
|
||||
url: `${APP_API_BASE_URL}${path}`,
|
||||
method: options.method || 'GET',
|
||||
data: options.data,
|
||||
header: {
|
||||
'x-wechat-appid': WECHAT_APP_ID,
|
||||
...(options.headers || {}),
|
||||
},
|
||||
success(response) {
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
resolve(response.data)
|
||||
return
|
||||
}
|
||||
reject(new Error(response.data?.message || `请求失败:${response.statusCode}`))
|
||||
},
|
||||
fail: reject,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { request }
|
||||
Reference in New Issue
Block a user