123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556 |
- <template>
- <view>
- <!-- 非H5撑高元素 -->
- <!-- <view class="status_bar"></view> -->
- <view class="box">
- <view class="box-top">
- <view class="box-top-action">
- <view class="box-top-action-item" @click="toPrize">
- <view class="flex box-top-action-item-cir">
- <image src="../../static/icon/index_prize.png" mode=""></image>
- </view>
- <view class="box-top-action-item-txt">奖品库</view>
- </view>
- </view>
- <view class="box-top-tip">
- <view class="flex box-top-tip-txt" @click="toRule">
- <text>规则说明</text>
- </view>
- <view class="flex box-top-tip-txt" @click="toTicket">
- <text>所有盲票</text>
- </view>
- </view>
- <!-- 弹幕 -->
- <view class="box-top-news">
- <prize-news :list="prizeNewsListOne" duration="20" v-if="prizeNewsListOne.length" />
- <prize-news :list="prizeNewsListTwo" duration="15" v-if="prizeNewsListTwo.length" />
- </view>
- </view>
- <view class="box-ticket">
- <!-- 盲票 -->
- <swiper class="image-container" circular :vertical="true" :current="currentIndex" :autoplay="false"
- @change="changeTicket" v-if="ticketList.length">
- <swiper-item class="swiper-item" v-for="(item, index) in ticketList" :key="item.picUrl"
- @click="toTicketBox">
- <view class="flex image-wrap">
- <image class="img" :src="item.picUrl" lazy-load mode=""></image>
- </view>
- </swiper-item>
- </swiper>
- <swiper class="image-container" circular :vertical="true" :autoplay="false" v-else>
- <swiper-item class="swiper-item">
- <view class="flex image-wrap">
- <image class="img" src="../../static/icon/ticket_index.png" lazy-load mode=""></image>
- </view>
- </swiper-item>
- </swiper>
- <!-- 奖品 -->
- <view class="prize-goods">
- <view class="prize-goods-item" :style="{ animation: activeAnimation }">
- <view class="flex image-wrap" v-for="(item, index) in prizeList" :key="index" @click="toPrizeGoods(item)">
- <image class="img" :src="item.picUrl" lazy-load mode="aspectFill"></image>
- </view>
- </view>
- <view class="prize-goods-item" :style="{ animation: activeAnimation }">
- <view class="flex image-wrap" v-for="(item, index) in prizeList" :key="index" @click="toPrizeGoods(item)">
- <image class="img" :src="item.picUrl" lazy-load mode="aspectFill"></image>
- </view>
- </view>
- </view>
- <!-- 盲票背景 -->
- <image class="box-img" src="../../static/icon/index_box.png" mode="" @click="toTicketBox"></image>
- <!-- 向左箭头 -->
- <image class="index-left" src="../../static/icon/index_left.png" mode="" @click="ticketLeft"></image>
- <!-- 向右箭头 -->
- <image class="index-right" src="../../static/icon/index_right.png" mode="" @click="ticketRight"></image>
- </view>
- <!-- 立即开刮 -->
- <view class="flex box-ticket-btn">
- <view class="box-ticket-btn-content" @click="payment">
- <image src="../../static/icon/index_btn.png" mode=""></image>
- <view class="flex title">
- <text>{{ payInfo.salePrice / 100 }}元立即开刮</text>
- </view>
- </view>
- </view>
- </view>
- <!-- tabbar组件 -->
- <custom-tab-bar :activeValue="'index'" />
- <!-- 支付弹框组件 -->
- <pay-popup :pay-show="payShow" :pay-info="payInfo" @close="close" @success="toProcess" v-if="payShow" />
- </view>
- </template>
- <script>
- import env from '../../config/env.js'
- import $http from '@/utils/request.js'
- import CustomTabBar from '../../components/custom-tab-bar/custom-tab-bar.vue'
- import Carousel from '../../components/vear-carousel/vear-carousel'
- import PayPopup from '../../components/pay-popup/pay-popup.vue'
- import PrizeNews from '../../components/prize-news/prize-news.vue'
- export default {
- components: {
- CustomTabBar,
- Carousel,
- PayPopup,
- PrizeNews,
- },
- data() {
- return {
- loginState: false, // 登录状态
- ticketList: [], // 盲票列表
- prizeList: [], // 奖品列表
- prizeNewsListOne: [], // 弹幕列表
- prizeNewsListTwo: [], // 弹幕列表
- payShow: false, // 支付弹框显示
- payInfo: {}, // 支付详情
- currentIndex: 0, // 盲票选中下标
- activeAnimation: 'moveLeft 10s linear infinite normal', // 奖品动画
- };
- },
- onLoad(opthios) {
- /**
- * 票赢天下小程序分享盲票跳转接受的参数
- * shareUid: 用户ID
- * shareType: 分享类型
- * */
- if (opthios.scene) {
- let sceneStr = decodeURIComponent(opthios.scene)
- this.sceneArr = sceneStr.split('&')
- uni.setStorageSync('shareUid', this.sceneArr[0])
- uni.setStorageSync('shareType', this.sceneArr[1])
- }
- this.getList()
- },
- onShow(opthios) {
- this.loginState = uni.getStorageSync('token') ? true : false
- this.getPrizeNews()
- },
- methods: {
- // 获取盲票列表
- getList() {
- uni.showLoading({
- title: '加载中'
- });
- let data = {
- categoryId: '',
- tagId: '',
- type: 'online',
- noToken: true
- }
- $http.post(`/api/v1/mp/user/mall/ticket/list?pageNum=${this.pageNum}&pageSize=100`, data).then(
- res => {
- uni.hideLoading();
- if (res.code == 0) {
- res.rows.forEach(item => item.picUrl = env.filePublic + item.picUrl.split(',')[0] +
- '?imageView2/2/w/375')
- this.ticketList = res.rows
- this.getPrize(this.ticketList[0].boxId)
- }
- }).catch(() => {
- uni.hideLoading();
- })
- },
- // 获取弹幕列表
- getPrizeNews() {
- $http.post('/api/v1/mp/user/ticket/hitPrizeBarrage', {}).then(res => {
- const {
- listOne,
- listTwo
- } = res && res.data
- listOne.forEach(item => {
- item.avatar = item.avatar ? env.filePublic + item.avatar : env.filePublic +
- '70/EJ305PQR2IBE45O9AFAI'
- item.prizeInfo = item.prizeInfo && (item.prizeInfo.length > 14) ? item.prizeInfo
- .substring(0, 15) + '...' : item.prizeInfo
- })
- listTwo.forEach(item => {
- item.avatar = item.avatar ? env.filePublic + item.avatar : env.filePublic +
- '70/EJ305PQR2IBE45O9AFAI'
- item.prizeInfo = item.prizeInfo && (item.prizeInfo.length > 14) ? item.prizeInfo
- .substring(0, 15) + '...' : item.prizeInfo
- })
- this.prizeNewsListOne = listOne
- this.prizeNewsListTwo = listTwo
- })
- },
- // 获取当前盲票的奖品列表
- getPrize(id) {
- this.prizeList = []
- $http.post('/api/v1/mp/user/mall/ticket/detail', {
- boxId: id,
- noToken: true
- }).then(res => {
- uni.hideLoading();
- if (res.code == 0) {
- let prizeList = res.data.prizeList
- prizeList.forEach(item => {
- let picUrlArr = item.picUrl.split(',')
- item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/170'
- })
- this.prizeList = prizeList
- // 根据奖品数量动态设置动画时间
- let time = Math.ceil(this.prizeList.length / 5 * 10)
- this.activeAnimation = `moveLeft ${ time }s linear infinite normal`,
- this.payInfo = this.ticketList[this.currentIndex]
- }
- }).catch(() => {
- uni.hideLoading();
- })
- },
- // 立即开刮
- payment() {
- this.payInfo = this.ticketList[this.currentIndex]
- let data = {
- userCouponIds: [],
- autoCoupon: 1,
- boxId: this.payInfo.boxId,
- orderNum: 1
- }
- $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
- if (res.code == 0) {
- let info = {
- ...res.data,
- ...this.payInfo,
- couponTitle: res.data && res.data.couponList && res.data.couponList.length && res
- .data.couponList[0].title,
- couponId: res.data && res.data.couponList && res.data.couponList.length && res.data
- .couponList[0].id
- }
- this.payInfo = info
- this.payShow = true
- }
- }).catch(() => {
- uni.$u.toast('开刮失败,请重试!');
- })
- },
- // 关闭支付弹框
- close() {
- this.payShow = false
- },
- // 盲票选中改变
- changeTicket(e) {
- this.getPrize(this.ticketList[this.currentIndex].boxId)
- },
- changeList() {
- let data = {
- categoryId: '',
- tagId: '',
- type: 'online',
- noToken: true
- }
- $http.post(`/api/v1/mp/user/mall/ticket/list?pageNum=${this.pageNum}&pageSize=100`, data).then(
- res => {
- const boxIdStr = this.ticketList.map(item => item.boxId).join()
- let boxIdStrNew = res && res.rows && res.rows.map(item => item.boxId).join()
- if (boxIdStr != boxIdStrNew) {
- this.currentIndex = 0
- this.getList()
- }
- })
- },
- // 盲票向左箭头
- ticketLeft() {
- if ((this.currentIndex >= 0) && (this.currentIndex < (this.ticketList.length - 1))) {
- this.currentIndex++
- } else if (this.currentIndex == (this.ticketList.length - 1)) {
- this.currentIndex = 0
- }
- this.changeList()
- },
- // 盲票向右箭头
- ticketRight() {
- if (this.currentIndex > 0) {
- this.currentIndex--
- } else if (this.currentIndex == 0) {
- this.currentIndex = this.ticketList.length - 1
- }
- this.changeList()
- },
- // 线上立即刮票成功,跳转到刮奖过程
- toProcess(id) {
- this.payShow = false
- uni.navigateTo({
- url: `/pages/process/index?id=${ id }`
- })
- },
- // 点击盲票,跳转盲票详情
- toTicketBox() {
- let item = this.ticketList[this.currentIndex]
- uni.navigateTo({
- url: `/pages/ticketBox/detail?boxId=${ item.boxId }`
- })
- },
- // 点击奖品,跳转到奖品详情
- toPrizeGoods(item) {
- if (item.prizeType == "goods") {
- uni.navigateTo({
- url: `/pages/prizeGoods/detail?id=${ item.refId }`
- })
- }
- //门店优惠券
- if (item.prizeType == "coupon") {
- // if (item.couponType == "1") {
- // uni.navigateTo({
- // url: `/pages/prizeGoods/detail?id=426`
- // })
- // }
- // if (item.couponType == "2") {
- // uni.navigateTo({
- // url: `/pages/prizeGoods/detail?id=425`
- // })
- // }
- uni.navigateTo({
- url: `/pages/prizeGoods/detail?id=425`
- })
- }
- // 盲豆
- if (item.prizeType == "coin") {
- uni.navigateTo({
- url: `/pages/prizeGoods/detail?id=424`
- })
- }
- },
- // 点击所有盲票
- toTicket() {
- uni.navigateTo({
- url: '/pages/ticketBox/index'
- })
- },
- // 点击奖品库
- toPrize() {
- if (!this.loginState) {
- uni.navigateTo({
- url: "/pages/login/index"
- })
- return
- }
- uni.navigateTo({
- url: '/pages/prize/index'
- })
- },
- // 点击规则说明
- toRule() {
- uni.navigateTo({
- url: '/pages/about/rule'
- })
- }
- },
- onShareAppMessage(res) {
- return {
- title: '盲票,玩的就是有趣',
- path: '/pages/index/index'
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .status_bar {
- width: 100%;
- height: var(--status-bar-height);
- }
- /deep/ .u-tabbar__placeholder {
- display: none;
- }
- </style>
- <style lang="scss" scoped>
- .box {
- width: 100%;
- height: calc(100vh - 50px);
- background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/index_bg.jpeg) center center;
- &-top {
- position: relative;
- display: flex;
- justify-content: space-between;
- padding: 130rpx 0 0 40rpx;
- &-action {
- z-index: 20;
- display: flex;
- &-item {
- margin-right: 76rpx;
- &-cir {
- width: 72rpx;
- height: 72rpx;
- background-color: #FFC320;
- border-radius: 50%;
- margin-bottom: 14rpx;
- image {
- width: 40rpx;
- height: 36rpx;
- }
- }
- &-txt {
- font-size: 24rpx;
- text-align: center;
- color: #FFFFFF;
- }
- }
- }
- &-tip {
- z-index: 20;
- display: flex;
- flex-direction: column;
- align-items: flex-end;
- justify-content: flex-end;
- &-txt {
- font-size: 24rpx;
- width: 152rpx;
- height: 48rpx;
- background-color: #FFC320;
- border-radius: 24rpx 0 0 24rpx;
- margin-top: 40rpx;
- }
- &-txt:last-child {
- background-color: #FFFFCC;
- }
- }
- &-news {
- position: absolute;
- left: 0;
- bottom: 0;
- z-index: 10;
- width: 100vw;
- }
- }
- &-ticket {
- position: relative;
- margin: 40rpx 0 0;
- .image-container {
- width: 750rpx;
- height: 40vh;
- .swiper-item {
- position: relative;
- width: 61vw;
- height: 40vh;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .image-wrap {
- position: relative;
- width: 61vw;
- height: 40vh;
- .img {
- width: 61vw;
- height: 40vh;
- }
- }
- }
- .prize-goods {
- display: flex;
- width: 100vw;
- height: 13vh;
- margin-top: 2vh;
- overflow: hidden;
- .prize-goods-item {
- display: flex;
- height: 13vh;
- .image-wrap {
- width: 160rpx;
- height: 13vh;
- border-radius: 20rpx;
- background: linear-gradient(0deg, #e6e6e6, #FFFFFF);
- margin-right: 60rpx;
- .img {
- width: 100%;
- height: 76%;
- }
- }
- }
- }
- .index-left {
- position: absolute;
- width: 100rpx;
- height: 100rpx;
- top: 380rpx;
- left: 10rpx;
- z-index: 20;
- }
- .index-right {
- position: absolute;
- width: 100rpx;
- height: 100rpx;
- top: 380rpx;
- right: 10rpx;
- z-index: 20;
- }
- .box-img {
- position: absolute;
- top: 0;
- z-index: 10;
- width: 100vw;
- height: 70vw;
- }
- }
- &-ticket-btn {
- margin-top: 30rpx;
- &-content {
- position: relative;
- width: 420rpx;
- height: 142rpx;
- image {
- width: 420rpx;
- height: 142rpx;
- }
- .title {
- position: absolute;
- top: 0;
- width: 100%;
- height: 142rpx;
- text {
- font-size: 56rpx;
- font-weight: bold;
- color: #C44906;
- text-shadow: 0px 1px 0px rgba(255, 255, 255, 0.76);
- }
- }
- }
- }
- }
- </style>
|