guhongwei 4 rokov pred
rodič
commit
cc4530f088

+ 1 - 1
src/router/index.js

@@ -7,7 +7,7 @@ Vue.use(VueRouter);
 const routes = [
   // 首页
   {
-    path: '/home/index',
+    path: '/',
     name: '',
     meta: { title: '首页', isleftarrow: false },
     component: () => import('../views/home/index.vue'),

+ 2 - 0
src/store/index.js

@@ -5,6 +5,7 @@ import expertsuser from '@common/store/market/exportuser';
 import maarkettype from '@common/store/market/markettype';
 import authUser from './user/auth-user';
 import dock from '@common/store/live/dock';
+import wxchattest from './user/wxchattest';
 
 Vue.use(Vuex);
 
@@ -18,5 +19,6 @@ export default new Vuex.Store({
     maarkettype,
     authUser,
     dock,
+    wxchattest,
   },
 });

+ 23 - 0
src/store/user/wxchattest.js

@@ -0,0 +1,23 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  wxchattestInfo: `/api/auth/wxchattest`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async login({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.wxchattestInfo}`, payload);
+    return res;
+  },
+};
+
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 12 - 2
src/views/home/index.vue

@@ -20,6 +20,8 @@
 import { mapState, createNamespacedHelpers } from 'vuex';
 import NavBar from '@/layout/common/topInfo.vue';
 import footInfo from '@/layout/common/footInfo.vue';
+const { mapActions: wxchattest } = createNamespacedHelpers('wxchattest');
+
 export default {
   name: 'index',
   props: {},
@@ -40,8 +42,16 @@ export default {
       },
     };
   },
-  created() {},
-  methods: {},
+  created() {
+    this.toLogin();
+  },
+  methods: {
+    ...wxchattest(['login']),
+    async toLogin() {
+      let res = await this.login({ redirect_uri: 'http://localhost:8002/home/index', type: '0', openid: '00' });
+      console.log(res);
+    },
+  },
   computed: {
     // ...mapState(['user']),
   },

+ 6 - 1
vue.config.js

@@ -16,7 +16,7 @@ module.exports = {
     });
   },
   devServer: {
-    port: '8001',
+    port: '8002',
     //api地址前缀
     proxy: {
       '/weixin': {
@@ -31,6 +31,11 @@ module.exports = {
         target: 'http://free.liaoningdoupo.com',
         changeOrigin: true,
         ws: true,
+      },
+      '/wxtoken': {
+        target: 'http://free.liaoningdoupo.com',
+        changeOrigin: true,
+        ws: true,
         pathRewrite: {
           '^/wxtoken': 'http://localhost:8002',
         },