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

feat: 支付完善

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