feat: 扫描登陆

master
xjs 2025-06-30 17:44:48 +08:00
parent 37c66c6919
commit 4be7560d81
6 changed files with 110 additions and 2 deletions

View File

@ -161,6 +161,13 @@ onLoad((options) => {
addWishList() addWishList()
} }
}) })
onUnload(() => {
if (typeName === '一键填报') {
userStore.clearWishList()
userStore.clearWishListId()
}
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -58,6 +58,14 @@
"enableShareTimeline": true "enableShareTimeline": true
} }
}, },
{
"path": "pages/index/index",
"type": "page",
"style": {
"navigationBarTitleText": "授权登录"
},
"needLogin": true
},
{ {
"path": "pages/evaluation/index/index", "path": "pages/evaluation/index/index",
"type": "page", "type": "page",

68
src/pages/index/index.vue Normal file
View File

@ -0,0 +1,68 @@
<route lang="json5" type="page">
{
style: {
navigationBarTitleText: '授权登录',
},
needLogin: true,
}
</route>
<template>
<view class="flex flex-col items-center">
<image
class="w-[440rpx] h-[440rpx] mt-[136rpx]"
src="https://api.static.ycymedu.com/images/logo.png"
mode="aspectFit"
></image>
<button
class="w-[493rpx]! mb-[40rpx] h-[88rpx]! rounded-[44rpx] text-[32rpx] text-white flex items-center justify-center bg-[#1580FF]"
@click="handleAuthPage"
>
授权网页登录
</button>
<button class="text-[#A2A2A2] bg-[#fff] text-[32rpx]" @click="handleCancel"></button>
</view>
</template>
<script lang="ts" setup>
import { authQrCode } from '@/service/index/api'
import { useUserStore } from '@/store/user'
const userStore = useUserStore()
let scene = ''
const handleCancel = () => {
uni.switchTab({ url: '/pages/home/index/index' })
}
const handleAuthPage = () => {
authQrCode({
userCode: scene,
messageType: 2,
weChat: { openId: userStore.userInfo.openid, sessionKey: '', unionId: '' },
}).then((resp) => {
if (resp.code == 200) {
uni.showToast({
title: '授权成功',
icon: 'none',
mask: true,
})
uni.reLaunch({
url: '/pages/home/index/index',
})
} else {
uni.showToast({
title: '二维码失效,请刷新后重试',
icon: 'none',
mask: true,
})
}
})
}
onLoad((options) => {
scene = options.scene || ''
})
</script>

View File

@ -482,3 +482,28 @@ export const verifyInviteCode = ({ code }: { code: string }) => {
export const getADBanner = ({ code }: { code: string } = { code: 'b001' }) => { export const getADBanner = ({ code }: { code: string } = { code: 'b001' }) => {
return http.get('/api/zhiYuan/banner', { code }) return http.get('/api/zhiYuan/banner', { code })
} }
export const authQrCode = ({
userCode,
messageType,
weChat,
}: {
userCode: string
messageType: number
weChat: {
openId: string
sessionKey: string
unionId: string
}
}) => {
return http.post(
'https://api.sso.ycymedu.com/api/syswxopen/hookscuess',
{
userCode: userCode,
messageType,
weChat,
tpkey: '9k1cbc3f546eda35168c3aa3cb91780fbe703f0996c6d123ea96dc85c70bbc0a',
},
{ hasPrefix: true },
)
}

View File

@ -5,6 +5,7 @@
interface NavigateToOptions { interface NavigateToOptions {
url: "/pages/home/index/index" | url: "/pages/home/index/index" |
"/pages/index/index" |
"/pages/evaluation/index/index" | "/pages/evaluation/index/index" |
"/pages/expert/index/index" | "/pages/expert/index/index" |
"/pages/ucenter/index/index" | "/pages/ucenter/index/index" |

View File

@ -6,8 +6,7 @@ export const http = <T>(options: CustomRequestOptions) => {
return new Promise<IResData<T>>((resolve, reject) => { return new Promise<IResData<T>>((resolve, reject) => {
if (options.query?.staticType === 'static') { if (options.query?.staticType === 'static') {
options.url = `${staticBaseUrl}${options.url}` options.url = `${staticBaseUrl}${options.url}`
} else if (options.query?.haPrefix) { } else if (options.query?.hasPrefix) {
console.log(options.query)
} else { } else {
options.url = `${baseUrl}${options.url}` options.url = `${baseUrl}${options.url}`
} }