guhongwei 4 år sedan
förälder
incheckning
b1458bd277
3 ändrade filer med 74 tillägg och 16 borttagningar
  1. 2 0
      src/store/index.js
  2. 39 0
      src/store/onlive/user.js
  3. 33 16
      src/views/live/parts/liveList.vue

+ 2 - 0
src/store/index.js

@@ -15,6 +15,7 @@ import expertsaudit from '@common/store/market/expertsaudit';
 import exportuser from '@common/store/market/exportuser';
 import user from './user';
 import place from './place';
+import onliveUser from './onlive/user';
 import * as ustate from '@/store/common/state';
 import * as umutations from '@/store/common/mutations';
 
@@ -41,5 +42,6 @@ export default new Vuex.Store({
     user,
     dock,
     place,
+    onliveUser,
   },
 });

+ 39 - 0
src/store/onlive/user.js

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

+ 33 - 16
src/views/live/parts/liveList.vue

@@ -6,10 +6,10 @@
           <el-col :span="18" class="left">
             <p class="textOver">{{ item.title }}</p>
             <p>
-              主讲人:<span>{{ item.user }}</span>
+              举办城市:<span>{{ item.province }}{{ item.places }}</span>
             </p>
             <p>
-              直播时间:<span>{{ item.date }}</span>
+              直播时间:<span>{{ item.start_time }}</span>
             </p>
           </el-col>
           <el-col :span="6" class="right">
@@ -23,28 +23,45 @@
 
 <script>
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: dock } = createNamespacedHelpers('dock');
+const { mapActions: place } = createNamespacedHelpers('place');
+
 export default {
   name: 'liveList',
   props: {},
   components: {},
   data: function() {
     return {
-      list: [
-        {
-          title: '标题',
-          user: '测试人员',
-          date: '2020-02-02',
-        },
-        {
-          title: '标题',
-          user: '测试人员',
-          date: '2020-02-02',
-        },
-      ],
+      list: [],
     };
   },
-  created() {},
-  methods: {},
+  created() {
+    this.searchInfo();
+  },
+  methods: {
+    ...dock({ dockQuery: 'query', palcefetch: 'fetch' }),
+    ...place({ palcequery: 'query', transactiondtetle: 'delete' }),
+    async searchInfo() {
+      let res = await this.dockQuery();
+      if (this.$checkRes(res)) {
+        for (const val of res.data) {
+          let parent = val.province;
+          let places = val.place;
+          let provinceInfo = await this.palcequery({ level: 1, parent });
+          let placesInfo = await this.palcequery({ level: 2, places });
+          var arr = provinceInfo.data.filter(item => item.code === parent);
+          var arrTwo = placesInfo.data.filter(item => item.code === places);
+          for (const province of arr) {
+            val.province = province.name;
+          }
+          for (const places of arrTwo) {
+            val.places = places.name;
+          }
+        }
+        this.$set(this, `list`, res.data);
+      }
+    },
+  },
   computed: {
     ...mapState(['user']),
     pageTitle() {