|
@@ -0,0 +1,197 @@
|
|
|
+<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.getPrizeList()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getPrizeList() {
|
|
|
+ uni.showLoading({
|
|
|
+ title: '加载中'
|
|
|
+ });
|
|
|
+ $http.post('/api/v1/mp/user/ticket/queryHitPrizeList', {
|
|
|
+ ticketId: this.ticketId
|
|
|
+ }).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
|
|
|
+ console.log(this.total);
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ uni.hideLoading();
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ selectPrize(item, index) {
|
|
|
+ if (item.remainQty == 0) {
|
|
|
+ uni.$u.toast('该奖品已兑完!');
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.actionIndex = index
|
|
|
+ console.log(item, index);
|
|
|
+ },
|
|
|
+
|
|
|
+ confirmPrize() {
|
|
|
+ let _this = this
|
|
|
+ let item = _this.prizeList[_this.actionIndex]
|
|
|
+ console.log(item);
|
|
|
+ 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>
|