<template>
	<view>
		
		<uni-nav-bar statusBar backgroundColor="#fafafa" fixed title="添加好友" left-icon="left" @clickLeft="utils.navigateBack()" />

		
		<form @submit="formSubmit" >
			<view class="search fx-r fx-bc" >
				<image src="/static/chat/tb-seach.png"></image>
				<input name="keyword" v-model="keyword" class="fx-g1" @confirm="tapConfirm" type="text" confirm-type="搜索" placeholder="搜索手机号码" />
				<u-icon name="close-circle-fill" @tap="keyword = ''" v-if="keyword.length > 0" size="20"></u-icon>
			</view>
		</form>
		
	</view>
</template>

<script>
	import {mapState,mapMutations } from 'vuex';
	export default {
	    data() {
	        return {
				keyword:""
	        }  
	    },
		
		onLoad(option){
			
		},
	    methods: {
			formSubmit:function(ev){
				var text = this.keyword;
				if(text == "") return;
				
			},
			tapConfirm:function(ev){
				var value = ev.detail.value;
				if(value == "") return;
				uni.showLoading({	title: '获取数据中..'});
				var post = {};
				post.usercode = value;
				this
					.request
					.post("chatFindCode",post)
					.then(res => {
						uni.hideLoading();
						if(res.code == 200) {
							uni.navigateTo({
								url:"info?usercode=" + res.msg
							});
						} else {
							uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
						}
					})
					.catch(res=>{
						uni.hideLoading();
						uni.showModal({title: '系统提示',content: '加载失败，重新点击尝试！',showCancel: false});
					});
				
			}
	    }
	}
</script>

<style>
	.search{background: #fff;border-radius: 6px;margin: 0px 10px;padding: 10px;}
	.search image{width: 30px;height: 30px;}
	.search input{font-size: 14px;}
</style>