mobileclient/营销系统C端 镜像环境/paysuccess.html

206 lines
9.0 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport"
content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,viewport-fit=cover" />
<title>支付成功</title>
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/common/vue.min.js?v=1367936144322" type="text/javascript"
charset="utf-8"></script>
<script type="text/javascript"
src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/common/axios.js?v=1367936144322"></script>
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/js/api2_0_pre.js"></script>
<script src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/common/modelPop.js?v=3"></script>
<link rel="stylesheet" href="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/css/loading.css">
<link rel="stylesheet"
href="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/css/paySuccess.css?v=12" />
</head>
<body>
<div id="app">
<div class="content" v-if="payResult">
<img class="img" src="https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/paySuccess.png"
alt="" />
<p class="success">支付成功</p>
<!-- 直充商品 -->
<div v-if="orderInfo.type==1" class="dlexcenter operation-btn">
<p class="bottom" @click="orderPageFn">确认</p>
<p class="note">{{countdown}}s后 自动跳转【订单列表】</p>
</div>
<!-- 立减金商品 -->
<div v-if="orderInfo.type==2" class="dlexcenter operation-reduce-btn">
<p class="dlexcenter back" @click="orderPageFn">返回</p>
<p class="dlexcenter exchange" @click="receiveFn">去兑换</p>
</div>
<!-- 卡密商品 -->
<div v-if="orderInfo.type==3" class="dlexcenter operation-btn">
<p class="bottom" @click="cardPwdPageFn">确认</p>
<p class="note">{{countdown}}s后 自动跳转【卡密详情页面】</p>
</div>
</div>
<!-- 弹出提示 -->
<model-pop :show.sync="popAttr.show" :title="popAttr.title" :status="popAttr.status" :text="popAttr.text"
:bottom_text="popAttr.bottomText" @backFunction="backFunctionPop"></model-pop>
</div>
<script>
new Vue({
el: "#app",
data () {
return {
orderNumber: '',
orderInfo: { type: 3 },
countdown: 3,
popAttr: {
show: false,
title: '温馨提示',
status: 3,/*1 成功 2提示 3失败 */
text: '错误信息',
bottomText: ''
},
plaflam: 1,
payResult: false,
copyLink: '',
orderId: '',
redirect_url: '' //微信小程序链接
};
},
components: { modelPop },
created () {
let orderNumber = this.getQueryString(
window.location.search,
"order_number"
);
this.orderNumber = orderNumber;
this.getOrderDetail(orderNumber);
localStorage.setItem('token', this.getQueryString(window.location.search, "token"));
},
methods: {
getQueryString (path, name) {
//获取浏览器地址栏的参数
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = path.substr(1).match(reg);
if (r != null) return unescape(r[2]);
return null;
},
//返回订单页面
orderPageFn () {
window.location.replace('./coupon/myOrder.html');
},
//卡密返回卡密详情页面
cardPwdPageFn () {
window.location.replace('./coupon/myOrder.html');
},
/* 倒计时 */
countdownFn () {
let time = 3;
let stopTimer = setInterval(() => {
time--;
if (time > 0) {
this.countdown = time;
} else {
this.orderPageFn();
clearInterval(stopTimer);
}
}, 1000);
},
//获取订单详情
getOrderDetail (id) {
req.axiosGet("/key/order/detail/" + id).then((res) => {
if (res.code == 200) {
this.orderInfo = res.data;
this.payResult = true;
if (res.data.type == 2) { //1 商品 2立减金
//channel 1支付宝 2微信
this.plaflam = res.data.product.entity.channel;//只有立减金商品才有channel字段
this.redirect_url = res.data.wechat_redirect_url;
this.payStatus = res.data.pay_status;
this.orderId = res.data.alipay_order_number;
} else {
this.countdownFn();
}
}
}).catch();
},
//弹出框提示
openTipDialog (popUpAttr) {
this.popAttr = popUpAttr;
},
/* 弹窗回调 */
backFunctionPop (type) {
if (this.popAttr.bottomText === '点击复制' && type) {
var aux = document.createElement("input");
aux.setAttribute("value", this.copyLink);
document.body.appendChild(aux);
aux.select();
document.execCommand("copy");
document.body.removeChild(aux);
this.openTipDialog({
show: true,
title: '温馨提示',
status: 1,/*1 成功 2提示 3失败 */
text: '复制成功'
});
}
if (this.isLogin) {
this.delayedOut();
}
},
toLinkAlipay () {
//支付宝H5跳转
let self = this;
let banklink = encodeURIComponent(
window.location.origin +
"/alipay.html?orderNumber=" + this.orderId
);
let link = "http://openapi.1688sup.com/alipay/oauth?jump=" + banklink;
let ua = navigator.userAgent.toLowerCase(); //判断用户打开链接环境
/* 判断如果是微信浏览器或者百度浏览器 则无法拉起支付宝 */
if (ua.match(/MicroMessenger/i) == "micromessenger" || ua.indexOf("baiduboxapp") > -1 || ua.indexOf("firefox") > -1) {
//复制链接地址,提醒去浏览器打开
this.copyLink = link;
this.openErrorDialog(`请复制链接,在其他浏览器打开`, '点击复制');
} else {
//唤起支付宝
window.location.replace(link);
}
},
openErrorDialog (tip, bottomText) {
this.popAttr.text = tip;
this.popAttr.show = true;
this.popAttr.bottomText = bottomText;
},
//领取立减金
receiveFn () {
if (this.payStatus != 2) {
this.openTipDialog({
show: true,
title: '温馨提示',
status: 2,/*1 成功 2提示 3失败 */
text: '支付结算中,请等待支付结果...'
});
return;
}
let ua = navigator.userAgent.toLowerCase(); //判断用户打开链接环境
if (this.plaflam == 1) {
//支付宝-微信环境中不能唤起支付宝
this.toLinkAlipay();
}
if (this.plaflam == 2) {
//微信
//唤起微信福利官小程序
window.location.replace(this.redirect_url);
}
}
},
});
</script>
</body>
</html>