Commit 4423a557 authored by jiangjiantao's avatar jiangjiantao

前屏登录通知后屏

parents 3bdaf5be ace69fb7
...@@ -37,5 +37,14 @@ export const ACTION_DIRECT_PAYMENT = "ACTION_DIRECT_PAYMENT"; ...@@ -37,5 +37,14 @@ export const ACTION_DIRECT_PAYMENT = "ACTION_DIRECT_PAYMENT";
//兑换券 //兑换券
export const ACTION_CONVERT_COUPON = "ACTION_CONVERT_COUPON"; export const ACTION_CONVERT_COUPON = "ACTION_CONVERT_COUPON";
//退款操作
export const ACTION_REFUND = "ACTION_REFUND";
//退款成功
export const ACTION_REFUND_SUCCESS = "ACTION_REFUND_SUCCESS";
//退款失败
export const ACTION_REFUND_FAILED = "ACTION_REFUND_FAILED";
//登录完成 //登录完成
export const ACTION_LOGIN_OK = "ACTION_LOGIN_OK"; export const ACTION_LOGIN_OK = "ACTION_LOGIN_OK";
...@@ -10,3 +10,5 @@ export const API_CREATE_ORDER = "order/create"; ...@@ -10,3 +10,5 @@ export const API_CREATE_ORDER = "order/create";
export const API_PAY = "pay/micropay"; export const API_PAY = "pay/micropay";
//查询支付结果 //查询支付结果
export const API_QUERY = "order/query"; export const API_QUERY = "order/query";
export const API_REFUND = "order/refund";
\ No newline at end of file
<view class="page" > <view class="page" >
<view class="bg" onTap="homeTap"/> <view class="bg" onTap="homeTap"/>
<!-- 弹窗 -->
<scandialog displayDialog="{{scanDialogDisplay}}" <scandialog displayDialog="{{scanDialogDisplay}}"
remindText="请扫描兑换码" remindText="{{dialogRemindText}}"
loadingText="识别中" loadingText="{{dialogLoadingText}}"
resultSuccessRemind="兑换码已识别" resultSuccessRemind="{{dialogResultSuccessRemind}}"
resultSuccessText="恭喜您!兑换成功 " resultSuccessText="{{dialogResultSuccessText}}"
resultFailureRemind="兑换码未识别" resultFailureRemind="{{dialogResultFailureRemind}}"
resultFailureText="兑换失败,请稍后重试!" resultFailureText="{{dialogResultFailureText}}"
/> />
</view> </view>
\ No newline at end of file
...@@ -5,22 +5,33 @@ import { ACTION_GO_SCAN } from '../../const/actioncmd' ...@@ -5,22 +5,33 @@ import { ACTION_GO_SCAN } from '../../const/actioncmd'
import { ACTION_GET_ACCOUNT } from '../../const/actioncmd' import { ACTION_GET_ACCOUNT } from '../../const/actioncmd'
import { ACTION_DIRECT_PAYMENT } from '../../const/actioncmd' import { ACTION_DIRECT_PAYMENT } from '../../const/actioncmd'
import { ACTION_CONVERT_COUPON } from '../../const/actioncmd' import { ACTION_CONVERT_COUPON } from '../../const/actioncmd'
import { ACTION_GO_HOME } from '../../const/actioncmd'
import { ACTION_REFUND } from '../../const/actioncmd'
import { ACTION_REFUND_FAILED } from '../../const/actioncmd'
import { ACTION_REFUND_SUCCESS } from '../../const/actioncmd'
Page({ Page({
data: { data: {
//显示弹窗,>1为显示,2loading 3 result success 4 result failed //显示弹窗,>1为显示,2loading 3 result success 4 result failed
scanDialogDisplay: 0 scanDialogDisplay: 0,
dialogRemindText: "请扫描兑换码",
dialogLoadingText: "识别中",
dialogResultSuccessRemind: "兑换码已识别",
dialogResultSuccessText: "恭喜您!兑换成功",
dialogResultFailureRemind: "兑换码未识别",
dialogResultFailureText: "兑换失败,请稍后重试!",
}, },
onLoad() { onLoad() {
}, },
onShow(){ onShow() {
let context = this;
my.ix.onBuddyMessage({ my.ix.onBuddyMessage({
success: (res) => { success: (res) => {
console.info(`onBuddyMessage success: ${JSON.stringify(res)}`); console.info(`onBuddyMessage success: ${JSON.stringify(res)}`);
if(res.action == ACTION_GO_SCAN){ if (res.action == ACTION_GO_SCAN) {
my.ix.sendBuddyMessage({ my.ix.sendBuddyMessage({
// 填入目标小程序的 AppID // 填入目标小程序的 AppID
target: getApp().globalData.backScreenAppId, target: getApp().globalData.backScreenAppId,
...@@ -39,10 +50,10 @@ Page({ ...@@ -39,10 +50,10 @@ Page({
console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`); console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`);
} }
}); });
} else if(res.action == ACTION_GET_ACCOUNT){ } else if (res.action == ACTION_GET_ACCOUNT) {
var message = { var message = {
data:getApp().globalData.localAccountInfo, data: getApp().globalData.localAccountInfo,
action:ACTION_GET_ACCOUNT action: ACTION_GET_ACCOUNT
} }
my.ix.sendBuddyMessage({ my.ix.sendBuddyMessage({
// 填入目标小程序的 AppID // 填入目标小程序的 AppID
...@@ -81,6 +92,22 @@ Page({ ...@@ -81,6 +92,22 @@ Page({
}else if(res.action == ACTION_CONVERT_COUPON){ }else if(res.action == ACTION_CONVERT_COUPON){
//兑换券 //兑换券
this.setData({scanDialogDisplay:res.data}) this.setData({scanDialogDisplay:res.data})
} else if (res.action == ACTION_REFUND) {
//显示弹窗
context.setData({
scanDialogDisplay: 1,
dialogRemindText: "请扫描订单编码",
dialogLoadingText: "识别中",
dialogResultSuccessRemind: "退款成功",
dialogResultSuccessText: "退款完成!会在1~2个工作日 返还到您的付款账户",
dialogResultFailureRemind: "退款失败",
dialogResultFailureText: "退款失败!无效的订单码",
});
} else if (res.action == ACTION_GO_HOME) {
//home界面收到,则返回界面上
context.setData({
scanDialogDisplay: 0
})
} }
} }
}); });
...@@ -156,6 +183,62 @@ Page({ ...@@ -156,6 +183,62 @@ Page({
}); });
}, },
//增加扫码内容,以及退款等操作的内容
onKeyPress(r) {
//只有在弹窗出现时才扫码
if (this.data.scanDialogDisplay > 0) {
refund(r);
}
},
refund(barcode) {
this.setData({ scanDialogDisplay: 2 })
var request = api.createCommonRequest();
request.tradeNo = barcode;
my.request({
url: getApp().globalData.BASE_URL + API_REFUND,
method: 'POST',
dataType: 'json',
timeout: 30000,
data: request,
success: (res) => {
if (res.data.success != true||res.data.data == null) {
this.setData({ scanDialogDisplay: 4 })
console.log("退款失败 ==>" + JSON.stringify(res.data));
this.refundCallback(ACTION_REFUND_FAILED,null);
} else {
this.setData({ scanDialogDisplay: 3 })
console.log("退款成功 ==>" + JSON.stringify(res.data));
this.refundCallback(ACTION_REFUND_SUCCESS, res.data.data);
}
},
fail: (res) => {
this.setData({ scanDialogDisplay: 4 })
console.log("退款失败 ==>" + JSON.stringify(res.data));
this.refundCallback(ACTION_REFUND_FAILED,null);
}
});
},
refundCallback(action,data){
my.ix.sendBuddyMessage({
// 填入目标小程序的 AppID
target: getApp().globalData.backScreenAppId,
data: {
action: action,
data: data
},
success: (res) => {
console.info(`sendBuddyMessage success: ${JSON.stringify(res)}`);
//跳转到扫码页面
},
fail: (res) => {
console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`);
}
});
},
//同步兑换券到后台 //同步兑换券到后台
sendConvertCouponToBack(e){ sendConvertCouponToBack(e){
......
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