Compare commits

...

3 Commits

Author SHA1 Message Date
杨杰 8bc34356a2 1.优化使用门店优惠券问题 1 year ago
杨杰 5d532b6884 1.优化弹窗提示 1 year ago
杨杰 578ff3f9df 1.新增支付宝支付 2 years ago
  1. 17
      App.vue
  2. 5
      Utils/Api.js
  3. 1998
      Utils/js/alipay.js
  4. 123
      pages/index/index.vue
  5. 48
      pages/welcome/welcome.vue

@ -26,18 +26,21 @@
// imageWxImg: 'https://hsgcs.dctpay.com/filesystem/wxApplets/',
},
onLaunch: function() {
},
onShow: function() {
console.log('App Show')
let that = this;
var userAgent = navigator.userAgent.toLowerCase();
if (userAgent.match(/Alipay/i) == "alipay") {
this.platformType = 'ALIPAY';
that.globalData.platformType = 'ALIPAY';
} else if (userAgent.match(/MicroMessenger/i) == "micromessenger") {
this.platformType = 'WECHAT';
that.globalData.platformType = 'WECHAT';
} else {
this.platformType = 'UQRCODEPAY';
that.globalData.platformType = 'UQRCODEPAY';
}
},
onShow: function() {
console.log('App Show')
let that = this;
uni.getStorage({
key: 'openId',
success(e) {

@ -32,6 +32,11 @@ export const getH5AccessToken = params => {
return POST('GET', `${base}/wechat/getH5AccessToken`, params).then(res => res.data);
}
//支付宝获取openid
export const getAlipayUserId = params => {
return POST('GET', `${grabase}/login/getAlipayUserId`, params).then(res => res.data);
}
//获取登录验证码
export const getLoginSMSCode = params => {
return POST('POST', `${base}/sms/getLoginSMSCode`, params).then(res => res.data);

File diff suppressed because it is too large Load Diff

@ -207,6 +207,7 @@
import passwordInput from "../../components/password-input/password-input.vue";
import cjSlider from '../../components/cj-slider/cj-slider.vue';
import wybPopup from '../../components/wyb-popup/wyb-popup.vue';
import alipayApi from '../../Utils/js/alipay.js';
import {
getQrCodeDetail,
getH5AccessToken,
@ -460,14 +461,14 @@
let storetype = '';
let storeprice = '';
if (this.storeList.discountActivity != '' && this.storeList.discountActivity != null) {
if (item >= this.storediscountCondition && (this.storediscountType == 1 || this.storediscountType ==
2)) {
storetype = this.storediscountType;
storeprice = this.storediscountPrice;
} else {
if (item >= this.storediscountCondition) {
storetype = this.storediscountType;
storeprice = this.storediscountPrice;
}
// else {
// storetype = this.storediscountType;
// storeprice = this.storediscountPrice;
// }
}
let phone = '';
if (app.globalData.userInfo) {
@ -676,6 +677,9 @@
},
//
createJSAPIOrder(item) {
uni.showLoading({
title:'请求中'
})
// "WECHAT ALIPAY UQRCODEPAY",
let phone = '';
if (app.globalData.userInfo) {
@ -691,6 +695,7 @@
"userPhone": phone
}
createJSAPIOrder(datas).then(res => {
uni.hideLoading();
if (res.return_code == '000000') {
this.jsapiPay(res.return_data.outTradeNo);
} else {
@ -714,12 +719,12 @@
return;
}
if (res.return_data.payParam && app.globalData.platformType == 'ALIPAY') {
this.alipayRequest(res.return_data.acc_resp_fields.paepay_id);
this.alipayRequest(res.return_data.payParam.acc_resp_fields.prepay_id);
return;
}
if (res.return_data.payParam && app.globalData.platformType == 'UQRCODEPAY') {
// this.unionPayRequest(res.return_data);
window.location.href = res.return_data.acc_resp_fields.redirect_url;
location.href = res.return_data.payParam.acc_resp_fields.redirect_url;
return;
}
uni.showToast({
@ -793,11 +798,11 @@
}
//
if (this.plateNumberList1[0] == '.') {
uni.showToast({
title: '请输入正确的金额',
duration: 2000,
icon: 'none'
})
// uni.showToast({
// title: '',
// duration: 2000,
// icon: 'none'
// })
this.plateNumberList1.pop();
return;
}
@ -810,21 +815,21 @@
// }
//
if (strdata1.length == 3 && !strdata2) {
uni.showToast({
title: '请输入正确的金额',
duration: 2000,
icon: 'none'
})
// uni.showToast({
// title: '',
// duration: 2000,
// icon: 'none'
// })
this.plateNumberList1.pop();
return;
}
//
if (this.plateNumberList.indexOf('.') != -1 && !strdata2) {
uni.showToast({
title: '请输入正确的金额',
duration: 2000,
icon: 'none'
})
// uni.showToast({
// title: '',
// duration: 2000,
// icon: 'none'
// })
this.plateNumberList1.pop();
return;
}
@ -848,11 +853,11 @@
})
if (self.platformType == 1) {
jweixin.config({
debug: true, // ,apialertpclogpc
appId: self.acc_resp_fields.app_id, //
timestamp: self.acc_resp_fields.time_stamp, //
nonceStr: self.acc_resp_fields.nonce_str, //
signature: self.acc_resp_fields.pay_sign, // 1
debug: false, // ,apialertpclogpc
appId: self.payParam.acc_resp_fields.app_id, //
timestamp: self.payParam.acc_resp_fields.time_stamp, //
nonceStr: self.payParam.acc_resp_fields.nonce_str, //
signature: self.payParam.acc_resp_fields.pay_sign, // 1
jsApiList: ['chooseWXPay'] // 使JSJS2
});
uni.hideLoading();
@ -863,14 +868,15 @@
fail: function(res) {}
});
jweixin.chooseWXPay({
appId: self.acc_resp_fields.app_id,
timestamp: self.acc_resp_fields
appId: self.payParam.acc_resp_fields.app_id,
timestamp: self.payParam.acc_resp_fields
.time_stamp, // jssdk使timestamp使timeStampS
nonceStr: self.acc_resp_fields.nonce_str, // 32
package: self.acc_resp_fields
nonceStr: self.payParam.acc_resp_fields.nonce_str, // 32
package: self.payParam.acc_resp_fields
.package, // prepay_idprepay_id=***
signType: self.acc_resp_fields.sign_type, // 'SHA1'使'MD5'
paySign: self.acc_resp_fields.pay_sign, //
signType: self.payParam.acc_resp_fields
.sign_type, // 'SHA1'使'MD5'
paySign: self.payParam.acc_resp_fields.pay_sign, //
success: function(res) {
//
uni.showToast({
@ -891,10 +897,10 @@
} else {
jweixin.config({
debug: false, // ,apialertpclogpc
appId: self.appId, //
timestamp: self.timeStamp, //
nonceStr: self.nonceStr, //
signature: self.sign, // 1
appId: self.payParam.appId, //
timestamp: self.payParam.timeStamp, //
nonceStr: self.payParam.nonceStr, //
signature: self.payParam.sign, // 1
jsApiList: ['chooseWXPay'] // 使JSJS2
});
uni.hideLoading();
@ -933,40 +939,13 @@
},
//
alipayRequest(item) {
// // provideralipay
uni.requestPayment({ // uniapp
provider: 'alipay', // wxpay
orderInfo: item, //
success: function(res) {
this.show1 = false
uni.showToast({
title: "支付成功",
icon: 'success',
duration: 2000
// success: () => {
// setTimeout(() => {
// uni.switchTab({
// url: '/pages/index/index'
// })
// }, 500)
// }
})
},
fail: function(err) {
uni.showToast({
title: "支付失败请稍后再试",
icon: 'none',
duration: 2000
// success: () => {
// setTimeout(() => {
// uni.switchTab({
// url: '/pages/my/my'
// })
// }, 500)
// }
})
}
alipayApi.tradePay({
tradeNO: item
}, function(res) {
// alert(JSON.stringify(res));
//
});
},
}
@ -975,6 +954,10 @@
</script>
<style lang="scss">
page {
background-color: #ffffff;
}
.form {
width: 100%;
border-radius: 8px;

@ -7,6 +7,7 @@
<script>
import {
getH5AccessToken,
getAlipayUserId
} from '../../Utils/Api.js';
let app = getApp();
export default {
@ -18,7 +19,7 @@
onLoad(options) {
var arr1 = window.location.href;
var arr2 = arr1.split('=');
if (app.globalData.platformType == 'WECHAT') {
if (app.globalData.platformType == 'WECHAT' || app.globalData.platformType == 'ALIPAY') {
if (arr2[1].length == 12) {
var arr3 = arr2[1].split('#/');
app.globalData.snNo = arr3[0];
@ -29,20 +30,26 @@
this.jumpWeb();
} else {
let that = this;
var arr4 = arr2[2].split('&');
var arr4;
arr4 = arr2[2].split('&');
app.globalData.code = arr4[0];
uni.getStorage({
key: 'snNumber',
success(e) {
app.globalData.snNo = e.data;
// that.getQrCodeDetail();
}
})
}
if (app.globalData.code) {
if (app.globalData.code && app.globalData.platformType == 'WECHAT') {
this.getH5AccessToken();
}
if (app.globalData.code && app.globalData.platformType == 'ALIPAY') {
this.getAlipayUserId();
}
} else {
var arr1 = window.location.href;
var arr2 = arr1.split('=');
var arr3 = arr2[1].split('#/');
app.globalData.snNo = arr3[0];
uni.setStorage({
@ -53,11 +60,10 @@
url: '../index/index'
})
}
},
methods: {
//H5 openId
//H5 openId
getH5AccessToken() {
let params = {
code: app.globalData.code
@ -77,10 +83,36 @@
}
});
},
//openid
getAlipayUserId() {
let params = {
code: app.globalData.code
}
getAlipayUserId(params).then(res => {
if (res.return_code == '000000' && res.return_data.userId) {
app.globalData.openId = res.return_data.userId;
uni.setStorage({
key: "openId",
data: res.return_data.userId
})
uni.reLaunch({
url: '../index/index'
})
} else {
this.jumpWeb();
}
});
},
//
jumpWeb() {
location.href =
'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa075e8509802f826&redirect_uri=https://hsg.dctpay.com/wechat_authorize/?redirect_uri=https://hsg.dctpay.com/scanPay&response_type=code&scope=snsapi_base#wechat_redirect';
if (app.globalData.platformType == 'WECHAT') {
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';
}
if (app.globalData.platformType == 'ALIPAY') {
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';
}
},
}
}

Loading…
Cancel
Save