From f7d384e55de7b5c965665a75a2c9c95fc56b63c8 Mon Sep 17 00:00:00 2001 From: sfmind Date: Sun, 1 May 2022 22:39:16 +0800 Subject: [PATCH] =?UTF-8?q?api=E6=8C=89=E6=A8=A1=E5=9D=97=E5=8D=95?= =?UTF-8?q?=E7=8B=AC=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-ui-app/api/address.js | 15 ++++++++++++ yudao-ui-app/api/auth.js | 12 ++++++++++ yudao-ui-app/api/index.js | 7 ++++++ yudao-ui-app/api/user.js | 14 +++++++++++ yudao-ui-app/common/api.js | 33 -------------------------- yudao-ui-app/pages/index/index.vue | 2 +- yudao-ui-app/pages/login/login.vue | 2 +- yudao-ui-app/pages/profile/profile.vue | 2 +- yudao-ui-app/pages/user/user.vue | 5 ++-- yudao-ui-app/store/index.js | 3 ++- 10 files changed, 55 insertions(+), 40 deletions(-) create mode 100644 yudao-ui-app/api/address.js create mode 100644 yudao-ui-app/api/auth.js create mode 100644 yudao-ui-app/api/index.js create mode 100644 yudao-ui-app/api/user.js delete mode 100644 yudao-ui-app/common/api.js diff --git a/yudao-ui-app/api/address.js b/yudao-ui-app/api/address.js new file mode 100644 index 0000000000..6f4297cd69 --- /dev/null +++ b/yudao-ui-app/api/address.js @@ -0,0 +1,15 @@ +//请求工具参考https://ext.dcloud.net.cn/plugin?id=392 +const { http } = uni.$u + +//获得用户收件地址列表 +export const getAddressList = params => http.get('/app-api/member/address/list', params) +//创建用户收件地址 +export const createAddress = data => http.post('/app-api/member/address/create', data) +//通过ID获得用户收件地址 +export const getAddressById = params => http.get('/app-api/member/address/get', { params }) +//获得默认的用户收件地址 +export const getDefaultUserAddress = params => http.get('/app-api/member/address/get-default', { params }) +//更新用户收件地址 +export const updateAddress = params => http.put('/app-api/member/address/update', params) +//删除用户收件地址 +export const deleteAddress = params => http.delete('/app-api/member/address/delete', {}, { params }) diff --git a/yudao-ui-app/api/auth.js b/yudao-ui-app/api/auth.js new file mode 100644 index 0000000000..8a49d2b21f --- /dev/null +++ b/yudao-ui-app/api/auth.js @@ -0,0 +1,12 @@ +//请求工具参考https://ext.dcloud.net.cn/plugin?id=392 +const { http } = uni.$u + +//使用手机 + 密码登录 +export const passwordLogin = data => http.post('/app-api/member/login', data) +//退出登录 +export const logout = data => http.post('/app-api/member/logout', data) +//发送手机验证码 +export const sendSmsCode = data => http.post('/app-api/member/send-sms-code', data) +//使用手机 + 验证码登录 +export const smsLogin = data => http.post('/app-api/member/sms-login', data) + diff --git a/yudao-ui-app/api/index.js b/yudao-ui-app/api/index.js new file mode 100644 index 0000000000..5bd7964a31 --- /dev/null +++ b/yudao-ui-app/api/index.js @@ -0,0 +1,7 @@ +//请求工具参考https://ext.dcloud.net.cn/plugin?id=392 +const { http } = uni.$u + +// 获取滚动图数据 +export const getBannerData = params => http.get('/app-api/index', { params }) +// 获取滚动通知数据 +export const getNoticeData = params => http.get('/app-api/notice', { params }) diff --git a/yudao-ui-app/api/user.js b/yudao-ui-app/api/user.js new file mode 100644 index 0000000000..4202fad29e --- /dev/null +++ b/yudao-ui-app/api/user.js @@ -0,0 +1,14 @@ +//请求工具参考https://ext.dcloud.net.cn/plugin?id=392 +const { http } = uni.$u + +//获取用户信息 +export const getUserInfo = params => http.get('/app-api/member/user/get', params) +//修改用户头像 +export const updateAvatar = filePath => + http.upload('/app-api/member/user/update-avatar', { + name: 'avatarFile', + fileType: 'image', + filePath: filePath + }) +//修改用户昵称 +export const updateNickname = params => http.put('/app-api/member/user/update-nickname', {}, { params }) diff --git a/yudao-ui-app/common/api.js b/yudao-ui-app/common/api.js deleted file mode 100644 index 307b37505d..0000000000 --- a/yudao-ui-app/common/api.js +++ /dev/null @@ -1,33 +0,0 @@ -//请求工具参考https://ext.dcloud.net.cn/plugin?id=392 -const { http } = uni.$u - -/* login */ -//使用手机 + 密码登录 -export const passwordLogin = params => http.post('/app-api/member/login', params) -//退出登录 -export const logout = params => http.post('/app-api/member/logout', params) -//发送手机验证码 -export const sendSmsCode = params => http.post('/app-api/member/send-sms-code', params) -//使用手机 + 验证码登录 -export const smsLogin = params => http.post('/app-api/member/sms-login', params) - -//获取用户信息 -export const getUserInfo = params => http.get('/app-api/member/user/get', params) -//修改用户头像 -export const updateAvatar = filePath => - http.upload('/app-api/member/user/update-avatar', { - name: 'avatarFile', - fileType: 'image', - filePath: filePath - }) -//修改用户昵称 -export const updateNickname = params => - http.put('/app-api/member/user/update-nickname', {}, { - params - }) - -/* index */ -// 获取滚动图数据 -export const getBannerData = params => http.get('/app-api/index', params) -// 获取滚动通知数据 -export const getNoticeData = params => http.get('/app-api/notice', params) diff --git a/yudao-ui-app/pages/index/index.vue b/yudao-ui-app/pages/index/index.vue index f0af9775e9..2937106480 100644 --- a/yudao-ui-app/pages/index/index.vue +++ b/yudao-ui-app/pages/index/index.vue @@ -109,7 +109,7 @@