index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. <template>
  2. <view class="center">
  3. <!-- 顶部logo and 搜索 start-->
  4. <view class="status_bar"></view>
  5. <view class="top-search flex">
  6. <view class="top-logo">
  7. <image src="../../static/icon/logo.png" mode="widthFix"></image>
  8. </view>
  9. <view class="search-box flex" @click="clickSearch()">
  10. <image class="search" src="../../static/icon/search-h.png" mode=""></image>
  11. <view class="search-font">输入关键词搜索</view>
  12. </view>
  13. </view>
  14. <!-- 顶部logo and 搜索 end-->
  15. <view class="jg"></view>
  16. <!-- 轮播图 start -->
  17. <swiper class="top-swiper" autoplay="true" duration="400" interval="5000" @change="swiperChange">
  18. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"
  19. @click="bannerNavToUrl(item)">
  20. <image :src="item.pic" />
  21. </swiper-item>
  22. </swiper>
  23. <!-- 轮播图 end -->
  24. <view class="swiper-btm flex">
  25. <view class="btm-item flex">
  26. <image src="../../static/icon/index-gou.png" mode=""></image>
  27. <view class="">自用购物返利</view>
  28. </view>
  29. <view class="btm-item flex">
  30. <image src="../../static/icon/index-gou.png" mode=""></image>
  31. <view class="">分享好友赚钱</view>
  32. </view>
  33. <view class="btm-item flex">
  34. <image src="../../static/icon/index-gou.png" mode=""></image>
  35. <view class="">超值正品优惠</view>
  36. </view>
  37. </view>
  38. <!-- 预约 start-->
  39. <view class="yuyue-wrap">
  40. <view class="yuyue-top flex">
  41. <image src="../../static/img/yuyue-top.png" mode="heightFix"></image>
  42. </view>
  43. <view class="yuyue-item" v-for="item in changCiList">
  44. <view class="item-top">
  45. <image src="../../static/img/yuyue.png" mode=""></image>
  46. <view class="item-top-info flex">
  47. <view class="">
  48. {{item.name}}<text>/大家都在买</text>
  49. </view>
  50. <view class="goto">
  51. GO>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="item-info flex">
  56. <view class="item-img">
  57. <image :src="item.image" mode=""></image>
  58. </view>
  59. <view class="item-val flex">
  60. <view class="item-status">
  61. {{!item.djs.over ? '距离预约结束': (!item.jcdjs.over?'距离开始进场':(!item.jsdjs.over?'活动进行中': '活动已结束'))}}
  62. </view>
  63. <view class="item-djs">
  64. <!-- 预约倒计时 -->
  65. <uni-countdown v-if="!item.djs.over" color="#C6914E" background-color="#F6EFDF"
  66. :show-day="false" :day="item.djs.day" :hour="item.djs.hours" :minute="item.djs.minutes"
  67. :second="item.djs.seconds"></uni-countdown>
  68. <!-- 进场倒计时 -->
  69. <uni-countdown v-if="item.djs.over && !item.jcdjs.over" color="#C6914E"
  70. background-color="#F6EFDF" :show-day="false" :day="item.jcdjs.day"
  71. :hour="item.jcdjs.hours" :minute="item.jcdjs.minutes" :second="item.jcdjs.seconds">
  72. </uni-countdown>
  73. <!-- 场次结束倒计时 -->
  74. <uni-countdown v-if="item.jcdjs.over && !item.jsdjs.over" color="#C6914E"
  75. background-color="#F6EFDF" :show-day="false" :day="item.jsdjs.day"
  76. :hour="item.jsdjs.hours" :minute="item.jsdjs.minutes" :second="item.jsdjs.seconds">
  77. </uni-countdown>
  78. <!-- 第二天倒计时 -->
  79. <uni-countdown v-if="item.jsdjs.over" color="#C6914E" background-color="#F6EFDF"
  80. :show-day="false" :day="item.xcdjs.day" :hour="item.xcdjs.hours"
  81. :minute="item.xcdjs.minutes" :second="item.xcdjs.seconds"></uni-countdown>
  82. <!-- <view class="" v-if="item.jsdjs.over" style="color: #dc262b;">
  83. 活动已结束
  84. </view> -->
  85. </view>
  86. <view class="item-base">
  87. 开始时间 {{item.radd_time}} 结束时间 {{item.rend_time }}
  88. </view>
  89. <view class="item-btn" @click="yuyue(item)"
  90. :class="{'yuyue': item.sta == 1,'jcf': item.sta == 2 && !item.jsdjs.over }">
  91. <!-- {{item.sta == 2 ? '立即进场': (item.djs.over ? '已结束': '立即预约')}} -->
  92. <!-- {{item.sta == 2 ? '立即进场' : '立即预约'}} -->
  93. {{item.str}}
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. <!-- 预约 end-->
  100. <!-- 预约弹窗 start-->
  101. <uni-popup ref="popupyy" type="bottom">
  102. <view class="popupyy-wrap">
  103. <view class="popupyy-top">
  104. 预约活动
  105. </view>
  106. <view class="popupyy-tit">
  107. 本次预约冻结广告值
  108. </view>
  109. <view class="popupyy-val">
  110. {{ yuyueInfo.advert }}
  111. </view>
  112. <view class="" style="margin-top: 50rpx;">
  113. 消费积分不低于{{yuyueInfo.lowest }}
  114. </view>
  115. <view class="" style="color: #FF4C4C;margin-top: 15rpx;">
  116. 广告值不低于{{yuyueInfo.minimum }}
  117. </view>
  118. <view class="popupyy-btn" @click="yuyueOk()">
  119. 确认预约
  120. </view>
  121. </view>
  122. </uni-popup>
  123. <!-- 预约弹窗 end-->
  124. <!-- 预约成功弹窗 start-->
  125. <uni-popup ref="popupyyok" type="center">
  126. <view class="popupyyok-wrap">
  127. <image src="../../static/img/yuyueok.png" mode="widthFix"></image>
  128. <view class="" style="font-size: 35rpx;font-weight: bold;color: #333333;">
  129. 预约成功!
  130. </view>
  131. <view class="" style="padding: 20rpx 80rpx;color: #999999;font-size: 26rpx;">
  132. 恭喜您预约活动成功,请您调好闹钟,准时参与!
  133. </view>
  134. <view class="btn" @click="$refs.popupyyok.close()">
  135. 确定
  136. </view>
  137. </view>
  138. </uni-popup>
  139. </view>
  140. </template>
  141. <script>
  142. import {
  143. timeComputed
  144. } from '@/utils/rocessor.js'
  145. import {
  146. tabbar1
  147. } from '@/utils/tabbar.js';
  148. import {
  149. loadIndexs,
  150. getChangCi,
  151. subscribe,
  152. advance
  153. } from '@/api/index.js';
  154. import uniCountdown from '@/components/uni-countdown/uni-countdown.vue';
  155. import {
  156. mapState,
  157. mapMutations
  158. } from 'vuex';
  159. export default {
  160. components: {
  161. uniCountdown
  162. },
  163. data() {
  164. return {
  165. current: 0,
  166. tabbar: tabbar1,
  167. titleNViewBackground: '',
  168. swiperCurrent: 0,
  169. swiperLength: 0,
  170. dataList: '',
  171. carouselList: [], //轮播图列表
  172. changCiList: [],
  173. yuyueInfo: {},
  174. loadingType: 'more'
  175. };
  176. },
  177. onLoad() {
  178. this.loadData();
  179. },
  180. onShow() {
  181. this.changCiList = []
  182. this.getChangCi()
  183. },
  184. onHide() {
  185. this.changCiList = []
  186. },
  187. computed: {
  188. ...mapState('user', ['userInfo'])
  189. },
  190. methods: {
  191. loadData() {
  192. loadIndexs({})
  193. .then(({
  194. data
  195. }) => {
  196. let goods = data.info;
  197. this.dataList = goods.bastList; //精品推荐
  198. this.carouselList = data.banner;
  199. })
  200. .catch(e => {});
  201. },
  202. goDetails(e) {
  203. console.log(e, '123456');
  204. uni.navigateTo({
  205. url: '/pages/index/messageInfo'
  206. });
  207. },
  208. nav(url) {
  209. uni.navigateTo({
  210. url,
  211. fail() {
  212. uni.switchTab({
  213. url
  214. });
  215. }
  216. });
  217. },
  218. //轮播图切换修改背景色
  219. swiperChange(e) {
  220. const index = e.detail.current;
  221. this.swiperCurrent = index;
  222. this.titleNViewBackground = this.carouselList[index].background;
  223. },
  224. // 點擊搜索框
  225. clickSearch() {
  226. uni.navigateTo({
  227. url: '/pages/product/search'
  228. });
  229. },
  230. //详情页
  231. navToDetailPage(item) {
  232. let id = item.id;
  233. uni.navigateTo({
  234. url: '/pages/product/product?id=' + id
  235. });
  236. },
  237. // 打开预约弹窗
  238. yuyue(item) {
  239. if (item.sta == 2) {
  240. // 进场
  241. advance({
  242. id: item.id
  243. }).then(res => {
  244. console.log(res)
  245. uni.navigateTo({
  246. url: '/pages/index/yuyuechang?id=' + item.id
  247. })
  248. })
  249. } else {
  250. this.yuyueInfo = item
  251. this.$refs.popupyy.open()
  252. }
  253. },
  254. // 确定预约
  255. yuyueOk() {
  256. let obj = this
  257. // 判断广告值
  258. if (obj.yuyueInfo.minimum * 1 > obj.userInfo.aid_val * 1) {
  259. return obj.$api.msg('您当前广告值不足')
  260. }
  261. // 判断消费账户
  262. if (obj.yuyueInfo.lowest * 1 > obj.userInfo.now_money * 1) {
  263. return obj.$api.msg('您当前消费账户不足')
  264. }
  265. subscribe({
  266. id: obj.yuyueInfo.id
  267. }).then(res => {
  268. console.log(res, '确定预约')
  269. // yuyueInfo
  270. let s = obj.changCiList.indexOf(obj.yuyueInfo);
  271. obj.changCiList[s].sta = 2;
  272. obj.changCiList[s].str = '进入'
  273. obj.$refs.popupyy.close()
  274. obj.$refs.popupyyok.open()
  275. })
  276. },
  277. // 获取场次信息
  278. getChangCi() {
  279. let obj = this
  280. getChangCi({
  281. page: 1,
  282. limit: 100
  283. }).then(res => {
  284. console.log(res, '获取场次信息')
  285. let arr = res.data.map(e => {
  286. // 预约倒计时
  287. e.djs = timeComputed(e.time)
  288. // 进场倒计时
  289. e.jcdjs = timeComputed(e.time + 600)
  290. // 场次结束倒计时
  291. e.jsdjs = timeComputed(e.e_time)
  292. // 第二天预约倒计时
  293. e.xcdjs = timeComputed(e.time + 86400)
  294. return e
  295. })
  296. console.log(arr)
  297. obj.changCiList = arr.reverse()
  298. })
  299. }
  300. }
  301. };
  302. </script>
  303. <style lang="scss">
  304. page,
  305. .center {
  306. min-height: 100%;
  307. height: auto;
  308. background: #ededed;
  309. }
  310. // 顶部搜索
  311. .top-search {
  312. height: 80rpx;
  313. padding: 0 20rpx;
  314. background-color: #fff;
  315. .top-logo {
  316. width: 50rpx;
  317. // height: 50rpx;
  318. margin-right: 10rpx;
  319. image {
  320. width: 48rpx;
  321. }
  322. }
  323. .search-box {
  324. justify-content: center;
  325. width: 698rpx;
  326. height: 60rpx;
  327. background: #EEEEEE;
  328. // box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
  329. border-radius: 30rpx;
  330. .search {
  331. width: 34rpx;
  332. height: 34rpx;
  333. }
  334. .search-font {
  335. margin-left: 14rpx;
  336. font-size: 28rpx;
  337. font-family: PingFang SC;
  338. font-weight: 500;
  339. color: #CBCBCB;
  340. }
  341. }
  342. }
  343. // 顶部轮播图
  344. .top-swiper {
  345. width: 750rpx;
  346. height: 360rpx;
  347. // margin: 20rpx 0 0;
  348. image {
  349. width: 750rpx;
  350. height: 360rpx;
  351. }
  352. }
  353. .swiper-btm {
  354. height: 60rpx;
  355. width: 750rpx;
  356. background-color: #fff;
  357. margin-bottom: 20rpx;
  358. font-size: 21rpx;
  359. font-weight: 500;
  360. color: #333333;
  361. .btm-item {
  362. flex-grow: 1;
  363. justify-content: center;
  364. image {
  365. width: 25rpx;
  366. height: 25rpx;
  367. margin-right: 14rpx;
  368. }
  369. }
  370. }
  371. .jg {
  372. height: 20rpx;
  373. background-color: #fff;
  374. }
  375. .yuyue-wrap {
  376. background-color: #fff;
  377. .yuyue-top {
  378. height: 117rpx;
  379. justify-content: center;
  380. image {
  381. display: inline-block;
  382. height: 31rpx;
  383. margin: auto;
  384. }
  385. }
  386. .yuyue-item {
  387. width: 690rpx;
  388. margin: auto;
  389. .item-top {
  390. width: 690rpx;
  391. height: 80rpx;
  392. border-radius: 18rpx;
  393. // background-color: #bfa;
  394. position: relative;
  395. image {
  396. width: 690rpx;
  397. height: 80rpx;
  398. // position: relative;
  399. }
  400. .item-top-info {
  401. width: 690rpx;
  402. height: 80rpx;
  403. position: absolute;
  404. top: 0;
  405. left: 0;
  406. font-size: 33rpx;
  407. font-weight: bold;
  408. color: #C6914E;
  409. padding-left: 35rpx;
  410. padding-right: 25rpx;
  411. text {
  412. font-size: 22rpx;
  413. font-weight: 500;
  414. color: #C6914E;
  415. }
  416. .goto {
  417. width: 60rpx;
  418. line-height: 26rpx;
  419. background: #C6914E;
  420. border-radius: 12rpx;
  421. font-size: 18rpx;
  422. font-weight: 500;
  423. color: #FFFFFF;
  424. text-align: center;
  425. }
  426. }
  427. }
  428. .item-info {
  429. width: 690rpx;
  430. height: 252rpx;
  431. margin-top: -20rpx;
  432. background: #FFFFFF;
  433. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  434. border-radius: 0px 0px 20rpx 20rpx;
  435. padding: 0 25rpx;
  436. margin-bottom: 20rpx;
  437. .item-img {
  438. width: 134rpx;
  439. height: 133rpx;
  440. background-color: #999;
  441. flex-shrink: 0;
  442. image {
  443. width: 134rpx;
  444. height: 133rpx;
  445. }
  446. }
  447. .item-val {
  448. flex-grow: 1;
  449. height: 100%;
  450. // background-color: #009688;
  451. position: relative;
  452. flex-direction: column;
  453. align-items: flex-start;
  454. padding-left: 25rpx;
  455. justify-content: center;
  456. .item-djs {
  457. margin: 20rpx 0;
  458. height: 42rpx;
  459. }
  460. .item-status {
  461. font-size: 26rpx;
  462. font-weight: bold;
  463. color: #333333;
  464. }
  465. .item-base {
  466. font-size: 25rpx;
  467. font-weight: 500;
  468. color: #666666;
  469. }
  470. .item-btn {
  471. width: 159rpx;
  472. height: 59rpx;
  473. line-height: 59rpx;
  474. background: #CCCCCC;
  475. border-radius: 10rpx;
  476. position: absolute;
  477. right: 0;
  478. top: 0;
  479. bottom: 0;
  480. margin: auto;
  481. text-align: center;
  482. }
  483. .yuyue {
  484. background-color: #303030;
  485. color: #F8DABA;
  486. }
  487. .jcf {
  488. background-color: #f42b4e;
  489. color: #fff;
  490. }
  491. }
  492. }
  493. }
  494. }
  495. .popupyy-wrap {
  496. width: 750rpx;
  497. height: 745rpx;
  498. background: #FFFFFF;
  499. border-radius: 20rpx 20rpx 0px 0px;
  500. text-align: center;
  501. font-size: 32rpx;
  502. color: #999999;
  503. font-weight: 500;
  504. padding-top: 60rpx;
  505. .popupyy-top {
  506. font-size: 36rpx;
  507. font-weight: 500;
  508. color: #333333;
  509. position: relative;
  510. &::before {
  511. content: '';
  512. width: 138rpx;
  513. height: 1rpx;
  514. background: #CBCBCB;
  515. position: absolute;
  516. top: 0;
  517. bottom: 0;
  518. left: 124rpx;
  519. margin: auto;
  520. }
  521. &::after {
  522. content: '';
  523. width: 138rpx;
  524. height: 1rpx;
  525. background: #CBCBCB;
  526. position: absolute;
  527. top: 0;
  528. bottom: 0;
  529. right: 124rpx;
  530. margin: auto;
  531. }
  532. }
  533. .popupyy-tit {
  534. font-size: 32rpx;
  535. font-weight: 500;
  536. color: #999999;
  537. margin-top: 70rpx;
  538. }
  539. .popupyy-val {
  540. font-size: 67rpx;
  541. font-weight: bold;
  542. color: #333333;
  543. margin-top: 60rpx;
  544. }
  545. .popupyy-btn {
  546. width: 680rpx;
  547. line-height: 100rpx;
  548. background: #303030;
  549. border-radius: 10rpx;
  550. font-size: 34rpx;
  551. font-weight: 500;
  552. color: #F8DABA;
  553. margin: 20rpx auto 0;
  554. }
  555. }
  556. .popupyyok-wrap {
  557. height: 707rpx;
  558. width: 551rpx;
  559. background-color: #fff;
  560. border-radius: 20rpx;
  561. text-align: center;
  562. image {
  563. width: 100%;
  564. }
  565. .btn {
  566. width: 295rpx;
  567. line-height: 69rpx;
  568. border-radius: 34rpx;
  569. background: #303030;
  570. color: #F8DABA;
  571. font-size: 35rpx;
  572. color: #F8DABA;
  573. margin: auto;
  574. }
  575. }
  576. .status_bar {
  577. height: var(--status-bar-height);
  578. width: 100%;
  579. background: #fff;
  580. }
  581. </style>