index.vue 14 KB

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