<template>
	<view class="center">
		<!-- 顶部logo and 搜索 start-->
		<view class="status_bar"></view>
		<view class="top-search flex">
			<view class="search-box flex" @click="navto('/pages/columnGoods/goods_search/index')">
				<image class="search" src="../../static/icon/search-h.png" mode=""></image>
				<view class="search-font">输入关键词搜索</view>
			</view>
		</view>
		<!-- 顶部logo and 搜索 end-->
		<view class="jg"></view>
		<!-- 轮播图 start -->
		<view class="swiper-wrap">
			<swiper class="top-swiper" autoplay="true" duration="400" interval="5000" @change="swiperChange">
				<swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"
					@click="bannerNavToUrl(item)">
					<image :src="item.img" />
				</swiper-item>
			</swiper>
		</view>
		<!-- 轮播图 end -->
		<view class="jg"></view>
		<!-- 分类 start-->
		<view class="cate-section flex">
			<view class="cate-item flex" @click="goCp()">
				<view class="img-wrapper flex">
					<image src="../../static/icon/c2.png" mode=""></image>
				</view>
				<view class="item-title">环球国际</view>
			</view>
			<view class="cate-item flex" @click="gozx">
				<view class="img-wrapper flex">
					<image src="../../static/icon/c1.png" mode=""></image>
				</view>
				<view class="item-title">易博甄选</view>
			</view>
			<view class="cate-item flex" @click="openGg()" v-if="isAndroid">
				<view class="img-wrapper flex">
					<image src="../../static/icon/c3.png" mode=""></image>
				</view>
				<view class="item-title">视频领奖</view>
			</view>
			<view class="cate-item flex" @click="navto('/pages/store/shopStreet/index')">
				<view class="img-wrapper flex">
					<image src="../../static/icon/c4.png" mode=""></image>
				</view>
				<view class="item-title">商铺列表</view>
			</view>
			<view class="cate-item flex" @click="nav('/pages/user/shareQrCode')">
				<view class="img-wrapper flex">
					<image src="../../static/icon/c5.png" mode=""></image>
				</view>
				<view class="item-title">邀请有礼</view>
			</view>
		</view>
		<!-- 分类 end-->
		<!-- 专区 start -->
		<view class="sbkh-wrap">
			<image src="../../static/img/sbkh.jpg" mode=""></image>
			<view class="sbkh-xfzq" @click.stop="navto('/pages/index/xfqzq')">

			</view>
			<view class="sbkh-jfzq" @click="navto('/pages/index/bdzq')">

			</view>
		</view>
		<!-- 魔方 -->
		<!-- 		<view class="zq-wrap flex">
			<view class="zq-item" @click="nav('/pages/index/xfqzq')">
				<view class="zq-tit">
					消费券专区
				</view>
				<view class="item-info flex">
					<image src="../../static/img/xf-bg.png" mode=""></image>
					<view class="info-tit">
						<image src="../../static/icon/ms.png" mode="widthFix"></image>
					</view>
				</view>
			</view>
			<view class="zq-item bd" @click="nav('/pages/index/bdzq')">
				<view class="zq-tit">
					积分专区
				</view>
				<view class="item-info flex">
					<image src="../../static/img/bd-bg.png" mode=""></image>
					<view class="info-tit">
						<image src="../../static/icon/bd.png" mode="widthFix"></image>
					</view>
				</view>
			</view>
		</view> -->
		<!-- 专区 end -->
		<!-- 商品列表 start -->
		<view class="product-box">
			<view class="product-tit flex">
				<view class="hx">

				</view>
				<view class="tit">
					猜您喜欢
				</view>
				<view class="hx">

				</view>
			</view>
			<view class="hotgoods">
				<view class="hotgoods-item" v-for="item in sortProduct" :key="item.id"
					@click="navto('/pages/goods_details/index?id=' + item.product_id)" style="height: 520rpx;">
					<view class="image-wrapper">
						<image class="image" :src="item.image" mode="scaleToFill"></image>
					</view>
					<view class="flex"
						style="flex-direction: column;justify-content: space-between;align-items: flex-start;height: 160rpx;">
						<view class="title clamp2">{{item.store_info}}</view>
						<view class="hot-price">
							<view class="price">
								<text class="font-size-sm"></text>
								{{ item.price * 1 }}<text class="jf">积分</text>
							</view>
							<view class="yuanPrice">市场价：￥{{ item.ot_price*1 }}</view>
						</view>
					</view>

				</view>
			</view>
			<!-- <uni-load-more :status="loadingType"></uni-load-more> -->

		</view>
		<view class="page-btm" style="padding-top: 20rpx;">
			©2022 浙江易博网络科技有限公司 版权所有
		</view>
		<view class="page-btm" @click="gocx" style="padding-bottom: 10rpx;">
			浙ICP备2021013190号-9
		</view>
	</view>
</template>
<script>
	var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
	let app = getApp();
	import {
		getUserInfo
	} from '@/api/user.js';
	import {
		getDiy,
		getIndexData,
		getAppVersion,
		getUserCoupons
	} from '@/api/api.js';
	// #ifdef MP-WEIXIN
	import {
		getTemlIds
	} from '@/api/api.js';
	import {
		SUBSCRIBE_MESSAGE,
		TIPS_KEY
	} from '@/config/cache';
	// #endif
	import {
		getShare,
		getconfig,
		advertisement
	} from '@/api/public.js';
	import {
		goShopDetail
	} from '@/libs/order.js';
	import {
		mapGetters
	} from 'vuex';
	import {
		getProductslist,
		getProductHot,
		storeCategory
	} from '@/api/store.js';
	import {
		initiateAssistApi
	} from '@/api/activity.js';
	import {
		openBargainSubscribe
	} from '@/utils/SubscribeMessage.js';
	import {
		setVisit,
		spread
	} from '@/api/user.js';
	import {
		isAndroid
	} from '@/utils/platform.js';
	import recommend from '@/components/recommend';
	// #ifndef H5
	import passwordPopup from '@/components/passwordPopup';
	// #endif
	// #ifdef H5
	import mConfig from './component/index.js';
	// #endif
	import authorize from '@/components/Authorize';
	// #ifdef MP || APP-PLUS
	import activeParty from './component/activeParty';
	import headerSerch from './component/headerSerch';
	import coupon from './component/coupon';
	import bargain from './component/bargain';
	import blankPage from './component/blankPage';
	import combination from './component/combination';
	import customerService from './component/customerService';
	import goodList from './component/goodList';
	import guide from './component/guide';
	import liveBroadcast from './component/liveBroadcast';
	import menus from './component/menus';
	import news from './component/news';
	import topic from './component/topic';
	import presellList from './component/presellList';
	import plantList from './component/plantList';
	import pictureCube from './component/pictureCube'
	import shopList from './component/shopList';
	import richText from './component/richText';
	import seckill from './component/seckill';
	import swiperBg from './component/swiperBg';
	import tabNav from './component/tabNav';
	import titles from './component/titles';
	// #endif
	import {
		silenceBindingSpread,
		configMap,
		isWeixin
	} from '@/utils/index';
	import history from '@/mixins/history';
	import shareScence from '@/libs/spread';
	import easyLoadimage from '@/components/easy-loadimage/easy-loadimage.vue';
	import {
		getNewPeopleCouponLst
	} from '@/api/activity.js'
	import {
		HTTP_REQUEST_URL
	} from '@/config/app';
	export default {
		computed: configMap({
				hide_mer_status: 0,
				beian_sn: '',
				share_title: '',
				site_name: ''
			},
			mapGetters(['isLogin', 'uid', 'keyColor'])),
		mixins: [history],
		components: {
			easyLoadimage,
			recommend,
			authorize,
			// #ifndef H5
			passwordPopup,
			// #endif
			// #ifdef H5
			...mConfig,
			// #endif
			// #ifdef MP || APP-PLUS
			activeParty,
			headerSerch,
			bargain,
			coupon,
			blankPage,
			combination,
			customerService,
			goodList,
			guide,
			liveBroadcast,
			menus,
			news,
			topic,
			presellList,
			plantList,
			pictureCube,
			shopList,
			richText,
			seckill,
			swiperBg,
			tabNav,
			titles
			// #endif
		},
		data() {
			return {
				list: [],//普通商品列表
				isAndroid: false,
				carouselList: [], //轮播图
				domain: HTTP_REQUEST_URL,
				couponTypeMsg: {
					10: '通用券',
					11: '品类券',
					12: '跨店券'
				},
				styleConfig: [],
				showSkeleton: true, //骨架屏显示隐藏
				isNodes: 0, //控制什么时候开始抓取元素节点,只要数值改变就重新抓取
				privacyStatus: false,
				errorNetwork: false,
				ad: {
					home_ad_pic: ''
				},
				userInfo: {},
				loading: false,
				isAuto: false, //没有授权的不会自动授权
				isShowAuth: false, //是否隐藏授权
				statusBarHeight: statusBarHeight,
				navIndex: 0,
				navTop: [],
				subscribe: false,
				followUrl: '',
				followHid: true,
				followCode: false,
				imgUrls: [{
					url: '',
					pic: '',
					id: '',
					name: ''
				}],
				hot: [],
				sortList: [],
				menus: [{
					url: '',
					pic: '',
					id: '',
					name: ''
				}, {
					url: '',
					pic: '',
					id: '',
					name: ''
				}, {
					url: '',
					pic: '',
					id: '',
					name: ''
				}, {
					url: '',
					pic: '',
					id: '',
					name: ''
				}, {
					url: '',
					pic: '',
					id: '',
					name: ''
				}, {
					url: '',
					pic: '',
					id: '',
					name: ''
				}, {
					url: '',
					pic: '',
					id: '',
					name: ''
				}, {
					url: '',
					pic: '',
					id: '',
					name: ''
				}, {
					url: '',
					pic: '',
					id: '',
					name: ''
				}, {
					url: '',
					pic: '',
					id: '',
					name: ''
				}],
				window: false,
				navH: '',
				couponList: [],
				marTop: 0,
				loadend: false,
				loading: false,
				loadTitle: '加载更多',
				sortProduct: [],
				where: {
					// pid: 0,
					page: 1,
					limit: 30
				},
				is_switch: true,
				hostProduct: [],
				hotPage: 1,
				hotLimit: 30,
				hotScroll: true,
				hotLoading: false,
				hotTitle: '加载更多',
				explosiveMoney: [],
				prodeuctTop: 0,
				pinkInfo: '',
				searchH: 0,
				domOffsetTop: 50,
				// #ifdef APP-PLUS || MP
				isFixed: true,
				// #endif
				// #ifdef H5
				isFixed: false,
				// #endif
				goodScroll: true, //精品推荐开关
				params: {
					//精品推荐分页
					page: 1,
					limit: 10
				},
				tempArr: [], //精品推荐临时数组
				numConfig: 0,
				pageInfo: '', // 精品推荐全数据
				swiperCur: 0,
				d: '',
				h: '',
				m: '',
				s: '',
				sum_h: '',
				sortMarTop: 0,
				globalDatas: {},
				// #ifdef MP || APP-PLUS
				mpHeight: 108,
				// #endif
				// #ifndef MP || APP-PLUS
				mpHeight: 0,
				// #endif
				currSpid: '',
				_options: {},
				isIntegral: false,
				appUpdate: {},
				sortMpTop: 0,
				bgColor: '',
				bgPic: '',
				bgTabVal: '',
				windowHeight: 0,
				isHeaderSerch: false,
				showCoupon: false,
				couponArray: [],
				
			};
		},
		/**
		 * 用户点击右上角分享
		 */
		// #ifdef MP
		onShareAppMessage: function() {
			let that = this;
			wx.showShareMenu({
				withShareTicket: true,
				menus: ['shareAppMessage', 'shareTimeline']
			});
			return {
				title: that.share_title,
				path: '/pages/index/index?spid=' + that.uid
			};
		},
		onShareTimeline: function() {
			let that = this;
			return {
				title: that.share_title,
				query: {
					spid: that.uid
				},
				imageUrl: ''
			};
		},
		// #endif
		onLoad(options) {
			let that = this
			this._options = options;
			// #ifdef APP-PLUS
			const pages = getCurrentPages();
			const page = pages[pages.length - 1];
			const currentWebview = page.$getAppWebview();
			currentWebview.setStyle({
				pullToRefresh: {
					support: !that.isSupport,
					style: plus.os.name === 'Android' ? 'circle' : 'default'
				}
			});
			that.isSupport = !that.isSupport;
			that.appVersionConfig(); //APP版本检测
			// #endif
			that.$nextTick(function() {
				uni.getSystemInfo({
					success: function(res) {
						that.windowHeight = res.windowHeight;
					}
				});
			})
			that.pageLoad(options);
			setTimeout(() => {
				that.isNodes++;
			}, 100);
		},
		onShow() {
			this.getConfig();
			this.isIntegral = uni.getStorageSync('isIntegral')
			// #ifdef APP-PLUS
			if (this.appUpdate.openUpgrade == '1') {
				this.alertAppUpdate();
			}
			// #endif
			this.loadCoupon()
			// #ifdef H5
			this.isAndroid = isAndroid()
			// #endif
			// #ifdef APP-PLUS
			this.isAndroid = true
			// #endif
			console.log(this.isAndroid,'this.isAndroid')
			this.get_product_list();
		},
		onHide() {
			uni.setStorageSync('isIntegral', false)
		},
		onReady() {

		},
		watch: {
			globalDatas(nVal, oVal) {
				// #ifdef H5
				this.ShareInfo(nVal);
				// #endif
			},
			privacyStatus(n) {
				if (n) {
					uni.hideTabBar();
				} else {
					uni.showTabBar();
				}
			},
		},
		onPullDownRefresh() {
			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 100);
			this.reconnect();
		},
		methods: {
			//观看广告领奖
			openGg() {
				getUserInfo().then(res => {
					that.userInfo = res.data;
					this.$dsbridge.call("fnAds.onShowRewardVideoAD", {}, function(result) {
						let res = JSON.parse(result)
						if (res.event == 'onReward') {	
							advertisement({
								task: '1'
							}).then(e => {
							}).catch(err => {})
						}
					});
				});
			},
			navto(url) {
				uni.navigateTo({
					url,
					fail() {
						uni.switchTab({
							url
						})
					}
				})
			},
			goCp() {
				window.location.href = 'http://web.mall.hqgjsmc.com/'
			},
			gozx() {
				window.location.href =
					'https://chen.ningjuwang.com/shop/wap/27x50ex0ep39-qfKx#/index?preview_template_id=19&preview_page_id=190&preview_template_type=1'
			},
			swiperChange() {},
			bannerNavToUrl(item) {
				console.log(item)
			},
			changeBarg() {},
			loadCoupon() {
				if (!this.showCoupon && !uni.getStorageSync('show_coupon') && uni.getStorageSync('is_new_user')) {
					getNewPeopleCouponLst().then(res => {
						this.couponArray = res.data;
						setTimeout(() => {
							this.showCoupon = this.couponArray.length > 0;
							uni.setStorageSync('show_coupon', '1')
						}, 1500);
					})
				}
			},
			pageLoad(options) {
				let that = this;
				if (options.spid) {
					that.currSpid = options.spid;
					app.globalData.spid = options.spid;
				}
				// #ifdef APP-PLUS
				try {
					let val = uni.getStorageSync('privacyStatus') || false;
					if (!val) {
						this.privacyStatus = true;
					}
				} catch (e) {}
				this.snycNetWork();
				// #endif
				// #ifdef MP
				if (options.scene) {
					let value = that.$util.getUrlParams(decodeURIComponent(options.scene));
					if (value.id) options.id = value.id;
					//记录推广人uid
					if (value.spid) {
						that.currSpid = value.spid;
						app.globalData.spid = value.spid;
					}
				}
				// #endif
				shareScence(that.currSpid, that.isLogin);
				this.isLogin && silenceBindingSpread();
				this.getIndexConfig()
				Promise.all([
					this.diyData(),
					this.get_host_product(),
				]);
				if (this.isLogin) {
					this.getUserInfo();
					// #ifdef MP
					this.getHistory();
					// #endif
				}
			},
			closeShare() {
				uni.setStorageSync('isIntegral', false);
				this.isIntegral = uni.getStorageSync('isIntegral');
			},
			bindHeighta(data) {
				// #ifdef APP-PLUS
				this.sortMpTop = data.top + data.height;
				// #endif
			},
			// 重新链接
			reconnect() {
				uni.getNetworkType({
					success: res => {
						this.errorNetwork = res.networkType === 'none';
						if (!this.errorNetwork) {
							this.pageLoad(this._options);
						}
					}
				});
			},
			// #ifdef APP-PLUS
			snycNetWork() {
				uni.getNetworkType({
					success: res => {
						this.errorNetwork = res.networkType === 'none';
					}
				});
			},
			// 同意隐私协议
			confirmApp() {
				uni.setStorageSync('privacyStatus', true);
				this.privacyStatus = false;
			},
			// 关闭 Model
			closeModel() {
				this.privacyStatus = false;
			},
			// #endif
			// 对象转数组
			objToArr(data) {
				let obj = Object.keys(data).sort();
				let m = obj.map(key => data[key]);
				return m;
			},
			diyData() {
				let that = this;
				getDiy().then(res => {
					setTimeout(() => {
						that.isNodes++;
					}, 0);
					that.errorNetwork = false
					uni.setNavigationBarTitle({
						title: res.data.title
					});
					let data = res.data;
					if (data.is_bg_color) {
						that.bgColor = data.color_picker
					}
					if (data.is_bg_pic) {
						that.bgPic = data.bg_pic
						that.bgTabVal = data.bg_tab_val
					}
					that.styleConfig = that.objToArr(res.data.value);
					that.styleConfig.forEach((item, index, arr) => {
						if (item.name == 'headerSerch') {
							that.isHeaderSerch = true
						}
						console.log(item.name)
						if (item.name == 'swiperBg') {
							that.carouselList = item.swiperConfig.list
							console.log(that.carouselList, 'ddddddddddddddddd')
						}
					});
				});
			},
			// 微信登录回调
			onLoadFun: function(e) {
				this.isShowAuth = false;
			},
			// #ifdef APP-PLUS
			appVersionConfig() {
				var that = this;
				//app升级
				// 获取本地应用资源版本号
				getAppVersion().then(res => {
					that.$set(that.appUpdate, 'androidAddress', res.data.androidAddress);
					that.$set(that.appUpdate, 'appVersion', res.data.appVersion);
					that.$set(that.appUpdate, 'iosAddress', res.data.iosAddress);
					that.$set(that.appUpdate, 'openUpgrade', res.data.openUpgrade);
					plus.runtime.getProperty(plus.runtime.appid, function(inf) {
						let nowVersion = (inf.version).split('.').join('');
						let appVersion = (res.data.appVersion).split('.').join('');
						that.$set(that.appUpdate, 'alert', appVersion > nowVersion);
						that.alertAppUpdate();
					});
				})
			},
			alertAppUpdate() {
				if (this.appUpdate.alert) {
					uni.getSystemInfo({
						success: (res) => {
							uni.showModal({
								title: '更新提示',
								content: '发现新版本，是否前去下载?',
								showCancel: this.appUpdate.openUpgrade !=
									'1',
								cancelColor: '#eeeeee',
								confirmColor: '#FF0000',
								success: (response) => {
									if (response.confirm) {
										switch (res.platform) {
											case "android":
												plus.runtime.openURL(this
													.appUpdate
													.androidAddress);
												break;
											case "ios":
												plus.runtime.openURL(encodeURI(
													this.appUpdate
													.iosAddress));
												break;
										}
									}
								}
							});
						}
					})
				}
			},
			// #endif
			getConfig() {
				// 获取配置
				getconfig()
					.then(res => {
						let self = this;
						this.globalDatas = res.data;
						uni.$emit('configData', res.data);
					})
					.catch(err => {});
			},
			// 分类页更多
			bindMore() {
				console.log(this.navTop[this.navIndex]);
				try {
					uni.setStorageSync('storeIndex', this.navTop[this.navIndex].pid);
					uni.switchTab({
						url: '/pages/goods_cate/goods_cate'
					});
				} catch (e) {}
			},
			goDetails(item) {
				goShopDetail(item, this.uid).then(res => {
					if (this.isLogin) {
						initiateAssistApi(item.activity_id)
							.then(res => {
								let id = res.data.product_assist_set_id;
								uni.hideLoading();
								// #ifndef MP
								uni.navigateTo({
									url: '/pages/activity/assist_detail/index?id=' + id
								});
								// #endif
								// #ifdef MP
								openBargainSubscribe()
									.then(res => {
										uni.hideLoading();
										uni.navigateTo({
											url: '/pages/activity/assist_detail/index?id=' + id
										});
									})
									.catch(err => {
										uni.hideLoading();
									});
								// #endif
							})
							.catch(err => {
								uni.showToast({
									title: err,
									icon: 'none'
								});
							});
					} else {
						this.isAuto = true;
						this.isShowAuth = true
					}
				});
			},
			/**
			 * 获取个人用户信息
			 */
			getUserInfo: function() {
				let that = this;
				getUserInfo().then(res => {
					that.userInfo = res.data;
				});
			},
			// 记录会员访问
			setVisit() {
				setVisit({
					url: '/pages/index/index'
				}).then(res => {
					console.log(res);
				});
			},
			// 导航分类切换
			changeTab(e) {
				let self = this;
				if (this.navIndex == e.index) return;
				this.navIndex = e.index;
				if (e.index > 0) {
					storeCategory({
						pid: e.pid
					}).then(res => {
						this.sortList = res.data.length > 9 ? res.data.splice(0, 9) : res.data;
						if (this.sortList.length > 0) {
							this.where.pid = e.pid;
							this.where.page = 1;
							this.loadend = false;
							this.loading = false;
							this.sortProduct = [];
							this.get_product_list();
						}
					});
					self.sortMarTop = 10;
				}
			},
			//分类产品
			get_product_list: function() {
				let that = this;
				if (that.loading) return;
				that.loading = true;
				that.loadTitle = '';
				getProductslist(that.where)
					.then(res => {
						let list = res.data.list;
						let productList = that.$util.SplitArray(list, that.sortProduct);
						let loadend = list.length < that.where.limit;
						that.loadend = loadend;
						that.loading = false;
						that.loadTitle = loadend ? '已全部加载' : '加载更多';
						that.$set(that, 'sortProduct', productList);
						console.log(that.sortProduct,'sortProduct+++++++++++++++++')
						that.$set(that.where, 'page', that.where.page + 1);
					})
					.catch(err => {
						that.loading = false;
						that.loadTitle = '加载更多';
					});
			},
			/**
			 * 获取我的推荐
			 */
			get_host_product: function() {
				let that = this;
				let num = that.hotLimit;
				if (!that.hotScroll) return;
				if (that.hotLoading) return;
				that.hotLoading = true;
				that.hotTitle = '';
				getProductHot(that.hotPage, that.hotLimit).then(res => {
					let list = res.data.list;
					let productList = that.$util.SplitArray(list, that.hostProduct);
					let hotScroll = list.length <= num && list.length != 0;
					that.hotScroll = hotScroll;
					that.hotLoading = false;
					that.hotTitle = !hotScroll ? '已全部加载' : '加载更多';
					that.$set(that, 'hostProduct', productList);
					that.$set(that, 'hotPage', that.hotPage + 1);
				});
			},
			// 首页数据
			getIndexConfig: function() {
				let that = this;
				getIndexData().then(res => {
					that.$set(that, 'imgUrls', res.data.banner);
					that.$set(that, 'menus', res.data.menu);
					that.$set(that, 'hot', res.data.hot);
					that.$set(that, 'ad', res.data.ad);
					res.data.category.unshift({
						cate_name: '首页'
					});
					that.$set(that, 'navTop', res.data.category);
					// #ifdef H5
					that.subscribe = res.data.subscribe;
					// #endif
					// 小程序判断用户是否授权；
					// #ifdef MP
					uni.getSetting({
						success(res) {
							if (!res.authSetting['scope.userInfo']) {
								that.window = that.couponList.length ? true : false;
							} else {
								that.window = false;
							}
						}
					});
					// #endif
					// #ifndef MP
					if (that.isLogin) {
						that.window = false;
					} else {
						that.window = that.couponList.length ? true : false;
					}
					// #endif
					that.reloadData();
				});
			},
			reloadData() {
				setTimeout(() => {
					this.showSkeleton = false
				}, 500)
			},
			// 授权关闭
			authColse: function(e) {
				this.isShowAuth = e;
			},
			// 首发新品详情
			goDetail(item) {
				if (item.activity && item.activity.type === '2' && !this.isLogin) {
					// #ifdef H5
					uni.showModal({
						title: '提示',
						content: '您未登录，请登录！',
						success: function(res) {
							if (res.confirm) {
								uni.navigateTo({
									url: '/pages/users/login/index'
								});
							} else if (res.cancel) {}
						}
					});
					// #endif
					// #ifdef MP
					this.$set(this, 'isAuto', true);
					this.$set(this, 'isShowAuth', true);
					// #endif
					return;
				} else {
					goShopDetail(item, this.uid).then(res => {
						uni.navigateTo({
							url: `/pages/goods_details/index?id=${item.id}`
						});
					});
				}
			},
			// 分类详情
			godDetail(item) {
				uni.navigateTo({
					url: `/pages/goods_details/index?id=${item.id}`
				});
			},
			//拼团详情
			goCombinDetail(item) {
				uni.navigateTo({
					url: `/pages/activity/combination_details/index?id=${item.product_group_id}`
				});
			},
			countTime: function() {
				// 获取当前时间
				var date = new Date();
				var now = date.getTime();
				//设置截止时间
				var endDate = new Date('2020-10-22 23:23:23');
				var end = endDate.getTime();
				//时间差
				var leftTime = end - now;
				//定义变量 d,h,m,s保存倒计时的时间
				if (leftTime >= 0) {
					this.d = Math.floor(leftTime / 1000 / 60 / 60 / 24);
					this.h = Math.floor((leftTime / 1000 / 60 / 60) % 24);
					this.m = Math.floor((leftTime / 1000 / 60) % 60);
					this.s = Math.floor((leftTime / 1000) % 60);
					this.sum_h = this.d * 24 + this.h;
				}
				//递归每秒调用countTime方法，显示动态时间效果
				setTimeout(this.countTime, 1000);
			},
			//#ifdef H5
			ShareInfo(datas) {
				let data = this.storeInfo;
				let href = location.href;
				if (this.$wechat.isWeixin()) {
					if (this.isLogin) {
						href = href.indexOf('?') === -1 ? href + '?spid=' + this.uid : href + '&spid=' + this.uid;
					} else {
						href = href;
					}
					let configAppMessage = {
						desc: datas.share_info,
						title: datas.share_title,
						link: href,
						imgUrl: datas.share_pic
					};
					this.$wechat
						.wechatEvevt(['updateAppMessageShareData', 'updateTimelineShareData', 'onMenuShareAppMessage',
							'onMenuShareTimeline'
						], configAppMessage)
						.then(res => {
							console.log(res, '=============================>>WXAPI');
						})
						.catch(err => {
							console.log(err);
						});
				}
			},
			//#endif
		},
		mounted() {

		},
		// 滚动到底部
		onReachBottom() {
			if (this.navIndex == 0) {
				// 首页加载更多
				this.get_host_product();
			} else {
				// 分类栏目加载更多
				if (this.sortProduct.length > 0) {
					this.get_product_list();
				} else {
					this.get_host_product();
				}
			}
		},
		// 滚动监听
		onPageScroll(e) {
			// #ifdef H5
			if (this.isHeaderSerch) {
				if (e.scrollTop > this.domOffsetTop) {
					this.isFixed = true;
				}
				if (e.scrollTop < this.domOffsetTop) {
					this.$nextTick(() => {
						this.isFixed = false;
					});
				}
			} else {
				this.isFixed = false
			}
			// #endif
			// 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
			uni.$emit('scroll');
		}
	};
</script>
<style>

</style>
<style lang="scss">
	page,
	.center {
		min-height: 100%;
		height: auto;
		background: #fff;
	}

	// 顶部搜索
	.top-search {
		height: 80rpx;
		// padding: 0 20rpx;
		// background-color: #338fc0;
		background-color: #478fbf;
		justify-content: center;

		.search-box {
			justify-content: center;
			width: 700rpx;
			height: 60rpx;
			background: #fff;
			// box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
			border-radius: 30rpx;

			.search {
				width: 34rpx;
				height: 34rpx;
			}

			.search-font {
				margin-left: 14rpx;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #CBCBCB;
			}
		}
	}

	// 顶部轮播图
	.swiper-wrap {
		width: 750rpx;
		// background-color: #338fc0;
		background-color: #478fbf;

		.top-swiper {
			width: 700rpx;
			height: 350rpx;
			margin: auto;
			border-radius: 20rpx;

			image {
				width: 700rpx;
				height: 350rpx;
				border-radius: 20rpx;
			}
		}
	}


	.swiper-btm {
		height: 60rpx;
		width: 750rpx;
		background-color: #fff;
		margin-bottom: 20rpx;
		font-size: 21rpx;
		font-weight: 500;
		color: #333333;

		.btm-item {
			flex-grow: 1;
			justify-content: center;

			image {
				width: 25rpx;
				height: 25rpx;
				margin-right: 14rpx;
			}
		}
	}

	.jg {
		height: 20rpx;
		// background-color: #338fc0;
		background-color: #478fbf;
	}

	.status_bar {
		height: var(--status-bar-height);
		width: 100%;
		// background: #338fc0;
		background-color: #478fbf;
	}

	// 分类
	.cate-section {
		justify-content: space-around;
		background-color: #fff;
		padding: 0rpx 0 30rpx;
		// background: #338fc0;
		background-color: #478fbf;

		.cate-item {
			flex-grow: 0;
			width: 20%;
			flex-direction: column;
			text-align: center;
			align-items: center;
			justify-content: center;

			.img-wrapper {
				width: 90rpx;
				height: 90rpx;
				border-radius: 20rpx;
				position: relative;

				image {
					width: 90rpx;
					height: 90rpx;
					position: absolute;
					left: 50%;
					top: 50%;
					transform: translate(-50%, -50%);
				}
			}

			.item-title {
				margin-top: 15rpx;
				font-size: 26rpx;
				font-weight: 500;
				color: #FFFFFF;
			}
		}
	}

	// 专区
	.zq-wrap {
		height: 345rpx;
		width: 750rpx;
		background: linear-gradient(180deg, #338fc0, #fff);

		padding: 0 27rpx;

		.zq-item {
			width: 342rpx;
			height: 300rpx;
			background: linear-gradient(180deg, #fc2f40, #fb829e);
			border-radius: 20rpx;
			box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.2);
			position: relative;

			.zq-tit {
				padding: 15rpx 0 0 20rpx;
				font-size: 32rpx;
				font-weight: bold;
				font-style: italic;
				color: #FFFFFF;
			}

			.item-info {
				position: absolute;
				bottom: 8rpx;
				left: 0;
				right: 0;
				margin: auto;
				width: 324rpx;
				height: 232rpx;
				background: #FFFFFF;
				border-radius: 20rpx;
				flex-direction: column;
				justify-content: center;
				align-items: center;

				image {
					width: 294rpx;
					height: 160rpx;
				}

				.info-tit {
					margin-top: 12rpx;
					width: 189rpx;
					height: 36rpx;

					image {
						width: 189rpx;

					}
				}
			}
		}

		.bd {

			background: linear-gradient(180deg, #ff601a, #feba9d);
		}
	}

	.product-box {
		margin-top: 20rpx;
		background: #ffffff;
		padding: 26rpx 20rpx 20rpx;

		.product-tit {
			justify-content: center;

			.hx {
				width: 120rpx;
				height: 1rpx;
				background: #989898;
			}

			.tit {
				margin: 0 70rpx;
				font-size: 30rpx;
				font-weight: 500;
				color: #363636;
			}
		}
	}

	.hotgoods {
		margin-top: 38rpx;
		width: 100%;
		display: flex;
		flex-wrap: wrap;
		padding: 0 0 30rpx;
		justify-content: space-between;

		.hotgoods-item {
			width: 345rpx;
			background-color: #ffffff;
			border-radius: 12rpx;
			box-shadow: 0 0 15rpx rgba(0, 0, 0, 0.2);
			margin-bottom: 15rpx;

			.image-wrapper {
				width: 345rpx;
				height: 345rpx;
				border-radius: 3px;
				overflow: hidden;
				position: relative;

				.image-bg {
					position: absolute;
					top: 0;
					left: 0;
					right: 0;
					bottom: 0;
					width: 100%;
					height: 100%;
					opacity: 1;
					border-radius: 12rpx 12rpx 0 0;
					z-index: 2;
				}

				.image {
					width: 100%;
					height: 100%;
					opacity: 1;
					border-radius: 12rpx 12rpx 0 0;
				}
			}

			.title {
				margin-top: 24rpx;
				padding: 0 20rpx;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #333333;
			}

			.hot-price {
				display: flex;
				justify-content: flex-start;
				align-items: center;
				// padding: 14rpx 0 30rpx;

				.hotPrice-box {
					padding: 2rpx 6rpx;

					background: linear-gradient(90deg, #c79a4c, #f9df7f);
					border-radius: 5rpx;
					text-align: center;
					line-height: 28rpx;
					font-size: 20rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #ffffff;
				}

				.price {
					margin-left: 10rpx;
					font-size: 40rpx;
					color: #ff0000;
					font-weight: 500;

					.jf {
						font-size: 20rpx;
					}
				}

				.yuanPrice {
					margin-left: 10rpx;
					font-size: 20rpx;
					font-family: PingFang SC;
					font-weight: 500;
					text-decoration: line-through;
					color: #999999;
				}

				.cart-icon {
					image {
						width: 44rpx;
						height: 44rpx;
					}
				}
			}
		}
	}

	.sbkh-wrap {
		width: 750rpx;
		height: 362rpx;
		position: relative;

		image {
			position: absolute;
			top: 0;
			left: 0;
			width: 750rpx;
			height: 362rpx;
		}

		.sbkh-xfzq,
		.sbkh-jfzq {
			width: 340rpx;
			height: 300rpx;
			position: absolute;
		}

		.sbkh-xfzq {
			top: 40rpx;
			left: 27rpx;
		}

		.sbkh-jfzq {
			top: 40rpx;
			right: 27rpx;
		}
	}

	.mf-wrap {
		.mf {
			transform-style: prserve-3d;
			perspective: 500;
			position: relative;
			height: 200rpx;
			width: 200rpx;
			background-color: #bfa;
		}

		image {
			position: absolute;
			width: 100rpx;
			height: 100rpx;
		}

		.top {
			transform: rotateX(90deg);
			transform-origin: 0 0;

		}

		.bottom {
			transform: rotateX(90deg);
			transform-origin: 0 100%;
		}

	}

	.page-btm {
		background-color: #f5f5f5;
		font-size: 20rpx;
		text-align: center;
		color: #d6d6d8;
	}
</style>
