index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. <template>
  2. <view class="index-box">
  3. <image class="bg-img" src="@/static/img/index/index-bg.png" mode="aspectFit"></image>
  4. <view class="">
  5. <Nav :leftShow='false' :customNav='true' :bgckgroundBox='bgckgroundBox'>
  6. <template>
  7. <view slot="custom" class="align-items-center" @click="toScroll()">
  8. <uni-icons type="location-filled" size="20"></uni-icons>
  9. <view class="fs-32 w-220 fw-600 ml-10 text-overflow-ellipsis-one">{{schoolData.school_name||''}}</view>
  10. <image class="nav-icon ml-10" src="@/static/img/index/index-right.png" mode="aspectFit"></image>
  11. </view>
  12. </template>
  13. </Nav>
  14. </view>
  15. <!-- 搜索 -->
  16. <view class="index-search box-border-box" @click="toUrl(1)"
  17. :style="[{'top': BarH + 'px','background':bgckgroundSearch}]">
  18. <view class="index-search-box box-border-box align-items-center">
  19. <uni-icons type="search" size="20" color="#000"></uni-icons>
  20. <view class="fs-28 fc-9 ml-10">搜索店铺名称或者商品名称</view>
  21. <view class="fs-28 fc-f index-search-box-buttom">搜索</view>
  22. </view>
  23. </view>
  24. <view class="index-box-1 ">
  25. <!-- 轮播 -->
  26. <view class="box-border-box plr-24">
  27. <swiper class="swiper mb-32 " circular indicator-dots indicator-active-color="#4FB3EF" :autoplay="true" :interval="3000" :duration="500">
  28. <swiper-item v-for="(item,i) in bannerList" :key="i">
  29. <image class="swiper-item" :src="item.image" mode="aspectFill"></image>
  30. </swiper-item>
  31. </swiper>
  32. </view>
  33. <!-- 导航 -->
  34. <view class="box-border-box plr-24">
  35. <view class="nav-list flex-wrap-wrap box-border-box mb-22">
  36. <view class="nav-list-item" v-for="(item,i) in navList" :key="i" @click="toUrl(item.type)">
  37. <image :src="item.img" mode="scaleToFill"></image>
  38. <view class="fs-26 fc-3 text-align-center">{{item.name}}</view>
  39. </view>
  40. </view>
  41. </view>
  42. <!-- 通知 -->
  43. <view class="box-border-box plr-24">
  44. <view class="msg-box align-items-center box-border-box mb-32">
  45. <image class="image-1" src="@/static/img/index/index-tz.png" mode="scaleToFill"></image>
  46. <view class="box-1 fs-20 fc-41ABF5">公告</view>
  47. <swiper class="tz-swiper" :vertical="true" circular :autoplay="true" :interval="3000" :duration="500">
  48. <swiper-item v-for="(item,i) in noticeList" :key="i" @click="toNoticeDet(item)">
  49. <view class="tz-swiper-item">{{item.title}}</view>
  50. </swiper-item>
  51. </swiper>
  52. <image class="image-2" src="@/static/img/toRight.png" mode="scaleToFill"></image>
  53. </view>
  54. </view>
  55. <!-- 限时秒杀 -->
  56. <view class="box-border-box plr-24" v-if="seckillGoodsList.length > 0">
  57. <view class="xsms-box mb-32">
  58. <image class="image-title" src="@/static/img/index/index-xsms.png" mode="scaleToFill"></image>
  59. <view class="xsms-box-list-f box-border-box plr-12">
  60. <view class="xsms-box-list display-flex ">
  61. <view class="xsms-box-list-item box-border-box p-8" v-for="(item,i) in seckillGoodsList" :key="i" @click="toShop(item)">
  62. <image class="xsms-box-list-item-img-1 mb-4" :src="item.goods_image" mode="aspectFill"></image>
  63. <view class="text-overflow-ellipsis-one fs-26 mb-4">{{item.goods_name}}</view>
  64. <view class="mb-4">
  65. <span class="fs-20 fw-b fc-FB3D03">¥</span><span class="fs-32 fw-b fc-FB3D03">{{item.seckill_money}}</span>
  66. </view>
  67. <view class="fs-20 fc-9 text-line-through">¥{{item.line_price}}</view>
  68. <image class="xsms-box-list-item-img-2" src="@/static/img/index/index-q.png" mode="scaleToFill"></image>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <!-- 类型选择 -->
  75. <view class="type-list-box display-flex" :style="[{'background':bgckgroundType}]">
  76. <view class="type-item-box view-nowrap" :class="category_id==item.id?'s-type':'n-type'"
  77. v-for="(item,i) in typeList" :key="i" @click="selectType(item.id)">{{item.name}}</view>
  78. </view>
  79. <!-- 商品列表 -->
  80. <view class="box-border-box plr-24">
  81. <view class="goos-list-box box-border-box p-24 display-flex" v-for="(item,i) in goodsList" :key="i" @click="toShop(item)">
  82. <image class="left-img" :src="item.shop_logo" mode="aspectFill"></image>
  83. <view class="flex-1">
  84. <view class="align-items-center mb-8">
  85. <view class="right-box-title fs-32 fw-600 text-overflow-ellipsis-one">{{item.shop_name}}</view>
  86. <image class="right-box-title-img" src="@/static/img/toRight.png" mode=""></image>
  87. </view>
  88. <view class="align-items-center mb-8">
  89. <image class="img-x mr-12" src="@/static/img/my/wdpj.png" mode=""></image>
  90. <view class="fs-26 fw-600 fc-FF7F00 mr-12">{{item.shop_score}}分</view>
  91. <view class="fc-6 fs-24 mr-12">| 预计{{item.delivery_time}}分钟 |</view>
  92. <view class="fc-6 fs-24 mr-12">{{item.shop_sales}}人购买</view>
  93. </view>
  94. <view class="align-items-center flex-wrap-wrap">
  95. <view class="quan-list display-flex mr-12 mb-12" v-for="(info1,index1) in item.coupon" :key="index1">
  96. <view class="quan-list-1 fs-24 fc-f">券</view>
  97. <view class="quan-list-2 fs-24 fc-FB3D03">{{info1.money}}元</view>
  98. </view>
  99. </view>
  100. <view class="goods-items-list display-flex">
  101. <view class="goods-items-list-box" v-for="(info2,index2) in item.goods" :key="index2">
  102. <image class="mb-12" :src="info2.goods_image" mode="aspectFill"></image>
  103. <view class="mb-8 fw-600 text-overflow-ellipsis-one fs-26">{{info2.goods_name}}</view>
  104. <view class="">
  105. <span class="fs-24 fc-FB3D03">¥</span>
  106. <span class="fs-32 fc-FB3D03 fw-b">{{info2.price}}</span>
  107. </view>
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. </view>
  113. </view>
  114. </view>
  115. </template>
  116. <script>
  117. import tools from "@/service/tools";
  118. import {getNotice,getBanner,} from '@/api/common.js';
  119. import {getSeckillGoods} from '@/api/seckill.js'
  120. import {getTakeaway} from '@/api/category.js';
  121. import {getGoodsList} from '@/api/goods.js';
  122. export default {
  123. data() {
  124. return {
  125. BarH:0,
  126. bgckgroundBox:'transparent',
  127. bgckgroundSearch:'',
  128. bgckgroundType:'',
  129. navList:[
  130. {name:"外卖",img:require('@/static/img/index/index-wm.png'),type:2},
  131. {name:"代取",img:require('@/static/img/index/index-dq.png'),type:3},
  132. {name:"校友圈",img:require('@/static/img/index/index-xyq.png'),type:7},
  133. {name:"团购",img:require('@/static/img/index/index-tg.png'),type:5},
  134. {name:"票务",img:require('@/static/img/index/index-pw.png'),type:4},
  135. {name:"干洗",img:require('@/static/img/index/index-gx.png'),type:6},
  136. {name:"租凭",img:require('@/static/img/index/index-zp.png'),},
  137. {name:"二手市场",img:require('@/static/img/index/index-esss.png'),},
  138. {name:"回收",img:require('@/static/img/index/index-hs.png'),},
  139. {name:"实习岗位",img:require('@/static/img/index/index-sxgw.png'),},
  140. ],
  141. schoolData:{
  142. school_name:'',
  143. },
  144. noticeList:[],
  145. bannerList:[],
  146. seckillGoodsList:[],
  147. typeList:[],//分类数组
  148. category_id:0, //分类id
  149. goodsList:[],
  150. total:0,
  151. page:1,
  152. }
  153. },
  154. onShow() {
  155. let school_id = uni.getStorageSync('school_id');
  156. let operate_id = uni.getStorageSync('operate_id');
  157. let school_name = uni.getStorageSync('school_name');
  158. if(!school_id||!operate_id){
  159. setTimeout(()=>{
  160. uni.reLaunch({
  161. url:'/pages-address/select-school?type=1'
  162. })
  163. },1000)
  164. }else{
  165. this.schoolData.school_name = school_name;
  166. }
  167. this.getBanner();
  168. this.getNotice();
  169. this.getSeckillGoods();
  170. this.getTakeaway();
  171. this.page = 1;
  172. this.goodsList = [];
  173. this.getGoodsList();
  174. },
  175. onPageScroll(e) {
  176. if(e.scrollTop>1){
  177. this.bgckgroundBox = '#fff';
  178. this.bgckgroundSearch = '#fff';
  179. if(e.scrollTop>500){
  180. this.bgckgroundType = '#fff';
  181. }else{
  182. this.bgckgroundType = '';
  183. }
  184. }else{
  185. this.bgckgroundBox = 'transparent';
  186. this.bgckgroundSearch = '';
  187. this.bgckgroundType = '';
  188. }
  189. },
  190. onReachBottom() {
  191. console.log('触底刷新');
  192. if(this.goodsList.length < this.total){
  193. this.page += 1;
  194. this.getGoodsList();
  195. }
  196. },
  197. created() {
  198. uni.getSystemInfo({
  199. success: (e) =>{
  200. let statusBarH = e.statusBarHeight + 10
  201. let custom = 0;
  202. custom = wx.getMenuButtonBoundingClientRect()
  203. let customBarH = custom.height;
  204. this.BarH = statusBarH + customBarH;
  205. }
  206. })
  207. },
  208. methods: {
  209. getBanner(){
  210. getBanner().then((res)=>{
  211. if(res.code === 1){
  212. this.bannerList = res.data;
  213. }
  214. })
  215. },
  216. getNotice(){
  217. getNotice().then((res)=>{
  218. if(res.code === 1){
  219. this.noticeList = res.data;
  220. }
  221. })
  222. },
  223. getSeckillGoods(){
  224. let operate_id = uni.getStorageSync('operate_id');
  225. getSeckillGoods({operate_id:operate_id}).then((res)=>{
  226. if(res.code === 1){
  227. this.seckillGoodsList = res.data
  228. }
  229. })
  230. },
  231. getTakeaway(){
  232. getTakeaway().then((res)=>{
  233. if(res.code === 1){
  234. this.typeList = res.data;
  235. this.typeList.unshift({name:"全部",id:0})
  236. }
  237. })
  238. },
  239. getGoodsList(){
  240. let operate_id = uni.getStorageSync('operate_id');
  241. getGoodsList({page:this.page,operate_id:operate_id,category_id:this.category_id}).then((res)=>{
  242. if(res.code === 1){
  243. this.goodsList = [...this.goodsList,...res.data.items];
  244. this.total = res.data.total;
  245. }
  246. })
  247. },
  248. selectType(id){
  249. if(this.category_id != id){
  250. this.category_id = id;
  251. this.page = 1;
  252. this.goodsList = [];
  253. this.getGoodsList();
  254. }
  255. },
  256. toUrl(type){
  257. if(type === 1){
  258. // 去搜索
  259. uni.navigateTo({
  260. url:'/pages/index/search-record'
  261. })
  262. }else if(type === 2){
  263. // 去外卖
  264. uni.navigateTo({
  265. url:'/pages-takeout/takeout'
  266. })
  267. }else if(type === 3){
  268. // 去外卖
  269. uni.navigateTo({
  270. url:'/pages-takeout/replace-take'
  271. })
  272. }else if(type === 4){
  273. // 去票务
  274. uni.navigateTo({
  275. url:'/pages-buy/ticket'
  276. })
  277. }else if(type === 5){
  278. // 去团购
  279. uni.navigateTo({
  280. url:'/pages-buy/group'
  281. })
  282. }else if(type === 6){
  283. // 去干洗
  284. uni.navigateTo({
  285. url:'/pages-buy/dry-clean'
  286. })
  287. }else if(type === 7){
  288. // 去校友圈
  289. uni.navigateTo({
  290. url:'/pages-school/school-circle'
  291. })
  292. }else{
  293. tools.error('暂未开放')
  294. }
  295. },
  296. toScroll(){
  297. uni.navigateTo({
  298. url:'/pages-address/select-school'
  299. })
  300. },
  301. toShop(item){
  302. uni.navigateTo({
  303. url:'/pages-takeout/shop?shop_id=' + item.shop_id
  304. })
  305. },
  306. toNoticeDet(item){
  307. uni.navigateTo({
  308. url: '/pages-my/notice/info?id=' +item.id
  309. })
  310. },
  311. },
  312. }
  313. </script>
  314. <style lang="scss" scoped>
  315. .index-box{
  316. .w-220{
  317. width: 220rpx;
  318. }
  319. position: relative;
  320. .bg-img{
  321. width: 100%;
  322. height: 1220rpx;
  323. position: absolute;
  324. top: 0;
  325. left: 0;
  326. z-index: -1;
  327. }
  328. .nav-icon{
  329. width: 32rpx;
  330. height: 32rpx;
  331. }
  332. .index-box-1{
  333. width: 100%;
  334. // height: 3000rpx;
  335. .swiper{
  336. width: 702rpx;
  337. height: 220rpx;
  338. border-radius: 20rpx;
  339. .swiper-item{
  340. width: 702rpx;
  341. height: 220rpx;
  342. border-radius: 20rpx;
  343. }
  344. }
  345. .nav-list{
  346. padding: 0 22rpx;
  347. .nav-list-item{
  348. margin-right: 52rpx;
  349. margin-bottom: 16rpx;
  350. image{
  351. width: 88rpx;
  352. height: 88rpx;
  353. margin: 0 auto;
  354. }
  355. }
  356. .nav-list-item:nth-child(7){
  357. margin-right: 42rpx !important;
  358. }
  359. .nav-list-item:nth-child(8){
  360. margin-right: 46rpx !important;
  361. }
  362. .nav-list-item:nth-child(9){
  363. margin-right: 44rpx !important;
  364. }
  365. .nav-list-item:nth-child(5),.nav-list-item:nth-child(10){
  366. margin-right: 0;
  367. }
  368. }
  369. .msg-box{
  370. width: 100%;
  371. height: 66rpx;
  372. background: #F7F8FC;
  373. border-radius: 12rpx;
  374. padding: 0 14rpx ;
  375. .image-1{
  376. width: 72rpx;
  377. height: 32rpx;
  378. margin-right: 10rpx;
  379. }
  380. .image-2{
  381. width: 40rpx;
  382. height: 40rpx;
  383. margin-left: auto;
  384. }
  385. .box-1{
  386. width: 50rpx;
  387. height: 26rpx;
  388. border-radius: 2rpx;
  389. border: 2rpx solid #41ABF5;
  390. text-align: center;
  391. line-height: 26rpx;
  392. margin-right: 10rpx;
  393. }
  394. .tz-swiper{
  395. width: 444rpx;
  396. height: 66rpx;
  397. .tz-swiper-item{
  398. width: 444rpx;
  399. height: 66rpx;
  400. line-height: 66rpx;
  401. }
  402. }
  403. }
  404. .xsms-box{
  405. .image-title{
  406. width: 100%;
  407. height: 92rpx;
  408. }
  409. .xsms-box-list-f{
  410. width: 100%;
  411. height: 310rpx;
  412. background: linear-gradient( 180deg, #ABDEFE 4%, #C9EAFF 30%, #C9EAFF 100%);
  413. border-radius: 0rpx 0rpx 20rpx 20rpx;
  414. }
  415. .xsms-box-list{
  416. overflow-y: scroll;
  417. .xsms-box-list-item:last-child{
  418. margin-right: 0;
  419. }
  420. .xsms-box-list-item{
  421. width: 180rpx;
  422. height: 300rpx;
  423. background: #FFFFFF;
  424. border-radius: 8rpx;
  425. margin-right: 8rpx;
  426. position: relative;
  427. .xsms-box-list-item-img-1{
  428. width: 164rpx;
  429. height: 175rpx;
  430. border-radius: 9rpx;
  431. }
  432. .xsms-box-list-item-img-2{
  433. position: absolute;
  434. width: 62rpx;
  435. height: 36rpx;
  436. right: 0;
  437. bottom: 8rpx;
  438. }
  439. }
  440. }
  441. }
  442. .type-list-box{
  443. position: sticky;
  444. left: 0;
  445. // top: calc(var(BarH)px + 93rpx);
  446. top: calc(86px + 93rpx);
  447. padding: 0 24rpx 24rpx 24rpx;
  448. overflow-x: scroll;
  449. .type-item-box{
  450. margin-right: 16rpx;
  451. padding: 0 24rpx;
  452. // min-width: 300rpx;
  453. height: 56rpx;
  454. line-height: 56rpx;
  455. border-radius: 200rpx;
  456. text-align: center;
  457. font-size: 28rpx;
  458. }
  459. .type-item-box:last-child{
  460. margin-right: 0;
  461. }
  462. .s-type{
  463. color: #fff;
  464. font-weight: 600;
  465. background: linear-gradient( 280deg, #44B1F7 0%, #96D6F4 100%);
  466. }
  467. .n-type{
  468. color: #666;
  469. background-color: #fff;
  470. }
  471. }
  472. .goos-list-box{
  473. width: 100%;
  474. min-height: 100rpx;
  475. background: #FFFFFF;
  476. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(51,51,51,0.1);
  477. border-radius: 20rpx;
  478. margin-bottom: 20rpx;
  479. .goods-items-list{
  480. width: 530rpx;
  481. overflow-y: scroll;
  482. .goods-items-list-box{
  483. width: 140rpx;
  484. margin-right: 16rpx;
  485. image{
  486. width: 140rpx;
  487. height: 140rpx;
  488. border-radius: 12rpx
  489. }
  490. }
  491. }
  492. .left-img{
  493. width: 100rpx;
  494. height: 100rpx;
  495. border-radius: 12rpx;
  496. margin-right: 16rpx;
  497. }
  498. .img-x{
  499. width: 24rpx;
  500. height: 24rpx;
  501. }
  502. .right-box-title{
  503. width: 438rpx;
  504. }
  505. .right-box-title-img{
  506. width: 32rpx;
  507. height: 32rpx;
  508. margin-left: auto;
  509. }
  510. .quan-list{
  511. .quan-list-1{
  512. width: 32rpx;
  513. height: 34rpx;
  514. background: #FB3D03;
  515. border-radius: 5rpx 0rpx 0rpx 5rpx;
  516. text-align: center;
  517. }
  518. .quan-list-2{
  519. box-sizing: border-box;
  520. padding: 0 2rpx;
  521. height: 34rpx;
  522. border-radius: 0 5rpx 5rpx 0;
  523. border: 1rpx solid #FB3D03;
  524. text-align: center;
  525. }
  526. }
  527. }
  528. }
  529. .index-search{
  530. position: sticky;
  531. left: 0;
  532. z-index: 100;
  533. padding: 0 24rpx 20rpx 24rpx;
  534. .index-search-box{
  535. width: 100%;
  536. height: 72rpx;
  537. padding: 0 6rpx 0 24rpx;
  538. border-radius: 200rpx;
  539. border: 2rpx solid #4FB3EF;
  540. .index-search-box-buttom{
  541. width: 120rpx;
  542. height: 60rpx;
  543. background: linear-gradient( 90deg, #57CAFF 0%, #41ABF5 100%);
  544. border-radius: 200rpx;
  545. margin-left: auto;
  546. line-height: 60rpx;
  547. text-align: center;
  548. }
  549. }
  550. }
  551. }
  552. </style>