Commit 18fb8bf1 authored by 杨硕's avatar 杨硕

优惠券核销

parent cdd920cf
...@@ -6,4 +6,12 @@ export function myCoupon(query) { ...@@ -6,4 +6,12 @@ export function myCoupon(query) {
method: 'get', method: 'get',
params: query params: query
}) })
}
// 获取二维码
export function getCouponCode(query) {
return request({
url: '/system/coupon/getTradeScan/',
method: 'get',
params: query
})
} }
\ No newline at end of file
import request from '@/utils/request'
// 核销优惠券列表
export function writeoffCoupon(query) {
return request({
url: '/system/coupon/selectUseCouponByPagination',
method: 'get',
params: query
})
}
// 核销订单列表
export function writeoffOrder(query) {
return request({
url: '/system/order/selectUseOrderByPagination',
method: 'get',
params: query
})
}
// 扫码核销优惠券
export function useCoupon(id) {
return request({
url: '/system/coupon/useCoupon/'+id,
method: 'get',
})
}
// 扫码核销订单
export function useOrder(id) {
return request({
url: '/system/order/useOrder/'+id,
method: 'get',
})
}
<template> <template>
<view class="myCoupon-module"> <view class="myCoupon-module">
<view v-for="item in couponList"> <view v-for="item in couponList">
<view class="use" v-if="item.status === 0"> <view class="use" v-if="item.status === 0">
<view class="price" v-if="item.type===0"><text style="margin-top: 20rpx;"></text><text style="font-size: 64rpx;">{{item.amount}}</text></view> <view class="price" v-if="item.type===0"><text style="margin-top: 20rpx;"></text><text style="font-size: 64rpx;">{{item.amount}}</text></view>
<view class="price" v-else-if="item.type===1"><text style="font-size: 64rpx;">{{item.discount}}</text><text style="margin-top: 20rpx;"></text></view> <view class="price" v-else-if="item.type===1"><text
<view class="coupon-right"> style="font-size: 64rpx;">{{item.discount}}</text><text style="margin-top: 20rpx;"></text>
<view class="message"> </view>
<view> <view class="coupon-right">
<view class="moduleprice">{{item.name}}</view> <view class="message">
<view class="time">{{dateFormat(item.useEndTime)}}前可用</view> <view>
<view class="moduleprice">{{item.name}}</view>
<view class="time">{{dateFormat(item.useEndTime)}}前可用</view>
</view>
</view>
<view class="usebutton" @click="gotoPage(item)">去使用</view>
</view> </view>
</view> </view>
<view class="usebutton" @click="gotoPage">去使用</view> <view class="all-write-off" v-if="item.status === 1">
<view class="write-off">
<view class="price" v-if="item.type===0"><text style="margin-top: 20rpx;"></text><text
style="font-size: 64rpx;">{{item.amount}}</text></view>
<view class="price" v-else-if="item.type===1"><text
style="font-size: 64rpx;">{{item.discount}}</text><text style="margin-top: 20rpx;"></text>
</view>
<view class="message">
<view>
<view class="moduleprice">{{item.name}}</view>
<view class="time">{{dateFormat(item.useEndTime)}}前可用</view>
</view>
</view>
<view class="usebutton">
<image class="write-off-image" :src="baseURL+'/static/my/wode_icon_yixiaohe@2x.png'">
</view>
</view>
<view class="write-off-detail">
<view class="write-off-time">
核销时间:{{item.cancelTime}}
</view>
<view class="write-off-bus">
核销商家:{{item.cancelName}}
</view>
</view>
</view> </view>
</view> <view class="expire" v-if="item.status === 2">
<view class="all-write-off" v-if="item.status === 1"> <view class="price" v-if="item.type===0"><text
<view class="write-off"> style="margin-top: 20rpx;"></text><text>{{item.amount}}</text></view>
<view class="price" v-if="item.type===0"><text style="margin-top: 20rpx;"></text><text style="font-size: 64rpx;">{{item.amount}}</text></view> <view class="price" v-else-if="item.type===1"><text
<view class="price" v-else-if="item.type===1"><text style="font-size: 64rpx;">{{item.discount}}</text><text style="margin-top: 20rpx;"></text></view> style="font-size: 64rpx;">{{item.discount}}</text><text style="margin-top: 20rpx;"></text>
</view>
<view class="message"> <view class="message">
<view> <view>
<view class="moduleprice">{{item.name}}</view> <view class="moduleprice">{{item.name}}</view>
...@@ -25,68 +55,61 @@ ...@@ -25,68 +55,61 @@
</view> </view>
</view> </view>
<view class="usebutton"> <view class="usebutton">
<image class="write-off-image" :src="baseURL+'/static/my/wode_icon_yixiaohe@2x.png'"> <image class="write-off-image" :src="baseURL+'/static/my/wode_icon_yiguoqi@2x.png'">
</view>
</view>
<view class="write-off-detail">
<view class="write-off-time">
核销时间:{{item.cancelTime}}
</view>
<view class="write-off-bus">
核销商家:{{item.cancelName}}
</view> </view>
</view> </view>
</view> </view>
<view class="expire" v-if="item.status === 2"> <u-popup :show="codeshow" mode="center" @close="codeshow = false">
<view class="price" v-if="item.type===0"><text style="margin-top: 20rpx;"></text><text>{{item.amount}}</text></view> <view class="qrCode-view">
<view class="price" v-else-if="item.type===1"><text style="font-size: 64rpx;">{{item.discount}}</text><text style="margin-top: 20rpx;"></text></view> <image :src="qrCode" class="qrCode-image">
<view class="message">
<view>
<view class="moduleprice">{{item.name}}</view>
<view class="time">{{dateFormat(item.useEndTime)}}前可用</view>
</view>
</view> </view>
<view class="usebutton"> </u-popup>
<image class="write-off-image" :src="baseURL+'/static/my/wode_icon_yiguoqi@2x.png'">
</view>
</view>
</view>
</view> </view>
</template> </template>
<script> <script>
import {myCoupon} from "../../api/my/myCoupon/index.js" import {
myCoupon,
getCouponCode
} from "../../api/my/myCoupon/index.js"
export default { export default {
name: "index", name: "index",
data(){ data() {
return{ return {
baseURL: 'http://192.144.239.97:20043/file/', baseURL: 'http://192.144.239.97:20043/file/',
couponList:[], couponList: [],
pageNum: 1, pageNum: 1,
pageSize:10, pageSize: 10,
total: 0 total: 0,
codeshow: false,
qrCode: ''
} }
}, },
onLoad() { onLoad() {
this.getmyCoupon() this.getmyCoupon()
}, },
methods:{ methods: {
// 查询我的优惠券 // 查询我的优惠券
getmyCoupon(){ getmyCoupon() {
const query={ const query = {
pageNum: this.pageNum, pageNum: this.pageNum,
pageSize:this.pageSize pageSize: this.pageSize
} }
myCoupon(query).then(res=>{ myCoupon(query).then(res => {
console.log("我的优惠券",res) console.log("我的优惠券", res)
this.couponList=res.rows this.couponList = res.rows
this.total=res.total this.total = res.total
}) })
}, },
gotoPage(){ gotoPage(val) {
// uni.switchTab({ this.codeshow = true
// url:'/pages/activity/index' const query = {
// }) id: val.businessId
}
getCouponCode(query).then(res => {
console.log("二维码数据", res)
this.qrCode = "data:image/png;base64," + res.data
})
}, },
// 日期格式化 // 日期格式化
dateFormat(time) { dateFormat(time) {
...@@ -111,12 +134,14 @@ ...@@ -111,12 +134,14 @@
background-color: #fff; background-color: #fff;
min-height: 100vh; min-height: 100vh;
padding: 44rpx 34rpx 0 34rpx; padding: 44rpx 34rpx 0 34rpx;
.coupon-right{
.coupon-right {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
width: calc(100% - 180rpx); width: calc(100% - 180rpx);
padding: 0 34rpx 0 26rpx; padding: 0 34rpx 0 26rpx;
} }
.use { .use {
width: 100%; width: 100%;
border-radius: 12px; border-radius: 12px;
...@@ -125,6 +150,7 @@ ...@@ -125,6 +150,7 @@
background-size: 100% 100%; background-size: 100% 100%;
display: flex; display: flex;
margin: 42rpx 0; margin: 42rpx 0;
.price { .price {
width: 180rpx; width: 180rpx;
height: 100%; height: 100%;
...@@ -145,7 +171,7 @@ ...@@ -145,7 +171,7 @@
margin: 34rpx 0 34rpx 0; margin: 34rpx 0 34rpx 0;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
.moduleprice { .moduleprice {
font-size: 38rpx; font-size: 38rpx;
font-family: Source Han Sans CN-Medium, Source Han Sans CN; font-family: Source Han Sans CN-Medium, Source Han Sans CN;
...@@ -176,6 +202,7 @@ ...@@ -176,6 +202,7 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
margin-top: 82rpx; margin-top: 82rpx;
// margin-bottom: 40rpx;
line-height: 32rpx; line-height: 32rpx;
} }
} }
...@@ -184,7 +211,7 @@ ...@@ -184,7 +211,7 @@
background: #FFFFFF; background: #FFFFFF;
border-radius: 14px 14px 14px 14px; border-radius: 14px 14px 14px 14px;
border: 1px solid #F5F5F5; border: 1px solid #F5F5F5;
margin-bottom: 40rpx;
.write-off { .write-off {
border-radius: 12px; border-radius: 12px;
height: 222rpx; height: 222rpx;
...@@ -274,6 +301,7 @@ ...@@ -274,6 +301,7 @@
display: flex; display: flex;
margin: 42rpx 0; margin: 42rpx 0;
position: relative; position: relative;
.price { .price {
width: 90px; width: 90px;
height: 100%; height: 100%;
...@@ -316,6 +344,7 @@ ...@@ -316,6 +344,7 @@
position: absolute; position: absolute;
top: 6rpx; top: 6rpx;
right: 22rpx; right: 22rpx;
.write-off-image { .write-off-image {
width: 108rpx; width: 108rpx;
height: 108rpx; height: 108rpx;
...@@ -323,5 +352,19 @@ ...@@ -323,5 +352,19 @@
} }
} }
} }
.qrCode-view {
width: 60vw;
height: 60vw;
// display: flex;
// justify-content: center;
// align-items: center;
// border-radius: 12px;
.qrCode-image {
width: 100%;
height: 100%;
}
}
} }
</style> </style>
\ No newline at end of file
<template>
<view class="wirteoff">
<u-sticky bgColor="#fff">
<u-tabs :list="list1" @click="click" lineColor="#D84848"
activeStyle="font-size: 38rpx;font-weight: bold;color: #D84848;width: calc(50vw - 34rpx);text-align: center;"
inactiveStyle="font-size: 19px;font-weight: bold;color: #222222;width: calc(50vw - 34rpx);text-align: center;"
lineWidth="42" lineHeight="6" itemStyle=" height: 64px;width:50vw;"></u-tabs>
</u-sticky>
<!-- 已核销的优惠券 -->
<view v-if="tabshow===0">
<view class="expire" v-for="item in writeoffCouponList">
<view class="price" v-if="item.type===0"><text
style="margin-top: 20rpx;"></text><text>{{item.amount}}</text></view>
<view class="price" v-else-if="item.type===1"><text
style="font-size: 64rpx;">{{item.discount}}</text><text style="margin-top: 20rpx;"></text>
</view>
<view class="message">
<view>
<view class="moduleprice">{{item.name}}</view>
<view class="time">核销时间:{{dateFormat(item.cancelTime)}}</view>
</view>
</view>
</view>
</view>
<!-- 已核销的订单 -->
<view v-if="tabshow===1">
<view class="myapplication-list" v-for="item in writeoffOrderList">
<view class="image">
<image class="myapplication-image" :src="baseURL + item.imgUrl" />
<!-- <image class="left-image" src="../../../static/images/message/wode_icon_longhui@2x.png"> -->
</view>
<view class="myapplication-title">
<view class="application-title">{{item.activityName}}</view>
<!-- <view class="application-message">活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容</view> -->
<view class="application-time">
<u-icon name="clock" size="28"></u-icon>
<view style="margin-left: 14rpx;">{{item.activityBeginDate}}</view></view>
<view class="application-address">
<u-icon name="map" color="#D84848" size="28"></u-icon>
<view style="margin-left: 14rpx;">{{item.address}}</view>
</view>
</view>
</view>
</view>
<!-- 悬浮按钮 -->
<view class="suspension-view" @click="ScanCode">
<image :src="baseURL+'/static/business/shangjia_icon_daohang@2x.png'" class="suspension">
</view>
<view class="nomore">~ 没有更多啦 ~</view>
</view>
</template>
<script>
import {writeoffOrder,writeoffCoupon,useCoupon,useOrder} from '../../api/my/writeoff/index.js'
export default {
data() {
return {
baseURL: 'http://192.144.239.97:20043/file/',
list1: [{
name: '优惠券',
}, {
name: '订单',
}],
myOrderList: [],
query: {
page: 1,
rows: 10
},
total: 0, // 订单总条数
tabshow: 0,
show: false,
show1: false,
orderdeatil: {},
allListItem: false, // 是否还有更多数据
writeoffCouponList:[], // 优惠券核销
writeoffOrderList:[] // 订单核销
}
},
onShow() {
this.getWriteoffCoupon()
},
// 触底加载
onReachBottom() {
console.log("触底加载")
// 触底的时候请求数据,即为上拉加载更多
var allTotal = this.query.page * this.query.rows
//this.page为加载次数,this.pageSize为每一次加载的数据条数
if (allTotal < this.total) {
//this.total为请求数据的总条数。只要现有条数小于总条数就就执行一下代码
this.allListItem = false;
this.query.page++;
//加载次数递加
this.getMoreorder() //请求更多数据列表
} else {
this.allListItem = true;
console.log('已加载全部数据')
}
},
methods: {
// tab点击事件
click(item) {
console.log('item', item);
this.tabshow = item.index
if (this.tabshow === 0) {
this.getWriteoffCoupon()
} else if (this.tabshow === 1) {
this.getWriteoffOrder()
}
},
// 获取核销优惠券列表
getWriteoffCoupon() {
writeoffCoupon(this.query).then(res => {
console.log("核销优惠券", res)
this.writeoffCouponList=res.rows
})
},
// 获取核销订单列表
getWriteoffOrder(){
writeoffOrder(this.query).then(res => {
console.log("核销订单", res)
this.writeoffOrderList=res.rows
})
},
// 获取更多数据
getMoreorder() {
// myOrder(this.query).then(res => {
// console.log("我的订单", res)
// res.rows.forEach(item => {
// this.myOrderList.push(item)
// })
// // this.total = res.total
// })
},
// 扫码
ScanCode(){
const result = this.tabshow
uni.scanCode({
scanType:['qrCode'],
success: function(res) {
console.log('111', res)
if(res.errMsg == "scanCode:ok"){
console.log("扫码成功",result)
if(result===0){
console.log("优惠券扫码")
useCoupon(res.result).then(res=>{
console.log("优惠券扫码核销",res)
})
}else if(result===1){
console.log("订单扫码")
useOrder(res.result).then(res=>{
console.log("订单扫码核销",res)
})
}
}
}
})
},
// 日期格式化
dateFormat(time) {
let date = new Date(time);
let year = date.getFullYear();
// 在日期格式中,月份是从0开始的,因此要加0,使用三元表达式在小于10的前面加0,以达到格式统一 如 09:11:05
let month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
let hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
let minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
let seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
// 拼接
// return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
return year + "-" + month + "-" + day + " " + hours + ":" + minutes ;
}
}
}
</script>
<style lang="scss" scoped>
.wirteoff {
padding-bottom: 40rpx;
background-color: #FFFFFF;
min-height: 100vh;
padding: 0 34rpx;
/deep/.u-tabs__wrapper__nav__line {
left: 12rpx;
}
.expire {
border-radius: 12px;
height: 222rpx;
background: url('../../static/my/wode_pic_youhuiquan@2x(1).png') no-repeat;
background-size: 100% 100%;
display: flex;
margin: 42rpx 0;
position: relative;
.price {
width: 90px;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
font-family: Source Han Sans CN-Bold, Source Han Sans CN;
font-weight: bold;
font-size: 32rpx;
color: #FFFFFF;
// text {
// font-size: 64rpx;
// }
}
.message {
margin: 34rpx 0 34rpx 26rpx;
display: flex;
justify-content: space-between;
.moduleprice {
font-size: 38rpx;
font-family: Source Han Sans CN-Medium, Source Han Sans CN;
font-weight: 500;
color: #222222;
white-space: nowrap;
margin-bottom: 70rpx;
}
.time {
font-size: 32rpx;
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
font-weight: 400;
color: #666666;
}
}
.usebutton {
position: absolute;
top: 6rpx;
right: 22rpx;
.write-off-image {
width: 108rpx;
height: 108rpx;
}
}
}
}
.nomore {
text-align: center;
padding: 42rpx 0;
font-size: 13px;
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
font-weight: 400;
color: #B9B9B9;
}
.myapplication-list{
padding: 30rpx 0;
margin: 0 34rpx 0 42rpx;
display: flex;
justify-content: space-between;
height: 260rpx;
align-items: center;
border-bottom: 1px solid #F1F1F1;
.image{
position: relative;
.left-image{
width: 96rpx;
height: 96rpx;
position: absolute;
left: 0;
}
}
.myapplication-image{
width: 220rpx;
height: 166rpx;
border-radius: 12px 12px 12px 12px;
}
.myapplication-title{
width: calc(100vw - 220rpx - 34rpx - 34rpx - 42rpx);
.application-title{
font-size: 32rpx;
font-family: Source Han Sans CN-Medium, Source Han Sans CN;
font-weight: 500;
color: #222222;
margin-bottom: 34rpx;
line-height: 32rpx;
}
.application-message{
font-size: 28rpx;
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
font-weight: 400;
color: #666666;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-bottom: 26rpx;
line-height: 28rpx;
}
.application-time{
font-size: 28rpx;
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
font-weight: 400;
color: #666666;
margin-bottom: 24rpx;
line-height: 28rpx;
display: flex;
}
.application-address{
font-size: 28rpx;
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
font-weight: 400;
color: #DF6969;
line-height: 28rpx;
display: flex;
}
}
}
.suspension-view {
position: fixed;
bottom: 32%;
right: 34rpx;
}
.suspension {
width: 160rpx;
height: 160rpx;
box-shadow: 0px 0px 15px 1px rgba(0, 0, 0, 0.18);
border-radius: 50px;
}
</style>
\ No newline at end of file
...@@ -105,6 +105,12 @@ ...@@ -105,6 +105,12 @@
"style": { "style": {
"navigationBarTitleText": "消息详情" "navigationBarTitleText": "消息详情"
} }
},
{
"path": "writeoff/index",
"style": {
"navigationBarTitleText": "核销"
}
} }
] ]
}, },
......
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
<image class="rightimage" :src="baseURL+'/static/my/wode_icon_jiantou@2x.png'"> <image class="rightimage" :src="baseURL+'/static/my/wode_icon_jiantou@2x.png'">
</view> </view>
</view> </view>
<view class="list-trim" @click="gotopage('/releaseactivity/index')" v-if="memberInfo.memberType > 0"> <view class="list-trim" @click="gotopage('/my/writeoff/index')" v-if="memberInfo.memberType > 0">
<view class="left"> <view class="left">
<image class="leftimage" :src="baseURL+'/static/my/wode_icon_tousu@2x.png'"> <image class="leftimage" :src="baseURL+'/static/my/wode_icon_tousu@2x.png'">
<view class="trim-title">核销</view> <view class="trim-title">核销</view>
...@@ -119,7 +119,9 @@ export default { ...@@ -119,7 +119,9 @@ export default {
this.userInfo=JSON.parse(uni.getStorageSync('userInfo')) this.userInfo=JSON.parse(uni.getStorageSync('userInfo'))
console.log('this.userInfo',this.userInfo) console.log('this.userInfo',this.userInfo)
this.getMyIntegral() this.getMyIntegral()
this.getUserInfo() },
onShow() {
this.getUserInfo()
}, },
methods: { methods: {
/** 跳转我的优惠券*/ /** 跳转我的优惠券*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment