mygift.vue 3.3 KB
<template>
	<view class="content">
		<view class="giftlist">
			<!-- v-for="(item,index) in giftarr" :key="index"    -->
			<view class="giftitem flextwo" v-for="(item,index) in giftarr" :key="index">
				<view class="giftitemleft">
					<view class="flexone" v-if="item.type==1">
						<view class="flexoneleft">
							<image :src="item.image" mode=""></image>
						</view>
						<view class="itemtop jiangname">{{item.name}}</view>
					</view>
					<view class="itemtop" v-else>{{item.name}}</view>

					<view class="itemtime">{{item.givetime}}</view>
				</view>
				<view class="itemname" v-if='item.is_give==2' @click="item.type==1?givegift(item):give(item)">立即兑换</view>
				<view class="itemnamek" v-if="item.is_give==1">已兑换</view>
			</view>
			<!-- <view class="giftitem flextwo">
				<view class="giftitemleft">
					<view class="itemtop">我的奖品</view>
					<view class="itemtime">2019-10-13 15:30:30</view>
				</view>
				<view class="itemnamek">立即兑换</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	import app from "../../App.vue";
	export default {
		data() {
			return {
				showbanben: false,
				giftarr: ''
			}
		},
		onLoad() {
			this.getgift()
		},
		methods: {
			getgift(item) {
				let that = this;
				var url = 'gift/my_gift';
				console.log('获取的参数', that.seldata)
				var params = {

				}
				console.log(params)
				app.post(url, params, "post").then((res) => {
					console.log(res);
					that.giftarr = res.data.data;
					// that.goodinfo=res.data.data;


				}).catch((err) => {
					console.log(err)
				})
			},
			// 领取积分优惠券
			give(item) {
				let that = this;
				console.log("领取优惠券")
				var url = 'gift/give';
				console.log('获取的参数', that.seldata)
				var params = {
					gift_log_id: item.id
				}
				console.log(params)
				app.post(url, params, "post").then((res) => {
					console.log(res);
					that.giftarr = res.data.data;
					// that.goodinfo=res.data.data;


				}).catch((err) => {
					console.log(err)
					uni.showToast({
						title:err.msg,
						icon:'none'
					})
				})
			},
			// 领取实物奖品
			givegift() {
				console.log("领取实物")
				let that = this;
				var url = 'gift/give';
				console.log('获取的参数', that.seldata)
				var params = {
					gift_log_id: item.id
				}
				console.log(params)
				app.post(url, params, "post").then((res) => {
					console.log(res);
					that.giftarr = res.data.data;
					// that.goodinfo=res.data.data;


				}).catch((err) => {})
			}


		}

	}
</script>

<style>
	.flexoneleft {
		width: 50rpx;
		height: 50rpx;
		font-size: 0;
	}

	.jiangname {
		margin-left: 10rpx;
	}

	.giftlist {
		padding: 0 32rpx;
		box-sizing: border-box;
	}

	.giftitem {
		padding: 24rpx 0;
		box-sizing: border-box;
		border-bottom: 1rpx solid #f5f5f5
	}

	.itemtop {
		color: #232323;
		font-size: 32rpx;
		font-weight: bold;

	}

	.itemtime {
		color: #BBC2CB;
		font-size: 24rpx;
		margin-top: 10rpx;
	}

	.itemname {
		width: 160rpx;
		height: 64rpx;
		border-radius: 8rpx;
		border: 2rpx solid rgba(255, 146, 24, 1);
		color: #FF9218;
		font-size: 30rpx;
		text-align: center;
		line-height: 64rpx;
	}

	.itemnamek {
		width: 160rpx;
		height: 64rpx;
		border-radius: 8rpx;
		color: #3F4444;
		border: 1rpx solid #3F4444;
		font-size: 30rpx;
		text-align: center;
		line-height: 64rpx;
	}
</style>