diff --git a/property-uniapp-project/App.vue b/property-uniapp-project/App.vue index 2d2b101..0d1d503 100644 --- a/property-uniapp-project/App.vue +++ b/property-uniapp-project/App.vue @@ -1,6 +1,10 @@ diff --git a/property-uniapp-project/manifest.json b/property-uniapp-project/manifest.json index 75f1741..2ea6bc5 100644 --- a/property-uniapp-project/manifest.json +++ b/property-uniapp-project/manifest.json @@ -3,7 +3,7 @@ "appid" : "__UNI__29C3D60", "description" : "智慧社区居民端面向小区业主使用,支持注册、验证码、账号密码多种登录方式,提供密码找回功能,账号使用安全便捷。支持多小区切换,首页设有轮播 banner、社区公告,集成远程开门、生活缴费、在线报修、访客邀请、社区活动常用服务。全服务板块统一涵盖门禁开门、线上缴费、报修申报、访客预约、投诉反馈、问卷调研、活动报名、社区公示、一键联系物业功能。个人中心可管理房屋、住户、车位、车辆信息,支持更换手机号、修改密码、消息通知设置、版本更新及账号退出,一站式满足业主居家生活、社区服务、房产车辆管理需求,实现社区生活数字化、便捷化。", "versionName" : "1.0.1", - "versionCode" : 109, + "versionCode" : 111, "transformPx" : false, "uniCloud" : { "provider" : "aliyun", @@ -172,6 +172,7 @@ "setting" : { "urlCheck" : false }, + "navigateToMiniProgramAppIdList" : [ "00004951" ], "requiredPrivateInfos" : [ "chooseLocation", "getLocation" ], "permission" : { "scope.camera" : { diff --git a/property-uniapp-project/pageSubPack/api/request.js b/property-uniapp-project/pageSubPack/api/request.js index b6ddabe..c55bce2 100644 --- a/property-uniapp-project/pageSubPack/api/request.js +++ b/property-uniapp-project/pageSubPack/api/request.js @@ -8,10 +8,10 @@ if (process.env.NODE_ENV === 'development') { export default function request(url, data = {}, method = "GET") { return new Promise((resolve, reject) => { - uni.showLoading({ - title: '请求中...', - mask: true - }); + // uni.showLoading({ + // title: '请求中...', + // mask: true + // }); uni.request({ url: baseUrl + url, @@ -23,7 +23,7 @@ export default function request(url, data = {}, method = "GET") { 'content-type': 'application/json' }, success: (res) => { - uni.hideLoading(); + // uni.hideLoading(); // HTTP 失败 if (res.statusCode !== 200) { @@ -54,7 +54,7 @@ export default function request(url, data = {}, method = "GET") { } }, fail: (err) => { - uni.hideLoading(); + // uni.hideLoading(); reject({ msg: '网络异常', code: -1, raw: err }); } }); diff --git a/property-uniapp-project/pageSubPack/loginSub/pwd-login.vue b/property-uniapp-project/pageSubPack/loginSub/pwd-login.vue index 06ddb4d..e96f96a 100644 --- a/property-uniapp-project/pageSubPack/loginSub/pwd-login.vue +++ b/property-uniapp-project/pageSubPack/loginSub/pwd-login.vue @@ -205,7 +205,7 @@ const doLogin = () => { setTimeout(() =>{ uni.switchTab({ url: '/pages/index/index' - },1000); + },2000); }) }else{ uni.showToast({ title: res.msg, icon: 'error' }); diff --git a/property-uniapp-project/pageSubPack/my/myParkingSpaceIndex.vue b/property-uniapp-project/pageSubPack/my/myParkingSpaceIndex.vue index 7b3e1f9..0a33685 100644 --- a/property-uniapp-project/pageSubPack/my/myParkingSpaceIndex.vue +++ b/property-uniapp-project/pageSubPack/my/myParkingSpaceIndex.vue @@ -37,7 +37,7 @@ 车位状态 - {{ item.parkingStatus }} + {{ getParkingStatus(item.parkingStatus) }} @@ -94,6 +94,18 @@ const pageNum = ref(1) const pageSize = ref(10) + + // 车位状态映射 + const getParkingStatus =(status) =>{ + const statusMap = { + '0':'闲置', + '1':'自用', + '2':'租赁', + '3':'借出', + '4':'其他' + } + return statusMap[status] + } // ==================== 获取列表数据 ==================== const getList = async () => { // 防重复请求 diff --git a/property-uniapp-project/pageSubPack/my/settingIndex.vue b/property-uniapp-project/pageSubPack/my/settingIndex.vue index 7ff694c..79f6e0a 100644 --- a/property-uniapp-project/pageSubPack/my/settingIndex.vue +++ b/property-uniapp-project/pageSubPack/my/settingIndex.vue @@ -70,12 +70,12 @@ title: '注销账号', type: 'arrow' }, - { - title: '升级版本', - type: 'text', - value: '当前版本 1.0.0', - valueClass: 'item-version' - } + // { + // title: '升级版本', + // type: 'text', + // value: '当前版本 1.0.0', + // valueClass: 'item-version' + // } ]) // 格式化字节大小 @@ -165,8 +165,8 @@ const checkVersionUpdate = async () => { uni.showLoading({ title: '检查中...', mask: true }) // #ifdef APP-PLUS - // const channel = plus.runtime.channel; // 云打包自动写入,自定义包为空 - // const channel = 'xioami' + const channel = plus.runtime.channel; // 云打包自动写入,自定义包为空 + // const channel = 'xiaomi' // console.log('channel',channel) // #endif @@ -174,8 +174,7 @@ const systemInfo = uni.getSystemInfoSync() const platform = systemInfo.platform === 'android' ? 'android':'ios' const appChannel = 'resident' - const channel = 'xiaomi' - // const channel = plus.runtime.channel; + // const channel = 'xiaomi' // 1. 查询最新版本 const versionRes = await getAppVersion(platform, channel, appChannel) @@ -299,6 +298,10 @@ }); authLogout().then(res => { if (res.code === 200) { + // 清除本地登录凭证 + uni.removeStorageSync('token'); + uni.removeStorageSync('userId'); + uni.removeStorageSync('currentVillageId'); uni.hideLoading(); uni.showToast({ title: '退出成功', @@ -306,22 +309,30 @@ }); setTimeout(() => { uni.hideLoading(); - uni.redirectTo({ + uni.reLaunch({ url: '/pageSubPack/loginSub/pwd-login' }); }, 1500); } else { - uni.showToast({ - title: `${res.msg}`, - icon: 'error' + // 即使服务端返回失败,也清除本地数据并跳转登录页 + uni.removeStorageSync('token'); + uni.removeStorageSync('userId'); + uni.removeStorageSync('currentVillageId'); + uni.hideLoading(); + uni.reLaunch({ + url: '/pageSubPack/loginSub/pwd-login' }); } }).catch(err => { console.log(err); - uni.showToast({ - title: err.msg, - icon: 'error' + // 网络异常时也清除本地数据并跳转登录页 + uni.removeStorageSync('token'); + uni.removeStorageSync('userId'); + uni.removeStorageSync('currentVillageId'); + uni.hideLoading(); + uni.reLaunch({ + url: '/pageSubPack/loginSub/pwd-login' }); }) diff --git a/property-uniapp-project/pageSubPack/payment-list/arrearsPayment.vue b/property-uniapp-project/pageSubPack/payment-list/arrearsPayment.vue index c268649..ac3afae 100644 --- a/property-uniapp-project/pageSubPack/payment-list/arrearsPayment.vue +++ b/property-uniapp-project/pageSubPack/payment-list/arrearsPayment.vue @@ -135,9 +135,14 @@ // 检查是否有从日照银行小程序返回的支付结果 if (options && options.referrerInfo && options.referrerInfo.extraData) { const extraData = options.referrerInfo.extraData - if (extraData.payResult === 'success') { - currentStep.value = 2 + if (extraData.retCode === 'SUCCESS') { sendPaySuccessPush() + uni.redirectTo({ + url: '/pageSubPack/payment-list/addPaymentSuccess?type=pay' + }) + return + } else if (extraData.retCode === 'FAIL') { + uni.showToast({ title: extraData.retMsg || '支付失败', icon: 'none' }) return } } @@ -145,7 +150,9 @@ const paySuccess = uni.getStorageSync('paySuccess') if (paySuccess) { uni.removeStorageSync('paySuccess') - currentStep.value = 2 + uni.redirectTo({ + url: '/pageSubPack/payment-list/addPaymentSuccess?type=pay' + }) } }) @@ -174,65 +181,122 @@ } // 立即缴费 — 通过微信拉起日照银行小程序进行支付 - const handlePay = async () => { - if (!payNum.value || Number(payNum.value) <= 0) { - uni.showToast({ - title: '请输入正确的缴费金额', - icon: 'none' - }) - return - } - - try { - uni.showLoading({ title: '加载中...' }) - - // 设备类型映射:电费→1(电表),水费→2(水表) - const deviceTypeMap = { '电费': '1', '水费': '2' } - const mappedDeviceType = deviceTypeMap[paymentItem.type] || paymentItem.deviceType || '' - - const res = await getBankMiniProgramParams({ - acct: uni.getStorageSync('userId'), // 用户userId - orderType: '20', // 水电费等手输金额 - orderAmount: String(Math.round(Number(payNum.value) * 100)), // 金额,单位:分 - deviceCode: paymentItem.deviceCode || '', - deviceType: mappedDeviceType, // 1-电表,2-水表 - billId: paymentItem.billId || '', // 账单明细ID - residentUserId: uni.getStorageSync('userId'), - goodName: paymentItem.name || '' // 商品名称 - }) - - uni.hideLoading() - - if (res.code !== 200 || !res.data) { - uni.showToast({ title: res.msg || '获取支付参数失败', icon: 'none' }) + const handlePay = async () => { + if (!payNum.value || Number(payNum.value) <= 0) { + uni.showToast({ + title: '请输入正确的缴费金额', + icon: 'none' + }) return } - console.log('resres返回数据',res) - console.log('resres',res.data) - const { appId, path, extraData } = res.data + try { + uni.showLoading({ title: '加载中...' }) - uni.navigateToMiniProgram({ - appId: appId, - path: path || '', - extraData: extraData || {}, - envVersion: 'release', - success: () => { - console.log('成功拉起日照银行小程序') - }, - fail: (err) => { - console.error('拉起日照银行小程序失败', err) - uni.showToast({ title: err.msg ||'拉起支付小程序失败', icon: 'none' }) + // 设备类型映射:电费→1(电表),水费→2(水表) + const deviceTypeMap = { '电费': '1', '水费': '2' } + const mappedDeviceType = deviceTypeMap[paymentItem.type] || paymentItem.deviceType || '' + + const res = await getBankMiniProgramParams({ + acct: uni.getStorageSync('userId'), + orderType: '20', + orderAmount: String(Math.round(Number(payNum.value) * 100)), + deviceCode: paymentItem.deviceCode || '', + deviceType: mappedDeviceType, + billId: paymentItem.billId || '', + residentUserId: uni.getStorageSync('userId'), + goodName: paymentItem.name || '' + }) + + uni.hideLoading() + + if (res.code !== 200 || !res.data) { + uni.showToast({ title: res.msg || '获取支付参数失败', icon: 'none' }) + return } - }) - } catch (err) { - uni.hideLoading() - console.error('获取支付参数异常', err) - uni.showToast({ title: err.msg || '请求异常,请重试', icon: 'none' }) - } - } + console.log('resres返回数据', res) + console.log('resres', res.data) - // 缴费成功推送通知 + const { appId, path, extraData } = res.data + console.log('navigateToMiniProgram参数:', { appId, path, extraData }) + + // 校验必要参数 + if (!appId) { + console.error('缺少appId,无法拉起支付小程序', res.data) + uni.showToast({ title: '获取支付参数失败:缺少appId', icon: 'none' }) + return + } + + // 解析 extraData(后端返回可能是字符串或对象) + // ' let extraDataObj = extraData + // if (typeof extraData === 'string') { + // try { + // extraDataObj = JSON.parse(extraData) + // } catch (e) { + // console.error('extraData JSON解析失败,使用空对象', e) + // extraDataObj = {} + // } + // } + // if (!extraDataObj || typeof extraDataObj !== 'object') { + // extraDataObj = {} + // }' + + // #ifdef APP-PLUS + // 原生App:通过微信SDK拉起小程序 + plus.share.getServices((services) => { + const weixin = services.find(s => s.id === 'weixin') + if (!weixin) { + uni.showToast({ title: '未检测到微信客户端', icon: 'none' }) + return + } + if (!weixin.launchMiniProgram) { + uni.showToast({ title: '当前微信版本太低,不支持拉起小程序', icon: 'none' }) + return + } + weixin.launchMiniProgram({ + id: appId, + type: 1, // 0=正式版 1=测试版 2=预览版 + path: path || '', + extraData: extraData + }, (res) => { + if (res.retCode === 'SUCCESS') { + console.log('成功拉起日照银行小程序(App)', res.retCode) + } else { + console.log('拉起日照银行小程序返回失败(App======)', res.retMsg) + } + + console.log('日照银行小程序回调结果(App)', JSON.stringify(res)) + }, (err) => { + console.error('拉起日照银行小程序失败(App)', JSON.stringify(err)) + uni.showToast({ title: '拉起支付小程序失败', icon: 'none' }) + }) + }) + // #endif + + // #ifdef MP-WEIXIN + // 微信小程序:直接navigateToMiniProgram + uni.navigateToMiniProgram({ + appId: appId, + path: path || '', + extraData: extraData, + envVersion: 'develop', + success: () => { + console.log('成功拉起日照银行小程序(微信)') + }, + fail: (err) => { + console.error('拉起日照银行小程序失败(微信)', JSON.stringify(err)) + uni.showToast({ title: err.errMsg || err.msg || '拉起支付小程序失败', icon: 'none' }) + } + }) + // #endif + } catch (err) { + uni.hideLoading() + console.error('获取支付参数异常', err) + uni.showToast({ title: err.msg || '请求异常,请重试', icon: 'none' }) + } + } + +// 缴费成功推送通知 const sendPaySuccessPush = () => { const userId = uni.getStorageSync('userId') if (userId) { @@ -709,4 +773,4 @@ width: 100vw; height: 46px; } - \ No newline at end of file + diff --git a/property-uniapp-project/pageSubPack/payment-list/paymentIndex.vue b/property-uniapp-project/pageSubPack/payment-list/paymentIndex.vue index d67bb9d..5b64d55 100644 --- a/property-uniapp-project/pageSubPack/payment-list/paymentIndex.vue +++ b/property-uniapp-project/pageSubPack/payment-list/paymentIndex.vue @@ -151,13 +151,13 @@ // iconClass: "gas" // }, { - name: "水费", + name: "水表", type: "water", icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/water.png", iconClass: "water" }, { - name: "电费", + name: "电表", type: "electric", icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/electric.png", iconClass: "electric" @@ -213,7 +213,7 @@ onReady(() => {}) onLoad(() => { - postOpenId() + // postOpenId() uni.hideTabBar({ animation: false // 关闭动画,更稳定 }); @@ -269,7 +269,7 @@ uni.redirectTo({ url: '/pageSubPack/payment-list/selectPaymentEntity' }) - } else if (type.name == '水费' || type.name == '电费') { + } else if (type.name == '水表' || type.name == '电表') { uni.redirectTo({ url: '/pageSubPack/payment-list/addHydropower' }) diff --git a/property-uniapp-project/pageSubPack/payment-list/propertyFeePayment.vue b/property-uniapp-project/pageSubPack/payment-list/propertyFeePayment.vue index 9c7fc41..2ab3b48 100644 --- a/property-uniapp-project/pageSubPack/payment-list/propertyFeePayment.vue +++ b/property-uniapp-project/pageSubPack/payment-list/propertyFeePayment.vue @@ -83,6 +83,9 @@ import { getPushSingle } from '/pageSubPack/api/api.js' + import { + getBankMiniProgramParams + } from '/pageSubPack/api/apiSub.js' // 响应式数据 const outstandingPayment = ref(true) @@ -106,11 +109,30 @@ }) // 从支付收银台返回时检查支付结果 - onShow(() => { + onShow((options) => { + // 检查是否有从日照银行小程序返回的支付结果 + if (options && options.referrerInfo && options.referrerInfo.extraData) { + const extraData = options.referrerInfo.extraData + if (extraData.retCode === 'SUCCESS') { + currentStep.value = 2 + sendPaySuccessPush() + uni.redirectTo({ + url: '/pageSubPack/payment-list/addPaymentSuccess?type=pay' + }) + return + } else if (extraData.retCode === 'FAIL') { + uni.showToast({ title: extraData.retMsg || '支付失败', icon: 'none' }) + return + } + } + const paySuccess = uni.getStorageSync('paySuccess') if (paySuccess) { uni.removeStorageSync('paySuccess') - currentStep.value = 2 + uni.redirectTo({ + url: '/pageSubPack/payment-list/addPaymentSuccess?type=pay' + }) + // currentStep.value = 2 } }) @@ -130,21 +152,110 @@ }); } - // 立即缴费 — 跳转到支付收银台选择支付方式 - const handlePay = () => { - // 优先使用用户输入金额,否则使用页面展示的应缴金额 - const amount = payAmount.value - uni.setStorageSync('payData', { - amount: String(amount), - deviceCode: paymentItem.deviceCode, - type: paymentItem.type, - name: paymentItem.name, - fullAddress: paymentItem.fullAddress - }) - // uni.navigateTo({ url: '/pageSubPack/payment-list/yinlianPayTn' }) - } + // 立即缴费 — 通过微信拉起日照银行小程序进行支付 + const handlePay = async () => { - // 缴费成功推送通知 + try { + uni.showLoading({ title: '加载中...' }) + + // 设备类型映射:物业费→3,车位费→4,垃圾处理费→5 + const deviceTypeMap = { '物业费': '3', '车位费': '4', '垃圾处理费': '5' } + const mappedDeviceType = deviceTypeMap[switchStatus(paymentItem.type)] || '' + + const res = await getBankMiniProgramParams({ + acct: uni.getStorageSync('userId'), + orderType: '20', + orderAmount: String(Math.round(Number(payAmount.value) * 100)), + deviceCode: paymentItem.deviceCode || '', + deviceType: mappedDeviceType, + billId: paymentItem.billId || '', + residentUserId: uni.getStorageSync('userId'), + goodName: paymentItem.name || '' + }) + + uni.hideLoading() + + if (res.code !== 200 || !res.data) { + uni.showToast({ title: res.msg || '获取支付参数失败', icon: 'none' }) + return + } + console.log('resres返回数据', res) + console.log('resres', res.data) + + const { appId, path, extraData } = res.data + console.log('navigateToMiniProgram参数:', { appId, path, extraData }) + + // 校验必要参数 + if (!appId) { + console.error('缺少appId,无法拉起支付小程序', res.data) + uni.showToast({ title: '获取支付参数失败:缺少appId', icon: 'none' }) + return + } + + // 解析 extraData(后端返回可能是字符串或对象) + let extraDataObj = extraData + if (typeof extraData === 'string') { + try { + extraDataObj = JSON.parse(extraData) + } catch (e) { + console.error('extraData JSON解析失败,使用空对象', e) + extraDataObj = {} + } + } + if (!extraDataObj || typeof extraDataObj !== 'object') { + extraDataObj = {} + } + + // #ifdef APP-PLUS + // 原生App:通过微信SDK拉起小程序 + plus.share.getServices((services) => { + const weixin = services.find(s => s.id === 'weixin') + if (!weixin) { + uni.showToast({ title: '未检测到微信客户端', icon: 'none' }) + return + } + if (!weixin.launchMiniProgram) { + uni.showToast({ title: '当前微信版本太低,不支持拉起小程序', icon: 'none' }) + return + } + weixin.launchMiniProgram({ + id: appId, + type: 0, // 0=正式版 1=测试版 2=预览版 + path: path || '', + extraData: extraDataObj + }, () => { + console.log('成功拉起日照银行小程序(App)') + }, (err) => { + console.error('拉起日照银行小程序失败(App)', JSON.stringify(err)) + uni.showToast({ title: '拉起支付小程序失败', icon: 'none' }) + }) + }) + // #endif + + // #ifdef MP-WEIXIN + // 微信小程序:直接navigateToMiniProgram + uni.navigateToMiniProgram({ + appId: appId, + path: path || '', + extraData: extraDataObj, + envVersion: 'develop', + success: () => { + console.log('成功拉起日照银行小程序(微信)') + }, + fail: (err) => { + console.error('拉起日照银行小程序失败(微信)', JSON.stringify(err)) + uni.showToast({ title: err.errMsg || err.msg || '拉起支付小程序失败', icon: 'none' }) + } + }) + // #endif + } catch (err) { + uni.hideLoading() + console.error('获取支付参数异常', err) + uni.showToast({ title: err.msg || '请求异常,请重试', icon: 'none' }) + } + } + +// 缴费成功推送通知 const sendPaySuccessPush = () => { const userId = uni.getStorageSync('userId') if (userId) { @@ -631,4 +742,4 @@ width: 100vw; height: 46px; } - \ No newline at end of file + diff --git a/property-uniapp-project/pages/navigation/navigation.vue b/property-uniapp-project/pages/navigation/navigation.vue index d905d52..50320ea 100644 --- a/property-uniapp-project/pages/navigation/navigation.vue +++ b/property-uniapp-project/pages/navigation/navigation.vue @@ -95,13 +95,19 @@ const handleBtnClick = () => { // 防重复跳转:已触发过跳转则直接返回 if (isNavigating.value) return; isNavigating.value = true; - // 立即体验,跳转登录页 - // 1. 记录引导已完成 + // 记录引导已完成 uni.setStorageSync('hasShowGuide', true); - // 2. 跳转登录页 - uni.redirectTo({ - url: "/pageSubPack/loginSub/pwd-login" - }) + // 检查是否已有登录 token,有则直接进首页,否则跳转登录页 + const token = uni.getStorageSync('token'); + if (token) { + uni.switchTab({ + url: '/pages/index/index' + }) + } else { + uni.redirectTo({ + url: "/pageSubPack/loginSub/pwd-login" + }) + } } };