diff --git a/src/api/upload.js b/src/api/upload.js index bf8ca44..4ede09b 100644 --- a/src/api/upload.js +++ b/src/api/upload.js @@ -12,9 +12,5 @@ export function fileUpload(data) { } export function base64uploadFile(data) { - return request({ - url: '/common/base64uploadFile', - method: 'post', - data - }) + return request.formDataPost('/common/base64uploadFile', data) } diff --git a/src/api/user.js b/src/api/user.js index 22e990e..aea6da9 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -29,3 +29,7 @@ export function setRegistry(data) { data }) } + +export function uploadAvatar(data) { + return request.formDataPost('/user/uploadAvatar', data) +} diff --git a/src/main.js b/src/main.js index 699bd5e..38f57c3 100644 --- a/src/main.js +++ b/src/main.js @@ -25,8 +25,8 @@ Vue.use(filters) // mock in online if (process.env.NODE_ENV === 'production') { - const { mockXHR } = require('../mock') - mockXHR() + // const { mockXHR } = require('../mock') + // mockXHR() } Vue.config.productionTip = false diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 1c5fa33..62c9608 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -70,7 +70,6 @@ const actions = { }) }) }, - // 重置token resetToken({ commit }) { return new Promise(resolve => { diff --git a/src/utils/request.js b/src/utils/request.js index 49e93cf..b516628 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,4 +1,5 @@ import axios from 'axios' +import qs from 'qs' import { Toast, Dialog } from 'vant' import store from '@/store' import { getToken } from '@/utils/auth' @@ -56,4 +57,20 @@ service.interceptors.response.use( } ) +/** + * 使用 application/x-www-form-urlencoded format + * @param {*} url + * @param {*} postData + * @returns + */ +service.formDataPost = function(url, postData) { + const options = { + method: 'POST', + headers: { 'content-type': 'application/x-www-form-urlencoded' }, + data: qs.stringify(postData), + url + } + return service(options) +} + export default service diff --git a/src/views/userSetting/index.vue b/src/views/userSetting/index.vue index ff7b996..27ffd69 100644 --- a/src/views/userSetting/index.vue +++ b/src/views/userSetting/index.vue @@ -5,26 +5,49 @@
- 你的头像 + 你的头像
- - + + + + - +