浏览代码

Merge branch 'master' of http://git.cc-lotus.info/service-platform/web-website

reloaded 5 年之前
父节点
当前提交
a40be56075
共有 3 个文件被更改,包括 149 次插入121 次删除
  1. 12 1
      src/layout/enterprise/contextxx.vue
  2. 19 2
      src/layout/enterprise/parts/chat.vue
  3. 118 118
      src/router/index.js

+ 12 - 1
src/layout/enterprise/contextxx.vue

@@ -4,7 +4,7 @@
       <rooms :list="list" @toChat="toChat"></rooms>
     </template>
     <template v-else>
-      <chat :room="room"></chat>
+      <chat :room="room" @toRoom="view = 'room'"></chat>
     </template>
   </div>
 </template>
@@ -28,6 +28,9 @@ export default {
   created() {
     this.search();
   },
+  mounted() {
+    this.channel();
+  },
   methods: {
     ...mapActions(['query', 'fetch']),
     async search() {
@@ -41,6 +44,14 @@ export default {
         this.view = 'chat';
       }
     },
+    channel() {
+      this.$stomp({
+        [`/exchange/chat_message/${this.user.uid}`]: this.onMessage,
+      });
+    },
+    onMessage(message) {
+      console.log(message);
+    },
   },
   computed: {
     ...mapState(['user']),

+ 19 - 2
src/layout/enterprise/parts/chat.vue

@@ -1,6 +1,9 @@
 <template>
   <div id="chats">
     <el-row :span="24" class="chat">
+      <el-col :span="24" style="padding-bottom:5px">
+        <el-button size="mini" @click="$emit('toRoom')" icon="el-icon-arrow-left" type="primary">返回</el-button>
+      </el-col>
       <el-col :span="24" class="chatInfo" id="chatBorder" ref="chatBorder">
         <template v-for="(i, index) in talk">
           <template v-if="isSender(i)">
@@ -22,6 +25,7 @@
 </template>
 
 <script>
+import _ from 'lodash';
 import { mapState, createNamespacedHelpers } from 'vuex';
 import wangEditor from '@/components/wang-editor.vue';
 const { mapActions: personalChat } = createNamespacedHelpers('personalchat');
@@ -56,7 +60,7 @@ export default {
       if (this.content != '') {
         let obj = { personroom_id: this.room.id, content: this.content, sender_id: this.user.uid, sender_name: this.user.name, send_time: '13:00' };
         let keys = Object.keys(this.room);
-        let fres = keys.filter(f => this.room[f] == this.user.uid);
+        let fres = keys.find(f => this.room[f] == this.user.uid);
         obj.receiver_id = fres === 'buyer_id' ? this.room['seller_id'] : this.room['buyer_id'];
         obj.receiver_name = fres === 'buyer_id' ? this.room['seller_name'] : this.room['buyer_name'];
         let res = await this.create(obj);
@@ -64,6 +68,7 @@ export default {
         this.$set(this, `content`, '');
         this.$forceUpdate();
         if (this.$checkRes(res, null, res.errmsg || '发言失败')) {
+          console.log(`in zhong tai chat`);
           this.talk.push(res.data);
           this.turnBottom();
         }
@@ -83,10 +88,22 @@ export default {
         console.warn('未获取到房间id,无法进行订阅');
         return;
       }
+      console.log(`this.user.uid`);
+      console.log(this.user.uid);
+      console.log(`${this.room.id}_${this.user.uid}`);
       this.$stomp({
         [`/exchange/person_chat/${this.room.id}_${this.user.uid}`]: this.onMessage,
       });
     },
+    onMessage(message) {
+      console.log(`in zhong tai message`);
+      let body = _.get(message, 'body');
+      if (body) {
+        body = JSON.parse(body);
+        this.talk.push(body);
+        this.turnBottom();
+      }
+    },
   },
   watch: {
     room: {
@@ -113,7 +130,7 @@ export default {
 .chat {
   float: left;
   width: 100%;
-  padding: 30px;
+  padding: 20px;
 }
 .chat .chatInfo {
   float: left;

+ 118 - 118
src/router/index.js

@@ -94,248 +94,248 @@ const live = [
 
 const routes = [
   {
-    path: "/",
-    name: "index",
-    component: () => import("../views/index.vue"),
+    path: '/',
+    name: 'index',
+    component: () => import('../views/index.vue'),
   },
   // 科技政务
   {
-    path: "/government/government",
-    name: "government",
-    component: () => import("../views/government/government.vue"),
+    path: '/government/government',
+    name: 'government',
+    component: () => import('../views/government/government.vue'),
   },
   // 科技政务-列表
   {
-    path: "/government/governmentList",
-    name: "governmentList",
-    component: () => import("../views/government/governmentList.vue"),
+    path: '/government/governmentList',
+    name: 'governmentList',
+    component: () => import('../views/government/governmentList.vue'),
   },
 
   // 科技政务-详情
   {
-    path: "/government/governmentDetail",
-    name: "governmentDetail",
-    component: () => import("../views/government/governmentDetail.vue"),
+    path: '/government/governmentDetail',
+    name: 'governmentDetail',
+    component: () => import('../views/government/governmentDetail.vue'),
   },
   // 科技政策
   {
-    path: "/policy/policy",
-    name: "policy",
-    component: () => import("../views/policy/policy.vue"),
+    path: '/policy/policy',
+    name: 'policy',
+    component: () => import('../views/policy/policy.vue'),
   },
   // 首页政策法规详情(所属科技政策,综合政策指导)
   {
-    path: "/policy/lawDetail",
-    name: "lawDetail",
-    component: () => import("../views/policy/lawDetail.vue"),
+    path: '/policy/lawDetail',
+    name: 'lawDetail',
+    component: () => import('../views/policy/lawDetail.vue'),
   },
   // 科技超市
   {
-    path: "/supermaket/supermarket",
-    name: "supermarket",
-    component: () => import("../views/supermaket/supermarket.vue"),
+    path: '/supermaket/supermarket',
+    name: 'supermarket',
+    component: () => import('../views/supermaket/supermarket.vue'),
   },
 
   // 科技超市产品列表
   {
-    path: "/supermaket/supermarketlist",
-    name: "supermarketlist",
-    component: () => import("../views/supermaket/supermarketlist.vue"),
+    path: '/supermaket/supermarketlist',
+    name: 'supermarketlist',
+    component: () => import('../views/supermaket/supermarketlist.vue'),
   },
   // 科技超市-高校院所
   {
-    path: "/supermaket/supermarketColleges",
-    name: "supermarketColleges",
-    component: () => import("../views/supermaket/supermarketColleges.vue"),
+    path: '/supermaket/supermarketColleges',
+    name: 'supermarketColleges',
+    component: () => import('../views/supermaket/supermarketColleges.vue'),
   },
   // 科技超市-科研院所
   {
-    path: "/supermaket/supermarketScientific",
-    name: "supermarketSientific",
-    component: () => import("../views/supermaket/supermarketScientific.vue"),
+    path: '/supermaket/supermarketScientific',
+    name: 'supermarketSientific',
+    component: () => import('../views/supermaket/supermarketScientific.vue'),
   },
   // 科技超市-科技企业
   {
-    path: "/supermaket/supermarketEnterprise",
-    name: "supermarketEnterprise",
-    component: () => import("../views/supermaket/supermarketEnterprise.vue"),
+    path: '/supermaket/supermarketEnterprise',
+    name: 'supermarketEnterprise',
+    component: () => import('../views/supermaket/supermarketEnterprise.vue'),
   },
   // 科技超市-机构团体
   {
-    path: "/supermaket/supermarketGroup",
-    name: "supermarketGroup",
-    component: () => import("../views/supermaket/supermarketGroup.vue"),
+    path: '/supermaket/supermarketGroup',
+    name: 'supermarketGroup',
+    component: () => import('../views/supermaket/supermarketGroup.vue'),
   },
   //xiangping
   {
-    path: "/supermaket/supermarketdetail",
-    name: "supermarketdetail",
-    component: () => import("../views/supermaket/supermarketdetail.vue"),
+    path: '/supermaket/supermarketdetail',
+    name: 'supermarketdetail',
+    component: () => import('../views/supermaket/supermarketdetail.vue'),
   },
 
   // 科技超市-研发服务
   {
-    path: "/supermaket/supermaketService",
-    name: "supermaketService",
-    component: () => import("../views/supermaket/supermaketService.vue"),
+    path: '/supermaket/supermaketService',
+    name: 'supermaketService',
+    component: () => import('../views/supermaket/supermaketService.vue'),
   },
   //科技超市-技术成果
   {
-    path: "/supermaket/supermakettechnology",
-    name: "supermakettechnology",
-    component: () => import("../views/supermaket/supermakettechnology.vue"),
+    path: '/supermaket/supermakettechnology',
+    name: 'supermakettechnology',
+    component: () => import('../views/supermaket/supermakettechnology.vue'),
   },
   // 科技超市-创新产品
   {
-    path: "/supermaket/supermarketProduct",
-    name: "supermarketProduct",
-    component: () => import("../views/supermaket/supermarketProduct.vue"),
+    path: '/supermaket/supermarketProduct',
+    name: 'supermarketProduct',
+    component: () => import('../views/supermaket/supermarketProduct.vue'),
   },
 
   //科技超市列表
   {
-    path: "/supermaket/supermarkelists",
-    name: "supermarketuct",
-    component: () => import("../views/supermaket/supermarkelists.vue"),
+    path: '/supermaket/supermarkelists',
+    name: 'supermarketuct',
+    component: () => import('../views/supermaket/supermarkelists.vue'),
   },
 
   // 科技超市-咨询服务
   {
-    path: "/supermaket/supermarketinnovate",
-    name: "supermarketinnovate",
-    component: () => import("../views/supermaket/supermarketinnovate.vue"),
+    path: '/supermaket/supermarketinnovate',
+    name: 'supermarketinnovate',
+    component: () => import('../views/supermaket/supermarketinnovate.vue'),
   },
   //科技数据
   {
-    path: "/shuju/shuju",
-    name: "shuju",
-    component: () => import("../views/shuju/shuju.vue"),
+    path: '/shuju/shuju',
+    name: 'shuju',
+    component: () => import('../views/shuju/shuju.vue'),
   },
   {
-    path: "/shuju/shujulist",
-    name: "shujulist",
-    component: () => import("../views/shuju/shujulist.vue"),
+    path: '/shuju/shujulist',
+    name: 'shujulist',
+    component: () => import('../views/shuju/shujulist.vue'),
   },
   {
-    path: "/shuju/shujudetail",
-    name: "shujudetail",
-    component: () => import("../views/shuju/shujudetail.vue"),
+    path: '/shuju/shujudetail',
+    name: 'shujudetail',
+    component: () => import('../views/shuju/shujudetail.vue'),
   },
   //科技服务
   {
-    path: "/service/service",
-    name: "service",
-    component: () => import("../views/service/service.vue"),
+    path: '/service/service',
+    name: 'service',
+    component: () => import('../views/service/service.vue'),
   },
   {
-    path: "/service/servicelist",
-    name: "servicelist",
-    component: () => import("../views/service/servicelist.vue"),
+    path: '/service/servicelist',
+    name: 'servicelist',
+    component: () => import('../views/service/servicelist.vue'),
   },
   {
-    path: "/service/servicedetail",
-    name: " servicedetail",
-    component: () => import("../views/service/servicedetail.vue"),
+    path: '/service/servicedetail',
+    name: ' servicedetail',
+    component: () => import('../views/service/servicedetail.vue'),
   },
   // 科技资源
   {
-    path: "/resource/resource",
-    name: "service",
-    component: () => import("../views/resource/resource.vue"),
+    path: '/resource/resource',
+    name: 'service',
+    component: () => import('../views/resource/resource.vue'),
   },
   //登录和注册
   {
-    path: "/login",
-    meta: { title: "用户" },
-    component: () => import("../views/login.vue"),
+    path: '/login',
+    meta: { title: '用户' },
+    component: () => import('../views/login.vue'),
   },
   //科技人才
   {
-    path: "/personnel/personnel",
-    name: "personnel",
-    component: () => import("../views/personnel/personnel.vue"),
+    path: '/personnel/personnel',
+    name: 'personnel',
+    component: () => import('../views/personnel/personnel.vue'),
   },
   //科技人才投简历详情
   {
-    path: "/personnel/rencai",
-    component: () => import("../views/personnel/rencai.vue"),
+    path: '/personnel/rencai',
+    component: () => import('../views/personnel/rencai.vue'),
   },
   //科技人才找工作详情
   {
-    path: "/personnel/personnelwork",
-    name: "personnelwork",
-    component: () => import("../views/personnel/personnelwork.vue"),
+    path: '/personnel/personnelwork',
+    name: 'personnelwork',
+    component: () => import('../views/personnel/personnelwork.vue'),
   },
   //科技人才找专家详情
   {
-    path: "/personnel/personnelexpert",
-    component: () => import("../views/personnel/personnelexpert.vue"),
+    path: '/personnel/personnelexpert',
+    component: () => import('../views/personnel/personnelexpert.vue'),
   },
   // 科技人才找参谋详情
   {
-    path: "/personnel/personnelcmdetail",
-    component: () => import("../views/personnel/personnelcmdetail.vue"),
+    path: '/personnel/personnelcmdetail',
+    component: () => import('../views/personnel/personnelcmdetail.vue'),
   },
   // 科技人才找招聘信息
   {
-    path: "/personnel/recruitList",
-    component: () => import("../views/personnel/recruitList.vue"),
+    path: '/personnel/recruitList',
+    component: () => import('../views/personnel/recruitList.vue'),
   },
   // 科技人才-就业指导
   {
-    path: "/personnel/guidanceList",
-    component: () => import("../views/personnel/guidanceList.vue"),
+    path: '/personnel/guidanceList',
+    component: () => import('../views/personnel/guidanceList.vue'),
   },
   // 科技人才-学习实践
   {
-    path: "/personnel/practiceList",
-    component: () => import("../views/personnel/practiceList.vue"),
+    path: '/personnel/practiceList',
+    component: () => import('../views/personnel/practiceList.vue'),
   },
   // 科技人才-勤工俭学
   {
-    path: "/personnel/diligenceList",
-    component: () => import("../views/personnel/diligenceList.vue"),
+    path: '/personnel/diligenceList',
+    component: () => import('../views/personnel/diligenceList.vue'),
   },
   // 科技人才-工作顾问
   {
-    path: "/personnel/adviserList",
-    component: () => import("../views/personnel/adviserList.vue"),
+    path: '/personnel/adviserList',
+    component: () => import('../views/personnel/adviserList.vue'),
   },
   //企业-基本信息
   {
-    path: "/enterprise/enterprisejb",
-    name: "enterprisefabu",
-    component: () => import("../views/enterprise/enterprisejb.vue"),
+    path: '/enterprise/enterprisejb',
+    name: 'enterprisefabu',
+    component: () => import('../views/enterprise/enterprisejb.vue'),
   },
   //企业-信息管理
   {
-    path: "/enterprise/enterprisexx",
-    name: "enterprisexuqiu",
-    component: () => import("../views/enterprise/enterprisexx.vue"),
+    path: '/enterprise/enterprisexx',
+    name: 'enterprisexuqiu',
+    component: () => import('../views/enterprise/enterprisexx.vue'),
   },
   //企业-发布信息列表
   {
-    path: "/enterprise/enterprisefabu",
-    name: "enterprisefabu",
-    component: () => import("../views/enterprise/enterprisefabu.vue"),
+    path: '/enterprise/enterprisefabu',
+    name: 'enterprisefabu',
+    component: () => import('../views/enterprise/enterprisefabu.vue'),
   },
   // 企业-需求发布
   {
-    path: "/enterprise/enterprisexuqiu",
-    name: "enterprisexuqiu",
-    component: () => import("../views/enterprise/enterprisexuqiu.vue"),
+    path: '/enterprise/enterprisexuqiu',
+    name: 'enterprisexuqiu',
+    component: () => import('../views/enterprise/enterprisexuqiu.vue'),
   },
   //企业-订购
   {
-    path: "/enterprise/enterprisedg",
-    name: "enterprisedg",
-    component: () => import("../views/enterprise/enterprisedg.vue"),
+    path: '/enterprise/enterprisedg',
+    name: 'enterprisedg',
+    component: () => import('../views/enterprise/enterprisedg.vue'),
   },
   // 外审管理员
   {
-    path: "/trial/index",
-    name: "trial",
-    component: () => import("../views/trial/index.vue"),
+    path: '/trial/index',
+    name: 'trial',
+    component: () => import('../views/trial/index.vue'),
   },
   // ...live,
 ];