frontend_h5/treegitee/pages/my/prizes.vue

193 lines
5.3 KiB
Vue

<template>
<view class="" v-if="istrue">
<view v-if="list.length!=0">
<view v-for="(item,index) in list" :key="index" class="mt30 pos bgwhite ptb30 plr20">
<view class="abs f18 f-center"
style="color: #C0513D; width: 82rpx;height:38rpx;line-height:38rpx; background: #FCECEB;border-radius: 0rpx 20rpx;right: 0;top: 0;">
新获得
</view>
<view>
<view class="flex_between flex_items mt30 bbe9s pb20" style="width: calc(100% - 40rpx);">
<view class="flex_start flex_items">
<view style="width: 120rpx;height: 120rpx;boredr-radius:12rpx">
<image v-if="item.prize_type==1" :src="item.prize_data.icon"
style="width: 120rpx;height: 120rpx;boredr-radius:12rpx" mode=""></image>
<image v-if="item.prize_type==2" :src="item.prize_data.main_image"
style="width: 120rpx;height: 120rpx;boredr-radius:12rpx" mode=""></image>
</view>
<view class="ml30 flex_column" style="width:350rpx;">
<view class="f30 bold three">{{item.prize}}</view>
<text class="f30 mt30" style="color: #888;">{{item.win_time}}</text>
</view>
</view>
<view v-if="item.goodsExchangeRecord==null" class="flex_start flex_items mr20" style="color: #EB5E42;">
<view class="f24">¥</view>
<text class="f48 bolder one">{{item.winning_integral}}</text>
</view>
</view>
<view class="mt40 flex_between flex_items">
<text class="f28" style="color: #4d4d4d;">
{{item.active_name}}
</text>
<view v-if="item.goodsExchangeRecord" class="flex_start flex_items">
<view v-if="item.goodsExchangeRecord.state==1" @click="dui(item)" class="f24 f-center mr20"
style="width: 124rpx;line-height: 48rpx;border: 1px solid #e9e9e9; color: #a0a0a0; height: 48rpx;background: #fff;border-radius: 23rpx;">
兑换
</view>
<view v-if="item.goodsExchangeRecord.state==2" class="f24 f-center mr20"
style="width: 124rpx;line-height: 48rpx;border: 1px solid #e9e9e9; color: #a0a0a0; height: 48rpx;background: #fff;border-radius: 23rpx;">
兑换中
</view>
<view v-if="item.goodsExchangeRecord.state==3" class="f24 f-center mr20"
style="width: 124rpx;line-height: 48rpx;border: 1px solid #e9e9e9; color: #a0a0a0; height: 48rpx;background: #fff;border-radius: 23rpx;">
已兑换
</view>
<view @click="gomypre(item.prize_data.id)" class="f24 f-center"
style="width: 124rpx;line-height: 48rpx;color: #fff; height: 48rpx;background: linear-gradient(90deg, #EA5C41 0%, #EC7852 100%);border-radius: 23rpx;">
查看
</view>
</view>
</view>
</view>
</view>
</view>
<view v-else class="flex_center flex_items f24" style="color: #888;height:600rpx;width: 100%;">
<text>--暂无数据--</text>
</view>
<Ywatermark :info="'蓝色兄弟'"></Ywatermark>
</view>
</template>
<script>
export default {
data() {
return {
istrue: false,
imgUrl:"",
form: {
page: 1,
pageSize: 10,
activity_id: ""
},
list: [],
}
},
onLoad(options) {
this.form.activity_id = options.acid
this.imgUrl = this.api.imgUrl
},
onShow() {
this.getData()
},
methods: {
getData() {
uni.showLoading({
title: "加载中..."
})
this.api.getprizes(this.form).then((res) => {
console.log(res)
if (res.data.code == 200) {
uni.stopPullDownRefresh();
uni.hideLoading()
if (res.data.data.data.length == 0) {
uni.showToast({
title: "暂无数据",
icon: "none"
})
this.istrue = true
return false
}
this.istrue = true
for (let i = 0; i < res.data.data.data.length; i++) {
res.data.data.data[i].prize_data = JSON.parse(res.data.data.data[i].prize_data)
this.list.push(res.data.data.data[i])
}
} else {
this.istrue = true
uni.hideLoading()
uni.showToast({
icon: "none",
title: res.data.message
})
}
})
},
gomypre(idx) {
uni.navigateTo({
url: "/pages/product/detail?id=" + idx
})
},
dui(item) {
uni.navigateTo({
url: "/pages/redeem/index?item=" + JSON.stringify(item)
})
return false
uni.showLoading({
title: '兑换中...',
})
let that = this
that.api.getdui({
joinId: idx,
phone: uni.getStorageSync('phone')
}).then((res) => {
console.log(res)
if (res.data.code == 200) {
uni.showToast({
title: "兑换成功",
icon: "none",
duration: 1200
})
setTimeout(function() {
that.list = []
that.form.page = 1
that.getData()
}, 1200);
} else {
uni.hideLoading()
that.istrue = true
uni.showToast({
title: res.data.message,
icon: 'none'
})
}
})
}
},
onReachBottom() {
uni.showLoading({
title: "加载中..."
})
this.form.page += 1
this.getData()
},
onPullDownRefresh() {
this.form.page = 1
this.list = []
this.getData()
}
}
</script>
<style>
page {
background: #f5f5f5 !important;
}
.three {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.one {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
width: 150rpx;
}
</style>