rename page to thisPage; add thisPage() function to quickly get this page in console at debugging

This commit is contained in:
陆柯 2021-07-16 09:36:11 +08:00
parent 5e5f0e1bdc
commit e54f0d78df

View File

@ -299,7 +299,7 @@ module.exports = {
// setBarTitles 迁移到 unip.i18n 库,通过 this.$store.commit('i18n/setBarTitles') 来调用
// setBarTitles({ windowTitle, pageTitle } = {}) {
// let page = this.$store ? this : getCurrentPages()[getCurrentPages().length - 1]
// let page = getCurrentPages()[getCurrentPages().length - 1]
// uni.setNavigationBarTitle({ title: pageTitle || page.i18nText[page.$store.state.i18n.mylang].tPageTitle })
// // #ifdef H5
// document.title = windowTitle || page.$store.getters['i18n/getAppName'] // 必须放在 setNavigationBarTitle 之后,否则会被其覆盖掉。
@ -307,14 +307,18 @@ module.exports = {
// if (page.$store._mutations['i18n/setTabbar']) page.$store.commit('i18n/setTabbar') // 必须要在有 tab 的页面里重置才有效果
// },
thisPage(){
return getCurrentPages()[getCurrentPages().length - 1]
},
localizeText(i18nText) {
// 如果直接挂载到 Vue.prototype 下,那么可以直接访问 this.i18nText。但如果通过 this.$T.localeText 访问,那么 this.i18nText 就报错了。因此安全起见,先获取当前 page
const page = getCurrentPages()[getCurrentPages().length - 1]
if (page.$store?.state?.i18n?.mylang) {
if (typeof(i18nText)==='object' && i18nText && i18nText[page.$store.state.i18n.mylang]){
return i18nText[page.$store.state.i18n.mylang]
const thisPage = getCurrentPages()[getCurrentPages().length - 1]
if (thisPage.$store?.state?.i18n?.mylang) {
if (typeof(i18nText)==='object' && i18nText && i18nText[thisPage.$store.state.i18n.mylang]){
return i18nText[thisPage.$store.state.i18n.mylang]
}else if (typeof(i18nText)==='undefined') {
return page.i18nText[page.$store.state.i18n.mylang]
return thisPage.i18nText[thisPage.$store.state.i18n.mylang]
}
}
return ''
@ -322,8 +326,8 @@ module.exports = {
localeText() {
// 如果直接挂载到 Vue.prototype 下,那么可以直接访问 this.i18nText。但如果通过 this.$T.localeText 访问,那么 this.i18nText 就报错了。因此安全起见,先获取当前 page
let page = getCurrentPages()[getCurrentPages().length - 1]
return page.i18nText[page.$store.state.i18n.mylang]
let thisPage = getCurrentPages()[getCurrentPages().length - 1]
return thisPage.i18nText[thisPage.$store.state.i18n.mylang]
},
formatMoney(value, decimal) {