lrf402788946 4 年之前
父节点
当前提交
f8517461a4

+ 70 - 4
src/views/achieveLive/expert/detailInfo.vue

@@ -114,30 +114,96 @@
           </el-col>
         </el-col>
         <el-col :span="24" class="btn" v-if="showBtn">
-          <el-button type="primary" size="mini">交流洽谈</el-button>
-          <el-button type="success" size="mini">供求对接</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>
+    <el-dialog title="对接" :visible.sync="dialogTableVisible" destroy-on-close>
+      <chat :room="room"></chat>
+    </el-dialog>
   </div>
 </template>
 
 <script>
+import chat from '@c/chat.vue';
+const _ = require('lodash');
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: personRoom } = createNamespacedHelpers('personRoom');
+const { mapActions: transaction } = createNamespacedHelpers('transaction');
 export default {
   name: 'detailInfo',
   props: {
     form: { type: Object },
     showBtn: { type: Boolean, default: () => true },
   },
-  components: {},
+  components: { chat },
   data: function() {
     return {
       img_url: require('@common/src/assets/live/d10_fbb1.png'),
+      dialogTableVisible: false,
+      room: {},
     };
   },
   created() {},
-  methods: {},
+  methods: {
+    ...personRoom(['create']),
+    ...transaction({ getTran: 'query', createTran: 'create' }),
+    async btnPhone() {
+      if (!this.room.id) {
+        //TODO 请求房间号
+        let obj = {};
+        if (!_.get(this.user, 'id')) {
+          // this.$message.error('游客身份无法与卖家对话,请先注册');
+          this.$message({
+            dangerouslyUseHTMLString: true,
+            message: '<strong><a href="http://broadcast.waityou24.cn/live/login" style="color:red;">游客身份无法与卖家对话,请先注册</a></strong>',
+            type: 'error',
+          });
+          return;
+        } else {
+          obj.p1_id = this.user.id;
+          obj.p1 = this.user.name;
+        }
+        if (!this.form.id) {
+          this.$message.error('缺少专家信息,请联系管理员');
+          return;
+        } else {
+          obj.p2_id = this.form.id;
+          obj.p2 = this.form.name;
+        }
+        let res = await this.create(obj);
+        if (this.$checkRes(res)) {
+          this.$set(this, `room`, res.data);
+        }
+      }
+      this.dialogTableVisible = true;
+    },
+    //供求对接
+    async onSubmit(data) {
+      const obj = {
+        supplier: _.get(data, 'id'),
+        s_name: _.get(data, 'name'),
+        s_phone: _.get(data, 'phone'),
+        product_id: _.get(data, 'id'),
+        product: _.get(data, 'name'),
+        demander: _.get(this.user, 'id'),
+        d_name: _.get(this.user, 'name'),
+        d_phone: _.get(this.user, 'phone'),
+      };
+      if (obj.demander === obj.supplier) {
+        this.$message.error('您不能对自己进行对接!');
+        return;
+      }
+      const list = await this.getTran({ product_id: obj.product_id, demander: obj.demander });
+      if (list.total > 0) {
+        this.$message.warning('您已申请供求对接,无需再次申请!');
+        return;
+      }
+      const res = await this.createTran(obj);
+      this.$checkRes(res, '对接成功', res.errmsg || '对接失败');
+    },
+  },
   computed: {
     ...mapState(['user']),
   },

+ 74 - 4
src/views/achieveLive/product/detailInfo.vue

@@ -159,8 +159,8 @@
           </el-col>
         </el-col>
         <el-col :span="24" class="anniu" v-if="showBtn">
-          <el-button type="primary" size="mini">交流洽谈</el-button>
-          <el-button type="success" size="mini">供求对接</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>
@@ -170,31 +170,101 @@
         <el-table-column prop="patentstatus" label="专利状态" align="center"> </el-table-column>
       </el-table>
     </el-dialog>
+    <el-dialog title="对接" :visible.sync="dialogTableVisible" destroy-on-close>
+      <chat :room="room"></chat>
+    </el-dialog>
   </div>
 </template>
 
 <script>
+import chat from '@c/chat.vue';
 import _ from 'lodash';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: personRoom } = createNamespacedHelpers('personRoom');
+const { mapActions: transaction } = createNamespacedHelpers('transaction');
 export default {
   name: 'detailInfo',
   props: {
     form: { type: Object },
     showBtn: { type: Boolean, default: () => true },
   },
-  components: {},
+  components: { chat },
   data: function() {
     return {
       dialogTableVisible1: false,
+      dialogTableVisible: false,
+      room: {},
     };
   },
   created() {},
-  methods: {},
+  methods: {
+    ...personRoom(['create']),
+    ...transaction({ getTran: 'query', createTran: 'create' }),
+    async btnPhone() {
+      if (!this.room.id) {
+        //TODO 请求房间号
+        let obj = {};
+        if (!_.get(this.user, 'id')) {
+          // this.$message.error('游客身份无法与卖家对话,请先注册');
+          this.$message({
+            dangerouslyUseHTMLString: true,
+            message: '<strong><a href="http://broadcast.waityou24.cn/live/login" style="color:red;">游客身份无法与卖家对话,请先注册</a></strong>',
+            type: 'error',
+          });
+          return;
+        } else {
+          obj.p1_id = this.user.id;
+          obj.p1 = this.user.name;
+        }
+        if (!this.form.user_id) {
+          this.$message.error('缺少卖家信息,请联系卖家或管理员');
+          return;
+        } else {
+          obj.p2_id = this.form.user_id;
+          obj.p2 = this.form.contacts;
+        }
+        let res = await this.create(obj);
+        if (this.$checkRes(res)) {
+          this.$set(this, `room`, res.data);
+        }
+      }
+      this.dialogTableVisible = true;
+    },
+    //供求对接
+    async onSubmit() {
+      const data = _.cloneDeep(this.form);
+      const obj = {
+        dock_id: this.dock_id,
+        supplier: _.get(data, 'user_id'),
+        s_name: _.get(data, 'contacts'),
+        s_phone: _.get(data, 'phone'),
+        product_id: _.get(data, 'id'),
+        product: _.get(data, 'name'),
+        demander: _.get(this.user, 'id'),
+        d_name: _.get(this.user, 'name'),
+        d_phone: _.get(this.user, 'phone'),
+      };
+      if (obj.demander === obj.supplier) {
+        this.$message.error('您不能对自己的成果进行对接!');
+        return;
+      }
+      const list = await this.getTran({ product_id: obj.product_id, demander: obj.demander, dock_id: this.dock_id });
+      if (list.total > 0) {
+        this.$message.warning('您已申请供求对接,无需再次申请!');
+        return;
+      }
+      const res = await this.createTran(obj);
+      this.$checkRes(res, '对接成功', res.errmsg || '对接失败');
+    },
+  },
   computed: {
     ...mapState(['user']),
     pageTitle() {
       return `${this.$route.meta.title}`;
     },
+    dock_id() {
+      return this.$route.query.dock_id;
+    },
   },
   metaInfo() {
     return { title: this.$route.meta.title };

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

@@ -175,12 +175,12 @@ export default {
           obj.p1_id = this.user.id;
           obj.p1 = this.user.name;
         }
-        if (!this.data.user_id) {
-          this.$message.error('缺少卖家信息,请联系卖家或管理员');
+        if (!this.data.id) {
+          this.$message.error('缺少专家信息,请联系管理员');
           return;
         } else {
-          obj.p2_id = this.data.user_id;
-          obj.p2 = this.data.contacts;
+          obj.p2_id = this.data.id;
+          obj.p2 = this.data.name;
         }
         let res = await this.create(obj);
         if (this.$checkRes(res)) {