<template>
	<view class="content">

		<!-- <view style="background: linear-gradient(360deg, #FFFFFF 0%, #FFFFFF 0%, #F4F4F4 100%, #F4F4F4 100%);"> -->
		<view style="background-color:#FFFFFF">
			<view class="" style="margin-left: 25rpx;margin-right: 25rpx;">
				<view class="flex align-center padding-top-sm">
					<!-- <image src="../../static/back.png" style="width:5vw;height: 5vw;" @click.stop="closeWeb">
					</image> -->
					<view class="color-11 text-bold " style="font-size: 36rpx;flex: 1;">
						<view class="flex align-center" @click.stop="closeWeb">
							<image src="../../static/back.png" style="width:36rpx;height: 36rpx;margin-right: 16rpx;">
							</image>
							<text v-if="this.$bizType == 1">家政</text>
							<text v-if="this.$bizType == 2">维修</text>
						</view>

					</view>

					<view class="flex align-center" @click="openAddress">
						<u-image width="28rpx" height="28rpx" src="../../static/home_address_icon.png"></u-image>
						<text class="address_text" style="margin-left: 5rpx;">{{address}}</text>
						<u-image src="../../static/back_down.png"
							style="width:24rpx;height: 24rpx;margin-left: 10rpx;margin-bottom: 6rpx;">
						</u-image>
					</view>

				</view>
				<view class="flex align-center justify-between search_main" @click="gotoSearch">
					<view class="flex align-center">
						<u-image style="margin-left: 34rpx;" width="34rpx" height="34rpx"
							src="../../static/home_search_icon.png"></u-image>
						<text class="search_text" v-if="this.$bizType == 1">油烟机清洗</text>
						<text class="search_text" v-if="this.$bizType == 2">洗衣机维修</text>
					</view>
					<view class="search_button">搜索</view>
					<!-- <u-search @click="gotoSearch" bg-color="#ffffff" :disabled="true"  :show-action="false"></u-search> -->
				</view>
				<view class="wrap">
					<u-swiper :mode="list.length==1?'none':'dot'" border-radius="20" :list="list" name="urlImg" height="200" img-mode="widthFix">
					</u-swiper>
				</view>
				<view
					style="border-radius: 20rpx; overflow: hidden; margin-top: 20rpx;background-color: #FFFFFF;box-shadow: 0px 0px 28rpx 0px #242F3E10;">
					<u-grid :col="4" style="padding-bottom: 15rpx;">
						<u-grid-item v-for="(item,index) in tabHomeList" :key='index' :custom-style="gridStyle"
							@tap="onCateClick(index)">
							<image :src="item.icon" style="width: 100rpx;height: 100rpx; border-radius: 100rpx;">
							</image>
							<view class="grid-text">{{item.categoryName}}</view>
						</u-grid-item>
					</u-grid>
				</view>
			</view>

		</view>
		<view class="flex"
			style="margin: 20rpx 25rpx;color: #778296 ;font-size: 24rpx;background-color: #F7F8F9;padding: 26rpx 31rpx;border-radius: 20rpx;">
			<view class="" style="flex: 1;">
				<text>支付金额由优鲜信托管，服务不满意，可申请退款，1小时内受理。服务热线时间：8:00-20:00</text>
			</view>
			<view class="" style="width: 2rpx;height: 60rpx;background: #DDDDDD;margin:0 20rpx;">
			</view>
			<view class="flex align-center" @click.stop="hotPhone">
				<u-image src='../../static/phone_index.png' width="28" height="28" style="margin-right: 10rpx;">
				</u-image>
				<text style="color: #F59A23;">投诉</text>
			</view>
			<!-- <a class="flex align-center " :href="'tel:'+complaintHotline" style="text-decoration: none;">

				<image src='../../static/phone_index.png'style="width: 28rpx;height: 28rpx;margin-right: 10rpx;">
				</image>
				<text style="color: #F59A23;">投诉</text>
			</a> -->
		</view>

		<view v-if="videoList.length>0" class="bg-f8">
			<view style="padding-left: 26rpx;padding-right: 25rpx;padding-top: 20rpx;padding-bottom: 20rpx;background: linear-gradient(180deg, #ffffff 0%, #f8f8f8 100%);"
				class="flex align-center justify-between bg-ff">
				<text class="server_title">百科视频</text>
                <view class="flex align-center" @tap="toVideoList()">
                    <span class="color-66">更多</span>
                    <image src='../../static/icon/next1.png' style="width:10rpx;height:20rpx;margin-left:16rpx;"></image>
                </view>
			</view>
			<view class="flex align-center padding-bottom" style="padding-left:12rpx;">
				<view v-for="item in videoList" :key="item.videoId" class="video-box bg-ff" @tap="toVideoList(item.videoId,item.parentId,item.videoCategoryId)">
					<view style="position: relative;">
                        <image :src='item.videoFaceUrl' class="video-img"  mode="scaleToFill"></image>
                        <image src='../../static/video.png' class="video-play-position"></image>
                    </view>
                    <view class="padding-tb" style="padding-left:16rpx;padding-right:16rpx;">
                        <view style="color:#282828;min-height:70rpx;" class="text-bold flex-sub break-word wb_hide_2 margin-bottom-sm">{{item.videoDesc}}</view>

                        <view class="flex align-center" style="color:#868686;font-size:22rpx;" v-if="$isNull(item.serverId)" >
                            <image :src='item.merchantAvatar' style="width:34rpx;height:34rpx;margin-right:20rpx;border-radius:50%;" v-if="!$isNull(item.merchantAvatar)"></image>
                            <image src="../../static/defalut_avatar_index.png" style="width:34rpx;height:34rpx;margin-right:20rpx;border-radius:50%;" v-else></image>
                            <view style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;max-width: 170rpx;" class="flex-sub">{{item.merchantName}}</view>
                        </view>
                        <view class="flex align-center" style="color:#868686;font-size:22rpx;" v-else>
                            <image :src='item.serverAvatar' style="width:34rpx;height:34rpx;margin-right:20rpx;border-radius:50%;" v-if="!$isNull(item.serverAvatar)"></image>
                            <image src="../../static/defalut_avatar_index.png" style="width:34rpx;height:34rpx;margin-right:20rpx;border-radius:50%;" v-else></image>

                            <view style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;max-width: 170rpx;" class="flex-sub">{{item.serverName}}</view>
                        </view>

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

		<view class="bg-index">
			<view style="margin-left: 54rpx;margin-right: 25rpx;padding-top: 20rpx;padding-bottom: 20rpx;"
				class="flex align-center justify-between ">
				<text class="server_title">热门服务</text>
				<view class="flex align-center">
                    <view
						:class="{'selected_server_type':serverType ==1,'unselected_server_type':serverType ==0 || serverType ==2}"
						@click="selectServer(1)">
						商家
					</view>
					<view v-if="bizType ==1" :class="{'selected_server_type':serverType ==2,'unselected_server_type':serverType ==1 || serverType ==0}"
						@click="selectServer(2)" style="margin-left: 18rpx;">
						团购服务
					</view>
					<view style="margin-left: 18rpx;" 
						:class="{'selected_server_type':serverType ==0,'unselected_server_type':serverType ==1 || serverType ==2 }"
						@click="selectServer(0)">
						预订服务
					</view>
					
				</view>
			</view>
			
			<view class="padding-lr">
				<!-- <view class="bg-ff tab" style="height:120rpx; padding-left: 10rpx;border-radius:20rpx 20rpx 0 0;">
					<u-sticky offset-top="0" @fixed="tabFixed=true" @unfixed="tabFixed=false" h5-nav-height="0">
						<u-tabs-swiper active-color="#111111" inactive-color="#111111" ref="uTabs" bg-color="#fff"
							:bar-style="barStyle" :list="homeList" :is-scroll="true" :current="tabCurrent"
							swiperWidth="700" height="80" name="categoryName" count ="goodsCount" :overflowCount="9999" :showZero="true"  @change="tabChange">
						</u-tabs-swiper>
					</u-sticky>
				</view> -->
                <view class="bg-ff tab" style="height:90rpx; padding-left: 10rpx;border-radius:10rpx 10rpx 0 0;">
					<u-sticky offset-top="0" @fixed="tabFixed=true" @unfixed="tabFixed=false" h5-nav-height="0">
						<u-tabs-swiper active-color="#111111" inactive-color="#111111" ref="uTabs" bg-color="#fff"
							:bar-style="barStyle" :list="homeList" :is-scroll="true" :current="tabCurrent"
							swiperWidth="700" height="90" name="categoryName" @change="tabChange">
						</u-tabs-swiper>
					</u-sticky>
				</view>
				<swiper style="height: calc(100vh - 100rpx); " :current="swiperCurrent" @transition="transition"
					@animationfinish="animationfinish" :style="{'background':serverType==2 && bizType ==1?'#f6f6f6':''}">
					<swiper-item class="swiper-item" v-for="(item, index) in homeList" :key="index+'s'" :class="serverType==2?'bf-f6':'bg-ff'">   
						<scroll-view :scroll-y="tabFixed" style="height: 100%" id="mySwiper" @scrolltolower='scrolltolower(index)'>

							<view v-if="serverType ==0" class="padding-bottom">
                                <view @click="gotoDetails(contentItem)" v-for="(contentItem,index1) in serveList[swiperCurrent].childList" :key="index1+'v'" class="flex align-start"
								style="margin-left: 25rpx;margin-right: 25rpx;" :class="serverType==0?'margin-top-lg':''">
                                    <view style="position: relative;">
                                        <view v-if="serverType==0" :class="{'presonal_auth':contentItem.merchantType == 1, 'company_auth':contentItem.merchantType ==0}"
                                            style="position: absolute; top: 0;left: 0;z-index: 2;">
                                            {{contentItem.merchantType == 1?"个人认证":"企业认证"}}
                                        </view>

                                        <image style="width: 240rpx; height: 180rpx; border-radius: 10rpx;" mode="aspectFill" v-if="!$isNull(contentItem.serverImgUrl)"
                                        :src="contentItem.serverImgUrl"></image>

                                        <image style="width: 240rpx; height: 180rpx; border-radius: 10rpx;" mode="aspectFill" v-if="contentItem.goodsImageList[0].type=='001'&&$isNull(contentItem.serverImgUrl)"
                                        :src="contentItem.goodsImageList[0].url"></image>
                                        <image style="width: 240rpx; height: 180rpx; border-radius: 10rpx;" mode="aspectFill" v-if="contentItem.goodsImageList[0].type=='002'&&$isNull(contentItem.serverImgUrl)"
                                        :src="contentItem.goodsImageList[0].url+'?x-oss-process=video/snapshot,t_1000,f_jpg,w_0,h_0,m_fast,ar_auto'"></image>
                                        <image src='../../static/video.png' class="video-play-position" v-if="contentItem.goodsImageList[0].type=='002'&&$isNull(contentItem.serverImgUrl)"></image>

                                    </view>
                                    <view class="flex-sub padding-right">
                                        <view style="margin:0 0 24rpx 20rpx; width: 100%; display: flex;flex-direction: column;justify-content: space-between;word-break:break-all">
                                            <view>
                                                <view class="wb_hide_2 content_text font-weight6" v-if="serverType==0">{{contentItem.name}}</view>
                                                
                                                <view style="margin-top: 15rpx;" class="flex align-center" v-if="serverType==0">
                                                    <view class="age_tag"> {{contentItem.serverAge}}年工龄</view>
                                                    <view class="content_comment" v-if="contentItem.rate>0">好评率{{contentItem.rate}}%</view>
                                                </view>

                                                <view class="" style="margin-top: 10rpx;display: flex;justify-content: space-between;" v-if="serverType==0">
                                                    <view class="flex flex-sub align-center">
                                                        <text style="color: #111111; font-size: 24rpx;" class="break-word">{{contentItem.realName}}</text>
                                                        <text v-if="contentItem.serverLevel == '001'" class="flex-sub" style="color: #D09A6C; font-size: 24rpx;margin-left: 20rpx;min-width:100rpx;">初级家政</text>
                                                        <text v-else-if="contentItem.serverLevel == '002'" class="flex-sub" style="color: #D09A6C; font-size: 24rpx;margin-left: 20rpx;min-width:100rpx;">中级家政</text>
                                                        <text v-else-if="contentItem.serverLevel == '003'" class="flex-sub" style="color: #D09A6C; font-size: 24rpx;margin-left: 20rpx;min-width:100rpx;">高级家政</text>
                                                        <text v-else-if="contentItem.serverLevel == '004'" class="flex-sub" style="color: #D09A6C; font-size: 24rpx;margin-left: 20rpx;min-width:100rpx;">金牌家政</text>
                                                    </view>
                                                    <view style="margin-top:10rpx;" class="flex justify-end align-center color-ff0">
                                                        <span class="text-sm font-weight5">￥</span>
                                                        <span class="font-weight5 text-lg" style="margin-right:6rpx;">{{contentItem.goodsServerPrice}}</span>
                                                        <span class="font-26">/{{contentItem.goodsUnit == "999"?contentItem.otherUnit:contentItem.goodsUnitName}}</span>
                                                    </view>
                                                </view>
                                            </view>
                    
                                            <view style="margin-top: 0rpx;" v-if="contentItem.merchantType!=1&&serverType==0">
                                                <text style="font-size: 22rpx;color: #999999;" class="wb_hide_2">{{contentItem.merchantName}}</text>
                                            </view>
                                        </view>
                                       
                                    </view>
                                </view>
                                
                            </view>

                            <view v-if="serverType ==1" class="padding-bottom">
                                <view @click="gotoDetails(contentItem)" v-for="(contentItem,index1) in shopList[swiperCurrent].childList" :key="index1+'v'" class="flex align-start"
								style="margin-left: 25rpx;margin-right: 25rpx;">
                                    <view style="position: relative;" :style="{height:serverType==1?'254rpx':''}" :class="serverType==1?'flex align-center':''">
                                        <image style="width: 240rpx; height: 180rpx; border-radius: 10rpx;" mode="aspectFill" :src="contentItem.avatar"></image>
                                    </view>
                                    <view class="flex-sub padding-right">
                                        <view style="margin:0 0 24rpx 20rpx; width: 100%; display: flex;flex-direction: column;justify-content: space-between;word-break:break-all">
                                            <view :class="serverType==1?'margin-top-lg':''">
                                                <view class="wb_hide_2 content_text font-weight6" v-if="serverType==1">{{contentItem.merchantName}}</view>

                                                <view style="margin-top: 15rpx;" class="flex align-center justify-between" v-if="serverType==1">
                                                    <view class="age_tag"> {{contentItem.storeAge}}年店龄</view>
                                                    <view style="color:#999;" class="text-sm">成交{{contentItem.sales}}单</view>
                                                </view>

                                                <view style="margin-top: 15rpx;" class="flex align-center justify-between" v-if="serverType==1">
                                                    <view style="color:#FF481E;font-size:22rpx;" v-if="contentItem.score != '' && contentItem.score > 0"> 综合评分： <span style="font-size: 24rpx;" class="text-bold">{{contentItem.score}}</span> </view>
                                                    <view class="content_comment" v-if="contentItem.rate>0">好评率{{contentItem.rate}}%</view>
                                                </view>

                                            </view>
                    
                                        </view>
                                        <view style="margin-left: 20rpx; width: 100%;" v-if="serverType==1">
                                            <view v-for="(good,goodIndex) in contentItem.goodsList" :key="goodIndex+'g'">
                                                <view v-if="goodIndex<2" style="border-top: 2rpx solid #eee;" class="padding-top-sm" @tap.stop="serveDetail(good,good.isGroupGoods)">
                                                    <view class="flex align-center">
                                                        <image src="../../static/group.png" style="width:36rpx;height:36rpx;left:0;top:0;margin-right:10rpx;" v-if="good.isGroupGoods==1"></image>
                                                        <image src="../../static/reserve.png" style="width:36rpx;height:36rpx;left:0;top:0;margin-right:10rpx;" v-if="good.isGroupGoods==0&&$bizType == 1"></image>
                                                        <view style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;max-width: 310rpx;">{{good.name}}</view>
                                                    </view>
                                                    <view class="flex align-center" style="margin: 18rpx 0;" v-if="good.isGroupGoods==1">
                                                        <view style="" class="font-weight5 text-lg color-ff0 flex align-center">
                                                            <span class="text-sm">￥</span>
                                                            <span>{{good.currentPrice}}</span>
                                                        </view>
                                                        <view style="margin-left: 16rpx; text-decoration:line-through;color: #999;font-size: 26rpx; text-align: left;">
                                                            <span>￥</span>{{good.scribingPrice}}
                                                        </view>
                                                    </view>
                                                    <view style="margin: 18rpx 0;" class="flex text-lg color-ff0 align-center flex-sub" v-if="good.isGroupGoods==0">
                                                        <span class="text-sm font-weight5">￥</span>
                                                        <span class="font-weight5" style="margin-right:8rpx;">{{good.goodsServerPrice}}</span>
                                                        <span style="font-size: 26rpx;">/{{good.goodsUnit == "999"?good.otherUnit:good.goodsUnitName}}</span>
                                                    </view>
                                                </view>
                                            </view>
                                        </view>
                                    </view>
                                </view>
                                
                            </view>

                            <view v-if="serverType==2 && bizType ==1&&groupList[swiperCurrent].childList.length!=0" class="padding-bottom">
                                <u-waterfall v-model="groupList[swiperCurrent].childList" ref="waterfallsFlow" style="padding-left:18rpx;background:#f6f6f6;">
                                    <template v-slot:left="{leftList}">                  
                                        <view @click="gotoDetails(item)" class="demo-warter" v-for="(item, index) in leftList" :key="index">
                                            <view style="position: relative;">
                                                <u-lazy-load threshold="-450" borderRadiusLRTB="20rpx 20rpx 0 0" :height="260" img-mode="aspectFill" v-if="item.goodsImageList[0].type=='001'" loading-img="../../static/lazy-loading.png"
                                                :image="item.goodsImageList[0].url" :index="index"></u-lazy-load>

                                                <u-lazy-load threshold="-450" borderRadiusLRTB="20rpx 20rpx 0 0" :height="260" img-mode="aspectFill" v-if="item.goodsImageList[0].type=='002'" loading-img="../../static/lazy-loading.png"
                                                :image="item.goodsImageList[0].url+'?x-oss-process=video/snapshot,t_1000,f_jpg,w_0,h_0,m_fast,ar_auto'" :index="index"></u-lazy-load>
                                                <image src='../../static/video.png' class="video-play-position" v-if="item.goodsImageList[0].type=='002'"></image>
                                            </view>
                                            
                                            <view class="padding-lr-sm padding-bottom">
                                                <view class="demo-title break-word wb_hide_2 font-weight6">
                                                    {{item.name}}
                                                </view>
                                                <view v-if="item.rate>0" style="margin-top: 20rpx;color:#FF0000; font-size: 22rpx;" class="flex align-center justify-center rate-box">
                                                    <view style=" text-align: left;">好评率</view>
                                                    <view style="margin-left:6rpx;margin-top:4rpx;">{{item.rate}}%</view>
                                                </view>
                                                <view style="margin-top: 20rpx;" class="flex align-center flex-wrap">
                                                    <view class="color-ff0 text-lg font-weight5 flex align-center">
                                                        <span class="text-sm">￥</span>
                                                        <span>{{item.currentPrice}}</span>
                                                    </view>
                                                    <view style="margin-left: 16rpx; text-decoration:line-through;color: #999;font-size: 26rpx; text-align: left;">
                                                        <span>￥</span>{{item.scribingPrice}}
                                                    </view>
                                                </view>
                                            </view>

                                        </view>
                                        
                                    </template>

                                    <template v-slot:right="{rightList}">
                                        <view @click="gotoDetails(item)" class="demo-warter" v-for="(item, index) in rightList" :key="index">
                                            <view style="position: relative;">
                                                <u-lazy-load threshold="-450" borderRadiusLRTB="20rpx 20rpx 0 0" :height="260" img-mode="aspectFill" v-if="item.goodsImageList[0].type=='001'" loading-img="../../static/lazy-loading.png"
                                                :image="item.goodsImageList[0].url" :index="index"></u-lazy-load>

                                                <u-lazy-load threshold="-450" borderRadiusLRTB="20rpx 20rpx 0 0" :height="260" img-mode="aspectFill" v-if="item.goodsImageList[0].type=='002'" loading-img="../../static/lazy-loading.png"
                                                :image="item.goodsImageList[0].url+'?x-oss-process=video/snapshot,t_1000,f_jpg,w_0,h_0,m_fast,ar_auto'" :index="index"></u-lazy-load>
                                                <image src='../../static/video.png' class="video-play-position" v-if="item.goodsImageList[0].type=='002'"></image>
                                            </view>
                                            <view class="padding-lr-sm padding-bottom">
                                                <view class="demo-title break-word wb_hide_2 font-weight6">
                                                    {{item.name}}
                                                </view>
                                                <view v-if="item.rate>0" style="margin-top: 20rpx;color:#FF0000; font-size: 22rpx;" class="flex align-center justify-center rate-box">
                                                    <view style=" text-align: left;">好评率</view>
                                                    <view style="margin-left:6rpx;margin-top:4rpx;">{{item.rate}}%</view>
                                                </view>
                                                <view style="margin-top: 20rpx;" class="flex align-center flex-wrap">
                                                    <view class="color-ff0 text-lg font-weight5 flex align-center">
                                                        <span class="text-sm">￥</span>
                                                        <span>{{item.currentPrice}}</span>
                                                    </view>
                                                    <view style="margin-left: 16rpx; text-decoration:line-through;color: #999;font-size: 26rpx; text-align: left;">
                                                        <span>￥</span>{{item.scribingPrice}}
                                                    </view>
                                                </view>
                                            </view>
                                        </view>
                                    </template>
                                </u-waterfall>
                            </view>

                            <view class="align-center padding-top" v-if="(serverType==0&&serveList[swiperCurrent].childList.length==0)||(serverType==1&&shopList[swiperCurrent].childList.length==0)||(serverType==2&&groupList[swiperCurrent].childList.length==0)">
                                <image src="../../static/nomore_icon.png" mode="" style="width: 370rpx;height: 370rpx;margin: 0 auto;" v-if="!emptyLoading"></image>
                                <view class="flex flex-direction align-center justify-center" style="width:100%" v-if="emptyLoading">
                                    <image src="../../static/empty-loading.png" mode="" style="width: 256rpx;height: 158rpx;margin-top:40rpx;"></image>
                                    <view style="color:#3A3A3A;font-size;34rpx;margin-top:46rpx;">加载中...</view>
                                </view>
                            </view>
			
						</scroll-view>
						
			
					</swiper-item>
				</swiper>
			</view>
			
			
		</view>
	</view>
 
</template>
<script>
	export default {
		data() {
			return {
				bizType:0,
				complaintHotline: '',
				gridStyle: {
					'padding': '15rpx 0'
				},
				activeitemstyle: {
					'font-size': '34rpx',
					'font-weight': 'blod'
				},
				barStyle: {
					'height': '14rpx',
					'background-color': 'transparent',
					'background-image': "url('../../static/tabbar_icon.png')",
					'background-size': '100% 100%',
                    'bottom': '6rpx'
                    // 'bottom': '36rpx'
				},
				topheight: -88,
				tabFixed: false,
				refresherStatus: false,
				address: '',
				title: 'Hello',
				tabCurrent: 0,
				swiperCurrent: 0,
				serverType: 1, // 0服务人员 1商家 2团购
				lastServerType: -1,
				list: [],
				templocation: {
					latitude: '',
					longitude: ''
				},
				tempObj:{},//flutter带来的参数

                isChangeTab: false,

                tabHomeList: [],
                homeList: [],
				groupList: [],
                serveList: [],
                shopList: [],

				videoList: [],
                emptyLoading: true,
			}
			
		},
		onLoad(options) {
			this.bizType = this.$bizType;

			this.getBannerList()
            // if(this.bizType ==1) {
            //     this.serverType = 2
            // }
			this.getCaregoryList()
			
			if(options.goodId && options.shopId && options.isPerson)
			{
				this.tempObj=options
			}

			this.getVideo();
				
		},
		onHide() {
			// this.serverType = 0
			// this.tabChange(0)
		},
		onShow() {
			this.address = uni.getStorageSync('addressName').title
			uni.removeStorageSync('channelPage')
            if(this.address==''||this.address==undefined) {
                this.getAddressLocation()
            }
            uni.$off('changeVideoClassify')
            
		},
		onReady() {
			if(this.tempObj.goodId && this.tempObj.shopId && this.tempObj.isPerson)
			{
				// alert(options.query.goodId)
				if(this.tempObj.isPerson === '1') //1是个人0是商家
				{
					uni.navigateTo({
						url: 'personDetails?goodsId='+this.tempObj.goodId+'&serverId='+this.tempObj.shopId+'&bizType='+this.$bizType+'&flag=true'
					})
				}else{
					uni.navigateTo({
						url: 'shopDetails?merchantId='+this.tempObj.merchantId+'&bizType='+this.$bizType+'&flag=true'
					})
				}
			}
		},
		onPullDownRefresh() {
			// this.lastServerType = -1
			this.homeList = []
            this.tabHomeList = []
            this.emptyLoading = true
			this.getCaregoryList()
            this.getVideo();
            this.getBannerList()
		},
		methods: {
			hotPhone() {
				uni.makePhoneCall({
					phoneNumber: this.complaintHotline
				});
			},
			// 点击分类
			onCateClick(index) {
				var data = this.tabHomeList[index];
				data.selectIndex = -1
				// console.log(data)
				uni.setStorageSync('channelPage', data)
				// var item = JSON.stringify(data)
				// console.log(data)
				uni.navigateTo({
					url: "../mine/minePage/channelPage"
				});
			},
			openAddress() {
				uni.navigateTo({
					url: '../mine/minePage/addressPage'
				})
			},
			getBannerList() {
				this.$u.api.getBannerList({
					'bizType': this.$bizType
				}).then(res => {
					if (res.code == 200) {
						this.list = res.data
						this.complaintHotline = this.list[0].complaintHotline
						uni.setStorageSync('complaintHotline',this.complaintHotline)
						console.log(res.data)
					}
				})
			},
			//scroll view 触底加载
			scrolltolower(index) {
                if(!this.isChangeTab)  {
                    this.isChangeTab = true;
                    console.log('scrolltolower')
                    this.getChannelContentList(index)
                }
				
			},
			rmFixed(e, ownI) {
				this.tabFixed = false
			},
            //初始化分类tab
			getCaregoryList() {
                let that = this;
                let goodType = ""
                // serverType: 1, // 0服务人员 1商家 2团购
                switch (that.serverType) {
                    case 0:
						goodType = 1;
					break;
                    case 1:
						goodType = 0;
					break;
                    case 2:
						goodType = 2;
					break;
                }
				this.$u.api.homeCountList({
					bizType: this.$bizType,
                    goodsType:goodType
				}).then(res => {
					// console.log(res,'categoryHomeList')
					if (res.code == 200) {
                        let obj = {
                            categoryId: "",
                            categoryName: "全部",
                            goodsCount: res.data.count
                        }
						this.homeList=[]
                        that.tabHomeList = []
                        that.tabHomeList = JSON.parse(JSON.stringify(res.data.list))
                        that.homeList = res.data.list;
                        that.homeList.unshift(obj)
                        that.groupList = [];
                        that.serveList = [];
                        that.shopList = [];
                        let arr = []
						this.homeList.forEach(function(element) {
                            let obj = {
                                childList: [],
                                pageNum: 1,
                                noMore: false,
                                categoryName: element.categoryName
                            }
                            arr.push(obj)
                            
						});
                        console.log(this.homeList)
                        that.groupList = JSON.parse(JSON.stringify(arr));
                        that.serveList = JSON.parse(JSON.stringify(arr))
                        that.shopList = JSON.parse(JSON.stringify(arr))
                        
						this.getChannelContentList(this.swiperCurrent);
					}
				}).catch(error => {
					console.log(error)
				})
			},
            //数据请求
			getChannelContentList(index) {
                
				// console.log(this.lastServerType, this.serverType,'kaishi ')
				var item = this.homeList[index];
				let that = this
                
				//   console.log(item)
				if (this.serverType == 0) {
                    if(that.serveList[index].noMore) return
					var param = {
						pageNum: that.serveList[index].pageNum,
						pageSize: 10,
						bizType: this.$bizType, //业务类型（1：家政；2：维修）
                        isGroupGoods: 0,
						// parentId: item.categoryId
					}
					if (item.categoryId) {
						param.parentId = item.categoryId
					}
					this.$u.api.seekCrewList(param).then(res => {
						if (res.code == 200) {
                            if(res.rows.length<10) {
                                that.serveList[index].noMore = true
                            } else {
                                that.serveList[index].noMore = false
                                that.serveList[index].pageNum ++
                            }
						
                        
                            that.serveList[index].childList = that.serveList[index].childList.concat(res.rows);
                            if(this.isChangeTab)  {
                                this.isChangeTab = false
                            }
							uni.stopPullDownRefresh()
							that.$forceUpdate()

						}
					}).catch(error => {

					}).finally(()=>{
                        that.emptyLoading = false
                    });
				} else if (this.serverType == 1) {
                    if(that.shopList[index].noMore) return
					var param = {
						pageNum: that.shopList[index].pageNum,
						pageSize: 10,
						bizType: this.$bizType, //业务类型（1：家政；2：维修）
						// parentId: item.categoryId
					}
					if (item.categoryId) {
						param.parentId = item.categoryId
					}

                    this.$u.api.seekMerchantMerchandiseList(param).then(res => {
						if (res.code == 200) {
                            if(res.rows.length<10) {
                                that.shopList[index].noMore = true
                            } else {
                                that.shopList[index].noMore = false
                                that.shopList[index].pageNum++
                            }
                            
                            that.shopList[index].childList = that.shopList[index].childList.concat(res.rows);
                            if(this.isChangeTab)  {
                                this.isChangeTab = false
                            }

							uni.stopPullDownRefresh()
							that.$forceUpdate()

						}
					}).catch(error => {

					}).finally(()=>{
                        that.emptyLoading = false
                    });
				}else if (this.serverType == 2) {
                    
                    if(that.groupList[index].noMore) return
                    
                    var param = {
                        pageNum: that.groupList[index].pageNum,
                        pageSize: 10,
                        bizType: this.$bizType, //业务类型（1：家政；2：维修）
                        isGroupGoods: 1,
                    }
                    if (item.categoryId) {
                        param.parentId = item.categoryId
                    }
                    
                    this.$u.api.seekCrewList(param).then(res => {
                        if (res.code == 200) {
                            if(res.rows.length<10) {
                                that.groupList[index].noMore = true
                            } else {
                                that.groupList[index].noMore = false
                                that.groupList[index].pageNum++
                            }
                            that.groupList[index].childList = that.groupList[index].childList.concat(res.rows);
                            if(this.isChangeTab)  {
                                this.isChangeTab = false
                            }
                                
                            uni.stopPullDownRefresh()
                            that.$forceUpdate()
                        }
                    }).catch(error => {

                    }).finally(()=>{
                        that.emptyLoading = false
                    });
													
				}
			 
			},
	

			getAddressLocation() {
				const that = this
				uni.getLocation({
					geocode: true,
					type: 'gcj02',
					success: function(res) {
						console.log(res, 'getAddressLocation')
						let location = [res.latitude, res.longitude]
						let StringLocation = location.toString()
						let url = 'https://apis.map.qq.com/ws/geocoder/v1?&output=jsonp';
						that.$jsonp(url, {
								key: '2KVBZ-JCJC5-WWCIG-QALQX-3HLMZ-A7FPF',
								location: StringLocation,
								get_poi: 1
							})
							.then(res => {
								// 获取附近地址赋值
								// console.log(res, 'res')
								let list = res.result.pois
								list.forEach(item => {
									item.address = item.address.substring(3)
								})
								const currentAddress = list[0]
								that.address = currentAddress.title
								uni.setStorageSync('addressName', currentAddress)
							})

					},

				})
			},
			onJump() {
				uni.navigateTo({
					url: '../codelogin/codelogin'
				})
			},
            //切换二级tab
			tabChange(index) {
                if(this.swiperCurrent==index) return
                
                this.isChangeTab = false;
                this.swiperCurrent = index;
                this.emptyLoading = true

                
			},
			// swiper-item左右移动，通知tabs的滑块跟随移动
			transition(e) {
				let dx = e.detail.dx;
				this.$refs.uTabs.setDx(dx);
			},
			// 由于swiper的内部机制问题，快速切换swiper不会触发dx的连续变化，需要在结束时重置状态
			// swiper滑动结束，分别设置tabs和swiper的状态
			animationfinish(e) {
                // console.log('滑滑划动')
				let current = e.detail.current;
				this.$refs.uTabs.setFinishCurrent(current);
				this.swiperCurrent = current;
				this.current = current;
				this.tabCurrent = current
                if(!this.isChangeTab)  {
                    // console.log('滑动请求数据数据数据')
                    this.getChannelContentList(current)
                }

                // if ((this.homeList[current].childList == undefined || this.homeList[current].childList.length <
				// 		1) && this.homeList[current].pageNum < 2) {
				// 	console.log('滑动结束',current,this.homeList[current].childList.length)
                //     // console.log(this.isChangeTab)
                //     if(!this.isChangeTab)  {
                //         // console.log('滑动请求数据数据数据')
                //         this.getChannelContentList(current)
                //     }
                    
				// }
            },

			gotoSearch() {
				uni.navigateTo({
					url: './search',
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			},
            //切换一级tab
			selectServer(index) {
                if(this.serverType==index) return
				this.serverType = index
                this.isChangeTab = true;
                this.emptyLoading = true
                // console.log('selectServerselectServerselectServer',this.swiperCurrent)
                this.getCaregoryList();
                


			},
			gotoDetails(obj) {
				uni.removeStorageSync('indexDetails')
				// console.log(obj)
				if (this.serverType == 0) {
					obj.bizType = this.$bizType
					uni.setStorageSync('indexDetails', obj)
					uni.navigateTo({
						url: './personDetails'
					})
				} else if (this.serverType == 1){
					obj.bizType = this.$bizType
					uni.setStorageSync('indexDetails', obj)
					uni.navigateTo({
						url: './shopDetails'
					})
				}else if (this.serverType == 2){
					obj.bizType = this.$bizType
					uni.setStorageSync('indexDetails', obj)
					uni.navigateTo({
						url: './groupDetails'
					})
				}

			},
            serveDetail(obj,isGroupGoods) {
                //  @tap.stop="serveDetail(good,good.isGroupGoods)"
                uni.removeStorageSync('indexDetails')
				// console.log(obj)
				if (isGroupGoods == 0) {
					obj.bizType = this.$bizType
					uni.setStorageSync('indexDetails', obj)
					uni.navigateTo({
						url: './personDetails'
					})
				} else if (isGroupGoods == 1){
					obj.bizType = this.$bizType
					uni.setStorageSync('indexDetails', obj)
					uni.navigateTo({
						url: './groupDetails'
					})
				}
            },
			closeWeb() {
				CloseWeb.postMessage("调用了fluter");
			},
			toVideoList(videoId,parentId,videoCategoryId) {
                if(this.$isNull(videoId)) {
                    uni.navigateTo({
                        url: `/pages/video/videoList?type=index`
                    })
                } else {
                    let id = ""
                    if(this.$isNull(parentId)) {
                        id = videoCategoryId
                    } else {
                        id = parentId
                    }
                    uni.navigateTo({
                        url: `/pages/video/videoList?videoId=${videoId}&type=index&parentId=${id}`
                    })
                }
				
			},
			//视频列表
			getVideo() {
				let that = this
				let params = {
					pageSize: 3,
					pageNum: 1,
					bizType: that.$bizType
				}
				this.$u.api.recommendVideoList(params).then(res => {
					if (res.code == 200) {
						// console.log(res)
						that.videoList = res.rows
					}
				}).catch(error => {
					console.log(error)
				})
			}
		}
	}
</script>
<style>
	page {
			background-color: #fff;
		}
</style>

<style lang="scss" scoped>
.tab {
    /deep/ .uni-scroll-view-content {
        border-radius: 26rpx !important;
        background: #fff;
    }
    /deep/ .u-tabs, /deep/ .u-sticky-wrap {
        background: none !important;
    }
    /deep/ .u-tabs-scroll-box {
        // padding-top: 24rpx !important;
        // padding-bottom: 10rpx;
    }
    /deep/ .u-tabs-item {
        // line-height: normal !important;
    }
}

/deep/ .u-badge {
    top: unset !important;
    right: unset !important;
    bottom: -4rpx !important;
    left: 0rpx !important;
    background: none !important;
    color: #FC6035 !important;
    font-size: 28rpx !important;
    width: 100%;
    padding: 0 20rpx;
}
/deep/ .diyColor {
    color: #111 !important;
}
 
    .bg-index {
		background-image: url(../../static/index-bg.png);
		background-size: 100%;
		background-repeat: no-repeat;
	}
	.address_text {
		font-size: 28rpx;
		// font-weight: bold;
		color: #111111;
	}

	.search_main {
		margin-top: 20rpx;
		height: 68rpx;
		border-radius: 100rpx;
		background-color: #FFFFFF;
		border: 1rpx solid #FC6035;
	}

	.search_button {
		margin-right: 5rpx;
		background-color: #FC6035;
		color: #FFFFFF;
		font-size: 30rpx;
		padding-top: 10rpx;
		padding-bottom: 10rpx;
		padding-left: 21rpx;
		padding-right: 21rpx;
		border-radius: 50rpx;
		margin-right: 6rpx;
	}

	.search_text {
		font-size: 28rpx;
		color: #999999;
		margin-left: 13rpx;
	}

	.wrap {
		margin-top: 20rpx;
	}

	.grid-text {
		padding-top: 10rpx;
		font-size: 24rpx;
		color: #333333;
	}

	.server_title {
		font-size: 36rpx;
		font-weight: bold;
		color: #111;
	}

	.selected_server_type {
		font-size: 26rpx;
        background: #FC6035;
		color: #fff;
		padding-bottom: 6rpx;
		padding-top: 6rpx;
		padding-left: 21rpx;
		padding-right: 21rpx;
		border-radius: 50rpx;

	}

	.unselected_server_type {
		font-size: 26rpx;
		color: #666666;
        background: #fff;
		padding-bottom: 6rpx;
		padding-top: 6rpx;
		padding-left: 21rpx;
		padding-right: 21rpx;
		border-radius: 50rpx;
	}

	.company_auth {
		// width: 98rpx;
		// height: 32rpx;
		padding: 4rpx 10rpx;
		background: linear-gradient(270deg, #009BF8 0%, #009BF8 0%, #97D5FF 100%, #97D5FF 100%);
		border-radius: 10rpx 0rpx 10rpx 0rpx;
		opacity: 1;
		color: #FFFFFF;
		text-align: center;
		font-size: 21rpx;
		// font-weight: bold;
	}

	.presonal_auth {
		// width: 98rpx;
		// height: 32rpx;
		padding: 4rpx 10rpx;
		background: linear-gradient(270deg, #FF6B00 0%, #FF6B00 0%, #FFB700 100%, #FFB700 100%);
		border-radius: 10rpx 0rpx 10rpx 0rpx;
		opacity: 1;
		color: #FFFFFF;
		text-align: center;
		font-size: 21rpx;
		// font-weight: bold;
	}

	.age_tag {
		// width: 98rpx;
		padding: 1rpx 10rpx;
		// height: 32rpx;
		background: linear-gradient(269deg, #E7C2A1 0%, #E7C2A1 0%, #F4EBE1 100%, #F4EBE1 100%);
		border-radius: 8rpx;
		opacity: 1;
		color: #885c4b;
		text-align: center;
		font-size: 22rpx;
	}

	.content_text {
		font-size: 30rpx;
		color: #111111;
	}

	.content_comment {
		border-radius: 8rpx;
		border: 1rpx solid #FF9999;
		color: #FF1414;
		font-size: 22rpx;
		padding: 4rpx 14rpx;
		margin-left: 17rpx;
	}

.demo-warter {
        border-radius: 20rpx;
        overflow: hidden;
        margin: 18rpx 18rpx 0 0;
        background-color: #ffffff;
        position: relative;
    }

    .u-close {
        position: absolute;
        top: 32rpx;
        right: 32rpx;
    }

    .demo-image {
        width: 100%;
        border-radius: 4px;
    }

    .demo-title {
        font-size: 30rpx;
        margin-top: 5px;
        color: #111;
        word-wrap: break-word;
    }

    .rate-box {
        border: 2rpx solid #ff8f96;
        border-radius: 8rpx;
        width: 150rpx;
        height: 36rpx;
    }
	.video-img {
		width: 224rpx !important;
		height: 163rpx !important;
		background: #FFA300;
		border-radius: 20rpx 20rpx 0 0;
		
	}
	.video-box {
		margin-left: 14rpx;
        border-radius: 20rpx;
        width: 224rpx;
	}

</style>
