银联支付集成和购买插件;修改首页小区更改后获取数据;对接我的信息接口

This commit is contained in:
zhouyanli
2026-06-04 17:42:29 +08:00
parent 4d0515e5fe
commit a8e3d1f875
11 changed files with 409 additions and 324 deletions

View File

@@ -3,7 +3,7 @@
"appid" : "__UNI__29C3D60", "appid" : "__UNI__29C3D60",
"description" : "物业用户端app", "description" : "物业用户端app",
"versionName" : "1.0.1", "versionName" : "1.0.1",
"versionCode" : "103", "versionCode" : 105,
"transformPx" : false, "transformPx" : false,
/* 5+App */ /* 5+App */
"app-plus" : { "app-plus" : {
@@ -23,7 +23,9 @@
"Camera" : {}, "Camera" : {},
"Contacts" : {}, "Contacts" : {},
"Gallery" : {}, "Gallery" : {},
"Push" : {} "Push" : {},
"Barcode" : {},
"Payment" : {}
}, },
/* */ /* */
"distribute" : { "distribute" : {
@@ -48,7 +50,8 @@
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>", "<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>", "<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.CALL_PHONE\"/>" "<uses-permission android:name=\"android.permission.CALL_PHONE\"/>"
] ],
"schemes" : ""
}, },
/* ios */ /* ios */
"ios" : { "ios" : {
@@ -56,7 +59,9 @@
"privacyDescription" : { "privacyDescription" : {
"NSPhotoLibraryUsageDescription" : "需要访问您的相册,用于选择图片上传", "NSPhotoLibraryUsageDescription" : "需要访问您的相册,用于选择图片上传",
"NSPhotoLibraryAddUsageDescription" : "保存二维码图片到相册" "NSPhotoLibraryAddUsageDescription" : "保存二维码图片到相册"
} },
"urltypes" : "uppaylyhuts",
"urlschemewhitelist" : "uppaywallet,uppaysdk,uppayx1,uppayx2,uppayx3,paesuperbank,ccbmbsylunionpay,bocom,bankabc,cmbmobilebank,cmblife,com.icbc.iphoneclient,spdbbank,spdbcccUnionPay,citicbankpay,credit,uppayxingyecredit,uppayhuaxiacredit,uppaybeijingcredit,uppayzhonghangcredit,uppayguangdacredit,uppaygonghangcredit,uppayjianhangcredit,uppayjiaohangcredit,uppayguangfa,psbccashier,uppayyouchucredit,com.cebbank.ebank,BankOfShangHai,boscgdlf,citicbankdkkj,cmbc,cibmb,bocmbankpsn,bankofbjpay,uppaynonghangcredit,uppayhuaxia,zytuppay,LZYHSJYHAUTHSSOAPP,bnbpay,dlrcb,czbank,uppayCbhb"
}, },
/* SDK */ /* SDK */
"sdkConfigs" : { "sdkConfigs" : {
@@ -89,7 +94,20 @@
"UniversalLinks" : "" "UniversalLinks" : ""
} }
}, },
"payment" : {} "payment" : {
"appleiap" : {},
"alipay" : {
"__platform__" : [ "ios", "android" ]
},
"unionpay" : {
"__platform__" : [ "ios", "android" ]
},
"weixin" : {
"__platform__" : [ "ios", "android" ],
"appid" : "",
"UniversalLinks" : ""
}
}
} }
} }
}, },

View File

@@ -136,8 +136,7 @@ export const getTopUpSelectByResident = (data) => {
} }
// 绑定设备 // 绑定设备
export const getTopUpBindDevice = (data) => { export const getTopUpBindDevice = (data) => {
return post(`/api/topUp/bindDevice/${data.deviceCode}/${data.residentUserId}/${data.openid}/${data.deviceType}`, return post(`/api/topUp/bindDevice/${data.deviceCode}/${data.residentUserId}/${data.deviceType}`, data)
data)
} }
// 充值调用 // 充值调用
// /${data.rechargeAmount}/${data.type}/${data.deviceCode} // /${data.rechargeAmount}/${data.type}/${data.deviceCode}
@@ -148,9 +147,9 @@ export const getopenIdByCode = (data) => {
return get(`/api/topUp/getOpenIdByCode?code=${data.code}`, data) return get(`/api/topUp/getOpenIdByCode?code=${data.code}`, data)
} }
// 微信支付调用 // 银联支付下单
export const getToWxPay = (data) => { export const getUnionPayTn = (data) => {
return post(`/api/topUp/wxPay/${data.orderId}/${data.openid}`, data) return post('/api/topUp/unionPay/getTn', data)
} }
// 缴费记录查询 // 缴费记录查询
export const getTopupRecordWithStat = (data) => { export const getTopupRecordWithStat = (data) => {
@@ -223,3 +222,16 @@ export const getParkingDetail = (data) => {
export const rebindCar = (data) => { export const rebindCar = (data) => {
return post(`/ResidentCarAreaManage/rebind`, data) return post(`/ResidentCarAreaManage/rebind`, data)
} }
// 查询版本信息
export const getAppVersion = (platform, channel) => {
return get(`/api/app/version/${platform}/${channel}`)
}
// 检查是否需要更新
export const checkAppUpdate = (data) => {
return post(`/api/app/checkUpdate`, data)
}
// 记录更新日志
export const postUpdateLog = (data) => {
return post(`/api/app/updateLog`, data)
}

View File

@@ -39,12 +39,14 @@
onPullDownRefresh onPullDownRefresh
} from '@dcloudio/uni-app' } from '@dcloudio/uni-app'
import { import {
authLogout, getUserProfile, getUserNotify, changeUserNotify authLogout, getUserProfile, getUserNotify, changeUserNotify, getAppVersion, checkAppUpdate, postUpdateLog
} from '/pageSubPack/api/apiSub.js' } from '/pageSubPack/api/apiSub.js'
// //
const statusBarHeight = ref(20) const statusBarHeight = ref(20)
const cacheSize = ref(0) const cacheSize = ref(0)
const currentVersion = ref('1.0.0')
const currentVersionCode = ref(1)
const settingList = ref([{ const settingList = ref([{
title: '更改手机号码', title: '更改手机号码',
type: 'text', type: 'text',
@@ -67,11 +69,142 @@
{ {
title: '升级版本', title: '升级版本',
type: 'text', type: 'text',
value: '当前版本 2.9.8', value: '当前版本 1.0.0',
valueClass: 'item-version' valueClass: 'item-version'
} }
]) ])
// 格式化字节大小
const formatSize = (bytes) => {
if (!bytes || bytes === 0) return '0B'
const k = 1024
const sizes = ['B', 'KB', 'M', 'G']
const i = Math.floor(Math.log(bytes) / Math.log(k))
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + sizes[i]
}
// 获取真实缓存大小
const getCacheSizeData = () => {
return new Promise((resolve) => {
// #ifdef APP-PLUS
// App 端获取完整缓存(含图片、文件等)
plus.cache.calculate((size) => {
resolve(formatSize(size))
})
// #endif
// #ifndef APP-PLUS
// 小程序/H5 端只能获取 storage 缓存
const info = uni.getStorageInfoSync()
const size = (info.currentSize || 0) * 1024 // currentSize 单位 KB
resolve(formatSize(size))
// #endif
})
}
// 获取当前运行版本号
const initCurrentVersion = () => {
// #ifdef APP-PLUS
currentVersion.value = plus.runtime.version || '1.0.0'
currentVersionCode.value = plus.runtime.versionCode || 1
// #endif
// #ifndef APP-PLUS
const manifest = uni.getAppAuthorizeSetting ? uni.getAppAuthorizeSetting() : null
if (manifest && manifest.version) {
currentVersion.value = manifest.version
}
// #endif
settingList.value[4].value = '当前版本 ' + currentVersion.value
}
// 版本号比较v1 > v2 返回 1v1 = v2 返回 0v1 < v2 返回 -1
const compareVersion = (v1, v2) => {
const arr1 = v1.split('.').map(Number)
const arr2 = v2.split('.').map(Number)
const len = Math.max(arr1.length, arr2.length)
for (let i = 0; i < len; i++) {
const n1 = arr1[i] || 0
const n2 = arr2[i] || 0
if (n1 > n2) return 1
if (n1 < n2) return -1
}
return 0
}
// 检查版本更新
const checkVersionUpdate = async () => {
uni.showLoading({ title: '检查中...', mask: true })
try {
const systemInfo = uni.getSystemInfoSync()
const platform = systemInfo.platform === 'ios' ? 'ios' : 'android'
const channel = 'resident'
// 1. 查询最新版本
const versionRes = await getAppVersion(platform, channel)
if (versionRes.code === 200 && versionRes.data) {
const latestVersion = versionRes.data.versionName || ''
const latestVersionCode = versionRes.data.versionCode || 0
// 2. 调 checkAppUpdate 检查是否需要更新
const checkRes = await checkAppUpdate({
platform: platform,
channel: channel,
currentVersionCode: currentVersionCode.value
})
uni.hideLoading()
if (checkRes.code === 200 && checkRes.data) {
const needUpdate = checkRes.data.needUpdate !== false
if (needUpdate) {
const updateType = checkRes.data.updateType || versionRes.data.updateType || 'optional'
const isForce = updateType === 'force'
uni.showModal({
title: isForce ? '强制更新' : '发现新版本',
content: `当前版本:${currentVersion.value}\n最新版本${latestVersion}${versionRes.data.releaseNotes || versionRes.data.updateDesc ? '\n\n更新内容' + (versionRes.data.releaseNotes || versionRes.data.updateDesc) : ''}`,
showCancel: !isForce,
confirmText: '立即更新',
cancelText: '稍后',
success: (modalRes) => {
if (modalRes.confirm && versionRes.data.downloadUrl) {
// 记录更新日志
const userId = uni.getStorageSync('userId')
if (userId) {
postUpdateLog({
userId: userId,
platform: platform,
fromVersion: currentVersionCode.value,
toVersion: latestVersionCode
})
}
// #ifdef APP-PLUS
plus.runtime.openURL(versionRes.data.downloadUrl)
// #endif
// #ifndef APP-PLUS
uni.showToast({ title: '请在应用商店更新', icon: 'none' })
// #endif
} else if (isForce && !modalRes.confirm) {
// 强制更新时用户点取消,退出应用
// #ifdef APP-PLUS
plus.runtime.quit()
// #endif
}
}
})
} else {
uni.showToast({ title: '已是最新版本', icon: 'success' })
}
} else {
uni.showToast({ title: '检查失败', icon: 'none' })
}
} else {
uni.hideLoading()
uni.showToast({ title: '检查失败', icon: 'none' })
}
} catch (err) {
uni.hideLoading()
uni.showToast({ title: '检查失败', icon: 'none' })
}
}
// //
const onItemClick = (item) => { const onItemClick = (item) => {
if (item.title == '更改手机号码') { if (item.title == '更改手机号码') {
@@ -84,7 +217,10 @@
}); });
} else if (item.title == '清除缓存') { } else if (item.title == '清除缓存') {
uni.clearStorageSync(); uni.clearStorageSync();
settingList.value[3].value = '0M' // #ifdef APP-PLUS
plus.cache.clear(() => {})
// #endif
settingList.value[3].value = '0B'
uni.showLoading({ uni.showLoading({
title: '清除中...', title: '清除中...',
mask: true mask: true
@@ -98,6 +234,8 @@
setTimeout(() => { setTimeout(() => {
uni.hideLoading(); uni.hideLoading();
}, 2500); }, 2500);
} else if (item.title == '升级版本') {
checkVersionUpdate()
} }
} }
@@ -166,7 +304,9 @@
}); });
} }
onMounted(() => { onMounted(async () => {
initCurrentVersion()
settingList.value[3].value = await getCacheSizeData()
getUserProfile().then(res => { getUserProfile().then(res => {
if (res.code === 200 && res.data) { if (res.code === 200 && res.data) {
const phone = res.data.phone || '' const phone = res.data.phone || ''

View File

@@ -124,13 +124,22 @@ const openDoorClick = () => {
// }) // })
// return // return
// } // }
getAccessOpenData() uni.showToast({
title: '正在对接硬件中...',
icon: 'none'
})
// getAccessOpenData()
} }
// 开门接口 // 开门接口
const getAccessOpenData = async () =>{ const getAccessOpenData = async () =>{
uni.showLoading({
title: '开门中...',
mask: true
})
try{ try{
let params = {deviceId:selectedDoor.value} let params = {deviceId:selectedDoor.value}
const res = await getAccessOpen(params) const res = await getAccessOpen(params)
uni.hideLoading()
if(res.code === 200){ if(res.code === 200){
uni.showToast({ uni.showToast({
title:'开门成功', title:'开门成功',
@@ -141,8 +150,9 @@ const getAccessOpenData = async () =>{
title:'开门失败', title:'开门失败',
icon:"error" icon:"error"
}) })
} }
}catch(err){ }catch(err){
uni.hideLoading()
uni.showToast({ uni.showToast({
title: err.msg || '开门失败', title: err.msg || '开门失败',
icon:"none" icon:"none"

View File

@@ -10,7 +10,7 @@
<!-- 头部物业费A标题+水滴图标 --> <!-- 头部物业费A标题+水滴图标 -->
<view class="card-header"> <view class="card-header">
<image class="iconStyle" <image class="iconStyle"
:src="paymentType=='物业费A'?'https://wuyeadmin.bugtc.com/images/propertyImgs/water.png':'https://wuyeadmin.bugtc.com/images/propertyImgs/electric.png'"> :src="paymentType=='水费'?'https://wuyeadmin.bugtc.com/images/propertyImgs/water.png':'https://wuyeadmin.bugtc.com/images/propertyImgs/electric.png'">
</image> </image>
<text class="card-title">{{paymentType}}</text> <text class="card-title">{{paymentType}}</text>
</view> </view>
@@ -175,10 +175,18 @@
// return // return
// } // }
const openid = uni.getStorageSync('openid') const openid = uni.getStorageSync('openid')
// if (!openid) {
// uni.hideLoading()
// uni.showToast({
// title: '获取用户信息失败,请重新登录',
// icon: 'none'
// })
// return
// }
await getTopUpBindDevice({ await getTopUpBindDevice({
deviceType: paymentType.value=='物业费A'?'2':'1', deviceType: paymentType.value=='水费'?'2':'1',
deviceCode: deviceNo.value, deviceCode: deviceNo.value,
openid: openid, // openid: openid,
residentUserId: uni.getStorageSync('userId') residentUserId: uni.getStorageSync('userId')
}) })
uni.hideLoading() uni.hideLoading()

View File

@@ -44,8 +44,13 @@
<view style="border-bottom: 2rpx solid #ededed;margin:10rpx 0rpx;"></view> <view style="border-bottom: 2rpx solid #ededed;margin:10rpx 0rpx;"></view>
<view class="input-section" style="display: flex;"> <view class="input-section" style="display: flex;">
<text class="amount-input" style="width: auto;margin: 0rpx 20rpx;">¥</text> <text class="amount-input" style="width: auto;margin: 0rpx 20rpx;">¥</text>
<input type="digit" v-model="payNum" class="amount-input" placeholder="点击输入缴费金额"> <input
</input> type="digit"
:value="payNum"
@input="(e) => payNum = e.detail.value"
class="amount-input"
placeholder="点击输入缴费金额"
/>
</view> </view>
<view style="border-bottom: 2rpx solid #ededed;margin:10rpx 0rpx;"></view> <view style="border-bottom: 2rpx solid #ededed;margin:10rpx 0rpx;"></view>
<view class="arrears-row" v-if="outstandingPayment==true"> <view class="arrears-row" v-if="outstandingPayment==true">
@@ -57,7 +62,6 @@
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<!-- 2. 缴费成功页 --> <!-- 2. 缴费成功页 -->
@@ -98,29 +102,18 @@
<script setup> <script setup>
import { import {
ref, ref,
reactive, reactive
onMounted,
computed
} from 'vue' } from 'vue'
import { import {
onShow, onShow,
onReady, onLoad
onReachBottom,
onLoad,
onUnload,
onPullDownRefresh
} from '@dcloudio/uni-app' } from '@dcloudio/uni-app'
import { import {
getTopUp, getPushSingle
getToWxPay, } from '/pageSubPack/api/api.js'
getopenIdByCode,
postSubscribeAuth
} from '/pageSubPack/api/apiSub.js'
// 响应式数据 // 响应式数据
const statusBarHeight = ref(20)
const outstandingPayment = ref(true) const outstandingPayment = ref(true)
const storageValue = uni.getStorageSync('arrearsPayment') const storageValue = uni.getStorageSync('arrearsPayment')
const paymentItem = reactive(typeof storageValue === 'object' && storageValue !== null ? storageValue : {}) const paymentItem = reactive(typeof storageValue === 'object' && storageValue !== null ? storageValue : {})
@@ -132,7 +125,15 @@
// 页面加载时初始化数据 // 页面加载时初始化数据
onLoad(() => { onLoad(() => {
initPaymentData() initPaymentData()
checkAllSubscribeStatus() })
// 从支付收银台返回时检查支付结果
onShow(() => {
const paySuccess = uni.getStorageSync('paySuccess')
if (paySuccess) {
uni.removeStorageSync('paySuccess')
currentStep.value = 2
}
}) })
// 初始化缴费数据 // 初始化缴费数据
@@ -159,7 +160,7 @@
}); });
} }
// 立即缴费 // 立即缴费 — 跳转到支付收银台选择支付方式
const handlePay = () => { const handlePay = () => {
if (!payNum.value || Number(payNum.value) <= 0) { if (!payNum.value || Number(payNum.value) <= 0) {
uni.showToast({ uni.showToast({
@@ -168,235 +169,31 @@
}) })
return return
} }
requestPayOrder() uni.setStorageSync('payData', {
amount: payNum.value,
deviceCode: paymentItem.deviceCode,
type: paymentItem.type,
name: paymentItem.name,
fullAddress: paymentItem.fullAddress
})
uni.navigateTo({ url: '/pageSubPack/payment-list/yinlianPayTn' })
} }
// 统一下单后后端返回的支付参数
const payInfo = ref({
appId: '', // 公众号/小程序ID
timeStamp: '', // 时间戳
nonceStr: '', // 随机串
package: '', // 数据包 如 prepay_id=xxx
signType: 'MD5', // 签名方式
paySign: '' // 签名
})
// 1. 先请求后端接口生成预支付订单 // 缴费成功推送通知
const requestPayOrder = async () => { const sendPaySuccessPush = () => {
try { const userId = uni.getStorageSync('userId')
uni.showLoading({ if (userId) {
title: '发起支付中' getPushSingle({
}) userId: userId,
channel: 'resident',
// // 获取 openid title: '缴费成功',
// const loginRes = await wx.login() content: `您已成功缴纳${paymentItem.type || ''}费用 ¥${payNum.value || payAmount.value}`
// if (!loginRes.code) { }).catch(err => {
// uni.hideLoading() console.log('推送发送失败', err)
// uni.showToast({
// title: '登录失败',
// icon: 'none'
// })
// return
// }
// // 用 code 换 openid
// const openIdRes = await getopenIdByCode({
// code: loginRes.code
// })
// if (openIdRes.code !== 200 || !openIdRes.data) {
// uni.hideLoading()
// uni.showToast({
// title: '获取openid失败',
// icon: 'none'
// })
// return
// }
// const openid = openIdRes.data
const openid = uni.getStorageSync('openid')
// 调用充值接口创建订单
console.log('1111111111', paymentItem);
const topUpRes = await getTopUp({
residentUserId: uni.getStorageSync('userId'),
rechargeAmount: payNum.value,
money: payNum.value || payAmount.value,
deviceCode: paymentItem.deviceCode,
// type: paymentItem.type == '物业费A' ? '2' : paymentItem.type == '物业费B' ? '1' : ''
type:'2'
})
uni.hideLoading()
const topUpData = topUpRes
console.log(topUpData);
if (topUpData.code !== 200) {
uni.showToast({
title: topUpData.msg || '下单失败',
icon: 'none'
})
return
}
// 调用微信支付接口获取支付参数
const payRes = await getToWxPay({
orderId: topUpData.data.orderId,
openid: openid,
// rechargeAmount: payNum.value || payAmount.value,
// type: paymentItem.type == '物业费A' ? '2' : paymentItem.type == '物业费B' ? '1' : ''
})
if (payRes.code !== 200) {
uni.showToast({
title: payRes.msg || '获取支付参数失败',
icon: 'none'
})
return
}
const payData = payRes.data
console.log('payData', payData);
// 赋值支付参数
payInfo.value = {
appId: payData.appId,
timeStamp: payData.timeStamp,
nonceStr: payData.nonceStr,
package: payData.package.startsWith('prepay_id=') ? payData.package : 'prepay_id=' + payData
.package,
signType: payData.signType,
paySign: payData.paySign
}
// 2. 调起微信支付
wx.requestPayment({
...payInfo.value,
success(res) {
console.log('支付成功', res)
currentStep.value = 2
},
fail(err) {
console.log('支付失败', err)
uni.showToast({
title: '支付取消或失败',
icon: 'none'
})
}
})
handleWaterElecSubscribe()
} catch (err) {
uni.hideLoading()
console.log('请求异常', err)
uni.showToast({
title: '支付请求异常',
icon: 'none'
}) })
} }
} }
// 【双模板ID】你提供的 物业费A+物业费B 催缴模板
const TEMPLATE_IDS = {
water: 'DowYnoGKNtl_eYycRCq-nt7DAoFjH7aVcGUQciZl1v0',
elec: 'PE7Neemv0z77JnBIPmb-Qg2Q3pJSUDGaILCryFCxmaw'
}
// 转成数组微信API要求
const TEMPLATE_ID_ARRAY = Object.values(TEMPLATE_IDS)
// 1. 检测 物业费A+物业费B 订阅状态
const checkAllSubscribeStatus = () => {
uni.getSetting({
withSubscriptions: true,
success: (res) => {
const itemSettings = res.subscriptionsSetting?.itemSettings || {}
console.log('物业费A订阅状态', itemSettings[TEMPLATE_IDS.water])
console.log('物业费B订阅状态', itemSettings[TEMPLATE_IDS.elec])
}
})
}
// 2. 点击开启订阅(主方法)
const handleWaterElecSubscribe = () => {
uni.getSetting({
withSubscriptions: true,
success: (res) => {
const itemSettings = res.subscriptionsSetting?.itemSettings || {}
const waterStatus = itemSettings[TEMPLATE_IDS.water]
const elecStatus = itemSettings[TEMPLATE_IDS.elec]
// 如果任意一个被永久拒绝 → 引导去设置
if ((waterStatus === 'reject' || waterStatus === 'ban') ||
(elecStatus === 'reject' || elecStatus === 'ban')) {
uni.showModal({
title: '开启消息通知',
content: '请前往设置页打开物业费A/物业费B提醒开关',
confirmText: '去设置',
success: (modalRes) => {
if (modalRes.confirm) uni.openSetting()
}
})
return
}
// 正常弹出授权框
requestMultiSubscribe()
}
})
}
// 3. 调用微信授权(根据类型传对应模板)
const requestMultiSubscribe = () => {
const tmplIds = paymentItem.type == '物业费A' ? [TEMPLATE_IDS.water] : paymentItem.type == '物业费B' ? [TEMPLATE_IDS.elec] : TEMPLATE_ID_ARRAY
uni.requestSubscribeMessage({
tmplIds: tmplIds,
success: async (res) => {
console.log('双模板授权结果:', res)
let successCount = 0
// 物业费A授权成功
if (res[TEMPLATE_IDS.water] === 'accept') successCount++
// 物业费B授权成功
if (res[TEMPLATE_IDS.elec] === 'accept') successCount++
if (successCount > 0) {
uni.showToast({
title: `已开启${successCount}项提醒`,
icon: 'success'
})
// 保存用户openid到后端
await saveUserSubscribe()
} else {
uni.showToast({
title: '已取消授权',
icon: 'none'
})
}
},
fail: () => {
uni.showToast({
title: '授权失败',
icon: 'none'
})
}
})
}
// 4. 传给后端:保存订阅信息
const saveUserSubscribe = async () => {
const res = await postSubscribeAuth({
openid: uni.getStorageSync('openid'),
templateIds: paymentItem.type == '物业费A' ? [TEMPLATE_IDS.water] : paymentItem.type == '物业费B' ? [TEMPLATE_IDS.elec] : TEMPLATE_ID_ARRAY,
// deviceCode: paymentItem.deviceCode,
// deviceType: paymentItem.type == '物业费A' ? '2' : paymentItem.type == '物业费B' ? '1' : ''
})
if (res.data == 200) {
console.log('111111111111111', res)
} else {
uni.showToast({
title: `${res.msg}`,
icon: 'none'
})
}
}
// 返回缴费列表 // 返回缴费列表
const handleBackToList = () => { const handleBackToList = () => {
uni.redirectTo({ uni.redirectTo({
@@ -764,6 +561,65 @@
margin-bottom: 150rpx; margin-bottom: 150rpx;
} }
/* 支付方式选择 */
.pay-method-section {
margin-top: 30rpx;
padding: 0 20rpx;
}
.pay-method-title {
font-size: 30rpx;
color: #333;
font-weight: 600;
margin-bottom: 20rpx;
display: block;
}
.pay-method-list {
display: flex;
flex-direction: column;
gap: 20rpx;
}
.pay-method-item {
display: flex;
align-items: center;
padding: 24rpx 30rpx;
background: #fff;
border-radius: 12rpx;
border: 2rpx solid #ededed;
}
.pay-method-item.active {
border-color: #1677ff;
background: #f0f7ff;
}
.pay-icon {
width: 48rpx;
height: 48rpx;
margin-right: 20rpx;
}
.pay-name {
flex: 1;
font-size: 30rpx;
color: #333;
}
.pay-check {
width: 32rpx;
height: 32rpx;
border-radius: 50%;
background: #1677ff;
position: relative;
}
.pay-check::after {
content: '';
position: absolute;
left: 10rpx;
top: 6rpx;
width: 8rpx;
height: 14rpx;
border: 2rpx solid #fff;
border-left: none;
border-top: none;
transform: rotate(45deg);
}
/* 核心:欠费金额行样式 */ /* 核心:欠费金额行样式 */
.arrears-row { .arrears-row {
display: flex; display: flex;

View File

@@ -14,9 +14,9 @@
<view class="bill-item" @click="goToBill(item)" v-for="item,index in paymentList" :key="index"> <view class="bill-item" @click="goToBill(item)" v-for="item,index in paymentList" :key="index">
<image class="billIcon" src="https://wuyeadmin.bugtc.com/images/propertyImgs/water.png" <image class="billIcon" src="https://wuyeadmin.bugtc.com/images/propertyImgs/water.png"
v-if="item.type=='物业费A'"></image> v-if="item.type=='水费'"></image>
<image class="billIcon" src="https://wuyeadmin.bugtc.com/images/propertyImgs/electric.png" <image class="billIcon" src="https://wuyeadmin.bugtc.com/images/propertyImgs/electric.png"
v-if="item.type=='物业费B'"></image> v-if="item.type=='电费'"></image>
<view class="bill-info"> <view class="bill-info">
<view class="bill-title">{{item.type}} <view class="bill-title">{{item.type}}
<view class="bill-status debt" v-if="item.balance<0">已欠费</view> <view class="bill-status debt" v-if="item.balance<0">已欠费</view>
@@ -80,7 +80,6 @@
import { import {
getTopUpSelectByResident, getTopUpSelectByResident,
getopenIdByCode,
postInsertOpenId, postInsertOpenId,
postSubscribeAuth postSubscribeAuth
} from '/pageSubPack/api/apiSub.js' } from '/pageSubPack/api/apiSub.js'
@@ -105,7 +104,7 @@
// }, // },
// { // {
// id: 3, // id: 3,
// name: '物业费B', // name: '电费',
// status: '已欠费', // status: '已欠费',
// address: '山东省日照市东港区桂花园别墅2号楼2层', // address: '山东省日照市东港区桂花园别墅2号楼2层',
// icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/electric.png", // icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/electric.png",
@@ -120,26 +119,25 @@
// iconClass: "gas" // iconClass: "gas"
// }, // },
{ {
name: "物业费A", name: "水费",
type: "water", type: "water",
icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/water.png", icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/water.png",
iconClass: "water" iconClass: "water"
}, },
{
name: "电费",
type: "electric",
icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/electric.png",
iconClass: "electric"
},
// { // {
// name: "物业", // name: "物业",
// type: "property", // type: "property",
// icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/property.png", // icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/property.png",
// iconClass: "property" // iconClass: "property"
// }, // },
// { // {
// name: "物业费B", // name: "车位费",
// type: "electric",
// icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/electric.png",
// iconClass: "electric"
// },
// {
// name: "车位",
// type: "parking", // type: "parking",
// icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/parkingIcon.png", // icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/parkingIcon.png",
// iconClass: "parking" // iconClass: "parking"
@@ -147,34 +145,18 @@
]) ])
const postOpenId = async () => { const postOpenId = async () => {
// 获取 openid // App 端直接从本地存储获取 openid
try { try {
const loginRes = await wx.login() const openid = uni.getStorageSync('openid')
if (!loginRes.code) { if (!openid) {
uni.hideLoading()
uni.showToast({ uni.showToast({
title: '登录失败', title: '请先登录',
icon: 'none' icon: 'none'
}) })
return return
} }
// 用 code 换 openid
const openIdRes = await getopenIdByCode({
code: loginRes.code
})
if (openIdRes.code !== 200 || !openIdRes.data) {
uni.hideLoading()
uni.showToast({
title: '获取openid失败',
icon: 'none'
})
return
}
const openid = openIdRes.data
uni.setStorageSync('openid', openid)
await postInsertOpenId({ await postInsertOpenId({
openid: uni.getStorageSync('openid'), openid: openid,
residentUserId: uni.getStorageSync('userId') residentUserId: uni.getStorageSync('userId')
}) })
} catch (err) { } catch (err) {
@@ -247,7 +229,7 @@
uni.redirectTo({ uni.redirectTo({
url: '/pageSubPack/payment-list/selectPaymentEntity' url: '/pageSubPack/payment-list/selectPaymentEntity'
}) })
} else if (type.name == '物业费A' || type.name == '物业费B') { } else if (type.name == '水费' || type.name == '电费') {
uni.redirectTo({ uni.redirectTo({
url: '/pageSubPack/payment-list/addHydropower' url: '/pageSubPack/payment-list/addHydropower'
}) })
@@ -425,23 +407,28 @@
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: flex-start; justify-content: flex-start;
gap: 26rpx; /* gap: 26rpx; */
} }
.grid-item { .grid-item {
width: calc(25% - 50rpx); width: calc(25% - 60rpx);
background-color: #F6F9FE; background-color: #F6F9FE;
border-radius: 12rpx; border-radius: 12rpx;
padding: 20rpx; padding: 20rpx;
margin-bottom: 20rpx; margin-bottom: 20rpx;
margin-left: 20rpx;
display: flex; display: flex;
align-items: center; align-items: center;
flex-direction: column; flex-direction: column;
} }
/* 每行第 1 个 item 清除左边距,保证对齐 */
.grid-item:nth-child(4n+1) {
margin-left: 0;
}
.icon-box { .icon-box {
width: 88rpx; width: 52rpx;
height: 88rpx; height: 52rpx;
border-radius: 50%; border-radius: 50%;
display: flex; display: flex;
align-items: center; align-items: center;

View File

@@ -187,7 +187,11 @@
})) }))
} }
} catch (e) { } catch (e) {
console.error('获取房屋列表失败', e) uni.showToast({
title:e.msg || '获取房屋列表失败',
icon:'none'
})
// console.error('获取房屋列表失败', e)
} }
} }
@@ -376,7 +380,7 @@
} }
} catch (e) { } catch (e) {
uni.hideLoading(); uni.hideLoading();
uni.showToast({ title: '网络异常,请重试', icon: 'none' }); uni.showToast({ title: e.msg || '网络异常,请重试', icon: 'none' });
} }
}; };

View File

@@ -392,6 +392,12 @@
"navigationBarTitleText": "", "navigationBarTitleText": "",
"navigationStyle": "custom" "navigationStyle": "custom"
} }
}, {
"path": "yinlianPayTn",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom"
}
} }
] ]

View File

@@ -184,6 +184,7 @@ const statusBarHeight = ref(0)
const bannerList = ref([]) const bannerList = ref([])
const noticeText = ref('暂无公告') const noticeText = ref('暂无公告')
const noticeId = ref('') const noticeId = ref('')
const lastUserId = ref('') // 用于检测是否切换账号
// =======方法======= // =======方法=======
// 格式化时间 // 格式化时间
@@ -276,9 +277,37 @@ const getNoticeData = async() =>{
} }
} }
onShow(() =>{ // 刷新所有数据(提取公共方法)
}) const refreshAllData = () => {
const token = uni.getStorageSync('token') || '';
const currentVillageId = uni.getStorageSync('currentVillageId');
if (token && currentVillageId && currentVillageId !== '0' && currentVillageId !== 0) {
getCurrentCommunityData();
}
getNoticeData()
getNewActivityList()
getbannarData()
}
onShow(() => {
const currentUserId = uni.getStorageSync('userId') || ''
// 检测到切换账号:重置数据并重新加载
if (lastUserId.value && lastUserId.value !== currentUserId) {
// 切换账号时重置页面数据
currentCommunity.value = '请认证小区'
currentVillageId.value = ''
activityList.value = []
bannerList.value = []
noticeText.value = '暂无公告'
noticeId.value = ''
refreshAllData()
}
// 首次显示 或 非切换账号的普通返回,也刷新数据
else {
refreshAllData()
}
lastUserId.value = currentUserId
})
onLoad(() => { onLoad(() => {
const info = uni.getSystemInfoSync() const info = uni.getSystemInfoSync()
@@ -287,15 +316,11 @@ onLoad(() => {
// 绑定全局事件监听 // 绑定全局事件监听
uni.$on('confirm', slelctHomeData) uni.$on('confirm', slelctHomeData)
// 页面加载时先判断是否有token有则获取认证小区 // 记录当前用户ID用于 onShow 中检测是否切换账号
const token = uni.getStorageSync('token') || ''; lastUserId.value = uni.getStorageSync('userId') || ''
const currentVillageId = uni.getStorageSync('currentVillageId');
if (token && currentVillageId && currentVillageId !== '0' && currentVillageId !== 0) { // 页面加载时刷新数据
getCurrentCommunityData(); // 加载时获取认证小区 refreshAllData()
}
getNoticeData()
getNewActivityList()
getbannarData()
}) })
// 页面销毁时移除监听(防止内存泄漏) // 页面销毁时移除监听(防止内存泄漏)

View File

@@ -6,7 +6,7 @@
<scroll-view class="page" scroll-y> <scroll-view class="page" scroll-y>
<view class="topBox"> <view class="topBox">
<view class="name"> <view class="name">
<image src="http://47.104.199.163:9090/images/propertyImgs/touxiang.jpg" class="img" /> <image :src="avatar" class="img" />
<span style="padding: 5rpx 5rpx;display: flex;flex-direction: column;line-height: 60rpx;"> <span style="padding: 5rpx 5rpx;display: flex;flex-direction: column;line-height: 60rpx;">
<span style="font-size: 36rpx;font-weight: 600;"> <span style="font-size: 36rpx;font-weight: 600;">
{{loginName}} {{loginName}}
@@ -28,7 +28,7 @@
style="align-self: flex-end;font-size: 24rpx;vertical-align: baseline;">{{ item.desc }}</span></span> style="align-self: flex-end;font-size: 24rpx;vertical-align: baseline;">{{ item.desc }}</span></span>
</view> </view>
<view class="item-arrow"></view> <view class="item-arrow"></view>
<!-- <image src="http://47.104.199.163:9090/images/propertyImgs/arrow-right.png" class="arrow-icon" /> --> <!-- <image src="https://wuyeadmin.bugtc.com/images/propertyImgs/arrow-right.png" class="arrow-icon" /> -->
</view> </view>
</view> </view>
@@ -46,32 +46,35 @@
import { import {
ref ref
} from 'vue'; } from 'vue';
import { getUserProfile } from '../../pageSubPack/api/apiSub';
import {onShow} from '@dcloudio/uni-app'
const list = ref([{ const list = ref([{
icon: "http://47.104.199.163:9090/images/propertyImgs/house.png", icon:'https://wuyeadmin.bugtc.com/images/propertyImgs/house.png',
title: "我的房屋" title: "我的房屋"
}, },
{ {
icon: "http://47.104.199.163:9090/images/propertyImgs/user.png", icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/user.png",
title: "住户管理", title: "住户管理",
// desc: "您可以在这里添加家人、朋友、租客~" // desc: "您可以在这里添加家人、朋友、租客~"
}, },
{ {
icon: "http://47.104.199.163:9090/images/propertyImgs/parking.png", icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/parking.png",
title: "我的车位" title: "我的车位"
}, },
{ {
icon: "http://47.104.199.163:9090/images/propertyImgs/car.png", icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/car.png",
title: "我的车辆" title: "我的车辆"
}, },
{ {
icon: "http://47.104.199.163:9090/images/propertyImgs/setting.png", icon: "https://wuyeadmin.bugtc.com/images/propertyImgs/setting.png",
title: "设置" title: "设置"
} }
]) ])
const loginName = ref("wangh") const loginName = ref("")
const phoneNum = ref('156*****1212') const phoneNum = ref('')
const avatar = ref('')
// --方法---- // --方法----
const goToDetail = () => { const goToDetail = () => {
@@ -79,6 +82,19 @@
url: '/pageSubPack/notice-list/noticeListDetails' url: '/pageSubPack/notice-list/noticeListDetails'
}) })
} }
// 获取用户账号信息
function getUserInfoData(){
getUserProfile().then(res => {
if (res.code === 200 && res.data) {
avatar.value = res.data.avatar
loginName.value = res.data.username
phoneNum.value = res.data.phone || ''
}
})
}
// 返回 // 返回
const onItemClick = (item) => { const onItemClick = (item) => {
if (item.title == '我的房屋') { if (item.title == '我的房屋') {
@@ -121,6 +137,9 @@
complete: () => {} complete: () => {}
}); });
} }
onShow(() =>{
getUserInfoData()
})
</script> </script>