From 633ea492f7f6c6e48b096bc920fae2563ef31d2f Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 7 Sep 2023 11:52:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BA=8C=E7=BB=B4=E7=A0=81?= =?UTF-8?q?=E4=BA=A4=E8=B4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/fee/feeApi.js | 84 +++++++++++++++++++++++-- api/user/userApi.js | 42 ++++++++++++- components/fee/qrcode-owe-fee.vue | 4 +- components/service/service-property.vue | 10 +-- constant/url.js | 5 ++ pages/fee/cashier.vue | 79 +++++++++++++++++++++-- pages/fee/payQrCodeFee.vue | 8 +-- 7 files changed, 208 insertions(+), 24 deletions(-) diff --git a/api/fee/feeApi.js b/api/fee/feeApi.js index 5f16265..e624f08 100644 --- a/api/fee/feeApi.js +++ b/api/fee/feeApi.js @@ -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 + }); + } + }); + +} diff --git a/api/user/userApi.js b/api/user/userApi.js index 242ecf9..3ae26bd 100644 --- a/api/user/userApi.js +++ b/api/user/userApi.js @@ -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(); + } + }); + }) +} diff --git a/components/fee/qrcode-owe-fee.vue b/components/fee/qrcode-owe-fee.vue index 2b375a7..ee7ddb2 100644 --- a/components/fee/qrcode-owe-fee.vue +++ b/components/fee/qrcode-owe-fee.vue @@ -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 }) }, diff --git a/components/service/service-property.vue b/components/service/service-property.vue index eb6dccd..5d3ccce 100644 --- a/components/service/service-property.vue +++ b/components/service/service-property.vue @@ -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', diff --git a/constant/url.js b/constant/url.js index 7373199..df6aec5 100644 --- a/constant/url.js +++ b/constant/url.js @@ -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", + + diff --git a/pages/fee/cashier.vue b/pages/fee/cashier.vue index 68cae2c..2e77f7c 100644 --- a/pages/fee/cashier.vue +++ b/pages/fee/cashier.vue @@ -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) + }, + } } diff --git a/pages/fee/payQrCodeFee.vue b/pages/fee/payQrCodeFee.vue index 4ed2ad7..1682c6c 100644 --- a/pages/fee/payQrCodeFee.vue +++ b/pages/fee/payQrCodeFee.vue @@ -11,8 +11,8 @@ - - + + @@ -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; }