1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <template>
- <div id="contextxx">
- <template v-if="view == 'room'">
- <rooms :list="list" @toChat="toChat"></rooms>
- </template>
- <template v-else>
- <chat :room="room" @toRoom="view = 'room'"></chat>
- </template>
- </div>
- </template>
- <script>
- import rooms from './parts/room.vue';
- import chat from './parts/chat.vue';
- import { mapState, createNamespacedHelpers } from 'vuex';
- const { mapActions } = createNamespacedHelpers('personalroom');
- export default {
- name: 'contextxx',
- props: {},
- components: { rooms, chat },
- data: () => {
- return {
- view: 'room',
- list: [],
- room: {},
- };
- },
- created() {
- this.search();
- },
- mounted() {
- this.channel();
- },
- methods: {
- ...mapActions(['query', 'fetch']),
- async search() {
- let res = await this.query({ seller_id: this.user.uid });
- if (this.$checkRes(res)) this.$set(this, `list`, res.data);
- },
- async toChat(data) {
- let res = await this.fetch(data.id);
- if (this.$checkRes(res)) {
- this.$set(this, `room`, res.data);
- this.view = 'chat';
- }
- },
- channel() {
- this.$stomp({
- [`/exchange/chat_message/${this.user.uid}`]: this.onMessage,
- });
- },
- onMessage(message) {
- console.log(message);
- },
- },
- computed: {
- ...mapState(['user']),
- pageTitle() {
- return `${this.$route.meta.title}`;
- },
- },
- metaInfo() {
- return { title: this.$route.meta.title };
- },
- };
- </script>
- <style lang="less" scoped></style>
|