最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序搜索框樣式并實(shí)現(xiàn)跳轉(zhuǎn)到搜索頁(yè)面(小程序搜索功能)

 更新時(shí)間:2020年03月10日 15:32:58   作者:a_靖  
這篇文章主要介紹了微信小程序搜索框樣式并實(shí)現(xiàn)跳轉(zhuǎn)到搜索頁(yè)面(小程序搜索功能),需要的朋友可以參考下

上效果圖:

一:搜索框功能實(shí)現(xiàn)

1.在首頁(yè)做一個(gè)搜索框的樣式并實(shí)現(xiàn)跳轉(zhuǎn)到搜索頁(yè)面

 <view class='page_row' bindtap="suo">
 <view class="search">
  <view class="df search_arr">
  <icon class="searchcion" size='20' type='search'></icon>
  <input class="" disabled placeholder="請(qǐng)輸入關(guān)鍵字" value="{{searchValue}}"/>
  </view>
 </view>
 <view class='sousuo'>搜索</view>
 </view>
.search{
 width: 80%;
}
.search_arr {
 border: 1px solid #d0d0d0;
 border-radius: 10rpx;
 margin-left: 20rpx;
}
.search_arr input{
 margin-left: 60rpx;
 height: 60rpx;
 border-radius: 5px;
}
.bc_text {
 line-height: 68rpx;
 height: 68rpx;
 margin-top: 34rpx;
}
 
.sousuo {
 margin-left: 15rpx;
 width: 15%;
 line-height: 150%;
 text-align: center;
 border: 1px solid #d0d0d0;
 border-radius: 10rpx;
}
.page_row{
 display: flex;
 flex-direction: row
}
.searchcion {
 margin: 10rpx 10rpx 10rpx 10rpx;
 position: absolute;
 left:25rpx;
 z-index: 2;
 width: 20px;
 height: 20px;
 text-align: center;
}

js.點(diǎn)擊跳轉(zhuǎn)到搜索的頁(yè)面

 suo: function (e) {
 wx.navigateTo({
  url: '../search/search',
 })
 },

2.搜索頁(yè)面實(shí)現(xiàn)搜索功能

<!--pages/search/search.wxml-->
<view class="search page_row">
 <input class="df_1" placeholder="請(qǐng)輸入你有搜索的內(nèi)容" value="{{searchValue}}" bindinput="searchValueInput" />
 <button bindtap="suo" data-id='1'>
 媒婆
 </button>
 <button bindtap="suo" data-id='2'>
 單身
 </button>
</view>
<view class="search_no" wx:if="{{!centent_Show}}">
 <text>很抱歉,沒有找到您要搜索的資料/(ㄒoㄒ)/~~</text>
</view>
<import src="../index/card/card.wxml" />
<template is="nanshen_card" data="{{nanshen_card,img}}" />
var app = getApp();
var searchValue =''
// pages/search/search.js
Page({
 data: {
 centent_Show: true,
 searchValue: '',
 img: '',
 nanshen_card:''
 },
 onLoad: function () {
 },
 searchValueInput: function (e) {
 var value = e.detail.value;
 this.setData({
  searchValue: value,
 });
 if (!value && this.data.productData.length == 0) {
  this.setData({
  centent_Show: false,
  });
 }
 },
 suo:function(e){
 var id= e.currentTarget.dataset.id
 var program_id = app.program_id;
 var that = this;
 wx.request({
  url: 'aaa.php',//這里填寫后臺(tái)給你的搜索接口
  method: 'post',
  data: { str: that.data.searchValue, program_id: program_id, style:id },
  header: {
  'content-type': 'application/x-www-form-urlencoded'
  },
  success: function (res) {
  if(res.data.length ==0){
   that.setData({
   centent_Show: false,
   });
  }
  that.setData({
   nanshen_card: res.data,
  });
  },
  fail: function (e) {
  wx.showToast({
   title: '網(wǎng)絡(luò)異常!',
   duration: 2000
  });
  },
 });
 }
});
/* pages/search/search.wxss */
@import "../index/card/card";
.searchcion{
 width: 24px;
 height: 24px;
 text-align: center;
 margin-top: 5rpx
}
.search{
 padding: 1% 3%;
 background: #D0D0D0;
}
.search input{
 width: 85%;
 border-radius: 5px;
 background: #fff;
 border: none;
 font-size: 12px;
 padding:1% 2.5%;
 margin-right: 5px;
 }
.search button{
 line-height:30px;
 text-align: center;
 border: none;
 font-size: 28rpx;
 background: white
}

php實(shí)現(xiàn)代碼

<?php
 header("Content-Type:text/html;charset=utf8"); 
 header("Access-Control-Allow-Origin: *"); //解決跨域
 header('Access-Control-Allow-Methods:POST');// 響應(yīng)類型 
 header('Access-Control-Allow-Headers:*'); // 響應(yīng)頭設(shè)置 
 $link=mysql_connect("localhost","root","root"); 
 mysql_select_db("shige", $link); //選擇數(shù)據(jù)庫(kù)
 mysql_query("SET NAMES utf8");//解決中文亂碼問題
 $str = $_POST['str'];
 
 //SQL查詢語(yǔ)句 SELECT * FROM 表名 LIKE 模糊搜索的變量
 $q="SELECT * FROM curriculum WHERE CONCAT_WS('',school,college,major,mtype,title) LIKE '%{$str}%'";
 
 $rs = mysql_query($q); //獲取數(shù)據(jù)集
 if(!$rs){die("數(shù)據(jù)庫(kù)沒有數(shù)據(jù)!");}
 
 //循環(huán)讀取數(shù)據(jù)并存入數(shù)組對(duì)象
 $dlogs;$i=0;
 while($row=mysql_fetch_array($rs))
 {
  $dlog['title']= $row["title"];
  $dlog['mtype']= $row["mtype"];
 $dlog['name']= $row["name"];
 $dlog['mfile']= $row["mfile"];
 $dlog['myear']= $row["myear"];
 $dlog['school']= $row["school"];
 $dlog['college']= $row["college"];
 $dlog['major']= $row["major"];
 $dlog['time']= $row["time"];
  $dlogs[$i++]=$dlog;
 }
 //以json格式返回html頁(yè)面
 echo urldecode(json_encode($dlogs));
?>

總結(jié)

到此這篇關(guān)于微信小程序搜索框樣式并實(shí)現(xiàn)跳轉(zhuǎn)到搜索頁(yè)面(小程序搜索功能)的文章就介紹到這了,更多相關(guān)微信小程序搜索內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • JS實(shí)現(xiàn)定時(shí)任務(wù)每隔N秒請(qǐng)求后臺(tái)setInterval定時(shí)和ajax請(qǐng)求問題

    JS實(shí)現(xiàn)定時(shí)任務(wù)每隔N秒請(qǐng)求后臺(tái)setInterval定時(shí)和ajax請(qǐng)求問題

    這篇文章主要介紹了JS實(shí)現(xiàn)定時(shí)任務(wù)每隔N秒請(qǐng)求后臺(tái)setInterval定時(shí)和ajax請(qǐng)求 的相關(guān)資料,需要的朋友可以參考下
    2017-10-10
  • JS實(shí)現(xiàn)單例模式的N種方案

    JS實(shí)現(xiàn)單例模式的N種方案

    JS實(shí)現(xiàn)單例模式的多種方案 ,本文稍加總結(jié),列出了6種方式與大家分享,大體上將內(nèi)容分為了ES5(Function)與ES6(Class)實(shí)現(xiàn)兩種部分,對(duì)js單例模式相關(guān)知識(shí)感興趣的朋友跟隨小編一起看看吧
    2022-09-09
  • js實(shí)現(xiàn)淘寶固定側(cè)邊欄

    js實(shí)現(xiàn)淘寶固定側(cè)邊欄

    這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)淘寶固定側(cè)邊欄,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-07-07
  • css+js完美控制圖片大小

    css+js完美控制圖片大小

    在做網(wǎng)站的時(shí)候,往往圖片的處理很重要,固定尺寸容易變形拉伸,不固定又會(huì)有不可預(yù)知的問題,有可能撐開頁(yè)面。
    2009-08-08
  • javascript全局變量封裝模塊實(shí)現(xiàn)代碼

    javascript全局變量封裝模塊實(shí)現(xiàn)代碼

    javascript全局變量封裝模塊的應(yīng)用,本文將詳細(xì)介紹,需要了解更多的朋友可以參考下
    2012-11-11
  • JavaScript接入百度地圖API的方法步驟

    JavaScript接入百度地圖API的方法步驟

    在網(wǎng)站開發(fā)過程中,經(jīng)常會(huì)調(diào)用到地圖,百度地圖JavaScript API可幫助您在網(wǎng)站中構(gòu)建功能豐富、交互性強(qiáng)的地圖應(yīng)用,本文就詳細(xì)的介紹一下,感興趣的可以了解一下
    2021-07-07
  • JavaScript 中如何實(shí)現(xiàn)并發(fā)控制

    JavaScript 中如何實(shí)現(xiàn)并發(fā)控制

    在日常開發(fā)過程中,你可能會(huì)遇到并發(fā)控制的場(chǎng)景,比如控制請(qǐng)求并發(fā)數(shù)。那么在 JavaScript 中如何實(shí)現(xiàn)并發(fā)控制呢?在回答這個(gè)問題之前,我們來簡(jiǎn)單介紹一下并發(fā)控制。
    2021-05-05
  • javascript中搜索數(shù)組的四種方法示例詳解

    javascript中搜索數(shù)組的四種方法示例詳解

    我們?cè)趯W(xué)到j(luò)s中數(shù)組的時(shí)候,我們會(huì)接觸到j(luò)s中數(shù)組的一些方法這些方法對(duì)我們來說,可以很便利的達(dá)到我們想要的結(jié)果,下面這篇文章主要給大家介紹了關(guān)于javascript中搜索數(shù)組的四種方法,需要的朋友可以參考下
    2022-12-12
  • JavaScript的面向?qū)ο?一)

    JavaScript的面向?qū)ο?一)

    JavaScript的面向?qū)ο?一)...
    2006-11-11
  • JS中比Switch...Case更優(yōu)雅的多條件判斷寫法

    JS中比Switch...Case更優(yōu)雅的多條件判斷寫法

    這篇文章主要給大家介紹了關(guān)于JS中比Switch...Case更優(yōu)雅的多條件判斷寫法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用JS具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-09-09

最新評(píng)論

泸定县| 珲春市| 巴中市| 萍乡市| 溧水县| 镇宁| 中卫市| 扶风县| 新巴尔虎右旗| 壶关县| 汶上县| 牙克石市| 疏附县| 吉木萨尔县| 隆尧县| 科尔| 青海省| 九龙县| 枝江市| 依安县| 会泽县| 屏东市| 马边| 鄂州市| 红桥区| 宜兰市| 威宁| 依兰县| 十堰市| 军事| 白山市| 临漳县| 壶关县| 高雄市| 建平县| 平乡县| 察雅县| 绥芬河市| 德阳市| 和田市| 唐山市|