From 7c3e22324fdd9ffbbe8ffed3d5539a7f65697b1c Mon Sep 17 00:00:00 2001 From: tangxinyue <524779910@qq.com> Date: Fri, 16 Jan 2026 18:52:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=96=B0=E5=A2=9E=E8=B4=A6?= =?UTF-8?q?=E5=8D=95=E4=B8=AD=E7=9A=84=E7=9B=91=E5=90=AC=E5=99=A8=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E9=87=8D=E5=A4=8D=E7=9B=91=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/bill/add-bill/add-bill.vue | 23 +++++++++++++++-------- store/index.js | 9 ++++++--- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/pages/bill/add-bill/add-bill.vue b/pages/bill/add-bill/add-bill.vue index 488f388..76f8454 100644 --- a/pages/bill/add-bill/add-bill.vue +++ b/pages/bill/add-bill/add-bill.vue @@ -277,6 +277,7 @@ import { import { onLoad, onShow, + onUnload } from '@dcloudio/uni-app' @@ -477,13 +478,20 @@ onShow(() => { plus.navigator.setStatusBarStyle("dark"); }, 500); // #endif + // #endif +}) + +onUnload(() => { + uni.$off('addBillDetail') }) onLoad((option) => { - uni.$on('addBill', (res) => { - console.log("addBill", res); + uni.$on('addBillDetail', (res) => { + console.log("billData", billData.value); billData.value.imgUrl = res.url billData.value.name = res.name + const billDataList = JSON.parse(JSON.stringify(getBillList())) + console.log("billDataList", billDataList) console.log(billData.value) }); console.log(option) @@ -491,9 +499,10 @@ onLoad((option) => { data.type = option.type data.navBar.title = '新增余额明细' } - if (option.id) { + if (option.id && isEdit) { + console.log('编辑页面') // 获取当前id账单 - const existingBill = getBillList().find(b => b.id === option.id) + const existingBill = JSON.parse(JSON.stringify(getBillList())).find(b => b.id === option.id) if (existingBill) { //表单赋值 billData.value.id = existingBill.id @@ -662,7 +671,7 @@ const setItemInfoValue = (id) => { * 切换头像 */ const changeAvatar = () => { - util.goPage("/pages/common/hot-icon/hot-icon" + "?page=addBill") + util.goPage("/pages/common/hot-icon/hot-icon" + "?page=addBillDetail") } @@ -771,6 +780,7 @@ const validateBillData = () => { */ const onRightClick = async () => { if (!validateBillData()) return + console.log("1111111111"); if (billData.value.merchantOption.serviceDetail && billData.value.merchantOption.serviceDetailInfo && billData.value.merchantOption.serviceDetailInfo.imgUrl) { const url = await saveAndDisplayImage(billData.value.merchantOption.serviceDetailInfo.imgUrl) billData.value.merchantOption.serviceDetailInfo.imgUrl = url @@ -794,9 +804,6 @@ const onRightClick = async () => { billData.value.payMethod = "余额" } addBill(billData.value) - const allBillList = getBillList() - - console.log("getBillDataList------", allBillList) } uni.showToast({ diff --git a/store/index.js b/store/index.js index 6f47cb7..9e606b5 100644 --- a/store/index.js +++ b/store/index.js @@ -35,7 +35,7 @@ export const store = reactive({ }, // 账单列表 - billList: storage.get('bill_list') || [], + billList: JSON.parse(JSON.stringify(storage.get('bill_list') || [])), }); @@ -83,7 +83,7 @@ export const useStore = () => { }; const getBillList = () => { - return store.billList + return JSON.parse(JSON.stringify(store.billList)) } @@ -107,7 +107,10 @@ export const useStore = () => { // 监听billList改变自动保存 watch( () => store.billList, - (newValue) => storage.set('bill_list', newValue), + (newValue) => { + console.log("store.billList") + storage.set('bill_list', newValue) + }, { deep: true } );