feat 微信获取OpenId

This commit is contained in:
DaxPay
2024-09-25 18:59:06 +08:00
parent d49572f94c
commit 3b2ac73eb6
7 changed files with 74 additions and 11 deletions

View File

@@ -5,7 +5,7 @@ VITE_PORT=9100
VITE_PUBLIC_PATH=/
# 跨域代理,可以配置多个,请注意不要换行
VITE_PROXY=[["/server","http://localhost:9000"]]
VITE_PROXY=[["/server","http://localhost:10880"]]
# API 接口地址
VITE_GLOB_API_URL=

View File

@@ -1,5 +1,5 @@
# 独立部署模式
VITE_PUBLIC_PATH = /h5
VITE_PUBLIC_PATH = /
# API 接口前缀
VITE_GLOB_API_URL_PREFIX = /api

View File

@@ -57,5 +57,13 @@ export default antfu({
'node/prefer-global/process': 'off',
// 对所有控制语句强制执行一致的大括号样式只有一行的时候eslint默认是不需要大括号的这样会降低代码清晰度
'curly': ['error', 'all'],
// 'indent': 'off',
// 'vue/script-indent': [
// 'error',
// 2,
// {
// baseIndent: 1,
// },
// ],
},
})

View File

@@ -1,6 +1,6 @@
import type { App } from 'vue'
import type { RouteRecordRaw } from 'vue-router'
import { createRouter, createWebHashHistory } from 'vue-router'
import { createRouter, createWebHashHistory, createWebHistory } from "vue-router";
import { createRouterGuards } from './router-guards'
import { ErrorPageRoute, routeModuleList } from '@/router/base'
import { useRouteStoreWidthOut } from '@/store/modules/route'
@@ -24,7 +24,8 @@ routeStore.setMenus(routeModuleList)
routeStore.setRouters(constantRouter.concat(routeModuleList))
const router = createRouter({
history: createWebHashHistory(''),
// 重定向时hash模式可能无法跳转需要使用history模式
history: createWebHistory(''),
routes: constantRouter.concat(...routeModuleList),
strict: true,
scrollBehavior: () => ({ left: 0, top: 0 }),

View File

@@ -0,0 +1,28 @@
import { http } from '@/utils/http/axios'
import type { Result } from '#/axios'
/**
* 通过AuthCode获取并设置认证结果
* @param param
*/
export function authAndSet(param: AuthCodeParam) {
return http.request<Result>({
url: '/unipay/assist/channel/auth/authAndSet',
method: 'POST',
data: param,
})
}
/**
* 通道认证参数
*/
export interface AuthCodeParam {
// 通道
channel?: string
// 标识码
authCode?: string
// 查询Code
queryCode?: string
// 应用号
appId?: string
}

View File

@@ -1,5 +1,6 @@
<template>
<div>
获取中
</div>
</template>
@@ -7,6 +8,7 @@
import { useRoute } from 'vue-router'
const route = useRoute()
const {appId, channel, queryCode, aliAppId} = route.params
console.log(appId, channel)

View File

@@ -1,13 +1,37 @@
<script setup lang="ts">
</script>
<template>
const {appId, channel,queryCode} = route.params
console.log(appId, channel)
<div />
</template>
<script setup lang="ts">
import { useRoute } from 'vue-router'
import { ref } from 'vue'
import type { AuthCodeParam } from '@/views/daxpay/channel/ChannelAuth.api'
import { authAndSet } from '@/views/daxpay/channel/ChannelAuth.api'
const route = useRoute()
const { appId, channel, queryCode } = route.params
const { code } = route.query
const param = ref<AuthCodeParam>({
appId: appId as string,
queryCode: queryCode as string,
authCode: code as string,
channel: channel as string,
})
onMounted(() => {
init()
})
/**
* 页面初始化
*/
async function init() {
authAndSet(param.value).then((res) => {
console.log(res)
})
}
</script>
<style scoped lang="less">
</style>