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

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

@ -7,6 +7,7 @@
<script> <script>
import { import {
getH5AccessToken, getH5AccessToken,
getAlipayUserId
} from '../../Utils/Api.js'; } from '../../Utils/Api.js';
let app = getApp(); let app = getApp();
export default { export default {
@ -18,7 +19,7 @@
onLoad(options) { onLoad(options) {
var arr1 = window.location.href; var arr1 = window.location.href;
var arr2 = arr1.split('='); var arr2 = arr1.split('=');
if (app.globalData.platformType == 'WECHAT') { if (app.globalData.platformType == 'WECHAT' || app.globalData.platformType == 'ALIPAY') {
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];
@ -29,20 +30,26 @@
this.jumpWeb(); this.jumpWeb();
} else { } else {
let that = this; let that = this;
var arr4 = arr2[2].split('&'); var arr4;
arr4 = arr2[2].split('&');
app.globalData.code = arr4[0]; app.globalData.code = arr4[0];
uni.getStorage({ uni.getStorage({
key: 'snNumber', key: 'snNumber',
success(e) { success(e) {
app.globalData.snNo = e.data; app.globalData.snNo = e.data;
// that.getQrCodeDetail();
} }
}) })
} }
if (app.globalData.code) {
if (app.globalData.code && app.globalData.platformType == 'WECHAT') {
this.getH5AccessToken(); this.getH5AccessToken();
} }
if (app.globalData.code && app.globalData.platformType == 'ALIPAY') {
this.getAlipayUserId();
}
} else { } else {
var arr1 = window.location.href;
var arr2 = arr1.split('=');
var arr3 = arr2[1].split('#/'); var arr3 = arr2[1].split('#/');
app.globalData.snNo = arr3[0]; app.globalData.snNo = arr3[0];
uni.setStorage({ uni.setStorage({
@ -53,11 +60,10 @@
url: '../index/index' url: '../index/index'
}) })
} }
}, },
methods: { methods: {
//H5 openId //H5 openId
getH5AccessToken() { getH5AccessToken() {
let params = { let params = {
code: app.globalData.code 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() { jumpWeb() {
location.href = if (app.globalData.platformType == 'WECHAT') {
'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'; 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