张延森 2 years ago
parent
commit
4808264636
5 changed files with 15 additions and 8 deletions
  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 View File

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

+ 4
- 3
src/pages/login.vue View File

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

+ 2
- 1
src/router/index.js View File

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

+ 7
- 3
src/utils/wx.js View File

23
 
23
 
24
   if (force || wxfirst || !code || code === originCode) {
24
   if (force || wxfirst || !code || code === originCode) {
25
     const origin = location.origin + location.pathname
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 View File

6
 
6
 
7
 // https://vitejs.dev/config/
7
 // https://vitejs.dev/config/
8
 export default defineConfig({
8
 export default defineConfig({
9
+  base: '/state-grid/invoice-filling-h5/',
9
   server: {
10
   server: {
10
     proxy: {
11
     proxy: {
11
       '/api': {
12
       '/api': {