<template>
	<view class="content">
		
	</view>
</template>

<script>
	import {
	  initGet,
	  getFeatureItemList,
	  isHaveExperienceCard,
	  followOrderManager,
	  setRedPageNum,
	  getMarketingShopInfo
	} from '../../api/home'
	export default {
		data() {
			return {
				url: 'http://192.168.0.215:9588',
				
				followSize: '',
				servicesSize: '',
				sweepCodebth: false,
				redData: {},
				experienceCard:'',
				redEnvelopes: false,
				marketingShopInfo: {},
				snapUpItem: {},
				featureItemlists: [],
				vipCardList: [],
				hotItemlist: [],
				newItemlist: [],
				voucherList: [],
				orderManagerList: [],
				scoreList: [],
				groupItem: {},
				demo01_index: 1,
				yishouXianliang: 0,
				show: false,
				loadings: false,
				title: '恭喜',
				text: '加载中',
				memberItemList: [],
				demo01_list: [],
				openTeSe: true,
				needdata: '',
				options: {
				  orderTime: ''
				},
				items: [
				  { key: '资质认证' },
				  { key: '优质商家' },
				  { key: '品质保证' },
				  { key: '品质保障' }
				
				],
				percent1: 0,
				// 门店信息
				marketingInfo: {},
				popupSHow:false,
				defaultImg: require("../../static/homeImg/pic_def.png"),
				defaultImg2: require("../../static/homeImg/pic_def2.png")
			}
		},
		onLoad() {
			var that=this;
			var params={ lat:'',lng:'',}
			uni.getLocation({
				type: 'wgs84',
				geocode:true,//设置该参数为true可直接获取经纬度及城市信息
				success: function (res) {
					console.log(res)
					params.lat=res.latitude
					params.lng=res.longitude
					that.init(params)
				},
				fail: function () {
					
					params.lat=res.latitude
					params.lng=res.longitude
					that.init(params)
				}
			});
			//console.log(this.$request.fetchGet)
			/* this.$request.fetchGet('home/getFeatureItemList', {
				
				
			}).then(res => {
				
			})
            getFeatureItemList().then(res => {
				  
			}) */
		},
		methods: {
           init (params) {
              //alert(params.shopId)
           
             this.loadings = true
           
             initGet(params).then(res => {
           
               this.loadings = false
               this.needdata = res.data;
                //return false
               this.experienceCard = res.data.experienceCard
           
                // 头部部分 门店信息
                this.marketingShopInfo = res.data.marketingShopInfo
               // 轮播图
               this.demo01_list = []
               if (this.marketingShopInfo.shopPhotos) {
                 this.marketingShopInfo.shopPhotos.forEach(item => {
                   this.demo01_list.push({
                     url: 'javascript:',
                     img: item.photoPath
                   })
                 })
               }
               if(this.marketingShopInfo.shopPhotos.length==0){
                 this.demo01_list.push({
                   url: 'javascript:',
                   img: 'http://phone.66km.cn:8088/thFiles/1175E99A-BB94-43CC-8B00-7E3ECA8EB355.png'
                 })
               }
               /* this.demo01_list.push({
                 url: 'javascript:',
                 img: 'http://phone.66km.cn:8088/marketing/8EF7F827-91E3-4A51-8244-21DA15FDA34E.jpeg'
               }) */
           
               // 限量抢购(1个)
               if (res.data.snapUpItem) {
                 this.snapUpItem = res.data.snapUpItem
                 // 已售的 百分数
                 if(this.snapUpItem.buyCount<0){
                   this.snapUpItem.buyCount=-this.snapUpItem.buyCount
                 }
                 this.yishouXianliang = ((this.snapUpItem.buyCount / this.snapUpItem.count).toFixed(2)) * 100
                 this.percent1 = ((this.snapUpItem.buyCount / this.snapUpItem.count).toFixed(2)) * 100 || 0
               }
           
               // 特色项目列表
               if (res.data.featureItemlist && res.data.featureItemlist.length) {
                 this.featureItemlists = res.data.featureItemlist
               }
           
               // vip 会员卡
               if (res.data.vipCardList && res.data.vipCardList.length) {
                 this.vipCardList = res.data.vipCardList
               }
           
               // 热门项目
               if (res.data.hotItemlist && res.data.hotItemlist.length) {
                 this.hotItemlist = res.data.hotItemlist
               }
               // 最新项目
               if (res.data.newItemlist && res.data.newItemlist.length) {
                 this.newItemlist = res.data.newItemlist
               }
               // 领取优惠
               if (res.data.voucherList && res.data.voucherList.length) {
                 this.voucherList = res.data.voucherList
                 this.voucherList.forEach(item => {
                   this.$set(item, 'nowlingqu', '立即领取')
                 })
               }
               // 拼团活动
               if (res.data.groupItem) {
                 this.groupItem = res.data.groupItem
               }
               // 顾客评价
               if (res.data.scoreList && res.data.scoreList.length) {
                 this.scoreList = res.data.scoreList
               }
           
               if (res.data.orderManagerList && res.data.orderManagerList.length) {
                 this.orderManagerList = res.data.orderManagerList
               }
               this.followSize = res.data.followSize
               this.servicesSize = res.data.servicesSize
               // 会员专区
               if (res.data.memberItemList && res.data.memberItemList.length) {
                 this.memberItemList = res.data.memberItemList
               }
           
               if (res.data.noHaveRedEnvelopesFlag === '1') {
                 this.redEnvelopes = true
                 let json = {
                   redEnvelopesId: res.data.redEnvelopesId
                 }
                 // this.redData = {
                 //   redEnvelopesId: '0C6BD78E-AE07-4D4C-96FF-69A3986980F2'
                 // }
                 setRedPageNum(json).then(res => {
                   if (!res.code) {
                     this.redData = res.data
                   }
                   // console.log(this.redData )
                 }).catch(err => {
                   console.log(err)
                 })
               }
               // this.$refs.viewBox.scrollTo(this.$store.state.user.SetScrollTop)
             }).catch(err => {
               this.loadings = false
               console.log(err)
             })
           },
		}
	}
</script>

<style>
	
</style>
