完成二维码交费

This commit is contained in:
Your Name 2023-09-07 11:52:12 +08:00
parent 86aeaa9c11
commit 633ea492f7
7 changed files with 208 additions and 24 deletions

View File

@ -546,12 +546,84 @@ export function receiveParkingCoupon(_objData) {
})
}
/**
* 收银台 支付
* @param {Object} _that
* @param {Object} _data
* @param {Object} _successUrl
*/
export function cashierPayFee(_that, _data,_successUrl) {
if(!_successUrl ){
_successUrl = "/pages/successPage/successPage?msg=支付成功&objType=3003";
}
wx.showLoading({
title: '支付中'
});
requestNoAuth({
url: url.cashier,
method: "POST",
data: _data,
//动态数据
success: function(res) {
wx.hideLoading();
if (res.data.code == '0') {
let data = res.data; //成功情况下跳转
// #ifdef MP-WEIXIN
uni.requestPayment({
'timeStamp': data.timeStamp,
'nonceStr': data.nonceStr,
'package': data.package,
'signType': data.signType,
'paySign': data.sign,
'success': function(res) {
uni.navigateTo({
url: _successUrl
})
},
'fail': function(res) {
console.log('fail:' + JSON.stringify(res));
}
});
// #endif
// #ifdef H5
WexinPayFactory.wexinPay(data, function() {
uni.navigateTo({
url: _successUrl
})
});
// #endif
return;
}
if (res.statusCode == 200 && res.data.code == '100') {
let data = res.data; //成功情况下跳转
uni.showToast({
title: "支付成功",
duration: 2000
});
setTimeout(function() {
uni.navigateBack({});
}, 2000)
return;
}
wx.showToast({
title: "缴费失败"+res.data.msg,
icon: 'none',
duration: 2000
});
},
fail: function(e) {
wx.hideLoading();
wx.showToast({
title: "服务器异常了",
icon: 'none',
duration: 2000
});
}
});
}

View File

@ -170,6 +170,27 @@ export function refreshUserOpenId(_objData){
})
}
export function getWechatMiniOpenId(_objData){
return new Promise((resolve, reject) => {
requestNoAuth({
url: url.getWechatMiniOpenId,
method: "GET",
data: _objData, //动态数据
success: function(res) {
if (res.statusCode == 200) {
resolve(res.data);
return;
}
reject();
},
fail: function(e) {
reject();
}
});
})
}
/**
* 刷新用户
* @param {Object} _objData
@ -243,5 +264,22 @@ export function generatorUserQrCode( _that) {
})
}
export function getCommunityWechatAppId(_objData){
return new Promise((resolve, reject) => {
requestNoAuth({
url: url.getCommunityWechatAppId,
method: "GET",
data: _objData, //动态数据
success: function(res) {
if (res.statusCode == 200) {
resolve(res.data);
return;
}
reject();
},
fail: function(e) {
reject();
}
});
})
}

View File

@ -80,6 +80,7 @@
storeId: '',
receivableAmount: 0,
customFee: 'OFF',
createStaffId:'',
feeIds: []
};
},
@ -88,6 +89,7 @@
this.ownerId = _param.ownerId;
this.communityId = _param.communityId;
this.customFee = _param.customFee;
this.createStaffId = _param.createStaffId;
let _that = this;
_that.feeIds = [];
getQrcodeOweFees(this, {
@ -130,7 +132,7 @@
uni.setStorageSync('doing_cashier',_objData);
uni.navigateTo({
url:'/pages/fee/cashier?money='+this.receivableAmount+"&business=oweFee&communityId="+this.communityId
url:'/pages/fee/cashier?money='+this.receivableAmount+"&business=oweFee&communityId="+this.communityId+"&cashierUserId="+this.createStaffId
})
},

View File

@ -57,11 +57,11 @@
src: this.imgUrl + '/h5/images/serve/1.png',
href: '/pages/fee/oweFee'
},
{
name: '二维码交费',
src: this.imgUrl+'/h5/images/serve/1.png',
href: '/pages/fee/payQrCode?communityId=2023052267100146&pfqId=102023090599200004'
},
// {
// name: '',
// src: this.imgUrl+'/h5/images/serve/1.png',
// href: '/pages/fee/payQrCode?communityId=2023052267100146&pfqId=102023090599200004'
// },
{
name: '房屋费',
src: this.imgUrl + '/h5/images/serve/5.png',

View File

@ -214,6 +214,11 @@ export default {
getQrcodeOwner: baseUrl + "app/owner.getQrcodeOwner",
getQrcodeOweFees: baseUrl + "app/payFeeQrcode.getQrcodeOweFees",
getOpenIdByCode: baseUrl + "app/wechat.getOpenIdByCode",
getWechatMiniOpenId: baseUrl + "app/wechat.getWechatMiniOpenId",
getCommunityWechatAppId: baseUrl + "app/wechat.getCommunityWechatAppId",
cashier: baseUrl + "app/payment.cashier",

View File

@ -20,11 +20,17 @@
} from '../../lib/java110/utils/StringUtil.js';
import {
refreshUserOpenId,
getOpenIdFromAliPay
getOpenIdFromAliPay,
getWechatMiniOpenId,
getCommunityWechatAppId
} from '../../api/user/userApi.js';
import {
isWxOrAli
} from '../../lib/java110/utils/EnvUtil.js';
import {
cashierPayFee
} from '../../api/fee/feeApi.js';
export default {
data() {
@ -33,7 +39,10 @@
money: 0.0,
business: '',
openId: '',
data: {}
appId:'',
data: {},
appId:'',
cashierUserId:'',
}
},
mounted() {
@ -49,6 +58,7 @@
onLoad(options) {
this.openId = options.openId;
this.communityId = options.communityId;
this.cashierUserId = options.cashierUserId;
if (!isNotNull(this.openId)) {
// openId
@ -63,15 +73,30 @@
// #endif
// #ifdef MP-WEIXIN
this.openId = this._refreshWechatMiniOpenId();
this._refreshWechatMiniOpenId();
// #endif
}
this.money = options.money;
this.business = options.business;
this.data = uni.getStorageSync('doing_cashier');
this._loadAppId();
},
methods: {
_loadAppId:function(){
let _objType = "1100"; // todo public
// #ifdef MP-WEIXIN
_objType = "1000";
// #endif
let _that = this;
getCommunityWechatAppId({
communityId:this.communityId,
objType:_objType
}).then(_data =>{
_that.appId = _data.data;
})
},
_refreshWechatOpenId: function() {
let _redirectUrl = window.location.href;
refreshUserOpenId({
@ -86,11 +111,53 @@
});
},
_refreshWechatMiniOpenId:function(){
let _that =this;
wx.login({
success: function(loginRes) {
if (!loginRes.code) {
return;
}
let accountInfo = uni.getAccountInfoSync();
let appId = accountInfo.miniProgram.appId;
getWechatMiniOpenId({
code:loginRes.code,
appId:appId,
}).then(_data =>{
if(_data.code != 0){
uni.showToast({
icon:'none',
title:_data.msg
})
return;
}
_that.openId = _data.data;
})
},
fail: function(error) {
// wx.login
console.log('调用wx.login获取code失败');
console.log(error);
}
});
},
_submit: function() {
}
if(!this.appId){
uni.showToast({
icon:'none',
title:'小区未配置支付信息'
});
return;
}
let _data = this.data;
_data.business = this.business;
_data.tradeType = 'JSAPI';
_data.appId = this.appId;
_data.cashierUserId = this.cashierUserId;
_data.openId = this.openId;
cashierPayFee(this,_data)
},
}
}

View File

@ -11,8 +11,8 @@
</view>
</scroll-view>
<view v-if="active == 0" class="margin-top">
<qr-code-owe-fee ref="qrCodeOweFeeRef"></qr-code-owe-fee>
<view v-show="active == 0" class="margin-top">
<qr-code-owe-fee ref="qrCodeOweFeeRef" ></qr-code-owe-fee>
</view>
</view>
@ -51,7 +51,6 @@
this.pfqId = options.pfqId;
this.communityId = options.communityId;
this._loadConfig();
},
methods: {
_loadConfig:function(){
@ -70,7 +69,8 @@
this.$refs.qrCodeOweFeeRef._loadFees({
ownerId:this.ownerId,
communityId:this.communityId,
customFee:this.config.customFee
customFee:this.config.customFee,
createStaffId:this.config.createStaffId
});
return;
}