Compare commits

...

5 Commits
dev ... addTips

  1. 29
      App.vue
  2. 10
      Utils/Api.js
  3. 3
      Utils/Request.js
  4. 234
      pages/index/index.vue
  5. 78
      pages/welcome/welcome.vue
  6. BIN
      static/tipBg.png

@ -15,15 +15,18 @@
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, //
}, },
onLaunch: function() { onLaunch: function() {
@ -41,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) {
@ -65,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')

@ -63,3 +63,13 @@ export const getUserDetail = params => {
export const queryUserDiscountList = params => { export const queryUserDiscountList = params => {
return POST('GET', `${base}/discount/queryUserDiscountList`, params).then(res => res.data); return POST('GET', `${base}/discount/queryUserDiscountList`, params).then(res => res.data);
} }
// 获取拉卡拉银联用户id
export const getUnionUserId = params => {
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);
}

@ -40,8 +40,9 @@ function request(method, url, data) {
} }
}, },
fail(err) { fail(err) {
app.globalData.isClick = true;
uni.showToast({ uni.showToast({
title: '请求失败', title: '请求失败,查看网络是否正常',
icon: 'none', icon: 'none',
duration: 1500, duration: 1500,
}) })

@ -122,7 +122,7 @@
</view> </view>
<!-- 优惠券弹窗 --> <!-- 优惠券弹窗 -->
<wybPopup ref="popup" type="bottom" width="500" radius="6" :showCloseIcon="true" scrollY="true"> <wybPopup ref="popup" type="bottom" width="500" radius="6" :showCloseIcon="true" :scrollY="true">
<view class="fotct font18 fontwig6 fcor333 mart10 height30">优惠券选择</view> <view class="fotct font18 fontwig6 fcor333 mart10 height30">优惠券选择</view>
<view v-if="discountList == ''" class="mart60 fotct font14 fcor666"> <view v-if="discountList == ''" class="mart60 fotct font14 fcor666">
<image mode="widthFix" style="width: 50vw;" src="../../static/noorder.png"></image> <image mode="widthFix" style="width: 50vw;" src="../../static/noorder.png"></image>
@ -151,7 +151,7 @@
<view class="height40p"></view> <view class="height40p"></view>
</wybPopup> </wybPopup>
<!-- 门店活动 --> <!-- 门店活动 -->
<wybPopup ref="popupstore" type="bottom" width="500" radius="6" :showCloseIcon="true" scrollY="true"> <wybPopup ref="popupstore" type="bottom" width="500" radius="6" :showCloseIcon="true" :scrollY="true">
<view class="fotct font18 fontwig6 fcor333 mart10 height30">门店活动选择</view> <view class="fotct font18 fontwig6 fcor333 mart10 height30">门店活动选择</view>
<view v-if="storeCouponlist == ''" class="mart60 fotct font14 fcor666"> <view v-if="storeCouponlist == ''" class="mart60 fotct font14 fcor666">
<image mode="widthFix" style="width: 50vw;" src="../../static/noorder.png"></image> <image mode="widthFix" style="width: 50vw;" src="../../static/noorder.png"></image>
@ -200,6 +200,25 @@
</view> </view>
</wybPopup> </wybPopup>
<wybPopup ref="popupTip" type="center" :maskClickClose="false" :height="popupHeight" :width="popupWidth"
bgColor="" radius="20" :showCloseIcon="false">
<view class="width100 height100 pr">
<image class="popImg" mode="aspectFit" src="/static/tipBg.png"></image>
<view class="popContain width100 ">
<view class="tip-top font20">恭喜!获得了到店优惠</view>
<view class="tip-price tip-color">
<text class="font45 " v-if="tradeDetail">{{tradeDetail.rebateActivityActualPrice}}</text><text
class=""></text>
</view>
<view class="tip-color tip-desc">
到店付款可当现金用
</view>
<view class="btnPay " @tap.stop="tapToPay">去支付</view>
</view>
</view>
</wybPopup>
</view> </view>
</template> </template>
@ -217,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');
@ -270,7 +290,13 @@
storediscountType: '', // storediscountType: '', //
storediscountCondition: '', // storediscountCondition: '', //
storediscountPrice: '', // storediscountPrice: '', //
storeDiscountId: '' //id storeDiscountId: '', //id
tradeDetail: null, //
/* 弹窗 */
popupHeight: 485,
popupWidth: 330,
outTradeNo: '', //
} }
}, },
mounted() {}, mounted() {},
@ -283,6 +309,9 @@
this.getUserAccount(); this.getUserAccount();
this.queryUserDiscountList(); this.queryUserDiscountList();
} }
this.popupHeight = this.rpxTopx(this.popupHeight);
this.popupWidth = this.rpxTopx(this.popupWidth);
}, },
computed: { computed: {
// //
@ -310,6 +339,13 @@
}, },
methods: { methods: {
rpxTopx(temp) {
let deviceWidth = uni.getSystemInfoSync().windowWidth; //
let rpx = (750 / deviceWidth) * Number(temp)
return Math.floor(rpx);
},
Timer() {}, Timer() {},
// //
getCode() { getCode() {
@ -672,13 +708,17 @@
// if (userAgent.match(/Alipay/i) == "alipay") { // if (userAgent.match(/Alipay/i) == "alipay") {
// this.createJSAPIOrder('ALIPAY'); // this.createJSAPIOrder('ALIPAY');
// } else if (userAgent.match(/MicroMessenger/i) == "micromessenger") { // } else if (userAgent.match(/MicroMessenger/i) == "micromessenger") {
if (app.globalData.isClick) {
this.createJSAPIOrder(); this.createJSAPIOrder();
app.globalData.isClick = false;
}
// } // }
}, },
// //
createJSAPIOrder(item) { createJSAPIOrder(item) {
uni.showLoading({ uni.showLoading({
title:'请求中' title: '请求中'
}) })
// "WECHAT ALIPAY UQRCODEPAY", // "WECHAT ALIPAY UQRCODEPAY",
let phone = ''; let phone = '';
@ -694,11 +734,21 @@
"userDiscountId": this.memDiscountId, "userDiscountId": this.memDiscountId,
"userPhone": phone "userPhone": phone
} }
this.tradeDetail = null;
this.outTradeNo = "";
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) {
this.tradeDetail = res.return_data.tradeDetail;
this.$refs.popupTip.show();
return
}
this.jsapiPay(res.return_data.outTradeNo); this.jsapiPay(res.return_data.outTradeNo);
} else { } else {
app.globalData.isClick = true;
uni.showToast({ uni.showToast({
title: res.return_msg, title: res.return_msg,
duration: 2000, duration: 2000,
@ -707,12 +757,26 @@
} }
}) })
}, },
tapToPay() {
this.$refs.popupTip.hide();
this.$nextTick(() => {
if (this.outTradeNo) {
this.jsapiPay(this.outTradeNo);
}
})
},
// //
jsapiPay(item) { jsapiPay(item) {
uni.showLoading({
title: '请求中',
mask: true,
})
let datas = { let datas = {
outTradeNo: item outTradeNo: item
} }
jsapiPay(datas).then(res => { jsapiPay(datas).then(res => {
uni.hideLoading();
if (res.return_code == '000000') { if (res.return_code == '000000') {
if (res.return_data.payParam && app.globalData.platformType == 'WECHAT') { if (res.return_data.payParam && app.globalData.platformType == 'WECHAT') {
this.wechatpayRequest(res.return_data); this.wechatpayRequest(res.return_data);
@ -733,6 +797,7 @@
duration: 2000 duration: 2000
}) })
} else { } else {
app.globalData.isClick = true;
uni.showToast({ uni.showToast({
title: res.return_msg, title: res.return_msg,
duration: 2000, duration: 2000,
@ -741,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();
@ -848,10 +936,11 @@
}, },
// //
wechatpayRequest: function(self) { wechatpayRequest: function(self) {
let that = this;
uni.showLoading({ uni.showLoading({
title: '支付中...' title: '支付中...'
}) })
if (self.platformType == 1) { if (self.platformType == 1 || self.platformType == 5) {
jweixin.config({ jweixin.config({
debug: false, // ,apialertpclogpc debug: false, // ,apialertpclogpc
appId: self.payParam.acc_resp_fields.app_id, // appId: self.payParam.acc_resp_fields.app_id, //
@ -864,8 +953,12 @@
jweixin.ready(function() { jweixin.ready(function() {
jweixin.checkJsApi({ jweixin.checkJsApi({
jsApiList: ['chooseWXPay'], // JSJS2, jsApiList: ['chooseWXPay'], // JSJS2,
success: function(res) {}, success: function(res) {
fail: function(res) {} // app.globalData.isClick = true;
},
fail: function(res) {
// app.globalData.isClick = true;
}
}); });
jweixin.chooseWXPay({ jweixin.chooseWXPay({
appId: self.payParam.acc_resp_fields.app_id, appId: self.payParam.acc_resp_fields.app_id,
@ -883,11 +976,20 @@
title: '支付成功' title: '支付成功'
}) })
}, },
cancel: function(r) {}, cancel: function(r) {
fail: function(res) {} that.cancelOrder(that.outTradeNo); //
// app.globalData.isClick = true;
},
fail: function(res) {
that.cancelOrder(that.outTradeNo); //
// app.globalData.isClick = true;
}
}); });
}); });
// configerrorconfigdebugresSPA
jweixin.error(function(res) { jweixin.error(function(res) {
that.cancelOrder(that.outTradeNo); //
// app.globalData.isClick = true;
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '支付失败了', title: '支付失败了',
@ -923,12 +1025,21 @@
uni.showToast({ uni.showToast({
title: '支付成功' title: '支付成功'
}) })
}, },
cancel: function(r) {}, cancel: function(r) {
fail: function(res) {} // app.globalData.isClick = true;
that.cancelOrder(that.outTradeNo); //
},
fail: function(res) {
// app.globalData.isClick = true;
that.cancelOrder(that.outTradeNo); //
}
}); });
}); });
jweixin.error(function(res) { jweixin.error(function(res) {
// app.globalData.isClick = true;
that.cancelOrder(that.outTradeNo); //
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '支付失败了', title: '支付失败了',
@ -939,12 +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;
// alert(JSON.stringify(res)); // alert(JSON.stringify(res));
// //
}); } */
);
}, },
@ -1003,6 +1142,9 @@
border-radius: 45rpx; border-radius: 45rpx;
font-size: 28rpx; font-size: 28rpx;
} }
} }
.re { .re {
@ -1159,4 +1301,66 @@
} }
} }
/* 活动金弹窗 */
.pr {
position: relative;
}
.popImg {
width: 100%;
height: 100%;
min-height: 430px;
}
.popContain {
position: absolute;
top: 0;
// padding: 20px;
box-sizing: border-box;
text-align: center;
font-size: 28rpx;
.tip-color {
color: #BF0E0F;
}
.tip-top {
color: white;
letter-spacing: 2px;
}
.tip-price {
margin-top: 143px;
font-weight: bold;
display: flex;
align-items: baseline;
justify-content: center;
.font45 {
font-size: 45px;
font-style: oblique;
margin-right: 5px;
}
}
.tip-desc {
font-size: 18px;
font-weight: bold;
margin-top: 10px;
}
}
.btnPay {
color: #FFFFFF;
background: linear-gradient(to right, #F46538, #E8411A);
width: 60%;
margin: 22px auto 16px;
height: 50px;
display: flex;
justify-content: center;
align-items: center;
border-radius: 25px;
font-size: 28rpx;
}
</style> </style>

@ -1,25 +1,35 @@
<template> <template>
<view> <view>
</view> </view>
</template> </template>
<script> <script>
import { import {
getH5AccessToken, getH5AccessToken,
getAlipayUserId getAlipayUserId,
getUnionUserId
} from '../../Utils/Api.js'; } from '../../Utils/Api.js';
let app = getApp(); let app = getApp();
export default { export default {
data() { data() {
return { return {
appUpIdentifier: ''
} }
}, },
onLoad(options) { onLoad(options) {
//
if (app.globalData.platformType == 'UQRCODEPAY') {
var useragent = navigator.userAgent;
var agentname = useragent.split('UnionPay/');
var agentno = agentname[1];
var agentnoname = agentno.split(')');
var lastangetname = agentnoname[0];
this.appUpIdentifier = 'UnionPay/' + lastangetname;
}
var arr1 = window.location.href; var arr1 = window.location.href;
var arr2 = arr1.split('='); var arr2 = arr1.split('=');
if (app.globalData.platformType == 'WECHAT' || app.globalData.platformType == 'ALIPAY') { if (app.globalData.platformType == 'WECHAT' || app.globalData.platformType == 'ALIPAY' || app.globalData
.platformType == 'UQRCODEPAY') {
if (arr2[1].length == 12) { if (arr2[1].length == 12) {
var arr3 = arr2[1].split('#/'); var arr3 = arr2[1].split('#/');
app.globalData.snNo = arr3[0]; app.globalData.snNo = arr3[0];
@ -31,6 +41,16 @@
} else { } else {
let that = this; let that = this;
var arr4; var arr4;
if (app.globalData.platformType == 'UQRCODEPAY') {
arr4 = arr2[1].split('&');
app.globalData.code = arr4[0];
uni.getStorage({
key: 'snNumber',
success(e) {
app.globalData.snNo = e.data;
}
})
} else {
arr4 = arr2[2].split('&'); arr4 = arr2[2].split('&');
app.globalData.code = arr4[0]; app.globalData.code = arr4[0];
uni.getStorage({ uni.getStorage({
@ -40,6 +60,7 @@
} }
}) })
} }
}
if (app.globalData.code && app.globalData.platformType == 'WECHAT') { if (app.globalData.code && app.globalData.platformType == 'WECHAT') {
this.getH5AccessToken(); this.getH5AccessToken();
@ -47,6 +68,9 @@
if (app.globalData.code && app.globalData.platformType == 'ALIPAY') { if (app.globalData.code && app.globalData.platformType == 'ALIPAY') {
this.getAlipayUserId(); this.getAlipayUserId();
} }
if (app.globalData.code && app.globalData.platformType == 'UQRCODEPAY') {
this.getUnionUserId();
}
} else { } else {
var arr1 = window.location.href; var arr1 = window.location.href;
var arr2 = arr1.split('='); var arr2 = arr1.split('=');
@ -60,9 +84,10 @@
url: '../index/index' url: '../index/index'
}) })
} }
}, },
methods: { methods: {
//H5 openId //H5 openId
getH5AccessToken() { getH5AccessToken() {
let params = { let params = {
@ -71,10 +96,11 @@
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'
}) })
@ -91,10 +117,34 @@
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({
url: '../index/index'
}) })
} else {
this.jumpWeb();
}
});
},
//openid
getUnionUserId() {
let params = {
"serialNumber": app.globalData.snNo,
"userAuthCode": app.globalData.code,
"appUpIdentifier": this.appUpIdentifier
}
getUnionUserId(params).then(res => {
if (res.return_code == '000000' && res.return_data.respData.userId) {
app.globalData.openId = res.return_data.respData.userId;
uni.setStorageSync("openId",res.return_data.respData.userId);
/* uni.setStorage({
key: "openId",
data: res.return_data.respData.userId
}) */
uni.reLaunch({ uni.reLaunch({
url: '../index/index' url: '../index/index'
}) })
@ -105,13 +155,19 @@
}, },
// //
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 =
'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') {
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://qr.95516.com/qrcGtwWeb-web/api/userAuth?version=1.0.0&redirectUrl='+redirectUrl;
} }
}, },
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

Loading…
Cancel
Save