张延森 2 年前
父节点
当前提交
4808264636
共有 5 个文件被更改,包括 15 次插入8 次删除
  1. 1
    1
      .env.production
  2. 4
    3
      src/pages/login.vue
  3. 2
    1
      src/router/index.js
  4. 7
    3
      src/utils/wx.js
  5. 1
    0
      vite.config.js

+ 1
- 1
.env.production 查看文件

@@ -1,2 +1,2 @@
1
-VITE_API_BASE=/api/h5
1
+VITE_API_BASE=http://invoice-filling.stategrid.njyunzhi.com/api/h5
2 2
 VITE_SECRET_KEY=5Io7jvsoRlZxa0vI5lIONlkUhajYaUGT

+ 4
- 3
src/pages/login.vue 查看文件

@@ -1,6 +1,6 @@
1 1
 <template>
2 2
   <div class="login-page">
3
-    <x-loading :show="true" />
3
+    <!-- <x-loading :show="true" /> -->
4 4
   </div>
5 5
 </template>
6 6
 
@@ -8,13 +8,14 @@
8 8
 import { onMounted } from 'vue';
9 9
 import { useRouter, useRoute } from 'vue-router'
10 10
 import { useModel } from '@zjxpcyc/vue-tiny-store'
11
-import { getRedirectURL } from '@/utils/wx';
11
+import { getRedirectURL, getCode } from '@/utils/wx';
12 12
 import { Notify } from 'vant';
13 13
 
14 14
 const { signIn } = useModel('user')
15 15
 const router = useRouter();
16 16
 const route = useRoute();
17
-let { code, from } = route.query;
17
+let { from } = route.query;
18
+let code = getCode();
18 19
 
19 20
 console.log(import.meta.env)
20 21
 if (import.meta.env.DEV) {

+ 2
- 1
src/router/index.js 查看文件

@@ -12,7 +12,8 @@ const routes = [
12 12
 ];
13 13
 
14 14
 const router = VueRouter.createRouter({
15
-  history: VueRouter.createWebHistory(),
15
+  // history: VueRouter.createWebHistory(import.meta.env.BASE_URL),
16
+  history: VueRouter.createWebHashHistory(),
16 17
   routes,
17 18
 })
18 19
 

+ 7
- 3
src/utils/wx.js 查看文件

@@ -23,8 +23,12 @@ export function getRedirectURL (force, code) {
23 23
 
24 24
   if (force || wxfirst || !code || code === originCode) {
25 25
     const origin = location.origin + location.pathname
26
-    const searchStr = location.search.replace(/code\=[^&]+/, '').replace(/state\=[^&]+/, '').replace(/^&+/, '').replace(/\?+$/, '')
27
-    const local = encodeURIComponent(origin + searchStr + location.hash)
28
-    return `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd3bab568bc42d1de&redirect_uri=${local}&response_type=code&scope=snsapi_base&state=123#wechat_redirect`
26
+    const searchStr = location.search.replace(/code\=[^&]+/, '').replace(/state\=[^&]+/, '').replace(/^&+/g, '').replace(/\?+$/, '')
27
+    const local = origin + searchStr + location.hash
28
+    console.log('--------------------->')
29
+    console.log(JSON.stringify(location))
30
+    console.log(local)
31
+    console.log('--------------------->')
32
+    return `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd3bab568bc42d1de&redirect_uri=${encodeURIComponent(local)}&response_type=code&scope=snsapi_base&state=123#wechat_redirect`
29 33
   }
30 34
 }

+ 1
- 0
vite.config.js 查看文件

@@ -6,6 +6,7 @@ import { VantResolver } from 'unplugin-vue-components/resolvers';
6 6
 
7 7
 // https://vitejs.dev/config/
8 8
 export default defineConfig({
9
+  base: '/state-grid/invoice-filling-h5/',
9 10
   server: {
10 11
     proxy: {
11 12
       '/api': {