<template>
	<view class="gather">
		<block v-if="isShow">
			<view class="special_work com" v-if="userInfoData.mer_info.type_id === 12">
				<view class="special_work com" v-if="true">
					<view class="title">市级供应链</view>
					<view class="content">
						<view class="examine"
							@click="navigator(`/pages/nongKe/supply_chain/goods_list?merid=${mer_id}`)">
							<image class="icon_img" :src="`${prefix}zsgl.png`" mode="aspectFill"></image>
							<text class="text">在售管理</text>
						</view>
						<view class="examine"
							@click="navigator(`/pages/admin/order/index?mer_id=${mer_id}&product_type=98&type_id=${userInfoData.mer_info.type_id}`)">
							<image class="icon_img" :src="`${prefix}cwgl.png`" mode="aspectFill"></image>
							<text class="text">财务管理</text>
						</view>
						<view class="examine"
							@click="navigator(`/pages/nongKe/gather/select_warehouse?mer_id=${mer_id}&stype=1`)">
							<image class="icon_img" :src="`${prefix}rkgl.png`" mode="aspectFill">
							</image>
							<text class="text">入库管理</text>
						</view>
						<view class="examine"
							@click="navigator(`/pages/product/basicSet?mer_id=${mer_id}&product_type=98`, '商户设置')">
							<image class="icon_img" :src="`${prefix}shsz.png`" mode="aspectFill"></image>
							<text class="text">商户设置</text>
						</view>
						<view class="examine" @click="navigator(`/pages/product/list/index?mer_id=${mer_id}`)">
							<image class="icon_img" :src="`${prefix}spgl.png`" mode="aspectFill">
							</image>
							<text class="text">商品管理</text>
						</view>
						<view class="examine" @click="navigator(`/pages/users/embody/embody?mer_id=${mer_id}`)">
							<image class="icon_img" :src="`${prefix}txgl.png`" mode="aspectFill">
							</image>
							<text class="text">提现管理</text>
						</view>
						<view class="examine"
							@click="navigator(`/pages/admin/order_cancellation/index?mer_id=${mer_id}`)">
							<image class="icon_img" :src="`${prefix}ddhx.png`" mode="aspectFill">
							</image>
							<text class="text">订单核销</text>
						</view>
						<!-- <view class="examine" @click="navigator(`/pages/nongKe/teach_video/teach_video`)">
							<image class="icon_img"
								src="https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/spjs.png" mode="aspectFill">
							</image>
							<text class="text">视频教学</text>
						</view> -->
						<!-- <view class="examine" @click="navigator(`/pages/users/user_invoice_Finance/index?mer_id=${mer_id}`)">
						<image class="icon_img" src="@/static/images/cwgk.png" mode="aspectFill">
						</image>
						<text class="text">财务公开</text>
					</view> -->
						<!-- <view class="examine" @click="navigator(`/pages/admin/order/index?mer_id=${mer_id}`)">
						<image class="icon_img" :src="`${prefix}ddgl.png`" mode="aspectFill">
						</image>
						<text class="text">订单管理</text>
					</view> -->
					</view>
				</view>
			</view>

			<view class="business com" v-if="userInfoData.mer_info.type_id === 10">
				<view class="business com" v-if="true">
					<view class="special_work com">
						<view class="title">我的店铺</view>
						<view class="content ">
							<view class="examine"
								@click="navigator(`/pages/users/supply_procurement/index?type_id=12&isDetail=1&product_type=98&cate_id=${userInfoData.mer_info.category_id}`)">
								<!-- @click="navigator(`/pages/nongKe/supply_chain/supplier?type_id=12&isDetail=1&product_type=98&cate_id=${userInfoData.mer_info.category_id}`) -->
								<image class="icon_img" :src="`${prefix}ghcg.png`" mode="aspectFill"></image>
								<text class="text">供货采购</text>
							</view>
							<view class="examine"
								@click="navigator('/pages/users/order_list/indexCopy?status=-1&product_type=98')">
								<image class="icon_img" :src="`${prefix}jhgl.png`" mode="aspectFill"></image>
								<text class="text">进货管理</text>
							</view>
							<view class="examine" @click="navigator(`/pages/admin/stockOut/index?mer_id=${mer_id}`)">
								<image class="icon_img" :src="`${prefix}smck.png`" mode="aspectFill">
								</image>
								<text class="text">扫码出库</text>
							</view>
							<view class="examine"
								@click="navigator(`/pages/nongKe/gather/select_warehouse?mer_id=${mer_id}&stype=2`)">
								<image class="icon_img" :src="`${prefix}rkgl.png`" mode="aspectFill">
								</image>
								<text class="text">入库管理</text>
							</view>
							<view class="examine" @click="navigator(`/pages/users/embody/embody?mer_id=${mer_id}`)">
								<image class="icon_img" :src="`${prefix}txgl.png`" mode="aspectFill">
								</image>
								<text class="text">提现管理</text>
							</view>

							<view class="examine"
								@click="navigator(`/pages/chat/customer_list/index?type=1&mer_id=${mer_id}`)">
								<image class="icon_img" :src="`${prefix}kfjl.png`" mode="aspectFill">
								</image>
								<text class="text">客服记录</text>
							</view>
							<view class="examine"
								@click="navigator(`/pages/admin/order_cancellation/index?mer_id=${mer_id}`)">
								<image class="icon_img" :src="`${prefix}ddhx.png`" mode="aspectFill">
								</image>
								<text class="text">订单核销</text>
							</view>
							<view class="examine"
								@click="navigator(`/pages/admin/order/index?mer_id=${mer_id}&type_id=${userInfoData.mer_info.type_id}`)">
								<image class="icon_img" :src="`${prefix}ddgl.png`" mode="aspectFill">
								</image>
								<text class="text">订单管理</text>
							</view>
							<view class="examine" @click="navigator(`/pages/product/list/index?mer_id=${mer_id}`)">
								<image class="icon_img" :src="`${prefix}spgl.png`" mode="aspectFill">
								</image>
								<text class="text">商品管理</text>
							</view>
							<view class="examine"
								@click="navigator(`/pages/product/basicSet?mer_id=${mer_id}`, '商户设置')">
								<image class="icon_img" :src="`${prefix}shsz.png`" mode="aspectFill">
								</image>
								<text class="text">商户设置</text>
							</view>
							<!-- 	<view class="examine"
								@click="navigator(`/pages/users/trading_hall/index?mer_id=${mer_id}`)">
								<image class="icon_img" src="@/static/images/diaohuo.png" mode="aspectFill">
								</image>
								<text class="text">交易大厅</text>
							</view>
							<view class="examine"
								@click="navigator(`/pages/commissionedSales/index/index?mer_id=${mer_id}`)">
								<image class="icon_img" src="@/static/images/weituo.png" mode="aspectFill">
								</image>
								<text class="text">委托销售</text>
							</view>
							<view class="examine" @click="navigator(`/pages/releaseManagement/index?mer_id=${mer_id}`)">
								<image class="icon_img" src="@/static/images/fabu.png" mode="aspectFill">
								</image>
								<text class="text">发布管理</text>
							</view> -->
							<!-- <view class="examine" @click="navigator(`/pages/users/user_invoice_Finance/index?mer_id=${mer_id}`)">
							<image class="icon_img" src="@/static/images/cwgk.png" mode="aspectFill">
							</image>
							<text class="text">财务公开</text>
						</view> -->


						</view>
					</view>

					<!-- <gatherBusiness :userInfoData="userInfoData" /> -->
				</view>
			</view>

			<view class="business com" v-if="userInfoData.mer_info.type_id!=null&&userInfoData.mer_info.type_id === 11">
				<view class="business com" v-if="true">
					<view class="special_work com">
						<view class="title">里海云仓</view>
						<view class="content ">
							<view class="examine"
								@click="navigator(`/pages/nongKe/supply_chain/supplier?type_id=12&isDetail=1&product_type=98&cate_id=${userInfoData.mer_info.category_id}`)">
								<image class="icon_img" :src="`${prefix}ghcg.png`" mode="aspectFill"></image>
								<text class="text">供货采购</text>
							</view>
							<view class="examine" @click="navigator('/pages/users/order_list/index?status=-1')">
								<image class="icon_img" :src="`${prefix}jhgl.png`" mode="aspectFill"></image>
								<text class="text">进货管理</text>
							</view>
							<view class="examine" @click="navigator(`/pages/admin/stockOut/index?mer_id=${mer_id}`)">
								<image class="icon_img" :src="`${prefix}smck.png`" mode="aspectFill">
								</image>
								<text class="text">扫码出库</text>
							</view>
							<view class="examine"
								@click="navigator(`/pages/nongKe/gather/select_warehouse?mer_id=${mer_id}&stype=2`)">
								<image class="icon_img" :src="`${prefix}rkgl.png`" mode="aspectFill">
								</image>
								<text class="text">入库管理</text>
							</view>
							<view class="examine" @click="navigator(`/pages/users/embody/embody?mer_id=${mer_id}`)">
								<image class="icon_img" :src="`${prefix}txgl.png`" mode="aspectFill">
								</image>
								<text class="text">提现管理</text>
							</view>

							<view class="examine"
								@click="navigator(`/pages/chat/customer_list/index?type=1&mer_id=${mer_id}`)">
								<image class="icon_img" :src="`${prefix}kfjl.png`" mode="aspectFill">
								</image>
								<text class="text">客服记录</text>
							</view>
							<view class="examine"
								@click="navigator(`/pages/admin/order_cancellation/index?mer_id=${mer_id}`)">
								<image class="icon_img" :src="`${prefix}ddhx.png`" mode="aspectFill">
								</image>
								<text class="text">订单核销</text>
							</view>
							<view class="examine"
								@click="navigator(`/pages/admin/order/index?mer_id=${mer_id}&type_id=${userInfoData.mer_info.type_id}`)">
								<image class="icon_img" :src="`${prefix}ddgl.png`" mode="aspectFill">
								</image>
								<text class="text">订单管理</text>
							</view>
							<view class="examine" @click="navigator(`/pages/product/list/index?mer_id=${mer_id}`)">
								<image class="icon_img" :src="`${prefix}spgl.png`" mode="aspectFill">
								</image>
								<text class="text">商品管理</text>
							</view>
							<view class="examine"
								@click="navigator(`/pages/product/basicSet?mer_id=${mer_id}`, '商户设置')">
								<image class="icon_img" :src="`${prefix}shsz.png`" mode="aspectFill">
								</image>
								<text class="text">商户设置</text>
							</view>
							<!-- <view class="examine" @click="navigator(`/pages/users/user_invoice_Finance/index?mer_id=${mer_id}`)">
							<image class="icon_img" src="@/static/images/cwgk.png" mode="aspectFill">
							</image>
							<text class="text">财务公开</text>
						</view> -->

						</view>
					</view>
				</view>
			</view>



		</block>
		<!-- <m-tabbar native>
      <template v-slot:tabbar_index_2>
        <view class="custom_style">
          <view class="custom_style_icon"></view>
        </view>
      </template>
    </m-tabbar> -->
		<view class="" v-if='jurisdiction==false&&isShow==false'>
			<emptyPage title="暂无信息"></emptyPage>
		</view>

	</view>
</template>

<script>
	import mTabbar from '@/components/m-tabbar/m-tabbar.vue'
	import emptyPage from '@/components/emptyPage.vue';
	import zbpSwiper from '@/components/zbpSwiper'
	import {
		mapState,
		mapGetters
	} from 'vuex'
	import {
		getWorkArticleCount,
		getSlideAPI
	} from '@/api/article.js'
	import {
		getStoreList,
		getUserInfo
	} from '@/api/user.js'
	import {
		getGeocoder,
		microSeachBarCode,
		microEadtProduct
	} from '@/api/store.js'
	import {
		Toast
	} from '@/libs/uniApi';
	import {
		getDiy
	} from '@/api/api.js'
	
	export default {
		components: {
			mTabbar,
			zbpSwiper,
			emptyPage
		},
		data() {
			return {
				locationArr: ({}),
				emptyText: '暂无可用应用',
				jurisdiction: false, // 是否有权限
				mer_id: '',
				userInfoData: {
					mer_info: {
						type_id: 0
					}
				},
				prefix: 'https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/11/',
				isShow: false,
				bgColor: '',
				isFshow: false,
				street:''
			};
		},
		computed: {
			...mapGetters(['userInfo', 'location', 'isLogin'])
		},
		created() {},
		onLoad() {},
		onShow() {
			if (this.isLogin) {
				this.emptyText = '暂无可用应用'
				this.jurisdiction = false
			} else {
				this.emptyText = '请登录'
				this.jurisdiction = true
			}
			this.getUserInfo()
			this.appLocation()
		},
		onPullDownRefresh() {
			this.getUserInfo()
			uni.stopPullDownRefresh()
		},
		mounted() {
			this.appLocation()
			// #ifdef  H5
// 监听页面滚动事件
			window.addEventListener("scroll", this.scrolling);
			// #endif
			

		},
		// #ifdef APP-PLUS
		onPageScroll(e) {
			// this.scrollTop = e.scrollTop;
			console.log(e.scrollTop)
			if (e.scrollTop > 0) {
				this.isFshow = true
			} else {
				this.isFshow = false
			}

		},
		// #endif

		methods: {
      
      
      appLocation() {
				uni.getLocation({
					type: 'wgs84',
					timeout: '10',
					success: (res) => {
						// console.log(res)

						let latitude, longitude;
						latitude = res.latitude.toString();
						longitude = res.longitude.toString();
						getGeocoder({
							lat: latitude,
							long: longitude
						}).then(res => {
							this.street = res.data.address_component.street
							Cache.set('ADRESS_LOCATION', this.street)
						}).catch(err => {
							uni.showToast({
								title: err,
								icon: 'none'
							})
						})
					},
					fail: (err) => {

						uni.showToast({
							title: "获取定位超时",
							icon: 'none',
							duration: 2000
						});
					}
				});
			},
			
			scrolling() {
				// 滚动条距文档顶部的距离
				let scrollTop =
					window.pageYOffset ||
					document.documentElement.scrollTop ||
					document.body.scrollTop;
				// 滚动条滚动的距离
				let scrollStep = scrollTop - this.oldScrollTop;
				console.log("header 滚动距离 ", scrollTop);
				// 更新——滚动前,滚动条距文档顶部的距离
				this.oldScrollTop = scrollTop;

				//变量windowHeight是可视区的高度
				let windowHeight =
					document.documentElement.clientHeight || document.body.clientHeight;
				//变量scrollHeight是滚动条的总高度
				let scrollHeight =
					document.documentElement.scrollHeight || document.body.scrollHeight;

				//滚动条到底部的条件
				if (scrollTop + windowHeight == scrollHeight) {
					//你想做的事情
					console.log("header  你已经到底部了");
				}
				if (scrollStep < 0) {
					this.isFshow = false
					console.log("header 滚动条向上滚动了!");
				} else {
					this.isFshow = true
					console.log("header  滚动条向下滚动了!");
				}
				// 判断是否到了最顶部
				if (scrollTop <= 0) {
					this.isFshow = false
					console.log("header 到了最顶部")
				}
			},

			kkchange(e) {
				this.bgColor = e
			},

			navigator(url, t) {
				// if (this.userInfoData.is_wsxx === 0 && t != '商户设置') return Toast("请完善商户信息");
				uni.navigateTo({
					url: url
				})
			},
			getUserInfo: function() {
				let that = this;
				getUserInfo().then(res => {
					that.userInfoData = res.data;
					// console.log(res.data.service);
					if (res.data.service == null) {
						// console.log('123');
						this.isShow = false
					} else {
						this.isShow = true
						this.mer_id = res.data.service.mer_id
					}

					if (!res.data.mer_info) {
						that.$set(this, 'jurisdiction', false);
					}
					// console.log(that.userInfoData);
				});
			}
		}
	};
</script>
<style lang="scss" scoped>
	.gather {
		padding-bottom: 164.91rpx;
		background: linear-gradient(180deg, #FFFFFF 0%, #F6F6F6 100%);
	}

	.bg-img {
		position: absolute;
		width: 100%;
		height: 100%;
		top: 0;
		/* #ifdef MP || APP-PLUS */
		z-index: -100;
		/* #endif */
		/* #ifdef H5 */
		z-index: -100;
		/* #endif */
		z-index: -100;
		filter: blur(0);
		overflow: hidden;


		img {
			width: 100%;
			height: 100%;
			filter: blur(30rpx);
			transform: scale(1.5);
		}
	}

	.site-box {
		width: 100%;
		height: 120rpx;
		margin-bottom: 26.32rpx;
		position: absolute;
		top: 0rpx;
		position: fixed;
		z-index: 999;
		padding-top: 30rpx;
		padding-right: 20rpx;

		// 位置
		.place_wrapper {
			color: #fff;
			margin-right: 24.56rpx;
			font-size: 30rpx;

			.town_name {
				margin-left: 21rpx;
			}
		}

		.iconfont {
			font-size: 35.09rpx;
		}
	}


	.top_box {
		// padding-top: 180rpx;
		background: linear-gradient(#36A2FF, #fff);
	}

	.com {
		margin-left: 50%;
		transform: translate(-50%);
	}

	.business {
		width: 694.74rpx;
		// margin-bottom: 175rpx;
	}

	.special_work {
		// padding: 17.54rpx;
		width: 694.74rpx;
		// margin-top: 52.63rpx;
    padding-top: 32rpx;
		border-radius: 17.54rpx;
		// box-shadow: 0px 0px 6px 1px rgba(0, 0, 0, 0.16);

		.title {
			font-size: 31.58rpx;
			font-weight: 700;
			margin-bottom: 38.6rpx;
		}

		.content {
			display: flex;
			align-content: center;
			flex-wrap: wrap;
			// justify-content: space-between;

			.examine {
				margin-bottom: 35rpx;
				width: 173.68rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				// margin: 0 0 33.33rpx 33.33rpx !important;

				.icon_img {
					width: 63.16rpx;
					height: 63.16rpx;
				}

				.text {
					font-size: 26.32rpx;
					margin-top: 21.05rpx;
					color: #000;
				}
			}

			.text {
				font-size: 29.82rpx;
				color: #a4a4a4;
			}
		}

		.cont_jus {
			margin-top: 56.14rpx;
			justify-content: flex-start;

			&:first-child {
				// margin-right: 33rpx;
			}

			.examine {
				margin-right: 48rpx;

				&:first-child {
					margin-right: 48rpx;
				}
			}
		}
	}
</style>