From 89d61651f58747add150858c63e006730763c6ca Mon Sep 17 00:00:00 2001
From: liugongyu <290219706@qq.com>
Date: Mon, 14 Aug 2023 09:24:05 +0800
Subject: [PATCH] 西城购买月卡
---
config/index.js | 8 ++++----
index.html | 2 +-
src/api/cards/cards.js | 23 +++++++++++++++++++++++
src/utils/utils.js | 10 +++++-----
src/views/cards/Cards.vue | 11 ++++++++---
src/views/cards/buyCard.vue | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
src/views/cards/renew.vue | 155 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------
src/views/parkPay/plateNumber.vue | 28 ++++++++++++++--------------
8 files changed, 295 insertions(+), 80 deletions(-)
diff --git a/config/index.js b/config/index.js
index f030a2a..211ee8c 100644
--- a/config/index.js
+++ b/config/index.js
@@ -8,7 +8,7 @@ module.exports = {
dev: {
// Paths
- assetsSubDirectory: 'static',
+ assetsSubDirectory: 'yueka',
assetsPublicPath: '/',
// proxyTable: {
// '/api':{
@@ -47,11 +47,11 @@ module.exports = {
build: {
// Template for index.html
- index: path.resolve(__dirname, '../dist/index.html'),
+ index: path.resolve(__dirname, '../yueka/yueka.html'),
// Paths
- assetsRoot: path.resolve(__dirname, '../dist'),
- assetsSubDirectory: 'static',
+ assetsRoot: path.resolve(__dirname, '../yueka'),
+ assetsSubDirectory: 'yueka',
assetsPublicPath: './',
/**
diff --git a/index.html b/index.html
index a5a64a9..d0432b1 100644
--- a/index.html
+++ b/index.html
@@ -8,7 +8,7 @@
-
@@ -181,7 +181,9 @@ import {
weixinpay,
createVipCardOrder,
queryVipCardInfoByPlNoForH5,
- createVipCardOrderForH5
+ createVipCardOrderForH5,
+ publicUnifiedOrderForH5,
+ getOpenIdByCode
} from "@/api/cards/cards";
import { timestampToTime } from "../../utils/utils.js";
export default {
@@ -217,12 +219,21 @@ export default {
typeNum: 4, // 卡类型判断
showHideOnBlur: false, // 购买协议
createVipCardOrder: {}, // 创建订单对象
- orderId: "" // 订单号
+ orderId: "", // 订单号
+ vipCardList: {},
+ openid: "",
+ custId: ""
};
},
+ created() {
+ if (this.$utils.clientBrowser() == "微信") {
+ this.webAppCode = this.getCode();
+ }
+ },
mounted() {
this.queryParkListForVipCard(); // 获取停车场
// this.queryUserCars(); // 获取用户车牌
+ this.custId = this.$route.query.custId
},
computed: {
// 卡类型 1-年卡;2-半年卡;3-季卡;4-月卡;5-日卡;
@@ -261,6 +272,23 @@ export default {
}
},
methods: {
+ // 获取code
+ getCode() {
+ var appID = this.$utils.myVxAppId;
+ var code = this.getUrlParam("code");
+ var local = window.location.href;
+ if (code == null || code === "") {
+ window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appID + "&redirect_uri=" + encodeURIComponent(local) + "&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect";
+ } else {
+ return code;
+ }
+ },
+ getUrlParam(name) {
+ var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
+ var r = window.location.search.substr(1).match(reg);
+ if (r != null) return unescape(r[2]);
+ return null;
+ },
// 获取用户绑定车牌
queryUserCars() {
let jsondata = this.$utils.commonParams();
@@ -336,15 +364,16 @@ export default {
jsondata.plNo = this.parkNo;
jsondata.cardType = "4";
// jsondata.parkName = this.parkName;
-
jsondata.sign = this.$utils.signObject(jsondata);
queryVipCardInfoByPlNoForH5(jsondata).then(data => {
console.log(data);
if (data.code == 0) {
-
- me.unitPrice = data.data.vipCardList[0].price
-
-
+ this.vipCardList = data.data.vipCardList[0];
+ me.unitPrice = data.data.vipCardList[0].price;
+ console.log(data.data.vipCardList[0].discValue / 10);
+ console.log(me.unitPrice * data.data.vipCardList[0].discValue);
+ me.disPrice = me.unitPrice - me.unitPrice * (data.data.vipCardList[0].discValue / 10);
+ me.needPay = me.unitPrice * (data.data.vipCardList[0].discValue / 10);
// me.cardTypeList = [];
// me.carType = "请点击选择";
// // res.vipCardList =
@@ -367,8 +396,6 @@ export default {
// me.typeNum = vipCardList[0].cardType;
// me.createVipCardOrder = e;
// }
- } else {
- this.$vux.toast.text(data.message, "top");
}
});
},
@@ -431,22 +458,59 @@ export default {
// this.$vux.toast.text("请选择车牌", "top");
// return;
// }
- if (!this.agreement) {
- this.$vux.toast.text("请同意购买须知", "top");
- return;
- }
+ // if (!this.agreement) {
+ // this.$vux.toast.text("请同意购买须知", "top");
+ // return;
+ // }
// this.createOrder();
- this.createVipCardOrderForH5()
+ this.getopenid();
+
+ },
+ // 获取openid
+ getopenid() {
+ let jsondata = {
+ appId: this.$utils.myVxAppId,
+ code: this.webAppCode
+ };
+ getOpenIdByCode(jsondata).then(data => {
+ console.log(data);
+ if (data.code == "0") {
+ this.openid = data.data;
+ this.createVipCardOrderForH5();
+ } else {
+ this.$vux.toast.text(data.message, "top");
+ }
+ });
},
- createVipCardOrderForH5(){
+ createVipCardOrderForH5() {
let jsondata = this.$utils.commonParams();
- jsondata.carNumber = this.$route.query.carNumber
- jsondata.custId = ''
+ jsondata.carNumber = this.$route.query.carNumber;
+ jsondata.custId = this.custId;
+ jsondata.optType = "1";
+ jsondata.cardCouponsId = "";
+ jsondata.terminalSource = "3";
+ jsondata.plNo = this.parkNo; // 停车场id
+ jsondata.discountAmount = this.disPrice;
+ jsondata.cardNo = this.vipCardList.cardNo; // 卡券编码
+ jsondata.cardType = (this.vipCardList.cardType).toString(); // 卡类型
+ jsondata.carType = (this.vipCardList.carType).toString(); // 1-大型车;2-小型车
+ // jsondata.plNo = this.createVipCardOrder.id; // 1-大型车;2-小型车
+ jsondata.price = (this.vipCardList.price).toString(); // 卡单价
+ jsondata.totalAmount = (this.needPay).toString(); // 购买的总金额
+ jsondata.num = this.cardNum; // 购买数量
+ jsondata.effDate = this.$utils.timestampToTime(this.startData); // 生效时间
+ jsondata.expDate = this.$utils.timestampToTime(this.endDate); // 失效时间
+ // jsondata.carNumber = this.carNumber; // 卡适用车牌
+ jsondata.optType = "1"; // 操作类型 1 购买 2 续费
jsondata.sign = this.$utils.signObject(jsondata);
createVipCardOrderForH5(jsondata).then(data => {
console.log(data);
if (data.code == 0) {
+ // orderId
+ let orderId = data.data.orderId;
+ this.custId = data.data.custId;
+ this.publicUnifiedOrderForH5(orderId);
} else {
this.$vux.toast.text(data.message, "top");
}
@@ -469,31 +533,35 @@ export default {
jsondata.carNumber = this.carNumber; // 卡适用车牌
jsondata.optType = "1"; // 操作类型 1 购买 2 续费
jsondata.forceBuy = "1";
+
jsondata.sign = this.$utils.signObject(jsondata);
createVipCardOrder(jsondata).then(data => {
console.log(data);
// orderId
if (data.code == 0) {
this.orderId = data.data.orderId;
- this.vxPay();
+ this.vxPay(orderId);
} else {
this.$vux.toast.text(data.message, "top");
}
});
},
- vxPay() {
+ publicUnifiedOrderForH5(orderId) {
let vm = this;
let jsondata = this.$utils.commonParams();
- jsondata.orderId = this.orderId; // 订单号
- jsondata.payType = "4"; // 支付方式-- 1:支付宝 2:微信 3:银联.
- jsondata.paySrcType = "301"; // 支付单来源 101:停车付款单 102:停车预付单 103:停车补缴单 104 共享车位 201 余额充值单 202 押金充值单 301 会员卡购买单 302 会员卡续费
+ jsondata.orderId = orderId; // 订单号
+ jsondata.payType = "4"; // /** 支付方式-- 1:支付宝 2:微信 3:银联 4:微信公众号 5 个人账户. */
+ jsondata.openId = this.openid
+ jsondata.paySrcType = "301"; // //支付单来源 101:停车付款单 102:停车预付单 103:停车补缴单 104 共享车位 201 余额充值单 202 押金充值单 301 会员卡购买单 302 会员卡续费
jsondata.appId = this.$utils.myVxAppId; // 微信标识符
jsondata.terminalSource = "3"; // 请求端来源 1: 任你停 2:pda 3:微信公共号
- jsondata.paySource = "3";
+ jsondata.custId = this.custId;
+ jsondata.payFee = this.needPay;
+ // jsondata.paySource = "3";
jsondata.couponPersonId = "";
- jsondata.openId = sessionStorage.getItem("wx_openId");
+ // jsondata.openId = sessionStorage.getItem("wx_openId");
jsondata.sign = this.$utils.signObject(jsondata);
- weixinpay(jsondata).then(res => {
+ publicUnifiedOrderForH5(jsondata).then(res => {
console.log(data);
if (res.code == 0) { //
if (res.data) {
@@ -537,11 +605,11 @@ export default {
if (res.err_msg === "get_brand_wcpay_request:ok") {
console.log("成功");
this.$vux.toast.text("支付成功", "top");
- me.$router.go(-2);
+ me.$router.go(-3);
} else {
console.log("失败");
- alert("支付失败");
- me.$router.go(-2);
+ this.$vux.toast.text("支付失败", "top");
+ me.$router.go(-3);
}
}
);
diff --git a/src/views/cards/renew.vue b/src/views/cards/renew.vue
index d0b99ec..756e05b 100644
--- a/src/views/cards/renew.vue
+++ b/src/views/cards/renew.vue
@@ -4,7 +4,7 @@
- 选择停车场
+ 停车场
{{renewData.parkName}}
@@ -17,15 +17,16 @@
- 选择卡类型
- {{renewData.cardName}}
+ 卡类型
+
+ 月卡
- 绑定车牌
+ 车牌
{{renewData.carNumber}}
@@ -69,13 +70,13 @@
-
+
+
+
+
+
+
+
@@ -120,7 +121,10 @@ import {
queryVipCardInfoByPlNo,
queryUserCars,
weixinpay,
- createVipCardOrder
+ createVipCardOrder,
+ createVipCardOrderForH5,
+ publicUnifiedOrderForH5,
+ getOpenIdByCode
} from "@/api/cards/cards";
import { timestampToTime } from "../../utils/utils.js";
export default {
@@ -148,6 +152,11 @@ export default {
renewData: {} // 续费数据
};
},
+ created() {
+ if (this.$utils.clientBrowser() == "微信") {
+ this.webAppCode = this.getCode();
+ }
+ },
mounted() {
this.renewData = JSON.parse(sessionStorage.getItem("renewData"));
console.log(this.renewData);
@@ -198,7 +207,23 @@ export default {
},
methods: {
-
+ // 获取code
+ getCode() {
+ var appID = this.$utils.myVxAppId;
+ var code = this.getUrlParam("code");
+ var local = window.location.href;
+ if (code == null || code === "") {
+ window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appID + "&redirect_uri=" + encodeURIComponent(local) + "&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect";
+ } else {
+ return code;
+ }
+ },
+ getUrlParam(name) {
+ var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
+ var r = window.location.search.substr(1).match(reg);
+ if (r != null) return unescape(r[2]);
+ return null;
+ },
clickActionCarNum(e) {
@@ -221,11 +246,105 @@ export default {
// 购买
toPay() {
- if (!this.agreement) {
- this.$vux.toast.text("请同意购买须知", "top");
- return;
- }
- this.createOrder();
+ // if (!this.agreement) {
+ // this.$vux.toast.text("请同意购买须知", "top");
+ // return;
+ // }
+ this.getopenid();
+
+ // this.createOrder();
+ },
+ // 获取openid
+ getopenid() {
+ let jsondata = {
+ appId: this.$utils.myVxAppId,
+ code: this.webAppCode
+ };
+ getOpenIdByCode(jsondata).then(data => {
+ console.log(data);
+ if (data.code == "0") {
+ this.openid = data.data;
+ this.createVipCardOrderForH5();
+ } else {
+ this.$vux.toast.text(data.message, "top");
+ }
+ });
+ },
+ createVipCardOrderForH5() {
+ let jsondata = this.$utils.commonParams();
+ jsondata.carNumber = this.renewData.carNumber;
+ jsondata.custId = this.renewData.custId;
+ jsondata.optType = "1";
+ // jsondata.cardCouponsId = "";
+ jsondata.terminalSource = "3";
+ jsondata.plNo = this.renewData.parkNo; // 停车场id
+ jsondata.discountAmount = this.disPrice;
+ jsondata.cardCouponsId = this.renewData.custCardNo; // 卡券编码
+ jsondata.cardNo = this.renewData.cardNo; // 卡券编码
+ jsondata.cardType = (this.renewData.cardType).toString(); // 卡类型
+ // jsondata.carType = (this.vipCardList.carType).toString(); // 1-大型车;2-小型车
+ // jsondata.plNo = this.createVipCardOrder.id; // 1-大型车;2-小型车
+ jsondata.price = this.unitPrice.toString(); // 卡单价
+ jsondata.totalAmount = (this.needPay).toString(); // 购买的总金额
+ jsondata.num = this.cardNum; // 购买数量
+ jsondata.effDate = this.$utils.timestampToTime(this.renewData.expDate); // 生效时间
+ jsondata.expDate = this.$utils.timestampToTime(this.endTimeFunc); // 失效时间
+ // jsondata.carNumber = this.carNumber; // 卡适用车牌
+ jsondata.optType = "2"; // 操作类型 1 购买 2 续费
+ jsondata.sign = this.$utils.signObject(jsondata);
+ createVipCardOrderForH5(jsondata).then(data => {
+ console.log(data);
+ if (data.code == 0) {
+
+ // orderId
+ let orderId = data.data.orderId;
+ // this.custId = data.data.custId;
+ this.publicUnifiedOrderForH5(orderId);
+ } else {
+ this.$vux.toast.text(data.message, "top");
+ }
+ });
+ },
+ publicUnifiedOrderForH5(orderId) {
+ let vm = this;
+ let jsondata = this.$utils.commonParams();
+ jsondata.orderId = orderId; // 订单号
+ jsondata.payType = "4"; // /** 支付方式-- 1:支付宝 2:微信 3:银联 4:微信公众号 5 个人账户. */
+ jsondata.openId = this.openid
+ jsondata.paySrcType = "302"; // //支付单来源 101:停车付款单 102:停车预付单 103:停车补缴单 104 共享车位 201 余额充值单 202 押金充值单 301 会员卡购买单 302 会员卡续费
+ jsondata.appId = this.$utils.myVxAppId; // 微信标识符
+ jsondata.terminalSource = "3"; // 请求端来源 1: 任你停 2:pda 3:微信公共号
+ jsondata.custId = this.renewData.custId;
+ jsondata.payFee = this.needPay;
+ // jsondata.paySource = "3";
+ jsondata.cardNo = this.renewData.cardNo; // 卡券编码
+ jsondata.couponPersonId = this.renewData.custCardNo;
+ // jsondata.openId = sessionStorage.getItem("wx_openId");
+ jsondata.sign = this.$utils.signObject(jsondata);
+ publicUnifiedOrderForH5(jsondata).then(res => {
+ console.log(data);
+ if (res.code == 0) { //
+ if (res.data) {
+ var data = res.data;
+ console.log(JSON.stringify(data));
+ if (typeof WeixinJSBridge === "undefined") { // 微信浏览器内置对象。参考微信官方文档
+ if (document.addEventListener) {
+ document.addEventListener("WeixinJSBridgeReady", vm.onBridgeReady(data), false);
+ } else if (document.attachEvent) {
+ document.attachEvent("WeixinJSBridgeReady", vm.onBridgeReady(data));
+ document.attachEvent("onWeixinJSBridgeReady", vm.onBridgeReady(data));
+ }
+ } else {
+ console.log("准备调用微信支付");
+ vm.onBridgeReady(data);
+ }
+ } else {
+ alert("没有找到返回值");
+ }
+ } else {
+ alert(res.message);
+ }
+ });
},
createOrder() {
console.log(this.createVipCardOrder);
diff --git a/src/views/parkPay/plateNumber.vue b/src/views/parkPay/plateNumber.vue
index 11c581d..f56014e 100644
--- a/src/views/parkPay/plateNumber.vue
+++ b/src/views/parkPay/plateNumber.vue
@@ -1,19 +1,19 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
@@ -360,7 +360,7 @@ export default {
}
},
created(){
- this.initSWiper()
+ // this.initSWiper()
},
mounted () {
//
@@ -647,7 +647,7 @@ export default {
align-items: center;
}
.wrap {
- padding:0 18px;
+ padding:40px 18px 0;
.radio-box {
display: flex;
align-items: center;
--
libgit2 0.21.4