shipyard.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <view class="content">
  3. <view class="search">
  4. <u-input v-model="serach_value" type="text" :border="true" placeholder="输入搜索关键词" shape="circle"
  5. prefixIcon="search" prefixIconStyle="font-size: 22px;color: #909399" @confirm="search">
  6. <template slot="suffix">
  7. <view @click="search">搜索</view>
  8. </template>
  9. </u-input>
  10. </view>
  11. <view class="swiper">
  12. <u-swiper :list="bannerList" radius="20rpx" @click="toBanner" keyName="img" height="160"></u-swiper>
  13. </view>
  14. <view class="box">
  15. <view class="tabs hflex acenter jbetween">
  16. <block v-for="(item,index) in tabs" :key="index">
  17. <view class="tabs_item" :class="active == item.id ? 'active' : ''" @click="changeTabs(item.id)">{{item.name}}</view>
  18. </block>
  19. </view>
  20. <view class="list" v-if="pageList.length > 0">
  21. <block v-for="(item,index) in pageList" :key="index">
  22. <view class="list_item hflex acenter jbetween" @click="toDetail(item.id)">
  23. <image :src="item.head_img" class="item_img" mode="aspectFill"></image>
  24. <view class="item_right vflex jbetween">
  25. <view class="hflex acenter jbetween">
  26. <view class="name">{{item.name}}</view>
  27. <view class="shipyard">{{item.pos}}</view>
  28. </view>
  29. <view class="address">{{item.address}}</view>
  30. </view>
  31. </view>
  32. </block>
  33. </view>
  34. <!-- <view v-else>
  35. <u-empty icon="https://ship-expert.zhousi.hdlkeji.com/common/zhan.png" text="暂时没有数据哦">
  36. </view> -->
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import $api from '@/static/js/api.js'
  42. var that = ''
  43. export default {
  44. data() {
  45. return {
  46. serach_value: '',
  47. bannerList: [
  48. ],
  49. tabs: [
  50. {
  51. id: 1,
  52. name: '综合推荐'
  53. },
  54. {
  55. id: 2,
  56. name: '距离'
  57. }
  58. ],
  59. active: 1,
  60. pageList: [
  61. ],
  62. page: 1,
  63. limit: 10,
  64. total: 1,
  65. }
  66. },
  67. onLoad() {
  68. that = this
  69. that.getBanner()
  70. var token = uni.getStorageSync('token')
  71. console.log(token);
  72. if(!token) {
  73. $api.info("请先登录")
  74. setTimeout(() => {
  75. $api.jump('/pages/login/code_login')
  76. },1000)
  77. }
  78. },
  79. onShow() {
  80. that.getList()
  81. },
  82. onPullDownRefresh() {
  83. var token = uni.getStorageSync('token')
  84. console.log(token);
  85. if(!token) {
  86. $api.jump('/pages/login/code_login')
  87. }
  88. that.getList()
  89. },
  90. methods: {
  91. getBanner() {
  92. $api.req({
  93. url: '/data/api.Data/getSlider',
  94. data: {
  95. keys: 'data_shipyard'
  96. }
  97. }, function(res) {
  98. if(res.code == 1) {
  99. that.bannerList = res.data
  100. }
  101. })
  102. },
  103. // banner图跳转
  104. toBanner(e) {
  105. var url = that.bannerList[e].url
  106. if(url == '#') {
  107. return
  108. }
  109. $api.jump('/pages/user/web_view?src=' +url)
  110. },
  111. getList() {
  112. $api.req({
  113. url: '/data/api.ShipYard/index',
  114. data: {
  115. sort: that.active,
  116. keyword: that.serach_value,
  117. longitude: uni.getStorageSync('userLocation').split(',')[0],
  118. latitude: uni.getStorageSync('userLocation').split(',')[1],
  119. page: that.page
  120. }
  121. }, function(res) {
  122. if(res.code == 1) {
  123. if(that.page == 1) {
  124. that.pageList = res.data.data
  125. } else {
  126. that.pageList = that.pageList.concat(res.data.data)
  127. }
  128. that.total = res.data.total
  129. that.limit = res.data.per_page
  130. }else if (res.code == 401) {
  131. $api.info("请先登录")
  132. setTimeout(() => {
  133. $api.jump('/pages/login/code_login')
  134. },1000)
  135. }
  136. uni.stopPullDownRefresh();
  137. })
  138. },
  139. // 切换tabs
  140. changeTabs(id) {
  141. that.active = id
  142. that.page = 1
  143. that.pageList = []
  144. that.getList()
  145. },
  146. toDetail(id) {
  147. $api.jump('/pages/tabbar/shipyard/detail?id=' + id)
  148. },
  149. search() {
  150. that.getList()
  151. // $api.jump('/pages/tabbar/shipyard/news?value=' + that.serach_value)
  152. },
  153. onReachBottom() {
  154. if (Number(that.page) * Number(that.limit) >= Number(that.total)) {
  155. $api.info("没有更多了")
  156. } else {
  157. that.page++
  158. that.getList()
  159. }
  160. }
  161. }
  162. }
  163. </script>
  164. <style lang="scss" scoped>
  165. .content::v-deep {
  166. background-color: #f6f6f6;
  167. .search {
  168. // background: #fff;
  169. width: 100%;
  170. height: 88rpx;
  171. box-sizing: border-box;
  172. padding: 12rpx 30rpx;
  173. .u-input {
  174. background-color: #fff;
  175. height: 64rpx;
  176. padding: 0 0 0 18rpx !important;
  177. border: 1rpx solid #506Dff;
  178. margin-bottom: 12rpx;
  179. }
  180. .u-input__content__subfix-icon {
  181. width: 128rpx;
  182. height: 64rpx;
  183. background-color: #506Dff;
  184. border-radius: 32rpx;
  185. color: #fff;
  186. font-size: 28rpx;
  187. text-align: center;
  188. line-height: 64rpx;
  189. }
  190. }
  191. .swiper {
  192. width: 100%;
  193. margin-top: 20rpx;
  194. box-sizing: border-box;
  195. padding: 0 30rpx;
  196. }
  197. .box {
  198. width: 690rpx;
  199. margin: 20rpx 30rpx 0;
  200. background: #fff;
  201. border-radius: 20rpx;
  202. box-sizing: border-box;
  203. padding: 24rpx 20rpx;
  204. .tabs {
  205. width: 100%;
  206. .tabs_item {
  207. width: 312rpx;
  208. height: 56rpx;
  209. background-color: #f6f6f6;
  210. border-radius: 8rpx;
  211. font-size: 28rpx;
  212. color: #444;
  213. text-align: center;
  214. line-height: 56rpx;
  215. }
  216. .active {
  217. background-color: #f1f3ff;
  218. color: #506dff;
  219. }
  220. }
  221. .list {
  222. .list_item {
  223. width: 100%;
  224. height: 152rpx;
  225. box-sizing: border-box;
  226. padding: 24rpx 0;
  227. border-bottom: 1rpx solid #f6f6f6;
  228. .item_img {
  229. width: 104rpx;
  230. height: 104rpx;
  231. border-radius: 16rpx;
  232. margin-right: 20rpx;
  233. }
  234. .item_right {
  235. width: calc(100% - 124rpx);
  236. height: 100%;
  237. .name {
  238. width: 80%;
  239. color: #333;
  240. font-size: 28rpx;
  241. overflow: hidden;
  242. white-space: nowrap;
  243. text-overflow: ellipsis;
  244. }
  245. .shipyard{
  246. width: auto;
  247. height: 28rpx;
  248. background-color: #506dff;
  249. border-radius: 5rpx;
  250. font-size: 16rpx;
  251. color: #fff;
  252. text-align: center;
  253. line-height: 28rpx;
  254. padding: 0 8rpx;
  255. box-sizing: border-box;
  256. }
  257. }
  258. .address {
  259. font-size: 20rpx;
  260. color: #666;
  261. padding-bottom: 20rpx;
  262. }
  263. }
  264. .list_item:nth-last-child(1) {
  265. padding-bottom: 0;
  266. border: none;
  267. }
  268. }
  269. }
  270. }
  271. </style>