diff --git a/api/index.js b/api/index.js index 17c2d56..f9d49e2 100644 --- a/api/index.js +++ b/api/index.js @@ -19,7 +19,6 @@ export function getProcessingCheckOutInfo(pamars) { export function checkoutConfirm(pamars) { return fly.post(`/bysmp/checkout/confirm`,pamars) } - //新增入住评价 export function evaluateAdd(data) { return fly.post(`/bysmp/evaluate/add`,data) @@ -36,3 +35,16 @@ export function selectMzGraduateInfo(pamars) { export function eSignDownload(pamars) { return fly.get(`/eSign/download/${pamars.bizId}`,{signType:pamars.signType}) } +// 获取待签合同(续期申请) +export function getContractToBeSigned(pamars) { + return fly.get(`/bysmp/renewal/getContractToBeSigned`,pamars) +} +// 获取支付参数 +export function pay(data) { + return fly.post(`/bysmp/wx/pay`,data) +} +// 获取支付情况 +export function paySuccess(pamars) { + return fly.get(`/bysmp/wx/paySuccess`,pamars) +} + diff --git a/pages/index/index.js b/pages/index/index.js index 9065be8..671c488 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -140,6 +140,7 @@ Page({ getUserInfo(){ getUserInfo().then(res=>{ // 有身份证号直接去信息确认没有的话就去识别身份证信息 + app.globalData.userInfo = res.data; if(res.data.idCard){ wx.navigateTo({ url: `/subpages/index/checkInUser/checkInUser?idCard=${res.data.idCard}`, diff --git a/pages/mine/mine.js b/pages/mine/mine.js index 18ffb37..0d6db71 100644 --- a/pages/mine/mine.js +++ b/pages/mine/mine.js @@ -45,6 +45,7 @@ Page({ statusHeight: app.globalData.deviceInfo.statusHeight, navigationHeight: app.globalData.deviceInfo.navigationHeight, }); + this.getUserInfo() }, // 跳转到修改信息页 goToEdit() { @@ -115,8 +116,8 @@ Page({ }, getUserInfo(){ getUserInfo().then(res=>{ - if(res.code ===200 && data){ - app.globalData.userInfo = res.data + if(res.code ===200 && res.data){ + app.globalData.userInfo = res.data; this.setData({ registerFlag:false }) diff --git a/subpages/OCRCard/pages/deposit/deposit.js b/subpages/OCRCard/pages/deposit/deposit.js index 2667b56..81fe4a1 100644 --- a/subpages/OCRCard/pages/deposit/deposit.js +++ b/subpages/OCRCard/pages/deposit/deposit.js @@ -1,18 +1,27 @@ // subpages/OCRCard/pages/deposit/deposit.js +import { + pay, + selectMzGraduateInfo +} from "../../../../api/index" +const app = getApp() Page({ /** * 页面的初始数据 */ data: { - show: true, - status: 2 + show: false, + status: 2, + chooseRoomId: null, //选房记录ID }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { + this.setData({ + chooseRoomId: options.chooseRoomId || app.globalData.userInfo.chooseRoomId + }) }, goback() { @@ -69,9 +78,62 @@ Page({ onShareAppMessage() { }, - toCheckInRecord(){ + toCheckInRecord() { wx.navigateTo({ - url: '/subpages/mine/checkInRecord/checkInRecord', + url: '/subpages/mine/checkInRecord/checkInRecord', + }) + }, + submit() { + const that = this; + pay({ + chooseRoomId: this.data.chooseRoomId + }).then(res => { + if (res.data.code === 200) { + const { + timeStamp, + nonceStr, + paySign, + packageValue, + appId, + payId + } = res.data + wx.requestPayment({ + // 必填参数 + timeStamp, // 时间戳,从1970年1月1日00:00:00至今的秒数 + nonceStr, // 随机字符串,32位以内 + package: packageValue, // 统一下单接口返回的 prepay_id 格式如:prepay_id=xxx + signType: 'RSA', // 签名算法,固定为RSA + paySign, // 签名,使用微信支付平台证书和商户私钥生成 + // 可选参数 + appId, // 小程序/公众号的appId + // 回调函数 + success(res) { + console.log('支付成功', res); + // 支付成功后的业务逻辑 + that.paySuccess(payId) + // 可跳转到订单详情页等 + }, + fail(res) { + that.paySuccess(payId) + }, + complete(res) { + that.paySuccess(payId) + console.log('支付完成', res); + // 无论成功失败都会执行 + } + }); + } + }) + + }, + paySuccess(payId) { + paySuccess({ + payId + }).then(res => { + this.setData({ + show: true, + status: res.data ? 0 : 1 + }) }) } }) \ No newline at end of file diff --git a/subpages/index/checkInUser/checkInUser.js b/subpages/index/checkInUser/checkInUser.js index f97be61..f7550ed 100644 --- a/subpages/index/checkInUser/checkInUser.js +++ b/subpages/index/checkInUser/checkInUser.js @@ -91,17 +91,19 @@ Page({ }, submit(){ selectMzGraduateInfo({idCard:this.data.form.idCard}).then(res=>{ + console.log(res); if(res.code === 200){ this.bindIdCard() if(res.data.signType === 0){ //线上支付去跳转签合同 + app.globalData.userInfo.chooseRoomId = res.data.chooseRecId wx.navigateTo({ url: '/pages/webView/webView?url=' + encodeURIComponent(res.data.contract), }) }else if(res.data.signType === 1){ // 线下签订去支付 wx.navigateTo({ - url: '/subpages/OCRCard/pages/deposit/deposit', + url: '/subpages/OCRCard/pages/deposit/deposit?chooseRoomId=' + res.data.chooseRecId, }) }else{ wx.navigateTo({ diff --git a/subpages/index/checkInWait/checkInWait.js b/subpages/index/checkInWait/checkInWait.js index ca29d71..7ecb061 100644 --- a/subpages/index/checkInWait/checkInWait.js +++ b/subpages/index/checkInWait/checkInWait.js @@ -94,13 +94,14 @@ Page({ // }) // 线上签订合同跳转信息确认 if(res.data.signType === 0){ + app.globalData.userInfo.chooseRoomId = res.data.chooseRecId wx.navigateTo({ url: '/pages/webView/webView?url=' + encodeURIComponent(res.data.contract), }) }else if(res.data.signType === 1){ // 线下签订 wx.navigateTo({ - url: '/subpages/OCRCard/pages/deposit/deposit', + url: '/subpages/OCRCard/pages/deposit/deposit?chooseRoomId=' + res.data.chooseRecId, }) }else{ // 没有合同信息 diff --git a/subpages/index/renewalApplication/renewalApplication.js b/subpages/index/renewalApplication/renewalApplication.js index 5f06b59..15dee15 100644 --- a/subpages/index/renewalApplication/renewalApplication.js +++ b/subpages/index/renewalApplication/renewalApplication.js @@ -1,4 +1,5 @@ // subpages/index/renewalApplication/renewalApplication.js +import {getContractToBeSigned} from "../../../api/index" Page({ /** @@ -14,7 +15,7 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad(options) { - + this.getContractToBeSigned() }, // 跳转首页 submit() { @@ -69,5 +70,14 @@ Page({ */ onShareAppMessage() { + }, + getContractToBeSigned(){ + getContractToBeSigned().then(res=>{ + if(res.data.code === 1){ + wx.navigateTo({ + url: '/pages/webView/webView?url=' + encodeURIComponent(res.data.url), + }) + } + }) } }) \ No newline at end of file