海南旅游项目 前端仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

434 lines
11 KiB

5 years ago
5 years ago
5 years ago
  1. <template>
  2. <view>
  3. <view class="lf-p-t-30 lf-p-b-30">
  4. <view class="lf-m-b-30 lf-flex lf-w-100">
  5. <u-icon name="search" class="search-icon"></u-icon>
  6. <input class="rom-search" type="text" placeholder="请输入商品名称" @confirm="startSearch()" v-model="search_content" />
  7. </view>
  8. <view class="special_tab">
  9. <u-tabs :list="tab_list" active-color="#1998FE" inactive-color='#777777' :is-scroll="true" @click="clicksort" :current="current" @change="tabChange"></u-tabs>
  10. <view style="position: absolute;right: 30rpx;top: 140rpx;display: flex;flex-direction: column;">
  11. <u-icon name="arrow-up" style="font-size: 20rpx;" :class="sort==0?'':'lf-color-blue'"></u-icon>
  12. <u-icon name="arrow-down" style="font-size: 20rpx;" :class="sort==0?'lf-color-blue':''"></u-icon>
  13. </view>
  14. </view>
  15. <swiper :style="{height: '1300rpx', width: '750rpx'}" :current="current" @change="swiperChange">
  16. <swiper-item v-for="(tabItem, tabIndex) in tab_list" :key="tabIndex">
  17. <scroll-view class="com" :scroll-y="true" :refresher-enabled="true" :refresher-triggered="tabItem.isRefresher" @scrolltolower="onScrolltolower" @refresherrefresh="onRefresherrefresh">
  18. <view class="lf-m-t-20"></view>
  19. <view>
  20. <!-- 活动列表 -->
  21. <view class="content">
  22. <view class="item" v-for="(item,index) of tabItem.list" :key="index" @click="$url('/pages/goodsDetail/index?goods_id='+item.id)">
  23. <view class="cover">
  24. <image :src="item.picture" class="lf-w-100 lf-h-100" mode="aspectFill"></image>
  25. </view>
  26. <view style="width: 420rpx;">
  27. <view class="lf-font-28 lf-color-333 lf-line-2">{{item.title}}</view>
  28. <view class="lf-font-24 lf-color-gray lf-line-2 lf-m-t-10" style="min-height: 64rpx;">本套票只包含两个成人不可带小孩本套票只包含两个成人不可带小孩本套票只包含两个成人不可带小孩</view>
  29. <view class="lf-flex lf-m-t-25">
  30. <lf-price :price="item.price"></lf-price>
  31. <text class="lf-font-24 lf-color-gray lf-line-through lf-m-l-15">¥{{item.original_price}}</text>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <!-- 加载 -->
  37. <view class="loading-more">
  38. <text v-if="tabItem.list.length" :class="{'loading-more-text': loadingClass}">{{ loadingText }}</text>
  39. <lf-nocontent v-else></lf-nocontent>
  40. </view>
  41. <!-- 回到顶部 -->
  42. <u-back-top :scroll-top="pageScrollTop" :custom-style="{background: 'rgba(51, 51 51, 0.3)'}"></u-back-top>
  43. </view>
  44. </scroll-view>
  45. </swiper-item>
  46. </swiper>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. export default {
  52. data() {
  53. return {
  54. search_content: '',
  55. tab_list: [
  56. {
  57. id: 1,
  58. name: '综合',
  59. list: [],
  60. isRefresher: false,
  61. loadingClass: true,
  62. loadingText: '正在加载中',
  63. page: 1,
  64. isPage: true
  65. },
  66. {
  67. id: 2,
  68. name: '销量',
  69. list: [],
  70. isRefresher: false,
  71. loadingClass: true,
  72. loadingText: '正在加载中',
  73. page: 1,
  74. isPage: true
  75. },
  76. {
  77. id: 3,
  78. name: '上新',
  79. list: [],
  80. isRefresher: false,
  81. loadingClass: true,
  82. loadingText: '正在加载中',
  83. page: 1,
  84. isPage: true
  85. },
  86. {
  87. id: 4,
  88. name: '价格',
  89. list: [],
  90. isRefresher: false,
  91. loadingClass: true,
  92. loadingText: '正在加载中',
  93. page: 1,
  94. isPage: true
  95. },
  96. ],
  97. current: 0,
  98. windowHeight: 0,
  99. list: [],
  100. loadingClass: false,
  101. loadingText: '已加载全部数据~',
  102. page: 1,
  103. isPage: true,
  104. pageSize: 20,
  105. isRefresher: false,
  106. sort: 0,
  107. }
  108. },
  109. methods: {
  110. changeSort(sort) {
  111. console.log('排序')
  112. this.sort != this.sort
  113. this.getActivityList()
  114. },
  115. // scroll-view 下拉刷新
  116. onRefresherrefresh(){
  117. this.tab_list[this.current].isRefresher = true;
  118. this.$u.throttle(() => {
  119. this.getActivityList();
  120. }, 200);
  121. },
  122. // 页面触底,加载下一页
  123. onScrolltolower(){
  124. let tab_item = this.tab_list[this.current];
  125. if(tab_item.isPage){
  126. tab_item.page = tab_item.page + 1;
  127. this.getActivityList();
  128. }
  129. },
  130. getActivityList(){
  131. let tab_item = this.tab_list[this.current];
  132. this.$http(this.API.API_SEARCH_GOODS,{keywords:this.search_content,type:this.current,by: this.sort}).then(res => {
  133. let isPage = res.data.prev_page_url == null?false:true;
  134. tab_item.isPage = isPage;
  135. if(!isPage){
  136. tab_item.loadingClass = false;
  137. tab_item.loadingText = '没有更多数据啦~';
  138. }
  139. tab_item.isRefresher = false;
  140. if(tab_item.page == 1){
  141. tab_item.list = res.data.data;
  142. }else{
  143. tab_item.list.push(...res.data.data);
  144. }
  145. })
  146. },
  147. clicksort(index) {
  148. if(index == 3) {
  149. if(this.sort == 0) {
  150. this.sort = 1
  151. }else {
  152. this.sort = 0
  153. }
  154. this.getActivityList()
  155. }else {
  156. return
  157. }
  158. },
  159. tabChange(index){
  160. this.current = index;
  161. console.log('重复只想')
  162. this.getActivityList()
  163. },
  164. // 滑块下标值变化
  165. swiperChange(event){
  166. this.current = event.detail.current;
  167. if(event.detail.source == '') return; // 如果是被动出发,没有事件类型则不做处理
  168. },
  169. startSearch() {
  170. console.log('当前值',this.search_content)
  171. this.getActivityList()
  172. },
  173. },
  174. onShow(){
  175. this.windowHeight = getApp().globalData.windowHeight;
  176. },
  177. onLoad(e) {
  178. this.search_content = e.serach_content
  179. if(this.search_content) {
  180. this.getActivityList()
  181. }
  182. console.log('传来的搜索',e)
  183. }
  184. }
  185. </script>
  186. <style lang="scss" scoped>
  187. .content{
  188. padding: 0;
  189. box-sizing: border-box;
  190. width: 750rpx;
  191. height: max-content;
  192. .item{
  193. width: 100%;
  194. height: auto;
  195. border-bottom: 1rpx solid #E5E5E5;
  196. padding: 30rpx 0;
  197. display: flex;
  198. &:last-child{
  199. border-bottom: none;
  200. }
  201. .cover{
  202. width: 250rpx;
  203. height: 210rpx;
  204. border-radius: 20rpx;
  205. overflow: hidden;
  206. margin-right: 15rpx;
  207. }
  208. }
  209. }
  210. .search-icon {
  211. position: relative;
  212. bottom: 0;
  213. left: 54rpx;
  214. }
  215. /deep/.input-placeholder{
  216. color: #777;
  217. font-size: 28rpx;
  218. }
  219. .rom-search {
  220. width: 686rpx;
  221. height: 60rpx;
  222. background: #f5f5f5;
  223. border-radius: 30rpx;
  224. padding-left: 74rpx;
  225. font-size: 28rpx;
  226. }
  227. .goods-rom {
  228. border-radius: 20rpx;
  229. width: 333rpx;
  230. height: 497rpx;
  231. background-color: white;
  232. box-shadow: 0px 2rpx 8rpx 1rpx rgba(0, 0, 0, 0.1);
  233. &:nth-child(2n) {
  234. margin-right: 0;
  235. }
  236. &:nth-child(n + 3) {
  237. margin-top: 20rpx;
  238. }
  239. }
  240. .introduct {
  241. padding: 0 0 30rpx 32rpx;
  242. }
  243. .com{
  244. width: 100%;
  245. height: 100%;
  246. box-sizing: border-box;
  247. padding: 0rpx 28rpx;
  248. }
  249. .shop-head {
  250. width: 100%;
  251. height: 400rpx;
  252. position: relative;
  253. }
  254. .shop-flex {
  255. display: flex;
  256. padding: 30rpx;
  257. }
  258. .shop-title {
  259. width: 686rpx;
  260. height: 274rpx;
  261. border-radius: 20rpx;
  262. background-color: white;
  263. box-shadow: 0rpx 2rpx 8rpx 1rpx rgba(0, 0, 0, 0.1);
  264. margin: 0 auto;
  265. position: relative;
  266. top: -32rpx;
  267. }
  268. .shop-img {
  269. width: 90rpx;
  270. height: 90rpx;
  271. margin-right: 15rpx;
  272. }
  273. .shop-function {
  274. width: 80rpx;
  275. height: 80rpx;
  276. border-radius: 50%;
  277. font-size: 40rpx;
  278. }
  279. .function-total {
  280. display: flex;
  281. justify-content: space-between;
  282. padding: 0 65rpx 0 65rpx;
  283. }
  284. /deep/.u-scroll-box {
  285. display: flex;
  286. justify-content: center;
  287. align-items: center;
  288. border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  289. }
  290. /deep/.u-scroll-box .u-tab-bar {
  291. background-color: #1998FE!important;
  292. width: 80rpx!important;
  293. position: absolute;
  294. left: 0;
  295. bottom: -12rpx;
  296. }
  297. /deep/.special_tab .u-tabs .u-scroll-box .u-tab-bar {
  298. background-color: #1998FE!important;
  299. width: 56rpx!important;
  300. position: absolute;
  301. height: 5rpx!important;
  302. left: 8rpx;
  303. bottom: -4rpx;
  304. }
  305. /deep/ .u-tab-item {
  306. font-size: 28rpx!important;
  307. }
  308. //价格筛选伪类
  309. // /deep/.special_tab .u-tab-item:nth-child(4n) ::after{
  310. // font-size: 48rpx!important;
  311. // content: '';
  312. // color: red;
  313. // }
  314. // loading加载
  315. .loading-more {
  316. align-items: center;
  317. justify-content: center;
  318. padding-top: 10px;
  319. padding-bottom: 10px;
  320. text-align: center;
  321. font-size: 28rpx;
  322. color: #999;
  323. }
  324. .loading-more-text::before {
  325. content: '';
  326. width: 20px;
  327. height: 20px;
  328. display: inline-block;
  329. vertical-align: middle;
  330. -webkit-animation: weuiLoading 1s steps(12, end) infinite;
  331. animation: weuiLoading 1s steps(12, end) infinite;
  332. background-repeat: no-repeat;
  333. background-image: url("data:image/svg+xml;charset=utf8, %3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 100 100'%3E%3Cpath fill='none' d='M0 0h100v100H0z'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23E9E9E9' rx='5' ry='5' transform='translate(0 -30)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23989697' rx='5' ry='5' transform='rotate(30 105.98 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%239B999A' rx='5' ry='5' transform='rotate(60 75.98 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23A3A1A2' rx='5' ry='5' transform='rotate(90 65 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23ABA9AA' rx='5' ry='5' transform='rotate(120 58.66 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23B2B2B2' rx='5' ry='5' transform='rotate(150 54.02 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23BAB8B9' rx='5' ry='5' transform='rotate(180 50 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23C2C0C1' rx='5' ry='5' transform='rotate(-150 45.98 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23CBCBCB' rx='5' ry='5' transform='rotate(-120 41.34 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23D2D2D2' rx='5' ry='5' transform='rotate(-90 35 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23DADADA' rx='5' ry='5' transform='rotate(-60 24.02 65)'/%3E%3Crect width='7' height='20' x='46.5' y='40' fill='%23E2E2E2' rx='5' ry='5' transform='rotate(-30 -5.98 65)'/%3E%3C/svg%3E");
  334. background-size: 100%;
  335. }
  336. @keyframes weuiLoading {
  337. 0% {
  338. transform: rotate3d(0, 0, 1, 0deg);
  339. }
  340. 100% {
  341. transform: rotate3d(0, 0, 1, 360deg);
  342. }
  343. }
  344. .list-warter {
  345. border-radius: 20rpx;
  346. margin: 10px 5px;
  347. margin-top: 0px;
  348. background-color: #ffffff;
  349. // padding: 8px;
  350. position: relative;
  351. overflow: hidden;
  352. box-shadow: 0rpx 2rpx 8rpx 1rpx rgba(0, 0, 0, 0.1);
  353. }
  354. .u-close {
  355. position: absolute;
  356. top: 32rpx;
  357. right: 32rpx;
  358. }
  359. .list-image {
  360. width: 100%;
  361. border-radius: 4px;
  362. }
  363. .list-title {
  364. font-size: 28rpx;
  365. // font-weight: bold;
  366. color: $u-main-color;
  367. }
  368. .list-label{
  369. position: absolute;
  370. bottom: 0;
  371. right: 0;
  372. background-color: rgba(0,0,0,0.5);
  373. width: 140rpx;
  374. height: 48rpx;
  375. border-radius: 20rpx 0rpx 0rpx 0rpx;
  376. font-size: 22rpx;
  377. color: #FFFFFF;
  378. line-height: 48rpx;
  379. text-align: center;
  380. }
  381. .list-tag {
  382. display: flex;
  383. margin-top: 5px;
  384. }
  385. .list-tag-owner {
  386. background-color: $u-type-error;
  387. color: #FFFFFF;
  388. display: flex;
  389. align-items: center;
  390. padding: 4rpx 14rpx;
  391. border-radius: 50rpx;
  392. font-size: 20rpx;
  393. line-height: 1;
  394. }
  395. .list-tag-text {
  396. border: 1px solid $u-type-primary;
  397. color: $u-type-primary;
  398. margin-left: 10px;
  399. border-radius: 50rpx;
  400. line-height: 1;
  401. padding: 4rpx 14rpx;
  402. display: flex;
  403. align-items: center;
  404. border-radius: 50rpx;
  405. font-size: 20rpx;
  406. }
  407. .list-price {
  408. font-size: 30rpx;
  409. color: $u-type-error;
  410. margin-top: 5px;
  411. display: flex;
  412. align-items: center;
  413. }
  414. </style>