lrf402788946 4 years ago
parent
commit
a60a031381

+ 1 - 0
.gitignore

@@ -1,6 +1,7 @@
 .DS_Store
 node_modules
 /dist
+package-lock.json
 
 
 # local env files

+ 13 - 9
src/components/chat.vue

@@ -28,7 +28,8 @@
 <script>
 // import wangEditor from '@common/src/components/frame/wang-editor.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
-const { mapActions: personalChat } = createNamespacedHelpers('personalchat');
+const { mapActions: personChat } = createNamespacedHelpers('personChat');
+const _ = require('lodash');
 export default {
   name: 'chats',
   props: {
@@ -42,11 +43,11 @@ export default {
     };
   },
   created() {},
-  mounted() {
+  async mounted() {
     this.channel();
   },
   methods: {
-    ...personalChat(['create', 'query']),
+    ...personChat(['create', 'query']),
     async search() {
       let res = await this.query({ personroom_id: this.room.id });
       if (this.$checkRes(res)) {
@@ -56,11 +57,11 @@ export default {
     },
     async sendMessage() {
       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.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 obj = { room_id: this.room.id, content: this.content, sender_id: this.user.id, sender_name: this.user.name };
+        let pos = 'p1';
+        if (_.get(this.room, 'p1_id') === this.user.id) pos = 'p2';
+        obj.receiver_id = _.get(this.room, `${pos}_id`);
+        obj.receiver = _.get(this.room, pos);
         let res = await this.create(obj);
         // this.$refs.editor.setContent();
         this.$set(this, `content`, '');
@@ -77,11 +78,14 @@ export default {
         console.warn('未获取到房间id,无法进行订阅');
         return;
       }
+      // console.log(`/exchange/personChat/${this.room.id}/${this.user.id}`);
       this.$stomp({
-        [`/exchange/person_chat/${this.room.id}_${this.user.uid}`]: this.onMessage,
+        [`/exchange/personChat/${this.room.id}.${this.user.id}`]: this.onMessage,
       });
     },
     onMessage(message) {
+      console.log('in function:');
+      console.log(message);
       let body = _.get(message, 'body');
       if (body) {
         body = JSON.parse(body);

+ 2 - 3
src/main.js

@@ -11,15 +11,14 @@ import '@/plugins/loading';
 import '@/plugins/var';
 import '@/plugins/methods';
 import '@/plugins/setting';
-// import InitStomp from '@/plugins/stomp';
+import InitStomp from '@/plugins/stomp';
 Vue.config.productionTip = false;
-
 new Vue({
   router,
   store,
   render: h => h(App),
 }).$mount('#app');
-// InitStomp();
+InitStomp();
 window.vm = new Vue({
   router,
 });

+ 4 - 3
src/plugins/setting.js

@@ -6,10 +6,11 @@ Vue.config.weixin = {
 };
 
 Vue.config.stomp = {
-  // brokerURL: 'ws://http://free.liaoningdoupo.com/ws',
-  brokerURL: '/ws', // ws://${location.host}/ws
+  brokerURL: 'ws://192.168.1.118/ws',
+  // brokerURL: '/ws', // ws://${location.host}/ws
+  // brokerURL: 'ws://127.0.0.1:8000/ws',
   connectHeaders: {
-    host: 'visit',
+    host: 'platform',
     login: 'visit', //visit
     passcode: 'visit', //visit123
   },

+ 5 - 0
src/store/index.js

@@ -36,6 +36,9 @@ import news from '@common/src/store/news';
 import survey from '@common/src/store/survey';
 // 统计
 import statistics from '@common/src/store/statistics';
+// 个人聊天
+import personRoom from '@common/src/store/person_room';
+import personChat from '@common/src/store/person_chat';
 
 // 字典表
 import category from '@common/src/store/category';
@@ -69,5 +72,7 @@ export default new Vuex.Store({
     statistics,
     dockPw,
     transaction,
+    personRoom,
+    personChat,
   },
 });

+ 5 - 1
src/views/market/list/business.vue

@@ -18,7 +18,11 @@ const { mapActions: product } = createNamespacedHelpers('product');
 export default {
   name: 'business',
   props: ['listModel'],
-  components: { listPage, model3: () => import('@c/list/list-model/model-3.vue'), dmodel: () => import('./detail-model/model-3.vue') },
+  components: {
+    listPage,
+    model3: () => import('@c/list/list-model/model-3.vue'),
+    dmodel: () => import('./detail-model/model-3.vue'),
+  },
   data: function() {
     return {
       list: [],

+ 13 - 10
src/views/market/list/detail-model/model-1.vue

@@ -164,8 +164,8 @@
           </el-col>
         </el-col>
         <el-col :span="24" class="anniu" v-if="displayBtn">
-          <el-button type="primary" size="mini" v-if="this.user && this.user.uid != data.userid" @click="btnPhone()">交流洽谈</el-button>
-          <el-button type="success" size="mini" v-if="this.user && this.user.uid != data.userid" @click="onSubmit()">供求对接</el-button>
+          <el-button type="primary" size="mini" @click="btnPhone()">交流洽谈</el-button>
+          <el-button type="success" size="mini" @click="onSubmit()">供求对接</el-button>
         </el-col>
       </el-col>
     </el-row>
@@ -177,7 +177,7 @@
       </el-table>
     </el-dialog>
 
-    <el-dialog title="对接" :visible.sync="dialogTableVisible">
+    <el-dialog title="对接" :visible.sync="dialogTableVisible" destroy-on-close>
       <chat :room="room"></chat>
     </el-dialog>
   </div>
@@ -186,6 +186,8 @@
 <script>
 import chat from '@c/chat.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const _ = require('lodash');
+const { mapActions: personRoom } = createNamespacedHelpers('personRoom');
 export default {
   name: 'model-1',
   props: {
@@ -202,12 +204,13 @@ export default {
   },
   created() {},
   methods: {
+    ...personRoom(['create']),
     // 对接
     async btnPhone() {
       if (!this.room.id) {
         //TODO 请求房间号
         let obj = {};
-        if (!this.user.uid) {
+        if (!_.get(this.user, 'id')) {
           // this.$message.error('游客身份无法与卖家对话,请先注册');
           this.$message({
             dangerouslyUseHTMLString: true,
@@ -216,15 +219,15 @@ export default {
           });
           return;
         } else {
-          obj.buyer_id = this.user.uid;
-          obj.buyer_name = this.user.name;
+          obj.p1_id = this.user.id;
+          obj.p1 = this.user.name;
         }
-        if (!this.detailInfo.userid) {
+        if (!this.data.user_id) {
           this.$message.error('缺少卖家信息,请联系卖家或管理员');
           return;
         } else {
-          obj.seller_id = this.detailInfo.userid;
-          obj.seller_name = this.detailInfo.contacts;
+          obj.p2_id = this.data.user_id;
+          obj.p2 = this.data.contacts;
         }
         let res = await this.create(obj);
         if (this.$checkRes(res)) {
@@ -233,7 +236,7 @@ export default {
       }
       this.dialogTableVisible = true;
     },
-    // 洽谈
+    // 对接
     onSubmit() {
       // TODO 提交申请即可
       // this.$emit('onSubmit', { data: this.data });

+ 12 - 9
src/views/market/list/detail-model/model-3.vue

@@ -96,8 +96,8 @@
           </el-col>
         </el-col>
         <el-col :span="24" class="anniu" v-if="displayBtn">
-          <el-button type="primary" size="mini" v-if="this.user && this.user.uid != data.userid" @click="btnPhone()">交流洽谈</el-button>
-          <el-button type="success" size="mini" v-if="this.user && this.user.uid != data.userid" @click="onSubmit()">供求对接</el-button>
+          <el-button type="primary" size="mini" @click="btnPhone()">交流洽谈</el-button>
+          <el-button type="success" size="mini" @click="onSubmit()">供求对接</el-button>
         </el-col>
       </el-col>
     </el-row>
@@ -108,8 +108,10 @@
 </template>
 
 <script>
+const _ = require('lodash');
 import chat from '@c/chat.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: personRoom } = createNamespacedHelpers('personRoom');
 export default {
   name: 'model-3',
   props: {
@@ -125,12 +127,13 @@ export default {
   },
   created() {},
   methods: {
+    ...personRoom(['create']),
     // 对接
     async btnPhone() {
       if (!this.room.id) {
         //TODO 请求房间号
         let obj = {};
-        if (!this.user.uid) {
+        if (!_.get(this.user, 'id')) {
           // this.$message.error('游客身份无法与卖家对话,请先注册');
           this.$message({
             dangerouslyUseHTMLString: true,
@@ -139,15 +142,15 @@ export default {
           });
           return;
         } else {
-          obj.buyer_id = this.user.uid;
-          obj.buyer_name = this.user.name;
+          obj.p1_id = this.user.id;
+          obj.p1 = this.user.name;
         }
-        if (!this.data.userid) {
+        if (!this.data.user_id) {
           this.$message.error('缺少卖家信息,请联系卖家或管理员');
           return;
         } else {
-          obj.seller_id = this.data.userid;
-          obj.seller_name = this.data.contacts;
+          obj.p2_id = this.data.user_id;
+          obj.p2 = this.data.contacts;
         }
         let res = await this.create(obj);
         if (this.$checkRes(res)) {
@@ -156,7 +159,7 @@ export default {
       }
       this.dialogTableVisible = true;
     },
-    // 洽谈
+    // 对接
     onSubmit() {
       this.$emit('onSubmit', { data: this.data });
     },

+ 12 - 9
src/views/market/list/detail-model/model-4.vue

@@ -125,8 +125,8 @@
           </el-col>
         </el-col>
         <el-col :span="24" class="anniu" v-if="displayBtn">
-          <el-button type="primary" size="mini" v-if="this.user && this.user._id != data.userid" @click="btnPhone()">交流洽谈</el-button>
-          <el-button type="success" size="mini" v-if="this.user && this.user._id != data.userid" @click="onSubmit()">供求对接</el-button>
+          <el-button type="primary" size="mini" @click="btnPhone()">交流洽谈</el-button>
+          <el-button type="success" size="mini" @click="onSubmit()">供求对接</el-button>
         </el-col>
       </el-col>
     </el-row>
@@ -139,6 +139,8 @@
 <script>
 import chat from '@c/chat.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const _ = require('lodash');
+const { mapActions: personRoom } = createNamespacedHelpers('personRoom');
 export default {
   name: 'model-4',
   props: {
@@ -155,12 +157,13 @@ export default {
   },
   created() {},
   methods: {
+    ...personRoom(['create']),
     // 对接
     async btnPhone() {
       if (!this.room.id) {
         //TODO 请求房间号
         let obj = {};
-        if (!this.user._id) {
+        if (!_.get(this.user, 'id')) {
           // this.$message.error('游客身份无法与卖家对话,请先注册');
           this.$message({
             dangerouslyUseHTMLString: true,
@@ -169,15 +172,15 @@ export default {
           });
           return;
         } else {
-          obj.buyer_id = this.user.uid;
-          obj.buyer_name = this.user.name;
+          obj.p1_id = this.user.id;
+          obj.p1 = this.user.name;
         }
-        if (!this.data.id) {
+        if (!this.data.user_id) {
           this.$message.error('缺少卖家信息,请联系卖家或管理员');
           return;
         } else {
-          obj.seller_id = this.data.userid;
-          obj.seller_name = this.data.name;
+          obj.p2_id = this.data.user_id;
+          obj.p2 = this.data.contacts;
         }
         let res = await this.create(obj);
         if (this.$checkRes(res)) {
@@ -186,7 +189,7 @@ export default {
       }
       this.dialogTableVisible = true;
     },
-    // 洽谈
+    // 对接
     onSubmit() {
       this.$emit('onSubmit', { data: this.data });
     },

+ 12 - 9
src/views/market/list/detail-model/model-5.vue

@@ -142,8 +142,8 @@
           </el-col>
         </el-col>
         <el-col :span="24" class="anniu" v-if="displayBtn">
-          <el-button type="primary" size="mini" v-if="this.user && this.user.uid != data.userid" @click="btnPhone()">交流洽谈</el-button>
-          <el-button type="success" size="mini" v-if="this.user && this.user.uid != data.userid" @click="onSubmit()">供求对接</el-button>
+          <el-button type="primary" size="mini" @click="btnPhone()">交流洽谈</el-button>
+          <el-button type="success" size="mini" @click="onSubmit()">供求对接</el-button>
         </el-col>
       </el-col>
     </el-row>
@@ -156,6 +156,8 @@
 <script>
 import chat from '@c/chat.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const _ = require('lodash');
+const { mapActions: personRoom } = createNamespacedHelpers('personRoom');
 export default {
   name: 'model-5',
   props: {
@@ -176,12 +178,13 @@ export default {
   },
   created() {},
   methods: {
+    ...personRoom(['create']),
     // 对接
     async btnPhone() {
       if (!this.room.id) {
         //TODO 请求房间号
         let obj = {};
-        if (!this.user.uid) {
+        if (!_.get(this.user, 'id')) {
           // this.$message.error('游客身份无法与卖家对话,请先注册');
           this.$message({
             dangerouslyUseHTMLString: true,
@@ -190,15 +193,15 @@ export default {
           });
           return;
         } else {
-          obj.buyer_id = this.user.uid;
-          obj.buyer_name = this.user.name;
+          obj.p1_id = this.user.id;
+          obj.p1 = this.user.name;
         }
-        if (!this.detailInfo.userid) {
+        if (!this.data.user_id) {
           this.$message.error('缺少卖家信息,请联系卖家或管理员');
           return;
         } else {
-          obj.seller_id = this.detailInfo.userid;
-          obj.seller_name = this.detailInfo.contacts;
+          obj.p2_id = this.data.user_id;
+          obj.p2 = this.data.contacts;
         }
         let res = await this.create(obj);
         if (this.$checkRes(res)) {
@@ -207,7 +210,7 @@ export default {
       }
       this.dialogTableVisible = true;
     },
-    // 洽谈
+    // 对接
     onSubmit() {
       this.$emit('onSubmit', { data: this.detailInfo });
     },

+ 1 - 1
src/views/techolchat/gzcy/chat.vue

@@ -52,7 +52,7 @@ export default {
     this.$set(this, 'dock_id', '123456');
     this.search();
   },
-  mounted() {
+  async mounted() {
     this.channel();
   },
   methods: {

+ 2 - 2
src/views/trainLive/parts/chat.vue

@@ -63,8 +63,8 @@ export default {
   async created() {
     // this.search();
   },
-  mounted() {
-    // this.channel();
+  async mounted() {
+    this.channel();
   },
   methods: {
     // ...trainchat(['query', 'create']),

+ 9 - 9
vue.config.js

@@ -27,25 +27,25 @@ module.exports = {
       '/weixin': {
         target: 'http://smart.cc-lotus.info',
         changeOrigin: true,
-        ws: true,
+        ws: false,
       },
       '/files': {
         target: 'http://free.liaoningdoupo.com',
       },
       '/api': {
-        target: 'http://broadcast.waityou24.cn',
+        target: 'http://192.168.1.118', //http://broadcast.waityou24.cn
         changeOrigin: true,
-        ws: true,
+        ws: false,
       },
       '/site': {
-        target: 'http://broadcast.waityou24.cn',
+        target: 'http://192.168.1.118', //http://broadcast.waityou24.cn
         changeOrigin: true,
-        ws: true,
-      },
-      '/ws': {
-        target: 'http://free.liaoningdoupo.com',
-        ws: true,
+        ws: false,
       },
+      // '/ws': {
+      //   target: 'http://192.168.1.118',
+      //   ws: false,
+      // },
     },
   },
 };