【前端】印包客app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

407 lines
12 KiB

<template>
<view>
<view class="flex-col group">
<!-- 只能使用v-iffixed会影响observer -->
<view class="justify-between header" v-if="showTitle">
<text class="text">{{ factoryInfo.name || '-' }}</text>
<view class="flex-row group_1">
<text class="text_1">分享</text>
<image
src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/611dd17441a9be0011f45822/620ccb0962a7d90011fe5c8f/16486138596948699331.png"
class="image"
/>
</view>
</view>
<Banner :list="swiperList"></Banner>
<view class="flex-col group_3">
<view class="flex-col section_1">
<view class="flex-col">
<view class="justify-between">
<text class="text_1">{{ factoryInfo.name || '-' }}</text>
<view class="flex-row group_6" @click="editFactory">
<text>修改</text>
<image
src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/611dd17441a9be0011f45822/620ccb0962a7d90011fe5c8f/16484397523702242367.png"
class="image_2"
/>
</view>
</view>
<view class="flex-col group_7">
<view class="flex-row">
<image
src="https://project-user-resource-1256085488.cos.ap-guangzhou.myqcloud.com/611dd17441a9be0011f45822/620ccb0962a7d90011fe5c8f/16484397546883580497.png"
class="image_3"
/>
<text class="text_3">{{ factoryInfo.contactName || '-' }} {{ factoryInfo.contactMobile }}</text>
</view>
<view class="flex-row group_9">
<image
src="https://project-user-resource-1256085488.cos.ap-guangzhou.myqcloud.com/611dd17441a9be0011f45822/620ccb0962a7d90011fe5c8f/16484397546889037530.png"
class="image_4"
/>
<text class="text_4">{{ factoryInfo.locProvinceName + factoryInfo.locCityName + factoryInfo.locDistrictName + factoryInfo.locDetail }}</text>
</view>
</view>
</view>
<text class="text_5">
{{ factoryInfo.factoryIntroduce || '-' }}
</text>
</view>
<view class="flex-col line-tabs">
<view class="flex-row group_10">
<view class="flex-col items-center text_7" :style="{ color: curTab == 'device' ? 'rgb(0, 122, 255)' : '' }">
<text @click="selectTab('device')">工厂设备</text>
<view v-show="curTab == 'device'" class="section_2"></view>
</view>
<view class="flex-col items-center text_7" :style="{ color: curTab == 'production' ? 'rgb(0, 122, 255)' : '' }">
<text @click="selectTab('production')">产品展示</text>
<view v-show="curTab == 'production'" class="section_2"></view>
</view>
</view>
<view v-if="curTab == 'device'">
<view class="flex-col section_3" v-for="(item, index) in deviceList" :key="index" @click="go2('device-info', { id: item.id })">
<image
src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/611dd17441a9be0011f45822/620ccb0962a7d90011fe5c8f/16484397512933663615.png"
class="image_5"
/>
<view class="flex-col">
<view class="justify-between group_13">
<text class="text_8">{{ item.name }}</text>
</view>
<text class="text_9">
{{ item.cameraId }}
</text>
</view>
</view>
</view>
<view class="observer">{{ hasMore ? '加载中' : '没有更多' }}</view>
</view>
<image
src="https://project-user-resource-1256085488.cos.ap-guangzhou.myqcloud.com/611dd17441a9be0011f45822/620ccb0962a7d90011fe5c8f/16484397546886233508.png"
class="image_6"
/>
</view>
</view>
</view>
</template>
<script>
import Banner from './Banner.vue'
import { go2 } from '@/utils/hook.js'
import { getFactoryInfo } from '@/apis/factoryApi.js'
import { getEquipmentList } from '@/apis/deviceApi.js'
import { fileType } from '@/enums/index.js'
export default {
components: {
Banner
},
data() {
return {
factoryInfo: {},
swiperList: [],
swiperCurrent: 0,
curTab: 'device',
pagination: {
pageNum: 1,
pageSize: 10
},
deviceList: [],
productionList: [],
observer: null,
hasMore: false,
showTitle: false
}
},
computed: {
hasFactory() {
return this.$store.state.companyInfo.id || 0
}
},
watch: {
hasFactory(val) {
if (val) {
this.getCompanyInfo()
}
},
curTab(val) {
// 重置
this.hasMore = false
this.pagination.pageNum = 1
this.getList()
}
},
created() {
this.getCompanyInfo()
this.getList()
},
mounted() {
this.observer = uni.createIntersectionObserver(this)
// 手动监听元素出现在视口
this.observer
.relativeToViewport({
bottom: 50
})
.observe('.observer', (res) => {
if (res.intersectionRatio > 0 && this.hasMore) {
this.pagination.pageNum++
this.getList()
}
})
let observerTitle = uni.createIntersectionObserver(this)
observerTitle
.relativeToViewport({
bottom: 50
})
.observe('.text_1', (res) => {
if (res.intersectionRatio > 0) {
this.showTitle = false
}
if (res.intersectionRatio == 0) {
this.showTitle = !this.showTitle
}
})
},
methods: {
go2,
editFactory() {
go2('complete-info', { id: this.$store.state.companyInfo.id, role: 'enterprise' })
},
getCompanyInfo() {
getFactoryInfo({ id: this.$store.state.companyInfo.id }).then((res) => {
if (res) {
this.factoryInfo = res
this.swiperList = res.imgItemList.map((item) => {
if (item.type == fileType.IMG) {
return {
type: 'image',
url: item.fileUrl
}
}
if (item.type == fileType.VIDEO) {
return {
type: 'video',
url: item.fileUrl,
imageUrl: item.videoPicUrl
}
}
return {}
})
}
})
},
selectTab(tab) {
this.pagination.pageNum = 1
this.curTab = tab
},
// 获取列表
getList() {
if (this.curTab == 'device') {
getEquipmentList({ ...this.pagination }).then((res) => {
if (res) {
if (res.current <= 1) {
this.deviceList = res.records
for (let i = 0; i < 3; i++) {
this.deviceList = [...this.deviceList, ...this.deviceList]
}
} else {
this.deviceList = this.deviceList.concat(res.records)
}
this.hasMore = this.deviceList.length < res.total
}
})
}
if (this.curTab == 'production') {
getEquipmentList({ ...this.pagination }).then((res) => {
if (res) {
if (res.current <= 1) {
this.deviceList = res.records
} else {
this.deviceList = this.deviceList.concat(res.records)
}
this.hasMore = this.deviceList.length < res.total
}
})
}
}
}
}
</script>
<style lang="scss" scoped>
.group {
padding-bottom: 68rpx;
flex: 1 1 auto;
overflow-y: auto;
height: 100vh; // 粘性定位的锚定元素
.group_3 {
margin-top: -40rpx;
position: relative;
.section_1 {
padding: 32rpx 32rpx 20rpx;
background-color: #fff;
border-radius: 40rpx 40rpx 0px 0px;
.text_5 {
margin-right: 7rpx;
margin-top: 48rpx;
color: rgb(51, 51, 51);
font-size: 26rpx;
line-height: 37rpx;
text-align: left;
}
.group_7 {
margin-top: 18rpx;
color: rgb(51, 51, 51);
font-size: 26rpx;
line-height: 37rpx;
white-space: nowrap;
.group_9 {
margin-top: 12rpx;
padding: 0 3rpx;
.image_4 {
margin: 3rpx 0 3rpx;
width: 27rpx;
height: 30rpx;
}
.text_4 {
margin-left: 12rpx;
width: 650rpx;
white-space: break-spaces;
}
}
.image_3 {
margin: 4rpx 0 4rpx;
width: 28rpx;
height: 28rpx;
}
.text_3 {
margin-left: 12rpx;
}
}
.text_1 {
color: rgb(0, 0, 0);
font-size: 36rpx;
font-weight: 500;
line-height: 50rpx;
white-space: nowrap;
}
.group_6 {
margin: 7rpx 7rpx 7rpx 0;
color: rgb(0, 122, 255);
font-size: 26rpx;
line-height: 37rpx;
white-space: nowrap;
.image_2 {
margin: 9rpx 0 9rpx 15rpx;
width: 10rpx;
height: 18rpx;
}
}
}
.line-tabs {
width: 750rpx;
padding-bottom: 20rpx;
.group_10 {
position: sticky;
top: 128rpx;
z-index: 10;
padding: 20rpx 38rpx;
background-color: rgb(255, 255, 255);
.section_2 {
margin-top: 18rpx;
background-color: rgb(0, 122, 255);
border-radius: 3rpx;
width: 80rpx;
height: 6rpx;
}
.text_7 {
margin-right: 32rpx;
color: rgb(51, 51, 51);
font-size: 28rpx;
line-height: 40rpx;
white-space: nowrap;
}
}
.section_3 {
margin: 20rpx 32rpx 0rpx;
padding: 26rpx 0 25rpx 24rpx;
filter: drop-shadow(0px 11rpx 23.5rpx #00000014);
background-color: rgb(255, 255, 255);
border-radius: 10rpx;
.image_5 {
margin-right: 24rpx;
width: 638rpx;
height: 390rpx;
}
.group_13 {
color: rgb(0, 0, 0);
font-size: 32rpx;
font-weight: 600;
line-height: 45rpx;
white-space: nowrap;
.text_8 {
align-self: center;
}
}
.text_9 {
margin-right: 40rpx;
color: rgb(51, 51, 51);
font-size: 26rpx;
line-height: 32rpx;
text-align: left;
}
}
}
}
.image_6 {
position: fixed;
bottom: 160rpx;
right: 32rpx;
box-shadow: 0px 2rpx 4rpx 0px rgba(0, 0, 0, 0.12);
border-radius: 50%;
width: 82rpx;
height: 82rpx;
}
}
.observer {
width: 100%;
display: flex;
align-self: center;
justify-content: center;
padding: 20rpx 32rpx 20rpx;
color: rgb(130, 132, 138);
font-size: 32rpx;
}
.header {
padding: 59rpx 35rpx 21rpx 38rpx;
background-color: rgb(255, 255, 255);
border-bottom: solid 1rpx rgb(221, 221, 221);
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
height: 128rpx;
.text {
color: rgb(0, 0, 0);
font-size: 36rpx;
font-weight: 500;
line-height: 50rpx;
white-space: nowrap;
}
.group_1 {
margin: 7rpx 0 6rpx;
color: rgb(51, 51, 51);
font-size: 24rpx;
line-height: 33rpx;
white-space: nowrap;
.text_1 {
margin-bottom: 3rpx;
}
.image {
margin-left: 14rpx;
width: 37rpx;
height: 37rpx;
}
}
}
</style>