397 lines
8.2 KiB
Vue
397 lines
8.2 KiB
Vue
<template>
|
||
<view class="Verification">
|
||
<image class="top-img" src="/static/imgs/hexiao_bg.png" mode="widthFix" />
|
||
<view class="txt">
|
||
<view class="title">扫描券码和权证 一键核销</view>
|
||
<view class="des">降低核销门槛 <span class='dian'>·</span>低成本留存优质客户</view>
|
||
</view>
|
||
<view class="btn">
|
||
<view class="goods" @click="scanCode('goods','get')"> 权证核销 </view>
|
||
<view class="coupons" @click="scanCode('coupons','get')"> 优惠券核销 </view>
|
||
</view>
|
||
<view class="history" @click="goHistory">核销记录</view>
|
||
<u-toast ref="uToast" />
|
||
|
||
<!-- 二维码展示动画效果 -->
|
||
<view class="showCode " v-if="showCode">
|
||
<view class="showCodeBg" @click="showCode = false"></view>
|
||
<view :class="['showCodeContent', showCode?'showCodeContentSelect':'showCodeContentSelectNo']">
|
||
<view class="showCodeTitle"> {{scanType === 'goods'?'确认核销该权证':'确认核销该优惠券'}}</view>
|
||
<view class="goodsInfo" v-if="scanType === 'goods'">
|
||
<image class="left" :src="info.goods.cover" mode="widthFix" />
|
||
<view class="right">
|
||
<view class="title ellipsis-2">{{info.goods.goods_name}}</view>
|
||
<view class="number">核销数量: X {{info.qty}}</view>
|
||
</view>
|
||
</view>
|
||
<view class="goodsInfo" v-else>
|
||
<view class="right">
|
||
<view class="title ellipsis-2">优惠券名称:‘ {{info.coupon.title}} ’</view>
|
||
<view class="number">
|
||
优惠券类型:{{info.coupon.type.text}}
|
||
<span style='padding-left: 20rpx;'>数量:1</span>
|
||
</view>
|
||
<view class="number">备注:{{info.coupon.remark}}</view>
|
||
|
||
</view>
|
||
</view>
|
||
<view class="sureVer" @click="scanInfo(code,'post',)">确认核销</view>
|
||
<view class="showCodeDes">请谨慎核销,操作成功后无法撤回</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import {
|
||
scanInfo
|
||
} from '@/apis/interfaces/scan'
|
||
export default {
|
||
data() {
|
||
return {
|
||
scanType: 'goods', // coupons 优惠券核销 goods 权证核销
|
||
showCode: false,
|
||
info: '', // 权证核销返回前置
|
||
code: '', // 扫码返回的code
|
||
};
|
||
},
|
||
onLoad() {
|
||
uni.hideLoading()
|
||
},
|
||
methods: {
|
||
scanCode(e) {
|
||
this.scanType = e
|
||
uni.scanCode({
|
||
success: (res) => {
|
||
// uni.showLoading({
|
||
// title: '核销请求中..'
|
||
// })
|
||
this.code = res.result
|
||
this.scanInfo(res.result, 'get')
|
||
}
|
||
});
|
||
},
|
||
// 请求核销前置,优惠券前置和权证前置(get) post 是核销
|
||
scanInfo(token, method) {
|
||
let apiUrl = ''
|
||
let data = {
|
||
code: token
|
||
}
|
||
if (this.scanType === 'goods') {
|
||
apiUrl = 'manages/warrants/verification'
|
||
} else {
|
||
apiUrl = 'coupons/verify/coupon'
|
||
}
|
||
scanInfo(apiUrl, data, method).then(res => {
|
||
if (this.scanType === 'goods') {
|
||
uni.hideLoading()
|
||
if (method === 'post') {
|
||
this.showCode = false
|
||
this.$refs.uToast.show({
|
||
title: '权证核销成功',
|
||
type: 'error',
|
||
icon: false,
|
||
duration: 3000
|
||
})
|
||
} else {
|
||
this.showCode = true
|
||
this.info = res
|
||
}
|
||
} else {
|
||
if (method === 'post') {
|
||
this.showCode = false
|
||
this.$refs.uToast.show({
|
||
title: '优惠券核销成功',
|
||
type: 'error',
|
||
icon: false,
|
||
duration: 3000
|
||
})
|
||
} else {
|
||
if (res.goods.length > 0) {
|
||
uni.showModal({
|
||
title: '温馨提示',
|
||
content: '该优惠券下绑定了商品,是否勾选相应商品',
|
||
success: (res1) => {
|
||
if (res1.confirm) {
|
||
uni.navigateTo({
|
||
url: '/pages/property/coupon/canUseList?code=' +
|
||
this.code
|
||
})
|
||
} else {
|
||
this.showCode = true
|
||
this.info = res.info
|
||
}
|
||
}
|
||
})
|
||
} else {
|
||
this.showCode = true
|
||
this.info = res.info
|
||
}
|
||
}
|
||
}
|
||
}).catch(err => {
|
||
this.$refs.uToast.show({
|
||
title: err.message,
|
||
type: 'error',
|
||
icon: false,
|
||
duration: 3000
|
||
})
|
||
this.showCode = false
|
||
})
|
||
},
|
||
// 核销记录
|
||
goHistory() {
|
||
this.$Router.push({
|
||
name:'verificationHistory'
|
||
})
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss">
|
||
.Verification {
|
||
width: 100%;
|
||
min-height: 100vh;
|
||
background-color: #fff;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
box-sizing: border-box;
|
||
|
||
.top-img {
|
||
margin-top: 100rpx;
|
||
width: 70vw;
|
||
}
|
||
|
||
.txt {
|
||
padding-top: 120rpx;
|
||
width: 100%;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
box-sizing: border-box;
|
||
|
||
.title {
|
||
font-size: $title-size + 5;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.des {
|
||
font-size: $title-size-m;
|
||
color: $text-gray-m;
|
||
padding-top: 20rpx;
|
||
font-weight: bold;
|
||
|
||
.dian {
|
||
color: $mian-color;
|
||
padding: 0 10rpx;
|
||
}
|
||
}
|
||
}
|
||
|
||
.btn {
|
||
margin-top: 140rpx;
|
||
display: flex;
|
||
width: 90vw;
|
||
.goods,
|
||
.coupons {
|
||
width: 50%;
|
||
margin: 0 $margin/2;
|
||
height: 90rpx;
|
||
line-height: 90rpx;
|
||
text-align: center;
|
||
border-radius: 8rpx;
|
||
border: solid 2rpx $mian-color;
|
||
color: $mian-color;
|
||
font-size: 34rpx;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.coupons {
|
||
background-color: $mian-color;
|
||
color: #fff;
|
||
margin-left: 30rpx;
|
||
}
|
||
}
|
||
|
||
.history {
|
||
text-align: center;
|
||
padding: ($padding * 2) $padding;
|
||
width: 100%;
|
||
color: $title-size-m;
|
||
}
|
||
}
|
||
|
||
// 动画效果
|
||
.showCode {
|
||
width: 100%;
|
||
height: 100vh;
|
||
position: fixed;
|
||
top: 0;
|
||
display: flex;
|
||
flex-direction: row;
|
||
align-items: center;
|
||
justify-content: center;
|
||
box-sizing: border-box;
|
||
z-index: 1;
|
||
|
||
.showCodeBg {
|
||
background-color: rgba($color:#000, $alpha: 0.3);
|
||
width: 100%;
|
||
height: 100%;
|
||
position: absolute;
|
||
top: 0;
|
||
left: 0;
|
||
z-index: 2;
|
||
}
|
||
|
||
.showCodeContentSelect {
|
||
animation: sk-foldCubeAngle .6s linear both;
|
||
}
|
||
|
||
.showCodeContentSelectNo {
|
||
animation: sk-foldCubeAngleNo .6s linear both;
|
||
}
|
||
|
||
.showCodeContent {
|
||
padding: 50rpx 30rpx 30rpx 30rpx;
|
||
width: 640rpx;
|
||
min-height: 500rpx;
|
||
background-color: #fff;
|
||
border-radius: 20rpx;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
box-sizing: border-box;
|
||
padding: 30rpx;
|
||
position: relative;
|
||
z-index: 199;
|
||
|
||
image {
|
||
width: 60%;
|
||
}
|
||
|
||
.showCodeTitle {
|
||
font-weight: bold;
|
||
padding-bottom: 20rpx;
|
||
font-size: 40rpx;
|
||
margin-bottom: 20rpx;
|
||
margin-top: 30rpx;
|
||
}
|
||
|
||
.goodsInfo {
|
||
display: flex;
|
||
flex-direction: row;
|
||
align-items: center;
|
||
justify-content: flex-start;
|
||
box-sizing: border-box;
|
||
margin: $margin;
|
||
|
||
// background-color:red;
|
||
.left {
|
||
width: 200rpx;
|
||
height: 200rpx;
|
||
margin-right: 20rpx;
|
||
border-radius: 2rpx;
|
||
}
|
||
|
||
.right {
|
||
flex: 1;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: flex-start;
|
||
justify-content: center;
|
||
box-sizing: border-box;
|
||
|
||
.title {
|
||
font-size: 30rpx;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.number {
|
||
padding-top: 10rpx;
|
||
color: #999;
|
||
}
|
||
}
|
||
}
|
||
|
||
.sureVer {
|
||
background-color: #039bfe;
|
||
width: 500rpx;
|
||
height: 90rpx;
|
||
border-radius: 8rpx;
|
||
color: #fff;
|
||
margin: 30rpx 0;
|
||
font-size: 40rpx;
|
||
font-weight: bold;
|
||
text-align: center;
|
||
line-height: 90rpx;
|
||
}
|
||
|
||
.showCodeDes {
|
||
padding: 20rpx 0 20rpx 0;
|
||
color: gray;
|
||
font-size: 24rpx;
|
||
}
|
||
}
|
||
|
||
@keyframes sk-foldCubeAngle {
|
||
0% {
|
||
-webkit-transform: perspective(140px) rotateX(-180deg);
|
||
transform: perspective(140px) rotateX(-180deg);
|
||
opacity: 0;
|
||
}
|
||
|
||
100% {
|
||
-webkit-transform: perspective(140px) rotateX(0deg);
|
||
transform: perspective(140px) rotateX(0deg);
|
||
opacity: 1;
|
||
}
|
||
}
|
||
|
||
@keyframes sk-foldCubeAngleNo {
|
||
0% {
|
||
transform: scale(1);
|
||
opacity: 1;
|
||
}
|
||
|
||
25% {
|
||
transform: scale(0);
|
||
opacity: 0;
|
||
}
|
||
}
|
||
|
||
@keyframes turn {
|
||
0% {
|
||
-webkit-transform: rotate(0deg);
|
||
opacity: 1;
|
||
}
|
||
|
||
25% {
|
||
-webkit-transform: rotate(90deg);
|
||
opacity: .9;
|
||
}
|
||
|
||
50% {
|
||
-webkit-transform: rotate(180deg);
|
||
opacity: .8;
|
||
}
|
||
|
||
75% {
|
||
-webkit-transform: rotate(270deg);
|
||
opacity: .9;
|
||
}
|
||
|
||
100% {
|
||
-webkit-transform: rotate(360deg);
|
||
opacity: 1;
|
||
}
|
||
}
|
||
|
||
}
|
||
</style>
|