diff --git a/.env b/.env index 01cbb6c..5d59f08 100644 --- a/.env +++ b/.env @@ -1,7 +1,6 @@ # ******************** start 开发环境 start ******************** -#VITE_APP_DEV_SERVICE =http://localhost:48080/app-api -VITE_APP_DEV_SERVICE =https://stgl.pj.gov.cn/app-api +VITE_APP_DEV_SERVICE =http://localhost:48080/app-api # VITE_APP_DEV_SERVICE =http://123.156.228.134:48080/app-api # ******************** end 开发环境 end ******************** diff --git a/src/pages.json b/src/pages.json index 3ecde96..a4cd9b1 100644 --- a/src/pages.json +++ b/src/pages.json @@ -178,6 +178,18 @@ } ] }, + { + "root": "pages/test", + "pages": [ + { + "path": "login", + "style": { + "navigationBarTitleText": "", + "disableScroll": true + } + } + ] + }, { "root": "pages/wallet", "pages": [ diff --git a/src/pages/tabbar/my.vue b/src/pages/tabbar/my.vue index 74f845a..e9c5733 100644 --- a/src/pages/tabbar/my.vue +++ b/src/pages/tabbar/my.vue @@ -13,6 +13,7 @@ const data = { // { text: '车牌管理', icon: '/static/icon/service_2.png', router: '/pages/user/diff-price' }, { text: '外来人员就餐', icon: '/static/icon/service_1.png', router: '/pages/apply/foreign-list' }, { text: '跨单位就餐', icon: '/static/icon/service_1.png', router: '/pages/apply/stride-list' }, + { text: '测试登陆', icon: '/static/icon/login.png', router: '/pages/test/login' }, ] }; @@ -23,29 +24,29 @@ const state = reactive({ onLoad((options) => { - window.CP2.getAppInfo().then((res) => { - console.log(res); - if (res.code==1){ - //诗画 - console.log("诗画环境") - window.CP2.getUserInfo().then((res) => { - let accountId=res.data.accountId; - let sessionId=res.sessionId; - doLogin(1,null,accountId,sessionId) - }); - }else { - //浙政钉或者h5 - const url = window.location.href; - const params = new URL(url).searchParams; - const token = params.get('uabaseToken'); // 获取 uabaseToken 参数值 - console.log('Token:', token); - if (null!=token){ - //浙政钉 - doLogin(2,token,null,null) - } + (window as any).CP2.getAppInfo().then((res) => { + console.log(res); + if (res.code == 1) { + //诗画 + console.log("诗画环境"); + (window as any).CP2.getUserInfo().then((res) => { + let accountId = res.data.accountId; + let sessionId = res.sessionId; + doLogin(1, null, accountId, sessionId) + }); + } else { + //浙政钉或者h5 + const url = window.location.href; + const params = new URL(url).searchParams; + const token = params.get('uabaseToken'); // 获取 uabaseToken 参数值 + console.log('Token:', token); + if (null != token) { + //浙政钉 + doLogin(2, token, null, null) + } - } - }); + } + }); }); onShow(() => { getUserInfo() @@ -59,7 +60,7 @@ const getUserInfo = () => { } } -const doLogin = async (loginType,token, accountId, sessionId) => { +const doLogin = async (loginType, token, accountId, sessionId) => { const tokenKey = constant.storageConstant.TOKEN const userInfoKey = constant.storageConstant.USERINFO const tokenStorage = uni.getStorageSync(tokenKey) @@ -70,20 +71,20 @@ const doLogin = async (loginType,token, accountId, sessionId) => { mask: true }); let authData; - if (loginType==1){ - // 诗画 - const params = { - accountId:accountId, - sessionId:sessionId - } - const response = await userApi.authsh(params); - authData = response.data; - }else if (loginType==2){ - //浙政钉 - const response = await userApi.auth(token); - authData = response.data; - }else { - //后期手机号+验证码登录 + if (loginType == 1) { + // 诗画 + const params = { + accountId: accountId, + sessionId: sessionId + } + const response = await userApi.authsh(params); + authData = response.data; + } else if (loginType == 2) { + //浙政钉 + const response = await userApi.auth(token); + authData = response.data; + } else { + //后期手机号+验证码登录 } // const {data: authData} = await userApi.auth(token); uni.setStorageSync(tokenKey, authData) diff --git a/src/pages/test/login.vue b/src/pages/test/login.vue new file mode 100644 index 0000000..f692028 --- /dev/null +++ b/src/pages/test/login.vue @@ -0,0 +1,89 @@ + + + + + + \ No newline at end of file diff --git a/src/sheep/api/user.ts b/src/sheep/api/user.ts index ce770b1..5889116 100644 --- a/src/sheep/api/user.ts +++ b/src/sheep/api/user.ts @@ -20,16 +20,16 @@ export default { loadingMsg: "授权中", }, }), - authsh: (params: any) => - request({ - url: `/sys/auth/shjnsso`, - method: "POST", - custom: { - showLoading: false, - loadingMsg: "授权中", - }, - data:params, - }), + authsh: (params: any) => + request({ + url: `/sys/auth/shjnsso`, + method: "POST", + custom: { + showLoading: false, + loadingMsg: "授权中", + }, + data: params, + }), refreshToken: (params: any) => request({ url: `/sys/auth/refresh-token`, @@ -39,4 +39,13 @@ export default { showLoading: false, }, }), + testLogin: (data: any) => + request({ + url: `/sys/auth/test-login`, + method: "POST", + data, + custom: { + showLoading: false, + }, + }), }; diff --git a/src/static/icon/login.png b/src/static/icon/login.png new file mode 100644 index 0000000..2265310 Binary files /dev/null and b/src/static/icon/login.png differ