<template>
	<view>
		<view class="padding-top margin-lr">
			<swiper class="screen-swiper" style="height: 260rpx;" :circular="true" :autoplay="true" interval="2500"
				duration="800">
				<swiper-item v-for="(item,index) in swiperList" :key="index">
					<image :src="item.imageUrl" mode="aspectFit" class="radius"></image>
				</swiper-item>
			</swiper>
		</view>
		<view class="margin-top">
			<view class="listbox margin-lr" v-for="(item,index) in list" :key="index">
				<view class="flex align-center justify-between">
					<view>
						<view class="text-lg text-bold flex align-center" style="color: #333333;">{{item.companyName}}
							<u-icon @click="copy(item.companyName)" size="30" style="margin-left:10rpx;"
								name="https://zhaopin.xianmaxiong.com/file/uploadPath/2022/09/06/31556a48bfaec6406c0d45ada8e27970.png">
							</u-icon>
						</view>
						<view class=" margin-top-xs" style="color: #999999;font-size: 26upx;width: 90%;">
							{{item.companyScope}}</view>
					</view>
					<view style="position: relative;" @click="Changekefu">
						<image :src="item.companyLogo?item.companyLogo:'../../static/logo.png'"
							style="width: 100upx;height: 100upx;border-radius: 50%;">
						</image>
						<image src="../../static/images/index/phones.png" class="phone"></image>
					</view>
				</view>
				<view class="flex align-center margin-top">
					<image src="../../static/images/index/add.png" style="width: 26upx;height: 30upx;"></image>
					<view class="margin-left-sm text-bold" style="color: #121212;width: 90%;">{{item.companyAddress}}
					</view>
				</view>
				<view class="flex align-center margin-top">
					<image src="../../static/images/index/hez.png" style="width: 26upx;height: 28upx;"></image>
					<view class="margin-left-sm text-bold" style="color: #121212;">资质简介</view>
				</view>
				<view class="text-sm margin-top-xs margin-left-xl" style="color: #999999;">
					{{item.companyDetails}}
				</view>
			</view>
		</view>
		<empty v-if="list.length==0" />
	</view>
</template>

<script>
	import empty from '@/components/empty.vue'
	export default {
		components: {
			empty
		},
		data() {
			return {
				swiperList: [],
				page: 1,
				limit: 10,
				list: [],
				count: '',
			}
		},
		onLoad() {
			this.getBannerList()
			//合作企业列表
			this.getHezuoList();
		},
		onReachBottom() {
			if (this.list.length == this.count) {
				uni.showToast({
					title: '已经到底了',
					icon: 'none'
				})
			} else {
				this.page = this.page + 1;
				this.getHezuoList()
			}
		},
		methods: {
			copy(name) {
				uni.setClipboardData({
					data: name, // e是你要保存的内容
					success: function() {
						uni.showToast({
							title: '复制成功',
							icon: 'none'
						})
					}
				})
			},
			//联系客服
			Changekefu() {
				let that = this
				if(uni.getStorageSync('userType')==1){//用户端
					// #ifdef MP-WEIXIN
					wx.openCustomerServiceChat({
						extInfo: {
							url: that.$queue.getData('kefu')
						},
						corpId: that.$queue.getData('kefuAppid'),
						success(res) {
							console.log(res)
						},
					})
					// #endif
					// #ifdef H5
					window.location.href = that.$queue.getData('kefu');
					// #endif
					// #ifdef APP
					let kefu = that.$queue.getData('kefu')
					console.log(kefu)
					plus.runtime.openURL(kefu, function(res) {});
					// #endif
				}else{//企业端
					// #ifdef MP-WEIXIN
					wx.openCustomerServiceChat({
						extInfo: {
							url: that.$queue.getData('kefuq')
						},
						corpId: that.$queue.getData('kefuAppidq'),
						success(res) {
							console.log(res)
						},
					})
					// #endif
					// #ifdef H5
					window.location.href = that.$queue.getData('kefuq');
					// #endif
					// #ifdef APP
					let kefu = that.$queue.getData('kefuq')
					console.log(kefu)
					plus.runtime.openURL(kefu, function(res) {});
					// #endif
				}
			},
			//获取轮播图
			getBannerList() {
				this.$Request.get("/app/banner/selectBannerList", {
					classify: 1
				}).then(res => {
					if (res.code == 0) {
						this.swiperList = res.data
					}
				});
			},
			//合作企业列表
			getHezuoList() {
				this.$Request.get("/app/company/selectCompanyListByMember", {
					page: this.page,
					limit: this.limit
				}).then(res => {
					this.count = res.data.totalPage
					if (res.code == 0) {
						if (this.page == 1) {
							this.list = res.data.list
						} else {
							this.list = [...this.list, ...res.data.list]
						}
					}
				});
			},
		}
	}
</script>

<style>
	page {
		background: #F2F2F7;
	}

	.listbox {
		background: #FFFFFF;
		border-radius: 24upx;
		padding: 30upx;
		margin-bottom: 20rpx;
	}

	.phone {
		width: 40upx;
		height: 40upx;
		position: absolute;
		bottom: 0;
		right: 0;
		z-index: 9;
	}
</style>
