Commit 4be3886e authored by jiangjiantao's avatar jiangjiantao

兑换券

parent be0f90c1
...@@ -5,7 +5,6 @@ import { ACTION_GO_SCAN } from '../../const/actioncmd' ...@@ -5,7 +5,6 @@ import { ACTION_GO_SCAN } from '../../const/actioncmd'
Page({ Page({
data: { data: {
storeName:"--", storeName:"--",
}, },
onLoad() { onLoad() {
my.ix.onBuddyMessage({ my.ix.onBuddyMessage({
......
...@@ -510,6 +510,7 @@ ...@@ -510,6 +510,7 @@
font-weight: 500; font-weight: 500;
color: rgba(51, 51, 51, 1); color: rgba(51, 51, 51, 1);
line-height: 22rpx; line-height: 22rpx;
margin-right: 80rpx;
} }
/* 扫券码提示 */ /* 扫券码提示 */
......
...@@ -38,22 +38,28 @@ ...@@ -38,22 +38,28 @@
<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="convertCouponClose">关闭</button> <button class="cancel-use-coupon" size="default" type="ghost" onTap="convertCouponClose">关闭</button>
</view> </view>
<!-- 兑换中 -->
<view class="coupon-bottom" a:if="{{convertCouponState == 2}}">
<text class="scan-coupon-text">正在兑换券码…</text>
<image class="scan-coupon-guide" mode="aspectFit" src="/images/scan_guide.png"/>
</view>
<!-- 兑换成功 -->
<view class="coupon-bottom-success" a:if="{{convertCouponState == 3}}">
<image class="scan-coupon-success" mode="aspectFit" src="/images/icon_success.png"/>
<text class="scan-coupon-text-success">兑换码已识别</text>
<button class="sure-use-coupon" type="primary" size="default" onTap="convertCouponClose">确定</button>
</view>
<!-- 兑换失败 --> <!-- 兑换失败 -->
<view class="coupon-bottom-fail" a:if="{{convertCouponState == 2}}"> <view class="coupon-bottom-fail" a:if="{{convertCouponState == 4}}">
<image class="scan-coupon-fail" mode="aspectFit" src="/images/icon_failed.png"/> <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">兑换失败</text>
<text class="scan-coupon-text-fail-desr">兑换失败!无效的兑换码</text> <text class="scan-coupon-text-fail-desr">兑换失败!无效的兑换码</text>
<view class="failure-operation"> <view class="failure-operation">
<button class="close-use-coupon" type="ghost" size="default" onTap="convertCouponClose">关闭</button> <button class="close-use-coupon" type="ghost" size="default" onTap="convertCouponClose">关闭</button>
<button class="again-use-coupon" type="primary" size="default" onTap="againConvertCouponClose">重新兑换</button> <button class="again-use-coupon" type="primary" size="default" onTap="convertCoupon">重新兑换</button>
</view> </view>
</view> </view>
<!-- 兑换成功 -->
<view class="coupon-bottom-success" a:if="{{convertCouponState == 3}}">
<image class="scan-coupon-success" mode="aspectFit" src="/images/icon_success.png"/>
<text class="scan-coupon-text-success">兑换码已识别</text>
<button class="sure-use-coupon" type="primary" size="default" onTap="convertCouponClose">确定</button>
</view>
</view> </view>
......
...@@ -37,8 +37,9 @@ Page({ ...@@ -37,8 +37,9 @@ Page({
//是否正在用券 //是否正在用券
couponUseing: false, couponUseing: false,
//兑换券 0关闭兑换券弹窗 1等待兑换 2.兑换失败 3.兑换成功 //兑换券 0关闭兑换券弹窗 1等待兑换 2.兑换中 3.兑换成功 4.兑换失败
convertCouponState: 0, convertCouponState: 0,
convertCouponMsg: "兑换失败!无效的兑换码",
//是否正在用券 //是否正在用券
couponUseing: false, couponUseing: false,
...@@ -167,7 +168,10 @@ Page({ ...@@ -167,7 +168,10 @@ Page({
context.goPage('waitoperate'); context.goPage('waitoperate');
}else if(res.action == ACTION_CONVERT_COUPON){ }else if(res.action == ACTION_CONVERT_COUPON){
//兑换券 //兑换券
context.setData({convertCouponState:res.data}) context.setData({convertCouponState:res.data.state})
if(null != res.data.msg){
context.setData({convertCouponMsg:res.data.msg})
}
} }
} }
...@@ -508,41 +512,31 @@ Page({ ...@@ -508,41 +512,31 @@ Page({
//兑换券 //兑换券
convertCoupon(e){ convertCoupon(e){
this.setData({convertCouponState:1}) this.setData({convertCouponState:1})
this.sendConvertCouponToFront() this.sendConvertCouponToFront(1)
}, },
//兑换券界面关闭 //兑换券界面关闭
convertCouponClose(e){ convertCouponClose(e){
this.setData({convertCouponState:0}) this.setData({convertCouponState:0})
this.sendConvertCouponToFront() this.sendConvertCouponToFront(0)
}, },
//再次兑换
againConvertCouponClose(e){
this.setData({convertCouponState:1})
this.sendConvertCouponToFront()
},
//发生兑换券到前屏 //发生兑换券到前屏
sendConvertCouponToFront(){ sendConvertCouponToFront(res){
let context = this;
my.ix.sendBuddyMessage({ my.ix.sendBuddyMessage({
target: getApp().globalData.frontScreenAppId, target: getApp().globalData.frontScreenAppId,
data: { data: {
action:ACTION_CONVERT_COUPON, action:ACTION_CONVERT_COUPON,
data:this.data.convertCouponState data:res
}, },
success: (res) => { success: (sres) => {
console.log("通知前屏关闭兑换券弹窗 成功 ===》" + JSON.stringify(res)); console.log("兑换券通知前屏 成功 ===》" + JSON.stringify(sres));
}, },
fail: (res) => { fail: (fres) => {
console.log("通知前屏关闭兑换券弹窗 失败 ===》 " + JSON.stringify(res)); console.log("兑换券通知前屏 失败 ===》 " + JSON.stringify(fres));
my.showToast({ context.sendConvertCouponToFront(res)
type: 'fail',
content: '操作失败',
duration: 3000,
success: () => {
},
});
} }
}) })
}, },
......
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