guhongwei 3 years ago
parent
commit
895b1623df

+ 20 - 24
src/components/detail-model/achieveInfo.vue

@@ -232,30 +232,26 @@ export default {
     },
     //供求对接
     async onSubmit() {
-      console.log(this.user);
-      // 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.tranCreate(obj);
-      // this.$checkRes(res, '对接成功', res.errmsg || '对接失败');
+      let data = { dock_id: this.dock_id, product_id: this.form.id, s_id: this.form.user_id, s_name: this.form.company, s_phone: this.form.phone };
+      if (!_.get(this.user, 'id')) {
+        this.$message({
+          dangerouslyUseHTMLString: true,
+          message: '<strong><a href="http://broadcast.waityou24.cn/live/login" style="color:red;">游客身份无法与专家进行对接,请先注册</a></strong>',
+          type: 'error',
+        });
+        return;
+      } else {
+        // 需求者信息
+        data.d_id = this.user.id;
+        data.d_name = this.user.name;
+        data.d_phone = this.user.phone;
+      }
+      if (data.d_id === data.s_id) {
+        this.$message.error('您不能对自己进行对接!');
+        return;
+      }
+      const res = await this.tranCreate(data);
+      this.$checkRes(res, '对接成功', res.errmsg || '对接失败');
     },
   },
   computed: {

+ 17 - 20
src/components/detail-model/techolInfo.vue

@@ -140,7 +140,7 @@ import chat from '@c/chat.vue';
 import _ from 'lodash';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: personRoom } = createNamespacedHelpers('personRoom');
-const { mapActions: transaction } = createNamespacedHelpers('transaction');
+const { mapActions: dockTranscation } = createNamespacedHelpers('dockTranscation');
 export default {
   name: 'techolInfo',
   props: {
@@ -162,7 +162,7 @@ export default {
   created() {},
   methods: {
     ...personRoom(['create']),
-    ...transaction({ getTran: 'query', createTran: 'create' }),
+    ...dockTranscation({ tranCreate: 'create' }),
     async btnPhone() {
       if (!this.room.id) {
         //TODO 请求房间号
@@ -195,28 +195,25 @@ export default {
     },
     //供求对接
     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('您不能对自己的成果进行对接!');
+      let data = { dock_id: this.dock_id, product_id: this.form.id, s_id: this.form.user_id, s_name: this.form.company, s_phone: this.form.phone };
+      if (!_.get(this.user, 'id')) {
+        this.$message({
+          dangerouslyUseHTMLString: true,
+          message: '<strong><a href="http://broadcast.waityou24.cn/live/login" style="color:red;">游客身份无法与专家进行对接,请先注册</a></strong>',
+          type: 'error',
+        });
         return;
+      } else {
+        // 需求者信息
+        data.d_id = this.user.id;
+        data.d_name = this.user.name;
+        data.d_phone = this.user.phone;
       }
-      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('您已申请供求对接,无需再次申请!');
+      if (data.d_id === data.s_id) {
+        this.$message.error('您不能对自己进行对接!');
         return;
       }
-      const res = await this.createTran(obj);
+      const res = await this.tranCreate(data);
       this.$checkRes(res, '对接成功', res.errmsg || '对接失败');
     },
     // 隐藏手机号

+ 1 - 1
src/views/achieveLive - 副本/detail/productData.vue

@@ -116,7 +116,7 @@ export default {
     },
     // 对接
     trans(data, type) {
-      this.$router.push({ path: '/achieveLive/product/detail', query: { dock_id: this.id, id: data.id, type: data.type } });
+      this.$router.push({ path: '/achieveLive/product/detail', query: { dock_id: this.id, id: data._id, type: data.type } });
     },
     // 取消查看
     handleClose() {

+ 1 - 1
src/views/achieveLive/detail/productData.vue

@@ -100,7 +100,7 @@ export default {
     },
     // 对接
     trans(data, type) {
-      this.$router.push({ path: '/achieveLive/model/dataDetail', query: { dock_id: this.dock_id, id: data._id, type: type, viewType: 'product' } });
+      this.$router.push({ path: '/achieveLive/model/dataDetail', query: { dock_id: this.dock_id, id: data.id, type: type, viewType: 'product' } });
     },
     // 查看更多项目
     moreBtn(type) {

+ 60 - 6
src/views/achieveLive/product/detail.vue

@@ -2,25 +2,63 @@
   <div id="detail">
     <el-row>
       <el-col :span="24" class="main">
-        产品对接
+        <el-col :span="24" class="one">
+          <el-col :span="24" class="right">
+            <el-button type="primary" size="mini" @click="back">返回活动首页</el-button>
+          </el-col>
+        </el-col>
+        <el-col :span="24" class="two">
+          <techolInfo :form="info" v-if="type == '0'"></techolInfo>
+          <achieveInfo :form="info" v-else-if="type == '1'"></achieveInfo>
+        </el-col>
       </el-col>
     </el-row>
   </div>
 </template>
 
 <script>
+import techolInfo from '@c/detail-model/techolInfo.vue';
+import achieveInfo from '@c/detail-model/achieveInfo.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: product } = createNamespacedHelpers('product');
 export default {
   name: 'detail',
   props: {},
-  components: {},
+  components: {
+    techolInfo,
+    achieveInfo,
+  },
   data: function() {
-    return {};
+    return {
+      info: {},
+    };
+  },
+  created() {
+    if (this.id) this.search();
+  },
+  methods: {
+    ...product(['fetch']),
+    async search() {
+      let res = await this.fetch(this.id);
+      if (this.$checkRes(res)) {
+        this.$set(this, `info`, res.data);
+      }
+    },
+    back() {
+      this.$router.push({ path: '/achieveLive/detail', query: { dock_id: this.dock_id } });
+    },
   },
-  created() {},
-  methods: {},
   computed: {
     ...mapState(['user']),
+    dock_id() {
+      return this.$route.query.dock_id;
+    },
+    id() {
+      return this.$route.query.id;
+    },
+    type() {
+      return this.$route.query.type;
+    },
   },
   metaInfo() {
     return { title: this.$route.meta.title };
@@ -35,4 +73,20 @@ export default {
 };
 </script>
 
-<style lang="less" scoped></style>
+<style lang="less" scoped>
+.main {
+  min-height: 505px;
+  box-shadow: 0 0 5px #ccc;
+  background-color: #fff;
+  padding: 20px;
+  .one {
+    margin: 0 0 10px 0;
+    height: 40px;
+    overflow: hidden;
+    border-bottom: 2px solid #666;
+    .right {
+      text-align: right;
+    }
+  }
+}
+</style>

+ 3 - 1
src/views/achieveLive/product/index.vue

@@ -58,7 +58,9 @@ export default {
       }
     },
     // 对接
-    toCheck({ data }) {},
+    toCheck({ data }) {
+      this.$router.push({ path: '/achieveLive/model/dataDetail', query: { dock_id: this.dock_id, id: data.id, type: data.type, viewType: 'product' } });
+    },
     back() {
       this.$router.push({ path: '/achieveLive/detail', query: { dock_id: this.dock_id } });
     },