123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- <template>
- <view class="content">
- <view class="search">
- <u-input v-model="serach_value" type="text" :border="true" placeholder="输入搜索关键词" shape="circle"
- prefixIcon="search" prefixIconStyle="font-size: 22px;color: #909399" @confirm="search">
- <template slot="suffix">
- <view @click="search">搜索</view>
- </template>
- </u-input>
- </view>
- <view class="swiper">
- <u-swiper :list="bannerList" radius="20rpx" @click="toBanner" keyName="img" height="160"></u-swiper>
- </view>
- <view class="box">
- <view class="tabs hflex acenter jbetween">
- <block v-for="(item,index) in tabs" :key="index">
- <view class="tabs_item" :class="active == item.id ? 'active' : ''" @click="changeTabs(item.id)">{{item.name}}</view>
- </block>
- </view>
- <view class="list" v-if="pageList.length > 0">
- <block v-for="(item,index) in pageList" :key="index">
- <view class="list_item hflex acenter jbetween" @click="toDetail(item.id)">
- <image :src="item.head_img" class="item_img" mode="aspectFill"></image>
- <view class="item_right vflex jbetween">
- <view class="hflex acenter jbetween">
- <view class="name">{{item.name}}</view>
- <view class="shipyard">{{item.pos}}</view>
- </view>
- <view class="address">{{item.address}}</view>
- </view>
- </view>
- </block>
- </view>
- <!-- <view v-else>
- <u-empty icon="https://ship-expert.zhousi.hdlkeji.com/common/zhan.png" text="暂时没有数据哦">
- </view> -->
- </view>
- </view>
- </template>
- <script>
- import $api from '@/static/js/api.js'
- var that = ''
- export default {
- data() {
- return {
- serach_value: '',
- bannerList: [
- ],
- tabs: [
- {
- id: 1,
- name: '综合推荐'
- },
- {
- id: 2,
- name: '距离'
- }
- ],
- active: 1,
- pageList: [
- ],
- page: 1,
- limit: 10,
- total: 1,
- }
- },
- onLoad() {
- that = this
- that.getBanner()
- var token = uni.getStorageSync('token')
- console.log(token);
- if(!token) {
- $api.info("请先登录")
- setTimeout(() => {
- $api.jump('/pages/login/code_login')
- },1000)
- }
- },
- onShow() {
-
- that.getList()
- },
- onPullDownRefresh() {
- var token = uni.getStorageSync('token')
- console.log(token);
- if(!token) {
- $api.jump('/pages/login/code_login')
- }
- that.getList()
- },
- methods: {
- getBanner() {
- $api.req({
- url: '/data/api.Data/getSlider',
- data: {
- keys: 'data_shipyard'
-
- }
- }, function(res) {
- if(res.code == 1) {
- that.bannerList = res.data
- }
- })
- },
- // banner图跳转
- toBanner(e) {
- var url = that.bannerList[e].url
- if(url == '#') {
- return
- }
- $api.jump('/pages/user/web_view?src=' +url)
- },
- getList() {
- $api.req({
- url: '/data/api.ShipYard/index',
- data: {
- sort: that.active,
- keyword: that.serach_value,
- longitude: uni.getStorageSync('userLocation').split(',')[0],
- latitude: uni.getStorageSync('userLocation').split(',')[1],
- page: that.page
- }
- }, function(res) {
- if(res.code == 1) {
- if(that.page == 1) {
- that.pageList = res.data.data
- } else {
- that.pageList = that.pageList.concat(res.data.data)
- }
- that.total = res.data.total
- that.limit = res.data.per_page
- }else if (res.code == 401) {
- $api.info("请先登录")
- setTimeout(() => {
- $api.jump('/pages/login/code_login')
- },1000)
- }
- uni.stopPullDownRefresh();
- })
- },
- // 切换tabs
- changeTabs(id) {
- that.active = id
- that.page = 1
- that.pageList = []
- that.getList()
- },
- toDetail(id) {
- $api.jump('/pages/tabbar/shipyard/detail?id=' + id)
- },
- search() {
- that.getList()
- // $api.jump('/pages/tabbar/shipyard/news?value=' + that.serach_value)
- },
- onReachBottom() {
- if (Number(that.page) * Number(that.limit) >= Number(that.total)) {
- $api.info("没有更多了")
- } else {
- that.page++
- that.getList()
- }
-
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .content::v-deep {
- background-color: #f6f6f6;
-
- .search {
- // background: #fff;
- width: 100%;
- height: 88rpx;
- box-sizing: border-box;
- padding: 12rpx 30rpx;
- .u-input {
- background-color: #fff;
- height: 64rpx;
- padding: 0 0 0 18rpx !important;
- border: 1rpx solid #506Dff;
- margin-bottom: 12rpx;
- }
- .u-input__content__subfix-icon {
- width: 128rpx;
- height: 64rpx;
- background-color: #506Dff;
- border-radius: 32rpx;
- color: #fff;
- font-size: 28rpx;
- text-align: center;
- line-height: 64rpx;
- }
- }
- .swiper {
- width: 100%;
- margin-top: 20rpx;
- box-sizing: border-box;
- padding: 0 30rpx;
- }
- .box {
- width: 690rpx;
- margin: 20rpx 30rpx 0;
- background: #fff;
- border-radius: 20rpx;
- box-sizing: border-box;
- padding: 24rpx 20rpx;
-
- .tabs {
- width: 100%;
- .tabs_item {
- width: 312rpx;
- height: 56rpx;
- background-color: #f6f6f6;
- border-radius: 8rpx;
- font-size: 28rpx;
- color: #444;
- text-align: center;
- line-height: 56rpx;
- }
- .active {
- background-color: #f1f3ff;
- color: #506dff;
- }
- }
- .list {
-
- .list_item {
- width: 100%;
- height: 152rpx;
- box-sizing: border-box;
- padding: 24rpx 0;
- border-bottom: 1rpx solid #f6f6f6;
- .item_img {
- width: 104rpx;
- height: 104rpx;
- border-radius: 16rpx;
- margin-right: 20rpx;
- }
- .item_right {
- width: calc(100% - 124rpx);
- height: 100%;
- .name {
- width: 80%;
- color: #333;
- font-size: 28rpx;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- .shipyard{
- width: auto;
- height: 28rpx;
- background-color: #506dff;
- border-radius: 5rpx;
- font-size: 16rpx;
- color: #fff;
- text-align: center;
- line-height: 28rpx;
- padding: 0 8rpx;
- box-sizing: border-box;
- }
- }
- .address {
- font-size: 20rpx;
- color: #666;
- padding-bottom: 20rpx;
- }
- }
- .list_item:nth-last-child(1) {
- padding-bottom: 0;
- border: none;
- }
- }
- }
-
- }
- </style>
|