zs 1 rok temu
rodzic
commit
857356dd1c

+ 5 - 0
src/store/api/platform/project.js

@@ -17,6 +17,10 @@ export const ProjectStore = defineStore('project', () => {
     const res = await axios.$get(`${url}/${payload}`)
     return res
   }
+  const detail = async (payload) => {
+    const res = await axios.$get(`${url}/detail/${payload}`)
+    return res
+  }
   const create = async (payload) => {
     const res = await axios.$post(`${url}`, payload)
     return res
@@ -33,6 +37,7 @@ export const ProjectStore = defineStore('project', () => {
   return {
     query,
     fetch,
+    detail,
     create,
     update,
     del

+ 5 - 0
src/store/api/user/company.js

@@ -17,6 +17,10 @@ export const CompanyStore = defineStore('company', () => {
     const res = await axios.$get(`${url}/${payload}`)
     return res
   }
+  const detail = async (payload) => {
+    const res = await axios.$get(`${url}/detail/${payload}`)
+    return res
+  }
   const create = async (payload) => {
     const res = await axios.$post(`${url}`, payload)
     return res
@@ -33,6 +37,7 @@ export const CompanyStore = defineStore('company', () => {
   return {
     query,
     fetch,
+    detail,
     create,
     update,
     del

+ 5 - 1
src/views/achievement/detail.vue

@@ -227,7 +227,11 @@ const getArea = (data) => {
 }
 // 附件下载
 const toFile = () => {
-  console.log('附件下载')
+  if (info.value && info.value.file && info.value.file.length > 0) {
+    window.open(info.value.file[0].url)
+  } else {
+    ElMessage({ type: `warning`, message: `暂无文件下载!` })
+  }
 }
 // 购买
 const toBuy = () => {

+ 52 - 6
src/views/company/detail.vue

@@ -27,9 +27,18 @@
                   </el-col>
                   <el-col :span="8" class="button">
                     <el-col :span="24" class="one_1">
-                      <el-col :span="5" class="file" @click="toCollection">
-                        <el-icon><Star /></el-icon>
-                        收藏
+                      <el-col
+                        :span="6"
+                        class="file"
+                        @click="toCollection(0)"
+                        v-if="info.is_collection"
+                      >
+                        <el-icon :size="16"><StarFilled /></el-icon>
+                        <span>已收藏</span>
+                      </el-col>
+                      <el-col :span="5" class="file" @click="toCollection(1)" v-else>
+                        <el-icon :size="16"><Star /></el-icon>
+                        <span>收藏</span>
                       </el-col>
                       <el-col :span="8" class="file">
                         <a-button type="primary" @click="toChat"> 在线洽谈 </a-button>
@@ -122,15 +131,18 @@
 
 <script setup>
 // 基础
+import moment from 'moment'
 import { get } from 'lodash-es'
 const $checkRes = inject('$checkRes')
 // 接口
 import { CompanyStore } from '@/store/api/user/company'
 import { AchievementStore } from '@/store/api/platform/achievement'
+import { CollectionStore } from '@/store/api/platform/collection'
 import { DictDataStore } from '@/store/api/system/dictData'
 const achievementStore = AchievementStore()
 const store = CompanyStore()
 const dictDataStore = DictDataStore()
+const collectionStore = CollectionStore()
 import { UserStore } from '@/store/user'
 const userStore = UserStore()
 const user = computed(() => userStore.user)
@@ -162,7 +174,7 @@ onMounted(async () => {
 const search = async () => {
   let id = route.query.id
   if (id) {
-    let res = await store.fetch(id)
+    let res = await store.detail(id)
     if (res.errcode == '0') info.value = res.data
   }
 }
@@ -217,8 +229,36 @@ const toChat = () => {
   router.push({ path: '/chat', query: { id: info.value.id || info.value._id } })
 }
 // 收藏
-const toCollection = () => {
-  console.log('收藏')
+const toCollection = async (status) => {
+  if (user.value._id) {
+    let res
+    let message
+    const data = {
+      user: user.value._id,
+      source: info.value._id,
+      type: 'company',
+      time: moment().format('YYYY-MM-DD')
+    }
+    if (status == '1') {
+      message = '收藏成功'
+      res = await collectionStore.create(data)
+    } else {
+      message = '取消收藏成功'
+      res = await collectionStore.cancel(data)
+    }
+    if (res.errcode === 0) {
+      ElMessage({
+        message,
+        type: 'success'
+      })
+      await search()
+    }
+  } else {
+    ElMessage({
+      message: '未登录无法进行收藏 请登录',
+      type: 'warning'
+    })
+  }
 }
 // 查看
 const toView = (item) => {
@@ -300,6 +340,12 @@ const sizeChange = (limits) => {
               .file {
                 display: flex;
                 align-items: center;
+                font-family: PingFangSC-Regular;
+                font-size: 14px;
+                color: #2374ff;
+                span {
+                  margin: 0 0 0 5px;
+                }
               }
             }
           }

+ 2 - 2
src/views/demand/detail.vue

@@ -7,11 +7,11 @@
             <el-row :span="24" class="one_1">
               <el-col :span="22" class="title">{{ info.name || '暂无标题' }}</el-col>
               <el-col :span="2" class="file" @click="toCollection(0)" v-if="info.is_collection">
-                <el-icon :size="18"><StarFilled /></el-icon>
+                <el-icon :size="16"><StarFilled /></el-icon>
                 <span>已收藏</span>
               </el-col>
               <el-col :span="2" class="file" @click="toCollection(1)" v-else>
-                <el-icon :size="18"><Star /></el-icon>
+                <el-icon :size="16"><Star /></el-icon>
                 <span>收藏</span>
               </el-col>
             </el-row>

+ 2 - 2
src/views/expert/detail.vue

@@ -30,11 +30,11 @@
               </el-col>
               <el-col :span="6" class="one_3">
                 <el-col :span="10" class="file" @click="toCollection(0)" v-if="info.is_collection">
-                  <el-icon :size="18"><StarFilled /></el-icon>
+                  <el-icon :size="16"><StarFilled /></el-icon>
                   <span>已收藏</span>
                 </el-col>
                 <el-col :span="10" class="file" @click="toCollection(1)" v-else>
-                  <el-icon :size="18"><Star /></el-icon>
+                  <el-icon :size="16"><Star /></el-icon>
                   <span>收藏</span>
                 </el-col>
                 <el-col :span="14">

+ 52 - 12
src/views/project/detail.vue

@@ -6,9 +6,13 @@
           <el-col :span="24" class="one">
             <el-row :span="24" class="one_1">
               <el-col :span="20" class="title">{{ info.name || '暂无标题' }}</el-col>
-              <el-col :span="4" class="file" @click="toCollection" v-if="info.status == '1'">
-                <el-icon><Star /></el-icon>
-                收藏
+              <el-col :span="4" class="file" @click="toCollection(0)" v-if="info.is_collection">
+                <el-icon :size="16"><StarFilled /></el-icon>
+                <span>已收藏</span>
+              </el-col>
+              <el-col :span="4" class="file" @click="toCollection(1)" v-else>
+                <el-icon :size="16"><Star /></el-icon>
+                <span>收藏</span>
               </el-col>
             </el-row>
           </el-col>
@@ -55,11 +59,11 @@
             <el-row :span="24" class="thr_2">
               <el-col :span="17" class="left">
                 <el-col :span="24" class="name">
-                  {{ unit.name || '暂无' }}
+                  {{ userInfo.name || '暂无单位' }}
                 </el-col>
                 <el-col :span="24" class="other">
                   <span>联系人</span>
-                  {{ unit.contacts || '暂无' }}
+                  {{ userInfo.name || '暂无联系人' }}
                 </el-col>
               </el-col>
               <el-col :span="4" class="right" v-if="info.status == '1'">
@@ -131,14 +135,17 @@
 </template>
 
 <script setup>
+import moment from 'moment'
 // 基础
 import { MessageOutlined } from '@ant-design/icons-vue'
 import { get } from 'lodash-es'
 const $checkRes = inject('$checkRes')
 // 接口
 import { ProjectStore } from '@/store/api/platform/project'
+import { CollectionStore } from '@/store/api/platform/collection'
 import { DictDataStore } from '@/store/api/system/dictData'
 const store = ProjectStore()
+const collectionStore = CollectionStore()
 const dictDataStore = DictDataStore()
 import { UserStore } from '@/store/user'
 const userStore = UserStore()
@@ -149,7 +156,7 @@ const router = useRouter()
 // 加载中
 const loading = ref(false)
 const info = ref({})
-const unit = ref({ name: '吉林大学', contacts: '陈老师' })
+const userInfo = ref({})
 // 字典表
 const fieldList = ref([])
 const typeList = ref([])
@@ -172,8 +179,11 @@ onMounted(async () => {
 const search = async () => {
   let id = route.query.id
   if (id) {
-    let res = await store.fetch(id)
-    if (res.errcode == '0') info.value = res.data
+    let res = await store.detail(id)
+    if (res.errcode == '0') {
+      info.value = res.data
+      userInfo.value = res.data.userInfo
+    }
   }
 }
 const searchAchieve = async (query = { skip: 0, limit }) => {
@@ -231,8 +241,36 @@ const toDocking = () => {
   console.log('我要对接')
 }
 // 收藏
-const toCollection = () => {
-  console.log('收藏')
+const toCollection = async (status) => {
+  if (user.value._id) {
+    let res
+    let message
+    const data = {
+      user: user.value._id,
+      source: info.value._id,
+      type: 'project',
+      time: moment().format('YYYY-MM-DD')
+    }
+    if (status == '1') {
+      message = '收藏成功'
+      res = await collectionStore.create(data)
+    } else {
+      message = '取消收藏成功'
+      res = await collectionStore.cancel(data)
+    }
+    if (res.errcode === 0) {
+      ElMessage({
+        message,
+        type: 'success'
+      })
+      await search()
+    }
+  } else {
+    ElMessage({
+      message: '未登录无法进行收藏 请登录',
+      type: 'warning'
+    })
+  }
 }
 // 查看
 const toView = (item) => {
@@ -272,11 +310,13 @@ const sizeChange = (limits) => {
       .file {
         display: flex;
         align-items: center;
-        justify-content: end;
+        justify-content: flex-end;
         font-family: PingFangSC-Regular;
         font-size: 14px;
         color: #2374ff;
-        text-align: right;
+        span {
+          margin: 0 0 0 5px;
+        }
       }
     }