123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <template>
- <view>
- <u-navbar title="选择奖品" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
- <view class="choice">
- <view class="choice-title">恭喜你获得</view>
- <view class="choice-all" v-if="total > 1">以下奖品任选其一</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="{'flex action': actionIndex == index, 'flex confirm': actionIndex != index, 'flex null': item.remainQty == 0}">
- <view class="info">
- <image :src="item.picUrl" mode="aspectFill"></image>
- <view class="title">{{ item.title }}</view>
- <view class="tip" v-if="item.remainQty == 0">已兑完</view>
- </view>
- </view>
- </view>
- </view>
- <view class="flex btn">
- <view class="confirm" @click="confirmPrize">确认</view>
- </view>
- </view>
- </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,
- };
- },
- onLoad(options) {
- this.ticketId = options.id
- this.orderId = options.orderId
- this.getPrizeList()
- },
- methods: {
- getPrizeList() {
- uni.showLoading({
- title: '加载中'
- });
- let data = this.orderId ? { orderId: this.orderId } : { ticketId: this.ticketId }
- $http.post('/api/v1/mp/user/ticket/queryHitPrizeList', data).then(res => {
- uni.hideLoading();
- if (res.code == 0) {
- res.data.forEach(item => {
- item.picUrl = env.filePublic + item.picUrl
- })
- this.prizeList = res.data
- this.total = res.data.length
- }
- }).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]
- 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) {
- uni.$u.toast('兑换成功');
- setTimeout(() => {
- uni.switchTab({
- url: '/pages/index/index'
- })
- }, 500)
- }
- })
- }
- }
- })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .choice {
- width: 100%;
- min-height: calc(100vh - 50px);
- background: url(https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic3.zhimg.com%2F50%2Fv2-a6f5c8b5b66fe87e4e79c1fc82a61a36_hd.jpg&refer=http%3A%2F%2Fpic3.zhimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1649658373&t=f216ee4825d5b36e62aa3a490516bfb1) 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;
- margin-top: 60rpx;
- margin-bottom: 60rpx;
- &-item {
- width: 40%;
- height: 440rpx;
- margin-bottom: 40rpx;
- .confirm {
- height: 100%;
- background: none;
- box-shadow: none;
- border: none;
- }
- .action {
- height: 100%;
- background-color: #4cd964;
- box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4);
- border: 1px solid rgba(187, 187, 187, 54);
- }
- .null {
- height: 100%;
- background: #918b8d;
- box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4);
- border: 1px solid rgba(187, 187, 187, 54);
- }
- .info {
- width: 80%;
- height: 80%;
- background-color: #C0C0C0;
- }
- image {
- width: 100%;
- height: 60%;
- }
- .title {
- margin-top: 20rpx;
- color: #FFFFFF;
- text-align: center;
- }
- .tip {
- margin-top: 20rpx;
- color: red;
- text-align: center;
- }
- }
- }
- .btn {
- .confirm {
- width: 320rpx;
- height: 60rpx;
- line-height: 60rpx;
- border-radius: 8px;
- background-color: rgba(235, 112, 9, 100);
- color: rgba(255, 255, 255, 100);
- font-size: 28rpx;
- text-align: center;
- }
- }
- }
- </style>
|