<template>
	<view class="workbench_page">
		<uni-nav-bar 
			title="发现"
			statusBar
			fixed
			background-color="transparent"></uni-nav-bar>
		<uni-list>
			<uni-list-item title="朋友圈" 
				thumb="/static/images/find/01.png" 
				:thumbSize="thumbSize" 
				showArrow
				to="/pages/find/friend-circle/friend-circle">
				<view slot="footer" v-if="last_unread_item&&last_unread_item.avatar.length>0">
					<u-avatar :src="last_unread_item.avatar" mode="square" :size="70"></u-avatar>
					<u-badge :is-dot="true" type="error" :offset="[20,60]"></u-badge>
				</view>
			</uni-list-item>
		</uni-list>
		<u-gap :height="10"></u-gap>
		<uni-list>
			<uni-list-item title="扫一扫" thumb="/static/images/find/03.png" :thumbSize="thumbSize" @click="scan" clickable  showArrow></uni-list-item>
			<uni-list-item v-if="1==2" title="摇一摇" thumb="/static/images/find/05.png" :thumbSize="thumbSize" to="/pages/find/friend-circle/friend-circle" showArrow></uni-list-item>
			<uni-list-item v-if="1==2" title="看一看" thumb="/static/images/find/06.png" :thumbSize="thumbSize" to="/pages/find/friend-circle/friend-circle" showArrow></uni-list-item>
			<uni-list-item v-if="1==2" title="听一听" thumb="/static/images/find/06.png" :thumbSize="thumbSize" to="/pages/find/friend-circle/friend-circle" showArrow></uni-list-item>
			<uni-list-item v-if="config.near_user_open == '1'" title="附近" thumb="/static/images/find/08.png" :thumbSize="thumbSize" to="/pages/find/near/near" showArrow></uni-list-item>
			<uni-list-item title="购物" thumb="/static/images/find/09.png" :thumbSize="thumbSize" :to="'/pages/common/webview?url='+encodeURI('http://pinduoduo.com')" showArrow></uni-list-item>
		</uni-list>
	</view>
</template>

<script>
	import { mapGetters } from "vuex";
	export default {
		data() {
			return {
				thumbSize:"base"
			};
		},
		computed:{
			...mapGetters(["config"]),
			circleUnreadCount() {
				return this.$store.getters.storeCircleUnreadCount;
			},
			last_unread_item() {
				return this.$store.getters.storeCircleLastUnreadItem;
			},
		},
		onShow: function() {
			let unreadCount= 1;
			this.$store.dispatch('circle/getFriendCircleInfo');
		},
		methods: {	
			scan(){
				uni.scanCode({
					success(res) {
						if(res.scanType == "QR_CODE"){
							if(res.result.startsWith("http")){
								uni.navigateTo({
									url:"/pages/common/webview?url="+encodeURIComponent(res.result)
								});
								//res.result;
								return ;
							}
							const user_prefix = `${this.config.website}/u/`;
							if(res.result.startsWith(user_prefix)){
								return uni.navigateTo({
									url:"/pages/common/userCard/index?sourceID="+res.result.replace(user_prefix,'')
								});
							}
							const group_prefix = `${this.config.website}/g/`;
							if(res.result.startsWith(group_prefix)){
								return uni.navigateTo({
									url:"/pages/common/groupCard/index?sourceID="+res.result.replace(group_prefix,'')
								});
							}
						}
					}
				})
				// uni.navigateTo({
				// 	url:"/pages/common/scan"		
				// })
			}
		}
	};
</script>

<style lang="scss" scoped>
	.workbench_page {
		background-color: #ececec !important;
	}
</style>
