diff --git a/admin-web/src/utils/cache.js b/admin-web/src/utils/cache.js index b24074b6a..491830084 100644 --- a/admin-web/src/utils/cache.js +++ b/admin-web/src/utils/cache.js @@ -22,6 +22,8 @@ export function getLoginToken() { return res; } + + /// /// 设置 localStorage 公共方法 @@ -39,4 +41,12 @@ function getLocalStorage(key) { } catch (e) { throw new Error(`localStorage 获取错误! ${e}`); } +} + +function removeLocalStorage(key) { + try { + localStorage.removeItem(key); + } catch (e) { + throw new Error(`localStorage 设置错误! ${e}`); + } } \ No newline at end of file diff --git a/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/AdminApplication.java b/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/AdminApplication.java index 76f90ad1f..dbb7835ba 100644 --- a/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/AdminApplication.java +++ b/admin/admin-application/src/main/java/cn/iocoder/mall/admin/application/AdminApplication.java @@ -2,13 +2,19 @@ package cn.iocoder.mall.admin.application; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ConfigurableApplicationContext; @SpringBootApplication(scanBasePackages = {"cn.iocoder.mall.admin"}) //@EnableAdminServer public class AdminApplication { public static void main(String[] args) { - SpringApplication.run(AdminApplication.class, args); + ConfigurableApplicationContext ctx = SpringApplication.run(AdminApplication.class, args); +// Object bean = ctx.getBean("test"); +// System.out.println(AopUtils.getTargetClass(bean)); + +// System.out.println(bean); + // ConfigurableApplicationContext ctx = // System.out.println(); // TODO 后面去掉,这里是临时的 } diff --git a/admin/admin-service-impl/src/main/java/cn/iocoder/mall/admin/service/AdminServiceImpl.java b/admin/admin-service-impl/src/main/java/cn/iocoder/mall/admin/service/AdminServiceImpl.java index 7dca1ef26..1a3641226 100644 --- a/admin/admin-service-impl/src/main/java/cn/iocoder/mall/admin/service/AdminServiceImpl.java +++ b/admin/admin-service-impl/src/main/java/cn/iocoder/mall/admin/service/AdminServiceImpl.java @@ -28,7 +28,7 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; -@Service +@Service("test") @com.alibaba.dubbo.config.annotation.Service(validation = "true") public class AdminServiceImpl implements AdminService { diff --git a/mobile-web/src/api/user.js b/mobile-web/src/api/user.js index 78cfb1029..9105a0567 100644 --- a/mobile-web/src/api/user.js +++ b/mobile-web/src/api/user.js @@ -75,8 +75,15 @@ export function getUserInfo() { return request({ url: 'user-api/users/user/info', method: 'get', - headers: { - test: 1, + }); +} + +export function doUserUpdateNickname(nickname) { + return request({ + url: 'user-api/users/user/update_nickname', + method: 'post', + params: { + nickname, } }); } @@ -100,4 +107,5 @@ export function doPassportMobileSendRegisterCode(mobile) { mobile, } }); -} \ No newline at end of file +} + diff --git a/mobile-web/src/config/env.js b/mobile-web/src/config/env.js index 1ac66ee86..d7dc995c2 100644 --- a/mobile-web/src/config/env.js +++ b/mobile-web/src/config/env.js @@ -12,13 +12,13 @@ let dataSources='local';//local=本地,其他值代表非本地 if (process.env.NODE_ENV == 'development') { - baseUrl=''; - + baseUrl='http://127.0.0.1'; }else if(process.env.NODE_ENV == 'production'){ - baseUrl = ''; + baseUrl = 'http://http://180.167.213.26:18099'; } -baseUrl = 'http://127.0.0.1'; +// baseUrl = 'http://127.0.0.1'; +baseUrl = 'http://http://180.167.213.26:18099'; dataSources = 'remote'; // dataSources = 'local'; diff --git a/mobile-web/src/config/request.js b/mobile-web/src/config/request.js index ed8c6e2f9..0f79ec73f 100644 --- a/mobile-web/src/config/request.js +++ b/mobile-web/src/config/request.js @@ -2,6 +2,7 @@ import axios from 'axios' import {baseUrl, dataSources} from './env'; import datas from '../data/data'; import { getAccessToken } from '../utils/cache.js'; +import { Dialog } from 'vant'; const service = axios.create({ baseURL: baseUrl, // api 的 base_url @@ -45,7 +46,15 @@ service.interceptors.request.use( // config.headers['X-Token'] = getToken() // } - debugger; + // debugger; + let url = config.url; + // TODO 芋艿,这些 url 不用增加认证 token 。可能这么写,有点脏,后面看看咋优化下。 + if (url === 'user-api/users/passport/mobile/send_register_code' + || url === 'user-api/users/passport/mobile/register') { + return config; + } + + // debugger; if (getAccessToken()) { config.headers['Authorization'] = `Bearer ${getAccessToken()}`; } @@ -71,12 +80,9 @@ service.interceptors.response.use( response => { // debugger; const res = response.data; - if (res.code !== 0) { - // Message({ - // message: res.message, - // type: 'error', - // duration: 5 * 1000 - // }) + const code = res.code; + if (code !== 0) { + // // 50008:非法的token; 50012:其他客户端登录了; 50014:Token 过期了; // if (res.code === 50008 || res.code === 50012 || res.code === 50014) { // // 请自行在引入 MessageBox @@ -91,6 +97,32 @@ service.interceptors.response.use( // }) // }) // } + + + + // TODO token 过期 + // TODO 需要拿 refresh token 置换 + if (code === 1001001012) { + Dialog.confirm({ + title: '系统提示', + message: res.message, + confirmButtonText: '重新登陆', + beforeClose: function (action, done) { + done(); + if (action === 'confirm') { + // debugger; + // this.$router.push({ path: '/login' }) + // TODO 跳转到登陆页.不是很优雅 + location.replace('/#login'); + } + } + }); + } else { + Dialog.alert({ + title: '系统提示', + message: res.message, + }); + } console.log(1); return Promise.reject('error') } else { diff --git a/mobile-web/src/config/router.js b/mobile-web/src/config/router.js index 285fff4bb..df0b54a61 100644 --- a/mobile-web/src/config/router.js +++ b/mobile-web/src/config/router.js @@ -17,32 +17,32 @@ const routes = [ }, { path: '/login', - component: () => import('../page/account/login'), - meta: { - title: '登录' - } - }, - { - path: '/login/password', - component: () => import('../page/account/password'), - meta: { - title: '登录' - } - }, - { - path: '/login/phone', component: () => import('../page/account/phonelogin'), meta: { - title: '手机号登录' - } - }, - { - path: '/login/register', - component: () => import('../page/account/register'), - meta: { - title: '注册' + title: '登录' } }, + // { + // path: '/login/password', + // component: () => import('../page/account/password'), + // meta: { + // title: '登录' + // } + // }, + // { + // path: '/login/phone', + // component: () => import('../page/account/phonelogin'), + // meta: { + // title: '手机号登录' + // } + // }, + // { + // path: '/login/register', + // component: () => import('../page/account/register'), + // meta: { + // title: '注册' + // } + // }, { path: '/user/index', component: () => import('../page/user/index'), @@ -56,7 +56,7 @@ const routes = [ component: () => import('../page/user/info/detail'), name: 'user', meta: { - title: '账号管理' + title: '个人信息' } }, { diff --git a/mobile-web/src/main.js b/mobile-web/src/main.js index 924d33877..ff8d752cb 100644 --- a/mobile-web/src/main.js +++ b/mobile-web/src/main.js @@ -5,9 +5,12 @@ import './config/rem'; import App from './App.vue'; import VueLazyload from 'vue-lazyload' import components from './config/components.js'; +import { Dialog } from 'vant'; + Vue.use(components); -Vue.use(VueLazyload) +Vue.use(VueLazyload); +Vue.use(Dialog); new Vue({ router, diff --git a/mobile-web/src/page/account/phonelogin.vue b/mobile-web/src/page/account/phonelogin.vue index aedcce71e..866404bcf 100644 --- a/mobile-web/src/page/account/phonelogin.vue +++ b/mobile-web/src/page/account/phonelogin.vue @@ -1,31 +1,86 @@ diff --git a/mobile-web/src/page/product/detail.vue b/mobile-web/src/page/product/detail.vue index 7807772c3..c6664fe88 100644 --- a/mobile-web/src/page/product/detail.vue +++ b/mobile-web/src/page/product/detail.vue @@ -165,14 +165,14 @@ diff --git a/mobile-web/src/utils/cache.js b/mobile-web/src/utils/cache.js index b9539a17c..9f3830d09 100644 --- a/mobile-web/src/utils/cache.js +++ b/mobile-web/src/utils/cache.js @@ -22,6 +22,11 @@ export function getLoginToken() { return res; } +export function clearLoginToken() { + removeLocalStorage(cacheKeys.accessTokenKey); + removeLocalStorage(cacheKeys.refreshTokenKey); +} + export function getAccessToken() { return getLocalStorage(cacheKeys.accessTokenKey); } @@ -43,4 +48,12 @@ function getLocalStorage(key) { } catch (e) { throw new Error(`localStorage 获取错误! ${e}`); } +} + +function removeLocalStorage(key) { + try { + localStorage.removeItem(key); + } catch (e) { + throw new Error(`localStorage 设置错误! ${e}`); + } } \ No newline at end of file diff --git a/user/user-service-impl/src/main/resources/mapper/UserMapper.xml b/user/user-service-impl/src/main/resources/mapper/UserMapper.xml index 933694a89..688f60012 100644 --- a/user/user-service-impl/src/main/resources/mapper/UserMapper.xml +++ b/user/user-service-impl/src/main/resources/mapper/UserMapper.xml @@ -11,7 +11,7 @@ INSERT INTO users ( id, mobile, status, create_time, deleted ) VALUES ( - #{id}, #{mobile}, #{status} #{createTime}, #{deleted} + #{id}, #{mobile}, #{status}, #{createTime}, #{deleted} )