123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- <template>
- <view class="search-scenic">
- <view class="search-box">
- <view class="city-box">
- <image class="icon" src="@/static/blue-position.png" mode=""></image>
- <view class="city">
- {{city}}
- </view>
- </view>
- <input class="search" v-model="query.key" focus type="text" placeholder="景点名称" />
- </view>
-
- <zs-list class="list" mt="0" @load="loadMore" :status="status">
- <view class="item" v-for="item in list" :key="item.scenicId" @click="goDetail(item)">
- <zs-img :src="item.newPicUrl" width="200rpx" height="200rpx" radius="full" mode="center"></zs-img>
- <view class="info">
- <view class="title">
- {{item.scenicName}}
- </view>
- <view class="price-box">
- <view class="unit">
- ¥
- </view>
- <view class="price">
- 580
- </view>
- <view class="text">
- 起
- </view>
- </view>
- <view class="address-box">
- <view class="address">
- 重庆
- </view>
- <view class="distance">
- {{item|filterDistance}} KM
- </view>
- </view>
- </view>
- </view>
-
- </zs-list>
-
- </view>
- </template>
- <script>
- import {debounce} from '@/utils/tool.js'
- import {getScenicList} from '@/api/scenic.js'
- export default {
- data() {
- return {
- city: uni.getStorageSync('city'),
- status:'more',
- list:[],
- query:{
- key: "",
- page: 1,
- pageSize: 10
- },
- }
- },
- watch: {
- 'query.key':debounce(function(val) {
- console.log(111111);
- this.query.page = 1
- this.list = []
- this.status = 'more'
- this.getScenicList()
- if(val){
- }
- })
- },
- filters: {
- filterDistance: function(item) {
- if(!item.glocation) return '-'
- let blocation = item.glocation.split(',')
- let location = JSON.parse(uni.getStorageSync('location'))
- /*参数:两地的经纬度数值*/
- var radLat1 = location.latitude * Math.PI / 180.0;
- var radLat2 = blocation[0]* Math.PI / 180.0;
- var a = radLat1 - radLat2;
- var b = location.longitude* Math.PI / 180.0 - blocation[1]* Math.PI / 180.0;
- var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
- Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
- s = s * 6378137.0;//地球半径 单位米;
- s = Math.round(s * 10000) / 10000 /1000 //输出为千米
- s = s.toFixed(0)
- return s
-
- }
- },
- methods: {
- loadMore(){
- this.getScenicList()
- },
- getScenicList(){
- // if(!this.query.key) return
- this.status = 'loading'
- getScenicList(this.query).then(res=>{
- if(res.state == 'Success'){
- this.list = this.list.concat(res.content.data.rows)
- if(this.list.length>= res.content.data.totalCount){
- this.status = 'noMore'
- }else{
- this.status = 'more'
- this.query.page++
- }
- }
- })
- },
- goDetail(item){
- uni.navigateTo({
- url:'/scenic/detail?id='+item.scenicId
- })
- }
- },
- onLoad() {
- uni.setNavigationBarTitle({
- title: uni.getStorageSync('city')
- });
- }
- }
- </script>
- <style lang="scss" >
- .search-scenic{
- min-height: 100vh;
- padding: 112rpx 24rpx 0;
- .search-box{
- position: fixed;
- top: 20rpx;
- left: 24rpx;
- width: 702rpx;
- height: 72rpx;
- // padding: 16rpx;
- box-sizing: border-box;
- z-index: 9;
- background: #F6F6F6;
- border-radius: 40rpx 40rpx 40rpx 40rpx;
- .city-box{
- position: absolute;
- left: 0;
- top: 50%;
- transform: translateY(-50%);
- display: flex;
- align-items: center;
- padding: 0 28rpx;
- border-right: 1rpx solid #F0F0F0;
- .icon{
- width: 30rpx;
- height: 30rpx;
- }
- .city{
- font-weight: 600;
- font-size: 28rpx;
- color: #222222;
- margin-left: 6rpx;
- }
- }
- .search{
- width: 702rpx;
- height: 72rpx;
- border-radius: 40rpx 40rpx 40rpx 40rpx;
- padding-left: 230rpx;
- padding-right: 100rpx;
- box-sizing: border-box;
- }
- }
- .zs-list{
- .item{
- background: #FFFFFF;
- border-radius: 16rpx;
- display: flex;
- padding: 12rpx 0;
- border-bottom: 1rpx solid #F0F0F0;
- .zs-img{
- width: 200rpx;
- }
- .info{
- flex: 1;
- padding: 30rpx 20rpx 20rpx;
- box-sizing: border-box;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- .title{
- font-weight: 400;
- font-size: 24rpx;
- color: #222222;
- width: 450rpx;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .price-box{
- display: flex;
- align-items: flex-end;
- margin-top: 12rpx;
- .unit{
- font-weight: 600;
- font-size: 20rpx;
- color: $uni-color-primary;
- }
- .price{
- font-weight: 600;
- font-size: 36rpx;
- color: $uni-color-primary;
- }
- .text{
- font-weight: 300;
- font-size: 24rpx;
- color: #AAAAAA;
- margin-left: 6rpx;
- }
- }
- .address-box{
- display: flex;
- align-items: center;
- justify-content: space-between;
- font-weight: 300;
- font-size: 20rpx;
- color: #AAAAAA;
- margin-top: 12rpx;
- }
- }
- }
- }
- }
- </style>
|