毕业论文写作

毕业设计需求

计算机毕业设计中微信小程序搜索功能实现,搜索框样式

 一:搜索框功能实现

1.在首页做一个搜索框的样式并实现跳转到搜索页面

 

  1. <view class='page_row' bindtap="suo">

  2. <view class="search">

  3. <view class="df search_arr">

  4. <icon class="searchcion" size='20' type='search'></icon>

  5. <input class="" disabled placeholder="请输入关键字" value="{{searchValue}}"/>

  6. </view>

  7. </view>

  8. <view class='sousuo'>搜索</view>

  9. </view>

  1. .search{

  2. width: 80%;

  3. }

  4. .search_arr {

  5. border: 1px solid #d0d0d0;

  6. border-radius: 10rpx;

  7. margin-left: 20rpx;

  8. }

  9. .search_arr input{

  10. margin-left: 60rpx;

  11. height: 60rpx;

  12. border-radius: 5px;

  13. }

  14. .bc_text {

  15. line-height: 68rpx;

  16. height: 68rpx;

  17. margin-top: 34rpx;

  18. }

  19.  

  20. .sousuo {

  21. margin-left: 15rpx;

  22. width: 15%;

  23. line-height: 150%;

  24. text-align: center;

  25. border: 1px solid #d0d0d0;

  26. border-radius: 10rpx;

  27. }

  28. .page_row{

  29. display: flex;

  30. flex-direction: row

  31. }

  32. .searchcion {

  33. margin: 10rpx 10rpx 10rpx 10rpx;

  34. position: absolute;

  35. left:25rpx;

  36. z-index: 2;

  37. width: 20px;

  38. height: 20px;

  39. text-align: center;

  40. }

js.点击跳转到搜索的页面

  1. suo: function (e) {

  2. wx.navigateTo({

  3. url: '../search/search',

  4. })

  5. },


2.搜索页面实现搜索功能

  1. <!--pages/search/search.wxml-->

  2. <view class="search page_row">

  3. <input class="df_1" placeholder="请输入你有搜索的内容" value="{{searchValue}}" bindinput="searchValueInput" />

  4. <button bindtap="suo" data-id='1'>

  5. 媒婆

  6. </button>

  7. <button bindtap="suo" data-id='2'>

  8. 单身

  9. </button>

  10. </view>

  11. <view class="search_no" wx:if="{{!centent_Show}}">

  12. <text>很抱歉,没有找到您要搜索的资料/(ㄒoㄒ)/~~</text>

  13. </view>

  14. <import src="../index/card/card.wxml" />

  15. <template is="nanshen_card" data="{{nanshen_card,img}}" />

  1. var app = getApp();

  2. var searchValue =''

  3. // pages/search/search.js

  4. Page({

  5. data: {

  6. centent_Show: true,

  7. searchValue: '',

  8. img: '',

  9. nanshen_card:''

  10. },

  11. onLoad: function () {

  12. },

  13. searchValueInput: function (e) {

  14. var value = e.detail.value;

  15. this.setData({

  16. searchValue: value,

  17. });

  18. if (!value && this.data.productData.length == 0) {

  19. this.setData({

  20. centent_Show: false,

  21. });

  22. }

  23. },

  24. suo:function(e){

  25. var id= e.currentTarget.dataset.id

  26. var program_id = app.program_id;

  27. var that = this;

  28. wx.request({

  29. url: 'aaa.php',//这里填写后台给你的搜索接口

  30. method: 'post',

  31. data: { str: that.data.searchValue, program_id: program_id, style:id },

  32. header: {

  33. 'content-type': 'application/x-www-form-urlencoded'

  34. },

  35. success: function (res) {

  36. if(res.data.length ==0){

  37. that.setData({

  38. centent_Show: false,

  39. });

  40. }

  41. that.setData({

  42. nanshen_card: res.data,

  43. });

  44. },

  45. fail: function (e) {

  46. wx.showToast({

  47. title: '网络异常!',

  48. duration: 2000

  49. });

  50. },

  51. });

  52. }

  53. });

  1. /* pages/search/search.wxss */

  2. @import "../index/card/card";

  3. .searchcion{

  4. width: 24px;

  5. height: 24px;

  6. text-align: center;

  7. margin-top: 5rpx

  8. }

  9. .search{

  10. padding: 1% 3%;

  11. background: #D0D0D0;

  12. }

  13. .search input{

  14. width: 85%;

  15. border-radius: 5px;

  16. background: #fff;

  17. border: none;

  18. font-size: 12px;

  19. padding:1% 2.5%;

  20. margin-right: 5px;

  21. }

  22. .search button{

  23. line-height:30px;

  24.  

  25. text-align: center;

  26. border: none;

  27. font-size: 28rpx;

  28. background: white

  29. }

php实现代码

  1. <?php

  2. header("Content-Type:text/html;charset=utf8");

  3. header("Access-Control-Allow-Origin: *"); //解决跨域

  4. header('Access-Control-Allow-Methods:POST');// 响应类型

  5. header('Access-Control-Allow-Headers:*'); // 响应头设置

  6. $link=mysql_connect("localhost","root","root");

  7. mysql_select_db("shige", $link); //选择数据库

  8. mysql_query("SET NAMES utf8");//解决中文乱码问题

  9.  

  10. $str = $_POST['str'];

  11.  

  12.  

  13. //SQL查询语句 SELECT * FROM 表名 LIKE 模糊搜索的变量

  14. $q="SELECT * FROM curriculum WHERE CONCAT_WS('',school,college,major,mtype,title) LIKE '%{$str}%'";

  15.  

  16. $rs = mysql_query($q); //获取数据集

  17. if(!$rs){die("数据库没有数据!");}

  18.  

  19. //循环读取数据并存入数组对象

  20. $dlogs;$i=0;

  21. while($row=mysql_fetch_array($rs))

  22. {

  23. $dlog['title']= $row["title"];

  24. $dlog['mtype']= $row["mtype"];

  25. $dlog['name']= $row["name"];

  26. $dlog['mfile']= $row["mfile"];

  27. $dlog['myear']= $row["myear"];

  28. $dlog['school']= $row["school"];

  29. $dlog['college']= $row["college"];

  30. $dlog['major']= $row["major"];

  31. $dlog['time']= $row["time"];

  32. $dlogs[$i++]=$dlog;

  33. }

  34.  

  35.  

  36. //以json格式返回html页面

  37. echo urldecode(json_encode($dlogs));

  38. ?>


最新毕业设计成品

版权所有© 帮我毕业网 并保留所有权利

QQ 1370405256 微信 biyebang

QQ:629001810微信:biyebang

收缩