Procházet zdrojové kódy

FIX

修复scroll-view样式问题,修复关键词高亮有时失效的问题
RegMs If před 4 roky
rodič
revize
bccb7607ab

+ 1 - 15
miniprogram/components/itemCard/itemCard.js

@@ -1,6 +1,4 @@
 // components/itemCard.js
-const util = require('../../utils/util.js')
-
 Component({
   options: {
     styleIsolation: 'apply-shared'
@@ -10,8 +8,7 @@ Component({
    * 组件的属性列表
    */
   properties: {
-    item: Object,
-    keyword: String
+    item: Object
   },
 
   /**
@@ -21,17 +18,6 @@ Component({
     show: true
   },
 
-  lifetimes: {
-    ready: function () {
-      if (this.data.keyword) {
-        this.setData({
-          'item.name': this.data.item.name.replace(new RegExp(this.data.keyword, 'gi'), '<span style="color: #009195;">$&</span>'),
-          'item.brief': this.data.item.brief.replace(new RegExp(this.data.keyword, 'gi'), '<span style="color: #009195;">$&</span>')
-        })
-      }
-    }
-  },
-
   /**
    * 组件的方法列表
    */

+ 12 - 1
miniprogram/pages/aboutUs/aboutUs.js

@@ -4,7 +4,8 @@ Page({
    * 页面的初始数据
    */
   data: {
-    currentTab: 0
+    currentTab: 0,
+    winHeight: 0
   },
 
   switch1: function () {
@@ -35,5 +36,15 @@ Page({
     this.setData({
       currentTab: 6
     })
+  },
+
+  onLoad: function (options) {
+    wx.getSystemInfo({
+      success: function (res) {
+        this.setData({
+          winHeight: res.windowHeight
+        })
+      }.bind(this),
+    })
   }
 })

+ 6 - 6
miniprogram/pages/aboutUs/aboutUs.wxml

@@ -16,7 +16,7 @@
   </view>
 </view>
 
-<scroll-view wx:if="{{currentTab == 1}}" style="padding-bottom: 50rpx;" scroll-y>
+<scroll-view wx:if="{{currentTab == 1}}" style="height: {{winHeight}}px;" scroll-y>
   <view class="sub-title primary-text-color">汇听建立的初衷</view>
   <view class="message-detail">
     <view class="detail-text">
@@ -38,26 +38,26 @@
       第三是信息的问答模块不够通畅。在qq空间发布的说说,谁都可以评论,可以看到一条正经的通知下面有很多没有营养的信息,刷掉了一些有意义的提问;而微信公众号方面,关闭留言版块后,发布者和用户的交流接近于零。
     </view>
   </view>
-  <view class="message-detail">
+  <view class="message-detail" style="padding-bottom: 40rpx;">
     <view class="detail-text">
       在这些想法的激励下,汇听诞生了。
     </view>
   </view>
 </scroll-view>
 
-<scroll-view wx:if="{{currentTab == 2}}" scroll-y>
+<scroll-view wx:if="{{currentTab == 2}}" style="height: {{winHeight}}px;" scroll-y>
   <view class="sub-title primary-text-color">开发中</view>
 </scroll-view>
 
-<scroll-view wx:if="{{currentTab == 3}}" scroll-y>
+<scroll-view wx:if="{{currentTab == 3}}" style="height: {{winHeight}}px;" scroll-y>
   <view class="sub-title primary-text-color">开发中</view>
 </scroll-view>
 
-<scroll-view wx:if="{{currentTab == 5}}" scroll-y>
+<scroll-view wx:if="{{currentTab == 5}}" style="height: {{winHeight}}px;" scroll-y>
   <view class="sub-title primary-text-color">开发中</view>
 </scroll-view>
 
-<scroll-view wx:if="{{currentTab == 6}}" scroll-y>
+<scroll-view wx:if="{{currentTab == 6}}" style="height: {{winHeight}}px;" scroll-y>
   <view class="sub-title primary-text-color">开发人员</view>
   <view class="message-detail">
     <view class="detail-text">

+ 1 - 1
miniprogram/pages/aboutUs/aboutUs.wxss

@@ -28,5 +28,5 @@
 }
 
 .sub-title {
-  margin: 40rpx;
+  padding: 40rpx;
 }

+ 4 - 0
miniprogram/pages/search/search.js

@@ -105,6 +105,8 @@ Page({
       }
       for (let i = 0; i < res.result.list.length; i++) {
         res.result.list[i] = util.dbToMsg(res.result.list[i])
+        res.result.list[i].name = res.result.list[i].name.replace(new RegExp(this.data.searchText, 'gi'), '<span style="color: #009195;">$&</span>')
+        res.result.list[i].brief = res.result.list[i].brief.replace(new RegExp(this.data.searchText, 'gi'), '<span style="color: #009195;">$&</span>')
       }
       this.setData({
         searchResult: res.result.list,
@@ -139,6 +141,8 @@ Page({
       }
       for (let i = 0; i < res.result.list.length; i++) {
         res.result.list[i] = util.dbToMsg(res.result.list[i])
+        res.result.list[i].name = res.result.list[i].name.replace(new RegExp(this.data.searchText, 'gi'), '<span style="color: #009195;">$&</span>')
+        res.result.list[i].brief = res.result.list[i].brief.replace(new RegExp(this.data.searchText, 'gi'), '<span style="color: #009195;">$&</span>')
       }
       this.setData({
         searchResult: this.data.searchResult.concat(res.result.list),

+ 7 - 7
miniprogram/pages/search/search.wxml

@@ -12,8 +12,8 @@
   <view class="hot-tag-block">
     <view class="hot-tag-title primary-text-color">历史搜索</view>
     <view class="hot-tags secondary-text-color">
-      <view class="hot-tag" wx:for="{{searchHistory}}" wx:for-item="keyword" wx:key="*this"
-        data-search-tag="{{keyword}}" bindtap="searchTag">{{keyword}}</view>
+      <view class="hot-tag" wx:for="{{searchHistory}}" wx:for-item="tag" wx:key="*this" data-search-tag="{{tag}}"
+        bindtap="searchTag">{{tag}}</view>
     </view>
   </view>
 
@@ -42,12 +42,12 @@
   bindscrolltolower="loadMore">
   <view class="result-bar">
     <view wx:for="{{searchResult}}" wx:for-item="msg" wx:key="_id">
-      <itemCard item="{{msg}}" keyword="{{searchText}}" />
+      <itemCard item="{{msg}}" />
     </view>
   </view>
-  <view wx:if="{{!searched}}" wx:for="{{searchHistory}}" wx:for-item="keyword" wx:key="*this" class="search-history"
-    data-search-tag="{{keyword}}" catchtap="searchTag">
-    <view>{{keyword}}</view>
-    <view data-search-tag="{{keyword}}" catchtap="removeHistory">×</view>
+  <view wx:if="{{!searched}}" wx:for="{{searchHistory}}" wx:for-item="tag" wx:key="*this" class="search-history"
+    data-search-tag="{{tag}}" catchtap="searchTag">
+    <view>{{tag}}</view>
+    <view data-search-tag="{{tag}}" catchtap="removeHistory">×</view>
   </view>
 </scroll-view>

+ 1 - 1
miniprogram/pages/search/search.wxss

@@ -28,7 +28,7 @@
   display: flex;
   flex-direction: column;
   align-items: flex-start;
-  margin-top: 10rpx;
+  margin-bottom: 10rpx;
 }
 
 .hot-tag-title {