hallDetail.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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">
  53. <template v-for="(i, index) in mainTalk">
  54. <span :key="`sellTime${i.id}`">[{{ i.send_time }}]</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">
  64. <template v-for="(i, index) in otherTalk">
  65. <span :key="`buyTime${i.id}${index}`">[{{ i.send_time }}]</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"></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. }),
  120. created() {
  121. this.search();
  122. },
  123. mounted() {
  124. this.channel();
  125. },
  126. methods: {
  127. ...dock(['fetch']),
  128. ...roomchat(['create']),
  129. async search() {
  130. const res = await this.fetch(this.id);
  131. if (this.$checkRes(res)) {
  132. let { apply, ...info } = res.data;
  133. this.$set(this, `info`, info);
  134. let buyList = apply.filter(f => f.buyer == '0');
  135. this.$set(this, `buyerList`, buyList);
  136. let sellList = apply.filter(f => f.buyer == '1');
  137. this.$set(this, `sellerList`, sellList);
  138. }
  139. },
  140. async sendMessage() {
  141. if (!this.user.uid) {
  142. this.$message.error('游客不能发言,请先注册');
  143. return;
  144. }
  145. if (this.content != '') {
  146. let object = { number: this.id, sender_name: this.user.name, content: this.content };
  147. if (this.user.uid) object.sender_id = this.user.uid;
  148. let res = await this.create(object);
  149. this.$checkRes(res, null, res.errmsg || '发言失败');
  150. } else this.$message.error('请输入信息后发送');
  151. },
  152. channel() {
  153. this.$stomp({
  154. [`/exchange/room_chat/${this.id}`]: this.onMessage,
  155. });
  156. },
  157. onMessage(message) {
  158. // console.log('receive a message: ', message.body);
  159. let body = _.get(message, 'body');
  160. if (body) {
  161. body = JSON.parse(body);
  162. let is_seller = this.sellerList.find(f => f.user_id == body.sender_id);
  163. if (is_seller) this.mainTalk.push({ id: body._id, sender_name: body.sender_name, send_time: body.send_time, content: body.content });
  164. else this.otherTalk.push({ id: body._id, sender_name: body.sender_name, send_time: body.send_time, content: body.content });
  165. this.content = '';
  166. }
  167. },
  168. },
  169. computed: {
  170. ...mapState(['user']),
  171. pageTitle() {
  172. return `${this.$route.meta.title}`;
  173. },
  174. id() {
  175. return this.$route.query.id;
  176. },
  177. },
  178. metaInfo() {
  179. return { title: this.$route.meta.title };
  180. },
  181. };
  182. </script>
  183. <style lang="less">
  184. @import '~@/style/style.css';
  185. .hallDetail {
  186. height: 800px;
  187. border: 1px solid red;
  188. margin: 0 0 20px 0;
  189. }
  190. .hallDetail .left {
  191. height: 450px;
  192. border: 1px solid #cccccc;
  193. }
  194. .hallDetail .left .top {
  195. height: 40px;
  196. line-height: 40px;
  197. padding: 0px 15px;
  198. font-size: 18px;
  199. border-bottom: 1px dashed #ccc;
  200. }
  201. .hallDetail .right {
  202. border: 1px solid #ccc;
  203. height: 450px;
  204. }
  205. .hallDetail .right .top {
  206. height: 40px;
  207. line-height: 40px;
  208. padding: 0px 15px;
  209. font-size: 18px;
  210. border-bottom: 1px dashed #ccc;
  211. }
  212. .hallDetailInput {
  213. padding: 30px 100px 0px 100px;
  214. }
  215. .hallDetailInput .el-input {
  216. width: 70%;
  217. }
  218. </style>