<template>
<div data-page="research">
<form class="mission_search_form">
<div class="">
<input type="search" id="search" placeholder="请输入姓名" @keyup="key($event)" class="search_input">
</div>
<span class="search_icon" @click="research()"></span>
</form>
<ul class="search_name">
<li class="search_name_list" v-for="(name,index) in names" @click="ContactDetails(index)">{{name}}</li>
</ul>
</div>
</template>
<script>
module.exports={
data:function(){
return{
names:[],//查询到的用户姓名
id:[],
}
},
mounted(){
this.init();
},
methods: {
key(e){
var _this=this;
if(e.keyCode=='13'){
_this.research();
}
},
ContactDetails(index){
var _this=this;
localStorage.name=_this.id[index];
_this.$router.push({name:"ContactDetails",});
},
init() {
var _this = this;
var $body=$('body').css("background",'#edebeb');
function time(time){
var date = new Date(time);
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? ('0' + m) : m;
var d = date.getDate();
d = d < 10 ? ('0' + d) : d;
return time=y + '/' + m + '/' + d;
}
if(localStorage.search) {
document.getElementById("search").value=localStorage.search;
app.api.user.missionSearch({
data : {
realname :localStorage.search,
},
success(data,urls) {
var id = [],imgs=[],title=[],times=[],videoID=[],videoTitle=[],videoTimes=[],videoImgs=[];
for(var i = 0;i < data.length;i++) {
var id = [],names=[];
for(var i = 0;i < data.length;i++) {
names.push(data[i].realname);
id.push(data[i].id);
}
_this.names=names;
_this.id=id;
}
}
});
}
},
research() {
var _this = this;
function time(time){
var date = new Date(time);
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? ('0' + m) : m;
var d = date.getDate();
d = d < 10 ? ('0' + d) : d;
return time=y + '/' + m + '/' + d;
}
if(document.getElementById("search").value == '') {
app.mui.confirm("搜索内容不可为空","提示",["确定"],function(result){
});
} else {
localStorage.search=document.getElementById("search").value;
app.api.user.missionSearch({
data : {
realname : document.getElementById("search").value,
},
success(data,urls) {
if(data == "没有相应文章") {
app.mui.confirm("没有找到合适的内容","提示",["确定"],function(result){
if(result.index == 0) {
document.getElementById("search").value = '';
}
});
} else {
var id = [],names=[];
for(var i = 0;i < data.length;i++) {
names.push(data[i].realname);
id.push(data[i].id);
}
_this.names=names;
_this.id=id;
}
}
});
}
},
}
}
</script>
手机环境上使用时点击软键盘上的搜索会出现跳到首页,再进搜索页的时候就不会跳转到首页,重启app之后还是会出现这个情况!