Commit d10ddffd authored by jiangjiantao's avatar jiangjiantao

优惠券功能

parent e33bedc8
......@@ -52,6 +52,9 @@ export const ACTION_REFUND_FAILED = "ACTION_REFUND_FAILED";
//打印上一单
export const ACTION_PRINT_LAST_ORDER = "ACTION_PRINT_LAST_ORDER";
//使用优惠券
export const ACTION_USE_COUPON = "ACTION_USE_COUPON";
const FLOW_IDLE = "idle";
const FLOW_COLLECTIONS = "collections";
const FLOW_REFUND = "refund";
......
.login-waiting-page{
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
position: absolute
.login-waiting-page {
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
position: absolute
}
.login-waiting-left{
width: 50%;
height: 100%;
.login-waiting-left {
width: 50%;
height: 100%;
}
.login-waiting-right{
width: 50%;
height: 100%;
background-color: white;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center
.login-waiting-right {
width: 50%;
height: 100%;
background-color: white;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center
}
.login-waiting-right-image{
width: 287rpx;
height: 204rpx;
.login-waiting-right-image {
width: 287rpx;
height: 204rpx;
}
/* home样式 */
......@@ -360,9 +360,28 @@
font-family: AlibabaPuHuiTiB;
color: rgba(0, 122, 255, 1);
line-height: 49px;
/* margin-left: 15rpx; */
}
/* 价格容器 */
.total-price-container {
display: flex;
flex-direction: row;
margin-left: 15rpx;
}
/* 优惠券抵扣金额 */
.pay-coupon {
font-size: 18rpx;
font-family: DINAlternate-Bold, DINAlternate;
font-weight: bold;
color: rgba(249, 97, 70, 1);
line-height: 18rpx;
margin-left: 5rpx;
}
/* 去付款 */
.go-pay {
......@@ -573,6 +592,7 @@
width: 252rpx;
height: 60rpx;
}
/* 确定 兑换成功 */
.sure-use-coupon {
......@@ -714,6 +734,7 @@
}
/* 兑换券成功文本 */
.scan-coupon-text-success {
font-size: 26rpx;
font-family: PingFangSC-Medium, PingFang SC;
......@@ -724,17 +745,18 @@
}
/* 兑换券失败文本 */
.scan-coupon-text-fail {
font-size: 26rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color:rgba(255,0,0,1);
color: rgba(255, 0, 0, 1);
line-height: 26rpx;
margin-top: 24rpx;
}
/* 兑换券失败容器*/
.failure-operation {
width: 100%;
height: 62rpx;
......@@ -745,129 +767,133 @@
}
/* 兑换券 关闭 */
.close-use-coupon{
width:252rpx;
height:60rpx;
margin-right: 18rpx;
.close-use-coupon {
width: 252rpx;
height: 60rpx;
margin-right: 18rpx;
}
/* 兑换券 再次兑换 */
.again-use-coupon{
width:252rpx;
height:60rpx;
margin-left: 18rpx;
.again-use-coupon {
width: 252rpx;
height: 60rpx;
margin-left: 18rpx;
}
/* 兑换券失败描述 */
.scan-coupon-text-fail-desr{
font-size:22rpx;
font-family:PingFangSC-Regular,PingFang SC;
font-weight:400;
color:rgba(91,105,129,1);
line-height:22rpx;
margin-top: 15rpx
/* 兑换券失败描述 */
.scan-coupon-text-fail-desr {
font-size: 22rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: rgba(91, 105, 129, 1);
line-height: 22rpx;
margin-top: 15rpx
}
/* 操作结果页面 */
.operateTopView{
position: relative;
width: 750rpx;
height: 60rpx;
background: rgba(255, 255, 255, 1);
/* border: 2px solid red; */
box-shadow: 0rpx 2rpx 7rpx 0rpx rgba(153, 153, 153, 0.16);
}
.operateBodyView{
position: relative;
display: flex;
flex-direction: column;
align-items: center;
width: 750rpx;
height: 364rpx;
background: #ffffff;
}
.operateResultIcon{
position: relative;
width: 84rpx;
height: 84rpx;
margin-top: 35rpx;
}
.operateResultText{
font-size:26rpx;
font-family:PingFangSC-Medium,PingFang SC;
font-weight:500;
color:rgba(0,122,255,1);
line-height:26rpx;
margin-top: 23rpx;
}
.operateResultDesc{
font-size:21rpx;
font-family:PingFangSC-Regular,PingFang SC;
font-weight:400;
color:rgba(91,105,129,1);
line-height:21rpx;
margin-top: 19rpx;
}
.operateResultBtnContainer{
width: auto;
height: auto;
display: flex;
flex-direction: row;
margin-top: 54rpx;
}
.operateResultConfirmBtn{
width:246rpx;
height:59rpx;
background:rgba(0,122,255,1);
border-radius:5rpx;
border:1rpx solid rgba(151,151,151,1);
flex-direction: row;
display: flex;
align-items: center;
}
.operateResultConfirmBtnText{
font-size:23rpx;
font-family:PingFangSC-Medium,PingFang SC;
font-weight:500;
color:rgba(255,255,255,1);
line-height:33rpx;
text-align: center;
width: 100%;
height: auto;
}
.operateResultCloseBtn{
width:246rpx;
height:59rpx;
background:rgba(255,255,255,1);
border-radius:5rpx;
border:1rpx solid rgba(0,122,255,1);
flex-direction: row;
display: flex;
margin-right:35rpx;
align-items: center;
}
.operateResultCloseBtnText{
font-size:23rpx;
font-family:PingFangSC-Medium,PingFang SC;
font-weight:500;
color:rgba(0,122,255,1);
line-height:33rpx;
text-align: center;
width: 100%;
height: auto;
.operateTopView {
position: relative;
width: 750rpx;
height: 60rpx;
background: rgba(255, 255, 255, 1);
/* border: 2px solid red; */
box-shadow: 0rpx 2rpx 7rpx 0rpx rgba(153, 153, 153, 0.16);
}
.operateBodyView {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
width: 750rpx;
height: 364rpx;
background: #ffffff;
}
.operateResultIcon {
position: relative;
width: 84rpx;
height: 84rpx;
margin-top: 35rpx;
}
.operateResultText {
font-size: 26rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: rgba(0, 122, 255, 1);
line-height: 26rpx;
margin-top: 23rpx;
}
.operateResultDesc {
font-size: 21rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: rgba(91, 105, 129, 1);
line-height: 21rpx;
margin-top: 19rpx;
}
.operateResultBtnContainer {
width: auto;
height: auto;
display: flex;
flex-direction: row;
margin-top: 54rpx;
}
.operateResultConfirmBtn {
width: 246rpx;
height: 59rpx;
background: rgba(0, 122, 255, 1);
border-radius: 5rpx;
border: 1rpx solid rgba(151, 151, 151, 1);
flex-direction: row;
display: flex;
align-items: center;
}
.operateResultConfirmBtnText {
font-size: 23rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: rgba(255, 255, 255, 1);
line-height: 33rpx;
text-align: center;
width: 100%;
height: auto;
}
.operateResultCloseBtn {
width: 246rpx;
height: 59rpx;
background: rgba(255, 255, 255, 1);
border-radius: 5rpx;
border: 1rpx solid rgba(0, 122, 255, 1);
flex-direction: row;
display: flex;
margin-right: 35rpx;
align-items: center;
}
.operateResultCloseBtnText {
font-size: 23rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: rgba(0, 122, 255, 1);
line-height: 33rpx;
text-align: center;
width: 100%;
height: auto;
}
/**打印上一单*/
.printLastOrderPage {
display: flex;
flex-direction: column;
......
......@@ -162,26 +162,45 @@
</view>
<view class="operating-bottom">
<text class="total-num">共{{totalQuantity}}件商品,合计金额</text>
<text class="pay-price">¥{{totalPrice}}</text>
<view class="total-price-container">
<text class="pay-price">¥{{totalPrice}}</text>
<text class="pay-coupon" a:if="{{discCouponPrice != 0}}">-¥{{discCouponPrice}}</text>
</view>
<button class="go-pay" size="default" type="primary" onTap="goPay">收款</button>
</view>
</view>
</view>
</view>
<!-- 扫描优惠券 -->
<view class="page-coupon" a:if="{{couponUseing}}">
<view class="page-coupon" a:if="{{discCouponState != 0 && discCouponState != 3 }}">
<view class="coupon-top">
<view class="coupon-back-container" onTap="couponBack">
<view class="coupon-back-container" onTap="convertCouponClose" a:if="{{discCouponState == 1}}">
<image class="coupon-back-icon" mode="aspectFit" src="/images/icon_back.png"/>
<text class="coupon-back-text">返回</text>
</view>
<view class="coupon-title">优惠券</view>
<view class="coupon-title" a:if="{{discCouponState == 1}}">优惠券</view>
<view></view>
</view>
<view class="coupon-bottom">
<!-- 等待扫描 -->
<view class="coupon-bottom" a:if="{{discCouponState == 1}}">
<text class="scan-coupon-text">等待顾客扫描优惠券码…</text>
<image class="scan-coupon-guide" mode="aspectFit" src="/images/scan_guide.png"/>
<button class="cancel-use-coupon" size="default" type="ghost" onTap="couponBack">取消</button>
<button class="cancel-use-coupon" size="default" type="ghost" onTap="couponBack">关闭</button>
</view>
<!-- 录入中 -->
<view class="coupon-bottom" a:if="{{discCouponState == 2}}">
<text class="scan-coupon-text">正在录入优惠券…</text>
<image class="scan-coupon-guide" mode="aspectFit" src="/images/scan_guide.png"/>
</view>
<!-- 录入失败 -->
<view class="coupon-bottom-fail" a:if="{{discCouponState == 4}}">
<image class="scan-coupon-fail" mode="aspectFit" src="/images/icon_failed.png"/>
<text class="scan-coupon-text-fail">录入失败</text>
<text class="scan-coupon-text-fail-desr">{{discCouponMsg}}</text>
<view class="failure-operation">
<button class="close-use-coupon" type="ghost" size="default" onTap="couponBack">关闭</button>
<button class="again-use-coupon" type="primary" size="default" onTap="useCoupon">重新录入</button>
</view>
</view>
</view>
</view>
......
......@@ -45,15 +45,15 @@ Page({
payPriceFen: 0,
/**商品扫码页相关参数 */
//是否正在用券
couponUseing: false,
//优惠券 0关闭 录入券弹窗 1等待录入 2.录入中 3.录入成功 4.录入失败
discCouponState: 0,
discCouponMsg: "录入失败!无效的优惠券码",
discCouponPrice : 0,
//兑换券 0关闭兑换券弹窗 1等待兑换 2.兑换中 3.兑换成功 4.兑换失败
convertCouponState: 0,
convertCouponMsg: "兑换失败!无效的兑换码",
//是否正在用券
couponUseing: false,
//0代表弹窗关闭 1代表手动输入条码弹窗 2代表会员 3.收款 4.退款
scene: 0,
//总数量
......@@ -216,22 +216,32 @@ Page({
//打印上一单结果返回
//获取到打印结果
var printLastOrderResult = res.data;
this.setData({
context.setData({
printLastOrderIsPrinting: false
});
if (printLastOrderResult.code == 0) {
//打印成功
this.setData({
context.setData({
printLastOrderIsPrintSuccess: true,
printLastOrderPrintStatusHint:"打印完成"
});
} else {
//打印失败
this.setData({
context.setData({
printLastOrderIsPrintSuccess: false,
printLastOrderPrintStatusHint:"打印失败"
});
}
}else if(res.action == ACTION_USE_COUPON){
//优惠券
let coupon = res.data
let discCouponPrice = context.data.discCouponPrice
discCouponPrice = discCouponPrice + coupon.discCouponPrice
context.setData({
discCouponState:coupon.discCouponState,
discCouponMsg:coupon.discCouponMsg,
discCouponPrice:discCouponPrice
})
}
}
......@@ -429,7 +439,6 @@ Page({
},
fail: (res) => {
console.log("发送收银事件到前屏小程序 失败 ===》 " + JSON.stringify(res));
},
});
},
......@@ -446,6 +455,9 @@ Page({
totalDisc: 0.00,
goods: [
],
discCouponState:0,
discCouponMsg:"",
discCouponPrice:0,
})
var commonRequest = {
......@@ -718,6 +730,25 @@ Page({
},
//发送优惠券到前屏
sendDiscCouponToFront(res) {
let context = this;
my.ix.sendBuddyMessage({
target: getApp().globalData.frontScreenAppId,
data: {
action: ACTION_USE_COUPON,
data: res
},
success: (sres) => {
console.log("优惠通知前屏 成功 ===》" + JSON.stringify(sres));
},
fail: (fres) => {
console.log("优惠券通知前屏 失败 ===》 " + JSON.stringify(fres));
context.sendDiscCouponToFront(res)
}
})
},
//发生兑换券到前屏
sendConvertCouponToFront(res) {
let context = this;
......@@ -739,11 +770,13 @@ Page({
//用券返回
couponBack(e) {
this.setData({ couponUseing: false })
this.setData({ discCouponState: 0 })
this.sendDiscCouponToFront(0)
},
//使用券
useCoupon(e) {
// this.setData({ couponUseing: true })
this.setData({ discCouponState: 1 })
this.sendDiscCouponToFront(1)
},
//发送退款金额.以分为单位
......
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