<template>
	<layout>
	  <uv-sticky
	    bg-color="#F5F5F5"
	    offset-top="0" 
	    customNavHeight="0"
	  >
	    <uv-navbar
	      :fixed="false"
	      :safeAreaInsetTop="true"
	      height="0"
	      bgColor="transparent"
	      leftIcon=""
	    />
	    <!-- #ifndef MP -->
	    <blank size="10"></blank>
	    <!-- #endif -->
	
	    <blank size="5"></blank>
	  </uv-sticky>
	
	  <blank size="10"></blank>		
	  
		
		<view class="page flex-col">
		    <view class="group_6 flex-row">
		      <view class="group_7 flex-col">
		        <view class="group_8 flex-row justify-between">
		          <view class="group_9 flex-col" @tap="takein">
		            <image
		              class="image_1"
		              referrerpolicy="no-referrer"
		              src="/static/images/index/store_pickup.png"
		            />
		            <view class="text-group_13 flex-col justify-between">
		              <text class="text_1">到店自取</text>
		              <text class="text_2">下单免排队</text>
		            </view>
		          </view>
		          <view class="image-text_7 flex-col" @tap="takeout">
		            <image
		              class="image_2"
		              referrerpolicy="no-referrer"
		              src="/static/images/index/delivery.png"
		            />
		            <view class="text-group_14 flex-col justify-between">
		              <text class="text_3">外卖外送</text>
		              <text class="text_4">美食送到家</text>
		            </view>
		          </view>
		        </view>
		        <!-- <view class="text-wrapper_3 flex-row justify-between">
		          <text class="text_2">下单免排队</text>
		          <text class="text_4">美食送到家</text>
		        </view> -->
		        <view class="block_5 flex-row">
		          <view class="image-text_8 flex-row justify-between">
		            <image
		              class="label_3"
		              referrerpolicy="no-referrer"
		              src="https://lanhu-oss-2537-2.lanhuapp.com/FigmaDDSSlicePNG6a50f629b5651809d4880952709ad066.png"
		            />
		            <text class="text-group_9">我的卡券</text>
		          </view>
		          <view class="image-text_9 flex-row justify-between">
		            <text class="text-group_10">去领取</text>
					<view class="iconfont iconarrow-right line-height-100 green flex-fill"></view>
		            <!-- <view class="section_2 flex-col"></view> -->
		          </view>
		        </view>
		      </view>
		    </view>
		    <view class="group_2 flex-col">
		      <view class="box_3 flex-col">
		        <view class="block_6 flex-row"></view>
		        <view class="image-wrapper_7 flex-row"></view>
		      </view>
		      <view class="box_6 flex-row">
		        <view class="image-wrapper_3 flex-col">
		          <image
		            class="image_10"
		            referrerpolicy="no-referrer"
		            src="https://lanhu-oss-2537-2.lanhuapp.com/FigmaDDSSlicePNG0e6d9934938921690cb666e0232ca99e.png"
		          />
		        </view>
		        <view class="text-group_15 flex-col justify-between">
		          <text class="text_6">Hi,{{ isLogin ? member.nickname : '新朋友' }}</text>
		          <text class="text_7">爱愈膳汤铺随时欢迎您回家</text>
		        </view>
		        <view class="text-group_16 flex-col justify-between">
		          <text class="text_8">积分</text>
		          <text class="text_9">1000</text>
		        </view>
		      </view>
		    </view>
		  </view>
	  
	  </layout>
</template>

<script setup>
	import {
	  ref
	} from 'vue'
	import { onLoad } from '@dcloudio/uni-app'
	import {
	  menuAds
	} from '@/api/market'
	import { storeToRefs } from 'pinia'
	import { useMainStore } from '@/store/store'
	//
	const main = useMainStore()
	const { member,store, isLogin} = storeToRefs(main)
	//const store = ref(main.store)
	const listAds = ref([])
	// const isLogin = ref(main.isLogin)
	
	const handGetListAds = async () => {
		let shop_id = store.id ? store.id : 0;
		let data = await menuAds({
			shop_id: shop_id
		});
		if (data) {
			listAds.value = data.list;
			console.log('listAds:',listAds.value)
			uni.setStorage({
					key: 'isActive',
					data: data.isActive
				});
			if(data.list.length > 0){
				uni.setStorage({
						key: 'shopAd',
						data: data.list[0].image
				 });
				}
			}
	}
	
	const takein = () => {
		console.log('显示信息')		
		main.SET_ORDER_TYPE('takein')
		uni.switchTab({
			url: '/pages/menu/menu'
		})
	}
	
	const takeout = () => {
		main.SET_ORDER_TYPE('takeout')
		uni.switchTab({
			url: '/pages/menu/menu'
		}) 
	}
	
	const coupons = () => { 
		console.log("--> % orderType:\n", main.orderType)
		console.log("--> % isLogin:\n", main.isLogin)
		if(!main.isLogin) {
			uni.navigateTo({url: '/pages/components/pages/login/login'})
			return
		}
		uni.navigateTo({
			url: '/pages/components/pages/coupons/coupons'
		})
	}
	
	const goScore = () => { 
		uni.navigateTo({
			url: '/pages/components/pages/scoreproduct/list'
		})
	}
	
	
	
	onLoad(() => {
	 // main.init()
	  handGetListAds()
	})
	
</script>

<style lang="scss">
	@import '../../static/style/common.css';
	@import './index.rpx.css';
</style>