首页 > 小程序教程 > 微信小程序带热门搜索的游戏攻略搜索页制作设计模板教程下载

微信小程序带热门搜索的游戏攻略搜索页制作设计模板教程下载

上一篇 下一篇
今天给大家带来热门搜索的游戏攻略搜索页制作设计模板教程,制作好以后效果图如下:
一、wxml页面代码如下:
<!--pages/onmyouji/hellspawnSearch/hellspawnSearch.wxml-->
<view class="page">
  <view class="hot">
    <text class="hot_title">热门搜索</text>
    <view class="hot_list">
      <navigator url="../onmyoji/onmyoji?id={{item.id}}" wx:for="{{ popularList }}" wx:key="name" class="hot_item">{{ item.name }}</navigator>
    </view>
  </view>
  <view class="page__bd">
    <view class="weui-search-bar">
      <view class="weui-search-bar__form">
        <view class="weui-search-bar__box">
          <icon class="weui-icon-search_in-box" type="search" size="14"></icon>
          <input type="text" class="weui-search-bar__input" placeholder="搜索" value="{{inputVal}}" focus="{{inputShowed}}" bindinput="inputTyping" />
          <view class="weui-icon-clear" wx:if="{{inputVal.length > 0}}" bindtap="clearInput">
            <icon type="clear" size="14"></icon>
          </view>
        </view>
        <label class="weui-search-bar__label" hidden="{{inputShowed}}" bindtap="showInput">
          <icon class="weui-icon-search" type="search" size="14"></icon>
          <view class="weui-search-bar__text">搜索</view>
        </label>
      </view>
      <view class="weui-search-bar__cancel-btn" hidden="{{!inputShowed}}" bindtap="hideInput">取消</view>
    </view>
    <view class="weui-cells searchbar-result" wx:if="{{inputVal.length > 0}}">
      <block wx:for="{{hellspawnList}}" wx:key="id">
        <navigator url="../onmyoji/onmyoji?id={{ item.id }}" class="weui-cell" hover-class="weui-cell_active">
          <view class="weui-cell__hd">
            <image src="{{item.icon}}" style="margin-right: 5px;vertical-align: middle;width:20px; height: 20px;"></image>
          </view>
          <view class="weui-cell__bd">{{ item.name }}</view>
        </navigator>
      </block>
    </view>
  </view>
  <view class="weui-footer weui-footer_fixed-bottom">
    <view class="weui-footer__text">Copyright © 2017 serenitynight.com</view>
  </view>
</view>
 
二、wxss样式文件代码如下:
/* pages/onmyouji/hellspawnSearch/hellspawnSearch.wxss */

.hot {
  height: 210rpx;
  background-color: #17212C;
  padding: 10rpx;
}

.hot_title {
  color: white;
  font-size: medium;
  display: block;
}

.hot_list {
  margin-top: 10rpx;
  margin-left: 10rpx;
}

.hot_item {
  display: inline-block;
  color: #99DDFF;
  line-height: 50rpx;
  padding-left: 20rpx;
  padding-right: 20rpx;
  background-color: #242E3F;
  border-radius: 15rpx;
  margin-right: 10rpx;
  margin-top: 10rpx;
  border:1px solid #67809F;
}
三、js页面代码如下:
/**
 * pages/onmyouji/hellspawnSearch/hellspawnSearch.js
 * 
 * @description 式神搜索页
 * @version 1.0.0
 * 
 */

var http = require("../../../utils/http.js");
var app = getApp();

Page({

  data: {
    popularList: [],
    inputShowed: false,
    inputVal: "",
    hellspawnList: []
  },

  onShow: function () {
    this.getPopular();
  },

  // 获取 热门搜索
  getPopular: function () {
    //console.log(http)
    var url = http.generateUrl('api/v1/populars');
    var _this = this;
    wx.request({
      url: url,
      method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      // header: {}, // 设置请求的 header
      success: function (res) {
        console.log(res)
        // success
        if (res.data.status == 1) {
          _this.setData({
            popularList: res.data.body.popular_list
          });
        }
      },
      fail: function (error) {
        console.error(error)
      }
    })
  },

  // 显示搜索input
  showInput: function () {
    this.setData({
      inputShowed: true
    });
  },

  // 隐藏搜索input
  hideInput: function () {
    this.setData({
      inputVal: "",
      inputShowed: false
    });
  },

  // 清空搜索input
  clearInput: function () {
    this.setData({
      inputVal: ""
    });
  },

  // 搜索input状态改变时
  inputTyping: function (e) {
    var _this = this;
    this.setData({
      inputVal: e.detail.value
    });
    if (e.detail.value) {
      var url = http.generateUrl('api/v1/search/' + e.detail.value);
      wx.request({
        url: url,
        method: 'GET',
        success: function (res) {
          if (res.data.status == 1) {
            _this.setData({
              hellspawnList: res.data.body.hellspawn_list
            })
          }
        }
      })
    }
  }

})

模板简介:该模板名称为【微信小程序带热门搜索的游戏攻略搜索页制作设计模板教程下载】,大小是,文档格式为.,推荐使用打开,作品中的图片,文字等数据均可修改,图片请在作品中选中图片替换即可,文字修改直接点击文字修改即可,您也可以新增或修改作品中的内容,该模板来自用户分享,如有侵权行为请联系网站客服处理。欢迎来懒人模板【小程序教程】栏目查找您需要的精美模板。

相关搜索
  • 下载密码 lanrenmb
  • 下载次数 17,767次
  • 使用软件
  • 文件格式
  • 文件大小
  • 上传时间 05-24
  • 作者 网友投稿
  • 肖像权 人物画像及字体仅供参考
栏目分类 更多 >
热门推荐 更多 >
微信素材 微信图片 响应式 企业网站 单页式简历模板 html5 微信文章 微信模板 微信公众平台 自适应
您可能会喜欢的其他模板