hi-ucs/front/src/views/detailsAll/components/Application/ApplicationTopDetails.vue

185 lines
5.0 KiB
Vue
Raw Normal View History

2022-06-14 09:32:49 +08:00
<!--
* @Author: hisense.liangjunhua
* @Date: 2022-06-08 11:56:28
* @LastEditors: hisense.liangjunhua
2022-06-14 11:32:25 +08:00
* @LastEditTime: 2022-06-14 11:31:12
2022-06-14 09:32:49 +08:00
* @Description: 算法详情页头部
-->
<template>
<div class="algorithm-top-details">
<div class="left">
<div class="top">
<span class="name">{{ props.dataList.name }}</span>
<span class="label">{{ props.dataList.type }}</span>
<span class="label">{{ props.dataList.shareType }}</span>
<span class="label">{{ props.dataList.shareCondition }}</span>
<!-- <span class="label">免费</span> -->
</div>
<div class="main">
<div>应用领域{{ applicationArea }}</div>
<div>
{{ props.dataList.description }}
</div>
</div>
<div class="bottom" v-if="props.dataList.id">
<a-button type="primary" @click="toView()">
<template #icon><form-outlined /></template>
申请使用
</a-button>
<a-button type="primary" @click="addShoppingCart()">
<template #icon><shopping-cart-outlined /></template>
加入购物车
</a-button>
<a-button type="primary" @click="goTOCollection()">收藏</a-button>
</div>
</div>
<div class="right"></div>
</div>
</template>
<script setup>
import { FormOutlined, ShoppingCartOutlined } from '@ant-design/icons-vue'
import { defineProps, ref, watch } from 'vue'
import { scInsert } from '@/api/personalCenter'
import { sgcInsert } from '@/api/home'
import { useRouter } from 'vue-router'
import mybus from '@/myplugins/mybus'
import { message } from 'ant-design-vue'
const props = defineProps({
dataList: { type: Object, default: null },
})
const router = useRouter()
const applicationArea = ref('')
// 加入申购车
const addShoppingCart = () => {
console.log('加入申购车==================>', props.dataList)
sgcInsert({
delFlag: '0',
resourceId: props.dataList.id,
// userId: userId.value,
}).then((res) => {
console.log(res)
message.success('添加申购车成功!')
mybus.emit('getSgcNum')
})
}
// 立即申请
function toView() {
// window.open(newpage.href, '_blank')
router.push({
path: '/apply',
query: {
name: props.dataList.name,
resourceId: [props.dataList.id],
},
})
}
// 收藏
const goTOCollection = () => {
console.log('收藏===================》', props.dataList)
scInsert([{ resourceId: props.dataList.id }]).then((res) => {
console.log(res)
message.success('收藏成功')
})
}
if (props.dataList.infoList) {
applicationArea.value = props.dataList.infoList.filter(
(val) => val.attrType === '应用领域'
)[0].attrValue
}
watch(
() => props.dataList,
(val) => {
if (val) {
applicationArea.value = props.dataList.infoList.filter(
(val) => val.attrType === '应用领域'
)[0].attrValue
}
}
)
</script>
<style lang="less" scoped>
.algorithm-top-details {
2022-06-14 11:32:25 +08:00
height: 6rem;
padding: 1.8rem 0 0;
2022-06-14 09:32:49 +08:00
background: url('~@/assets/detailsAll/sf_top_bg.png') no-repeat;
background-size: 100%;
display: flex;
justify-content: center;
.left {
2022-06-14 11:32:25 +08:00
width: 7rem;
2022-06-14 09:32:49 +08:00
color: #fff;
.top {
display: flex;
align-items: center;
span {
2022-06-14 11:32:25 +08:00
font-size: 0.14rem;
2022-06-14 09:32:49 +08:00
}
.name {
2022-06-14 11:32:25 +08:00
max-width: 3.3rem;
2022-06-14 09:32:49 +08:00
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
2022-06-14 11:32:25 +08:00
font-size: 0.4rem;
margin-right: 0.2rem;
2022-06-14 09:32:49 +08:00
}
.label {
2022-06-14 11:32:25 +08:00
padding: 0.01rem 0.1rem;
margin-right: 0.1rem;
border-radius: 0.13rem;
2022-06-14 09:32:49 +08:00
background: rgba(255, 255, 255, 0.4);
}
}
.main {
2022-06-14 11:32:25 +08:00
margin-top: 0.2rem;
font-size: 0.18rem;
line-height: 0.34rem;
2022-06-14 09:32:49 +08:00
& > div:nth-of-type(1) {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
& > div:nth-of-type(2) {
2022-06-14 11:32:25 +08:00
max-height: 1rem;
2022-06-14 09:32:49 +08:00
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
}
}
.bottom {
2022-06-14 11:32:25 +08:00
margin-top: 0.4rem;
2022-06-14 09:32:49 +08:00
display: flex;
.ant-btn {
2022-06-14 11:32:25 +08:00
height: 0.5rem;
margin-right: 0.2rem;
2022-06-14 09:32:49 +08:00
background: #ff8b55;
2022-06-14 11:32:25 +08:00
border-radius: 0.06rem;
font-size: 0.2rem;
2022-06-14 09:32:49 +08:00
display: flex;
justify-content: center;
align-items: center;
}
.ant-btn:nth-of-type(1) {
2022-06-14 11:32:25 +08:00
width: 1.8rem;
2022-06-14 09:32:49 +08:00
}
.ant-btn:nth-of-type(2) {
2022-06-14 11:32:25 +08:00
width: 2.2rem;
2022-06-14 09:32:49 +08:00
}
.ant-btn:nth-of-type(3) {
2022-06-14 11:32:25 +08:00
width: 1.45rem;
2022-06-14 09:32:49 +08:00
background: #fff;
color: #526aff;
}
}
}
.right {
2022-06-14 11:32:25 +08:00
width: 5.8rem;
height: 4rem;
2022-06-14 09:32:49 +08:00
background: url('~@/assets/detailsAll/sf_right_bg.png') no-repeat;
background-size: 100%;
2022-06-14 11:32:25 +08:00
margin-top: -0.4rem;
2022-06-14 09:32:49 +08:00
}
}
</style>