home.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. <template>
  2. <view class="zaiui-home-box show" >
  3. <bar-title bgColor='bg-red' :isBack="false" :title="place.name">
  4. <block slot="content">{{place.name}}</block>
  5. <block slot="right">
  6. </block>
  7. </bar-title>
  8. <view class="zaiui-head-search-box" :class="headInfo.Class">
  9. <!--搜索框-->
  10. <view class="cu-bar search zaiui-search-box">
  11. <form @submit="search">
  12. <view class="search-form round">
  13. <text class="cuIcon-search"/>
  14. <input type="search" />
  15. </view>
  16. </form>
  17. <view class="action text-white"></view>
  18. </view>
  19. <!--选项卡-->
  20. <view class="zaiui-flex-tab show">
  21. <view class="flex text-white">
  22. <view class="basis-xxl">
  23. <scroll-view scroll-x class="nav z" scroll-with-animation :scroll-left="headTab.scrollLeft">
  24. <block v-for="(item,index) in headTab.list" :key="item.id">
  25. <view class="cu-item" :class="item.id==headTab.TabCur?'select':''" @tap="tabSelect" :data-id="item.id">
  26. <view>{{item.name}}</view>
  27. <view class="tab-dot bg-white"/>
  28. </view>
  29. </block>
  30. </scroll-view>
  31. </view>
  32. <!-- <view class="basis-xxs">
  33. <view class="sort-icon" @tap="sortVueTap">
  34. <text class="cuIcon-sort"/>
  35. </view>
  36. </view> -->
  37. </view>
  38. </view>
  39. </view>
  40. <!--中间内容区域-->
  41. <view class="zaiui-view-content" :class="[headTab.TabCur==0?'show':'']">
  42. <!--滑动菜单-->
  43. <grid-menu-list v-if="gridMenuData.length" :list_data='gridMenuData' @listTap='gridMenuTap'/>
  44. <!--红包块-->
  45. <!-- <view class="bg-red margin radius padding-sm">
  46. <image class="red-envelopes" src="/static/images/home/sundry/2.png" mode="widthFix"/>
  47. </view> -->
  48. <!--免费鉴别-->
  49. <!-- <identify-list :list_data='identifyData' @listTap='identifyTap'/> -->
  50. <!--省心快卖-->
  51. <!-- <sell-quickly-list :list_data='quickly' @listTap='quicklyTap'/> -->
  52. <!--活动区域-->
  53. <!-- <activity-list :list_data='activity' @listTap='activityTap'/> -->
  54. <!--商品tab-->
  55. <!-- <view class="zaiui-goods-tab-box">
  56. <scroll-view scroll-x class="nav z margin-tb-sm">
  57. <view class="flex text-center">
  58. <block v-for="(item,index) in goodsTabData.list" :key="index">
  59. <view class="cu-item flex-sub nf" :class="index==goodsTabData.TabCur?'select':''" @tap="goodsTab" :data-id="index">
  60. <view class="cu-tag badge z bg-gradual-pink" v-if="item.tag">{{item.tag}}</view>
  61. <view :class="index == goodsTabData.TabCur?'text-red':''">{{item.title}}</view>
  62. <view class="tab-dot bg-red"/>
  63. </view>
  64. </block>
  65. </view>
  66. </scroll-view>
  67. </view> -->
  68. <view class="zaiui-tab-list">
  69. <!--商品列表-->
  70. <goods-list :list_data="goodsData" @listTap="goodsListTap" :show="goodsTabData.TabCur!=2 && goodsTabData.TabCur!=4?true:false"/>
  71. <!--直播列表-->
  72. <!-- <live-list :list_data="liveData" @listTap="liveListTap" :show="goodsTabData.TabCur==2?true:false"/> -->
  73. <!--视频列表-->
  74. <!-- <video-list :list_data="videoData" @listTap="videoListTap" :show="goodsTabData.TabCur==4?true:false"/> -->
  75. </view>
  76. <!--占位底部距离-->
  77. <view class="cu-tabbar-height"/>
  78. </view>
  79. <!--中间内容区域-分类-->
  80. <view class="zaiui-view-content" :class="headTab.TabCur!=0?'show':''">
  81. <!--宫格分类-->
  82. <grid-sort-list v-if="gridSortData.length" :list_data="gridSortData" @listTap="gridSortTap"/>
  83. <!--广告-->
  84. <!-- <view class="margin">
  85. <image class="zaiui-ad-img" src="/static/images/home/swiper/swiper-1.png" mode="widthFix"/>
  86. </view> -->
  87. <!--标题-->
  88. <!-- <view class="margin-bottom-sm zaiui-tab-list-title">
  89. <view class="flex flex-wrap">
  90. <view class="basis-sm text-right">
  91. <image class="img-aau" src="/static/zaiui/img/aau.png" lazy-load mode="widthFix"/>
  92. </view>
  93. <view class="basis-xs text-center">
  94. <text class="text-black text-xl text-bold">为您推荐</text>
  95. </view>
  96. <view class="basis-sm text-left">
  97. <image class="img-aau" src="/static/zaiui/img/aau.png" lazy-load mode="widthFix"/>
  98. </view>
  99. </view>
  100. </view> -->
  101. <!--商品列表-->
  102. <goods-list :list_data="goodsData" @listTap="goodsListTap"/>
  103. <!--占位底部距离-->
  104. <view class="cu-tabbar-height"/>
  105. </view>
  106. <!--弹出框-->
  107. <modal-img :show="modalShow" src="/static/images/home/sundry/reward.png" @imgTap="imgTap" @closeTap="closeTap"/>
  108. </view>
  109. </template>
  110. <script>
  111. //加载组件
  112. import welcomeTip from '@/components/zaiui-common/basics/welcome-tip';
  113. import swiperBackground from '@/components/zaiui-common/basics/swiper-background';
  114. import gridMenuList from '@/components/zaiui-common/list/grid-menu-list';
  115. import identifyList from '@/components/zaiui-common/list/identify-list';
  116. import sellQuicklyList from '@/components/zaiui-common/list/sell-quickly-list';
  117. import activityList from '@/components/zaiui-common/list/activity-list';
  118. import goodsList from '@/components/zaiui-common/list/goods-list';
  119. import liveList from '@/components/zaiui-common/list/live-list';
  120. import videoList from '@/components/zaiui-common/list/video-list';
  121. import footerTabbar from '@/components/zaiui-common/footer/footer-tabbar';
  122. import gridSortList from '@/components/zaiui-common/list/grid-sort-list';
  123. import modalImg from '@/components/zaiui-common/basics/modal-img';
  124. //======================================================================
  125. import _home_data from '@/static/zaiui/data/home.js'; //虚拟数据
  126. import _tool from '@/static/zaiui/util/tools.js';
  127. import barTitle from '@/components/zaiui-common/basics/bar-title';
  128. export default {
  129. name: 'home',
  130. components: {
  131. welcomeTip, swiperBackground, gridMenuList, identifyList, sellQuicklyList, activityList, goodsList, liveList, videoList, footerTabbar,
  132. gridSortList, modalImg,barTitle
  133. },
  134. data() {
  135. return {
  136. swiperInfo: {index: 0, show: true, welcome: true, list: []}, headInfo: {Class: "", opacity: 0,}, goodsShow: true,
  137. headTab: {TabCur: 0, scrollLeft: 0, list: []}, viewContent: {welcome: false,}, gridMenuData: [], identifyData: [],
  138. quickly: {}, activity: [], goodsTabData: {TabCur: 0, list: []}, goodsData: [], liveData: [], videoData: [],
  139. gridSortData: [], modalShow: false,
  140. place: {}
  141. }
  142. },
  143. props: {
  144. show: {
  145. type: Boolean,
  146. default: true
  147. },
  148. scrollY: {
  149. type: Number,
  150. default: 0
  151. },
  152. scrollBottom: {
  153. type: Number,
  154. default: 0
  155. }
  156. },
  157. watch: {
  158. scrollY() {
  159. //通知他妈的滚动了。
  160. this.setPageScroll(this.scrollY);
  161. },
  162. scrollBottom() {
  163. if(this.scrollBottom != 0) {
  164. //通知他妈的触底了
  165. this.setReachBottom();
  166. }
  167. },
  168. },
  169. created() {
  170. //加载虚拟数据
  171. // this.headTab.list = _home_data.tab();
  172. this.swiperInfo.list = _home_data.swiper();
  173. // this.gridMenuData = _home_data.nav();
  174. // this.identifyData = _home_data.live();
  175. // this.quickly.swiper = _home_data.earn();
  176. // this.quickly.list = _home_data.sellQuickly();
  177. // this.activity = _home_data.activity();
  178. // this.goodsTabData.list = _home_data.goodsTab();
  179. //商品列表数据
  180. // let GoodsData = _home_data.goodsList();
  181. //推荐感兴趣数据
  182. // let recommendData = _home_data.recommend();
  183. //把推荐感兴趣的数据,添加到商品数据里,可扩展为随机位置显示。
  184. // GoodsData.splice(1, 0, recommendData);
  185. // this.goodsData = GoodsData;
  186. this.headInfo.Class = '';
  187. this.welcomeClose(true)
  188. this.getListByCate('')
  189. },
  190. mounted() {
  191. uni.pageScrollTo({
  192. scrollTop: 0,
  193. duration: 0
  194. });
  195. //次级虚拟数据加载
  196. this.liveData = _home_data.liveData();
  197. this.videoData = _home_data.videoData();
  198. // this.gridSortData = _home_data.gridSortData();
  199. },
  200. methods: {
  201. search() {
  202. console.log('ddddd')
  203. },
  204. getListByCate(cate_id) {
  205. this.req({
  206. url: '?l=resource.home',
  207. data: {type: 3, cate_id},
  208. success: res => {
  209. if(res.data.status == 1) {
  210. console.log(res.data.data)
  211. if(!cate_id) {
  212. this.headTab.list = [{name: '全部', id: ''},...res.data.data.cate_parent];
  213. this.gridMenuData = res.data.data.cate_child
  214. } else {
  215. this.gridSortData = res.data.data.cate_child
  216. }
  217. this.goodsData = res.data.data.list;
  218. this.place = res.data.data.place;
  219. }else {
  220. this.error = res.data.msg
  221. }
  222. }
  223. })
  224. },
  225. //页面被滚动
  226. setPageScroll(scrollTop) {
  227. //console.log(scrollTop);
  228. if(this.headTab.TabCur == 0) {
  229. if(scrollTop <= 100) {
  230. let num = scrollTop / 100;
  231. this.headInfo.opacity = num;
  232. } else if(scrollTop > 100) {
  233. this.headInfo.opacity = 1;
  234. }
  235. }
  236. },
  237. //触底了
  238. setReachBottom() {
  239. console.log('触底了');
  240. },
  241. //欢迎提示关闭事件
  242. welcomeClose(bol) {
  243. this.swiperInfo.welcome = bol;
  244. this.headTab.welcome = bol;
  245. let Class = this.headInfo.Class;
  246. this.headInfo.Class = Class.replace(/welcome/g, '');
  247. this.viewContent.welcome = bol;
  248. //设置颜色
  249. _tool.setBarColor(false);
  250. console.log(bol);
  251. },
  252. //搜索框下的tab菜单被点击
  253. tabSelect(e) {
  254. let index = e.currentTarget.dataset.id;
  255. this.headTab.TabCur = index;
  256. this.headTab.scrollLeft = (index - 1) * 60;
  257. if(index == 0) {
  258. this.swiperInfo.show = true;
  259. this.headInfo.opacity = 0;
  260. } else {
  261. this.swiperInfo.show = false;
  262. this.headInfo.opacity = 1;
  263. }
  264. uni.pageScrollTo({
  265. scrollTop: 0,
  266. duration: 0
  267. });
  268. this.getListByCate(index)
  269. },
  270. swiperChange(e) {
  271. this.swiperInfo.index = e.detail.current;
  272. },
  273. gridMenuTap(e) {
  274. console.log(e);
  275. uni.navigateTo({
  276. url: "/pages/home/sort_list"
  277. });
  278. },
  279. identifyTap(e) {
  280. console.log(e);
  281. },
  282. quicklyTap(e) {
  283. console.log(e);
  284. },
  285. activityTap(e) {
  286. console.log(e);
  287. },
  288. //商品列表上的分类tab被点击
  289. goodsTab(e) {
  290. this.goodsTabData.TabCur = e.currentTarget.dataset.id;
  291. // #ifdef H5
  292. uni.pageScrollTo({
  293. scrollTop: 1060,
  294. duration: 200
  295. });
  296. // #endif
  297. // #ifdef APP-PLUS
  298. uni.pageScrollTo({
  299. scrollTop: 1010,
  300. duration: 200
  301. });
  302. // #endif
  303. },
  304. goodsListTap(e) {
  305. console.log(e);
  306. // if(e.index==0) {
  307. uni.navigateTo({
  308. url: '/pages/goods/goods?id='+e.data.id
  309. });
  310. // } else if(e.index == 2) {
  311. // uni.navigateTo({
  312. // url: '/pages/goods/second_hand'
  313. // });
  314. // } else if(e.index == 3) {
  315. // uni.navigateTo({
  316. // url: '/pages/goods/second_terrace'
  317. // });
  318. // } else {
  319. // }
  320. },
  321. liveListTap(e) {
  322. console.log(e);
  323. },
  324. videoListTap(e) {
  325. console.log(e);
  326. },
  327. gridSortTap(e) {
  328. console.log(e);
  329. },
  330. rewardTap() {
  331. uni.navigateTo({
  332. url: "/pages/goods/reward"
  333. });
  334. },
  335. imgTap() {
  336. this.modalShow = false;
  337. uni.navigateTo({
  338. url: "/pages/goods/reward"
  339. });
  340. console.log('图片被点击');
  341. },
  342. closeTap() {
  343. this.modalShow = false;
  344. console.log('点击了关闭');
  345. },
  346. sortVueTap() {
  347. uni.navigateTo({
  348. url: "/pages/home/sort"
  349. });
  350. },
  351. searchTap() {
  352. uni.navigateTo({
  353. url: "/pages/home/search"
  354. });
  355. }
  356. }
  357. }
  358. </script>
  359. <style lang="scss" scoped>
  360. .zaiui-head-search-box {
  361. // position: fixed;
  362. width: 100%;
  363. // top: 0;
  364. z-index: 999;
  365. background-color: rgb(229, 77, 66);
  366. // padding-top: var(--status-bar-height);
  367. transition: top .25s;
  368. padding-bottom: 10upx;
  369. .zaiui-search-box {
  370. position: relative;
  371. }
  372. .zaiui-flex-tab {
  373. position: relative;
  374. transition: opacity .25s;
  375. .flex {
  376. .basis-xxl {
  377. flex-basis: 90%;
  378. width: 90%;
  379. z-index: 1;
  380. }
  381. .basis-xxs {
  382. flex-basis: 10%;
  383. z-index: 1;
  384. width: 10%;
  385. }
  386. .sort-icon {
  387. font-size: 55upx;
  388. height: 64upx;
  389. line-height: 64upx;
  390. text-align: center;
  391. }
  392. }
  393. }
  394. }
  395. .zaiui-head-search-box.welcome {
  396. top: calc(var(--status-bar-height) + 101upx);
  397. transition: top .25s;
  398. }
  399. .zaiui-view-content {
  400. display: none;
  401. width: 100%;
  402. .zaiui-tab-list {
  403. position: relative;
  404. width: 100%;
  405. }
  406. }
  407. .zaiui-view-content.welcome {
  408. /* #ifdef APP-PLUS */
  409. margin-top: calc(var(--status-bar-height) + 180upx);
  410. /* #endif */
  411. /* #ifdef H5 */
  412. margin-top: calc(var(--status-bar-height) + 220upx);
  413. /* #endif */
  414. /* #ifdef MP */
  415. margin-top: calc(var(--status-bar-height) + 220upx);
  416. /* #endif */
  417. transition: all .25s;
  418. }
  419. .zaiui-view-content.show {
  420. display: block;
  421. }
  422. .zaiui-swiper-box {
  423. width: 100%;
  424. .screen-swiper {
  425. height: 230upx;
  426. min-height: 230upx;
  427. .swiper-padding {
  428. padding: 0 25upx;
  429. }
  430. }
  431. }
  432. .red-envelopes {
  433. width: 100%;
  434. }
  435. .zaiui-goods-tab-box {
  436. position: sticky;
  437. padding: 2upx 0;
  438. transition: all .25s;
  439. z-index: 999;
  440. background: #fff;
  441. /* #ifndef MP */
  442. top: calc(var(--status-bar-height) + 101upx);
  443. /* #endif */
  444. /* #ifdef MP */
  445. top: calc(var(--status-bar-height) + 161upx);
  446. /* #endif */
  447. .cu-tag.z {
  448. top: 0px;
  449. right: -32.72upx;
  450. font-size: 20upx;
  451. padding: 19upx 6upx;
  452. transform: scale(0.8);
  453. }
  454. }
  455. .zaiui-ad-img {
  456. width: 100%;
  457. }
  458. .zaiui-tab-list-title {
  459. .img-aau {
  460. width: 101.81upx;
  461. margin-top: 12.72upx;
  462. }
  463. .text-right {
  464. .img-aau {
  465. margin-right: 14.54upx;
  466. }
  467. }
  468. .text-left {
  469. .img-aau {
  470. margin-left: 14.54upx;
  471. }
  472. }
  473. }
  474. .zaiui-add-btn-view-box {
  475. position: fixed;
  476. z-index: 999;
  477. bottom: 181.81upx;
  478. right: 27.27upx;
  479. .cu-btn {
  480. margin: auto;
  481. width: 81.81upx;
  482. height: 81.81upx;
  483. font-weight: 800;
  484. border-radius: 50%;
  485. font-size: 36.36upx;
  486. border: 9.09upx solid #fff;
  487. box-shadow: 0 0 14.54upx 7.27upx #d0d0d0;
  488. }
  489. }
  490. .zaiui-home-box {
  491. display: none;
  492. }
  493. .zaiui-home-box.show {
  494. display: block;
  495. }
  496. </style>