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