ADD file via upload

main
pjhmizn49 1 year ago
parent 98dd540ad8
commit d54a0ccd16

@ -0,0 +1,161 @@
<template>
<div>
<div v-if="this.user.user_role===1">
<div style="margin-top: 50px"><h3>您的积分{{this.user.member_point}}</h3></div>
<div>
<div class="gift-main">
<el-row>
<el-col :span="12" v-for="item in this.gifts">
<el-card style="margin: 15px 20px;color: #333" shadow="always">
<el-row>
<el-col :span="12">
<img :src="require('/Users/zhangjiadi/IdeaProjects/毕业设计/picFiles'+item.gift_pic)" style="height: 150px;width: 150px" alt="">
</el-col>
<el-col :span="12" style="text-align: left;font-weight: bold">
<div style="font-size: 18px;margin-bottom: 10px">{{ item.gift_name }}</div>
<div style="color: red;margin-bottom: 5px">积分{{ item.gift_point }}</div>
<div style="font-size: 14px;color: #8c8c8c;margin-bottom: 25px">库存{{ item.gift_stock }}</div>
<el-button @click="pay(item)" type="danger" size="small" style="font-weight: bold!important;">立即兑换</el-button>
</el-col>
</el-row>
</el-card>
</el-col>
</el-row>
</div>
<el-pagination
background
:current-page="currentPage"
:page-size="pageSize"
layout="total, prev, pager, next, jumper"
:total="total"
:page-count="page_number"
style="margin-top: 50px"
@current-change="handleCurrentChange">
</el-pagination>
</div>
</div>
<div v-if="this.user.user_role===0">
<h3 style="margin-top: 100px">抱歉您还不是本店的会员无法参与积分换赠活动</h3>
<el-button class="toMember" @click="navTo('/member')" type="danger">立即充值会员</el-button>
</div>
</div>
</template>
<script>
import Cookie from "js-cookie";
export default {
data(){
return{
user: {
user_id:1,
user_role:1,
member_point:1
},
gifts:[{
gift_id:1,
gift_name:'',
gift_point:1,
gift_stock:1,
gift_pic:''
}],
//
currentPage:1,
pageSize:4,
page_number:1,//
total:10,//
}
},
created() {
this.getByToken();
this.getGift();
},
methods:{
getByToken(){
const _this=this;
axios({
method: 'post',
url: 'http://localhost:8181/user/getByToken',
headers: {
Authorization: Cookie.get('token'),
'Content-Type': 'application/json'
}
}).then(function (response){
if (response.data.code===200) {
_this.user = response.data.data;
}
});
},
navTo(url){
location.href = url
},
getGift(){
const _this = this
try {
axios({
method: 'post',
url: 'http://localhost:8181/gift/list',
headers: {
Authorization: Cookie.get('token'),
'Content-Type': 'application/json'
},
data:{
page:_this.currentPage,
page_size:_this.pageSize,
}
}).then(function (response){
if (response.data.code===200){
_this.gifts=response.data.data.gifts;
_this.page_number=response.data.data.page_number;
_this.total=response.data.data.total;
}
if (response.data.code===401){
_this.$message.warning('身份验证失败,请重新登录!')
}
if (response.data.code===403){
const message = response.data.msg;
this.$alert("页面加载出错,具体原因如下:\n"+message, '页面加载失败', {
confirmButtonText: '确定'
})
}
});
}catch (error){
this.$message.warning('页面加载出错,请重试!')
}
},
pay(item){
if(this.user.member_point < item.gift_point)
this.$message.warning('会员积分不足!')
else{
let selectedData=[{}]
selectedData[0].gift_id=item.gift_id
selectedData[0].gift_name=item.gift_name
selectedData[0].gift_point=item.gift_point
selectedData[0].gift_pic=item.gift_pic
selectedData[0].number=1
// pay
this.$router.push({name: 'giftPay', params: {
data: selectedData,
type:1, //
total_price:item.gift_point
}})
}
},
//
handleCurrentChange(page) {
this.currentPage = page;
this.getGift();
},
}
}
</script>
<style>
.toMember{
margin-top: 80px!important;
width: 180px;
height: 60px;
font-size: 20px!important;
font-weight: bold!important;
}
</style>
Loading…
Cancel
Save