123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408 |
- <template>
- <view>
- <u-navbar title="选择奖品" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
- <view class="choice">
- <view class="choice-title" v-if="!tipShow">恭喜你获得</view>
- <view class="choice-all" v-if="total > 1 && !tipShow">以下奖品任选其一</view>
- <view class="flex choice-list">
- <view class="choice-list-item" v-for="(item, index) in prizeList" :key="index"
- @click="selectPrize(item, index)">
- <view
- :class="{'item-info action': actionIndex == index, 'item-info confirm': actionIndex != index, 'item-info null': item.remainQty == 0}">
- <view class="flex info-image">
- <image :src="item.picUrl" mode="aspectFill"></image>
- </view>
- <view class="title" v-if="item.prizeType && item.prizeType.value != 'coin'">{{ item.title }}
- </view>
- <view class="title" v-else>盲豆x {{ item.value }}</view>
- <view class="tip" v-if="item.remainQty == 0">已兑完</view>
- <view class="flex action-icon" v-if="actionIndex == index">
- <u-icon name="checkmark" color="#fff" size="24"></u-icon>
- </view>
- </view>
- </view>
- </view>
- <!-- <view class="flex btn">
- <view class="confirm" @click="confirmPrize" v-if="!tipShow">确认</view>
- </view> -->
- </view>
-
- <view class="footer-fixed" v-if="!tipShow">
- <view class="flex btn">
- <button type="default" @click="confirmPrize">确认</button>
- </view>
- </view>
- <u-popup :show="tipShow" :round="10" mode="center" :safeAreaInsetBottom="false">
- <view class="null-prize">
- <view class="title">该盲票已被他人买走了</view>
- <navigator open-type="exit" target="miniProgram" hover-class="none" class="btn">确认</navigator>
- </view>
- </u-popup>
- <u-popup :show="comfirmShow" :round="10" mode="center" :safeAreaInsetBottom="false">
- <view class="confirm-prize">
- <view class="flex confirm-prize-info">
- <image :src="actionInfo.picUrl" mode="aspectFill"></image>
- <view class="title" v-if="actionInfo.prizeType && actionInfo.prizeType.value != 'coin'">
- {{ actionInfo.title }}
- </view>
- <view class="title" v-else>盲豆x {{ actionInfo.value }}</view>
- </view>
- <view class="confirm-prize-tip" v-if="actionInfo.prizeType && actionInfo.prizeType.value != 'coin'">
- 已放入我的奖品库</view>
- <view class="confirm-prize-tip" v-else>已放入“我的盲豆”</view>
- <view class="flex confirm-prize-btn">
- <view class="back" @click="back">返回</view>
- <view class="confirm" @click="toPrize">前往查看</view>
- </view>
- </view>
- </u-popup>
- </view>
- </template>
- <script>
- import env from '../../config/env.js'
- import $http from '@/utils/request.js'
- export default {
- data() {
- return {
- ticketId: '',
- prizeList: [],
- total: 0,
- actionIndex: 0,
- tipShow: false,
- comfirmShow: false,
- actionInfo: {}
- };
- },
- onLoad(options) {
- this.ticketId = options.id
- },
- onShow() {
- this.getPrizeList()
- },
- methods: {
- getPrizeList() {
- uni.showLoading({
- title: '加载中'
- });
- let data = {
- ticketId: this.ticketId
- }
- $http.post('/api/v1/mp/user/ticket/queryHitPrizeList', data).then(res => {
- uni.hideLoading();
- if (res.code == 0) {
- res.data.prizeList.forEach(item => {
- let picUrlArr = item.picUrl.split(',')
- item.picUrl = env.filePublic + picUrlArr[0]
- item.prizeType = JSON.parse(item.prizeType)
- })
- this.prizeList = res.data.prizeList
- this.ticketId = res.data.ticketId
- this.total = this.prizeList.length
- } else if (res.code == 1018) {
- this.tipShow = true
- } else {
- this.tipShow = true
- }
- }).catch(() => {
- uni.hideLoading();
- })
- },
- selectPrize(item, index) {
- if (item.remainQty == 0) {
- uni.$u.toast('该奖品已兑完!');
- return
- }
- this.actionIndex = index
- },
- confirmPrize() {
- let _this = this
- let item = _this.prizeList[_this.actionIndex]
- _this.actionInfo = item
- if (_this.prizeList.length > 1) {
- uni.showModal({
- title: '提示',
- content: '确定选择该奖品吗?',
- success(res) {
- if (res.confirm) {
- $http.post('/api/v1/mp/user/ticket/cashPrize', {
- ticketId: _this.ticketId,
- awardsId: item.awardsId,
- prizeId: item.prizeId
- }).then(res => {
- if (res.code == 0) {
- _this.comfirmShow = true
- }
- })
- }
- }
- })
- } else {
- $http.post('/api/v1/mp/user/ticket/cashPrize', {
- ticketId: _this.ticketId,
- awardsId: item.awardsId,
- prizeId: item.prizeId
- }).then(res => {
- if (res.code == 0) {
- _this.comfirmShow = true
- }
- })
- }
- },
- toIndex() {
- uni.switchTab({
- url: '/pages/index/index'
- })
- },
- back() {
- let pages = getCurrentPages();
- if (pages.length > 1) {
- uni.navigateBack({
- delta: 1
- })
- } else {
- uni.switchTab({
- url: '/pages/core/index'
- })
- }
- },
- toPrize() {
- uni.switchTab({
- url: '/pages/user/index'
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .choice {
- width: 100%;
- min-height: calc(100vh - 44px - var(--status-bar-height));
- background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/background.png) center center;
- padding-bottom: 150rpx;
- &-title {
- padding-top: 100rpx;
- font-size: 56rpx;
- font-weight: bold;
- text-align: center;
- line-height: 84rpx;
- margin-bottom: 12rpx;
- }
- &-all {
- text-align: center;
- line-height: 40rpx;
- }
- &-list {
- justify-content: space-around;
- flex-wrap: wrap;
- padding: 60rpx;
- &-item {
- position: relative;
- width: 43%;
- height: 440rpx;
- margin-bottom: 40rpx;
- background-color: #FFFFFF;
- border-radius: 10rpx;
- .item-info {
- height: 100%;
- display: flex;
- flex-direction: column;
- align-items: center;
- border: 2px solid #FFFFFF;
- border-radius: 10rpx;
- }
- .confirm {
- background: none;
- box-shadow: none;
- }
- .action-icon {
- position: absolute;
- bottom: -15rpx;
- right: -15rpx;
- width: 82rpx;
- height: 82rpx;
- line-height: 82rpx;
- background-color: rgba(236, 122, 61, 100);
- text-align: center;
- box-shadow: 0px 4rpx 12rpx 0px rgba(0, 0, 0, 0.4);
- border-radius: 50%;
- }
- .action {
- box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4);
- border: 2px solid rgba(236, 122, 61, 100);
- }
- .null {
- box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4);
- border: 2px solid rgba(187, 187, 187, 54);
- }
- .info-image {
- width: 100%;
- min-height: 75%;
- background-color: #F8F8F8;
- border-top-left-radius: 10rpx;
- border-top-right-radius: 10rpx;
- }
- image {
- width: 100%;
- height: 80%;
- }
- .title {
- width: 100%;
- font-size: 24rpx;
- margin: 16rpx 0 0 10rpx;
- color: #333;
- }
- .tip {
- margin: 16rpx 0 0 10rpx;
- font-size: 24rpx;
- color: red;
- }
- }
- }
- .btn {
- margin-top: 200rpx;
- .confirm {
- width: 400rpx;
- height: 80rpx;
- font-size: 36rpx;
- line-height: 80rpx;
- border-radius: 20rpx;
- background-color: rgba(235, 112, 9, 100);
- color: rgba(255, 255, 255, 100);
- text-align: center;
- }
- }
- }
-
- .footer-fixed {
- position: fixed;
- bottom: var(--window-bottom);
- left: 0;
- right: 0;
- z-index: 11;
- box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
- background: #fff;
- // 设置ios刘海屏底部横线安全区域
- padding-bottom: constant(safe-area-inset-bottom);
- padding-bottom: env(safe-area-inset-bottom);
-
- .btn {
- padding: 20rpx 0;
-
- /deep/ button {
- width: 640rpx;
- height: 90rpx;
- line-height: 90rpx;
- font-size: 36rpx;
- color: #fff;
- background-color: $uni-bg-color;
- border: none;
- border-radius: 20rpx;
- }
- }
- }
- .null-prize {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- width: 80vw;
- height: 320rpx;
- background-color: #FFFFFF;
- border: 1px solid rgba(187, 187, 187, 100);
- .btn {
- margin-top: 60rpx;
- width: 160rpx;
- height: 60rpx;
- line-height: 60rpx;
- border-radius: 8rpx;
- background-color: rgba(235, 112, 9, 100);
- color: rgba(255, 255, 255, 100);
- font-size: 28rpx;
- text-align: center;
- }
- }
- .confirm-prize {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- width: 80vw;
- padding: 40rpx 0;
- &-info {
- width: 80%;
- margin-bottom: 60rpx;
- justify-content: space-around;
- image {
- width: 150rpx;
- height: 200rpx;
- }
-
- .title{
- flex: 1;
- padding-left: 40rpx;
- }
- }
- &-tip {
- text-align: center;
- margin-bottom: 60rpx;
- }
- &-btn {
- width: 80%;
- justify-content: space-around;
- .back {
- width: 160rpx;
- height: 60rpx;
- line-height: 60rpx;
- border-radius: 8rpx;
- color: rgba(235, 112, 9, 100);
- font-size: 28rpx;
- text-align: center;
- font-family: Microsoft Yahei;
- border: 1px solid rgba(235, 112, 9, 100);
- }
- .confirm {
- width: 160rpx;
- height: 60rpx;
- line-height: 60rpx;
- border-radius: 8rpx;
- background-color: rgba(235, 112, 9, 100);
- color: rgba(253, 253, 253, 100);
- font-size: 28rpx;
- text-align: center;
- }
- }
- }
- </style>
|