Browse Source

搜索页面

lx 5 years ago
parent
commit
77a3516d54

+ 2 - 1
app.json

@@ -8,7 +8,8 @@
     "pages/details/details",
     "pages/next/next",
     "pages/news/news",
-    "pages/auth/auth"
+    "pages/auth/auth",
+    "pages/search/search"
   ],
   "window": {
     "backgroundTextStyle": "light",

+ 7 - 1
components/navBar/navBar.js

@@ -98,6 +98,12 @@ Component({
         },
         home: function() {
             this.triggerEvent('home', {});
-        }
+        },
+        search: function() {
+            wx.navigateTo({
+              url: '../search/search'
+            })
+          },
+
     }
 })

+ 1 - 1
components/navBar/navBar.wxml

@@ -15,7 +15,7 @@
         </view> -->
         <view class='nav-title'>
            <view class="input-box row">
-               <input placeholder="请输入板块代码" />
+               <input placeholder="请输入板块代码" bindtap="search" />
                <icon class="weui-icon-search_in-box" type="search" size="20"></icon>
             </view>
             <!-- <input placeholder="请输入板块代码" style='{{textStyle}}'/> -->

+ 19 - 6
pages/index/index.js

@@ -7,6 +7,7 @@ Page({
   data: {
     url:'../../images/timg.jpg',
     motto: '',
+    currentTab: 0,
     userInfo: {},
     hasUserInfo: false,
     canIUse: wx.canIUse('button.open-type.getUserInfo'),
@@ -167,16 +168,16 @@ Page({
   computeScrollViewHeight() {
     var that = this
     let query = wx.createSelectorQuery().in(that)
-    query.select('.userinfo').boundingClientRect()
-    query.select('.search').boundingClientRect()
+    // query.select('.userinfo').boundingClientRect()
+    // query.select('.search').boundingClientRect()
     query.select('.news').boundingClientRect()
     query.exec(res => {
-      let topHeight = res[0].height
-      let searchHeight = res[1].height
-      let titleHeight = res[2].height
+      // let topHeight = res[0].height
+      // let searchHeight = res[1].height
+      let titleHeight = res[0].height
       let windowHeight = wx.getSystemInfoSync().windowHeight
       let windowWidth = wx.getSystemInfoSync().windowWidth
-      let height = windowHeight - topHeight - searchHeight - titleHeight
+      let height = windowHeight - titleHeight
       let ratio = 750 / windowWidth
       let scrollHeight = height * ratio + 20
       that.setData({ scrollHeight: scrollHeight})
@@ -195,6 +196,18 @@ Page({
     wx.navigateTo({
       url:"../news/news"
       });
+  },
+  swichNav: function(e) {
+    var that = this;
+    if (this.data.currentTab === e.target.dataset.current) {
+      return false;
+    } else {
+      that.setData({
+        currentTab: e.target.dataset.current
+      })
+    }
+
+
   },
   getUserInfo: function(e) {
     console.log(e)

+ 11 - 7
pages/index/index.wxml

@@ -4,21 +4,25 @@
 </view> -->
 <navBar></navBar>
 <view class="container">
-  <view class="userinfo">
-    <!-- <button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
+  <view class="swiper-tab">
+  <view class="swiper-tab-list {{currentTab==0 ? 'on' : ''}}" data-current="0" bindtap="swichNav">沪深</view>
+  <view class="swiper-tab-list {{currentTab==1 ? 'on' : ''}}" data-current="1" bindtap="swichNav">港股</view>
+</view>
+  <!-- <view class="userinfo">
+    <button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
     <block wx:else>
       <image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
       <text class="userinfo-nickname">{{userInfo.nickName}}</text>
-    </block> -->
-    <!-- <image class="imageSize" src="{{url}}" mode="widthFix"></image> -->
+    </block>
+    <image class="imageSize" src="{{url}}" mode="widthFix"></image>
     <image class="image" style="width: {{imagewidth}}px; height: {{imageheight}}px;" src="{{url}}" bindload="imageLoad"></image> 
-  </view>
-  <view class="search">
+  </view> -->
+  <!-- <view class="search">
     <input class="weui-input" placeholder="请输入板块代码"/>
     <view class="weui-search-bar__cancel-btn" bindtap='方法名a'>
       <icon class="weui-icon-search_in-box" type="search" size="20"></icon>
     </view>
-  </view>
+  </view> -->
   <view class="news">
     <text class="news-today">今日快讯</text>
   </view>

+ 18 - 1
pages/index/index.wxss

@@ -1,4 +1,20 @@
 /**index.wxss**/
+.swiper-tab {
+  width: 100%;
+  text-align: center;
+  line-height: 80rpx;
+}
+
+.swiper-tab-list {
+  font-size: 30rpx;
+  display: inline-block;
+  width: 20%;
+  color: #777;
+}
+.on {
+  color: #D81E06;
+  border-bottom: 5rpx solid #D81E06;
+}
 .userinfo {
   width:100%;
   /* display: flex;
@@ -33,6 +49,7 @@
 .news{
   margin-top:20rpx;
   width:90%;
+  margin-bottom: 20rpx;
 }
 .line{
   background: #E0E3DA;
@@ -111,4 +128,4 @@
   color: #999;
   margin-top:10rpx;
   margin-bottom: 10rpx;
-}
+}

+ 0 - 1
pages/rise/rise.json

@@ -1,6 +1,5 @@
 {
   "navigationBarTitleText": "涨幅",
-
   "usingComponents": {
     "ec-canvas": "../../ec-canvas/ec-canvas"
   }

+ 66 - 0
pages/search/search.js

@@ -0,0 +1,66 @@
+// pages/search/search.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 4 - 0
pages/search/search.json

@@ -0,0 +1,4 @@
+{
+  "navigationBarTitleText": "搜索",
+  "usingComponents": {}
+}

+ 2 - 0
pages/search/search.wxml

@@ -0,0 +1,2 @@
+<!--pages/search/search.wxml-->
+<text>pages/search/search.wxml</text>

+ 1 - 0
pages/search/search.wxss

@@ -0,0 +1 @@
+/* pages/search/search.wxss */