resource.vue 14 KB

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