index.vue 9.4 KB

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