diff --git a/App.vue b/App.vue
index 3db0a77..f2fb0c8 100644
--- a/App.vue
+++ b/App.vue
@@ -9,15 +9,51 @@
imgUrl: 'https://xuan-pay-private.obs.cn-southwest-2.myhuaweicloud.com',
userInfo: "",
openId: '',
+ token: '',
appId: 'wxa075e8509802f826',
code: '', //code获取openid
- snNo: '' // 设备sn号
+ snNo: '', // 设备sn号
+ //正式
+ // url: 'https://hsg.dctpay.com/user',
+ // imgUrl: 'https://hsg.dctpay.com/filesystem/',
+ // imageWxImg: 'https://hsg.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/',
},
onLaunch: function() {
console.log('App Launch');
},
onShow: function() {
console.log('App Show')
+ let that = this;
+ uni.getStorage({
+ key: 'openId',
+ success(e) {
+ if (e.data) {
+ that.globalData.openId = e.data;
+ }
+ }
+ })
+ uni.getStorage({
+ key: 'user',
+ success(e) {
+ if (e.data) {
+ that.globalData.userInfo = e.data;
+ }
+ }
+ })
+
+ uni.getStorage({
+ key: 'token',
+ success(e) {
+ if (e.data) {
+ that.globalData.token = e.data;
+ }
+ }
+ })
},
onHide: function() {
console.log('App Hide')
diff --git a/Utils/Api.js b/Utils/Api.js
index be08817..e4f5379 100644
--- a/Utils/Api.js
+++ b/Utils/Api.js
@@ -3,23 +3,58 @@ import {
} from './Request.js';
let app = getApp();
let base = app.globalData.url;
+let grabase = app.globalData.graurl;
// 门店详情
export const getQrCodeDetail = params => {
- return POST('POST', `${base}/payQrCode/getQrCodeDetail`, params).then(res => res.data);
+ return POST('POST', `${grabase}/payQrCode/getQrCodeDetail`, params).then(res => res.data);
}
//银行卡识别
export const recognizeBankCard = params => {
- return POST('GET', `${base}/ocr/recognizeBankCard`, params).then(res => res.data);
-}
-//H5 code 转化openid
-export const getAccessToken = params => {
- return POST('GET', `${base}/wechat/getAccessToken`, params).then(res => res.data);
-}
+ return POST('GET', `${grabase}/ocr/recognizeBankCard`, params).then(res => res.data);
+}
+
//创建 JSAPI 订单
export const createJSAPIOrder = params => {
- return POST('POST', `${base}/tradeOrder/createJSAPIOrder`, params).then(res => res.data);
+ return POST('POST', `${grabase}/tradeOrder/createJSAPIOrder`, params).then(res => res.data);
}
// 支付 JSAPI 订单
export const jsapiPay = params => {
- return POST('POST', `${base}/pay/jsapiPay`, params).then(res => res.data);
+ return POST('POST', `${grabase}/pay/jsapiPay`, params).then(res => res.data);
+}
+
+//计算价格
+export const calculation = params => {
+ return POST('GET', `${grabase}/tradeOrder/calculation`, params).then(res => res.data);
+}
+
+//H5 code 转化openid
+export const getH5AccessToken = params => {
+ return POST('GET', `${base}/wechat/getH5AccessToken`, params).then(res => res.data);
+}
+
+//获取登录验证码
+export const getLoginSMSCode = params => {
+ return POST('POST', `${base}/sms/getLoginSMSCode`, params).then(res => res.data);
+}
+//手机号登录
+export const phone = params => {
+ return POST('POST', `${base}/login/phone`, params).then(res => res.data);
+}
+//获取用户积分余额
+export const getUserAccount = params => {
+ return POST('POST', `${base}/getUserAccount`, params).then(res => res.data);
+}
+
+//退出登录
+export const loginout = params => {
+ return POST('POST', `${base}/login/out`, params).then(res => res.data);
+}
+
+//获取用户信息
+export const getUserDetail = params => {
+ return POST('POST', `${base}/getUserDetail`, params).then(res => res.data);
+}
+//查询优惠券
+export const queryUserDiscountList = params => {
+ return POST('GET', `${base}/discount/queryUserDiscountList`, params).then(res => res.data);
}
diff --git a/manifest.json b/manifest.json
index 6140c54..96b39f3 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,5 +1,5 @@
{
- "name" : "scan-pay-h5",
+ "name" : "惠支付",
"appid" : "__UNI__BEFC310",
"description" : "",
"versionName" : "1.0.0",
@@ -74,7 +74,7 @@
"mode" : "hash",
"base" : "/scanPay"
},
- "title" : "支付",
+ "title" : "惠支付",
"devServer" : {
"https" : false
}
diff --git a/pages.json b/pages.json
index 0eaad5f..8ab7e76 100644
--- a/pages.json
+++ b/pages.json
@@ -1,17 +1,29 @@
{
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
- "path": "pages/index/index",
+ "path": "pages/welcome/welcome",
"style": {
- "navigationBarTextStyle": "white",
- "navigationBarTitleText": "首页",
- "onReachBottomDistance": 50,
+ "navigationBarTitleText": "",
+ "enablePullDownRefresh": false,
"app-plus": {
"titleNView": false, //禁用原生导航栏
"softinputNavBar": "none"
}
}
+
+ }, {
+ "path": "pages/index/index",
+ "style": {
+ "navigationBarTextStyle": "white",
+ "navigationBarTitleText": "首页",
+ "onReachBottomDistance": 50,
+ "app-plus": {
+ "titleNView": false, //禁用原生导航栏
+ "softinputNavBar": "none"
+ }
+ }
}
+
],
"globalStyle": {
"navigationBarTextStyle": "black",
diff --git a/pages/index/index.vue b/pages/index/index.vue
index 9aa65fd..b08ee95 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -1,7 +1,7 @@
- {{storeList.storeName}}
+ {{storeList.qrCode.storeName}}
-请输入金额-
{{plateNumberStr==''?'¥0.00':'¥'+plateNumberStr}}
@@ -11,17 +11,37 @@
- 商家优惠
+ 门店优惠
-
- 商家优惠活动
+
+ 满{{storeList.discountActivity.discountCondition}}元减{{storeList.discountActivity.discountPrice}}元
+
+
+ 全场立减{{storeList.discountActivity.discountPrice}}
+
+
+ 全场打{{storeList.discountActivity.discountPrice}}折
- 抵扣金额 : ¥{{priceValue[1] / 10 /10}}
+
-
-
+
+
优惠券抵扣
-
-
+
+ 未使用
+
+
+
暂无优惠券
+
+ 登陆查看可享用优惠券
+
+
@@ -94,15 +120,32 @@
-
+
-
+
- {{item.name}}
+ {{discout.discountName}}
+
+
+
+
+
+
+
+
+
+ {{getCodeText}}
+
+
+
+
+ 立即登录
+
+
@@ -113,9 +156,14 @@
import wybPopup from '../../components/wyb-popup/wyb-popup.vue';
import {
getQrCodeDetail,
- getAccessToken,
+ getH5AccessToken,
createJSAPIOrder,
- jsapiPay
+ jsapiPay,
+ getLoginSMSCode,
+ phone,
+ getUserAccount,
+ queryUserDiscountList,
+ calculation
} from '../../Utils/Api.js';
// #ifdef H5
var jweixin = require('jweixin-module');
@@ -131,13 +179,13 @@
data() {
return {
plateNumberList: [],
- length: 4,
- inputPrice: '', //输入金额
+ length: 6,
discountPrice: 0, //优惠金额
+ inputPrice: '', //输入金额
payPrice: 0, //支付金额
reNum: 0, // 是否重复
- priceValue: [0, 20000], // 可以指定默认值
- discountList: [], //优惠券数据
+ priceValue: [0, 0], // 可以指定默认值
+ discountList: '', //优惠券数据
memDiscountId: [], //选择中的值
numKeybordList: [
[1, 2, 3],
@@ -153,81 +201,266 @@
suNo: '', //sn号
storeList: '', //门店信息
isDiscount: true,
+ user: '', //用户信息
+ deductionPrice: '0.00', //优惠券抵扣
+ //一键登陆
+ phoneNumber: "",
+ code: '',
+ getCodeText: '获取验证码',
+ getCodeBtnColor: "#ffffff",
+ getCodeisWaiting: false,
}
},
mounted() {
// this.openKeyBoard('number');
},
onLoad: function() {
- var arr1 = window.location.href;
- var arr2 = arr1.split('=');
- if (arr2[1].length == 12) {
- var arr3 = arr2[1].split('#/');
- app.globalData.snNo = arr3[0];
- uni.setStorage({
- key: "snNumber",
- data: arr3[0]
- })
- this.jumpWeb();
- } else {
- var arr4 = arr2[1].split('&');
- app.globalData.code = arr4[0];
- let that = this;
- uni.getStorage({
- key: 'snNumber',
- success(e) {
- app.globalData.snNo = e.data;
- that.getQrCodeDetail();
- }
- })
+ // var arr1 = window.location.href;
+ // var arr2 = arr1.split('=');
+ // if (arr2[1].length == 12) {
+ // var arr3 = arr2[1].split('#/');
+ // app.globalData.snNo = arr3[0];
+ // uni.setStorage({
+ // key: "snNumber",
+ // data: arr3[0]
+ // })
+ // this.jumpWeb();
+ // } else {
+ // let that = this;
+ // var 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) {
+ // this.getH5AccessToken();
+ // }
+ if (app.globalData.snNo) {
+ this.getQrCodeDetail();
}
- if (app.globalData.code) {
- this.getAccessToken();
+ if (app.globalData.userInfo) {
+ this.user = app.globalData.userInfo;
+ this.getUserAccount();
+ this.queryUserDiscountList();
}
- // if (app.globalData.snNo) {
- // this.getQrCodeDetail();
- // }
},
computed: {
//获取输入金额值
plateNumberStr() {
let str = '';
+ let parice = '';
this.plateNumberList.forEach(item => {
str += item.toString();
})
- this.payPrice = str - (this.priceValue[1] / 10 / 10);
- if (this.payPrice > 0) {
+ parice = str - (this.priceValue[1] / 10 / 10);
+ if(str == 0){
+ this.calculation(0);
+ }
+ if(str){
+ this.calculation(str);
+ }
+ if (parice > 0) {
this.cjstu = false;
} else {
- this.payPrice = 0;
+ // this.payPrice = 0;
this.priceValue = [0, 0];
}
+ this.inputPrice = str;
return str;
},
},
methods: {
- //H5 获取openId
- getAccessToken(item) {
+ Timer() {},
+ //发送验证码
+ getCode() {
+ uni.hideKeyboard()
+ if (this.getCodeisWaiting) {
+ return;
+ }
+ if (!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(this.phoneNumber))) {
+ uni.showToast({
+ title: '请填写正确手机号码',
+ icon: "none",
+ duration: 2000
+ });
+ return;
+ }
+ uni.showLoading({
+ title: '发送中...'
+ })
let params = {
- code: app.globalData.code
+ phone: this.phoneNumber,
+ }
+ getLoginSMSCode(params).then(res => {
+ uni.hideLoading();
+ if (res.return_code == '000000') {
+ this.getCodeisWaiting = true;
+ this.getCodeBtnColor = "rgba(255,255,255,0.5)"
+ uni.showToast({
+ title: '验证码已发送',
+ icon: "none"
+ });
+ this.setTimer();
+ }
+ })
+ },
+ setTimer() {
+ let holdTime = 60;
+ this.getCodeText = "重新获取(60)"
+ this.Timer = setInterval(() => {
+ if (holdTime <= 0) {
+ this.getCodeisWaiting = false;
+ this.getCodeBtnColor = "#ffffff";
+ this.getCodeText = "获取验证码"
+ clearInterval(this.Timer);
+ return;
+ }
+ this.getCodeText = "重新获取(" + holdTime + ")"
+ holdTime--;
+
+ }, 1000)
+ },
+ //登陆
+ doReg() {
+ uni.hideKeyboard();
+ //模板示例部分验证规则
+ if (!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(this.phoneNumber))) {
+ uni.showToast({
+ title: '请填写正确手机号码',
+ icon: "none"
+ });
+ return false;
+ }
+ if (!this.code) {
+ uni.showToast({
+ title: '请填写验证码',
+ icon: "none"
+ });
+ return false;
+ }
+ uni.showLoading({
+ title: '提交中...'
+ })
+ let params = {
+ phone: this.phoneNumber,
+ smsCode: this.code,
+ "type": "SMS",
+ "platform": "H5",
+ }
+ phone(params).then(res => {
+ uni.hideLoading();
+ if (res.return_code == '000000') {
+ app.globalData.userInfo = res.return_data
+ .object
+ .highUser;
+ app.globalData.token = res.return_data.uniqueCode;
+ this.user = res.return_data
+ .object
+ .highUser;
+ uni.setStorage({
+ key: "user",
+ data: res.return_data
+ .object
+ .highUser
+ })
+ uni.setStorage({
+ key: "token",
+ data: res.return_data.uniqueCode
+ })
+ this.$refs.popups.hide();
+ this.getUserAccount();
+ } else {
+ this.showtoastdes = res.return_msg;
+ uni.showToast({
+ title: res.return_msg,
+ icon: "none",
+ duration: 2000
+ });
+ }
+ })
+ },
+ //弹出登陆
+ showPopuplogin() {
+ this.$refs.popups.show();
+ },
+ //查询积分
+ getUserAccount() {
+ getUserAccount().then(res => {
+ if (res.return_code == '000000') {
+ this.priceValue[1] = res.return_data.integral;
+ }
+ });
+ },
+ //查询优惠券
+ queryUserDiscountList() {
+ let datas = {
+ platform: 2,
+ storeNo: app.globalData.snNo,
+ status: 1,
+ pageNum: 1,
+ pageSize: 9999
}
- getAccessToken(params).then(res => {
- if (res.return_code == '000000' && res.return_data.openid) {
- app.globalData.openId = res.return_data.openid;
+ queryUserDiscountList(datas).then(res => {
+ if (res.return_code == '000000') {
+ this.discountList = res.return_data.list;
+ }
+ });
+ },
+ //计算价格
+ calculation(item) {
+ let storetype = '';
+ let storeprice = '';
+ if (item >= this.storeList.discountActivity.discountCondition && this.storeList.discountActivity.discountType == 1) {
+ storetype = this.storeList.discountActivity.discountType;
+ storeprice = this.storeList.discountActivity.discountPrice;
+ }else{
+ storetype = this.storeList.discountActivity.discountType;
+ storeprice = this.storeList.discountActivity.discountPrice;
+ }
+ let datas = {
+ transactionPrice: item,
+ storeDiscountType: storetype,
+ storeDiscountPrice: storeprice,
+ userDiscountType: '',
+ userDiscountPrice: ''
+ }
+ calculation(datas).then(res => {
+ if (res.return_code == '000000') {
+ this.payPrice = res.return_data;
} else {
- this.jumpWeb();
+ this.payPrice = 0;
}
});
},
+ //H5 获取openId
+ // getH5AccessToken(item) {
+ // let params = {
+ // code: app.globalData.code
+ // }
+ // getH5AccessToken(params).then(res => {
+ // if (res.return_code == '000000' && res.return_data.openid) {
+ // app.globalData.openId = res.return_data.openid;
+ // } else {
+ // this.jumpWeb();
+ // }
+ // });
+ // },
//查询门店详情
getQrCodeDetail() {
let datas = {
serialNumber: app.globalData.snNo
+ // 1000017421
+
}
getQrCodeDetail(datas).then(res => {
if (res.return_code == '000000') {
- this.storeList = res.return_data.qrCode
+ this.storeList = res.return_data;
}
})
},
@@ -246,12 +479,11 @@
} else if (userAgent.match(/MicroMessenger/i) == "micromessenger") {
location.href =
- 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa075e8509802f826&redirect_uri=https%3A%2F%2Fpaycs.dctpay.com%2FscanPay%2Findex.html%23%2F&response_type=code&scope=snsapi_basewechat_redirect';
+ 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa075e8509802f826&redirect_uri=https%3A%2F%2Fhsgcs.dctpay.com%2Fgratia-pay-scanPay%2Findex.html%23%2F&response_type=code&scope=snsapi_basewechat_redirect';
}
},
//提交支付
confirm() {
-
let lenth = this.plateNumberList.length - 1;
// if (!this.payPrice) {
// uni.showToast({
@@ -287,12 +519,12 @@
this.plateNumberList = [];
return;
}
- var userAgent = navigator.userAgent.toLowerCase();
- if (userAgent.match(/Alipay/i) == "alipay") {
- this.createJSAPIOrder('ALIPAY');
- } else if (userAgent.match(/MicroMessenger/i) == "micromessenger") {
- this.createJSAPIOrder('WECHAT');
- }
+ // var userAgent = navigator.userAgent.toLowerCase();
+ // if (userAgent.match(/Alipay/i) == "alipay") {
+ // this.createJSAPIOrder('ALIPAY');
+ // } else if (userAgent.match(/MicroMessenger/i) == "micromessenger") {
+ this.createJSAPIOrder('WECHAT');
+ // }
},
// 创建订单
createJSAPIOrder(item) {
@@ -301,7 +533,7 @@
"qrCodeSN": app.globalData.snNo,
"payUserId": app.globalData.openId,
"payMode": item,
- "totalAmount": this.payPrice
+ "totalAmount": this.inputPrice
}
createJSAPIOrder(datas).then(res => {
if (res.return_code == '000000') {
@@ -322,7 +554,7 @@
}
jsapiPay(datas).then(res => {
if (res.return_code == '000000') {
- this.payRequest(res.return_data.payParam.acc_resp_fields);
+ this.payRequest(res.return_data.payParam);
} else {
uni.showToast({
title: res.return_msg,
@@ -391,10 +623,10 @@
})
jweixin.config({
// debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
- appId: self.app_id, // 必填,公众号的唯一标识
- timestamp: self.time_stamp, // 必填,生成签名的时间戳
- nonceStr: self.nonce_str, // 必填,生成签名的随机串
- signature: self.sign_type, // 必填,签名,见附录1
+ appId: self.appId, // 必填,公众号的唯一标识
+ timestamp: self.timeStamp, // 必填,生成签名的时间戳
+ nonceStr: self.nonceStr, // 必填,生成签名的随机串
+ signature: self.sign, // 必填,签名,见附录1
jsApiList: ['chooseWXPay'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
});
uni.hideLoading();
@@ -405,14 +637,12 @@
fail: function(res) {}
});
jweixin.chooseWXPay({
- appId: self.app_id,
- timestamp: self
- .time_stamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
- nonceStr: self.nonce_str, // 支付签名随机串,不长于 32 位
- package: self
- .package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=***)
- signType: self.sign_type, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
- paySign: self.pay_sign, // 支付签名
+ appId: self.appId,
+ timestamp: self.timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
+ nonceStr: self.nonceStr, // 支付签名随机串,不长于 32 位
+ package: self.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=***)
+ signType: self.signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
+ paySign: self.sign, // 支付签名
success: function(res) {
// 支付成功后的回调函数
uni.showToast({
@@ -432,26 +662,95 @@
});
});
},
- //支付宝支付
- unialiPay() {
- // const unipayIns = this.unipay.initAlipay({
- // appId: 'your appId',
- // mchId: 'your mchId',
- // privateKey: 'your privateKey',
- // // 如果不使用证书(普通公钥模式)需要alipayPublicKey
- // alipayPublicKey: 'you alipayPublicKey', // 使用支付时需传递此值做返回结果验签
- // // 如果使用证书需要传alipayRootCertPath、appCertPath、alipayPublicCertPath
- // alipayRootCertPath: path.join(__dirname,'../fixtures/alipayRootCert.crt'),
- // appCertPath: path.join(__dirname,'../fixtures/appCertPublicKey.crt'),
- // alipayPublicCertPath: path.join(__dirname,'../fixtures/alipayCertPublicKey_RSA2.crt'),
- // })
- }
- },
+ }
}
diff --git a/static/noorder.png b/static/noorder.png
index dd772b3..19c7ccb 100644
Binary files a/static/noorder.png and b/static/noorder.png differ