From 281e672aee3db7fbcfc5eb5f848923b012ccd3ae Mon Sep 17 00:00:00 2001 From: xjs Date: Mon, 3 Mar 2025 12:22:37 +0800 Subject: [PATCH] =?UTF-8?q?index=20on=20master:=20a53bb07=20feat:=20?= =?UTF-8?q?=E7=99=BB=E9=99=86=E6=8B=A6=E6=88=AA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc-auto-import.json | 4 +- env/.env | 2 +- src/components/bar/TabBar.vue | 2 +- src/components/home/Consultation.vue | 2 +- src/components/login/LoginMask.vue | 115 +++++++++++++++++++++++++++ src/hooks/useUserInfo.ts | 27 +++++++ src/manifest.json | 2 +- src/pages.json | 8 +- src/pages/evaluation/index/index.vue | 1 - src/pages/expert/index/index.vue | 2 +- src/pages/login/index.vue | 36 ++++++++- src/service/index/api.ts | 8 ++ src/types/auto-import.d.ts | 4 + 13 files changed, 199 insertions(+), 14 deletions(-) create mode 100644 src/components/login/LoginMask.vue create mode 100644 src/hooks/useUserInfo.ts diff --git a/.eslintrc-auto-import.json b/.eslintrc-auto-import.json index 3ea8661..e7f4e30 100644 --- a/.eslintrc-auto-import.json +++ b/.eslintrc-auto-import.json @@ -121,6 +121,8 @@ "newDetail": true, "newsDetail": true, "useNewsList": true, - "newsList": true + "newsList": true, + "useLogin": true, + "useWxInfo": true } } diff --git a/env/.env b/env/.env index d617cb2..7e90583 100644 --- a/env/.env +++ b/env/.env @@ -2,7 +2,7 @@ VITE_APP_TITLE = '六维志愿' VITE_APP_PORT = 9000 VITE_UNI_APPID = 'H57F2ACE4' -VITE_WX_APPID = 'wxa2abb91f64032a2b' +VITE_WX_APPID = '__UNI__7AE2402' # h5部署网站的base,配置到 manifest.config.ts 里的 h5.router.base VITE_APP_PUBLIC_BASE= diff --git a/src/components/bar/TabBar.vue b/src/components/bar/TabBar.vue index 2c8084a..22fcd2a 100644 --- a/src/components/bar/TabBar.vue +++ b/src/components/bar/TabBar.vue @@ -3,7 +3,7 @@ diff --git a/src/components/home/Consultation.vue b/src/components/home/Consultation.vue index 7b69e61..7a74e8d 100644 --- a/src/components/home/Consultation.vue +++ b/src/components/home/Consultation.vue @@ -18,7 +18,7 @@ class="truncate flex flex-col py-[32rpx]" style="border-bottom: 2rpx solid #eee" v-for="item in newsList" - :key="item" + :key="item.id" @click="handleClick(item)" > diff --git a/src/components/login/LoginMask.vue b/src/components/login/LoginMask.vue new file mode 100644 index 0000000..fa685c1 --- /dev/null +++ b/src/components/login/LoginMask.vue @@ -0,0 +1,115 @@ + + + + + diff --git a/src/hooks/useUserInfo.ts b/src/hooks/useUserInfo.ts new file mode 100644 index 0000000..41c27d0 --- /dev/null +++ b/src/hooks/useUserInfo.ts @@ -0,0 +1,27 @@ +import { getWxInfo } from '@/service/index/api' + +//uniapp 登陆获取用户信息 +export const useLogin = () => { + return new Promise(function (resolve, reject) { + uni.login({ + success: function (res) { + if (res.code) { + resolve(res) + } else { + reject(res) + } + }, + fail: function (err) { + reject(err) + }, + }) + }) +} + +export const useWxInfo = ({ code, OpenId }) => { + getWxInfo({ code, OpenId }).then((res) => { + if (res.code === 200) { + console.log(res.result) + } + }) +} diff --git a/src/manifest.json b/src/manifest.json index ec70944..3f4a4a7 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -55,7 +55,7 @@ }, "quickapp": {}, "mp-weixin": { - "appid": "wxa2abb91f64032a2b", + "appid": "__UNI__7AE2402", "setting": { "urlCheck": false }, diff --git a/src/pages.json b/src/pages.json index cd9feb4..9eb50af 100644 --- a/src/pages.json +++ b/src/pages.json @@ -60,7 +60,10 @@ { "path": "pages/login/index", "type": "page", - "style": {} + "style": { + "navigationStyle": "custom", + "navigationBarTitleText": "新高考选科" + } }, { "path": "pages/aiService/index/index", @@ -70,7 +73,6 @@ { "path": "pages/evaluation/index/index", "type": "page", - "layout": "demo", "style": { "navigationBarTitleText": "测评师" }, @@ -79,7 +81,7 @@ { "path": "pages/expert/index/index", "type": "page", - "layout": "demo", + "layout": "pages", "style": { "navigationBarTitleText": "测评师" }, diff --git a/src/pages/evaluation/index/index.vue b/src/pages/evaluation/index/index.vue index 4867d17..48e94c5 100644 --- a/src/pages/evaluation/index/index.vue +++ b/src/pages/evaluation/index/index.vue @@ -1,6 +1,5 @@ { - layout: 'demo', style: { navigationBarTitleText: '测评师', }, diff --git a/src/pages/expert/index/index.vue b/src/pages/expert/index/index.vue index 14c88b2..b1a6187 100644 --- a/src/pages/expert/index/index.vue +++ b/src/pages/expert/index/index.vue @@ -1,6 +1,6 @@ { - layout: 'demo', + layout: 'pages', style: { navigationBarTitleText: '测评师', }, diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue index fdc69c1..a086cf0 100644 --- a/src/pages/login/index.vue +++ b/src/pages/login/index.vue @@ -1,12 +1,40 @@ + +{ + style: { + navigationStyle: 'custom', + navigationBarTitleText: '新高考选科', + }, +} + + + + diff --git a/src/service/index/api.ts b/src/service/index/api.ts index 0b8105e..91c576f 100644 --- a/src/service/index/api.ts +++ b/src/service/index/api.ts @@ -64,3 +64,11 @@ export const getNewsList = (params: { }) => { return http.get('/api/ZyNews/newsPage', params) } + +export const getSessionKey = (params: { JsCode: string }) => { + return http.get('/api/sysWxOpen/wxOpenId', params) +} + +export const getWxInfo = (params: { code: string; OpenId: string }) => { + return http.get('/api/weChatUserEx/wxInfo', params) +} diff --git a/src/types/auto-import.d.ts b/src/types/auto-import.d.ts index d01f6fa..ec4b004 100644 --- a/src/types/auto-import.d.ts +++ b/src/types/auto-import.d.ts @@ -94,6 +94,7 @@ declare global { const useCssModule: typeof import('vue')['useCssModule'] const useCssVars: typeof import('vue')['useCssVars'] const useId: typeof import('vue')['useId'] + const useLogin: typeof import('../hooks/useUserInfo')['useLogin'] const useModel: typeof import('vue')['useModel'] const useNatureList: typeof import('../hooks/useFilterSchool')['useNatureList'] const useNavbarWeixin: typeof import('../hooks/useNavbarWeixin')['default'] @@ -109,6 +110,7 @@ declare global { const useUniversityType: typeof import('../hooks/useFilterSchool')['useUniversityType'] const useUpload: typeof import('../hooks/useUpload')['default'] const useUpload2: typeof import('../hooks/useUpload2')['default'] + const useWxInfo: typeof import('../hooks/useUserInfo')['useWxInfo'] const watch: typeof import('vue')['watch'] const watchEffect: typeof import('vue')['watchEffect'] const watchPostEffect: typeof import('vue')['watchPostEffect'] @@ -210,6 +212,7 @@ declare module 'vue' { readonly useCssModule: UnwrapRef readonly useCssVars: UnwrapRef readonly useId: UnwrapRef + readonly useLogin: UnwrapRef readonly useModel: UnwrapRef readonly useNatureList: UnwrapRef readonly useNavbarWeixin: UnwrapRef @@ -223,6 +226,7 @@ declare module 'vue' { readonly useUniversityRank: UnwrapRef readonly useUniversityType: UnwrapRef readonly useUpload: UnwrapRef + readonly useWxInfo: UnwrapRef readonly watch: UnwrapRef readonly watchEffect: UnwrapRef readonly watchPostEffect: UnwrapRef