Feat:地标好物政策搜索页

This commit is contained in:
modendeveloper
2024-11-19 00:58:08 +08:00
parent 0edbbfcdf5
commit bf7035cd2e
3 changed files with 151 additions and 8 deletions
+10 -8
View File
@@ -7,9 +7,9 @@
</view>
<view class="item-action v12-dark"><u-icon name="arrow-right" color="#fff" size="8"></u-icon></view>
</view>
<view class="more-wrap" v-if="isMore ? isMore : list.length > 3">
<view class="more-wrap">
<view class="more-btn v12-primary v12-align-center" @click="showMore">
{{ isMore ? '收起' : '查看更多' }}
{{ isMore ? '查看更多' : '查看更多' }}
<view class="item-action v12-white"><u-icon name="arrow-right" color="#C52733 " size="12"></u-icon></view>
</view>
</view>
@@ -65,12 +65,14 @@ export default {
})
},
showMore() {
this.isMore = !this.isMore
if(this.isMore) {
this.currentList = this.list
} else {
this.currentList = this.list.filter((item, index) => index < 3)
}
// this.isMore = !this.isMore
// if(this.isMore) {
// this.currentList = this.list
// } else {
// this.currentList = this.list.filter((item, index) => index < 3)
// }
uni.navigateTo({ url: `/pages/home/searchPage?id=${this.landmarkDataId}&type=2` })
},
fileItemClick(file) {
const url = file.attachment || ''
+135
View File
@@ -0,0 +1,135 @@
<template>
<view class="list-page">
<view class="v12-mb-3">
<u-search
placeholder="请输入关键词查询"
v-model="keyword"
shape="round"
:show-action="false"
height="72rpx"
@search="handleSearch"
bg-color="#fff">
</u-search>
</view>
<view v-if="isLoad" class="file-list">
<view
v-for="(file, fileIndex) in currentList"
:key="fileIndex"
class="file-item"
@click="fileItemClick(file)"
>
<view class="name more-t">
·&nbsp;&nbsp;{{ file.title }}
</view>
<image
:src="webUrl + '/page/qianxian/icon-05.png'"
class="icon"
/>
</view>
<view v-if="currentList.length === 0" class="no-data-txt">
暂无数据~
</view>
</view>
<goo-skeleton v-else />
</view>
</template>
<script>
import {
getPorjectPolicyFiles,
} from "@/api/product"
import { pageListenMixins } from '@/mixins/pageListenMixins'
export default {
name: 'searchPage',
mixins: [pageListenMixins],
data() {
return {
webUrl: this.$VUE_APP_RESOURCES_URL,
isLoad: false,
pageKeyId: '',
list: [],
keyword: '',
currentList: []
}
},
onLoad(options) {
const id = options.id
this.getListReq(id)
},
methods: {
handleSearch() {
this.currentList = this.list.filter(item => item.title.indexOf(this.keyword) > -1)
},
getListReq(id) {
const params = {
landmarkDataId : id,
page: 1,
limit: 9999
}
getPorjectPolicyFiles(params).then(res => {
const { success, data } = res
if (success) {
this.isLoad = true
this.list = data.records || []
this.currentList = [...this.list]
}
})
},
fileItemClick(file) {
const url = file.attachment || ''
if (!url) return
uni.downloadFile({
url,
success: res => {
const filePath = res.tempFilePath
wx.openDocument({
filePath,
fail: (err) => {
console.log(err)
}
})
}
})
}
}
}
</script>
<style scoped lang="less">
.list-page {
min-height: 100vh;
padding: 30rpx;
box-sizing: border-box;
background-color: #f0f0f0;
.file-item {
display: flex;
align-items: center;
justify-content: space-between;
height: 100rpx;
width: 100%;
padding: 0 20rpx;
margin: 0 0 20rpx 0;
border-radius: 20rpx;
box-sizing: border-box;
line-height: 36rpx;
background-color: #fff;
.name {
width: calc(100% - 40rpx);
font-size: 28rpx;
}
.icon {
display: block;
width: 26rpx;
height: 26rpx;
}
}
.loadend {
width: 100%;
}
.no-data-txt {
text-align: center;
line-height: 200rpx;
color: #999;
font-size: 36rpx;
}
}
</style>