index.vue 14 KB

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