添加支付失败/取消后:取消订单

addTips
游梦婷 1 year ago
parent e2b4cb6270
commit 74c14f913a
  1. 28
      App.vue
  2. 5
      Utils/Api.js
  3. 105
      pages/index/index.vue
  4. 23
      pages/welcome/welcome.vue

@ -15,15 +15,17 @@
snNo: '', // sn snNo: '', // sn
platformType: '', // platformType: '', //
// //
url: 'https://hsg.dctpay.com/user', // url: 'https://hsg.dctpay.com/user',
graurl: 'https://pay.dctpay.com/crest', // graurl: 'https://pay.dctpay.com/crest',
imgUrl: 'https://pay.dctpay.com/filesystem/', // imgUrl: 'https://pay.dctpay.com/filesystem/',
imageWxImg: 'https://hsgcs.dctpay.com/filesystem/wxApplets/',
//
// url: 'https://hsgcs.dctpay.com/user',
// graurl:'https://gratia-pay.dctpay.com/crest',
// imgUrl: 'https://hsgcs.dctpay.com/filesystem/',
// imageWxImg: 'https://hsgcs.dctpay.com/filesystem/wxApplets/', // imageWxImg: 'https://hsgcs.dctpay.com/filesystem/wxApplets/',
// redirectUrl:'https://pay.dctpay.com/scanPay',
//
url: 'https://hsgcs.dctpay.com/user',
graurl:'https://gratia-pay.dctpay.com/crest',
imgUrl: 'https://hsgcs.dctpay.com/filesystem/',
imageWxImg: 'https://hsgcs.dctpay.com/filesystem/wxApplets/',
redirectUrl:'https://gratia-pay.dctpay.com/scanPay',
isClick: true, // isClick: true, //
}, },
onLaunch: function() { onLaunch: function() {
@ -42,7 +44,7 @@
that.globalData.platformType = 'UQRCODEPAY'; that.globalData.platformType = 'UQRCODEPAY';
} }
uni.getStorage({ /* uni.getStorage({
key: 'openId', key: 'openId',
success(e) { success(e) {
if (e.data) { if (e.data) {
@ -66,7 +68,13 @@
that.globalData.token = e.data; that.globalData.token = e.data;
} }
} }
}) }) */
that.globalData.openId = uni.getStorageSync("openId");
that.globalData.userInfo = uni.getStorageSync("user");
that.globalData.token = uni.getStorageSync("token");
}, },
onHide: function() { onHide: function() {
console.log('App Hide') console.log('App Hide')

@ -68,3 +68,8 @@ export const queryUserDiscountList = params => {
export const getUnionUserId = params => { export const getUnionUserId = params => {
return POST('POST', `${grabase}/tradeOrder/getUnionUserId`, params).then(res => res.data); return POST('POST', `${grabase}/tradeOrder/getUnionUserId`, params).then(res => res.data);
} }
//取消订单
export const cancelOrder = params => {
return POST('POST', `${grabase}/tradeOrder/cancelOrder`, params).then(res => res.data);
}

@ -200,14 +200,16 @@
</view> </view>
</wybPopup> </wybPopup>
<wybPopup ref="popupTip" type="center" :maskClickClose="false" :height="popupHeight" :width="popupWidth" bgColor="" radius="20" :showCloseIcon="false"> <wybPopup ref="popupTip" type="center" :maskClickClose="false" :height="popupHeight" :width="popupWidth"
bgColor="" radius="20" :showCloseIcon="false">
<view class="width100 height100 pr"> <view class="width100 height100 pr">
<image class="popImg" mode="aspectFit" src="/static/tipBg.png"></image> <image class="popImg" mode="aspectFit" src="/static/tipBg.png"></image>
<view class="popContain width100 "> <view class="popContain width100 ">
<view class="tip-top font20">恭喜!获得了到店优惠</view> <view class="tip-top font20">恭喜!获得了到店优惠</view>
<view class="tip-price tip-color"> <view class="tip-price tip-color">
<text class="font45 " v-if="tradeDetail">{{tradeDetail.rebateActivityActualPrice}}</text><text class=""></text> <text class="font45 " v-if="tradeDetail">{{tradeDetail.rebateActivityActualPrice}}</text><text
class=""></text>
</view> </view>
<view class="tip-color tip-desc"> <view class="tip-color tip-desc">
到店付款可当现金用 到店付款可当现金用
@ -234,7 +236,8 @@
phone, phone,
getUserAccount, getUserAccount,
queryUserDiscountList, queryUserDiscountList,
calculation calculation,
cancelOrder
} from '../../Utils/Api.js'; } from '../../Utils/Api.js';
// #ifdef H5 // #ifdef H5
var jweixin = require('jweixin-module'); var jweixin = require('jweixin-module');
@ -736,14 +739,12 @@
createJSAPIOrder(datas).then(res => { createJSAPIOrder(datas).then(res => {
uni.hideLoading(); uni.hideLoading();
if (res.return_code == '000000') { if (res.return_code == '000000') {
this.outTradeNo = res.return_data.outTradeNo;
if (res.return_data.tradeDetail && res.return_data.tradeDetail.rebateActivityPart) { if (res.return_data.tradeDetail && res.return_data.tradeDetail.rebateActivityPart) {
this.tradeDetail = res.return_data.tradeDetail; this.tradeDetail = res.return_data.tradeDetail;
this.outTradeNo = res.return_data.outTradeNo;
this.$refs.popupTip.show(); this.$refs.popupTip.show();
return return
} }
this.jsapiPay(res.return_data.outTradeNo); this.jsapiPay(res.return_data.outTradeNo);
} else { } else {
@ -763,8 +764,6 @@
this.jsapiPay(this.outTradeNo); this.jsapiPay(this.outTradeNo);
} }
}) })
}, },
// //
jsapiPay(item) { jsapiPay(item) {
@ -775,7 +774,7 @@
let datas = { let datas = {
outTradeNo: item outTradeNo: item
} }
this.outTradeNo = "";
jsapiPay(datas).then(res => { jsapiPay(datas).then(res => {
uni.hideLoading(); uni.hideLoading();
if (res.return_code == '000000') { if (res.return_code == '000000') {
@ -807,6 +806,29 @@
} }
}) })
}, },
//
cancelOrder(outTradeNo) {
let params = {
"outTradeNo": outTradeNo
}
cancelOrder(params).then(res => {
app.globalData.isClick = true;
this.outTradeNo = "";
if (res.return_code == '000000') {
// uni.showToast({
// title: "",
// icon: 'none',
// duration: 2000
// })
} else {
uni.showToast({
title: res.return_msg,
icon: 'none',
duration: 2000
})
}
})
},
// //
deleteVal() { deleteVal() {
// this.plateNumberList.pop(); // this.plateNumberList.pop();
@ -932,10 +954,10 @@
jweixin.checkJsApi({ jweixin.checkJsApi({
jsApiList: ['chooseWXPay'], // JSJS2, jsApiList: ['chooseWXPay'], // JSJS2,
success: function(res) { success: function(res) {
app.globalData.isClick = true; // app.globalData.isClick = true;
}, },
fail: function(res) { fail: function(res) {
app.globalData.isClick = true; // app.globalData.isClick = true;
} }
}); });
jweixin.chooseWXPay({ jweixin.chooseWXPay({
@ -955,15 +977,19 @@
}) })
}, },
cancel: function(r) { cancel: function(r) {
app.globalData.isClick = true; that.cancelOrder(that.outTradeNo); //
// app.globalData.isClick = true;
}, },
fail: function(res) { fail: function(res) {
app.globalData.isClick = true; that.cancelOrder(that.outTradeNo); //
// app.globalData.isClick = true;
} }
}); });
}); });
// configerrorconfigdebugresSPA
jweixin.error(function(res) { jweixin.error(function(res) {
app.globalData.isClick = true; that.cancelOrder(that.outTradeNo); //
// app.globalData.isClick = true;
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '支付失败了', title: '支付失败了',
@ -999,17 +1025,21 @@
uni.showToast({ uni.showToast({
title: '支付成功' title: '支付成功'
}) })
}, },
cancel: function(r) { cancel: function(r) {
app.globalData.isClick = true; // app.globalData.isClick = true;
that.cancelOrder(that.outTradeNo); //
}, },
fail: function(res) { fail: function(res) {
app.globalData.isClick = true; // app.globalData.isClick = true;
that.cancelOrder(that.outTradeNo); //
} }
}); });
}); });
jweixin.error(function(res) { jweixin.error(function(res) {
app.globalData.isClick = true; // app.globalData.isClick = true;
that.cancelOrder(that.outTradeNo); //
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '支付失败了', title: '支付失败了',
@ -1020,13 +1050,40 @@
}, },
// //
alipayRequest(item) { alipayRequest(item) {
let that = this;
alipayApi.tradePay({ alipayApi.tradePay({
tradeNO: item tradeNO: item,
}, function(res) { success: function(res) {
if(res.resultCode==9000){
app.globalData.isClick = true;
// uni.showToast({
// title:"!",
// icon:'none'
// })
}else{
// uni.showToast({
// title:"!",
// icon:'none'
// })
that.cancelOrder(that.outTradeNo); //
}
},
fail: function(res) {
uni.showToast({
title:res,
icon:'none'
})
that.cancelOrder(that.outTradeNo); //
},
},
/* function(res) {
app.globalData.isClick = true; app.globalData.isClick = true;
// alert(JSON.stringify(res)); // alert(JSON.stringify(res));
// //
}); } */
);
}, },
@ -1249,11 +1306,13 @@
.pr { .pr {
position: relative; position: relative;
} }
.popImg { .popImg {
width: 100%; width: 100%;
height: 100%; height: 100%;
min-height: 430px; min-height: 430px;
} }
.popContain { .popContain {
position: absolute; position: absolute;
top: 0; top: 0;
@ -1261,31 +1320,37 @@
box-sizing: border-box; box-sizing: border-box;
text-align: center; text-align: center;
font-size: 28rpx; font-size: 28rpx;
.tip-color { .tip-color {
color: #BF0E0F; color: #BF0E0F;
} }
.tip-top { .tip-top {
color: white; color: white;
letter-spacing: 2px; letter-spacing: 2px;
} }
.tip-price { .tip-price {
margin-top: 143px; margin-top: 143px;
font-weight: bold; font-weight: bold;
display: flex; display: flex;
align-items: baseline; align-items: baseline;
justify-content: center; justify-content: center;
.font45 { .font45 {
font-size: 45px; font-size: 45px;
font-style: oblique; font-style: oblique;
margin-right: 5px; margin-right: 5px;
} }
} }
.tip-desc { .tip-desc {
font-size: 18px; font-size: 18px;
font-weight: bold; font-weight: bold;
margin-top: 10px; margin-top: 10px;
} }
} }
.btnPay { .btnPay {
color: #FFFFFF; color: #FFFFFF;
background: linear-gradient(to right, #F46538, #E8411A); background: linear-gradient(to right, #F46538, #E8411A);

@ -96,10 +96,11 @@ import {
getH5AccessToken(params).then(res => { getH5AccessToken(params).then(res => {
if (res.return_code == '000000' && res.return_data.openid) { if (res.return_code == '000000' && res.return_data.openid) {
app.globalData.openId = res.return_data.openid; app.globalData.openId = res.return_data.openid;
uni.setStorage({ uni.setStorageSync("openId",res.return_data.openid)
/* uni.setStorage({
key: "openId", key: "openId",
data: res.return_data.openid data: res.return_data.openid
}) }) */
uni.reLaunch({ uni.reLaunch({
url: '../index/index' url: '../index/index'
}) })
@ -116,10 +117,11 @@ import {
getAlipayUserId(params).then(res => { getAlipayUserId(params).then(res => {
if (res.return_code == '000000' && res.return_data.userId) { if (res.return_code == '000000' && res.return_data.userId) {
app.globalData.openId = res.return_data.userId; app.globalData.openId = res.return_data.userId;
uni.setStorage({ uni.setStorageSync("openId",res.return_data.userId)
/* uni.setStorage({
key: "openId", key: "openId",
data: res.return_data.userId data: res.return_data.userId
}) }) */
uni.reLaunch({ uni.reLaunch({
url: '../index/index' url: '../index/index'
}) })
@ -138,10 +140,11 @@ import {
getUnionUserId(params).then(res => { getUnionUserId(params).then(res => {
if (res.return_code == '000000' && res.return_data.respData.userId) { if (res.return_code == '000000' && res.return_data.respData.userId) {
app.globalData.openId = res.return_data.respData.userId; app.globalData.openId = res.return_data.respData.userId;
uni.setStorage({ uni.setStorageSync("openId",res.return_data.respData.userId);
/* uni.setStorage({
key: "openId", key: "openId",
data: res.return_data.respData.userId data: res.return_data.respData.userId
}) }) */
uni.reLaunch({ uni.reLaunch({
url: '../index/index' url: '../index/index'
}) })
@ -152,17 +155,19 @@ import {
}, },
// //
jumpWeb() { jumpWeb() {
let redirectUrl = app.globalData.redirectUrl;
if (app.globalData.platformType == 'WECHAT') { if (app.globalData.platformType == 'WECHAT') {
location.href = location.href =
'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa075e8509802f826&redirect_uri=https://hsg.dctpay.com/wechat_authorize/?redirect_uri=https://pay.dctpay.com/scanPay&response_type=code&scope=snsapi_base#wechat_redirect'; 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa075e8509802f826&redirect_uri=https://hsg.dctpay.com/wechat_authorize/?redirect_uri='+redirectUrl+'&response_type=code&scope=snsapi_base#wechat_redirect';
} }
if (app.globalData.platformType == 'ALIPAY') { if (app.globalData.platformType == 'ALIPAY') {
let str =encodeURIComponent(redirectUrl+"?sn=1000017476")
location.href = location.href =
'https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=2021003176605875&scope=auth_base&redirect_uri=https://pay.dctpay.com/redirect?redirect_uri=https%3A%2F%2Fpay.dctpay.com%2FscanPay%3Fsn%3D1000017476'; 'https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=2021003176605875&scope=auth_base&redirect_uri=https://pay.dctpay.com/redirect?redirect_uri='+str;
} }
if (app.globalData.platformType == 'UQRCODEPAY') { if (app.globalData.platformType == 'UQRCODEPAY') {
location.href = location.href =
'https://qr.95516.com/qrcGtwWeb-web/api/userAuth?version=1.0.0&redirectUrl=https://pay.dctpay.com/scanPay'; 'https://qr.95516.com/qrcGtwWeb-web/api/userAuth?version=1.0.0&redirectUrl='+redirectUrl;
} }
}, },
} }

Loading…
Cancel
Save