index.vue 11 KB

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