移除新增账单中的监听器避免重复监听
This commit is contained in:
parent
79862a3fa0
commit
7c3e22324f
|
|
@ -277,6 +277,7 @@ import {
|
||||||
import {
|
import {
|
||||||
onLoad,
|
onLoad,
|
||||||
onShow,
|
onShow,
|
||||||
|
onUnload
|
||||||
} from '@dcloudio/uni-app'
|
} from '@dcloudio/uni-app'
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -477,13 +478,20 @@ onShow(() => {
|
||||||
plus.navigator.setStatusBarStyle("dark");
|
plus.navigator.setStatusBarStyle("dark");
|
||||||
}, 500);
|
}, 500);
|
||||||
// #endif
|
// #endif
|
||||||
|
// #endif
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnload(() => {
|
||||||
|
uni.$off('addBillDetail')
|
||||||
})
|
})
|
||||||
|
|
||||||
onLoad((option) => {
|
onLoad((option) => {
|
||||||
uni.$on('addBill', (res) => {
|
uni.$on('addBillDetail', (res) => {
|
||||||
console.log("addBill", res);
|
console.log("billData", billData.value);
|
||||||
billData.value.imgUrl = res.url
|
billData.value.imgUrl = res.url
|
||||||
billData.value.name = res.name
|
billData.value.name = res.name
|
||||||
|
const billDataList = JSON.parse(JSON.stringify(getBillList()))
|
||||||
|
console.log("billDataList", billDataList)
|
||||||
console.log(billData.value)
|
console.log(billData.value)
|
||||||
});
|
});
|
||||||
console.log(option)
|
console.log(option)
|
||||||
|
|
@ -491,9 +499,10 @@ onLoad((option) => {
|
||||||
data.type = option.type
|
data.type = option.type
|
||||||
data.navBar.title = '新增余额明细'
|
data.navBar.title = '新增余额明细'
|
||||||
}
|
}
|
||||||
if (option.id) {
|
if (option.id && isEdit) {
|
||||||
|
console.log('编辑页面')
|
||||||
// 获取当前id账单
|
// 获取当前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) {
|
if (existingBill) {
|
||||||
//表单赋值
|
//表单赋值
|
||||||
billData.value.id = existingBill.id
|
billData.value.id = existingBill.id
|
||||||
|
|
@ -662,7 +671,7 @@ const setItemInfoValue = (id) => {
|
||||||
* 切换头像
|
* 切换头像
|
||||||
*/
|
*/
|
||||||
const changeAvatar = () => {
|
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 () => {
|
const onRightClick = async () => {
|
||||||
if (!validateBillData()) return
|
if (!validateBillData()) return
|
||||||
|
console.log("1111111111");
|
||||||
if (billData.value.merchantOption.serviceDetail && billData.value.merchantOption.serviceDetailInfo && billData.value.merchantOption.serviceDetailInfo.imgUrl) {
|
if (billData.value.merchantOption.serviceDetail && billData.value.merchantOption.serviceDetailInfo && billData.value.merchantOption.serviceDetailInfo.imgUrl) {
|
||||||
const url = await saveAndDisplayImage(billData.value.merchantOption.serviceDetailInfo.imgUrl)
|
const url = await saveAndDisplayImage(billData.value.merchantOption.serviceDetailInfo.imgUrl)
|
||||||
billData.value.merchantOption.serviceDetailInfo.imgUrl = url
|
billData.value.merchantOption.serviceDetailInfo.imgUrl = url
|
||||||
|
|
@ -794,9 +804,6 @@ const onRightClick = async () => {
|
||||||
billData.value.payMethod = "余额"
|
billData.value.payMethod = "余额"
|
||||||
}
|
}
|
||||||
addBill(billData.value)
|
addBill(billData.value)
|
||||||
const allBillList = getBillList()
|
|
||||||
|
|
||||||
console.log("getBillDataList------", allBillList)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
|
|
|
||||||
|
|
@ -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 = () => {
|
const getBillList = () => {
|
||||||
return store.billList
|
return JSON.parse(JSON.stringify(store.billList))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -107,7 +107,10 @@ export const useStore = () => {
|
||||||
// 监听billList改变自动保存
|
// 监听billList改变自动保存
|
||||||
watch(
|
watch(
|
||||||
() => store.billList,
|
() => store.billList,
|
||||||
(newValue) => storage.set('bill_list', newValue),
|
(newValue) => {
|
||||||
|
console.log("store.billList")
|
||||||
|
storage.set('bill_list', newValue)
|
||||||
|
},
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue