liuyu 4 anni fa
parent
commit
6d1915e08a
3 ha cambiato i file con 77 aggiunte e 0 eliminazioni
  1. 2 0
      src/store/index.js
  2. 48 0
      src/store/onlive/quest.js
  3. 27 0
      src/views/live/roomDetail.vue

+ 2 - 0
src/store/index.js

@@ -18,6 +18,7 @@ import place from './place';
 import onliveUser from './onlive/user';
 import gensign from './onlive/gensign';
 import room from './onlive/room';
+import quest from './onlive/quest';
 import chat from './chat';
 import * as ustate from '@/store/common/state';
 import * as umutations from '@/store/common/mutations';
@@ -49,5 +50,6 @@ export default new Vuex.Store({
     room,
     gensign,
     chat,
+    quest,
   },
 });

+ 48 - 0
src/store/onlive/quest.js

@@ -0,0 +1,48 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+import axios from 'axios';
+Vue.use(Vuex);
+const api = {
+  questinfo: `/api/onlive/questionnaire`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async questfetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.questinfo}/show/${payload}`);
+    return res;
+  },
+  async mergeRequest({ commit, dispatch }, { method, data }) {
+    let toRequest = () => {
+      let res = [];
+      for (const i of data) {
+        res.push(dispatch(method, i));
+      }
+      return res;
+    };
+    let result = await axios.all(toRequest());
+    let newFilter = data => {
+      let res = data.map(i => {
+        let type = _.isArray(i);
+        if (!type) {
+          //fetch的多个请求 是object 将errcode为0的data取出来
+          return _.get(i, `data`, i);
+        } else {
+          //query的多个请求 array 将此数据再次走这个方法
+          return newFilter(i);
+        }
+      });
+      return res;
+    };
+    let returns = _.flattenDeep(newFilter(result));
+    return returns;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 27 - 0
src/views/live/roomDetail.vue

@@ -105,6 +105,7 @@ Vue.use(VanImage);
 Vue.use(Lazyload);
 const { mapActions: gensign } = createNamespacedHelpers('gensign');
 const { mapActions: room } = createNamespacedHelpers('room');
+const { mapActions: quest } = createNamespacedHelpers('quest');
 const { mapActions: chat } = createNamespacedHelpers('chat');
 export default {
   name: 'roomsDetail',
@@ -138,6 +139,9 @@ export default {
       rvideoid_: '',
       userList: [],
       isxf: '',
+      showQuest: false,
+      queid: '',
+      questInfo: {},
     };
   },
   created() {
@@ -160,6 +164,7 @@ export default {
     ...gensign(['gensignFetch']),
     ...room(['lookuserFetch', 'fetch', 'lookusercount', 'lookquery', 'lookupdate', 'lookrecord']),
     ...chat(['query', 'create']),
+    ...quest(['questfetch']),
     async recordSave() {
       console.log(2121);
       let data = {};
@@ -217,6 +222,9 @@ export default {
       this.$stomp({
         [`/exchange/public_chat_` + this.id]: this.onMessage,
       });
+      this.$stomp({
+        [`/exchange/quest_publish_` + this.id]: this.onQueMessage,
+      });
     },
     onMessage(message) {
       // console.log('receive a message: ', message.body);
@@ -230,6 +238,25 @@ export default {
         document.getElementById('chatSell').scrollTop = document.getElementById('chatSell').scrollHeight + 275;
       });
     },
+    onQueMessage(message) {
+      // console.log('receive a message: ', message.body);
+      this.showQuest = true;
+      let body = _.get(message, 'body');
+      if (body) {
+        body = JSON.parse(body);
+        this.queid = body.queid;
+        this.questSearch();
+      }
+    },
+    async questSearch() {
+      if (this.queid) {
+        const result = await this.questfetch(this.queid);
+        if (this.$checkRes(result)) {
+          console.log(result.data);
+          this.$set(this, `questInfo`, result.data);
+        }
+      }
+    },
     async lookuserSearch() {
       if (this.user.uid) {
         let data = {};