index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <template>
  2. <view>
  3. <!-- 非H5撑高元素 -->
  4. <!-- <view class="status_bar"></view> -->
  5. <view class="box">
  6. <view class="box-top">
  7. <view class="box-top-action">
  8. <view class="box-top-action-item" @click="toPrize">
  9. <view class="flex box-top-action-item-cir">
  10. <image src="../../static/icon/index_prize.png" mode=""></image>
  11. </view>
  12. <view class="box-top-action-item-txt">奖品库</view>
  13. </view>
  14. </view>
  15. <view class="box-top-tip">
  16. <view class="flex box-top-tip-txt" @click="toRule">
  17. <text>规则说明</text>
  18. </view>
  19. <view class="flex box-top-tip-txt" @click="toTicket">
  20. <text>所有盲票</text>
  21. </view>
  22. </view>
  23. <view class="box-top-news">
  24. <prize-news :list="list" duration="35" />
  25. <prize-news :list="list" duration="15" />
  26. </view>
  27. </view>
  28. <view class="box-ticket">
  29. <swiper class="image-container" circular :vertical="true" :current="currentIndex" :autoplay="false"
  30. @change="swiperChange" v-if="imgList.length">
  31. <swiper-item class="swiper-item" v-for="(item, index) in imgList" :key="item.picUrl">
  32. <view class="flex image-wrap">
  33. <image class="img" :src="item.picUrl" lazy-load mode=""></image>
  34. </view>
  35. </swiper-item>
  36. </swiper>
  37. <swiper class="image-container" circular :vertical="true" :autoplay="false" v-else>
  38. <swiper-item class="swiper-item">
  39. <view class="flex image-wrap">
  40. <image class="img" src="../../static/icon/ticket_index.png" lazy-load mode=""></image>
  41. </view>
  42. </swiper-item>
  43. </swiper>
  44. <swiper class="prize-container" previous-margin="270rpx" next-margin="270rpx" circular :duration="15000"
  45. :interval="1500" easing-function="easeOutCubic" :current="currentPrizeIndex" :disable-touch="true"
  46. :autoplay="true">
  47. <swiper-item class="swiper-item" v-for="(item, index) in prizeList" :key="index">
  48. <view class="flex image-wrap">
  49. <image class="img" :src="item.picUrl" lazy-load mode="aspectFill"></image>
  50. </view>
  51. </swiper-item>
  52. </swiper>
  53. <image class="box-img" src="../../static/icon/index_box.png" mode=""></image>
  54. <image class="index-left" src="../../static/icon/index_left.png" mode="" @click="ticketLeft"></image>
  55. <image class="index-right" src="../../static/icon/index_right.png" mode="" @click="ticketRight"></image>
  56. </view>
  57. <view class="flex box-ticket-btn">
  58. <view class="box-ticket-btn-content" @click="exchange">
  59. <image src="../../static/icon/index_btn.png" mode=""></image>
  60. <view class="flex title">
  61. <text>{{ payInfo.salePrice / 100 }}元立即开刮</text>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. <custom-tab-bar :activeValue="'index'" />
  67. <pay-popup :pay-show="payShow" :pay-info="payInfo" @close="close" @success="toProcess" />
  68. </view>
  69. </template>
  70. <script>
  71. import env from '../../config/env.js'
  72. import $http from '@/utils/request.js'
  73. import CustomTabBar from '../../components/custom-tab-bar/custom-tab-bar.vue'
  74. import Carousel from '../../components/vear-carousel/vear-carousel'
  75. import PayPopup from '../../components/pay-popup/pay-popup.vue'
  76. import PrizeNews from '../../components/prize-news/prize-news.vue'
  77. export default {
  78. components: {
  79. CustomTabBar,
  80. Carousel,
  81. PayPopup,
  82. PrizeNews
  83. },
  84. data() {
  85. return {
  86. imgList: [],
  87. value: 1,
  88. payShow: false,
  89. checked: false,
  90. pageNum: 1,
  91. total: 100,
  92. list: [],
  93. currentIndex: 0,
  94. currentPrizeIndex: 2,
  95. payInfo: {},
  96. prizeList: [],
  97. list: [{
  98. url: 'https://mp-public-test-1307117429.cos.ap-shanghai.myqcloud.com/EJSFMIQFND7IYJO3T37Q.png',
  99. text: '测试'
  100. }, {
  101. url: 'https://mp-public-test-1307117429.cos.ap-shanghai.myqcloud.com/EJSFMIQFND7IYJO3T37Q.png',
  102. text: '测试'
  103. }, {
  104. url: 'https://mp-public-test-1307117429.cos.ap-shanghai.myqcloud.com/EJSFMIQFND7IYJO3T37Q.png',
  105. text: '测试'
  106. }, {
  107. url: 'https://mp-public-test-1307117429.cos.ap-shanghai.myqcloud.com/EJSFMIQFND7IYJO3T37Q.png',
  108. text: '测试'
  109. }],
  110. };
  111. },
  112. onLoad(opthios) {
  113. if (opthios.scene) {
  114. let sceneStr = decodeURIComponent(opthios.scene)
  115. this.sceneArr = sceneStr.split('&')
  116. uni.setStorageSync('shareUid', this.sceneArr[0])
  117. uni.setStorageSync('shareType', this.sceneArr[1])
  118. }
  119. },
  120. onShow(opthios) {
  121. this.loginState = uni.getStorageSync('token') ? true : false
  122. this.getList()
  123. },
  124. methods: {
  125. swiperChange(e) {
  126. this.dontFirstAnimation = false
  127. this.currentIndex = e.detail.current
  128. this.getPrize(this.imgList[this.currentIndex].boxId)
  129. },
  130. prizeChange(e) {
  131. let ticketNum = this.imgList.length - 1
  132. let num = this.prizeList.length - 1
  133. let index = this.currentPrizeIndex = e.detail.current
  134. let acIndex = this.currentIndex
  135. if (num == index) {
  136. acIndex++
  137. if (acIndex < ticketNum) {
  138. this.currentIndex++
  139. } else if (acIndex == ticketNum) {
  140. this.currentIndex = ticketNum
  141. } else {
  142. this.currentIndex = 0
  143. }
  144. this.currentPrizeIndex = 2
  145. this.getPrize(this.imgList[this.currentIndex].boxId)
  146. }
  147. },
  148. clickImg(item) {
  149. console.log(item);
  150. },
  151. ticketLeft() {
  152. if ((this.currentIndex >= 0) && (this.currentIndex < (this.imgList.length - 1))) {
  153. this.currentIndex++
  154. } else if (this.currentIndex == (this.imgList.length - 1)) {
  155. this.currentIndex = 0
  156. }
  157. },
  158. ticketRight() {
  159. if (this.currentIndex > 0) {
  160. this.currentIndex--
  161. } else if (this.currentIndex == 0) {
  162. this.currentIndex = this.imgList.length - 1
  163. }
  164. },
  165. getList() {
  166. uni.showLoading({
  167. title: '加载中'
  168. });
  169. let data = {
  170. categoryId: '',
  171. tagId: '',
  172. type: 'online',
  173. noToken: true
  174. }
  175. $http.post(`/api/v1/mp/user/mall/ticket/list?pageNum=${this.pageNum}&pageSize=100`, data).then(
  176. res => {
  177. uni.hideLoading();
  178. if (res.code == 0) {
  179. res.rows.forEach(item => {
  180. let picUrlArr = item.picUrl.split(',')
  181. item.picUrl = env.filePublic + picUrlArr[0]
  182. })
  183. this.total = res.total
  184. this.imgList = res.rows
  185. this.getPrize(this.imgList[0].boxId)
  186. }
  187. }).catch(() => {
  188. uni.hideLoading();
  189. })
  190. },
  191. getPrize(id) {
  192. this.prizeList = []
  193. $http.post('/api/v1/mp/user/mall/ticket/detail', {
  194. boxId: id,
  195. noToken: true
  196. }).then(res => {
  197. uni.hideLoading();
  198. if (res.code == 0) {
  199. let prizeList = res.data.prizeList
  200. prizeList.forEach(item => {
  201. let picUrlArr = item.picUrl.split(',')
  202. item.picUrl = env.filePublic + picUrlArr[0]
  203. })
  204. this.prizeList = prizeList
  205. this.currentPrizeIndex = 2
  206. this.payInfo = this.imgList[this.currentIndex]
  207. }
  208. }).catch(() => {
  209. uni.hideLoading();
  210. })
  211. },
  212. selectedBanner(item, index) {
  213. uni.navigateTo({
  214. url: `/pages/ticketBox/detail?boxId=${ item.boxId }`
  215. })
  216. },
  217. getTicket(index) {
  218. this.currentIndex = index
  219. },
  220. close() {
  221. this.payShow = false
  222. },
  223. toProcess(id) {
  224. this.payShow = false
  225. uni.navigateTo({
  226. url: `/pages/process/index?id=${ id }`
  227. })
  228. },
  229. exchange() {
  230. this.payInfo = this.imgList[this.currentIndex]
  231. let data = {
  232. couponIds: [],
  233. autoCoupon: 1,
  234. boxId: this.payInfo.boxId,
  235. orderNum: 1
  236. }
  237. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  238. if (res.code == 0) {
  239. let info = {
  240. ...res.data,
  241. ...this.payInfo
  242. }
  243. this.payInfo = info
  244. this.payShow = true
  245. }
  246. }).catch(() => {
  247. uni.$u.toast('开刮失败,请重试!');
  248. })
  249. },
  250. toTicket() {
  251. uni.navigateTo({
  252. url: '/pages/ticketBox/index'
  253. })
  254. },
  255. toPrize() {
  256. if (!this.loginState) {
  257. uni.navigateTo({
  258. url: "/pages/login/index"
  259. })
  260. return
  261. }
  262. uni.navigateTo({
  263. url: '/pages/prize/index'
  264. })
  265. },
  266. toRule() {
  267. uni.navigateTo({
  268. url: '/pages/about/rule'
  269. })
  270. }
  271. }
  272. }
  273. </script>
  274. <style lang="scss" scoped>
  275. .status_bar {
  276. width: 100%;
  277. height: var(--status-bar-height);
  278. }
  279. /deep/ .u-tabbar__placeholder {
  280. display: none;
  281. }
  282. </style>
  283. <style lang="scss" scoped>
  284. .image-container {
  285. width: 750rpx;
  286. height: 40vh;
  287. .swiper-item {
  288. position: relative;
  289. width: 61vw;
  290. height: 40vh;
  291. display: flex;
  292. justify-content: center;
  293. align-items: center;
  294. }
  295. .image-wrap {
  296. position: relative;
  297. width: 61vw;
  298. height: 40vh;
  299. .img {
  300. width: 61vw;
  301. height: 40vh;
  302. }
  303. }
  304. }
  305. .prize-container {
  306. width: 750rpx;
  307. height: 13vh;
  308. margin-top: 2vh;
  309. .swiper-item {
  310. width: 100rpx;
  311. height: 13vh;
  312. display: flex;
  313. justify-content: flex-start;
  314. align-items: center;
  315. .image-wrap {
  316. width: 160rpx;
  317. height: 13vh;
  318. border-radius: 20rpx;
  319. background: linear-gradient(0deg, #BBBBBB, #FFFFFF);
  320. .img {
  321. width: 100%;
  322. height: 76%;
  323. }
  324. }
  325. }
  326. }
  327. .box {
  328. width: 100%;
  329. height: calc(100vh - 50px);
  330. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/index_bg.jpeg) center center;
  331. &-top {
  332. position: relative;
  333. display: flex;
  334. justify-content: space-between;
  335. padding: 130rpx 0 0 40rpx;
  336. &-action {
  337. z-index: 20;
  338. display: flex;
  339. &-item {
  340. margin-right: 76rpx;
  341. &-cir {
  342. width: 72rpx;
  343. height: 72rpx;
  344. background-color: #FFC320;
  345. border-radius: 50%;
  346. margin-bottom: 14rpx;
  347. image {
  348. width: 40rpx;
  349. height: 36rpx;
  350. }
  351. }
  352. &-txt {
  353. font-size: 24rpx;
  354. text-align: center;
  355. color: #FFFFFF;
  356. }
  357. }
  358. }
  359. &-tip {
  360. z-index: 20;
  361. display: flex;
  362. flex-direction: column;
  363. align-items: flex-end;
  364. justify-content: flex-end;
  365. &-txt {
  366. font-size: 24rpx;
  367. width: 152rpx;
  368. height: 48rpx;
  369. background-color: #FFC320;
  370. border-radius: 24rpx 0 0 24rpx;
  371. margin-top: 40rpx;
  372. }
  373. &-txt:last-child {
  374. background-color: #FFFFCC;
  375. }
  376. }
  377. &-news {
  378. position: absolute;
  379. left: 0;
  380. bottom: 0;
  381. z-index: 10;
  382. width: 100vw;
  383. }
  384. }
  385. &-ticket {
  386. position: relative;
  387. margin: 40rpx 0 0;
  388. .index-left {
  389. position: absolute;
  390. width: 100rpx;
  391. height: 100rpx;
  392. top: 380rpx;
  393. left: 10rpx;
  394. z-index: 20;
  395. }
  396. .index-right {
  397. position: absolute;
  398. width: 100rpx;
  399. height: 100rpx;
  400. top: 380rpx;
  401. right: 10rpx;
  402. z-index: 20;
  403. }
  404. .box-img {
  405. position: absolute;
  406. top: 0;
  407. z-index: 10;
  408. width: 100vw;
  409. height: 70vw;
  410. }
  411. }
  412. &-ticket-btn {
  413. margin-top: 30rpx;
  414. &-content {
  415. position: relative;
  416. width: 420rpx;
  417. height: 142rpx;
  418. image {
  419. width: 420rpx;
  420. height: 142rpx;
  421. }
  422. .title {
  423. position: absolute;
  424. top: 0;
  425. width: 100%;
  426. height: 142rpx;
  427. text {
  428. font-size: 56rpx;
  429. font-weight: bold;
  430. color: #C44906;
  431. text-shadow: 0px 1px 0px rgba(255, 255, 255, 0.76);
  432. }
  433. }
  434. }
  435. }
  436. }
  437. </style>