Commit 19b4137b authored by 郭志伟's avatar 郭志伟 Committed by 郝聪敏

feat: 支付完善

parent e5b99baa
...@@ -2,11 +2,12 @@ ...@@ -2,11 +2,12 @@
* @Description: 支付微信h5, jsapi, 第三方收银台,跳转) * @Description: 支付微信h5, jsapi, 第三方收银台,跳转)
* @Date: 2020-07-28 15:03:52 * @Date: 2020-07-28 15:03:52
* @LastEditors: gzw * @LastEditors: gzw
* @LastEditTime: 2020-07-31 10:46:33 * @LastEditTime: 2020-08-04 10:30:09
*/ */
import { Notify } from "@qg/cherry-ui"; import cherry from "@qg/cherry-ui";
import qs from "qs"; import qs from "qs";
const { Notify } = cherry;
/** /**
* payByWeixinJsapi * payByWeixinJsapi
...@@ -15,20 +16,11 @@ import qs from "qs"; ...@@ -15,20 +16,11 @@ import qs from "qs";
* @param {type} * @param {type}
* @return: * @return:
*/ */
function payByWeixinJsapi(info, callback) { function payByWeixinJsapi(info = {}, callback) {
function onBridgeReady() { function onBridgeReady() {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
WeixinJSBridge.invoke( WeixinJSBridge.invoke("getBrandWCPayRequest", info, function(res) {
"getBrandWCPayRequest", console.log(res);
{
appId: info.appId, //公众号名称,由商户传入
timeStamp: info.timeStamp, //时间戳,自1970年以来的秒数
nonceStr: info.nonceStr, //随机串
package: `prepay_id=${info.prepayId}`,
signType: "MD5", //微信签名方式:
paySign: info.sign //微信签名
},
function(res) {
if (res.err_msg == "get_brand_wcpay_request:ok") { if (res.err_msg == "get_brand_wcpay_request:ok") {
// 使用以上方式判断前端返回,微信团队郑重提示: // 使用以上方式判断前端返回,微信团队郑重提示:
//res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。 //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
...@@ -40,8 +32,7 @@ function payByWeixinJsapi(info, callback) { ...@@ -40,8 +32,7 @@ function payByWeixinJsapi(info, callback) {
// 支付失败 // 支付失败
callback("fail"); callback("fail");
} }
} });
);
} }
if (typeof WeixinJSBridge == "undefined") { if (typeof WeixinJSBridge == "undefined") {
if (document.addEventListener) { if (document.addEventListener) {
...@@ -86,6 +77,7 @@ function payByThirdPartyCashier(info) { ...@@ -86,6 +77,7 @@ function payByThirdPartyCashier(info) {
/** /**
* @description: 支付方式判断, 返回promise * @description: 支付方式判断, 返回promise
* NATIVE=原生扫码支付.,APP=ap支付,,JSAPI=公众号支付/小程序支付,,MWEB=H5支付.,MICROPAY=刷卡支付,默认JSAPI
* @param {String} type 支付方式,THIRD -> 第三方,MWEB -> H5支付, JSAPI -> jsapi支付,默认支付方式,THIRD * @param {String} type 支付方式,THIRD -> 第三方,MWEB -> H5支付, JSAPI -> jsapi支付,默认支付方式,THIRD
* @param {Object/String} payInfo 支付信息 * @param {Object/String} payInfo 支付信息
* @return {Promise} 回调 * @return {Promise} 回调
......
...@@ -81,6 +81,7 @@ ...@@ -81,6 +81,7 @@
<script> <script>
import localStorage from "@/service/localStorage"; import localStorage from "@/service/localStorage";
import { payByWay } from "@/service/pay";
import { mapActions, mapState } from "vuex"; import { mapActions, mapState } from "vuex";
import { create, goPay } from "@/api/consultant"; import { create, goPay } from "@/api/consultant";
import Card from "@/components/Card"; import Card from "@/components/Card";
...@@ -100,6 +101,7 @@ export default { ...@@ -100,6 +101,7 @@ export default {
remain: 126, remain: 126,
price: [0.99, 199], price: [0.99, 199],
consultantOrderNo: "", consultantOrderNo: "",
tradeType: "JSAPI",
serviceList: [ serviceList: [
{ icon: "team", title: "资深", sub: "保险精算团队" }, { icon: "team", title: "资深", sub: "保险精算团队" },
{ icon: "card", title: "专属", sub: "保险顾问" }, { icon: "card", title: "专属", sub: "保险顾问" },
...@@ -220,13 +222,15 @@ export default { ...@@ -220,13 +222,15 @@ export default {
} }
}, },
async goPay() { async goPay() {
const res = await goPay({ consultantOrderNo: this.consultantOrderNo }); const res = await goPay({ tradeType: this.tradeType });
if (res) { if (res) {
payByWay(this.tradeType, res.payInfo).then(() => {
this.$notify({ type: "success", message: "支付成功" }); this.$notify({ type: "success", message: "支付成功" });
setTimeout(() => { setTimeout(() => {
// this.$router.push("/consultant/success"); // this.$router.push("/consultant/success");
this.$parent.getOrderInfo(); this.$parent.getOrderInfo();
}, 2000); }, 2000);
});
} }
} }
} }
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
import { loginByPhone, getwxOpenId } from "@/api/user"; import { loginByPhone, getwxOpenId } from "@/api/user";
import { placeOrder } from "@/api/order"; import { placeOrder } from "@/api/order";
import cfg from "@/config"; import cfg from "@/config";
import { payByWay } from "@/service/pay.service"; import { payByWay } from "@/service/pay";
let pollTimer = null; let pollTimer = null;
export default { export default {
name: "paytest", name: "paytest",
...@@ -60,49 +60,49 @@ export default { ...@@ -60,49 +60,49 @@ export default {
}, },
insuredOrderInfo: { insuredOrderInfo: {
insuredUserInfo: { insuredUserInfo: {
phoneNo: "13209654413", phoneNo: "15715416416",
userInfoSecId: "commodo", userName: "龚秀兰",
userName: "罗刚", idNo: "640181198708118231",
idNo: "566254180010306614",
longTerm: false, longTerm: false,
validEnd: "1978-11-18", validEnd: "2021-03-15",
relation: "1", relation: "2",
socialSecurity: false, socialSecurity: true,
email: "s.yfyviye@mxxv.ki", email: "r.icj@crtzzkdr.is",
annualIncome: "17159", annualIncome: "71067",
addressCode: "110100", addressCode: "110100",
addressDetail: "海外", addressDetail: "六安市",
occupation: "5", occupation: "7",
height: 169, height: 183,
weight: 58, weight: 66,
bankCardCode: "ICBC", bankCardCode: "ICBC",
bankCardNo: "6220549771082240618" bankCardNo: "1815137475347541839"
}, },
productNo: "1", productNo: "HTYLX001",
holderUserInfo: { holderUserInfo: {
phoneNo: "13499177270", phoneNo: "15664415945",
userInfoSecId: "eu in", userName: "郭平",
userName: "崔静", idNo: "640181198708118231",
idNo: "16479119920330003X", longTerm: true,
longTerm: false, validEnd: "2021-12-03",
validEnd: "1985-09-23", socialSecurity: true,
socialSecurity: false, email: "y.dcqoic@bkfygg.fo",
email: "n.ata@ueccvun.bz", annualIncome: "50401",
annualIncome: "35555",
addressCode: "110100", addressCode: "110100",
addressDetail: "白城", addressDetail: "通化",
occupation: "1", occupation: "3",
height: 186, height: 169,
weight: 54, weight: 66,
bankCardCode: "ICBC", bankCardCode: "ICBC",
bankCardNo: "667782802278796" bankCardNo: "9397487291495249077"
},
productItem: {
insuredAmount: "30万",
policyPeriod: "至60岁",
paymentPeriod: "20年"
}, },
insuredAmount: "57",
policyPeriod: "26",
paymentType: 4, paymentType: 4,
paymentPeriod: "et in", effectiveDate: "2020-08-16 12:44:18",
effectiveDate: "2003-07-06 23:11:44", autoRenewPolicy: false
autoRenewPolicy: true
}, },
orderInfo: {}, orderInfo: {},
tradeType: "", tradeType: "",
...@@ -191,7 +191,7 @@ export default { ...@@ -191,7 +191,7 @@ export default {
}; };
if (tradeType === "JSAPI") { if (tradeType === "JSAPI") {
payInfo = res.data.payInfo; payInfo = res.data.payInfo;
payInfo.appId = cfg.wxAppId; // payInfo.appId = cfg.wxAppId;
} }
payByWay(tradeType, payInfo).then(() => { payByWay(tradeType, payInfo).then(() => {
this.payBack = 1; this.payBack = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment