diff --git a/api/v2local.js b/api/v2local.js index 1f0cb839..8e17092c 100644 --- a/api/v2local.js +++ b/api/v2local.js @@ -13,5 +13,7 @@ export const apiArr = { getPayList:"/api/v2/wechat/quick-payment-record-crud/page", //支付记录 getUserPoints:"/api/v2/wechat/member-points-flow-crud/main",//获取用户积分 getPointsList:"/api/v2/wechat/member-points-flow-crud/page", //积分记录 + createPay:"/api/v2/wechat/quick-payment-record-crud/creat",//创建支付信息 + getPayInfo:"/api/v2/wechat/quick-payment-record-crud/info" }; diff --git a/packages/localLife/pay/index.vue b/packages/localLife/pay/index.vue index 80271cc4..94f06162 100644 --- a/packages/localLife/pay/index.vue +++ b/packages/localLife/pay/index.vue @@ -41,7 +41,7 @@
- 惠生活42#2单元2层202号 + {{ room_name }}
@@ -68,8 +68,8 @@ - +
@@ -93,6 +93,7 @@ import { apiArr } from '../../../api/v2local'; +import { apiPay } from '../../../api/pay' export default { data() { @@ -103,12 +104,15 @@ export default { info: "", integral: 0, homeMoney: 0, - commintyList: [], Money: "", show: false, - remarks:"", - room_id:"", - boxShow:false + remarks: "", + room_id: "", + room_name: "", + boxShow: false, + commintyList: [], + OrderMsg: "", + payId:"" } }, watch: { @@ -129,13 +133,23 @@ export default { methods: { - // - changeBoxshadow(){ + + changeBoxshadow() { this.boxShow = !this.boxShow }, + + confirm(e) { + console.log(e); + this.room_id = e.value[0].room_id + this.room_name = e.value[0].label + this.show = false + }, + onClose() { + this.show = false + }, //选择房源 choseComminty() { - + this.show = true }, back() { NavgateTo("1") @@ -145,38 +159,95 @@ export default { page_num: 1, page_size: 30, }).then(res => { + res.rows.forEach(item => { + item.label = item.name + }) this.commintyList = res.rows + if (res.rows.length) { + this.room_id = res.rows[0].room_id + this.room_name = res.rows[0].name + } }) }, pay() { let that = this - if(!that.Money){ + if (!that.Money) { return uni.showToast({ - title:"请输入金额", - icon:"none" + title: "请输入金额", + icon: "none" }) } request(apiArr.createPay, "POST", { - merchant_id:that.info.id, - order_amount:that.Money, //金额 - refund_property_fee:that.homeMoney, //物业费 - refund_member_points:that.integral, //积分 - remark:that.remarks, - room_id:that.room_id - }).then(res=>{ - console.log(res); + merchant_id: that.info.id, + order_amount: that.Money, //金额 + refund_property_fee: that.homeMoney, //物业费 + refund_member_points: that.integral, //积分 + remark: that.remarks, + room_id: that.room_id + }).then(res => { + that.payId = res.id + that.getPayInfo(res.id) }) }, - payList(){ + payList() { NavgateTo("../payInfo/index") }, - homeMoneList(){ + homeMoneList() { NavgateTo("../houseProvident/index") }, - home(){ + home() { NavgateTo("/pages/index/index") - } + }, + + async getPayInfo(e) { + let that = this + await request(apiArr.getPayInfo, "POST", { + id: e + }).then(res => { + console.log(res); + this.OrderMsg = res + + that.LakaLaPrePay() + }) + }, + + async LakaLaPrePay() { + let that = this + request(apiPay.pay, "POST", { + total_amount: that.OrderMsg.order_amount, + subject: '快捷支付订单', + goods_id: that.payId, + address: "", + out_trade_no: that.OrderMsg.term_no, + remark: that.OrderMsg.remark, + quantity: '1', + user: uni.getStorageSync('userId'), + user_id: uni.getStorageSync('openId') + }).then(res => { + console.log(res,'res'); + + const { resp_data, msg } = res.data + + wx.requestPayment({ + timeStamp: String(resp_data.acc_resp_fields.time_stamp), + nonceStr: String(resp_data.acc_resp_fields.nonce_str), + package: String(resp_data.acc_resp_fields.package), + signType: String(resp_data.acc_resp_fields.sign_type), + paySign: String(resp_data.acc_resp_fields.pay_sign), + success(res) { + that.queryPay() + }, + fail(fal) { + if (fal.errMsg == 'requestPayment:fail cancel') { + that.payFail(2) + } else { + that.payFail(1) + } + } + }) + }) + }, }, diff --git a/packages/localLife/payInfo/index.vue b/packages/localLife/payInfo/index.vue index 6dbd6413..9863fe7d 100644 --- a/packages/localLife/payInfo/index.vue +++ b/packages/localLife/payInfo/index.vue @@ -1,44 +1,47 @@