index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  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="toSelectSchool()">
  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 lon = uni.getStorageSync('lon');
  156. let lat = uni.getStorageSync('lat');
  157. if(!lon||!lat){
  158. uni.getLocation({
  159. type:"gcj02",
  160. success:(res)=>{
  161. if(res.errMsg === 'getLocation:ok'){
  162. uni.setStorageSync('lon',res.longitude);
  163. uni.setStorageSync('lat',res.latitude);
  164. }else{
  165. tools.error('位置授权失败,请检查是否开始授权')
  166. }
  167. },
  168. fail:(res)=>{
  169. tools.error('位置授权失败,请检查是否开始授权')
  170. },
  171. })
  172. }
  173. let school_id = uni.getStorageSync('school_id');
  174. let operate_id = uni.getStorageSync('operate_id');
  175. let school_name = uni.getStorageSync('school_name');
  176. if(!school_id||!operate_id){
  177. setTimeout(()=>{
  178. uni.reLaunch({
  179. url:'/pages-address/select-school?type=1'
  180. })
  181. },1000)
  182. }else{
  183. this.schoolData.school_name = school_name;
  184. }
  185. this.getBanner();
  186. this.getNotice();
  187. this.getSeckillGoods();
  188. this.getTakeaway();
  189. this.page = 1;
  190. this.goodsList = [];
  191. this.getGoodsList();
  192. },
  193. onPageScroll(e) {
  194. if(e.scrollTop>1){
  195. this.bgckgroundBox = '#fff';
  196. this.bgckgroundSearch = '#fff';
  197. if(e.scrollTop>500){
  198. this.bgckgroundType = '#fff';
  199. }else{
  200. this.bgckgroundType = '';
  201. }
  202. }else{
  203. this.bgckgroundBox = 'transparent';
  204. this.bgckgroundSearch = '';
  205. this.bgckgroundType = '';
  206. }
  207. },
  208. onReachBottom() {
  209. console.log('触底刷新');
  210. if(this.goodsList.length < this.total){
  211. this.page += 1;
  212. this.getGoodsList();
  213. }
  214. },
  215. created() {
  216. uni.getSystemInfo({
  217. success: (e) =>{
  218. let statusBarH = e.statusBarHeight + 10
  219. let custom = 0;
  220. custom = wx.getMenuButtonBoundingClientRect()
  221. let customBarH = custom.height;
  222. this.BarH = statusBarH + customBarH;
  223. }
  224. })
  225. },
  226. methods: {
  227. getBanner(){
  228. getBanner().then((res)=>{
  229. if(res.code === 1){
  230. this.bannerList = res.data;
  231. }
  232. })
  233. },
  234. getNotice(){
  235. getNotice().then((res)=>{
  236. if(res.code === 1){
  237. this.noticeList = res.data;
  238. }
  239. })
  240. },
  241. getSeckillGoods(){
  242. let operate_id = uni.getStorageSync('operate_id');
  243. getSeckillGoods({operate_id:operate_id}).then((res)=>{
  244. if(res.code === 1){
  245. this.seckillGoodsList = res.data
  246. }
  247. })
  248. },
  249. getTakeaway(){
  250. getTakeaway().then((res)=>{
  251. if(res.code === 1){
  252. this.typeList = res.data;
  253. this.typeList.unshift({name:"全部",id:0})
  254. }
  255. })
  256. },
  257. getGoodsList(){
  258. let operate_id = uni.getStorageSync('operate_id');
  259. getGoodsList({page:this.page,operate_id:operate_id,category_id:this.category_id}).then((res)=>{
  260. if(res.code === 1){
  261. this.goodsList = [...this.goodsList,...res.data.items];
  262. this.total = res.data.total;
  263. }
  264. })
  265. },
  266. selectType(id){
  267. if(this.category_id != id){
  268. this.category_id = id;
  269. this.page = 1;
  270. this.goodsList = [];
  271. this.getGoodsList();
  272. }
  273. },
  274. toUrl(type){
  275. if(type === 1){
  276. // 去搜索
  277. uni.navigateTo({
  278. url:'/pages/index/search-record'
  279. })
  280. }else if(type === 2){
  281. // 去外卖
  282. uni.navigateTo({
  283. url:'/pages-takeout/takeout'
  284. })
  285. }else if(type === 3){
  286. // 去外卖
  287. uni.navigateTo({
  288. url:'/pages-takeout/replace-take'
  289. })
  290. }else if(type === 4){
  291. // 去票务
  292. uni.navigateTo({
  293. url:'/pages-buy/ticket'
  294. })
  295. }else if(type === 5){
  296. // 去团购
  297. uni.navigateTo({
  298. url:'/pages-buy/group'
  299. })
  300. }else if(type === 6){
  301. // 去干洗
  302. uni.navigateTo({
  303. url:'/pages-buy/dry-clean'
  304. })
  305. }else if(type === 7){
  306. // 去校友圈
  307. uni.navigateTo({
  308. url:'/pages-school/school-circle'
  309. })
  310. }else{
  311. tools.error('暂未开放')
  312. }
  313. },
  314. toSelectSchool(){
  315. uni.navigateTo({
  316. url:'/pages-address/select-school?type=1'
  317. })
  318. },
  319. toShop(item){
  320. uni.navigateTo({
  321. url:'/pages-takeout/shop?shop_id=' + item.shop_id
  322. })
  323. },
  324. toNoticeDet(item){
  325. uni.navigateTo({
  326. url: '/pages-my/notice/info?id=' +item.id
  327. })
  328. },
  329. },
  330. }
  331. </script>
  332. <style lang="scss" scoped>
  333. .index-box{
  334. .w-220{
  335. width: 220rpx;
  336. }
  337. position: relative;
  338. .bg-img{
  339. width: 100%;
  340. height: 1220rpx;
  341. position: absolute;
  342. top: 0;
  343. left: 0;
  344. z-index: -1;
  345. }
  346. .nav-icon{
  347. width: 32rpx;
  348. height: 32rpx;
  349. }
  350. .index-box-1{
  351. width: 100%;
  352. // height: 3000rpx;
  353. .swiper{
  354. width: 702rpx;
  355. height: 220rpx;
  356. border-radius: 20rpx;
  357. .swiper-item{
  358. width: 702rpx;
  359. height: 220rpx;
  360. border-radius: 20rpx;
  361. }
  362. }
  363. .nav-list{
  364. padding: 0 22rpx;
  365. .nav-list-item{
  366. margin-right: 52rpx;
  367. margin-bottom: 16rpx;
  368. image{
  369. width: 88rpx;
  370. height: 88rpx;
  371. margin: 0 auto;
  372. }
  373. }
  374. .nav-list-item:nth-child(7){
  375. margin-right: 42rpx !important;
  376. }
  377. .nav-list-item:nth-child(8){
  378. margin-right: 46rpx !important;
  379. }
  380. .nav-list-item:nth-child(9){
  381. margin-right: 44rpx !important;
  382. }
  383. .nav-list-item:nth-child(5),.nav-list-item:nth-child(10){
  384. margin-right: 0;
  385. }
  386. }
  387. .msg-box{
  388. width: 100%;
  389. height: 66rpx;
  390. background: #F7F8FC;
  391. border-radius: 12rpx;
  392. padding: 0 14rpx ;
  393. .image-1{
  394. width: 72rpx;
  395. height: 32rpx;
  396. margin-right: 10rpx;
  397. }
  398. .image-2{
  399. width: 40rpx;
  400. height: 40rpx;
  401. margin-left: auto;
  402. }
  403. .box-1{
  404. width: 50rpx;
  405. height: 26rpx;
  406. border-radius: 2rpx;
  407. border: 2rpx solid #41ABF5;
  408. text-align: center;
  409. line-height: 26rpx;
  410. margin-right: 10rpx;
  411. }
  412. .tz-swiper{
  413. width: 444rpx;
  414. height: 66rpx;
  415. .tz-swiper-item{
  416. width: 444rpx;
  417. height: 66rpx;
  418. line-height: 66rpx;
  419. }
  420. }
  421. }
  422. .xsms-box{
  423. .image-title{
  424. width: 100%;
  425. height: 92rpx;
  426. }
  427. .xsms-box-list-f{
  428. width: 100%;
  429. height: 310rpx;
  430. background: linear-gradient( 180deg, #ABDEFE 4%, #C9EAFF 30%, #C9EAFF 100%);
  431. border-radius: 0rpx 0rpx 20rpx 20rpx;
  432. }
  433. .xsms-box-list{
  434. overflow-y: scroll;
  435. .xsms-box-list-item:last-child{
  436. margin-right: 0;
  437. }
  438. .xsms-box-list-item{
  439. width: 180rpx;
  440. height: 300rpx;
  441. background: #FFFFFF;
  442. border-radius: 8rpx;
  443. margin-right: 8rpx;
  444. position: relative;
  445. .xsms-box-list-item-img-1{
  446. width: 164rpx;
  447. height: 175rpx;
  448. border-radius: 9rpx;
  449. }
  450. .xsms-box-list-item-img-2{
  451. position: absolute;
  452. width: 62rpx;
  453. height: 36rpx;
  454. right: 0;
  455. bottom: 8rpx;
  456. }
  457. }
  458. }
  459. }
  460. .type-list-box{
  461. position: sticky;
  462. left: 0;
  463. // top: calc(var(BarH)px + 93rpx);
  464. top: calc(86px + 93rpx);
  465. padding: 0 24rpx 24rpx 24rpx;
  466. overflow-x: scroll;
  467. .type-item-box{
  468. margin-right: 16rpx;
  469. padding: 0 24rpx;
  470. // min-width: 300rpx;
  471. height: 56rpx;
  472. line-height: 56rpx;
  473. border-radius: 200rpx;
  474. text-align: center;
  475. font-size: 28rpx;
  476. }
  477. .type-item-box:last-child{
  478. margin-right: 0;
  479. }
  480. .s-type{
  481. color: #fff;
  482. font-weight: 600;
  483. background: linear-gradient( 280deg, #44B1F7 0%, #96D6F4 100%);
  484. }
  485. .n-type{
  486. color: #666;
  487. background-color: #fff;
  488. }
  489. }
  490. .goos-list-box{
  491. width: 100%;
  492. min-height: 100rpx;
  493. background: #FFFFFF;
  494. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(51,51,51,0.1);
  495. border-radius: 20rpx;
  496. margin-bottom: 20rpx;
  497. .goods-items-list{
  498. width: 530rpx;
  499. overflow-y: scroll;
  500. .goods-items-list-box{
  501. width: 140rpx;
  502. margin-right: 16rpx;
  503. image{
  504. width: 140rpx;
  505. height: 140rpx;
  506. border-radius: 12rpx
  507. }
  508. }
  509. }
  510. .left-img{
  511. width: 100rpx;
  512. height: 100rpx;
  513. border-radius: 12rpx;
  514. margin-right: 16rpx;
  515. }
  516. .img-x{
  517. width: 24rpx;
  518. height: 24rpx;
  519. }
  520. .right-box-title{
  521. width: 438rpx;
  522. }
  523. .right-box-title-img{
  524. width: 32rpx;
  525. height: 32rpx;
  526. margin-left: auto;
  527. }
  528. .quan-list{
  529. .quan-list-1{
  530. width: 32rpx;
  531. height: 34rpx;
  532. background: #FB3D03;
  533. border-radius: 5rpx 0rpx 0rpx 5rpx;
  534. text-align: center;
  535. }
  536. .quan-list-2{
  537. box-sizing: border-box;
  538. padding: 0 2rpx;
  539. height: 34rpx;
  540. border-radius: 0 5rpx 5rpx 0;
  541. border: 1rpx solid #FB3D03;
  542. text-align: center;
  543. }
  544. }
  545. }
  546. }
  547. .index-search{
  548. position: sticky;
  549. left: 0;
  550. z-index: 100;
  551. padding: 0 24rpx 20rpx 24rpx;
  552. .index-search-box{
  553. width: 100%;
  554. height: 72rpx;
  555. padding: 0 6rpx 0 24rpx;
  556. border-radius: 200rpx;
  557. border: 2rpx solid #4FB3EF;
  558. .index-search-box-buttom{
  559. width: 120rpx;
  560. height: 60rpx;
  561. background: linear-gradient( 90deg, #57CAFF 0%, #41ABF5 100%);
  562. border-radius: 200rpx;
  563. margin-left: auto;
  564. line-height: 60rpx;
  565. text-align: center;
  566. }
  567. }
  568. }
  569. }
  570. </style>