guhongwei 4 lat temu
rodzic
commit
4924c1eaf1
3 zmienionych plików z 77 dodań i 56 usunięć
  1. 2 0
      src/store/index.js
  2. 48 0
      src/store/user/user.js
  3. 27 56
      src/views/supermaket/supermarket.vue

+ 2 - 0
src/store/index.js

@@ -27,6 +27,7 @@ import apply from './apply';
 import talentExperts from './talentExperts';
 import room from './room';
 import login from '@common/store/login';
+import user from './user/user';
 
 import * as ustate from '@common/store/user/state';
 import * as umutations from '@common/store/user/mutations';
@@ -65,6 +66,7 @@ export default new Vuex.Store({
     login,
     personalchat,
     personalroom,
+    user,
   },
   state: { ...ustate },
   mutations: { ...umutations },

+ 48 - 0
src/store/user/user.js

@@ -0,0 +1,48 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  interface: `/api/market/user`,
+  userinterface: `/api/market/user/hwsxg`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit = undefined, ...info } = {}) {
+    const res = await this.$axios.$get(api.interface, { skip, limit, ...info });
+    return res;
+  },
+  async userquery({ commit }, { skip = 0, limit = undefined, ...info } = {}) {
+    const res = await this.$axios.$get(api.userinterface, {
+      skip,
+      limit,
+      ...info,
+    });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.interface}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.interface}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...info } = {}) {
+    const res = await this.$axios.$post(`${api.interface}/${id}`, { ...info });
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.interface}/${payload}`);
+    return res;
+  },
+};
+
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 27 - 56
src/views/supermaket/supermarket.vue

@@ -30,8 +30,7 @@
 import supermarketDetail from '@/components/supermaket/supermarket.vue';
 import { createNamespacedHelpers, mapGetters, mapState } from 'vuex';
 const { mapActions: mapSite } = createNamespacedHelpers('site');
-const { mapActions: mapProduct } = createNamespacedHelpers('enterpriseproject');
-const { mapActions: transaction } = createNamespacedHelpers('transaction');
+const { mapActions: user } = createNamespacedHelpers('user');
 // 获取学校
 import { school } from '@/util/school';
 export default {
@@ -41,6 +40,7 @@ export default {
     supermarketDetail,
   },
   data: () => ({
+    // 站点信息
     info: {},
     nativeList: [
       {
@@ -72,6 +72,21 @@ export default {
       },
     ],
     display: 'first',
+    // 高校院所
+    schoolList: school,
+    schoolTotal: 76,
+    // 科研院所
+    scientificList: [
+      {
+        pic: require('@/assets/fabu.jpg'),
+        title: '科研院所',
+        com: 'www.baidu.com',
+        type: '二级本科',
+        address: '吉林省长春市力旺广场B座16楼',
+      },
+    ],
+    scientificTotal: 1,
+
     // 技术型
     jishuList: [],
     // 技术型分页
@@ -111,20 +126,6 @@ export default {
         deal: '交易完成',
       },
     ],
-    // 高校院所
-    schoolList: school,
-    schoolTotal: 76,
-    // 科研院所
-    scientificList: [
-      {
-        pic: require('@/assets/fabu.jpg'),
-        title: '科研院所',
-        com: 'www.baidu.com',
-        type: '二级本科',
-        address: '吉林省长春市力旺广场B座16楼',
-      },
-    ],
-    scientificTotal: 1,
     // 科技企业
     companyList: [
       {
@@ -150,59 +151,29 @@ export default {
     ],
     mechanismTotal: 1,
   }),
-  created() {
-    console.log(school);
-    this.searchSite();
-    this.searchInfo();
-    this.jiaoyilist();
+  async created() {
+    await this.search();
+    await this.searchList();
   },
   computed: {
     ...mapState(['user']),
   },
   methods: {
     ...mapSite(['showInfo']),
-    ...mapProduct({ ProductQuery: 'query', ProductFetch: 'fetch', ProductDelete: 'delete' }),
-    ...transaction({ transactionQuery: 'query', ProductFetch: 'fetch', ProductDelete: 'delete' }),
-
+    ...user({ userQuery: 'query' }),
     // 查询站点信息
-    async searchSite() {
+    async search() {
       let res = await this.showInfo();
       let object = JSON.parse(JSON.stringify(res.data));
       if (object) {
         this.$set(this, `info`, res.data);
-      } else {
-        this.$message.error(res.errmsg ? res.errmsg : 'error');
-      }
-    },
-    async searchInfo({ skip = 0, limit = 8, ...info } = {}) {
-      const res = await this.ProductQuery({ skip, limit, ...info });
-      for (const val of res.data) {
-        if (val.totaltype === '0') {
-          var arr = res.data.filter(item => item.totaltype === '0');
-          this.$set(this, `jishuList`, arr);
-          this.$set(this, `jishuTotal`, arr.length);
-        } else if (val.totaltype === '1') {
-          var arrs = res.data.filter(item => item.totaltype === '1');
-          this.$set(this, `chanpinList`, arrs);
-          this.$set(this, `chanpinTotal`, arrs.length);
-        } else if (val.totaltype === '2') {
-          var arrss = res.data.filter(item => item.totaltype === '2');
-          this.$set(this, `serviceList`, arrss);
-          this.$set(this, `serveTotal`, arrss.length);
-        }
-      }
-    },
-    //交易
-    async jiaoyilist() {
-      const res = await this.transactionQuery();
-      this.$set(this, `tableData`, res.data);
-    },
-    fabu() {
-      console.log('闹');
-      if (this.user.role == '2' || this.user.role == '3') {
-        this.$router.push({ path: '/enterprise/enterprisexuqiu' });
       }
     },
+    // 查询列表
+    searchList() {},
+    // 发布
+    fabu() {},
+    // 跳转
     async nativeClick({ name }) {
       if (name === '高校院所') {
         this.display = 'second';