index.vue 13 KB

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