123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766 |
- <template>
- <view class="ticket-wrap">
- <!-- #ifdef MP-ALIPAY -->
- <view v-if="pagesNum > 1">
- <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="盲票详情" leftIconSize="0"></u-navbar>
- </view>
- <view v-else>
- <u-navbar leftIconSize="0" :placeholder="true" bgColor="#fff" title="盲票详情">
- <view class="nav-left flex" slot="left" @click="toIndex">
- <u-icon name="home" size="20" color="#333"></u-icon>
- <view class="nav-left__code">首页</view>
- </view>
- </u-navbar>
- </view>
- <!-- #endif -->
- <!-- #ifndef MP-ALIPAY -->
- <view v-if="pagesNum > 1">
- <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="盲票详情"></u-navbar>
- </view>
- <view v-else>
- <u-navbar leftIconSize="0" :placeholder="true" bgColor="#fff" title="盲票详情">
- <view class="nav-left flex" slot="left" @click="toIndex">
- <u-icon name="home" size="20" color="#333"></u-icon>
- <view class="nav-left__code">首页</view>
- </view>
- </u-navbar>
- </view>
- <!-- #endif -->
-
- <!-- 奖品轮播 -->
- <view class="prize">
- <!-- 查看规则 -->
- <view class="prize-rule" @click="toRule">
- <view class="prize-rule-content flex">
- <image src="../../static/index/index_tip.png" mode="scaleToFill"></image>
- <text>查看规则</text>
- </view>
- </view>
-
- <!-- 奖品 -->
- <swiper class="prize-swiper" previous-margin="100px" next-margin="100px" :interval="4000" :autoplay="true" :circular="true" @change="changePrizeSwiper">
- <swiper-item :class="prizeIndex == index ? 'swiper-item' : 'swiper-item-side'" v-for="(item, index) in prizeList.slice(0, 10)" :key="index">
- <view class="prize-swiper-item flex" @click="toPrizeGoods(item)">
- <image :class="prizeIndex == index ? 'img' : 'img-side'" :src="item.picUrl" mode="aspectFit"></image>
- </view>
- </swiper-item>
- </swiper>
- <!-- 奖品价格 -->
- <view class="prize-price flex">
- <view class="prize-price-present" v-if="prizeInfo.prizeType != 'coin'">¥{{ $numberFormat(prizeInfo.value) }}</view>
- <view class="prize-price-present" v-else>{{ prizeInfo.value }}个</view>
- <view class="prize-price-txt ells-one">{{ prizeInfo.title }}</view>
- <view class="prize-price__ticket-price flex">
- <image src="../../static/ticketBox/ticket_block.png" mode="scaleToFill"></image>
- <view class="txt">¥{{ $numberFormat(info.salePrice) }}</view>
- </view>
- <view class="prize-price-past" v-if="info.originPrice != 0">原价:¥{{ $numberFormat(info.originPrice) }}</view>
- </view>
-
- <!-- 开启盲票 -->
- <view class="ticket-btn flex">
- <image class="ticket-btn-game" src="../../static/ticketBox/ticket_game.png" mode="scaleToFill" @click="toRollingGame"></image>
- <view class="ticket-btn-center flex" @click="exchange">
- <image src="../../static/ticketBox/ticket_btn_center.png" mode="scaleToFill"></image>
- <view class="ticket-btn-center-txt">刮开盲票</view>
- </view>
- <view class="ticket-btn-share flex">
- <!-- #ifdef MP-WEIXIN -->
- <image src="../../static/ticketBox/ticket_share.png" mode="scaleToFill" @click="toShare"></image>
- <button type="default" open-type="share" v-if="loginState"></button>
- <!-- #endif -->
- </view>
- </view>
- </view>
-
- <!-- 盲票奖品说明 -->
- <view class="explain flex">
- <image class="image-left" src="../../static/ticketBox/ticket_explain_left.png" mode="aspectFit"></image>
- <view class="explain-title">刮开必出以下宝贝之一</view>
- <image class="image-right" src="../../static/ticketBox/ticket_explain_right.png" mode="aspectFit"></image>
- </view>
-
- <!-- 盲票奖品数量、概率 -->
- <view class="prize-total">
- <view class="prize-total-num">共{{ total }}款</view>
- <!-- 中奖概率 -->
- <view class="prize-total-chance flex">
- <view class="prize-total-chance-content flex" v-for="(item, index) in info.ticketAwardsLabelList">
- <image :src="item.picUrl" mode="scaleToFill"></image>
- <text>{{ item.hitRate }}%</text>
- </view>
- </view>
- <!-- 文字说明 -->
- <view class="prize-total-txt">因概率对小数点后三位进行四舍五入处理,故存在总值不为100%的可能。商品抽奖存在概率性,付费请谨慎!未成年人请在家长监督下使用。</view>
- </view>
-
- <!-- 盲票奖品列表 -->
- <view class="prize-list">
- <view class="prize-list-item flex" v-for="(item, index) in prizeList" :key="index" @click="toPrizeGoods(item)">
- <image :src="item.picUrl" mode="aspectFit"></image>
- <view class="prize-list-item-info flex">
- <view class="title ells">{{ item.title }}</view>
- <view class="price" v-if="item.prizeType != 'coin'">¥{{ $numberFormat(item.value) }}</view>
- <view class="price" v-else>{{ item.value }}个</view>
- </view>
- <view class="prize-list-item-grade">
- <image :src="item.awardsLabelPicUrl" />
- </view>
- </view>
- <u-loadmore :line="true" v-if="prizeList.length>10" :status="status" :loading-text="'努力加载中'" :nomore-text="'已经到底了'" />
- </view>
-
- <view class="footer-fixed" v-if="btnFixed">
- <view class="footer-fixed-btn flex">
- <view class="footer-fixed-btn-center flex" @click="exchange">
- <image src="../../static/ticketBox/ticket_btn_center.png" mode="scaleToFill"></image>
- <view class="footer-fixed-btn-center-txt">刮开盲票</view>
- </view>
- </view>
- </view>
-
- <!-- 支付弹层 -->
- <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 PayPopup from '../../components/pay-popup/pay-popup.vue'
- export default {
- components: {
- PayPopup
- },
- data() {
- return {
- boxId: '',
- picUrlArr: [],
- info: {},
- status: 'nomore',//上拉刷新状态
- pageNum: 1,
- total: 0,
- prizeList: [],
- payShow: false,
- payInfo: {},
- pagesNum: null,
- sceneArr: null,
-
- prizeIndex: 0,
- contnetHeight: 0,
- btnFixed: false,
- prizeInfo: {},
- userInfo: {},
- loginState: false,
- };
- },
- onLoad(opthios) {
- if (opthios.boxId) {
- this.boxId = opthios.boxId
- }
-
- if (opthios.scene) {
- let sceneStr = decodeURIComponent(opthios.scene)
- this.sceneArr = sceneStr.split('&')
- this.boxId = this.sceneArr[0]
- uni.setStorageSync('shareUid', this.sceneArr[1])
- uni.setStorageSync('shareType', this.sceneArr[2])
- }
- if (opthios.userId) {
- uni.setStorageSync('shareUid', opthios.userId)
- }
- if (opthios.type) {
- uni.setStorageSync('shareType', opthios.type)
- }
-
- /**
- * 外部app跳转接受的参数
- * shareUid: 用户ID
- * shareType: 分享类型
- * */
- if(opthios.uid) {
- uni.setStorageSync('shareUid', opthios.uid)
- uni.setStorageSync('shareType', opthios.t)
- }
- },
-
- mounted() {
- let _this = this;
- let info = uni.createSelectorQuery().select(".prize");
- info.boundingClientRect(function(data) { //data - 各种参数
- _this.contnetHeight = data.height
- }).exec()
- },
-
- onPageScroll: function(e) {
- let _this = this;
- _this.btnFixed = _this.contnetHeight <= e.scrollTop;
- },
-
- onShow() {
- this.loginState = uni.getStorageSync('token') ? true : false
- if(this.loginState) {
- this.getBaseInfo()
- }
- this.pagesNum = getCurrentPages().length
- if (this.boxId) {
- this.getDetail()
- }
-
- },
- methods: {
- changePrizeSwiper({ detail }) {
- this.prizeIndex = detail.current
- this.prizeInfo = this.prizeList[detail.current]
- },
-
- getDetail() {
- uni.showLoading({
- title: '加载中'
- });
- $http.post('/api/v1/mp/user/mall/ticket/detail/new', {
- boxId: this.boxId,
- noToken: true
- }).then(res => {
- uni.hideLoading();
- if (res.code == 0) {
- this.info = {
- ...res.data,
- picUrl: res.data.picUrl.split(',').map(item => env.filePublic + item + '?imageView2/2/w/375'),
- ticketAwardsLabelList: res.data.ticketAwardsLabelList.map(item => {
- return { ...item, picUrl: env.filePublic + item.picUrl }
- })
- }
- this.pageNum = 1
- this.total = 0
- this.prizeList = []
- this.getPrizeList()
- }
- }).catch(() => {
- uni.hideLoading();
- })
- },
- getPrizeList() {
- $http.post(`/api/v1/mp/user/ticket/prize/list/${this.boxId}?pageNum=${this.pageNum}&pageSize=10`,{}).then(res => {
- if (res.code == 0) {
- let prizeList = res.rows
- prizeList.forEach(item => {
- item.picUrl = env.filePublic + item.picUrl.split(',')[0] + '?imageView2/2/w/375'
- item.awardsLabelPicUrl = env.filePublic + item.awardsLabelPicUrl
- })
- this.total = res.total
- this.prizeList = this.prizeList.concat(prizeList)
- this.prizeInfo = this.prizeList[this.prizeIndex]
- }
- })
- },
- getPageNum() {
- let pages = getCurrentPages();
- },
- close() {
- this.payShow = false
- },
- toProcess(id) {
- this.payShow = false
- uni.navigateTo({
- url: `/packagePrize/rolling/index?boxId=${ this.info.boxId }&orderId=${ id }&isTry=0`
- })
- },
- exchange() {
- let data = {
- userCouponIds: [],
- autoCoupon: 1,
- boxId: this.info.boxId,
- orderNum: 1
- }
- $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
- if (res.code == 0) {
- let info = {
- ...res.data,
- ...this.info,
- picUrl: this.info.picUrl[0],
- 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
- }
- })
- },
-
- toRollingGame() {
- if (!uni.getStorageSync('token')) {
- uni.navigateTo({
- url: '/pages/login/index'
- })
- return
- }
- uni.navigateTo({
- url: `/packagePrize/rolling/index?boxId=${ this.info.boxId }&isTry=1`
- })
- },
- toShare() {
- this.getBaseInfo()
- // if (!uni.getStorageSync('token')) {
- // uni.navigateTo({
- // url: "/pages/login/index"
- // })
- // return
- // }
- // uni.navigateTo({
- // url: `/packageOperate/share/index?boxId=${ this.info.boxId }`
- // })
- },
- toIndex() {
- uni.switchTab({
- url: '/pages/index/index'
- })
- },
-
- // 点击规则说明
- toRule() {
- uni.navigateTo({
- url: '/packageOther/rule/index'
- })
- },
- toPrizeGoods(item) {
- if (item.prizeType == "goods") {
- uni.navigateTo({
- url: `/packagePrize/goods/detail?id=${ item.refId }`
- })
- }
- //门店优惠券
- if (item.prizeType == "coupon" || item.prizeType == "coupon_pkg") {
- uni.navigateTo({
- url: `/packagePrize/goods/detail?id=425`
- })
- }
- // 盲豆
- if (item.prizeType == "coin") {
- uni.navigateTo({
- url: `/packagePrize/goods/detail?id=424`
- })
- }
- },
-
- getBaseInfo() {
- $http.post('/api/v1/mp/user/getLoginUserinfo', {}).then(res => {
- uni.hideLoading();
- if (res.code == 0) {
- this.userInfo = res.data
- }
- })
- },
- },
-
- onShareAppMessage(res) {
- return {
- title: '一起来刮盲票吧',
- path: `/pages/ticketBox/detail?boxId=${ this.info.boxId }&userId=${ this.userInfo.userId }&type=1`,
- type: 2,
- }
- },
- //分享朋友圈
- onShareTimeline() {
- return {
- title: '一起来刮盲票吧',
- // query: { userId: this.userInfo.userId,
- // type: 1, },
- query: `boxId=${ this.info.boxId }&userId=${ this.userInfo.userId?this.userInfo.userId:null }&type=1`
-
- }
- },
- onReachBottom() {
- if(this.total < this.pageNum * 10) return ;
- this.status = 'loading';
- // setTimeout(() => {
- ++this.pageNum
- if(this.total < this.pageNum * 10) this.status = 'nomore';
- else this.status = 'loading';
- this.getPrizeList()
- // }, 2000)
- },
- }
- </script>
- <style lang="scss" scoped>
- .ticket-wrap {
- background: #FFF3EB;
- padding-bottom: 100rpx;
- }
- .nav-left {
- &__code {
- margin-left: 10rpx;
- }
- }
-
- // 奖品轮播
- .prize {
- // height: 71vh;
- background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/detail_3.png) center center no-repeat;
- background-size: 100vw 71vh;
- margin-bottom: 14rpx;
-
- // 查看规则
- &-rule {
- display: flex;
- align-items: center;
- height: 34rpx;
- padding: 44rpx 0 0 34rpx;
- margin-bottom: 60rpx;
-
- &-content {
- image {
- width: 34rpx;
- height: 34rpx;
- margin-right: 14rpx;
- }
-
- text {
- font-size: 40rpx;
- font-family: 'YouSheBiaoTiHei';
- font-weight: 400;
- color: #FFFFFF;
- }
- }
- }
-
- // 奖品轮播
- &-swiper {
- height: 534rpx;
-
- .swiper-item {
- width: 100%;
- height: 100%;
- // 80
- }
-
- .swiper-item-side {
- width: 100%;
- height: 100%;
- margin: 0;
- }
-
- &-item {
- height: 267px;
-
- .img {
- position: absolute;
-
- width: 100%;
- height: 100%;
- animation: prizeBig .3s;
- }
-
- .img-side {
- width: 60%;
- height: 60%;
- animation: prizeMini .3s;
- opacity: .5;
- }
- }
- }
-
- // 奖品价格
- &-price {
- flex-direction: column;
- justify-content: space-between;
- height: 14vh;
- margin-bottom: 30rpx;
-
- &-present {
- font-size: 26rpx;
- font-weight: bold;
- }
-
- &-txt {
- padding: 0 34rpx;
- font-size: 30rpx;
- font-weight: bold;
- }
-
- &__ticket-price {
- position: relative;
- height: 66rpx;
-
- image {
- width: 276rpx;
- height: 66rpx;
- }
-
- .txt {
- position: absolute;
- font-size: 40rpx;
- line-height: 66rpx;
- font-family: YouSheBiaoTiHei;
- font-weight: 400;
- color: #FFFFFF;
- }
- }
-
- &-past {
- font-size: 26rpx;
- font-weight: bold;
- text-decoration: line-through;
- color: #5E3909;
- }
- }
-
- // 开启盲票
- .ticket-btn {
- justify-content: space-between;
- height: 10vh;
- padding: 0 34rpx;
-
- &-game {
- width: 110rpx;
- height: 110rpx;
- }
-
- &-center {
- position: relative;
- height: 100%;
-
- image {
- height: 100%;
- width: 55vw;
- }
-
- &-txt {
- position: absolute;
- top: 30rpx;
- font-size: 72rpx;
- line-height: 72rpx;
- font-family: YouSheBiaoTiHei;
- font-weight: 400;
- color: #FFFFFF;
- }
- }
-
- &-share {
- position: relative;
- width: 110rpx;
- height: 110rpx;
-
- image {
- position: absolute;
- width: 110rpx;
- height: 110rpx;
- }
-
- ::v-deep button {
- position: absolute;
- z-index: 5;
- width: 110rpx;
- height: 110rpx;
- background: none;
- border: none !important;
- }
- ::v-deep uni-button:after {
- border: none !important;
- }
- ::v-deep button:after {
- border: none !important;
- }
- }
- }
- }
-
- // 盲票奖品说明
- .explain {
- width: 100vw;
- position: relative;
- height: 40rpx;
- margin-bottom: 32rpx;
-
- .image-left {
- width: 18vw;
- height: 40rpx;
- }
-
- .image-right {
- width: 18vw;
- height: 40rpx;
- }
-
- &-title {
- font-size: 46rpx;
- line-height: 46rpx;
- font-family: YouSheBiaoTiHei;
- font-weight: 400;
- color: #5E3909;
- padding: 0 8rpx;
- }
- }
-
- // 盲票奖品数量、概率
- .prize-total {
- margin-bottom: 34rpx;
-
- &-num {
- font-size: 26rpx;
- text-align: center;
- font-weight: bold;
- color: #744111;
- margin-bottom: 24rpx;
- }
-
- &-chance {
- margin-bottom: 32rpx;
-
- &-content {
- margin-right: 40rpx;
-
- image {
- width: 56rpx;
- height: 50rpx;
- }
-
- text {
- font-size: 28rpx;
- font-family: YouSheBiaoTiHei;
- font-weight: 400;
- color: #622C06;
- }
- }
-
- &-content:last-child {
- margin: 0;
- }
- }
-
- &-txt {
- padding: 0 100rpx;
- font-size: 26rpx;
- font-weight: 500;
- color: #956B33;
- line-height: 42rpx;
- text-align: center;
- }
- }
-
- // 盲票奖品列表
- .prize-list {
- padding: 0 34rpx 70rpx;
-
- &-item {
- position: relative;
- padding: 0 110rpx 0 84rpx;
- justify-content: flex-start;
- height: 264rpx;
- background: #FFFFFF;
- border-radius: 22rpx;
- margin-bottom: 26rpx;
-
- image {
- width: 166rpx;
- height: 166rpx;
- margin-right: 34rpx;
- }
-
- &-info {
- height: 166rpx;
- flex: 1;
- flex-direction: column;
- align-items: flex-start;
- justify-content: space-between;
-
- .title {
- font-size: 30rpx;
- font-weight: bold;
- line-height: 42rpx;
- }
-
- .price {
- font-size: 36rpx;
- font-weight: bold;
- color: #FF4208;
- line-height: 42rpx;
- }
- }
-
- &-grade {
- position: absolute;
- top: -12rpx;
- left: 0;
-
- image {
- width: 66rpx;
- height: 60rpx;
- }
- }
- }
- }
-
- // 滚动固定按钮
- .footer-fixed {
- position: fixed;
- bottom: var(--window-bottom);
- left: 0;
- right: 0;
-
- &-btn {
- height: 10vh;
-
- &-center {
- position: relative;
- height: 100%;
-
- image {
- height: 100%;
- width: 55vw;
- }
-
- &-txt {
- position: absolute;
- top: 30rpx;
- font-size: 72rpx;
- line-height: 72rpx;
- font-family: YouSheBiaoTiHei;
- font-weight: 400;
- color: #FFFFFF;
- }
- }
- }
- }
-
- // 奖品缩小动画
- @keyframes prizeMini
- {
- from {
- width: 100%;
- height: 100%;
- }
- to {
- width: 60%;
- height: 60%;
- }
- }
-
- // 奖品放大动画
- @keyframes prizeBig
- {
- from {
- width: 60%;
- height: 60%;
- }
- to {
- width: 100%;
- height: 100%;
- }
- }
- </style>
|