+
+
@@ -150,6 +150,12 @@ export default {
}
},
methods: {
+ onNavBack() {
+ this.$router.replace({
+ name: "cardInfo",
+ query: { imei: this.$route.query.imei, iccid: this.$route.query.iccid, isShowMenu: true, isHasCode: true}
+ });
+ },
// 获取core token
getAuth() {
let manufactorId = "5bf13062-a41e-4d00-ba14-1101aad12650";
@@ -292,14 +298,16 @@ export default {
wxPay(data, packageType) {
let that = this;
const orderData = data;
+ console.log("orderData", orderData);
let reqBody = {
openId: this.$store.getters.openId, //openId
imei: that.$route.query.imei, //imei
iccid: that.$route.query.iccid,
- productId: orderData.packagesId, //套餐id
+ productId: orderData.payTypeList[0].productId, //套餐id
packageName:
orderData.productModel + "," + orderData.packagesName, //套餐名字
packagePayType: '1', //支付类型, 默认微信
+ pkId: data.packagesCardId,
packageIssue: orderData.packageIssue, //分期
packagePrice: orderData.packagesPrice * 100
};
@@ -311,6 +319,11 @@ export default {
setTimeout(() => {
this.wxPay(orderData);
}, 1000);
+ } else if ( res.data.code !== 0){
+ return this.$dialog.confirm({
+ message: `请反馈给一线人员,\n${res.data.message}`,
+ showCancelButton: false
+ })
}
let wxData = res.data.data;
let outTradeNo = wxData.out_trade_no;
@@ -318,54 +331,75 @@ export default {
//this.checkWxPayResult(outTradeNo);
//this.closeTime();
// 调起微信支付收银台
- wx.chooseWXPay({
- timestamp: wxData.timeStamp, // 支付签名时间戳,注意微信 jssdk 中的所有使用 timestamp 字段均为小写。但最新版的支付后台生成签名使用的 timeStamp 字段名需大写其中的 S 字符
- nonceStr: wxData.nonceStr, // 支付签名随机串,不长于 32 位
- package: wxData.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
- signType: wxData.signType, // 微信支付V3的传入 RSA ,微信支付V2的传入格式与V2统一下单的签名格式保持一致
- paySign: wxData.paySign, // 支付签名
- success: function(res) {
- console.log("微信支付成功::", res);
- if(packageType === 1) {
- // 加油包不用跳转,直接提示支付成功
- that.$toast.success({
- message: '支付成功'
- });
- } else {
- // 套餐订购,跳转查询页面
- that.$router.replace({
- name: "payResult",
- query: {
- outTradeNo: that.outTradeNo,
- price: that.price,
- rechargeUrl: data.rechargeUrl,
- iccid: that.$route.query.iccid,
- isAdmin: that.$route.query.isAdmin || false,
- serialNo: that.$route.query.imei,
- issue: that.packageIssue
- }
- });
- }
- },
- fail: err => {
- console.log("支付出错了::", err);
- that.$dialog.confirm({
- title: "支付失败",
- message: "出错了,请您联系管理员"
- });
- },
- cancel: function(err) {
- // 用户取消支付
- that.$dialog.confirm({
- message: "您取消了支付"
- });
- }
- });
+ this.onWxPay(wxData,packageType);
})
.catch(error => {
console.log("error", error);
})
},
+ onWxPay(data,packageType) {
+ let that = this;
+ function onBridgeReady() {
+ WeixinJSBridge.invoke(
+ "getBrandWCPayRequest",
+ {
+ appId: AppId, //公众号ID,由商户传入
+ timeStamp: data.timeStamp, //时间戳,自1970年以来的秒数
+ nonceStr: data.nonceStr, //随机串
+ package: data.package,
+ signType: data.signType, //微信签名方式:
+ paySign: data.paySign //微信签名
+ },
+ function(res) {
+ if (res.err_msg == "get_brand_wcpay_request:ok") {
+ // 使用以上方式判断前端返回,微信团队郑重提示:
+ //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
+ if(packageType === 1) {
+ // 加油包不用跳转,直接提示支付成功
+ that.$toast.success({
+ message: '支付成功'
+ });
+ } else {
+ that.$router.replace({
+ name: "payResult",
+ query: {
+ outTradeNo: that.outTradeNo,
+ price: that.price,
+ rechargeUrl: data.rechargeUrl,
+ iccid: that.$route.query.iccid,
+ isAdmin: that.$route.query.isAdmin || false,
+ serialNo: that.$route.query.imei,
+ issue: that.packageIssue
+ }
+ });
+ }
+ } else {
+ that.$dialog.confirm({
+ message: "您取消了支付",
+ showCancelButton: false
+ });
+ }
+ }
+ );
+ }
+ if (typeof WeixinJSBridge == "undefined") {
+ if (document.addEventListener) {
+ document.addEventListener(
+ "WeixinJSBridgeReady",
+ onBridgeReady,
+ false
+ );
+ } else if (document.attachEvent) {
+ document.attachEvent("WeixinJSBridgeReady", onBridgeReady);
+ document.attachEvent(
+ "onWeixinJSBridgeReady",
+ onBridgeReady
+ );
+ }
+ } else {
+ onBridgeReady();
+ }
+ },
// 跳转到支付宝花呗外部链接
aliPay(data) {
console.log("选择了支付宝::", data);
@@ -379,6 +413,7 @@ export default {
imei: that.$route.query.imei, //imei
iccid: that.$route.query.iccid,
productId: this.payProductId, //套餐id
+ pkId: data.packagesCardId,
packageName: /* data.productModel + ',' + */data.packagesName, //套餐名字
packagePayType: Number(this.payType), //支付类型
packageIssue: this.packageIssue, //分期
@@ -428,8 +463,6 @@ export default {
},
},
created() {
- /* this.getAuth(); */
- this.getWxAutograph();
// 套餐列表
this.getDevicePayPackage();
},
diff --git a/src/views/package-home/index.vue b/src/views/package-home/index.vue
index 77af019..d5c4756 100644
--- a/src/views/package-home/index.vue
+++ b/src/views/package-home/index.vue
@@ -1,7 +1,7 @@
@@ -110,13 +110,16 @@ export default {
// todo 暂时去掉
if(this.isRecharge) {
// 如果是已经支付,但未激活,跳转激活界面
- this.$router.replace({
+ /* this.$router.replace({
name: 'cardActive',
query: {
imei: params.imei,
iccid: params.iccid
}
- })
+ }) */
+ let redUrl = encodeURIComponent(`${commonUrl}/h5-frontendweb/#/cardInfo?imei=${params.imei}&iccid=${params.iccid}`);
+ let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${AppId}&redirect_uri=${redUrl}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`;
+ window.location.href = url;
} else {
let redUrl = encodeURIComponent(`${commonUrl}/h5-frontendweb/#/${params.routerName}?imei=${params.imei}&iccid=${params.iccid}`);
let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${AppId}&redirect_uri=${redUrl}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`;
diff --git a/src/views/package-list/index.vue b/src/views/package-list/index.vue
index 0f1ce7c..6c6d90b 100644
--- a/src/views/package-list/index.vue
+++ b/src/views/package-list/index.vue
@@ -1,7 +1,7 @@
@@ -351,6 +351,7 @@ export default {
packageName: /* data.productModel */ data.packagesName, //套餐名字
packagePayType: Number(this.payType), //支付类型
packageIssue: 0, //分期
+ pkId: data.packagesCardId,
packagePrice: process.env.NODE_ENV === "production" ? data.packagesPrice * 100 : 1 //总金额单位为分,测试环境写死
};
this.$toast.clear();
@@ -509,6 +510,7 @@ export default {
productId: this.payProductId, //套餐id
packageName: /* data.productModel + ',' + */data.packagesName, //套餐名字
packagePayType: Number(this.payType), //支付类型
+ pkId: data.packagesCardId,
packageIssue: this.packageIssue, //分期
packagePrice: process.env.NODE_ENV === "production" ? data.packagesPrice * 100 : 1 //总金额单位为分,测试环境写死
};