hallDetail.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <div id="liveList">
  3. <div class="pz_top">
  4. <div class="w_0100">
  5. <div class="livetop">
  6. <div class="w_1200">
  7. <div class="title">
  8. 吉林省计算中心对接直播中心
  9. </div>
  10. <div class="zhuban">
  11. <span>主办方:</span>
  12. <span>吉林省计算中心直播大厅</span>
  13. </div>
  14. <div class="num">
  15. <p>
  16. <span>同时在线</span>
  17. <span>1人</span>
  18. </p>
  19. <p>
  20. <span>特邀嘉宾</span>
  21. <span>1人</span>
  22. </p>
  23. <p>
  24. <span>洽谈合作</span>
  25. <span>1人</span>
  26. </p>
  27. <p>
  28. <span>达成意愿</span>
  29. <span>1人</span>
  30. </p>
  31. <p>
  32. <span>展示成果</span>
  33. <span>1人</span>
  34. </p>
  35. <p>
  36. <span>发布需求</span>
  37. <span>1人</span>
  38. </p>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="pz_main">
  45. <div class="w_0100">
  46. <div class="w_1200">
  47. <el-col :span="24" class="hallDetail">
  48. <el-col :span="18" class="left">
  49. <el-col :span="24" class="top">
  50. 图文直播
  51. </el-col>
  52. <el-col :span="24" class="info" style="height: 402px;overflow: auto;" id="chatSell">
  53. <template v-for="(i, index) in mainTalk">
  54. <span :key="`sellTime${i.id}`">[{{ i.send_time }}] {{ i.sender_name }}</span>
  55. <span v-html="i.content" :key="`sellContent${i.id}${index}`"></span>
  56. </template>
  57. </el-col>
  58. </el-col>
  59. <el-col :span="6" class="right">
  60. <el-col :span="24" class="top">
  61. 聊天记录
  62. </el-col>
  63. <el-col :span="24" class="info" style="height: 402px;overflow: auto;" id="chatBuy">
  64. <template v-for="(i, index) in otherTalk">
  65. <span :key="`buyTime${i.id}${index}`">[{{ i.send_time }}] {{ i.sender_name }}</span>
  66. <span v-html="i.content" :key="`buyContent${i.id}${index}`"></span>
  67. </template>
  68. </el-col>
  69. </el-col>
  70. <el-col :span="24" class="hallDetailInput" style="text-align:center">
  71. <wang-editor v-model="content" style="height:130px;padding-bottom:120px" ref="editor"></wang-editor>
  72. <el-button type="primary" @click="sendMessage">发送</el-button>
  73. </el-col>
  74. </el-col>
  75. </div>
  76. </div>
  77. </div>
  78. <div class="pz_down">
  79. <div class="w_0100">
  80. <div class="superdown">
  81. <div class="w_1200">
  82. <p>版权所有:吉林省技术算中心</p>
  83. <p>
  84. <span>技术支持:长春福瑞科技有限公司</span>
  85. &nbsp;&nbsp;&nbsp;&nbsp;
  86. <span>邮编:130000</span>
  87. &nbsp;&nbsp;&nbsp;&nbsp;
  88. <span>传真:239823982</span>
  89. </p>
  90. <p>
  91. <span>地址:吉林省长春市朝阳区前进大街1244号</span>
  92. &nbsp;&nbsp;&nbsp;&nbsp;
  93. <span>电话:0134-1234567</span>
  94. &nbsp;&nbsp;&nbsp;&nbsp;
  95. <span>邮箱:123456@163.com</span>
  96. </p>
  97. </div>
  98. </div>
  99. </div>
  100. </div>
  101. </div>
  102. </template>
  103. <script>
  104. import wangEditor from '@/components/wang-editor.vue';
  105. import { mapState, createNamespacedHelpers } from 'vuex';
  106. const { mapActions: dock } = createNamespacedHelpers('dock');
  107. const { mapActions: roomchat } = createNamespacedHelpers('roomchat');
  108. export default {
  109. name: 'hallDetail',
  110. props: {},
  111. components: { wangEditor },
  112. data: () => ({
  113. content: '',
  114. mainTalk: [],
  115. otherTalk: [],
  116. info: {},
  117. buyerList: [],
  118. sellerList: [],
  119. sending: true,
  120. text: '',
  121. }),
  122. created() {
  123. this.search();
  124. },
  125. mounted() {
  126. this.channel();
  127. },
  128. methods: {
  129. ...dock(['fetch']),
  130. ...roomchat(['create']),
  131. async search() {
  132. const res = await this.fetch(this.id);
  133. if (this.$checkRes(res)) {
  134. let { apply, ...info } = res.data;
  135. this.$set(this, `info`, info);
  136. let buyList = apply.filter(f => f.buyer == '0');
  137. this.$set(this, `buyerList`, buyList);
  138. let sellList = apply.filter(f => f.buyer == '1');
  139. this.$set(this, `sellerList`, sellList);
  140. }
  141. },
  142. async sendMessage() {
  143. this.$set(this, `sending`, false);
  144. // if (!this.user.uid) {
  145. // this.$message.error('游客不能发言,请先注册');
  146. // return;
  147. // }
  148. if (this.content != '') {
  149. let object = { number: this.id, sender_name: this.user.name, content: this.content };
  150. if (this.user.uid) object.sender_id = this.user.uid;
  151. let res = await this.create(object);
  152. this.$refs.editor.setContent();
  153. this.$set(this, `content`, '');
  154. this.$forceUpdate();
  155. this.$checkRes(res, null, res.errmsg || '发言失败');
  156. } else this.$message.error('请输入信息后发送');
  157. this.$set(this, `sending`, true);
  158. },
  159. channel() {
  160. this.$stomp({
  161. [`/exchange/room_chat/${this.id}`]: this.onMessage,
  162. });
  163. },
  164. onMessage(message) {
  165. // console.log('receive a message: ', message.body);
  166. let body = _.get(message, 'body');
  167. if (body) {
  168. body = JSON.parse(body);
  169. let is_seller = this.sellerList.find(f => f.user_id == body.sender_id);
  170. if (is_seller) this.mainTalk.push({ id: body._id, sender_name: body.sender_name, send_time: body.send_time, content: body.content });
  171. else this.otherTalk.push({ id: body._id, sender_name: body.sender_name, send_time: body.send_time, content: body.content });
  172. this.$nextTick(() => {
  173. document.getElementById('chatBuy').scrollTop = document.getElementById('chatBuy').scrollHeight + 150;
  174. document.getElementById('chatSell').scrollTop = document.getElementById('chatSell').scrollHeight + 150;
  175. });
  176. }
  177. },
  178. },
  179. computed: {
  180. ...mapState(['user']),
  181. pageTitle() {
  182. return `${this.$route.meta.title}`;
  183. },
  184. id() {
  185. return this.$route.query.id;
  186. },
  187. },
  188. metaInfo() {
  189. return { title: this.$route.meta.title };
  190. },
  191. };
  192. </script>
  193. <style lang="less">
  194. @import '~@/style/style.css';
  195. .hallDetail {
  196. height: 800px;
  197. border: 1px solid red;
  198. margin: 0 0 20px 0;
  199. }
  200. .hallDetail .left {
  201. height: 450px;
  202. border: 1px solid #cccccc;
  203. }
  204. .hallDetail .left .top {
  205. height: 40px;
  206. line-height: 40px;
  207. padding: 0px 15px;
  208. font-size: 18px;
  209. border-bottom: 1px dashed #ccc;
  210. }
  211. .hallDetail .right {
  212. border: 1px solid #ccc;
  213. height: 450px;
  214. }
  215. .hallDetail .right .top {
  216. height: 40px;
  217. line-height: 40px;
  218. padding: 0px 15px;
  219. font-size: 18px;
  220. border-bottom: 1px dashed #ccc;
  221. }
  222. .hallDetailInput {
  223. padding: 30px 100px 0px 100px;
  224. }
  225. .hallDetailInput .el-input {
  226. width: 70%;
  227. }
  228. </style>