123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <template>
- <view class="pk-search">
- <view class="search-box u-flex u-row-between">
- <u-icon name="search" color="#CCCCCC" size="36"></u-icon>
- <input type="text" placeholder="搜索楼盘" class="input" v-model="keyword1">
- <text class="text" @click="tosearch">搜索</text>
- </view>
- <view class="lishi-box">
- <view class="lishi-title">
- 历史搜索
- </view>
- <view class="u-flex u-flex-wrap">
- <text v-for="(item,index) in lishilist" :key="index" class="lishi-item" @click="lishisearch(item)">{{item}}</text>
- </view>
- </view>
- <view class="search-list">
- <view class="search-item u-flex u-row-between" v-for="(item,index) in list" :key="index">
- <text>{{item.name}}</text>
- <text @click="addpk(item)">添加</text>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- lishilist: [],
- keyword:'',
- keyword1:'',
- page:1,
- list:[]
- }
- },
- onLoad() {
- this.lishilist = uni.getStorageSync("lishi") || []
- this.getlist()
- },
- onReachBottom() {
- if(this.list.length % 20 == 0){
- this.page++
- this.getlist()
- }
- },
- methods: {
- lishisearch(item){
- this.keyword = item
- this.keyword1 = item
- this.page = 1
- this.list = []
- this.getlist()
- },
- addpk(item){
- var list = uni.getStorageSync("pklist") || []
- var index = list.findIndex(value => value.id == item.id)
- console.log(index);
- if(index == -1){
- list.unshift(item)
- uni.setStorageSync("pklist",list)
- uni.navigateBack()
- }else{
- uni.showModal({
- content:"该楼盘已添加!"
- })
- }
- },
- setlishi() {
- if (this.keyword) {
- if (this.lishilist.indexOf(this.keyword) == -1) {
- this.lishilist.unshift(this.keyword)
- uni.setStorageSync("lishi", this.lishilist)
- }
- }
- },
- tosearch() {
- this.keyword = this.$u.trim(this.keyword1)
- this.setlishi()
- this.page = 1
- this.list = []
- this.getlist()
- },
- getlist(){
- this.$u.post('/api/Index/property_list', {
- page: this.page,
- page_num: 20,
- keyword: this.keyword
- }).then(res => {
- if (this.page == 1) {
- this.list = res.data
- } else {
- this.list = this.list.concat(res.data)
- }
- })
- }
- }
- }
- </script>
- <style lang="scss">
- .pk-search {
- .search-list {
- padding: 0 24rpx;
- .search-item {
- padding: 18rpx 0;
- border-bottom: 1rpx solid #F2F2F2;
- text:first-child {
- font-size: 24rpx;
- font-family: PingFangSC-Regular, PingFang SC;
- font-weight: 400;
- color: #333333;
- }
- text:last-child {
- width: 80rpx;
- line-height: 46rpx;
- background: #1F7EFF;
- border-radius: 8rpx;
- text-align: center;
- font-size: 24rpx;
- font-family: PingFangSC-Regular, PingFang SC;
- font-weight: 400;
- color: #FFFFFF;
- }
- }
- }
- .lishi-box {
- padding: 0 24rpx;
- .lishi-item {
- line-height: 44rpx;
- background: #E5E5E5;
- border-radius: 22rpx;
- padding: 0 30rpx;
- font-size: 18rpx;
- font-family: PingFangSC-Regular, PingFang SC;
- font-weight: 400;
- color: #999999;
- margin-bottom: 20rpx;
- margin-right: 20rpx;
- }
- .lishi-title {
- font-size: 24rpx;
- font-family: PingFangSC-Medium, PingFang SC;
- font-weight: 500;
- color: #333333;
- margin-bottom: 14rpx;
- }
- }
- .search-box {
- width: 702rpx;
- height: 72rpx;
- background: #FFFFFF;
- border-radius: 20rpx;
- margin: 24rpx auto;
- padding-left: 24rpx;
- border: 2rpx solid #CCCCCC;
- position: sticky;
- top: 0;
- left: 0;
- .input {
- flex: 1;
- margin: 0 10rpx;
- }
- .text {
- padding: 0 24rpx;
- border-left: 1rpx solid #E5E7ED;
- line-height: 36rpx;
- font-size: 28rpx;
- font-family: PingFangSC-Medium, PingFang SC;
- font-weight: 500;
- color: #1E7DFF;
- }
- }
- }
- </style>
|