瀏覽代碼

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

guhongwei 5 年之前
父節點
當前提交
9b3a24f0a1
共有 2 個文件被更改,包括 19 次插入16 次删除
  1. 8 4
      src/layout/live/head.vue
  2. 11 12
      src/views/hall/dock/parts/chat.vue

+ 8 - 4
src/layout/live/head.vue

@@ -12,16 +12,16 @@
           <p v-if="user && user.uid">
             {{ user.name }}
           </p>
-          <p v-else>
+          <p>
             <span v-if="user && user.name">{{ user.name }}</span>
-            <button type="button">登录</button>
-            <button type="button">注册</button>
+            <button type="button" class="logininfo">登录</button>
+            <button type="button" class="logininfo">注册</button>
           </p>
         </div>
       </div>
       <div class="superlogo">
         <div class="w_1200">
-          <a href="/">
+          <a href="home">
             <img :src="logo" />
             <span>
               吉林省计算中心科技平台
@@ -98,4 +98,8 @@ export default {
 
 <style lang="less" scoped>
 @import '~@/style/style.css';
+.logininfo {
+  font-size: 20px;
+  margin: 0 0 0 5px;
+}
 </style>

+ 11 - 12
src/views/hall/dock/parts/chat.vue

@@ -4,8 +4,8 @@
       <el-col :span="24" class="info chat_frame" id="chat">
         <template v-for="(i, index) in talk">
           <template v-if="isSender(i, index)">
-            <span :key="`senderTime${i.id}${index}`">[{{ i.send_time }}] {{ i.sender_name }}</span>
-            <span v-html="i.content" :key="`senderContent${i.id}${index}`"></span>
+            <span style="text-align:right" :key="`senderTime${i.id}${index}`">[{{ i.send_time }}] {{ i.sender_name }}</span>
+            <span style="text-align:right" v-html="i.content" :key="`senderContent${i.id}${index}`"></span>
           </template>
           <template v-else>
             <span :key="`receverTime${i.id}${index}`">[{{ i.send_time }}] {{ i.receiver_name }}</span>
@@ -54,7 +54,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);
@@ -62,6 +62,7 @@ export default {
         this.$set(this, `content`, '');
         this.$forceUpdate();
         if (this.$checkRes(res, null, res.errmsg || '发言失败')) {
+          console.log(`in 交易 chat`);
           this.talk.push(res.data);
           this.turnBottom();
         }
@@ -73,22 +74,20 @@ 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 交易 message`);
       let body = _.get(message, 'body');
       if (body) {
         body = JSON.parse(body);
-        console.log(body);
-        // let is_seller = this.sellerList.find(f => f.user_id == body.sender_id);
-        // if (is_seller) this.mainTalk.push({ id: body._id, sender_name: body.sender_name, send_time: body.send_time, content: body.content });
-        // else this.otherTalk.push({ id: body._id, sender_name: body.sender_name, send_time: body.send_time, content: body.content });
-        this.$nextTick(() => {
-          // document.getElementById('chatBuy').scrollTop = document.getElementById('chatBuy').scrollHeight + 150;
-          // document.getElementById('chat').scrollTop = document.getElementById('chat').scrollHeight + 150;
-        });
+        this.talk.push(body);
+        this.turnBottom();
       }
     },
     turnBottom() {
@@ -97,7 +96,7 @@ export default {
       });
     },
     isSender(data) {
-      return this.user.uid == data.sender_id;
+      return this.user.uid != data.sender_id;
     },
   },
   watch: {