hengmei-two/pagesA/coupon/coupon.vue

212 lines
7.4 KiB
Vue
Raw Normal View History

2021-10-22 03:07:32 +00:00
<template>
2022-06-07 02:24:54 +00:00
<view class="pad-x180">
2021-10-22 03:07:32 +00:00
<!-- 状态栏 -->
<status-nav :titleVal="'优惠券'" :statusTitle="true"></status-nav>
<view id="daoh" class="bacf pad-zy40 pad-sx20 isTopf fon28 col3 disjbac" :style="{top:statusHeight+'px'}">
2021-10-22 03:07:32 +00:00
<view @tap="chooseNav(indexn)" :class="isStatus==indexn?'isWen bold':''" class="posir" v-for="(itemn,indexn) in navList" :key="indexn">{{itemn}}</view>
</view>
<!-- 列表 -->
<view :style="{paddingTop: (statusHeight+chuTop+15)+'px'}" class="pad-zy32">
2021-10-22 03:07:32 +00:00
<view class="pad-x30">
2021-11-02 10:23:53 +00:00
<view v-if="dataList.length!=0" class="mar-x20 animated fadeInLeft" v-for="(item,index) in dataList" :key="index">
2021-10-22 03:07:32 +00:00
<view style="height: 200rpx;" class="disjbac posir">
2021-11-02 10:23:53 +00:00
<view class="disjcac fc recerve-left" style="width: 218rpx;height: 200rpx;flex-shrink: 0;text-align: center;color: #FFFFFF;">
2021-10-22 03:07:32 +00:00
<image v-if="item.statusNum!=0 && item.statusNum!=2" class="posia quan-img" src="/static/public/quan-left-two.png" mode=""></image>
<image v-else class="posia quan-img" src="/static/public/quan-left.png" mode=""></image>
<view class="posir disjcac fc" style="z-index: 1;">
2022-06-08 05:59:00 +00:00
<view class="fon28 mar-s20 mar-x36"><span class="bold" style="font-size: 56rpx;">{{item.num}}</span><span v-if="item.unit">{{item.unit}}</span></view>
2021-10-22 03:07:32 +00:00
<view v-if="item.statusNum==0 || item.statusNum==2" @tap="useEv(index)" class="fon24 quan-btn">{{item.statusNum==2?'':'使'}}</view>
</view>
</view>
<view class="quan-right-box">
<view class="fon28 col3 mar-s20">{{item.title}}</view>
<view class="fon24 col80">{{item.manPrice}}元可使用</view>
<view class="fon20 col80 mar-x20">有效期{{item.startTime}}{{item.endTime}}</view>
</view>
<image v-if="item.statusNum==1" class="posia quan-use" src="/static/public/quan-use.png" mode=""></image>
<image v-if="item.statusNum==3" class="posia quan-use" src="/static/public/quan-over.png" mode=""></image>
</view>
</view>
<block v-if="loading">
<nothing-page v-if="dataList.length==0" :content="['暂无可使用优惠券','暂无已使用优惠券','暂无可领取优惠券','暂无已过期优惠券'][isStatus]"></nothing-page>
</block>
</view>
</view>
<!-- 体验券使用弹框 -->
2021-11-11 07:33:17 +00:00
<view v-if="isTY" @tap="isTY=false" class="disjcac tc quan-tk-box" catchtouchmove="return">
2021-10-22 03:07:32 +00:00
<view class="bacf width100 radius20 pad30 posir" style="margin: 0 128rpx;" @tap.stop="isTY=true">
<view class="fon28 col3">体验券使用</view>
<view class="mar-sx30">
2021-11-08 07:50:30 +00:00
<!-- <image :src="tyImg" class="quan-tk-em" style="width: 325rpx;height: 325rpx;" mode="aspectFill"></image> -->
2022-03-04 08:48:40 +00:00
<yz-qr ref="qrPath" :text="text" :size="sizeq" :colorDark="colorDark" :colorLight="colorLight"></yz-qr>
2021-10-22 03:07:32 +00:00
</view>
<view class="fon24 col3 mar-s40 mar-x20">工作人员扫码使用体验券</view>
2021-11-10 11:23:11 +00:00
<image @tap.stop="closeQuanEv" src="/static/public/closequan.png" class="posia quan-tk-btn" mode=""></image>
2021-10-22 03:07:32 +00:00
</view>
</view>
2022-03-04 08:48:40 +00:00
<!-- 用户信息授权手机号授权 -->
<auth-userInfo-mobileInfo></auth-userInfo-mobileInfo>
<!-- 底部导航 -->
<view class="posixzy">
<bottom-tab></bottom-tab>
</view>
2021-10-22 03:07:32 +00:00
</view>
</template>
<script>
2021-11-08 07:50:30 +00:00
import yzQr from '@/components/yz-qr/yz-qr.vue';
import bottomTab from '@/components/bottom-tab.vue';
2021-10-22 03:07:32 +00:00
export default {
2021-11-08 07:50:30 +00:00
components:{
yzQr,
bottomTab,
2021-11-08 07:50:30 +00:00
},
2021-10-22 03:07:32 +00:00
data() {
return {
chuTop:'',
navList:['未使用','已使用','可领取','已过期'],
isStatus:0,
dataList:[],
zcList:[],
isTY:false,
page:1,
size:10,
quanStatus:'normal',//优惠券状态
loading:false,
2021-11-08 07:50:30 +00:00
tyImg:'',//立即使用体验券时弹框中的img
canvasQrPath: '',
text: 'hello',
2022-03-04 08:48:40 +00:00
sizeq: 162,
2021-11-08 07:50:30 +00:00
colorDark: '#000000',
colorLight: '#ffffff',
timer:null,
secret:''
2021-10-22 03:07:32 +00:00
}
},
computed:{
statusHeight() {
return this.$store.state.statusHeight
}
},
2021-10-22 03:07:32 +00:00
onLoad() {
const query = wx.createSelectorQuery()
query.select('#daoh').boundingClientRect((rect) => {
// console.log('状态栏+标题栏:',rect);
this.chuTop = rect.height;
}).exec()
2022-03-21 01:44:07 +00:00
if(uni.getStorageSync('phone_active')!=0 && uni.getStorageSync('is_active')!=0){
2022-03-04 08:48:40 +00:00
this.checkAllList(0);
}
2021-10-22 03:07:32 +00:00
},
2021-11-11 02:50:50 +00:00
onUnload() {
this.closeQuanEv();
},
2021-10-22 03:07:32 +00:00
methods: {
checkAllList(index){//查询所有优惠券列表
let params = {
status: this.quanStatus,//留空默获取全部 normal=正常(未使用) used=已使用 invalid=已失效 waiting=待领取
page:this.page,
size:this.size
}
this.$requst.post('user/get-coupon-list',params).then(res=>{
if(res.code==0){
this.dataList = [];
2021-11-02 10:23:53 +00:00
this.zcList = [];
2021-10-22 03:07:32 +00:00
if(res.data.length!=0){
res.data.forEach(item=>{
let leix = false;
if(item.type=='taste') leix = true;
let obj = {
id:item.id,
2021-11-02 10:23:53 +00:00
num:item.amount/100,
2021-10-22 03:07:32 +00:00
title:item.name,
cover:this.$http + item.cover,
2021-11-02 10:23:53 +00:00
manPrice:item.condition/100,
startTime:item.begin_at.slice(0,10),
endTime:item.end_at.slice(0,10),
2021-10-22 03:07:32 +00:00
isTiyan:leix,
isZhek:false,
2022-06-07 02:24:54 +00:00
statusNum:index,
2022-06-08 05:59:00 +00:00
type:item.type,
unit:item.unit
2021-10-22 03:07:32 +00:00
}
2021-11-02 10:23:53 +00:00
this.dataList.push(obj);//渲染的列表
this.zcList.push(obj);//暂存的列表
2021-10-22 03:07:32 +00:00
})
this.checkList(index);
}
this.loading = true;
}
})
},
chooseNav(index){
this.isStatus = index;
if(index==0) this.quanStatus = 'normal';//未使用
if(index==1) this.quanStatus = 'used';//已使用
if(index==2) this.quanStatus = 'waiting';//待领取
if(index==3) this.quanStatus = 'invalid';//已过期
this.loading = false;
this.checkAllList(index);
},
checkList(index){
this.dataList = this.zcList.filter(item=>item.statusNum==index);
},
useEv(index){
if(this.dataList[index].statusNum==2) {
this.$requst.post('user/get-coupon',{coupon_id:this.dataList[index].id}).then(res=>{
if(res.code==0){
this.$toolAll.tools.showToast('领取成功');
this.checkAllList(this.isStatus);
} else {
this.$toolAll.tools.showToast(res.msg);
}
})
}
2021-12-20 08:02:27 +00:00
if(this.dataList[index].isTiyan==false && this.dataList[index].statusNum==0) {
uni.navigateTo({url:'/pages/tabbar/shop/shop'})
}
2021-11-08 07:50:30 +00:00
if(this.dataList[index].isTiyan==true && this.dataList[index].statusNum==0){
this.tyImg = this.dataList[index].cover;
this.$requst.post('user/exhibition-experience-coupon',{coupon_id:this.dataList[index].id}).then(res=>{
if(res.code==0){
this.isTY = true;
2022-01-24 05:53:00 +00:00
this.text = `${this.dataList[index].id}HtrueH${res.data.secret}H${uni.getStorageSync('userId')}`;
2021-11-08 07:50:30 +00:00
this.secret = res.data.secret;
} else this.$toolAll.tools.showToast(res.msg);
},error=>{})
this.timer = setInterval(()=>{
this.$requst.post('staff/coupon/write-off-experience-couponQuery',{coupon_id:this.dataList[index].id,secret:this.secret}).then(res=>{
if(res.code==0){
2022-01-24 05:53:00 +00:00
// if(res.data.result==0){
2021-11-11 02:50:50 +00:00
this.$toolAll.tools.showToast('使用成功');
this.isTY = false;
clearInterval(this.timer);
this.checkAllList(0);
2022-01-24 05:53:00 +00:00
// }
2021-11-10 11:23:11 +00:00
}
2021-11-08 07:50:30 +00:00
})
},3000)
}
2021-12-20 08:02:27 +00:00
2021-11-10 11:23:11 +00:00
},
closeQuanEv(){
this.isTY = false;
clearInterval(this.timer);
2021-10-22 03:07:32 +00:00
}
}
}
</script>
<style>
.isWen{color: #3875F6;}
.isWen::after{
content: '';
display: block;
height: 8rpx;
width: 100%;
position: absolute;
bottom: -20rpx;
background: #3875F6;
}
</style>