diff --git a/src/libs/axios.js b/src/libs/axios.js index d7fc7af..e0163cb 100644 --- a/src/libs/axios.js +++ b/src/libs/axios.js @@ -9,16 +9,20 @@ const http = axios.create({ // 添加请求拦截器 http.interceptors.request.use((config) => { - const { customBaseURL } = config.params || {}; + const { customBaseURL } = config.params || config.data || {}; if (customBaseURL) { config.baseURL = customBaseURL; - delete config.params.customBaseURL; + if (config.params) { + delete config.params.customBaseURL; + } else if (config.data) { + delete config.data.customBaseURL; + } } else { config.baseURL = process.env.VUE_APP_URL; } const token = store.state.user?.userInfo?.token || ''; - config.headers['token'] = token + config.headers['token'] = token || "745f2b4c-49b7-4393-bf58-bc380a87149a"; config.headers['Content-Type'] = 'application/json;charset=UTF-8'; // 显示加载中状态(Element UI 的 Loading) diff --git a/src/libs/utils.js b/src/libs/utils.js index 19c5a2c..94ec3c9 100644 --- a/src/libs/utils.js +++ b/src/libs/utils.js @@ -62,7 +62,17 @@ export default { } else { return 'https://static.ticket.sz-trip.com' + img; } - } + }, + + imgToBase64(img) { + let reader = new FileReader(); + reader.readAsDataURL(img); + return new Promise((resolve, reject) => { + reader.onload = () => { + resolve(reader.result); + } + }); + }, } } } diff --git a/src/router/index.js b/src/router/index.js index 7241b3b..b713e35 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -172,6 +172,12 @@ const router = new Router({ meta: { title: '消息中心 - 精品商城', keepAlive: false }, component: () => import('@/views/User/MessageList.vue') }, + { + path: 'PurchaserAdd', + name: 'PurchaserAdd', + meta: { title: '添加采购单位信息 - 精品商城', keepAlive: false }, + component: () => import('@/views/User/PurchaserAdd.vue') + }, ], }, { @@ -186,12 +192,7 @@ const router = new Router({ meta: { title: '订单详情 - 精品商城', keepAlive: false }, component: () => import('@/views/Order/OrderDetail.vue') }, - { - path: '/PurchaserAdd', - name: 'PurchaserAdd', - meta: { title: '添加采购单位信息 - 精品商城', keepAlive: false }, - component: () => import('@/views/User/PurchaserAdd.vue') - }, + { path: '/OrderPay', name: 'OrderPay', diff --git a/src/views/User/Index.vue b/src/views/User/Index.vue index b6738dd..0f25887 100644 --- a/src/views/User/Index.vue +++ b/src/views/User/Index.vue @@ -30,7 +30,7 @@ export default { {title: '我的足迹',path:"/User/ViewHistory" }, {title: '消息中心',path:"/User/MessageList" }, {title: '个人信息',path:"/User/UserInfo" }, - {title: '账号设置',path:"" }, + {title: '采购人信息',path:"/User/PurchaserAdd" }, {title: '我的收货地址',path:"/User/UserAddress" } ] } diff --git a/src/views/User/MessageList.vue b/src/views/User/MessageList.vue index 7428177..20a6faf 100644 --- a/src/views/User/MessageList.vue +++ b/src/views/User/MessageList.vue @@ -5,11 +5,14 @@ -
+
{{ item.title }} - - {{ item.isExpanded? '收起 ^' : '展开 ∨' }} + + {{ item.isExpanded? '收起' : '展开' }} + + + {{ item.date }}
@@ -106,8 +109,7 @@ export default { + + + diff --git a/src/views/User/UserCenter.vue b/src/views/User/UserCenter.vue index 1ea915f..ff6bcad 100644 --- a/src/views/User/UserCenter.vue +++ b/src/views/User/UserCenter.vue @@ -14,30 +14,30 @@ -
+
{{ item.title }} 去设置 -
+
- +
个人信息
- + 编辑个人信息
@@ -108,9 +108,9 @@ export default { showNotice: true, userId: '200901071124', headFun: [ - {icon: "el-icon-location", title: "设置收货地址", path: ""}, - {icon: "el-icon-document", title: "设置发票抬头", path: ""}, - {icon: "el-icon-user", title: "设置采购人信息", path: ""}, + {icon: "el-icon-location", title: "设置收货地址", path: "/User/UserAddress"}, + {icon: "el-icon-document", title: "设置发票抬头", path: "/User/UserInvoice"}, + {icon: "el-icon-user", title: "设置采购人信息", path: "/User/PurchaserAdd"}, ], bargaining: [ {icon: "el-icon-time", title: "待回复", path: "", value: 2}, @@ -121,7 +121,9 @@ export default { {icon: "el-icon-time", title: "待付款", path: "", value: 2}, {icon: "el-icon-truck", title: "未发货", path: "", value: 2}, {icon: "el-icon-menu", title: "全部订单", path: "", value: 2}, - ] + ], + + userInfo: null, } @@ -129,10 +131,22 @@ export default { computed: { }, - created() { - + mounted() { + this.getUserInfo(); }, methods: { + getUserInfo() { + // 获取用户信息 + this.post({customBaseURL:"/api"},"/api/uservice/user/getMyInfo").then(res=>{ + this.userInfo = res.data; + console.log(this.userInfo) + }) + }, + + goPath(path) { + this.$router.push(path); + }, + // 复制用户ID copyId() { const input = document.createElement('input'); @@ -146,7 +160,7 @@ export default { message: 'ID已复制', type: 'success' }); - } + }, } } @@ -224,6 +238,7 @@ export default { border-radius: 50%; margin-right: 20px; border: 4px solid #f5f7fa; + object-fit: cover; } .user-details { diff --git a/src/views/User/UserInfo.vue b/src/views/User/UserInfo.vue index 34cecbc..5f15ca8 100644 --- a/src/views/User/UserInfo.vue +++ b/src/views/User/UserInfo.vue @@ -5,7 +5,7 @@ 个人信息
- + @@ -16,11 +16,11 @@ - + - + @@ -28,9 +28,9 @@ - 男性 - 女性 - 保密 + 男性 + 女性 + 保密 @@ -39,7 +39,7 @@ 保存 - 关闭 +
@@ -54,42 +54,63 @@ export default { return { user: { avatar: '', - nickname: '张三哥', - id: '209901071124', - gender: 'male', - birthday: '' + nickname: '', + id: '', + gender: null, + birthday: null, } } }, + mounted() { + this.getUserInfo(); + }, methods:{ + getUserInfo() { + // 获取用户信息 + this.post({customBaseURL:"/api"},"/api/uservice/user/getMyInfo").then(res=>{ + this.user = res.data; + }) + }, + handleAvatarChange(file) { - this.user.avatar = URL.createObjectURL(file.raw); - }, - copyId() { - const input = document.createElement('input'); - input.value = this.user.id; - document.body.appendChild(input); - input.select(); - document.execCommand('copy'); - document.body.removeChild(input); - this.$message({ - message: '用户ID已复制', - type: 'success' - }); - }, - saveUser() { - this.$message({ - message: '保存成功', - type: 'success' - }); - }, - close() { - this.$message({ - message: '已关闭', - type: 'info' - }); + // this.user.avatar = URL.createObjectURL(file.raw); + + this.util.imgToBase64(file.raw).then(base64 => { + console.log(base64); + this.post({ + customBaseURL:"/api", + img_base64: base64 + }, "/api/pbservice/Other/base64Upload").then(res=>{ + this.user.avatar = res.data.url; + }) + }) + + }, + copyId() { + const input = document.createElement('input'); + input.value = this.user.id; + document.body.appendChild(input); + input.select(); + document.execCommand('copy'); + document.body.removeChild(input); + this.$message({ + message: '用户ID已复制', + type: 'success' + }); + }, + saveUser() { + this.$refs.userForm.validate((valid)=>{ + if(valid){ + this.post({customBaseURL:"/api",...this.user},"/api/uservice/user/profile").then(res=>{ + if (res.code == 1) { + this.$message({ message: '修改成功', type:'success'}); + } + }) } - } + }) + }, + + } } diff --git a/vue.config.js b/vue.config.js index fe86d76..571b4c1 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,5 +1,16 @@ const { defineConfig } = require('@vue/cli-service') module.exports = defineConfig({ transpileDependencies: true, - runtimeCompiler: true + runtimeCompiler: true, + devServer: { + proxy: { + '/api':{ + target: "https://swsz.api.js-dyyj.com", + changeOrigin: true, + pathRewrite: { + '/api':'' + }, + } + } + } })