Commit d10ddffd authored by jiangjiantao's avatar jiangjiantao

优惠券功能

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