123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- <template>
- <view class="content">
- <!-- 导航 -->
- <view class="nav">
- <view class="leftView" @click="back">
- <image src="../../static/mobile/backBtn.png" mode=""
- style="width: 22rpx; height: 40rpx; padding-left: 24rpx;"></image>
- </view>
- <view class="navTitle">搜索</view>
- <view class="rightView">
- </view>
- </view>
- <!-- content -->
- <!-- <view class="commend"> -->
- <!-- 搜索 -->
- <view class="searchBoxBg">
- <searchBox placeholder="请输入搜索内容" @search='search($event)'></searchBox>
- </view>
- <view class="top" v-if="itemArr.length!=0">为你找到“{{searchValue}}”相关结果共{{TotalSize}}条</view>
- <!-- </view> -->
- <!-- item -->
- <view class="itemBg">
- <view v-for="(item,index) in itemArr" :key="index" :class="{line:index>0}" class="twoItem" @click="goDetail(item)">
- <image :src="item.LogoImg" mode="" class="img2"></image>
- <view class="rightItem">
- <view class="title">{{item.Title}}</view>
- <view class="title2">{{item.Comment}}</view>
- </view>
- </view>
- </view>
- <!-- 上拉 加载更多 -->
- <view class="noMore" v-if="noMoreShow">没有更多数据</view>
- <!-- 无数据空白页 -->
- <nodata v-if="itemArr.length==0 && isFirst == false" style="padding-top: 30%;"></nodata>
- <view class="gotop" @click="gotoTop">
- <image src="../../static/pcimg/btn_top@2x.png" mode="" class="gotopImg"></image>
- </view>
- </view>
- </template>
- <script>
- import searchBox from '@/components/searchBox/searchBox.vue'
- import nodata from '../../components/nodata/nodata.vue'
- export default {
- components: {
- searchBox,
- nodata
- },
- data() {
- return {
- searchValue: '',
- page: 1,
- itemArr: [],
- TotalSize: '',
- noMoreShow: false,
- isFirst:true,
- }
- },
- onLoad() {
- },
- methods: {
- gotoTop() {
- uni.pageScrollTo({
- scrollTop: 0,
- duration: 300
- });
- },
- goDetail(item) {
- uni.navigateTo({
- url: 'detail?id=' + item.ID
- })
- },
- back() {
- uni.navigateBack({
- })
- },
- search(val) {
- console.log(val);
- this.isFirst = false
- this.searchValue = val
- if (this.searchValue.length != 0) {
- this.page = 1
- this.getItemData()
- } else {
- this.itemArr = [];
- this.TotalSize = ''
- this.noMoreShow = false
- }
- },
- getItemData() {
- uni.showLoading({
- title: '加载中'
- })
- let url = 'trainingOpenApiV2/searchPageData',
- params = {
- page: this.page,
- limit: 10,
- title: this.searchValue,
- }
- this.$http(url, params, 'GET').then(res => {
- uni.hideLoading();
- var data = res.data
- // 处理 undefined和null转为空白字符串
- for (const key in data) {
- data[key] = this.$praseStrEmpty(data[key])
- }
- this.TotalSize = data.TotalSize
- if (this.page == 1) {
- this.itemArr = data.Items
- } else {
- this.itemArr = this.itemArr.concat(data.Items)
- }
- if (data.Items.length < 10) {
- this.noMoreShow = true
- } else {
- this.noMoreShow = false
- }
- if (this.itemArr.length == 0) {
- this.noMoreShow = false
- }
- })
- },
- }
- }
- </script>
- <style scoped>
- .content {
- min-height: 100vh;
- background-color: #FFFFFF;
- padding-top: 88rpx;
- padding-bottom: 20rpx;
- }
- .nav {
- position: fixed;
- left: 0;
- top: 0;
- width: 100vw;
- height: 88rpx;
- background-color: #FFFFFF;
- display: flex;
- justify-content: space-between;
- align-items: center;
- z-index: 999;
- border-bottom: #eeeeee 2rpx solid;
- }
- .navTitle {
- font-size: 36rpx;
- font-weight: bold;
- color: #3c3c3c;
- }
- .leftView {
- width: 30%;
- }
- .rightView {
- width: 30%;
- display: flex;
- justify-content: flex-end;
- padding-right: 24rpx;
- }
- .rightImg {
- width: 40rpx;
- height: 40rpx;
- }
- .searchBoxBg {
- position: fixed;
- left: 0;
- top: 88rpx;
- width: calc(100vw - 50rpx);
- background-color: #FFFFFF;
- padding: 0 24rpx;
- z-index: 999;
- }
- .top {
- padding: 130rpx 24rpx 0;
- text-align: left;
- font-size: 24rpx;
- color: #999999;
- background-color: #FFFFFF;
- }
- .itemBg {
- background-color: #FFFFFF;
- padding: 0 30rpx;
- }
- .twoItem {
- display: flex;
- background-color: #FFFFFF;
- padding: 30rpx 0;
-
- }
- .line{
- border-top: #eeeeee 2rpx solid;
- }
- .title {
- font-size: 28rpx;
- font-weight: bold;
- color: #3c3c3c;
-
- /* 隐藏文字显示 ...不换行 */
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .title2 {
- font-size: 24rpx;
- color: #999999;
- //超过固定行数 隐藏
- display: -webkit-box;
- overflow: hidden;
- text-overflow: ellipsis;
- word-wrap: break-word;
- white-space: normal !important;
- -webkit-line-clamp: 3;
- -webkit-box-orient: vertical;
- margin: 14rpx 0;
- }
- .img2 {
- width: 240rpx;
- height: 135rpx;
- border-radius: 10rpx;
- }
- .rightItem {
- margin-left: 30rpx;
- width: calc(100vw - 300rpx);
- }
- .noMore {
- text-align: center;
- line-height: 50rpx;
- color: #999999;
- font-size: 28rpx;
- }
- .gotopImg {
- width: 100rpx;
- height: 100rpx;
- }
- .gotop {
- position: fixed;
- right: 15rpx;
- bottom: 100rpx;
- cursor: pointer;
- }
- </style>
|