123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- <template>
- <view class="container">
- <view class="product">
- <uni-swiper-dot class="uni-swiper-dot-box" :info="info" :current="current" :mode="mode" field="content">
- <swiper class="swiper-box" @change="swiperChange" :current="swiperDotIndex">
- <swiper-item v-for="(item, index) in boxDetail.boxLeft">
- <image class="swiperItem" :src="detail.prizeIcon" mode="aspectFit" />
- </swiper-item>
- </swiper>
- </uni-swiper-dot>
- </view>
- <view class="number">{{ num }} / {{ boxDetail.boxLeft }} 包</view>
- <view class="tipText">官方正品,非质量问题不支持退换</view>
- <view class="prizes">
- <view class="prizesLine">
- <view class="prize" v-for="(item, index) in prizeList" @click="showImg(item)">
- <image class="prizeImg" :src="item.icon" mode="aspectFit"></image>
- <view class="info">
- <view class="name">
- {{ item.name }}
- </view>
- <view class="price">¥{{ detail.price }}</view>
- </view>
- </view>
- </view>
- </view>
- <view class="buttons">
- <view class="button button1" @click="currentChange">换一包</view>
- <view class="button button2" @click="buy" style="color: #6a3d11">就买它</view>
- </view>
- <view class="rightButtons">
- <view class="button">规则</view>
- <view class="button" @click="toKnapsack" style="top: 44px">背包</view>
- <view class="button" @click="toWinningRecord" style="bottom: 0">中奖记录</view>
- </view>
- <paymentPopup ref="paymentPopup" @callBack="paymentSuccess" />
- <imgPopup ref="imgPopup" />
- </view>
- </template>
- <script>
- import paymentPopup from '@/component/paymentPopup.vue'
- import imgPopup from '@/component/imgPopup.vue'
- import { raffleDetailApi, getRoundPrizes, getBoxDetail } from '@/api/drawCard.js'
- export default {
- components: {
- paymentPopup,
- imgPopup,
- },
- data() {
- return {
- query: null,
- detail: null,
- boxDetail: null,
- current: 0,
- mode: 'dot',
- swiperDotIndex: 0,
- num: 1,
- prizeList: [],
- }
- },
- onLoad(query) {
- console.log(query, 'query')
- this.query = query
- if (query.raffleId) {
- this.init()
- }
- },
- methods: {
- init() {
- this.getBoxDetail()
- this.getDetail()
- this.getCard()
- },
- showImg(value) {
- this.$refs.imgPopup.show(value)
- },
- aniRun() {
- // 同时右平移到 100px,旋转 360 读
- this.$refs.ani.step({
- translateX: '100px',
- rotate: '360',
- })
- // 上面的动画执行完成后,等待200毫秒平移到 0px,旋转到 0 读
- this.$refs.ani.step(
- {
- translateX: '0px',
- rotate: '0',
- },
- {
- timingFunction: 'ease-in',
- duration: 200,
- },
- )
- // 开始执行动画
- this.$refs.ani.run(() => {
- this.aniRun()
- })
- },
- // 购买
- buy() {
- this.$refs.paymentPopup.show(this.query, 1, this.detail)
- },
- // 支付成功后回调
- paymentSuccess() {
- this.init()
- },
- getDetail() {
- let params = {
- raffleId: this.query.raffleId,
- }
- raffleDetailApi(params).then(res => {
- console.log(res, '详情')
- this.detail = res.data
- })
- },
- getBoxDetail() {
- getBoxDetail(this.query).then(res => {
- console.log(res, 'res')
- this.boxDetail = res.data
- })
- },
- getCard() {
- let params = {
- raffleId: this.query.raffleId,
- roundId: this.query.roundId,
- }
- getRoundPrizes(params).then(res => {
- console.log(res, '抽盒机奖品预览')
- this.prizeList = res.data
- })
- },
- swiperChange(value) {
- console.log(value)
- this.num = value.detail.current + 1
- },
- currentChange() {
- if (this.swiperDotIndex < this.boxDetail.boxLeft - 1) {
- this.swiperDotIndex += 1
- } else {
- this.swiperDotIndex = 0
- }
- },
- toKnapsack() {
- // 跳转背包界面
- wx.navigateTo({
- url: '/pages/knapsack/knapsack',
- })
- },
- toWinningRecord() {
- this.$navigateTo('/pages/winningRecord/winningRecord', this.query)
- },
- },
- }
- </script>
- <style scoped lang="scss">
- .container {
- background: #9ec8f9;
- overflow: inherit;
- .product {
- display: flex;
- justify-content: center;
- margin: 20vw auto 0 auto;
- // background: #fff;
- .uni-swiper-dot-box {
- display: inline-block;
- width: 60vw;
- height: 60vw;
- .swiper-box {
- width: 60vw;
- height: 60vw;
- }
- .swiperItem {
- width: 60vw;
- height: 60vw;
- }
- }
- }
- .number {
- margin-top: 5vw;
- text-align: center;
- color: #ffffff;
- text-shadow: 2px 2px 2px #829bfb;
- font-weight: 600;
- }
- .tipText {
- text-align: center;
- margin-top: 3vw;
- font-size: 13px;
- font-weight: 600;
- }
- .prizes {
- margin-top: 15vw;
- overflow: auto;
- padding: 0 20px;
- .prizesLine {
- position: relative;
- white-space: nowrap;
- }
- .prize {
- display: inline-block;
- margin-right: 10px;
- background: linear-gradient(180deg, #faf1a7 0%, #ffe456 100%);
- border-radius: 5px;
- overflow: hidden;
- .prizeImg {
- width: 20vw;
- height: 20vw;
- }
- .info {
- background: #fff;
- text-align: center;
- .name {
- font-size: 12px;
- }
- .price {
- color: #ff2c43;
- font-size: 12px;
- font-weight: 600;
- }
- }
- }
- }
- .buttons {
- margin-top: 5vw;
- display: flex;
- justify-content: space-around;
- .button {
- width: 35vw;
- height: 40px;
- padding: 0 20px;
- border-radius: 20px;
- line-height: 40px;
- color: #fff;
- font-weight: 600;
- font-size: 18px;
- text-align: center;
- }
- .button1 {
- background: linear-gradient(180deg, #89a9fa 0%, #716ff5 100%);
- }
- .button2 {
- background: linear-gradient(180deg, #fae5af 0%, #f3ba8e 100%);
- }
- }
- .rightButtons {
- position: fixed;
- right: 0;
- width: 50px;
- height: 70vh;
- top: 50%;
- transform: translateY(-50%);
- .button {
- position: absolute;
- right: 0;
- background: rgba(255, 255, 255, 0.7);
- font-size: 10px;
- text-align: center;
- height: 24px;
- line-height: 24px;
- border-radius: 12px 0 0 12px;
- width: 46px;
- }
- }
- }
- </style>
|